diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d8d0bfbc..11800578f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +## [0.1.5] - 2020-12-09 +### Changed +- Updated `depend/zcash` to new version including a precompute API + ## [0.1.4] - 2020-11-17 ### Changed - switched from bindgen `0.55` to bindgen `0.54` to avoid a dependency @@ -33,7 +37,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated `bindgen` to a non yanked version -[Unreleased]: https://github.com/ZcashFoundation/zcash_script/compare/v0.1.4...HEAD +[Unreleased]: https://github.com/ZcashFoundation/zcash_script/compare/v0.1.5...HEAD +[0.1.5]: https://github.com/ZcashFoundation/zcash_script/compare/v0.1.4...v0.1.5 [0.1.4]: https://github.com/ZcashFoundation/zcash_script/compare/v0.1.3...v0.1.4 [0.1.3]: https://github.com/ZcashFoundation/zcash_script/compare/v0.1.2...v0.1.3 [0.1.2]: https://github.com/ZcashFoundation/zcash_script/compare/v0.1.1...v0.1.2 diff --git a/Cargo.toml b/Cargo.toml index 354c70f30..7a16841ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zcash_script" -version = "0.1.5-alpha.0" +version = "0.1.6-alpha.0" authors = ["Tamas Blummer ", "Zcash Foundation "] license = "Apache-2.0" readme = "README.md" diff --git a/README.md b/README.md index ff8bb83a0..a66dd6750 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,11 @@ [docs-url]: https://docs.rs/zcash_script Rust bindings to the ECC's `zcash_script` c++ library. + +### Updating `depend/zcash` + +To pull in recent changes from the upstream repo run the following: + +```console +git subtree pull -P depend/zcash --squash +``` diff --git a/depend/zcash/.gitignore b/depend/zcash/.gitignore index f566c0f5f..802519c4a 100644 --- a/depend/zcash/.gitignore +++ b/depend/zcash/.gitignore @@ -7,6 +7,7 @@ src/zcash-cli src/zcash-gtest src/zcash-tx src/test/test_bitcoin +zcutil/bin/ *zcashTest.pk *zcashTest.vk @@ -116,5 +117,6 @@ libzcash_script.pc contrib/debian/files contrib/debian/substvars +src/fuzzing/*/input src/fuzzing/*/output src/fuzz.cpp diff --git a/depend/zcash/COPYING b/depend/zcash/COPYING index f8fc375ea..139db196b 100644 --- a/depend/zcash/COPYING +++ b/depend/zcash/COPYING @@ -29,11 +29,6 @@ source code is not considered a derived work of these Autoconf macros or of the dependencies. For further details see 'contrib/debian/copyright'. -This product includes software developed by the OpenSSL Project for use in the -OpenSSL Toolkit (https://www.openssl.org/). This product includes cryptographic -software written by Eric Young (eay@cryptsoft.com). - - Although almost all of the Zcash code is licensed under "permissive" open source licenses, users and distributors should note that when built using the default build options, Zcash depends on Oracle Berkeley DB 6.2.x, which is licensed diff --git a/depend/zcash/Cargo.lock b/depend/zcash/Cargo.lock index 7c53cc712..2f769ae6f 100644 --- a/depend/zcash/Cargo.lock +++ b/depend/zcash/Cargo.lock @@ -2,64 +2,76 @@ # It is not intended for manual editing. [[package]] name = "aes" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" +checksum = "dd2bc6d3f370b5666245ff421e231cba4353df936e26986d2918e61a8fd6aef6" dependencies = [ "aes-soft", "aesni", - "block-cipher-trait", + "block-cipher", ] [[package]] name = "aes-soft" -version = "0.3.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" +checksum = "63dd91889c49327ad7ef3b500fd1109dbd3c509a03db0d4a9ce413b79f575cb6" dependencies = [ - "block-cipher-trait", + "block-cipher", "byteorder", "opaque-debug", ] [[package]] name = "aesni" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +checksum = "0a6fe808308bb07d393e2ea47780043ec47683fcf19cf5efc8ca51c50cc8c68a" dependencies = [ - "block-cipher-trait", + "block-cipher", "opaque-debug", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + [[package]] name = "arrayref" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" [[package]] name = "arrayvec" -version = "0.4.11" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" -dependencies = [ - "nodrop", -] +checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" [[package]] name = "autocfg" -version = "0.1.6" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base64" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "bellman" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2be536193834affcd8a6d362963e66dec8c6bca4d2009f5bac55ec9002776ff2" +checksum = "cc584b78257b78b8359e751b140921df627ae90087818da4d316b1e83523c0c5" dependencies = [ - "bit-vec", + "bitvec", "blake2s_simd", "byteorder", "crossbeam", @@ -70,29 +82,35 @@ dependencies = [ "num_cpus", "pairing", "rand_core", + "subtle", ] [[package]] name = "bigint" -version = "4.4.1" +version = "4.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282" +checksum = "c0e8c8a600052b52482eff2cf4d810e462fdff1f656ac1ecb6232132a1ed7def" dependencies = [ "byteorder", "crunchy", ] [[package]] -name = "bit-vec" -version = "0.4.4" +name = "bitvec" +version = "0.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f" +checksum = "1d2838fdd79e8776dbe07a106c784b0f8dda571a21b2750a092cc4cbaa653c8e" +dependencies = [ + "funty", + "radium", + "wyz", +] [[package]] name = "blake2b_simd" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5850aeee1552f495dd0250014cf64b82b7c8879a89d83b33bbdace2cc4f63182" +checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" dependencies = [ "arrayref", "arrayvec", @@ -101,9 +119,9 @@ dependencies = [ [[package]] name = "blake2s_simd" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "979da0ce13c897d6be19e005ea77ac12b0fea0157aeeee7feb8c49f91386f0ea" +checksum = "ab9e07352b829279624ceb7c64adb4f585dacdb81d35cafae81139ccd617cf44" dependencies = [ "arrayref", "arrayvec", @@ -112,73 +130,94 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.7.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "block-padding", - "byte-tools", - "byteorder", "generic-array", ] [[package]] -name = "block-cipher-trait" -version = "0.6.2" +name = "block-cipher" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" +checksum = "f337a3e6da609650eb74e02bc9fac7b735049f7623ab12f2e4c719316fcc7e80" dependencies = [ "generic-array", ] [[package]] -name = "block-padding" -version = "0.1.4" +name = "block-modes" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" +checksum = "0c9b14fd8a4739e6548d4b6018696cf991dcf8c6effd9ef9eb33b29b8a650972" dependencies = [ - "byte-tools", + "block-cipher", + "block-padding", ] [[package]] -name = "byte-tools" +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + +[[package]] +name = "bls12_381" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +checksum = "4caf0101205582491f772d60a6fcb6bcec19963e68209cb631851eeadb01421f" +dependencies = [ + "bitvec", + "ff", + "group", + "pairing", + "rand_core", + "subtle", +] [[package]] name = "byteorder" -version = "1.3.2" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] -name = "c2-chacha" -version = "0.2.2" +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "chrono" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" dependencies = [ - "lazy_static", - "ppv-lite86", + "libc", + "num-integer", + "num-traits", + "time", + "winapi", ] [[package]] -name = "cfg-if" -version = "0.1.9" +name = "constant_time_eq" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] -name = "constant_time_eq" -version = "0.1.4" +name = "cpuid-bool" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120" +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "crossbeam" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d818a4990769aac0c7ff1360e233ef3a41adcb009ebb2036bf6915eb0f6b23c" +checksum = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e" dependencies = [ "cfg-if", "crossbeam-channel", @@ -190,52 +229,58 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.3.9" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" +checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" dependencies = [ "crossbeam-utils", + "maybe-uninit", ] [[package]] name = "crossbeam-deque" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" +checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" dependencies = [ "crossbeam-epoch", "crossbeam-utils", + "maybe-uninit", ] [[package]] name = "crossbeam-epoch" -version = "0.7.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ - "arrayvec", + "autocfg", "cfg-if", "crossbeam-utils", "lazy_static", + "maybe-uninit", "memoffset", "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.1.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" +checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" dependencies = [ + "cfg-if", "crossbeam-utils", + "maybe-uninit", ] [[package]] name = "crossbeam-utils" -version = "0.6.6" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ + "autocfg", "cfg-if", "lazy_static", ] @@ -254,18 +299,18 @@ checksum = "2f855e87e75a4799e18b8529178adcde6fd4f97c1449ff4821e747ff728bb102" [[package]] name = "crypto_api_chachapoly" -version = "0.2.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b2ad7cab08fd71addba81df5077c49df208effdfb3118a1519f9cdeac5aaf2" +checksum = "d930b6a026ce9d358a17f9c9046c55d90b14bb847f36b6ebb6b19365d4feffb8" dependencies = [ "crypto_api", ] [[package]] name = "curve25519-dalek" -version = "2.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5" +checksum = "c8492de420e9e60bc9a1d66e2dbb91825390b738a388606600663fc529b4b307" dependencies = [ "byteorder", "digest", @@ -276,31 +321,41 @@ dependencies = [ [[package]] name = "digest" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ "generic-array", ] [[package]] name = "directories" -version = "1.0.2" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fed639d60b58d0f53498ab13d26f621fd77569cc6edb031f4cc36a2ad9da0f" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f" +checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" dependencies = [ "libc", + "redox_users", "winapi", ] [[package]] name = "ed25519-zebra" -version = "2.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beeba2b02b91dc7cc2d1f42c96b9e82db4cd20ad1c326f1dbf64ac8943c7bf32" +checksum = "0a128b76af6dd4b427e34a6fd43dc78dbfe73672ec41ff615a2414c1a0ad0409" dependencies = [ "curve25519-dalek", - "hex 0.4.2", + "hex", "rand_core", "serde", "sha2", @@ -308,54 +363,50 @@ dependencies = [ ] [[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "ff" -version = "0.6.0" +name = "equihash" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4b967a3ee6ae993f0094174257d404a5818f58be79d67a1aea1ec8996d28906" +checksum = "4127688f6177e3f57521881cb1cfd90d1228214f9dc43b8efe6f6c6948cd8280" dependencies = [ + "blake2b_simd", "byteorder", - "ff_derive", - "rand_core", ] [[package]] -name = "ff_derive" -version = "0.6.0" +name = "ff" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3776aaf60a45037a9c3cabdd8542b38693acaa3e241ff957181b72579d29feb" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" dependencies = [ - "num-bigint", - "num-integer", - "num-traits", - "proc-macro2", - "quote", - "syn", + "bitvec", + "rand_core", + "subtle", ] [[package]] name = "fpe" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21988a326139165b75e3196bc6962ca638e5fb0c95102fbf152a3743174b01e4" +checksum = "ef2196a22f6d98bbde79ae510eb4f397bd446cfbd6c26425e25ec81442a31bab" dependencies = [ "aes", - "byteorder", + "block-modes", "num-bigint", "num-integer", "num-traits", ] +[[package]] +name = "funty" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ba62103ce691c2fd80fbae2213dfdda9ce60804973ac6b6e97de818ea7f52c8" + [[package]] name = "futures" -version = "0.1.29" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +checksum = "4c7e4c2612746b0df8fed4ce0c69156021b704c9aefa360311c04e6e9e002eed" [[package]] name = "futures-cpupool" @@ -369,40 +420,45 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.12.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" dependencies = [ "typenum", + "version_check", ] [[package]] name = "getrandom" -version = "0.1.12" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] name = "group" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f15be54742789e36f03307c8fdf0621201e1345e94f1387282024178b5e9ec8c" +checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" dependencies = [ + "byteorder", "ff", - "rand", - "rand_xorshift", + "rand_core", + "subtle", ] [[package]] -name = "hex" -version = "0.3.2" +name = "hermit-abi" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" +checksum = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151" +dependencies = [ + "libc", +] [[package]] name = "hex" @@ -410,6 +466,20 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +[[package]] +name = "jubjub" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "620638af3b80d23f4df0cae21e3cc9809ac8826767f345066f010bcea66a2c55" +dependencies = [ + "bitvec", + "bls12_381", + "ff", + "group", + "rand_core", + "subtle", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -418,9 +488,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.62" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" +checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" [[package]] name = "librustzcash" @@ -429,12 +499,17 @@ dependencies = [ "bellman", "blake2b_simd", "blake2s_simd", + "bls12_381", "ed25519-zebra", - "ff", - "lazy_static", + "group", + "jubjub", "libc", - "pairing", "rand_core", + "subtle", + "tracing", + "tracing-appender", + "tracing-core", + "tracing-subscriber", "zcash_history", "zcash_primitives", "zcash_proofs", @@ -442,33 +517,42 @@ dependencies = [ [[package]] name = "log" -version = "0.4.8" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" dependencies = [ "cfg-if", ] [[package]] -name = "memoffset" -version = "0.5.1" +name = "matchers" +version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "rustc_version", + "regex-automata", ] [[package]] -name = "nodrop" -version = "0.1.13" +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "memoffset" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +dependencies = [ + "autocfg", +] [[package]] name = "num-bigint" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9c3f34cdd24f334cb265d9bf8bfa8a241920d026916785747a92f0e55541a1a" +checksum = "b7f3fc75e3697059fb1bc465e3d8cca6cf92f56854f201158b3f9c77d5a3cfa0" dependencies = [ "autocfg", "num-integer", @@ -477,9 +561,9 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.41" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" +checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" dependencies = [ "autocfg", "num-traits", @@ -487,69 +571,80 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.8" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" +checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.10.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ + "hermit-abi", "libc", ] [[package]] name = "opaque-debug" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "pairing" -version = "0.16.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8290dea210a712682cd65031dc2b34fd132cf2729def3df7ee08f0737ff5ed6" +checksum = "4f702cdbee9e0a6272452c20dec82465bc821116598b4eeb63e9a71a69dbf7fd" dependencies = [ - "byteorder", "ff", "group", - "rand_core", ] +[[package]] +name = "pin-project-lite" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e555d9e657502182ac97b539fb3dae8b79cda19e3e4f8ffb5e8de4f18df93c95" + [[package]] name = "ppv-lite86" -version = "0.2.5" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" +checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" [[package]] name = "proc-macro2" -version = "1.0.3" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.2" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64de9a0c5361e034f1aefc9f71a86871ec870e766fe31a009734a989b329286a" + [[package]] name = "rand" -version = "0.7.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom", "libc", @@ -560,11 +655,11 @@ dependencies = [ [[package]] name = "rand_chacha" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ - "c2-chacha", + "ppv-lite86", "rand_core", ] @@ -587,58 +682,79 @@ dependencies = [ ] [[package]] -name = "rand_xorshift" -version = "0.2.0" +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "redox_users" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "rand_core", + "getrandom", + "redox_syscall", + "rust-argon2", ] [[package]] -name = "rustc_version" -version = "0.2.3" +name = "regex" +version = "1.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" dependencies = [ - "semver", + "regex-syntax", ] [[package]] -name = "scopeguard" -version = "1.0.0" +name = "regex-automata" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +dependencies = [ + "byteorder", + "regex-syntax", +] [[package]] -name = "semver" -version = "0.9.0" +name = "regex-syntax" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" + +[[package]] +name = "rust-argon2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" dependencies = [ - "semver-parser", + "base64", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils", ] [[package]] -name = "semver-parser" -version = "0.7.0" +name = "scopeguard" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.113" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6135c78461981c79497158ef777264c51d9d0f4f3fc3a4d22b915900e42dac6a" +checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.113" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93c5eaa17d0954cb481cdcfffe9d84fcfa7a1a9f2349271e678677be4c26ae31" +checksum = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8" dependencies = [ "proc-macro2", "quote", @@ -647,27 +763,37 @@ dependencies = [ [[package]] name = "sha2" -version = "0.8.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" +checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1" dependencies = [ "block-buffer", + "cfg-if", + "cpuid-bool", "digest", - "fake-simd", "opaque-debug", ] +[[package]] +name = "sharded-slab" +version = "0.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06d5a3f5166fb5b42a5439f2eee8b9de149e235961e3eb21c5808fc3ea17ff3e" +dependencies = [ + "lazy_static", +] + [[package]] name = "subtle" -version = "2.2.3" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "502d53007c02d7605a05df1c1a73ee436952781653da5d0bf57ad608f66932c1" +checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" [[package]] name = "syn" -version = "1.0.11" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" +checksum = "9c51d92969d209b54a98397e1b91c8ae82d8c87a7bb87df0b29aa2ad81454228" dependencies = [ "proc-macro2", "quote", @@ -694,29 +820,120 @@ dependencies = [ "syn", ] +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + +[[package]] +name = "tracing" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-appender" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aa52d56cc0d79ab604e8a022a1cebc4de33cf09dc9933c94353bea2e00d6e88" +dependencies = [ + "chrono", + "crossbeam-channel", + "tracing-subscriber", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82bb5079aa76438620837198db8a5c529fb9878c730bc2b28179b0241cf04c10" +dependencies = [ + "ansi_term", + "chrono", + "lazy_static", + "matchers", + "regex", + "sharded-slab", + "thread_local", + "tracing-core", +] + [[package]] name = "typenum" -version = "1.11.2" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" [[package]] name = "unicode-xid" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.7.0" +version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "winapi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", @@ -734,6 +951,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zcash_history" version = "0.2.0" @@ -747,44 +970,52 @@ dependencies = [ [[package]] name = "zcash_primitives" -version = "0.2.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f33b9e4f3b4db97234fc79ea67b12f2d5778bde8f3eab6dbba52eb54c596585" +checksum = "45ab71b5765cb89a423e3a2f0de596dc8e581bf5bbf9d933bc8c22833886d13c" dependencies = [ "aes", + "bitvec", "blake2b_simd", "blake2s_simd", + "bls12_381", "byteorder", "crypto_api_chachapoly", + "equihash", "ff", "fpe", - "hex 0.3.2", + "group", + "hex", + "jubjub", "lazy_static", "log", - "pairing", "rand", "rand_core", "sha2", + "subtle", ] [[package]] name = "zcash_proofs" -version = "0.2.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2011f78f14d5121248d3b4f921434207b1d870fb3bf2efc7d784cae79b19bfbc" +checksum = "902845afb8636c4f88c0fd2a8bf338b645474488cb60676194fbf7713a3b9cc0" dependencies = [ "bellman", "blake2b_simd", + "bls12_381", "byteorder", "directories", "ff", - "pairing", + "group", + "jubjub", + "lazy_static", "rand_core", "zcash_primitives", ] [[package]] name = "zeroize" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" +checksum = "05f33972566adbd2d3588b0491eb94b98b43695c4ef897903470ede4f3f5a28a" diff --git a/depend/zcash/Makefile.am b/depend/zcash/Makefile.am index 352537f6e..d987063d2 100644 --- a/depend/zcash/Makefile.am +++ b/depend/zcash/Makefile.am @@ -33,18 +33,8 @@ COVERAGE_INFO = baseline_filtered_combined.info baseline.info \ zcash-gtest.info zcash-gtest_filtered.info zcash-gtest_coverage.info dist-hook: - -$(MAKE) -C $(top_distdir)/src/leveldb clean - -$(MAKE) -C $(top_distdir)/src/secp256k1 distclean -$(GIT) archive --format=tar HEAD -- src/clientversion.cpp | $(AMTAR) -C $(top_distdir) -xf - -distcheck-hook: - $(MKDIR_P) $(top_distdir)/_build/src/leveldb - cp -rf $(top_srcdir)/src/leveldb/* $(top_distdir)/_build/src/leveldb/ - -$(MAKE) -C $(top_distdir)/_build/src/leveldb clean - -distcleancheck: - @: - $(if $(findstring src/,$(MAKECMDGOALS)),$(MAKECMDGOALS), none): FORCE $(MAKE) -C src $(patsubst src/%,%,$@) @@ -61,10 +51,10 @@ baseline.info: baseline_filtered.info: baseline.info $(LCOV) -r $< "/usr/include/*" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/*.h" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/boost/*" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/gmock/*" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/gtest/*" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/*.h" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/boost/*" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/gmock/*" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/gtest/*" \ "$(abs_builddir)/src/gtest/*" \ "$(abs_builddir)/src/test/*" \ "$(abs_builddir)/src/wallet/gtest/*" \ @@ -76,10 +66,10 @@ leveldb_baseline.info: baseline_filtered.info leveldb_baseline_filtered.info: leveldb_baseline.info $(LCOV) -r $< "/usr/include/*" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/*.h" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/boost/*" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/gmock/*" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/gtest/*" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/*.h" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/boost/*" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/gmock/*" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/gtest/*" \ "$(abs_builddir)/src/gtest/*" \ "$(abs_builddir)/src/test/*" \ "$(abs_builddir)/src/wallet/gtest/*" \ @@ -97,10 +87,10 @@ test_bitcoin.info: baseline_filtered_combined.info test_bitcoin_filtered.info: test_bitcoin.info $(LCOV) -r $< "/usr/include/*" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/*.h" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/boost/*" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/gmock/*" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/gtest/*" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/*.h" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/boost/*" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/gmock/*" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/gtest/*" \ "$(abs_builddir)/src/gtest/*" \ "$(abs_builddir)/src/test/*" \ "$(abs_builddir)/src/wallet/gtest/*" \ @@ -115,10 +105,10 @@ zcash-gtest.info: baseline_filtered_combined.info zcash-gtest_filtered.info: zcash-gtest.info $(LCOV) -r $< "/usr/include/*" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/*.h" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/boost/*" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/gmock/*" \ - "$(abs_builddir)/depends/x86_64-unknown-linux-gnu/include/gtest/*" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/*.h" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/boost/*" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/gmock/*" \ + "$(abs_builddir)/depends/x86_64-pc-linux-gnu/include/gtest/*" \ "$(abs_builddir)/src/gtest/*" \ "$(abs_builddir)/src/test/*" \ "$(abs_builddir)/src/wallet/gtest/*" \ @@ -169,3 +159,7 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-man clean-local: rm -rf test_bitcoin.coverage/ zcash-gtest.coverage/ total.coverage/ rm -rf afl-temp + +distclean-local: + rm -f zcutil/bin/db_* + rmdir zcutil/bin 2>/dev/null || true diff --git a/depend/zcash/README.md b/depend/zcash/README.md index f0df2bc97..0d4138cbb 100644 --- a/depend/zcash/README.md +++ b/depend/zcash/README.md @@ -1,4 +1,4 @@ -Zcash 3.1.0-rc2 +Zcash 4.0.0 =========== @@ -56,7 +56,9 @@ Build Zcash along with most dependencies from source by running the following co ./zcutil/build.sh -j$(nproc) ``` -Currently, Zcash is only officially supported on Debian and Ubuntu. +Currently, Zcash is only officially supported on Debian and Ubuntu. See the +[Debian / Ubuntu build](https://zcash.readthedocs.io/en/latest/rtd_pages/Debian-Ubuntu-build.html) +for detailed instructions. License ------- diff --git a/depend/zcash/code_of_conduct.md b/depend/zcash/code_of_conduct.md index ceb5f506d..07e751de7 100644 --- a/depend/zcash/code_of_conduct.md +++ b/depend/zcash/code_of_conduct.md @@ -13,6 +13,10 @@ body size, race, ethnicity, age, religion, or nationality. Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery +* The use of language or imagery that originates with, or has been + adopted as a symbol or "dog-whistle" for, any of: right-wing extremism, + anti-Semitism, Islamophobia, white supremacism, eugenics, homophobia, or + transphobia (whether or not the use by itself falls into those categories) * Personal attacks * Trolling or insulting/derogatory comments * Public or private harassment diff --git a/depend/zcash/configure.ac b/depend/zcash/configure.ac index d611fe1c7..ea1722627 100644 --- a/depend/zcash/configure.ac +++ b/depend/zcash/configure.ac @@ -1,9 +1,9 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) -define(_CLIENT_VERSION_MAJOR, 3) -define(_CLIENT_VERSION_MINOR, 1) +define(_CLIENT_VERSION_MAJOR, 4) +define(_CLIENT_VERSION_MINOR, 0) define(_CLIENT_VERSION_REVISION, 0) -define(_CLIENT_VERSION_BUILD, 26) +define(_CLIENT_VERSION_BUILD, 50) define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50))) define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1))) define(_CLIENT_VERSION_IS_RELEASE, true) @@ -62,7 +62,7 @@ case $host in ;; esac dnl Require C++17 compiler (no GNU extensions) -AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory], [nodefault]) +AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory]) dnl Check if -latomic is required for CHECK_ATOMIC @@ -105,12 +105,6 @@ AC_ARG_ENABLE([mining], [enable_mining=$enableval], [enable_mining=yes]) -AC_ARG_ENABLE([proton], - [AS_HELP_STRING([--enable-proton], - [enable Proton (AMQP messaging) (default is no)])], - [use_proton=$enableval], - [use_proton=no]) - AC_ARG_ENABLE(tests, AS_HELP_STRING([--disable-tests],[do not compile tests (default is to compile)]), [use_tests=$enableval], @@ -298,7 +292,36 @@ if test "x$CXXFLAGS_overridden" = "xno"; then AX_CHECK_COMPILE_FLAG([-Wself-assign],[CXXFLAGS="$CXXFLAGS -Wno-self-assign"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wdeprecated-register],[CXXFLAGS="$CXXFLAGS -Wno-deprecated-register"],,[[$CXXFLAG_WERROR]]) -fi + + # Check for optional instruction set support. Enabling these does _not_ imply that all code will + # be compiled with them, rather that specific objects/libs may use them after checking for runtime + # compatibility. + AX_CHECK_COMPILE_FLAG([-msse4.2],[[SSE42_CXXFLAGS="-msse4.2"]],,[[$CXXFLAG_WERROR]]) + +fi + +TEMP_CXXFLAGS="$CXXFLAGS" +CXXFLAGS="$CXXFLAGS $SSE42_CXXFLAGS" +AC_MSG_CHECKING(for assembler crc32 support) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #if defined(_MSC_VER) + #include + #elif defined(__GNUC__) && defined(__SSE4_2__) + #include + #endif + ]],[[ + uint64_t l = 0; + l = _mm_crc32_u8(l, 0); + l = _mm_crc32_u32(l, 0); + l = _mm_crc32_u64(l, 0); + return l; + ]])], + [ AC_MSG_RESULT(yes); enable_hwcrc32=yes], + [ AC_MSG_RESULT(no)] +) +CXXFLAGS="$TEMP_CXXFLAGS" + CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS" AC_ARG_WITH([utils], @@ -362,7 +385,7 @@ case $host in fi CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB" - LEVELDB_TARGET_FLAGS="TARGET_OS=OS_WINDOWS_CROSSCOMPILE" + LEVELDB_TARGET_FLAGS="-DOS_WINDOWS" if test "x$CXXFLAGS_overridden" = "xno"; then CXXFLAGS="$CXXFLAGS -w" fi @@ -384,7 +407,7 @@ case $host in ;; *darwin*) TARGET_OS=darwin - LEVELDB_TARGET_FLAGS="TARGET_OS=Darwin" + LEVELDB_TARGET_FLAGS="-DOS_MACOSX" if test x$cross_compiling != xyes; then BUILD_OS=darwin AC_CHECK_PROG([PORT],port, port) @@ -406,12 +429,7 @@ case $host in dnl It's safe to add these paths even if the functionality is disabled by dnl the user (--without-wallet for example). - openssl_prefix=`$BREW --prefix openssl 2>/dev/null` bdb_prefix=`$BREW --prefix berkeley-db4 2>/dev/null` - if test x$openssl_prefix != x; then - PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH" - export PKG_CONFIG_PATH - fi if test x$bdb_prefix != x; then CPPFLAGS="$CPPFLAGS -I$bdb_prefix/include" LIBS="$LIBS -L$bdb_prefix/lib" @@ -441,9 +459,11 @@ case $host in OBJCXXFLAGS="$CXXFLAGS" ;; *linux*) - TARGET_OS=linux + LEVELDB_TARGET_FLAGS="-DOS_LINUX" ;; *) + OTHER_OS=`echo ${host_os} | awk '{print toupper($0)}'` + LEVELDB_TARGET_FLAGS="-DOS_${OTHER_OS}" ;; esac @@ -666,31 +686,6 @@ if test x$enable_wallet != xno; then BITCOIN_FIND_BDB62 fi -dnl Check Qpid Proton headers and library exist -if test x$use_proton = xyes; then - AC_CHECK_HEADERS([proton/connection.hpp], - [], - [AC_MSG_WARN([Proton headers not found, disabling Proton support]) - use_proton=no]) - AC_CHECK_LIB([qpid-proton-cpp-static], [main], - [PROTON_LIBS="-lqpid-proton-cpp-static"], - [AC_MSG_WARN([Proton qpid-proton-cpp-static library not found, disabling Proton support]) - use_proton=no]) - AC_CHECK_LIB([qpid-proton-core-static], [main], - [PROTON_LIBS+=" -lqpid-proton-core-static"], - [AC_MSG_WARN([Proton qpid-proton-core-static library not found, disabling Proton support]) - use_proton=no]) - AC_CHECK_LIB([qpid-proton-static], [main], - [PROTON_LIBS+=" -lqpid-proton-static"], - [AC_MSG_WARN([Proton qpid-proton-static library not found, disabling Proton support]) - use_proton=no]) -fi -if test x$use_proton = xyes; then - AC_DEFINE(ENABLE_PROTON, 1, [Define to 1 to enable Proton functions]) -else - AC_DEFINE(ENABLE_PROTON, 0, [Define to 1 to enable Proton functions]) -fi - if test x$build_bitcoin_utils$build_bitcoind$use_tests = xnonono; then use_boost=no else @@ -756,8 +751,6 @@ if test x$use_pkgconfig = xyes; then m4_ifdef( [PKG_CHECK_MODULES], [ - PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)]) - PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)]) if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests != xnononono; then PKG_CHECK_MODULES([EVENT], [libevent],, [AC_MSG_ERROR(libevent not found.)]) if test x$TARGET_OS != xwindows; then @@ -777,14 +770,6 @@ if test x$use_pkgconfig = xyes; then ] ) else - # BUG: Fix this: - echo 'BUG: configure does not yet check for the following dependencies if pkg-config is not on the system: libcrypto++' - - AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing)) - AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing)) - - AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),) - AC_CHECK_LIB([ssl], [main],SSL_LIBS=-lssl, AC_MSG_ERROR(libssl missing)) if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests != xnononono; then AC_CHECK_HEADER([event2/event.h],, AC_MSG_ERROR(libevent headers missing),) @@ -832,7 +817,7 @@ esac AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing],[CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"]) AX_CHECK_COMPILE_FLAG([-Wno-builtin-declaration-mismatch],[CXXFLAGS="$CXXFLAGS -Wno-builtin-declaration-mismatch"],,[[$CXXFLAG_WERROR]]) -LIBZCASH_LIBS="$BOOST_SYSTEM_LIB -lcrypto -lsodium $RUST_LIBS" +LIBZCASH_LIBS="$BOOST_SYSTEM_LIB -lsodium $RUST_LIBS" AC_MSG_CHECKING([whether to build bitcoind]) AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes]) @@ -845,7 +830,7 @@ AC_MSG_RESULT($build_bitcoin_utils) AC_MSG_CHECKING([whether to build libraries]) AM_CONDITIONAL([BUILD_BITCOIN_LIBS], [test x$build_bitcoin_libs = xyes]) if test x$build_bitcoin_libs = xyes; then - AC_DEFINE(HAVE_CONSENSUS_LIB, 1, [Define this symbol if the consensus lib has been built]) + AC_DEFINE(HAVE_SCRIPT_LIB, 1, [Define this symbol if the script lib has been built]) AC_CONFIG_FILES([libzcash_script.pc:libzcash_script.pc.in]) fi @@ -894,8 +879,6 @@ fi AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"]) -AM_CONDITIONAL([ENABLE_PROTON], [test "x$use_proton" = "xyes"]) - AC_MSG_CHECKING([whether to build test_bitcoin]) if test x$use_tests = xyes; then AC_MSG_RESULT([yes]) @@ -926,6 +909,7 @@ AM_CONDITIONAL([ENABLE_BENCH],[test x$use_bench = xyes]) AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes]) AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes]) AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes]) +AM_CONDITIONAL([ENABLE_HWCRC32],[test x$enable_hwcrc32 = xyes]) AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version]) AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version]) @@ -958,17 +942,15 @@ AC_SUBST(PIC_FLAGS) AC_SUBST(PIE_FLAGS) AC_SUBST(SANITIZER_CXXFLAGS) AC_SUBST(SANITIZER_LDFLAGS) +AC_SUBST(SSE42_CXXFLAGS) AC_SUBST(LIBTOOL_APP_LDFLAGS) AC_SUBST(BOOST_LIBS) AC_SUBST(TESTDEFS) AC_SUBST(LEVELDB_TARGET_FLAGS) -AC_SUBST(CRYPTO_LIBS) -AC_SUBST(SSL_LIBS) AC_SUBST(EVENT_LIBS) AC_SUBST(EVENT_PTHREADS_LIBS) AC_SUBST(ZMQ_LIBS) AC_SUBST(LIBZCASH_LIBS) -AC_SUBST(PROTON_LIBS) AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile src/test/buildenv.py]) AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh]) AC_CONFIG_FILES([qa/pull-tester/tests-config.sh],[chmod +x qa/pull-tester/tests-config.sh]) @@ -1015,7 +997,6 @@ esac echo echo "Options used to compile and link:" echo " with wallet = $enable_wallet" -echo " with proton = $use_proton" echo " with zmq = $use_zmq" echo " with test = $use_tests" echo " sanitizers = $use_sanitizers" diff --git a/depend/zcash/contrib/README.md b/depend/zcash/contrib/README.md index 70378d100..4ec9fffa5 100644 --- a/depend/zcash/contrib/README.md +++ b/depend/zcash/contrib/README.md @@ -6,11 +6,6 @@ Wallet Tools ### [BitRPC](/contrib/bitrpc) ### Allows for sending of all standard Bitcoin commands via RPC rather than as command line args. -### [SpendFrom](/contrib/spendfrom) ### - -Use the raw transactions API to send coins received on a particular -address (or addresses). - Repository Tools --------------------- @@ -18,9 +13,6 @@ Repository Tools Specific tools for developers working on this repository. Contains the script `github-merge.sh` for merging github pull requests securely and signing them using GPG. -### [Verify-Commits](/contrib/verify-commits) ### -Tool to verify that every merge commit was signed by a developer using the above `github-merge.sh` script. - ### [Linearize](/contrib/linearize) ### Construct a linear, no-fork, best version of the blockchain. @@ -44,18 +36,8 @@ Gavin's notes on getting gitian builds up and running using KVM. ### [Gitian-downloader](/contrib/gitian-downloader) Various PGP files of core developers. -### [MacDeploy](/contrib/macdeploy) ### -Scripts and notes for Mac builds. - Test and Verify Tools --------------------- ### [TestGen](/contrib/testgen) ### -Utilities to generate test vectors for the data-driven Bitcoin tests. - -### [Test Patches](/contrib/test-patches) ### -These patches are applied when the automated pull-tester -tests each pull and when master is tested using jenkins. - -### [Verify SF Binaries](/contrib/verifysfbinaries) ### -This script attempts to download and verify the signature file SHA256SUMS.asc from SourceForge. +Utilities to generate test vectors for the data-driven Bitcoin tests. \ No newline at end of file diff --git a/depend/zcash/contrib/amqp/amqp_sub.py b/depend/zcash/contrib/amqp/amqp_sub.py deleted file mode 100644 index 707c5f466..000000000 --- a/depend/zcash/contrib/amqp/amqp_sub.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python2 -# Copyright (c) 2017-2019 The Zcash developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or https://www.opensource.org/licenses/mit-license.php . - -# Requirements: -# pip install python-qpid-proton - -import binascii -from proton.handlers import MessagingHandler -from proton.reactor import Container - -port = 5672 - -class Server(MessagingHandler): - def __init__(self, url): - super(Server, self).__init__() - self.url = url - self.senders = {} - - def on_start(self, event): - print "Listening on:", self.url - self.container = event.container - self.acceptor = event.container.listen(self.url) - - def on_message(self, event): - m = event.message - topic = m.subject - body = m.body - sequence = str( m.properties['x-opt-sequence-number'] ) - if topic == "hashablock": - print '- HASH BLOCK ('+sequence+') -' - print binascii.hexlify(body) - elif topic == "hashtx": - print '- HASH TX ('+sequence+') -' - print binascii.hexlify(body) - elif topic == "rawblock": - print '- RAW BLOCK HEADER ('+sequence+') -' - print binascii.hexlify(body[:80]) - elif topic == "rawtx": - print '- RAW TX ('+sequence+') -' - print binascii.hexlify(body) - -try: - Container(Server("127.0.0.1:%i" % port)).run() -except KeyboardInterrupt: - pass - diff --git a/depend/zcash/contrib/ci-builders/Dockerfile-bbworker.apt b/depend/zcash/contrib/ci-builders/Dockerfile-bbworker.apt index 89e00ffb1..40ee4b8a4 100644 --- a/depend/zcash/contrib/ci-builders/Dockerfile-bbworker.apt +++ b/depend/zcash/contrib/ci-builders/Dockerfile-bbworker.apt @@ -1,6 +1,6 @@ ARG FROMBASEOS ARG FROMBASEOS_BUILD_TAG=latest -FROM electriccoinco/zcashd-build:$FROMBASEOS$FROMBASEOS_BUILD_TAG +FROM electriccoinco/zcashd-build-$FROMBASEOS$FROMBASEOS_BUILD_TAG ARG DUMBINIT_VERSION=1.2.2 RUN wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMBINIT_VERSION}/dumb-init_${DUMBINIT_VERSION}_amd64 diff --git a/depend/zcash/contrib/ci-builders/Dockerfile-bbworker.arch b/depend/zcash/contrib/ci-builders/Dockerfile-bbworker.arch index 0f81aa386..c3e6ff9d7 100644 --- a/depend/zcash/contrib/ci-builders/Dockerfile-bbworker.arch +++ b/depend/zcash/contrib/ci-builders/Dockerfile-bbworker.arch @@ -1,17 +1,4 @@ -ARG ARCHLINUX_TAG=20200205 -FROM archlinux:$ARCHLINUX_TAG - -RUN pacman -Syyu --noconfirm \ - && pacman -S --noconfirm \ - base-devel \ - git \ - python3 \ - python-pip \ - wget - -RUN wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 -RUN chmod +x /usr/bin/dumb-init -RUN python -m pip install virtualenv +FROM electriccoinco/zcashd-build-arch # Buildbot user ARG BUILDBOT_USER=zcbbworker @@ -25,15 +12,11 @@ RUN useradd --home-dir /home/$BUILDBOT_USER \ USER $BUILDBOT_USER WORKDIR /home/$BUILDBOT_USER +ADD bbworker-requirements.txt requirements.txt RUN python -m venv venv \ && . venv/bin/activate \ - && python -m pip install \ - buildbot-worker \ - pyflakes \ - pyblake2 \ - pyzmq \ - requests \ - twisted[tls] + && python -m pip install wheel \ + && python -m pip install -r requirements.txt # Buildbot worker ARG BUILDBOT_WORKER_NAME=arch-docker @@ -46,7 +29,7 @@ RUN venv/bin/buildbot-worker create-worker $BUILDBOT_WORKER_NAME \ $BUILDBOT_MASTER_HOST:$BUILDBOT_MASTER_PORT \ $BUILDBOT_WORKER_NAME $BUILDBOT_WORKER_PASS \ && echo "OS: Centos 8" > $BUILDBOT_WORKER_NAME/info/host -ADD buildbot.tac $BUILDBOT_WORKER_NAME/buildbot.tac +ADD bbworker-buildbot.tac $BUILDBOT_WORKER_NAME/buildbot.tac WORKDIR /home/$BUILDBOT_USER/$BUILDBOT_WORKER_NAME CMD ["/usr/bin/dumb-init", "../venv/bin/twistd", "--pidfile=", "-ny", "buildbot.tac"] diff --git a/depend/zcash/contrib/ci-builders/Dockerfile-bbworker.centos8 b/depend/zcash/contrib/ci-builders/Dockerfile-bbworker.centos8 index 79adaf860..fbc02101b 100644 --- a/depend/zcash/contrib/ci-builders/Dockerfile-bbworker.centos8 +++ b/depend/zcash/contrib/ci-builders/Dockerfile-bbworker.centos8 @@ -1,16 +1,4 @@ -FROM centos:8 - -RUN yum update -y \ - && dnf group install -y "Development Tools" \ - && yum install -y \ - python3 \ - python3-devel \ - wget - -RUN wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 -RUN chmod +x /usr/bin/dumb-init -RUN alternatives --set python /usr/bin/python3 \ - && python3 -m pip install virtualenv +FROM electriccoinco/zcashd-build-centos8 # Buildbot user ARG BUILDBOT_USER=zcbbworker @@ -24,15 +12,11 @@ RUN useradd --home-dir /home/$BUILDBOT_USER \ USER $BUILDBOT_USER WORKDIR /home/$BUILDBOT_USER +ADD bbworker-requirements.txt requirements.txt RUN python3 -m venv venv \ && . venv/bin/activate \ - && python3 -m pip install \ - buildbot-worker \ - pyflakes \ - pyblake2 \ - pyzmq \ - requests \ - twisted[tls] + && python -m pip install wheel \ + && python -m pip install -r requirements.txt # Buildbot worker ARG BUILDBOT_WORKER_NAME=centos8-docker @@ -45,7 +29,7 @@ RUN venv/bin/buildbot-worker create-worker $BUILDBOT_WORKER_NAME \ $BUILDBOT_MASTER_HOST:$BUILDBOT_MASTER_PORT \ $BUILDBOT_WORKER_NAME $BUILDBOT_WORKER_PASS \ && echo "OS: Centos 8" > $BUILDBOT_WORKER_NAME/info/host -ADD buildbot.tac $BUILDBOT_WORKER_NAME/buildbot.tac +ADD bbworker-buildbot.tac $BUILDBOT_WORKER_NAME/buildbot.tac WORKDIR /home/$BUILDBOT_USER/$BUILDBOT_WORKER_NAME CMD ["/usr/bin/dumb-init", "../venv/bin/twistd", "--pidfile=", "-ny", "buildbot.tac"] diff --git a/depend/zcash/contrib/ci-builders/Dockerfile-build-python.apt b/depend/zcash/contrib/ci-builders/Dockerfile-build-python.apt new file mode 100644 index 000000000..8b73e9bb7 --- /dev/null +++ b/depend/zcash/contrib/ci-builders/Dockerfile-build-python.apt @@ -0,0 +1,30 @@ +ARG FROMBASEOS +ARG FROMBASEOS_BUILD_TAG +FROM $FROMBASEOS:$FROMBASEOS_BUILD_TAG +ARG DEBIAN_FRONTEND=noninteractive + +ADD apt-package-list.txt /tmp/apt-package-list.txt +RUN apt-get update \ + && apt-get install -y $(tr "\n" " " < /tmp/apt-package-list.txt) \ + && update-alternatives --install /usr/bin/python python /usr/bin/python3 1 + +ARG PYTHONVERSION=3.7.5 +RUN apt-get install -y \ + build-essential \ + zlib1g-dev \ + libncurses5-dev \ + libgdbm-dev \ + libnss3-dev \ + libssl-dev \ + libreadline-dev \ + libffi-dev \ + curl +WORKDIR /tmp +RUN curl https://www.python.org/ftp/python/$PYTHONVERSION/Python-$PYTHONVERSION.tar.xz -o python.tar.xz \ + && tar -xf python.tar.xz \ + && cd Python-$PYTHONVERSION \ + && ./configure --enable-optimizations \ + && make -j 8 \ + && make altinstall \ + && update-alternatives --install /usr/bin/python python /usr/local/bin/python3.7 1 +RUN update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.7 1 \ No newline at end of file diff --git a/depend/zcash/contrib/ci-builders/Dockerfile-build.arch b/depend/zcash/contrib/ci-builders/Dockerfile-build.arch new file mode 100644 index 000000000..c75f5a190 --- /dev/null +++ b/depend/zcash/contrib/ci-builders/Dockerfile-build.arch @@ -0,0 +1,23 @@ +ARG ARCHLINUX_TAG +FROM archlinux:$ARCHLINUX_TAG + +RUN pacman -Syyu --noconfirm \ + && pacman -S --noconfirm \ + base-devel \ + git \ + python3 \ + python-pip \ + wget + +RUN wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 +RUN chmod +x /usr/bin/dumb-init +RUN python -m pip install virtualenv +# AUR for libtinfo5 Source: https://dev.to/cloudx/testing-our-package-build-in-the-docker-world-34p0 +RUN useradd builduser -m \ + && passwd -d builduser \ + && cd /home/builduser \ + && git clone "https://aur.archlinux.org/ncurses5-compat-libs.git" ncurses5-compat-libs \ + && chown builduser -R ncurses5-compat-libs \ + && (printf 'builduser ALL=(ALL) ALL\n' | tee -a /etc/sudoers) \ + && sudo -u builduser bash -c 'gpg --keyserver pool.sks-keyservers.net --recv-keys 702353E0F7E48EDB' \ + && sudo -u builduser bash -c 'cd ~/ncurses5-compat-libs && makepkg -si --noconfirm' \ No newline at end of file diff --git a/depend/zcash/contrib/ci-builders/Dockerfile-build.centos8 b/depend/zcash/contrib/ci-builders/Dockerfile-build.centos8 new file mode 100644 index 000000000..b5fb3eb20 --- /dev/null +++ b/depend/zcash/contrib/ci-builders/Dockerfile-build.centos8 @@ -0,0 +1,14 @@ +FROM centos:8 + +RUN yum update -y \ + && dnf group install -y "Development Tools" \ + && yum install -y \ + ncurses-compat-libs \ + python3 \ + python3-devel \ + wget + +RUN wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 +RUN chmod +x /usr/bin/dumb-init +RUN alternatives --set python /usr/bin/python3 \ + && python3 -m pip install virtualenv diff --git a/depend/zcash/contrib/ci-builders/Dockerfile-gitian.apt b/depend/zcash/contrib/ci-builders/Dockerfile-gitian.apt index 247262c17..5ca2a8757 100644 --- a/depend/zcash/contrib/ci-builders/Dockerfile-gitian.apt +++ b/depend/zcash/contrib/ci-builders/Dockerfile-gitian.apt @@ -1,6 +1,6 @@ ARG FROMBASEOS ARG FROMBASEOS_BUILD_TAG=latest -FROM electriccoinco/zcashd-build:$FROMBASEOS$FROMBASEOS_BUILD_TAG +FROM electriccoinco/zcashd-build-$FROMBASEOS$FROMBASEOS_BUILD_TAG RUN useradd -ms /bin/bash -U debian USER debian:debian diff --git a/depend/zcash/contrib/ci-builders/apt-package-list.txt b/depend/zcash/contrib/ci-builders/apt-package-list.txt index c1725b15a..c7813dfdc 100644 --- a/depend/zcash/contrib/ci-builders/apt-package-list.txt +++ b/depend/zcash/contrib/ci-builders/apt-package-list.txt @@ -3,11 +3,17 @@ bsdmainutils build-essential cmake curl +g++-aarch64-linux-gnu git lcov +libcap-dev libffi-dev +libtinfo5 libtool libssl-dev +libz-dev +libbz2-dev +mingw-w64 pkg-config python3 python3-dev diff --git a/depend/zcash/contrib/ci-builders/bbworker-requirements.txt b/depend/zcash/contrib/ci-builders/bbworker-requirements.txt index d5492aaa8..012268cae 100644 --- a/depend/zcash/contrib/ci-builders/bbworker-requirements.txt +++ b/depend/zcash/contrib/ci-builders/bbworker-requirements.txt @@ -1,7 +1,6 @@ buildbot-worker pyblake2 pyflakes -python-qpid-proton pyutil pyzmq requests diff --git a/depend/zcash/contrib/ci-builders/docker-build.sh b/depend/zcash/contrib/ci-builders/docker-build.sh old mode 100644 new mode 100755 index 6a37027af..232c5b9b1 --- a/depend/zcash/contrib/ci-builders/docker-build.sh +++ b/depend/zcash/contrib/ci-builders/docker-build.sh @@ -1,37 +1,49 @@ -# Debian -docker build . -f Dockerfile-build.apt --build-arg FROMBASEOS=debian --build-arg FROMBASEOS_BUILD_TAG=9 -t electriccoinco/zcashd-build:debian9 -docker build . -f Dockerfile-build.apt --build-arg FROMBASEOS=debian --build-arg FROMBASEOS_BUILD_TAG=10 -t electriccoinco/zcashd-build:debian10 - -docker push electriccoinco/zcashd-build:debian9 -docker push electriccoinco/zcashd-build:debian10 - -docker build . -f Dockerfile-gitian.apt --build-arg FROMBASEOS=debian --build-arg FROMBASEOS_BUILD_TAG=9 -t electriccoinco/zcashd-gitian:debian9 -docker build . -f Dockerfile-gitian.apt --build-arg FROMBASEOS=debian --build-arg FROMBASEOS_BUILD_TAG=10 -t electriccoinco/zcashd-gitian:debian10 - -docker push electriccoinco/zcashd-gitian:debian9 -docker push electriccoinco/zcashd-gitian:debian10 - -docker build . -f Dockerfile-bbworker.apt --build-arg BASEOS=debian --build-arg FROMBASEOS=debian --build-arg FROMBASEOS_BUILD_TAG=9 -t electriccoinco/zcashd-bbworker:debian9 -docker build . -f Dockerfile-bbworker.apt --build-arg BASEOS=debian --build-arg FROMBASEOS=debian --build-arg FROMBASEOS_BUILD_TAG=10 -t electriccoinco/zcashd-bbworker:debian10 - -docker push electriccoinco/zcashd-bbworker:debian9 -docker push electriccoinco/zcashd-bbworker:debian10 - -# Ubuntu -docker build . -f Dockerfile-build.apt --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=18.04 -t electriccoinco/zcashd-build:ubuntu18.04 -docker build . -f Dockerfile-build.apt --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=20.04 -t electriccoinco/zcashd-build:ubuntu20.04 - -docker push electriccoinco/zcashd-build:ubuntu18.04 -docker push electriccoinco/zcashd-build:ubuntu20.04 - -docker build . -f Dockerfile-gitian.apt --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=18.04 -t electriccoinco/zcashd-gitian:ubuntu18.04 -docker build . -f Dockerfile-gitian.apt --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=20.04 -t electriccoinco/zcashd-gitian:ubuntu20.04 - -docker push electriccoinco/zcashd-gitian:ubuntu18.04 -docker push electriccoinco/zcashd-gitian:ubuntu20.04 - -docker build . -f Dockerfile-bbworker.apt --build-arg BASEOS=ubuntu --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=18.04 -t electriccoinco/zcashd-bbworker:ubuntu18.04 -docker build . -f Dockerfile-bbworker.apt --build-arg BASEOS=ubuntu --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=20.04 -t electriccoinco/zcashd-bbworker:ubuntu20.04 - -docker push electriccoinco/zcashd-bbworker:ubuntu18.04 -docker push electriccoinco/zcashd-bbworker:ubuntu20.04 \ No newline at end of file +#!/bin/bash +set -exo pipefail +# Debian 9 +docker build . -f Dockerfile-build-python.apt --build-arg FROMBASEOS=debian --build-arg FROMBASEOS_BUILD_TAG=9 -t electriccoinco/zcashd-build-debian9 +docker push electriccoinco/zcashd-build-debian9 +docker build . -f Dockerfile-bbworker.apt --build-arg BASEOS=debian --build-arg FROMBASEOS=debian --build-arg FROMBASEOS_BUILD_TAG=9 -t electriccoinco/zcashd-bbworker-debian9 +docker push electriccoinco/zcashd-bbworker-debian9 + +# Debian 10 +docker build . -f Dockerfile-build.apt --build-arg FROMBASEOS=debian --build-arg FROMBASEOS_BUILD_TAG=10 -t electriccoinco/zcashd-build-debian10 +docker push electriccoinco/zcashd-build-debian10 +docker build . -f Dockerfile-gitian.apt --build-arg FROMBASEOS=debian --build-arg FROMBASEOS_BUILD_TAG=10 -t electriccoinco/zcashd-gitian-debian10 +docker push electriccoinco/zcashd-gitian-debian10 +docker build . -f Dockerfile-bbworker.apt --build-arg BASEOS=debian --build-arg FROMBASEOS=debian --build-arg FROMBASEOS_BUILD_TAG=10 -t electriccoinco/zcashd-bbworker-debian10 +docker push electriccoinco/zcashd-bbworker-debian10 + +# Ubuntu 16.04 +docker build . -f Dockerfile-build.apt --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=16.04 -t electriccoinco/zcashd-build-ubuntu1604 +docker push electriccoinco/zcashd-build-ubuntu1604 +docker build . -f Dockerfile-gitian.apt --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=1604 -t electriccoinco/zcashd-gitian-ubuntu1604 +docker push electriccoinco/zcashd-gitian-ubuntu1604 +docker build . -f Dockerfile-bbworker.apt --build-arg BASEOS=ubuntu --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=1604 -t electriccoinco/zcashd-bbworker-ubuntu1604 +docker push electriccoinco/zcashd-bbworker-ubuntu1604 + +# Ubuntu 18.04, 20.04 +docker build . -f Dockerfile-build.apt --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=18.04 -t electriccoinco/zcashd-build-ubuntu1804 +docker build . -f Dockerfile-build.apt --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=20.04 -t electriccoinco/zcashd-build-ubuntu2004 +docker push electriccoinco/zcashd-build-ubuntu1804 +docker push electriccoinco/zcashd-build-ubuntu2004 +docker build . -f Dockerfile-gitian.apt --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=1804 -t electriccoinco/zcashd-gitian-ubuntu1804 +docker build . -f Dockerfile-gitian.apt --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=2004 -t electriccoinco/zcashd-gitian-ubuntu2004 +docker push electriccoinco/zcashd-gitian-ubuntu1804 +docker push electriccoinco/zcashd-gitian-ubuntu2004 +docker build . -f Dockerfile-bbworker.apt --build-arg BASEOS=ubuntu --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=1804 -t electriccoinco/zcashd-bbworker-ubuntu1804 +docker build . -f Dockerfile-bbworker.apt --build-arg BASEOS=ubuntu --build-arg FROMBASEOS=ubuntu --build-arg FROMBASEOS_BUILD_TAG=2004 -t electriccoinco/zcashd-bbworker-ubuntu2004 +docker push electriccoinco/zcashd-bbworker-ubuntu1804 +docker push electriccoinco/zcashd-bbworker-ubuntu2004 + +# Centos8 +docker build . -f Dockerfile-build.centos8 -t electriccoinco/zcashd-build-centos8 +docker build . -f Dockerfile-bbworker.centos8 -t electriccoinco/zcashd-bbworker-centos8 +docker push electriccoinco/zcashd-build-centos8 +docker push electriccoinco/zcashd-bbworker-centos8 + +# Arch 20200908 +docker build . -f Dockerfile-build.arch --build-arg ARCHLINUX_TAG=20200908 -t electriccoinco/zcashd-build-arch +docker build . -f Dockerfile-bbworker.arch -t electriccoinco/zcashd-bbworker-arch +docker push electriccoinco/zcashd-build-arch +docker push electriccoinco/zcashd-bbworker-arch \ No newline at end of file diff --git a/depend/zcash/contrib/debian/changelog b/depend/zcash/contrib/debian/changelog index 69866a770..adff3fe11 100644 --- a/depend/zcash/contrib/debian/changelog +++ b/depend/zcash/contrib/debian/changelog @@ -1,3 +1,21 @@ +zcash (4.0.0) stable; urgency=medium + + * 4.0.0 release. + + -- Electric Coin Company Tue, 01 Sep 2020 13:31:19 -0600 + +zcash (4.0.0~rc1) stable; urgency=medium + + * 4.0.0-rc1 release. + + -- Electric Coin Company Wed, 26 Aug 2020 10:17:07 -0600 + +zcash (3.1.0) stable; urgency=medium + + * 3.1.0 release. + + -- Electric Coin Company Tue, 28 Jul 2020 07:02:06 +0800 + zcash (3.1.0~rc2) stable; urgency=medium * 3.1.0-rc2 release. diff --git a/depend/zcash/contrib/debian/copyright b/depend/zcash/contrib/debian/copyright index dfc6da637..6a142c3a1 100644 --- a/depend/zcash/contrib/debian/copyright +++ b/depend/zcash/contrib/debian/copyright @@ -54,6 +54,8 @@ Copyright: 2008, Benjamin Kosnik 2014-2015, Google Inc.; contributed by Alexey Sokolov 2015, Paul Norman 2015, Moritz Klammler + 2016, 2018 Krzesimir Nowak + 2019 Enji Cooper License: GNU-All-permissive-License Files: build-aux/m4/ax_gcc_func_attribute.m4 @@ -77,7 +79,9 @@ Copyright: 2008, Steven G. Johnson License: GPLv3-or-later-with-Autoconf-exception Files: qa/zcash/checksec.sh -Copyright: 2009-2011, Tobias Klein +Copyright: 2014-2015, Brian Davis + 2013, Robin David + 2009-2011, Tobias Klein License: BSD-3clause-Tobias-Klein Files: depends/sources/libsodium-*.tar.gz @@ -95,10 +99,6 @@ Copyright: 1990, 2016 Oracle and/or its affiliates; 2000-2005 INRIA, France Telecom License: BDB -Files: depends/sources/openssl-*.tar.gz -Copyright: 1998-2016 The OpenSSL Project and 1995-1998 Eric Young -License: OpenSSL+SSLeay - Files: depends/sources/zeromq-*.tar.gz Copyright: 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. @@ -116,14 +116,28 @@ Files: depends/sources/google*.tar.gz Copyright: 2008 Google Inc. License: BSD-3clause-Google -Files: depends/sources/qpid-proton-*.tar.gz -Copyright: 2012-2017 The Apache Software Foundation -License: Apache-Qpid-Proton-with-BSD-Subcomponents - Files: depends/sources/utfcpp-*.tar.gz Copyright: 2006 Nemanja Trifunovic License: Boost-Software-License-1.0 +Files: src/crypto/ctaes/* +Copyright: Copyright (c) 2016 Pieter Wuille +License: Expat + +Files: src/rust/include/tracing.h + src/rust/src/tracing_ffi.rs +Copyright: Copyright (c) 2020 Jack Grigg +License: Expat + +Files: src/rust/include/tracing/map.h +Copyright: Copyright (c) 2012 William Swanson +License: Expat-with-advertising-clause + +Files: src/secp256k1/* +Copyright: Copyright (c) 2013 Pieter Wuille +License: Expat +Comment: This copyright entry excludes files explicitly listed below. + Files: src/secp256k1/build-aux/m4/ax_jni_include_dir.m4 Copyright: 2008 Don Anderson License: GNU-All-permissive-License @@ -919,128 +933,6 @@ License: BDB * THE POSSIBILITY OF SUCH DAMAGE. */ -License: OpenSSL+SSLeay - The OpenSSL toolkit stays under a dual license, i.e. both the conditions of - the OpenSSL License and the original SSLeay license apply to the toolkit. - See below for the actual license texts. - . - OpenSSL License - --------------- - . - /* ==================================================================== - * Copyright (c) 1998-2016 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - . - Original SSLeay License - ----------------------- - . - /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - License: BSD-3clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -1195,222 +1087,6 @@ Comment: You should have received a copy of the GNU General Public License along with this program. If not, see . -License: Apache-Qpid-Proton-with-BSD-Subcomponents - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - . - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - . - 1. Definitions. - . - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - . - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - . - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - . - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - . - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - . - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - . - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - . - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - . - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - . - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - . - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - . - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - . - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - . - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - . - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - . - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - . - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - . - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - . - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - . - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - . - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - . - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - . - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - . - END OF TERMS AND CONDITIONS - . - APPENDIX: How to apply the Apache License to your work. - . - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - . - Copyright [yyyy] [name of copyright owner] - . - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - . - http://www.apache.org/licenses/LICENSE-2.0 - . - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - . - . - PROTON SUBCOMPONENTS: - . - Proton includes freegetopt with a separate BSD license. Your use - of the source code for freegetopt is subject to the terms and - conditions of its license in examples/include/pncompat/internal/LICENSE. - . - The setup scripts for the python bindings include files derived by - PyZMQ and are licensed with a separate Modified BSD license. Use of - the source code in these setup files are subject to the terms and - conditions in the license: - proton-c/bindings/python/setuputils/PYZMQ_LICENSE.BSD. - License: GNU-All-permissive-License Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice @@ -1446,3 +1122,28 @@ License: GPLv3-or-later-with-Autoconf-exception Comment: The "special exception" is extended to the versions of files covered by this license that are distributed with this software. + +License: Expat-with-advertising-clause + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the names of the authors or + their institutions shall not be used in advertising or otherwise to + promote the sale, use or other dealings in this Software without + prior written authorization from the authors. diff --git a/depend/zcash/contrib/devtools/fix-copyright-headers.py b/depend/zcash/contrib/devtools/fix-copyright-headers.py index 5e8495254..14b6de706 100755 --- a/depend/zcash/contrib/devtools/fix-copyright-headers.py +++ b/depend/zcash/contrib/devtools/fix-copyright-headers.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ''' Run this script inside of src/ and it will look for all the files that were changed this year that still have the last year in the @@ -46,7 +46,7 @@ def getLastGitModifiedDate(filePath): filePath = os.getcwd() + filePath modifiedTime = getLastGitModifiedDate(filePath) if len(modifiedTime) > 0 and str(year) in modifiedTime: - print n,"Last Git Modified: ", modifiedTime, " - ", filePath + print(n,"Last Git Modified: ", modifiedTime, " - ", filePath) os.popen(command % (last_year,year,filePath)) n = n + 1 diff --git a/depend/zcash/contrib/devtools/optimize-pngs.py b/depend/zcash/contrib/devtools/optimize-pngs.py index 38aaa00f3..3cfd10d24 100755 --- a/depend/zcash/contrib/devtools/optimize-pngs.py +++ b/depend/zcash/contrib/devtools/optimize-pngs.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import sys @@ -44,30 +44,30 @@ def content_hash(filename): [pngcrush, "-brute", "-ow", "-rem", "gAMA", "-rem", "cHRM", "-rem", "iCCP", "-rem", "sRGB", "-rem", "alla", "-rem", "text", file_path], stderr=subprocess.STDOUT).rstrip('\n') except: - print "pngcrush is not installed, aborting..." + print("pngcrush is not installed, aborting...") sys.exit(0) #verify if "Not a PNG file" in subprocess.check_output([pngcrush, "-n", "-v", file_path], stderr=subprocess.STDOUT): - print "PNG file "+file+" is corrupted after crushing, check out pngcursh version" + print("PNG file "+file+" is corrupted after crushing, check out pngcursh version") sys.exit(1) fileMetaMap['sha256New'] = file_hash(file_path) fileMetaMap['contentHashPost'] = content_hash(file_path) if fileMetaMap['contentHashPre'] != fileMetaMap['contentHashPost']: - print "Image contents of PNG file "+file+" before and after crushing don't match" + print("Image contents of PNG file "+file+" before and after crushing don't match") sys.exit(1) fileMetaMap['psize'] = os.path.getsize(file_path) outputArray.append(fileMetaMap) print("done\n"), -print "summary:\n+++++++++++++++++" +print("summary:\n+++++++++++++++++") for fileDict in outputArray: oldHash = fileDict['sha256Old'] newHash = fileDict['sha256New'] totalSaveBytes += fileDict['osize'] - fileDict['psize'] - print fileDict['file']+"\n size diff from: "+str(fileDict['osize'])+" to: "+str(fileDict['psize'])+"\n old sha256: "+oldHash+"\n new sha256: "+newHash+"\n" + print(fileDict['file']+"\n size diff from: "+str(fileDict['osize'])+" to: "+str(fileDict['psize'])+"\n old sha256: "+oldHash+"\n new sha256: "+newHash+"\n") -print "completed. Total reduction: "+str(totalSaveBytes)+" bytes" +print("completed. Total reduction: "+str(totalSaveBytes)+" bytes") diff --git a/depend/zcash/contrib/devtools/symbol-check.py b/depend/zcash/contrib/devtools/symbol-check.py index 5b83ba97b..6bedea5ac 100755 --- a/depend/zcash/contrib/devtools/symbol-check.py +++ b/depend/zcash/contrib/devtools/symbol-check.py @@ -1,12 +1,12 @@ #!/usr/bin/env python # Copyright (c) 2014 Wladimir J. van der Laan -# Copyright (c) 2016-2019 The Zcash developers +# Copyright (c) 2016-2020 The Zcash developers # Distributed under the MIT software license, see the accompanying # file COPYING or https://www.opensource.org/licenses/mit-license.php . ''' A script to check that the (Linux) executables produced by gitian only contain -allowed gcc, glibc and libstdc++ version symbols. This makes sure they are -still compatible with the minimum supported Linux distribution versions. +allowed gcc and glibc version symbols. This makes sure they are still compatible +with the minimum supported Linux distribution versions. Example usage: @@ -18,55 +18,83 @@ import sys import os -# Debian 6.0.9 (Squeeze) has: +# Ubuntu 16.04 LTS (Xenial Xerus; End of Standard Support April 2021, EOL April 2022) has: # -# - g++ version 4.4.5 (https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=g%2B%2B) -# - libc version 2.11.3 (https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=libc6) -# - libstdc++ version 4.4.5 (https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=libstdc%2B%2B6) +# - g++ version 4.5.3 (https://packages.ubuntu.com/search?suite=all&searchon=names&keywords=g%2B%2B) +# - libc6 version 2.23 (https://packages.ubuntu.com/search?suite=all&searchon=names&keywords=libc6) # -# Ubuntu 10.04.4 (Lucid Lynx) has: +# Debian 9 (Stretch; EOL 2020-07-06, LTS EOL in 2022) has: # -# - g++ version 4.4.3 (http://packages.ubuntu.com/search?keywords=g%2B%2B&searchon=names&suite=lucid§ion=all) -# - libc version 2.11.1 (http://packages.ubuntu.com/search?keywords=libc6&searchon=names&suite=lucid§ion=all) -# - libstdc++ version 4.4.3 (http://packages.ubuntu.com/search?suite=lucid§ion=all&arch=any&keywords=libstdc%2B%2B&searchon=names) +# - g++ version 6.3.0 (https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=g%2B%2B) +# - libc6 version 2.24 (https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=libc6) # -# Taking the minimum of these as our target. +# RedHat Enterprise Linux 8 (EOL: long and complicated) is based on Fedora 28 (EOL 2019-05-28) and uses the same base packages: # -# According to GNU ABI document (http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html) this corresponds to: -# GCC 4.4.0: GCC_4.4.0 -# GCC 4.4.2: GLIBCXX_3.4.13, CXXABI_1.3.3 -# (glibc) GLIBC_2_11 +# - g++ version 8.0.1 (https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Everything/x86_64/os/Packages/g/ search for gcc-) +# - libc6 version 2.27 (https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Everything/x86_64/os/Packages/g/ search for glibc) # +# CentOS 8 (Full update EOL May 2024, Maintenance EOL 2029-05-31) has: +# +# - g++ version 8.3.1 (http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/ search for libgcc) +# - libc6 version 2.28 (http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/ search for glibc) +# +# Fedora 31 (EOL ~November 2020) has: +# +# - g++ version 9.2.1 (https://dl.fedoraproject.org/pub/fedora/linux/releases/31/Everything/x86_64/os/Packages/g/ search for gcc-) +# - libc6 version 2.30 (https://dl.fedoraproject.org/pub/fedora/linux/releases/31/Everything/x86_64/os/Packages/g/ search for glibc) +# +# Arch is a rolling release, and as of October 2020 has packages for: +# +# - g++ version 8.4.0 / 9.3.0 / 10.2.0 (https://www.archlinux.org/packages/?q=gcc) +# - libc6 version 2.32 (https://www.archlinux.org/packages/?q=glibc) +# +# We take the minimum of these as our target. In practice, if we build on Xenial without +# upgrading GCC or libc, then we should get a binary that works for all these systems, and +# later ones. +# +# According to the GNU ABI document (http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html) this corresponds to: +# GCC 4.5.3: GCC_4.5.0, GLIBCXX_3.4.14, CXXABI_1.3.4 +# libc6: GLIBC_2_23 + +# We statically link libc++ and libc++abi in our builds. Set this to allow dynamic linking to libstdc++. +ALLOW_DYNAMIC_LIBSTDCXX = False + MAX_VERSIONS = { -'GCC': (4,4,0), -'CXXABI': (1,3,3), -'GLIBCXX': (3,4,13), -'GLIBC': (2,11) + 'GCC': (4,5,0), + 'GLIBC': (2,23), } +if ALLOW_DYNAMIC_LIBSTDCXX: + MAX_VERSIONS.update({ + 'GLIBCXX': (3,4,14), + 'CXXABI': (1,3,4), + }) + # See here for a description of _IO_stdin_used: # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=634261#109 # Ignore symbols that are exported as part of every executable IGNORE_EXPORTS = { -'_edata', '_end', '_init', '__bss_start', '_fini', '_IO_stdin_used' + '_edata', '_end', '_init', '__bss_start', '_fini', '_IO_stdin_used' } READELF_CMD = os.getenv('READELF', '/usr/bin/readelf') CPPFILT_CMD = os.getenv('CPPFILT', '/usr/bin/c++filt') + # Allowed NEEDED libraries ALLOWED_LIBRARIES = { -# zcashd -'libgcc_s.so.1', # GCC base support -'libc.so.6', # C library -'libstdc++.so.6', # C++ standard library -'libpthread.so.0', # threading -'libanl.so.1', # DNS resolve -'libm.so.6', # math library -'librt.so.1', # real-time (clock) -'libgomp.so.1', # OpenMP support library -'ld-linux-x86-64.so.2', # 64-bit dynamic linker -'ld-linux.so.2', # 32-bit dynamic linker -'libdl.so.2' # programming interface to dynamic linker + # zcashd + 'libgcc_s.so.1', # GCC support library (also used by clang) + 'libc.so.6', # C library + 'libpthread.so.0', # threading + 'libanl.so.1', # DNS resolver + 'libm.so.6', # math library + 'librt.so.1', # real-time (POSIX compatibility) + 'ld-linux-x86-64.so.2', # 64-bit dynamic linker + 'ld-linux.so.2', # 32-bit dynamic linker + 'libdl.so.2' # programming interface to dynamic linker } +if ALLOW_DYNAMIC_LIBSTDCXX: + ALLOWED_LIBRARIES.add('libstdc++.so.6') # C++ standard library + class CPPFilt(object): ''' @@ -138,6 +166,7 @@ def read_libraries(filename): cppfilt = CPPFilt() retval = 0 for filename in sys.argv[1:]: + print("Checking %s..." % (filename,)) # Check imported symbols for sym,version in read_symbols(filename, True): if version and not check_version(MAX_VERSIONS, version): @@ -154,7 +183,12 @@ def read_libraries(filename): if library_name not in ALLOWED_LIBRARIES: print('%s: NEEDED library %s is not allowed' % (filename, library_name)) retval = 1 + print() - exit(retval) - + if retval == 0: + print("Everything OK") + else: + print("Note: this script is intended to ensure that Gitian builds meet our compatibility policy.") + print("The above warnings do not necessarily mean the program(s) will not work on your system.") + exit(retval) diff --git a/depend/zcash/contrib/docker/README.md b/depend/zcash/contrib/docker/README.md index ce871f42e..912604517 100644 --- a/depend/zcash/contrib/docker/README.md +++ b/depend/zcash/contrib/docker/README.md @@ -65,10 +65,6 @@ This is experimental software. Distributed under the MIT software license, see the accompanying file COPYING or . - -This product includes software developed by the OpenSSL Project for use in the -OpenSSL Toolkit and cryptographic software written -by Eric Young. ``` ### Persist data to the host diff --git a/depend/zcash/contrib/gitian-descriptors/gitian-linux.yml b/depend/zcash/contrib/gitian-descriptors/gitian-linux.yml index 3a39ad4ae..3da8e23ae 100644 --- a/depend/zcash/contrib/gitian-descriptors/gitian-linux.yml +++ b/depend/zcash/contrib/gitian-descriptors/gitian-linux.yml @@ -1,9 +1,8 @@ --- -name: "zcash-3.1.0-rc2" +name: "zcash-4.0.0" enable_cache: true distro: "debian" suites: -- "jessie" - "stretch" architectures: - "amd64" @@ -32,7 +31,7 @@ remotes: files: [] script: | WRAP_DIR=$HOME/wrapped - HOSTS="x86_64-unknown-linux-gnu" + HOSTS="x86_64-linux-gnu" CONFIGFLAGS="--enable-glibc-back-compat --enable-reduce-exports --disable-bench --enable-hardening" MAKEOPTS="V=1" FAKETIME_HOST_PROGS="" @@ -87,7 +86,7 @@ script: | BASEPREFIX=`pwd`/depends # Build dependencies for each host for i in $HOSTS; do - NO_PROTON="x" make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" + make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" done # Faketime for binaries diff --git a/depend/zcash/contrib/gitian-descriptors/gitian-osx.yml b/depend/zcash/contrib/gitian-descriptors/gitian-osx.yml index 794a82af8..250204892 100644 --- a/depend/zcash/contrib/gitian-descriptors/gitian-osx.yml +++ b/depend/zcash/contrib/gitian-descriptors/gitian-osx.yml @@ -24,10 +24,10 @@ remotes: - "url": "https://github.com/bitcoin/bitcoin.git" "dir": "bitcoin" files: -- "MacOSX10.9.sdk.tar.gz" +- "Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz" script: | WRAP_DIR=$HOME/wrapped - HOSTS="x86_64-apple-darwin11" + HOSTS="x86_64-apple-darwin16" CONFIGFLAGS="--enable-reduce-exports --disable-bench GENISOIMAGE=$WRAP_DIR/genisoimage" FAKETIME_HOST_PROGS="" FAKETIME_PROGS="ar ranlib date dmg genisoimage" @@ -80,7 +80,7 @@ script: | BASEPREFIX=`pwd`/depends mkdir -p ${BASEPREFIX}/SDKs - tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/MacOSX10.9.sdk.tar.gz + tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz # Build dependencies for each host for i in $HOSTS; do diff --git a/depend/zcash/contrib/init/README.md b/depend/zcash/contrib/init/README.md deleted file mode 100644 index 0d19da303..000000000 --- a/depend/zcash/contrib/init/README.md +++ /dev/null @@ -1,11 +0,0 @@ -Sample configuration files for: - -SystemD: bitcoind.service -Upstart: bitcoind.conf -OpenRC: bitcoind.openrc - bitcoind.openrcconf -CentOS: bitcoind.init - -have been made available to assist packagers in creating node packages here. - -See doc/init.md for more information. diff --git a/depend/zcash/contrib/init/bitcoind.conf b/depend/zcash/contrib/init/bitcoind.conf deleted file mode 100644 index f9554eecd..000000000 --- a/depend/zcash/contrib/init/bitcoind.conf +++ /dev/null @@ -1,65 +0,0 @@ -description "Bitcoin Core Daemon" - -start on runlevel [2345] -stop on starting rc RUNLEVEL=[016] - -env BITCOIND_BIN="/usr/bin/bitcoind" -env BITCOIND_USER="bitcoin" -env BITCOIND_GROUP="bitcoin" -env BITCOIND_PIDDIR="/var/run/bitcoind" -# upstart can't handle variables constructed with other variables -env BITCOIND_PIDFILE="/var/run/bitcoind/bitcoind.pid" -env BITCOIND_CONFIGFILE="/etc/bitcoin/bitcoin.conf" -env BITCOIND_DATADIR="/var/lib/bitcoind" - -expect fork - -respawn -respawn limit 5 120 -kill timeout 60 - -pre-start script - # this will catch non-existent config files - # bitcoind will check and exit with this very warning, but it can do so - # long after forking, leaving upstart to think everything started fine. - # since this is a commonly encountered case on install, just check and - # warn here. - if ! grep -qs '^rpcpassword=' "$BITCOIND_CONFIGFILE" ; then - echo "ERROR: You must set a secure rpcpassword to run bitcoind." - echo "The setting must appear in $BITCOIND_CONFIGFILE" - echo - echo "This password is security critical to securing wallets " - echo "and must not be the same as the rpcuser setting." - echo "You can generate a suitable random password using the following" - echo "command from the shell:" - echo - echo "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'" - echo - echo "It is also recommended that you also set alertnotify so you are " - echo "notified of problems:" - echo - echo "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \ - "admin@foo.com" - echo - exit 1 - fi - - mkdir -p "$BITCOIND_PIDDIR" - chmod 0755 "$BITCOIND_PIDDIR" - chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_PIDDIR" - chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_CONFIGFILE" - chmod 0660 "$BITCOIND_CONFIGFILE" -end script - -exec start-stop-daemon \ - --start \ - --pidfile "$BITCOIND_PIDFILE" \ - --chuid $BITCOIND_USER:$BITCOIND_GROUP \ - --exec "$BITCOIND_BIN" \ - -- \ - -pid="$BITCOIND_PIDFILE" \ - -conf="$BITCOIND_CONFIGFILE" \ - -datadir="$BITCOIND_DATADIR" \ - -disablewallet \ - -daemon - diff --git a/depend/zcash/contrib/init/bitcoind.init b/depend/zcash/contrib/init/bitcoind.init deleted file mode 100644 index db5061874..000000000 --- a/depend/zcash/contrib/init/bitcoind.init +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# -# bitcoind The bitcoin core server. -# -# -# chkconfig: 345 80 20 -# description: bitcoind -# processname: bitcoind -# - -# Source function library. -. /etc/init.d/functions - -# you can override defaults in /etc/sysconfig/bitcoind, see below -if [ -f /etc/sysconfig/bitcoind ]; then - . /etc/sysconfig/bitcoind -fi - -RETVAL=0 - -prog=bitcoind -# you can override the lockfile via BITCOIND_LOCKFILE in /etc/sysconfig/bitcoind -lockfile=${BITCOIND_LOCKFILE-/var/lock/subsys/bitcoind} - -# bitcoind defaults to /usr/bin/bitcoind, override with BITCOIND_BIN -bitcoind=${BITCOIND_BIN-/usr/bin/bitcoind} - -# bitcoind opts default to -disablewallet, override with BITCOIND_OPTS -bitcoind_opts=${BITCOIND_OPTS--disablewallet} - -start() { - echo -n $"Starting $prog: " - daemon $DAEMONOPTS $bitcoind $bitcoind_opts - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch $lockfile - return $RETVAL -} - -stop() { - echo -n $"Stopping $prog: " - killproc $prog - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && rm -f $lockfile - return $RETVAL -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - status) - status $prog - ;; - restart) - stop - start - ;; - *) - echo "Usage: service $prog {start|stop|status|restart}" - exit 1 - ;; -esac diff --git a/depend/zcash/contrib/init/bitcoind.openrc b/depend/zcash/contrib/init/bitcoind.openrc deleted file mode 100644 index eda1a96fb..000000000 --- a/depend/zcash/contrib/init/bitcoind.openrc +++ /dev/null @@ -1,92 +0,0 @@ -#!/sbin/runscript - -# backward compatibility for existing gentoo layout -# -if [ -d "/var/lib/bitcoin/.bitcoin" ]; then - BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoin/.bitcoin" -else - BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoind" -fi - -BITCOIND_CONFIGFILE=${BITCOIND_CONFIGFILE:-/etc/bitcoin/bitcoin.conf} -BITCOIND_PIDDIR=${BITCOIND_PIDDIR:-/var/run/bitcoind} -BITCOIND_PIDFILE=${BITCOIND_PIDFILE:-${BITCOIND_PIDDIR}/bitcoind.pid} -BITCOIND_DATADIR=${BITCOIND_DATADIR:-${BITCOIND_DEFAULT_DATADIR}} -BITCOIND_USER=${BITCOIND_USER:-${BITCOIN_USER:-bitcoin}} -BITCOIND_GROUP=${BITCOIND_GROUP:-bitcoin} -BITCOIND_BIN=${BITCOIND_BIN:-/usr/bin/bitcoind} -BITCOIND_NICE=${BITCOIND_NICE:-${NICELEVEL:-0}} -BITCOIND_OPTS="${BITCOIND_OPTS:-${BITCOIN_OPTS}}" - -name="Bitcoin Core Daemon" -description="Bitcoin cryptocurrency P2P network daemon" - -command="/usr/bin/bitcoind" -command_args="-pid=\"${BITCOIND_PIDFILE}\" \ - -conf=\"${BITCOIND_CONFIGFILE}\" \ - -datadir=\"${BITCOIND_DATADIR}\" \ - -daemon \ - ${BITCOIND_OPTS}" - -required_files="${BITCOIND_CONFIGFILE}" -start_stop_daemon_args="-u ${BITCOIND_USER} \ - -N ${BITCOIND_NICE} -w 2000" -pidfile="${BITCOIND_PIDFILE}" - -# The retry schedule to use when stopping the daemon. Could be either -# a timeout in seconds or multiple signal/timeout pairs (like -# "SIGKILL/180 SIGTERM/300") -retry="${BITCOIND_SIGTERM_TIMEOUT}" - -depend() { - need localmount net -} - -# verify -# 1) that the datadir exists and is writable (or create it) -# 2) that a directory for the pid exists and is writable -# 3) ownership and permissions on the config file -start_pre() { - checkpath \ - -d \ - --mode 0750 \ - --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \ - "${BITCOIND_DATADIR}" - - checkpath \ - -d \ - --mode 0755 \ - --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \ - "${BITCOIND_PIDDIR}" - - checkpath -f \ - -o ${BITCOIND_USER}:${BITCOIND_GROUP} \ - -m 0660 \ - ${BITCOIND_CONFIGFILE} - - checkconfig || return 1 -} - -checkconfig() -{ - if ! grep -qs '^rpcpassword=' "${BITCOIND_CONFIGFILE}" ; then - eerror "" - eerror "ERROR: You must set a secure rpcpassword to run bitcoind." - eerror "The setting must appear in ${BITCOIND_CONFIGFILE}" - eerror "" - eerror "This password is security critical to securing wallets " - eerror "and must not be the same as the rpcuser setting." - eerror "You can generate a suitable random password using the following" - eerror "command from the shell:" - eerror "" - eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'" - eerror "" - eerror "It is also recommended that you also set alertnotify so you are " - eerror "notified of problems:" - eerror "" - eerror "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \ - "admin@foo.com" - eerror "" - return 1 - fi -} diff --git a/depend/zcash/contrib/init/bitcoind.openrcconf b/depend/zcash/contrib/init/bitcoind.openrcconf deleted file mode 100644 index 0cbff6d30..000000000 --- a/depend/zcash/contrib/init/bitcoind.openrcconf +++ /dev/null @@ -1,33 +0,0 @@ -# /etc/conf.d/bitcoind: config file for /etc/init.d/bitcoind - -# Config file location -#BITCOIND_CONFIGFILE="/etc/bitcoin/bitcoin.conf" - -# What directory to write pidfile to? (created and owned by $BITCOIND_USER) -#BITCOIND_PIDDIR="/var/run/bitcoind" - -# What filename to give the pidfile -#BITCOIND_PIDFILE="${BITCOIND_PIDDIR}/bitcoind.pid" - -# Where to write bitcoind data (be mindful that the blockchain is large) -#BITCOIND_DATADIR="/var/lib/bitcoind" - -# User and group to own bitcoind process -#BITCOIND_USER="bitcoin" -#BITCOIND_GROUP="bitcoin" - -# Path to bitcoind executable -#BITCOIND_BIN="/usr/bin/bitcoind" - -# Nice value to run bitcoind under -#BITCOIND_NICE=0 - -# Additional options (avoid -conf and -datadir, use flags above) -BITCOIND_OPTS="-disablewallet" - -# The timeout in seconds OpenRC will wait for bitcoind to terminate -# after a SIGTERM has been raised. -# Note that this will be mapped as argument to start-stop-daemon's -# '--retry' option, which means you can specify a retry schedule -# here. For more information see man 8 start-stop-daemon. -BITCOIND_SIGTERM_TIMEOUT=60 diff --git a/depend/zcash/contrib/init/bitcoind.service b/depend/zcash/contrib/init/bitcoind.service deleted file mode 100644 index 9132957c3..000000000 --- a/depend/zcash/contrib/init/bitcoind.service +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description=Bitcoin's distributed currency daemon -After=network.target - -[Service] -User=bitcoin -Group=bitcoin - -Type=forking -PIDFile=/var/lib/bitcoind/bitcoind.pid -ExecStart=/usr/bin/bitcoind -daemon -pid=/var/lib/bitcoind/bitcoind.pid \ --conf=/etc/bitcoin/bitcoin.conf -datadir=/var/lib/bitcoind -disablewallet - -Restart=always -PrivateTmp=true -TimeoutStopSec=60s -TimeoutStartSec=2s -StartLimitInterval=120s -StartLimitBurst=5 - -[Install] -WantedBy=multi-user.target diff --git a/depend/zcash/contrib/macdeploy/Base.lproj/InfoPlist.strings b/depend/zcash/contrib/macdeploy/Base.lproj/InfoPlist.strings deleted file mode 100644 index b259ea141..000000000 --- a/depend/zcash/contrib/macdeploy/Base.lproj/InfoPlist.strings +++ /dev/null @@ -1 +0,0 @@ -{ CFBundleDisplayName = "Bitcoin Core"; CFBundleName = "Bitcoin Core"; } diff --git a/depend/zcash/contrib/macdeploy/DS_Store b/depend/zcash/contrib/macdeploy/DS_Store deleted file mode 100644 index db9d16f1d..000000000 Binary files a/depend/zcash/contrib/macdeploy/DS_Store and /dev/null differ diff --git a/depend/zcash/contrib/macdeploy/LICENSE b/depend/zcash/contrib/macdeploy/LICENSE deleted file mode 100644 index 94a9ed024..000000000 --- a/depend/zcash/contrib/macdeploy/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/depend/zcash/contrib/macdeploy/README.md b/depend/zcash/contrib/macdeploy/README.md index 6163734e6..ab670c6e4 100644 --- a/depend/zcash/contrib/macdeploy/README.md +++ b/depend/zcash/contrib/macdeploy/README.md @@ -1,15 +1,123 @@ -### MacDeploy ### +# MacOS Deployment -For Snow Leopard (which uses [Python 2.6](http://www.python.org/download/releases/2.6/)), you will need the param_parser package: - - sudo easy_install argparse +## SDK Extraction -This script should not be run manually, instead, after building as usual: +### Step 1: Obtaining `Xcode.app` - make deploy +Our current macOS SDK +(`Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz`) can be +extracted from +[Xcode_11.3.1.xip](https://download.developer.apple.com/Developer_Tools/Xcode_11.3.1/Xcode_11.3.1.xip). +In order to download this, you may need to first +[log in with an Apple ID here](https://developer.apple.com/download/more/). -During the process, the disk image window will pop up briefly where the fancy -settings are applied. This is normal, please do not interfere. +The file is ~7.8 GB. -When finished, it will produce `Bitcoin-Core.dmg`. +After Xcode version 7.x, Apple started shipping the `Xcode.app` in a `.xip` +archive. This makes the SDK less-trivial to extract on non-macOS machines. One +approach (tested on Debian Buster) is outlined below: +```bash +# Install/clone tools needed for extracting Xcode.app +apt install cpio +git clone https://github.com/bitcoin-core/apple-sdk-tools.git + +# Unpack Xcode_11.3.1.xip and place the resulting Xcode.app in your current +# working directory +python3 apple-sdk-tools/extract_xcode.py -f Xcode_11.3.1.xip | cpio -d -i +``` + +On macOS the process is more straightforward: + +```bash +xip -x Xcode_11.3.1.xip +``` + +The extracted files require ~17 GB of disk space. + +### Step 2: Generating `Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz` from `Xcode.app` + +To generate `Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz`, run +the script [`gen-sdk`](./gen-sdk) with the path to `Xcode.app` (extracted in the +previous stage) as the first argument. + +```bash +# Generate a Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz from +# the supplied Xcode.app +./contrib/macdeploy/gen-sdk '/path/to/Xcode.app' +``` + +## Deterministic macOS DMG Notes +Working macOS DMGs are created in Linux by combining a recent `clang`, the Apple +`binutils` (`ld`, `ar`, etc) and DMG authoring tools. + +Apple uses `clang` extensively for development and has upstreamed the necessary +functionality so that a vanilla clang can take advantage. It supports the use of `-F`, +`-target`, `-mmacosx-version-min`, and `--sysroot`, which are all necessary when +building for macOS. + +Apple's version of `binutils` (called `cctools`) contains lots of functionality missing in the +FSF's `binutils`. In addition to extra linker options for frameworks and sysroots, several +other tools are needed as well such as `install_name_tool`, `lipo`, and `nmedit`. These +do not build under Linux, so they have been patched to do so. The work here was used as +a starting point: [mingwandroid/toolchain4](https://github.com/mingwandroid/toolchain4). + +In order to build a working toolchain, the following source packages are needed from +Apple: `cctools`, `dyld`, and `ld64`. + +These tools inject timestamps by default, which produce non-deterministic binaries. The +`ZERO_AR_DATE` environment variable is used to disable that. + +This version of `cctools` has been patched to use the current version of `clang`'s headers +and its `libLTO.so` rather than those from `llvmgcc`, as it was originally done in `toolchain4`. + +To complicate things further, all builds must target a macOS SDK. These SDKs are free to +download, but are contained in an Xcode archive that is not redistributable. Instructions +on how to obtain this archive (Xcode_11.3.1.xip) were given earlier. + +This file is many gigabytes in size, but most (but not all) of what we need is +contained only in a single directory: + +```bash +Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk +``` + +See the SDK Extraction notes above for how to obtain it. + +The Gitian descriptors build 2 sets of files: Linux tools, then Apple binaries which are +created using these tools. The build process has been designed to avoid including the +SDK's files in Gitian's outputs. All interim tarballs are fully deterministic and may be freely +redistributed. + +Note: the documentation below may be outdated. + +`genisoimage` is used to create the initial DMG. It is not deterministic as-is, so it has been +patched. A system `genisoimage` will work fine, but it will not be deterministic because +the file-order will change between invocations. The patch can be seen here: [cdrkit-deterministic.patch](https://github.com/bitcoin/bitcoin/blob/master/depends/patches/native_cdrkit/cdrkit-deterministic.patch). +No effort was made to fix this cleanly, so it likely leaks memory badly, however it's only used for +a single invocation, so that's no real concern. + +`genisoimage` cannot compress DMGs, so afterwards, the DMG tool from the +`libdmg-hfsplus` project is used to compress it. There are several bugs in this tool and its +maintainer has seemingly abandoned the project. + +The DMG tool has the ability to create DMGs from scratch as well, but this functionality is +broken. Only the compression feature is currently used. Ideally, the creation could be fixed +and `genisoimage` would no longer be necessary. + +Background images and other features can be added to DMG files by inserting a +`.DS_Store` before creation. This is generated by the script `contrib/macdeploy/custom_dsstore.py`. + +As of OS X 10.9 Mavericks, using an Apple-blessed key to sign binaries is a requirement in +order to satisfy the new Gatekeeper requirements. Because this private key cannot be +shared, we'll have to be a bit creative in order for the build process to remain somewhat +deterministic. Here's how it works: + +- Builders use Gitian to create an unsigned release. This outputs an unsigned DMG which + users may choose to bless and run. It also outputs an unsigned app structure in the form + of a tarball, which also contains all of the tools that have been previously (deterministically) + built in order to create a final DMG. +- The Apple keyholder uses this unsigned app to create a detached signature, using the + script that is also included there. Detached signatures are available from this [repository](https://github.com/bitcoin-core/bitcoin-detached-sigs). +- Builders feed the unsigned app + detached signature back into Gitian. It uses the + pre-built tools to recombine the pieces into a deterministic DMG. diff --git a/depend/zcash/contrib/macdeploy/background.png b/depend/zcash/contrib/macdeploy/background.png deleted file mode 100644 index f88a2ae74..000000000 Binary files a/depend/zcash/contrib/macdeploy/background.png and /dev/null differ diff --git a/depend/zcash/contrib/macdeploy/background.psd b/depend/zcash/contrib/macdeploy/background.psd deleted file mode 100644 index fdc4f4ca4..000000000 Binary files a/depend/zcash/contrib/macdeploy/background.psd and /dev/null differ diff --git a/depend/zcash/contrib/macdeploy/background.tiff b/depend/zcash/contrib/macdeploy/background.tiff deleted file mode 100644 index 4b44ac672..000000000 Binary files a/depend/zcash/contrib/macdeploy/background.tiff and /dev/null differ diff --git a/depend/zcash/contrib/macdeploy/background@2x.png b/depend/zcash/contrib/macdeploy/background@2x.png deleted file mode 100644 index 4858183f7..000000000 Binary files a/depend/zcash/contrib/macdeploy/background@2x.png and /dev/null differ diff --git a/depend/zcash/contrib/macdeploy/detached-sig-apply.sh b/depend/zcash/contrib/macdeploy/detached-sig-apply.sh deleted file mode 100755 index 781fe315e..000000000 --- a/depend/zcash/contrib/macdeploy/detached-sig-apply.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -set -e - -UNSIGNED="$1" -SIGNATURE="$2" -ARCH=x86_64 -ROOTDIR=dist -TEMPDIR=signed.temp -OUTDIR=signed-app - -if [ -z "$UNSIGNED" ]; then - echo "usage: $0 " - exit 1 -fi - -if [ -z "$SIGNATURE" ]; then - echo "usage: $0 " - exit 1 -fi - -rm -rf ${TEMPDIR} && mkdir -p ${TEMPDIR} -tar -C ${TEMPDIR} -xf ${UNSIGNED} -cp -rf "${SIGNATURE}"/* ${TEMPDIR} - -if [ -z "${PAGESTUFF}" ]; then - PAGESTUFF=${TEMPDIR}/pagestuff -fi - -if [ -z "${CODESIGN_ALLOCATE}" ]; then - CODESIGN_ALLOCATE=${TEMPDIR}/codesign_allocate -fi - -find ${TEMPDIR} -name "*.sign" | while read i; do - SIZE=`stat -c %s "${i}"` - TARGET_FILE="`echo "${i}" | sed 's/\.sign$//'`" - - echo "Allocating space for the signature of size ${SIZE} in ${TARGET_FILE}" - ${CODESIGN_ALLOCATE} -i "${TARGET_FILE}" -a ${ARCH} ${SIZE} -o "${i}.tmp" - - OFFSET=`${PAGESTUFF} "${i}.tmp" -p | tail -2 | grep offset | sed 's/[^0-9]*//g'` - if [ -z ${QUIET} ]; then - echo "Attaching signature at offset ${OFFSET}" - fi - - dd if="$i" of="${i}.tmp" bs=1 seek=${OFFSET} count=${SIZE} 2>/dev/null - mv "${i}.tmp" "${TARGET_FILE}" - rm "${i}" - echo "Success." -done -mv ${TEMPDIR}/${ROOTDIR} ${OUTDIR} -rm -rf ${TEMPDIR} -echo "Signed: ${OUTDIR}" diff --git a/depend/zcash/contrib/macdeploy/detached-sig-create.sh b/depend/zcash/contrib/macdeploy/detached-sig-create.sh deleted file mode 100755 index 89a2da32f..000000000 --- a/depend/zcash/contrib/macdeploy/detached-sig-create.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -set -e - -ROOTDIR=dist -BUNDLE="${ROOTDIR}/Bitcoin-Qt.app" -CODESIGN=codesign -TEMPDIR=sign.temp -TEMPLIST=${TEMPDIR}/signatures.txt -OUT=signature.tar.gz -OUTROOT=osx - -if [ ! -n "$1" ]; then - echo "usage: $0 " - echo "example: $0 -s MyIdentity" - exit 1 -fi - -rm -rf ${TEMPDIR} ${TEMPLIST} -mkdir -p ${TEMPDIR} - -${CODESIGN} -f --file-list ${TEMPLIST} "$@" "${BUNDLE}" - -grep -v CodeResources < "${TEMPLIST}" | while read i; do - TARGETFILE="${BUNDLE}/`echo "${i}" | sed "s|.*${BUNDLE}/||"`" - SIZE=`pagestuff "$i" -p | tail -2 | grep size | sed 's/[^0-9]*//g'` - OFFSET=`pagestuff "$i" -p | tail -2 | grep offset | sed 's/[^0-9]*//g'` - SIGNFILE="${TEMPDIR}/${OUTROOT}/${TARGETFILE}.sign" - DIRNAME="`dirname "${SIGNFILE}"`" - mkdir -p "${DIRNAME}" - echo "Adding detached signature for: ${TARGETFILE}. Size: ${SIZE}. Offset: ${OFFSET}" - dd if="$i" of="${SIGNFILE}" bs=1 skip=${OFFSET} count=${SIZE} 2>/dev/null -done - -grep CodeResources < "${TEMPLIST}" | while read i; do - TARGETFILE="${BUNDLE}/`echo "${i}" | sed "s|.*${BUNDLE}/||"`" - RESOURCE="${TEMPDIR}/${OUTROOT}/${TARGETFILE}" - DIRNAME="`dirname "${RESOURCE}"`" - mkdir -p "${DIRNAME}" - echo "Adding resource for: "${TARGETFILE}"" - cp "${i}" "${RESOURCE}" -done - -rm ${TEMPLIST} - -tar -C "${TEMPDIR}" -czf "${OUT}" . -rm -rf "${TEMPDIR}" -echo "Created ${OUT}" diff --git a/depend/zcash/contrib/macdeploy/fancy.plist b/depend/zcash/contrib/macdeploy/fancy.plist deleted file mode 100644 index ef277a7f1..000000000 --- a/depend/zcash/contrib/macdeploy/fancy.plist +++ /dev/null @@ -1,32 +0,0 @@ - - - - - window_bounds - - 300 - 300 - 800 - 620 - - background_picture - background.tiff - icon_size - 96 - applications_symlink - - items_position - - Applications - - 370 - 156 - - Bitcoin-Qt.app - - 128 - 156 - - - - diff --git a/depend/zcash/contrib/macdeploy/gen-sdk b/depend/zcash/contrib/macdeploy/gen-sdk new file mode 100755 index 000000000..7af726937 --- /dev/null +++ b/depend/zcash/contrib/macdeploy/gen-sdk @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 +import argparse +import plistlib +import pathlib +import sys +import tarfile +import gzip +import os +import contextlib + +@contextlib.contextmanager +def cd(path): + """Context manager that restores PWD even if an exception was raised.""" + old_pwd = os.getcwd() + os.chdir(str(path)) + try: + yield + finally: + os.chdir(old_pwd) + +def run(): + parser = argparse.ArgumentParser( + description=__doc__, formatter_class=argparse.RawTextHelpFormatter) + + parser.add_argument('xcode_app', metavar='XCODEAPP', nargs=1) + parser.add_argument("-o", metavar='OUTSDKTGZ', nargs=1, dest='out_sdktgz', required=False) + + args = parser.parse_args() + + xcode_app = pathlib.Path(args.xcode_app[0]).resolve() + assert xcode_app.is_dir(), "The supplied Xcode.app path '{}' either does not exist or is not a directory".format(xcode_app) + + xcode_app_plist = xcode_app.joinpath("Contents/version.plist") + with xcode_app_plist.open('rb') as fp: + pl = plistlib.load(fp) + xcode_version = pl['CFBundleShortVersionString'] + xcode_build_id = pl['ProductBuildVersion'] + print("Found Xcode (version: {xcode_version}, build id: {xcode_build_id})".format(xcode_version=xcode_version, xcode_build_id=xcode_build_id)) + + sdk_dir = xcode_app.joinpath("Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk") + sdk_plist = sdk_dir.joinpath("System/Library/CoreServices/SystemVersion.plist") + with sdk_plist.open('rb') as fp: + pl = plistlib.load(fp) + sdk_version = pl['ProductVersion'] + sdk_build_id = pl['ProductBuildVersion'] + print("Found MacOSX SDK (version: {sdk_version}, build id: {sdk_build_id})".format(sdk_version=sdk_version, sdk_build_id=sdk_build_id)) + + out_name = "Xcode-{xcode_version}-{xcode_build_id}-extracted-SDK-with-libcxx-headers".format(xcode_version=xcode_version, xcode_build_id=xcode_build_id) + + xcode_libcxx_dir = xcode_app.joinpath("Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1") + assert xcode_libcxx_dir.is_dir() + + if args.out_sdktgz: + out_sdktgz_path = pathlib.Path(args.out_sdktgz_path) + else: + # Construct our own out_sdktgz if not specified on the command line + out_sdktgz_path = pathlib.Path("./{}.tar.gz".format(out_name)) + + def tarfp_add_with_base_change(tarfp, dir_to_add, alt_base_dir): + """Add all files in dir_to_add to tarfp, but prepend MEMBERPREFIX to the files' + names + + e.g. if the only file under /root/bazdir is /root/bazdir/qux, invoking: + + tarfp_add_with_base_change(tarfp, "foo/bar", "/root/bazdir") + + would result in the following members being added to tarfp: + + foo/bar/ -> corresponding to /root/bazdir + foo/bar/qux -> corresponding to /root/bazdir/qux + + """ + def change_tarinfo_base(tarinfo): + if tarinfo.name and tarinfo.name.startswith("./"): + tarinfo.name = str(pathlib.Path(alt_base_dir, tarinfo.name)) + if tarinfo.linkname and tarinfo.linkname.startswith("./"): + tarinfo.linkname = str(pathlib.Path(alt_base_dir, tarinfo.linkname)) + return tarinfo + with cd(dir_to_add): + tarfp.add(".", recursive=True, filter=change_tarinfo_base) + + print("Creating output .tar.gz file...") + with out_sdktgz_path.open("wb") as fp: + with gzip.GzipFile(fileobj=fp, compresslevel=9, mtime=0) as gzf: + with tarfile.open(mode="w", fileobj=gzf) as tarfp: + print("Adding MacOSX SDK {} files...".format(sdk_version)) + tarfp_add_with_base_change(tarfp, sdk_dir, out_name) + print("Adding libc++ headers...") + tarfp_add_with_base_change(tarfp, xcode_libcxx_dir, "{}/usr/include/c++/v1".format(out_name)) + print("Done! Find the resulting gzipped tarball at:") + print(out_sdktgz_path.resolve()) + +if __name__ == '__main__': + run() diff --git a/depend/zcash/contrib/seeds/README.md b/depend/zcash/contrib/seeds/README.md index 63647fa11..0a9d59d88 100644 --- a/depend/zcash/contrib/seeds/README.md +++ b/depend/zcash/contrib/seeds/README.md @@ -1,8 +1,4 @@ ### Seeds ### Utility to generate the seeds.txt list that is compiled into the client -(see [src/chainparamsseeds.h](/src/chainparamsseeds.h) and other utilities in [contrib/seeds](/contrib/seeds)). - -The 512 seeds compiled into the 0.10 release were created from sipa's DNS seed data, like this: - - curl -s http://bitcoin.sipa.be/seeds.txt | makeseeds.py +(see [src/chainparamsseeds.h](/src/chainparamsseeds.h) and other utilities in [contrib/seeds](/contrib/seeds)). \ No newline at end of file diff --git a/depend/zcash/contrib/seeds/nodes_main.txt b/depend/zcash/contrib/seeds/nodes_main.txt deleted file mode 100644 index 17339d514..000000000 --- a/depend/zcash/contrib/seeds/nodes_main.txt +++ /dev/null @@ -1,879 +0,0 @@ -1.34.168.128:8333 -1.202.128.218:8333 -2.30.0.210:8333 -5.9.96.203:8333 -5.45.71.130:8333 -5.45.98.141:8333 -5.102.145.68:8333 -5.135.160.77:8333 -5.189.134.246:8333 -5.199.164.132:8333 -5.249.135.102:8333 -8.19.44.110:8333 -8.22.230.8:8333 -14.200.200.145:8333 -18.228.0.188:8333 -18.228.0.200:8333 -23.24.168.97:8333 -23.28.35.227:8333 -23.92.76.170:8333 -23.99.64.119:8333 -23.228.166.128:8333 -23.229.45.32:8333 -24.8.105.128:8333 -24.16.69.137:8333 -24.94.98.96:8333 -24.102.118.7:8333 -24.118.166.228:8333 -24.122.133.49:8333 -24.166.97.162:8333 -24.213.235.242:8333 -24.226.107.64:8333 -24.228.192.171:8333 -27.140.133.18:8333 -31.41.40.25:8333 -31.43.101.59:8333 -31.184.195.181:8333 -31.193.139.66:8333 -37.200.70.102:8333 -37.205.10.151:8333 -42.3.106.227:8333 -42.60.133.106:8333 -45.56.85.231:8333 -45.56.102.228:8333 -45.79.130.235:8333 -46.28.204.61:11101 -46.38.235.229:8333 -46.59.2.74:8333 -46.101.132.37:8333 -46.101.168.50:8333 -46.163.76.230:8333 -46.166.161.103:8333 -46.182.132.100:8333 -46.223.36.94:8333 -46.227.66.132:8333 -46.227.66.138:8333 -46.239.107.74:8333 -46.249.39.100:8333 -46.250.98.108:8333 -50.7.37.114:8333 -50.81.53.151:8333 -50.115.43.253:8333 -50.116.20.87:8333 -50.116.33.92:8333 -50.125.167.245:8333 -50.143.9.51:8333 -50.188.192.133:8333 -54.77.162.76:8333 -54.153.97.109:8333 -54.165.192.125:8333 -58.96.105.85:8333 -59.167.196.135:8333 -60.29.227.163:8333 -61.35.225.19:8333 -62.43.130.178:8333 -62.109.49.26:8333 -62.202.0.97:8333 -62.210.66.227:8333 -62.210.192.169:8333 -64.74.98.205:8333 -64.156.193.100:8333 -64.203.102.86:8333 -64.229.142.48:8333 -65.96.193.165:8333 -66.30.3.7:8333 -66.114.33.49:8333 -66.118.133.194:8333 -66.135.10.126:8333 -66.172.10.4:8333 -66.194.38.250:8333 -66.194.38.253:8333 -66.215.192.104:8333 -67.60.98.115:8333 -67.164.35.36:8333 -67.191.162.244:8333 -67.207.195.77:8333 -67.219.233.140:8333 -67.221.193.55:8333 -67.228.162.228:8333 -68.50.67.199:8333 -68.62.3.203:8333 -68.65.205.226:9000 -68.106.42.191:8333 -68.150.181.198:8333 -68.196.196.106:8333 -68.224.194.81:8333 -69.46.5.194:8333 -69.50.171.238:8333 -69.64.43.152:8333 -69.65.41.13:8333 -69.90.132.200:8333 -69.143.1.243:8333 -69.146.98.216:8333 -69.165.246.38:8333 -69.207.6.135:8333 -69.251.208.26:8333 -70.38.1.101:8333 -70.38.9.66:8333 -70.90.2.18:8333 -71.58.228.226:8333 -71.199.11.189:8333 -71.199.193.202:8333 -71.205.232.181:8333 -71.236.200.162:8333 -72.24.73.186:8333 -72.52.130.110:8333 -72.53.111.37:8333 -72.235.38.70:8333 -73.31.171.149:8333 -73.32.137.72:8333 -73.137.133.238:8333 -73.181.192.103:8333 -73.190.2.60:8333 -73.195.192.137:8333 -73.222.35.117:8333 -74.57.199.180:8333 -74.82.233.205:8333 -74.85.66.82:8333 -74.101.224.127:8333 -74.113.69.16:8333 -74.122.235.68:8333 -74.193.68.141:8333 -74.208.164.219:8333 -75.100.37.122:8333 -75.145.149.169:8333 -75.168.34.20:8333 -76.20.44.240:8333 -76.100.70.17:8333 -76.168.3.239:8333 -76.186.140.103:8333 -77.92.68.221:8333 -77.109.101.142:8333 -77.110.11.86:8333 -77.242.108.18:8333 -78.46.96.150:9020 -78.84.100.95:8333 -79.132.230.144:8333 -79.133.43.63:8333 -79.160.76.153:8333 -79.169.34.24:8333 -79.188.7.78:8333 -80.217.226.25:8333 -80.223.100.179:8333 -80.240.129.221:8333 -81.1.173.243:8333 -81.7.11.50:8333 -81.7.16.17:8333 -81.66.111.3:8333 -81.80.9.71:8333 -81.140.43.138:8333 -81.171.34.37:8333 -81.174.247.50:8333 -81.181.155.53:8333 -81.184.5.253:8333 -81.187.69.130:8333 -81.230.3.84:8333 -82.42.128.51:8333 -82.74.226.21:8333 -82.142.75.50:8333 -82.199.102.10:8333 -82.200.205.30:8333 -82.221.108.21:8333 -82.221.128.35:8333 -82.238.124.41:8333 -82.242.0.245:8333 -83.76.123.110:8333 -83.150.9.196:8333 -83.162.196.192:8333 -83.162.234.224:8333 -83.170.104.91:8333 -83.255.66.118:8334 -84.2.34.104:8333 -84.45.98.91:8333 -84.47.161.150:8333 -84.212.192.131:8333 -84.215.169.101:8333 -84.238.140.176:8333 -84.245.71.31:8333 -85.17.4.212:8333 -85.114.128.134:8333 -85.159.237.191:8333 -85.166.130.189:8333 -85.199.4.228:8333 -85.214.66.168:8333 -85.214.195.210:8333 -85.229.0.73:8333 -86.21.96.45:8333 -87.48.42.199:8333 -87.81.143.82:8333 -87.81.251.72:8333 -87.104.24.185:8333 -87.104.168.104:8333 -87.117.234.71:8333 -87.118.96.197:8333 -87.145.12.57:8333 -87.159.170.190:8333 -88.150.168.160:8333 -88.208.0.79:8333 -88.208.0.149:8333 -88.214.194.226:8343 -89.1.11.32:8333 -89.36.235.108:8333 -89.67.96.2:15321 -89.98.16.41:8333 -89.108.72.195:8333 -89.156.35.157:8333 -89.163.227.28:8333 -89.212.33.237:8333 -89.212.160.165:8333 -89.231.96.83:8333 -89.248.164.64:8333 -90.149.193.199:8333 -91.77.239.245:8333 -91.106.194.97:8333 -91.126.77.77:8333 -91.134.38.195:8333 -91.156.97.181:8333 -91.207.68.144:8333 -91.209.77.101:8333 -91.214.200.205:8333 -91.220.131.242:8333 -91.220.163.18:8333 -91.233.23.35:8333 -92.13.96.93:8333 -92.14.74.114:8333 -92.27.7.209:8333 -92.221.228.13:8333 -92.255.207.73:8333 -93.72.167.148:8333 -93.74.163.234:8333 -93.123.174.66:8333 -93.152.166.29:8333 -93.181.45.188:8333 -94.19.12.244:8333 -94.190.227.112:8333 -94.198.135.29:8333 -94.224.162.65:8333 -94.226.107.86:8333 -94.242.198.161:8333 -95.31.10.209:8333 -95.65.72.244:8333 -95.84.162.95:8333 -95.90.139.46:8333 -95.183.49.27:8005 -95.215.47.133:8333 -96.23.67.85:8333 -96.44.166.190:8333 -97.93.225.74:8333 -98.26.0.34:8333 -98.27.225.102:8333 -98.229.117.229:8333 -98.249.68.125:8333 -98.255.5.155:8333 -99.101.240.114:8333 -101.100.174.138:8333 -101.251.203.6:8333 -103.3.60.61:8333 -103.30.42.189:8333 -103.224.165.48:8333 -104.36.83.233:8333 -104.37.129.22:8333 -104.54.192.251:8333 -104.128.228.252:8333 -104.128.230.185:8334 -104.130.161.47:8333 -104.131.33.60:8333 -104.143.0.156:8333 -104.156.111.72:8333 -104.167.111.84:8333 -104.193.40.248:8333 -104.197.7.174:8333 -104.197.8.250:8333 -104.223.1.133:8333 -104.236.97.140:8333 -104.238.128.214:8333 -104.238.130.182:8333 -106.38.234.84:8333 -106.185.36.204:8333 -107.6.4.145:8333 -107.150.2.6:8333 -107.150.40.234:8333 -107.155.108.130:8333 -107.161.182.115:8333 -107.170.66.231:8333 -107.190.128.226:8333 -107.191.106.115:8333 -108.16.2.61:8333 -109.70.4.168:8333 -109.162.35.196:8333 -109.163.235.239:8333 -109.190.196.220:8333 -109.191.39.60:8333 -109.234.106.191:8333 -109.238.81.82:8333 -114.76.147.27:8333 -115.28.224.127:8333 -115.68.110.82:18333 -118.97.79.218:8333 -118.189.207.197:8333 -119.228.96.233:8333 -120.147.178.81:8333 -121.41.123.5:8333 -121.67.5.230:8333 -122.107.143.110:8333 -123.2.170.98:8333 -123.110.65.94:8333 -123.193.139.19:8333 -125.239.160.41:8333 -128.101.162.193:8333 -128.111.73.10:8333 -128.140.229.73:8333 -128.175.195.31:8333 -128.199.107.63:8333 -128.199.192.153:8333 -128.253.3.193:20020 -129.123.7.7:8333 -130.89.160.234:8333 -131.72.139.164:8333 -131.191.112.98:8333 -133.1.134.162:8333 -134.19.132.53:8333 -137.226.34.42:8333 -141.41.2.172:8333 -141.255.128.204:8333 -142.217.12.106:8333 -143.215.129.126:8333 -146.0.32.101:8337 -147.229.13.199:8333 -149.210.133.244:8333 -149.210.162.187:8333 -150.101.163.241:8333 -151.236.11.189:8333 -153.121.66.211:8333 -154.20.2.139:8333 -159.253.23.132:8333 -162.209.106.123:8333 -162.210.198.184:8333 -162.218.65.121:8333 -162.222.161.49:8333 -162.243.132.6:8333 -162.243.132.58:8333 -162.248.99.164:53011 -162.248.102.117:8333 -163.158.35.110:8333 -164.15.10.189:8333 -164.40.134.171:8333 -166.230.71.67:8333 -167.160.161.199:8333 -168.103.195.250:8333 -168.144.27.112:8333 -168.158.129.29:8333 -170.75.162.86:8333 -172.90.99.174:8333 -172.245.5.156:8333 -173.23.166.47:8333 -173.32.11.194:8333 -173.34.203.76:8333 -173.171.1.52:8333 -173.175.136.13:8333 -173.230.228.139:8333 -173.247.193.70:8333 -174.49.132.28:8333 -174.52.202.72:8333 -174.53.76.87:8333 -174.109.33.28:8333 -176.28.12.169:8333 -176.35.182.214:8333 -176.36.33.113:8333 -176.36.33.121:8333 -176.58.96.173:8333 -176.121.76.84:8333 -178.62.70.16:8333 -178.62.111.26:8333 -178.76.169.59:8333 -178.79.131.32:8333 -178.162.199.216:8333 -178.175.134.35:8333 -178.248.111.4:8333 -178.254.1.170:8333 -178.254.34.161:8333 -179.43.143.120:8333 -179.208.156.198:8333 -180.200.128.58:8333 -183.78.169.108:8333 -183.96.96.152:8333 -184.68.2.46:8333 -184.73.160.160:8333 -184.94.227.58:8333 -184.152.68.163:8333 -185.7.35.114:8333 -185.28.76.179:8333 -185.31.160.202:8333 -185.45.192.129:8333 -185.66.140.15:8333 -186.2.167.23:8333 -186.220.101.142:8333 -188.26.5.33:8333 -188.75.136.146:8333 -188.120.194.140:8333 -188.121.5.150:8333 -188.138.0.114:8333 -188.138.33.239:8333 -188.166.0.82:8333 -188.182.108.129:8333 -188.191.97.208:8333 -188.226.198.102:8001 -190.10.9.217:8333 -190.75.143.144:8333 -190.139.102.146:8333 -191.237.64.28:8333 -192.3.131.61:8333 -192.99.225.3:8333 -192.110.160.122:8333 -192.146.137.1:8333 -192.183.198.204:8333 -192.203.228.71:8333 -193.0.109.3:8333 -193.12.238.204:8333 -193.91.200.85:8333 -193.234.225.156:8333 -194.6.233.38:8333 -194.63.143.136:8333 -194.126.100.246:8333 -195.134.99.195:8333 -195.159.111.98:8333 -195.159.226.139:8333 -195.197.175.190:8333 -198.48.199.108:8333 -198.57.208.134:8333 -198.57.210.27:8333 -198.62.109.223:8333 -198.167.140.8:8333 -198.167.140.18:8333 -199.91.173.234:8333 -199.127.226.245:8333 -199.180.134.116:8333 -200.7.96.99:8333 -201.160.106.86:8333 -202.55.87.45:8333 -202.60.68.242:8333 -202.60.69.232:8333 -202.124.109.103:8333 -203.30.197.77:8333 -203.88.160.43:8333 -203.151.140.14:8333 -203.219.14.204:8333 -205.147.40.62:8333 -207.235.39.214:8333 -207.244.73.8:8333 -208.12.64.225:8333 -208.76.200.200:8333 -209.40.96.121:8333 -209.126.107.176:8333 -209.141.40.149:8333 -209.190.75.59:8333 -209.208.111.142:8333 -210.54.34.164:8333 -211.72.66.229:8333 -212.51.144.42:8333 -212.112.33.157:8333 -212.116.72.63:8333 -212.126.14.122:8333 -213.66.205.194:8333 -213.111.196.21:8333 -213.122.107.102:8333 -213.136.75.175:8333 -213.155.7.24:8333 -213.163.64.31:8333 -213.163.64.208:8333 -213.165.86.136:8333 -213.184.8.22:8333 -216.15.78.182:8333 -216.55.143.154:8333 -216.115.235.32:8333 -216.126.226.166:8333 -216.145.67.87:8333 -216.169.141.169:8333 -216.249.92.230:8333 -216.250.138.230:8333 -217.20.171.43:8333 -217.23.2.71:8333 -217.23.2.242:8333 -217.25.9.76:8333 -217.40.226.169:8333 -217.123.98.9:8333 -217.155.36.62:8333 -217.172.32.18:20993 -218.61.196.202:8333 -218.231.205.41:8333 -220.233.77.200:8333 -223.18.226.85:8333 -223.197.203.82:8333 -223.255.166.142:8333 -[2001:1291:2bf:1::100]:8333 -[2001:1418:100:5c2::2]:8333 -[2001:16d8:dd24:0:86c9:681e:f931:256]:8333 -[2001:19f0:1624:e6::579d:9428]:8333 -[2001:19f0:300:1340:225:90ff:fec9:2b6d]:8333 -[2001:19f0:4009:1405::64]:8333 -[2001:1b40:5000:2e::3fb0:6571]:8333 -[2001:410:a000:4050:8463:90b0:fffb:4e58]:8333 -[2001:410:a002:cafe:8463:90b0:fffb:4e58]:8333 -[2001:41d0:1:541e::1]:8333 -[2001:41d0:1:6a34::3]:8333 -[2001:41d0:1:6cd3::]:8333 -[2001:41d0:1:8b26::1]:8333 -[2001:41d0:1:a33d::1]:8333 -[2001:41d0:1:b855::1]:8333 -[2001:41d0:1:c139::1]:8333 -[2001:41d0:1:c8d7::1]:8333 -[2001:41d0:1:dd3f::1]:8333 -[2001:41d0:1:e29d::1]:8333 -[2001:41d0:1:f59f::33]:8333 -[2001:41d0:1:f7cc::1]:8333 -[2001:41d0:1:ff87::1]:8333 -[2001:41d0:2:2f05::1]:8333 -[2001:41d0:2:37c3::]:8200 -[2001:41d0:2:3e13::1]:8333 -[2001:41d0:2:8619::]:8333 -[2001:41d0:2:9c94::1]:8333 -[2001:41d0:2:a24f::]:8333 -[2001:41d0:2:adbf::]:8333 -[2001:41d0:2:b721::1]:8333 -[2001:41d0:2:ee52::1]:8333 -[2001:41d0:2:f1a5::]:8333 -[2001:41d0:2:fa54::1]:8333 -[2001:41d0:51:1::2036]:8333 -[2001:41d0:52:a00::1a1]:8333 -[2001:41d0:52:cff::6f5]:8333 -[2001:41d0:52:d00::2c0]:8333 -[2001:41d0:52:d00::cf2]:8333 -[2001:41d0:8:1087::1]:8333 -[2001:41d0:8:4a3c::b7c]:8333 -[2001:41d0:8:6728::]:8333 -[2001:41d0:8:b779::1]:8333 -[2001:41d0:8:c30f::1]:8333 -[2001:41d0:8:d2b2::1]:8333 -[2001:41d0:8:d5c3::1]:8333 -[2001:41d0:8:eb8b::]:8333 -[2001:41d0:a:16d0::1]:8333 -[2001:41d0:a:2b18::1]:8333 -[2001:41d0:a:3a9c::1]:8333 -[2001:41d0:a:4903::]:8333 -[2001:41d0:a:57b::1]:8333 -[2001:41d0:a:5c7a::]:8333 -[2001:41d0:a:6c29::1]:8333 -[2001:41d0:a:f482::1]:8333 -[2001:41d0:b:854:b7c:b7c:b7c:b7c]:8333 -[2001:41d0:d:111c::]:8333 -[2001:44b8:4116:7801:4216:7eff:fe78:3fe4]:8333 -[2001:470:1f08:837::2]:8333 -[2001:470:1f08:c33::2]:8333 -[2001:470:1f09:bca:218:7dff:fe10:be33]:8333 -[2001:470:1f0f:22d::212:26]:8333 -[2001:470:1f11:12d5::ae1:5611]:8333 -[2001:470:1f14:57a::2]:8333 -[2001:470:1f14:7d::2]:8333 -[2001:470:1f15:57c::1]:8333 -[2001:470:1f15:dda:3d9a:3f11:9a56:ed64]:8333 -[2001:470:25:482::2]:8333 -[2001:470:25:e4::2]:8333 -[2001:470:4:26b::2]:8333 -[2001:470:5f:5f::232]:8333 -[2001:470:66:119::2]:8333 -[2001:470:67:39d::71]:8333 -[2001:470:6c4f::cafe]:8333 -[2001:470:8:2e1::43]:8333 -[2001:470:90a7:96::afe:6021]:8333 -[2001:470:95c1::2]:8333 -[2001:470:b1d0:ffff::1000]:8333 -[2001:470:c1f2:3::201]:8333 -[2001:470:d00d:0:3664:a9ff:fe9a:5150]:8333 -[2001:470:e250:0:211:11ff:feb9:924c]:8333 -[2001:4800:7817:101:be76:4eff:fe04:dc52]:8333 -[2001:4800:7819:104:be76:4eff:fe04:7809]:8333 -[2001:4800:7819:104:be76:4eff:fe05:c828]:8333 -[2001:4802:7800:2:30d7:1775:ff20:1858]:8333 -[2001:4802:7802:101:be76:4eff:fe20:256]:8333 -[2001:4802:7802:103:be76:4eff:fe20:2de8]:8333 -[2001:4830:1100:2e8::2]:8333 -[2001:4ba0:fff7:181:dead::1]:8333 -[2001:4ba0:fffa:5d::93]:8333 -[2001:4ba0:ffff:1be:1:1005:0:1]:8335 -[2001:4c48:110:101:216:3eff:fe24:1162]:8333 -[2001:4dd0:f101::32]:8333 -[2001:4dd0:ff00:867f::3]:8333 -[2001:4dd0:ff00:9a67::9]:8333 -[2001:4dd0:ff00:9c55:c23f:d5ff:fe6c:7ee9]:8333 -[2001:5c0:1400:b::3cc7]:8333 -[2001:5c0:1400:b::3d01]:8333 -[2001:5c0:1400:b::8df]:8333 -[2001:5c0:1501:300::3]:8333 -[2001:610:1b19::3]:8333 -[2001:620:500:fff0:f21f:afff:fecf:91cc]:8333 -[2001:67c:1220:80c:ad:8de2:f7e2:c784]:8333 -[2001:67c:21ec:1000::b]:8333 -[2001:6f8:1296:0:76d4:35ff:feba:1d26]:8333 -[2001:840:f000:4250:3e4a:92ff:fe6d:145f]:8333 -[2001:8d8:840:500::39:1ae]:8333 -[2001:980:efd8:0:21:de4a:2709:912]:8333 -[2001:981:46:1::3]:8333 -[2001:981:9319:2:c0:a8:c8:8]:8333 -[2001:9d8:cafe:3::91]:8333 -[2001:ad0:1:1:26be:5ff:fe25:959d]:8333 -[2001:ba8:1f1:f34c::2]:8333 -[2001:bc8:381c:100::1]:8333 -[2002:175c:4caa::175c:4caa]:8333 -[2002:4404:82f1:0:8d55:8fbb:15fa:f4e0]:8333 -[2002:4475:2233:0:21f:5bff:fe33:9f70]:8333 -[2002:596c:48c3::596c:48c3]:8333 -[2002:8c6d:6521:9617:12bf:48ff:fed8:1724]:8333 -[2002:a646:5e6a::1:2]:8333 -[2002:b009:20c5::b009:20c5]:8333 -[2400:8900::f03c:91ff:fe6e:823e]:8333 -[2400:8900::f03c:91ff:fe70:d164]:8333 -[2400:8901::f03c:91ff:fe37:9761]:8333 -[2403:4200:403:2::ff]:8333 -[2403:b800:1000:64:40a:e9ff:fe5f:94c1]:8333 -[2403:b800:1000:64:9879:17ff:fe6a:a59f]:8333 -[2600:3c00::f03c:91ff:fe18:59b2]:8333 -[2600:3c00::f03c:91ff:fe37:a4b1]:8333 -[2600:3c00::f03c:91ff:fe56:2973]:8333 -[2600:3c00::f03c:91ff:fe6e:7297]:8333 -[2600:3c00::f03c:91ff:fe84:8a6e]:8333 -[2600:3c01::f03c:91ff:fe18:6adf]:8333 -[2600:3c01::f03c:91ff:fe18:e217]:8333 -[2600:3c01::f03c:91ff:fe33:1b31]:8333 -[2600:3c01::f03c:91ff:fe33:2fe1]:8333 -[2600:3c01::f03c:91ff:fe33:a03f]:8333 -[2600:3c01::f03c:91ff:fe50:5e06]:8333 -[2600:3c01::f03c:91ff:fe56:d645]:8333 -[2600:3c01::f03c:91ff:fe6e:a3dc]:8333 -[2600:3c01::f03c:91ff:fe89:a659]:8333 -[2600:3c02::f03c:91ff:fe6e:6f0b]:8333 -[2600:3c03::f03c:91ff:fe33:f6fb]:8333 -[2600:3c03::f03c:91ff:fe50:5fa7]:8333 -[2600:3c03::f03c:91ff:fe6e:1803]:8333 -[2600:3c03::f03c:91ff:fe6e:4ac0]:8333 -[2601:6:4800:47f:1e4e:1f4d:332c:3bf6]:8333 -[2601:d:5400:fed:8d54:c1e8:7ed7:d45e]:8333 -[2602:100:4b8f:6d2a:20c:29ff:feaf:c4c2]:8333 -[2602:ffc5:1f::1f:2d61]:8333 -[2602:ffc5:1f::1f:9211]:8333 -[2602:ffc5::ffc5:b844]:8333 -[2602:ffe8:100:2::457:936b]:8333 -[2602:ffea:1001:125::2ad4]:8333 -[2602:ffea:1001:6ff::837d]:8333 -[2602:ffea:1001:72b::578b]:8333 -[2602:ffea:1001:77a::9cae]:8333 -[2602:ffea:1:2fe::6bc8]:8333 -[2602:ffea:1:701::7968]:8333 -[2602:ffea:1:70d::82ec]:8333 -[2602:ffea:1:9ff::e957]:8333 -[2602:ffea:1:a5d::4acb]:8333 -[2602:ffea:a::24c4:d9fd]:8333 -[2602:ffea:a::c06:ae32]:8333 -[2604:0:c1:100:1ec1:deff:fe54:2235]:8333 -[2604:180:1:1af::42a9]:8333 -[2604:180::b208:398]:8333 -[2604:2880::6072:aed]:8333 -[2604:4080:1114:0:3285:a9ff:fe93:850c]:8333 -[2604:7c00:17:3d0::5a4d]:8333 -[2604:9a00:2100:a009:2::]:8333 -[2604:a880:1:20::22a:4001]:8333 -[2604:a880:800:10::752:f001]:8333 -[2604:c00:88:32:216:3eff:fee4:fcca]:8333 -[2604:c00:88:32:216:3eff:fef5:bc21]:8333 -[2605:7980:1:2::1761:3d4e]:8333 -[2605:e000:1417:4068:223:32ff:fe96:e2d]:8333 -[2606:6000:a441:9903:5054:ff:fe78:66ff]:8333 -[2606:df00:2::ae85:8fc6]:8333 -[2607:5300:100:200::e7f]:8333 -[2607:5300:10::a1]:8333 -[2607:5300:60:116e::1]:8333 -[2607:5300:60:1535::]:8333 -[2607:5300:60:1b32::1]:8333 -[2607:5300:60:2337::1]:8333 -[2607:5300:60:2b90::1]:8333 -[2607:5300:60:2d99::1]:8333 -[2607:5300:60:3cb::1]:8333 -[2607:5300:60:4a85::]:8333 -[2607:5300:60:5112:0:2:4af5:63fe]:8333 -[2607:5300:60:6dd5::]:8333 -[2607:5300:60:a91::1]:8333 -[2607:f1c0:820:1500::7f:3f44]:8333 -[2607:f1c0:848:1000::48:943c]:8333 -[2607:f948:0:1::7]:8333 -[2607:fcd0:100:2300::4ad:e594]:8333 -[2607:fcd0:100:2300::659e:9cb3]:8333 -[2607:fcd0:100:2300::c74b:a8ae]:8333 -[2607:fcd0:100:2300::d82:d8c2]:8333 -[2607:fcd0:100:4300::8795:2fa8]:8333 -[2607:fcd0:daaa:901::9561:e043]:8333 -[2a00:1178:2:43:5054:ff:fee7:2eb6]:8333 -[2a00:1328:e100:cc42:230:48ff:fe92:55d]:8333 -[2a00:14f0:e000:80d2:cd1a::1]:8333 -[2a00:16d8:c::5b6a:c261]:8333 -[2a00:61e0:4083:6d01:6852:1376:e972:2091]:8333 -[2a00:c98:2030:a02f:2::2]:8333 -[2a01:1b0:7999:402::131]:8333 -[2a01:1e8:e100:811c:700f:65f0:f72a:1084]:8333 -[2a01:238:42da:c500:6546:1293:5422:ab40]:8333 -[2a01:348:6:473::2]:8333 -[2a01:368:e010:2::2]:8333 -[2a01:430:17:1::ffff:549]:8333 -[2a01:430:17:1::ffff:830]:8333 -[2a01:488:66:1000:53a9:d04:0:1]:8333 -[2a01:488:66:1000:57e6:578c:0:1]:8333 -[2a01:488:66:1000:b01c:178d:0:1]:8333 -[2a01:488:67:1000:523:fdce:0:1]:8333 -[2a01:488:67:1000:b01c:30ab:0:1]:8333 -[2a01:4f8:100:24aa::2]:8333 -[2a01:4f8:100:44e7::2]:8333 -[2a01:4f8:100:5128::2]:8333 -[2a01:4f8:100:84a7::1:1]:8333 -[2a01:4f8:110:516c::2]:8333 -[2a01:4f8:110:536e::2]:8333 -[2a01:4f8:120:62e6::2]:8333 -[2a01:4f8:120:702e::2]:8333 -[2a01:4f8:120:8005::2]:8333 -[2a01:4f8:120:8203::2]:8333 -[2a01:4f8:120:8422::2]:8333 -[2a01:4f8:121:11eb::2]:8333 -[2a01:4f8:121:261::2]:8333 -[2a01:4f8:130:242b::10]:8333 -[2a01:4f8:130:242b::5]:8333 -[2a01:4f8:130:2468::3]:8333 -[2a01:4f8:130:632c::2]:8333 -[2a01:4f8:130:6366::2]:8333 -[2a01:4f8:130:6426::2]:8333 -[2a01:4f8:130:934f::2]:8333 -[2a01:4f8:131:2070::2]:8333 -[2a01:4f8:131:54a2::2]:8333 -[2a01:4f8:140:80ad::2]:8333 -[2a01:4f8:141:186::2]:8333 -[2a01:4f8:150:210b::2]:8333 -[2a01:4f8:150:2263::5]:8333 -[2a01:4f8:150:2349::2]:8333 -[2a01:4f8:150:61ee::2]:8333 -[2a01:4f8:150:7088:5054:ff:fe45:bff2]:8333 -[2a01:4f8:150:8324::2]:9001 -[2a01:4f8:151:1d8::2]:8333 -[2a01:4f8:151:5128::2]:8333 -[2a01:4f8:151:6347::2]:9001 -[2a01:4f8:161:526d::2]:8333 -[2a01:4f8:161:9349::2]:8333 -[2a01:4f8:162:23c6::2]:8333 -[2a01:4f8:162:4348::2]:8333 -[2a01:4f8:162:7345::2]:8333 -[2a01:4f8:162:7383::2]:8333 -[2a01:4f8:162:74e3::2]:8333 -[2a01:4f8:190:6065::2]:8333 -[2a01:4f8:190:6349::2]:8333 -[2a01:4f8:190:64c9::2]:8333 -[2a01:4f8:190:91ce::2]:8333 -[2a01:4f8:191:2194::83]:8333 -[2a01:4f8:191:40a1::2]:8333 -[2a01:4f8:191:4a7::2]:8333 -[2a01:4f8:191:63b4:5000::1]:8333 -[2a01:4f8:191:7121::2]:8333 -[2a01:4f8:191:83a2::2]:8333 -[2a01:4f8:191:93c4::2]:8333 -[2a01:4f8:192:60a9:0:1:5:2]:8333 -[2a01:4f8:192:73b2::2]:8333 -[2a01:4f8:192:8098::2]:8333 -[2a01:4f8:192:db::2]:8333 -[2a01:4f8:200:1012::2]:8333 -[2a01:4f8:200:22e3::2]:8333 -[2a01:4f8:200:414e::2]:8333 -[2a01:4f8:200:63af::222]:8333 -[2a01:4f8:200:71e3:78b4:f3ff:fead:e8cf]:8333 -[2a01:4f8:201:5164::2]:8333 -[2a01:4f8:201:6011::4]:8333 -[2a01:4f8:201:60d5::2]:8333 -[2a01:4f8:202:53c3::2]:8333 -[2a01:4f8:210:24aa::2]:8333 -[2a01:4f8:210:502f::2]:8333 -[2a01:4f8:211:14cf::2]:8333 -[2a01:4f8:211:1a59::2]:8333 -[2a01:4f8:211:2ac1::2]:8333 -[2a01:4f8:211:cca::2]:8333 -[2a01:4f8:a0:22a5::2]:8333 -[2a01:4f8:a0:5023::2]:8333 -[2a01:4f8:a0:5243::2]:8333 -[2a01:4f8:a0:74c8::2]:8333 -[2a01:4f8:a0:8227::2]:8333 -[2a01:4f8:a0:822d::2]:8333 -[2a01:4f8:d13:2183::2]:8333 -[2a01:608:ffff:a009:8bf5:879d:e51a:f837]:8333 -[2a01:79d:469e:ed94:c23f:d5ff:fe65:20c5]:8333 -[2a01:7c8:aab5:3e6:5054:ff:fed7:4e54]:8333 -[2a01:7e00::f03c:91ff:fe18:301e]:8333 -[2a01:7e00::f03c:91ff:fe18:7749]:8333 -[2a01:7e00::f03c:91ff:fe33:2d67]:8333 -[2a01:7e00::f03c:91ff:fe33:347c]:8333 -[2a01:7e00::f03c:91ff:fe33:ae50]:8333 -[2a01:7e00::f03c:91ff:fe56:6b5c]:8333 -[2a01:7e00::f03c:91ff:fe56:bee6]:8333 -[2a01:7e00::f03c:91ff:fe69:4895]:8333 -[2a01:7e00::f03c:91ff:fe69:9912]:8333 -[2a01:7e00::f03c:91ff:fe6e:26ee]:8333 -[2a01:7e00::f03c:91ff:fe73:42f1]:8333 -[2a01:7e00::f03c:91ff:fe84:434f]:8333 -[2a01:7e00::f03c:91ff:fe84:b36b]:8333 -[2a01:7e00::f03c:91ff:fe89:1faa]:8333 -[2a01:7e00::f03c:91ff:fe98:816]:8333 -[2a01:7e00::f03c:91ff:fedb:352e]:8333 -[2a01:7e00::f03c:91ff:fedb:4a1d]:8333 -[2a01:e34:edbb:6750:224:1dff:fe89:3897]:8333 -[2a01:e35:2f1d:3fb0:7187:c7ba:bcfc:80ce]:8333 -[2a01:e35:8787:96f0:9032:9297:39ae:496d]:8333 -[2a01:e35:8a3f:47c0:c617:feff:fe3c:9fbd]:8333 -[2a01:e35:8b66:6a0:4900:9dfd:d841:d025]:8333 -[2a02:168:4a01::39]:8333 -[2a02:168:5404:2:c23f:d5ff:fe6a:512e]:8333 -[2a02:180:1:1::5b8f:538c]:8333 -[2a02:2028:1016::2]:8333 -[2a02:2528:503:2::14]:8333 -[2a02:2528:503:2::15]:8333 -[2a02:2528:ff00:81a6:21e:c5ff:fe8d:f9a5]:8333 -[2a02:2770:5:0:21a:4aff:fee4:c7db]:8333 -[2a02:2770:8:0:21a:4aff:fe7b:3dcd]:8333 -[2a02:348:5e:5a29::1]:8333 -[2a02:7aa0:1619::202f:c06a]:8333 -[2a02:8109:8e40:35fc:ba27:ebff:feae:cf16]:8333 -[2a02:af8:6:1500::1:130]:8333 -[2a02:c200:0:10:1:0:6314:2222]:8333 -[2a02:c200:0:10:2:3:3295:1]:8332 -[2a02:c200:0:10:3:0:5449:1]:8333 -[2a02:c200:1:10:2:3:5899:1]:8333 -[2a02:c200:1:10::2705:1]:8333 -[2a02:ce80:0:20::1]:8333 -[2a02:fe0:c321:27e0:6ef0:49ff:fe11:a61d]:8333 -[2a03:4000:2:496::8]:8333 -[2a03:b0c0:0:1010::62:f001]:8333 -[2a03:f80:ed16:ca7:ea75:b12d:2af:9e2a]:8333 -3ffk7iumtx3cegbi.onion:8333 -3hshaantu6ot4upz.onion:8333 -45c5lc77qgpikafy.onion:8333 -77mx2jsxaoyesz2p.onion:8333 -7g7j54btiaxhtsiy.onion:8333 -b6fr7dlbu2kpiysf.onion:8333 -bitcoincfqcssig5.onion:8333 -bitcoinostk4e4re.onion:8333 -bmutjfrj5btseddb.onion:8333 -drp4pvejybx2ejdr.onion:8333 -gixnv56d63buypan.onion:8333 -h2vlpudzphzqxutd.onion:8333 -hhiv5pnxenvbf4am.onion:8333 -lzxpkn6ptp3ohh63.onion:8333 -msphsgfiqfq5stne.onion:8333 -ncwk3lutemffcpc4.onion:8333 -okdzjarwekbshnof.onion:8333 -sjdomi4yb2dwkjbc.onion:8333 -uvwozwxlihntigbb.onion:8333 -v6ylz45dn5ybpk4d.onion:8333 -vk3qjdehyy4dwcxw.onion:8333 -vqpye2k5rcqvj5mq.onion:8333 -xudkoztdfrsuyyou.onion:8333 -z55v4ostefnwfy32.onion:8333 diff --git a/depend/zcash/contrib/seeds/nodes_test.txt b/depend/zcash/contrib/seeds/nodes_test.txt deleted file mode 100644 index 98365ee50..000000000 --- a/depend/zcash/contrib/seeds/nodes_test.txt +++ /dev/null @@ -1,11 +0,0 @@ -# List of fixed seed nodes for testnet - -# Onion nodes -thfsmmn2jbitcoin.onion -it2pj4f7657g3rhi.onion -nkf5e6b7pl4jfd4a.onion -4zhkir2ofl7orfom.onion -t6xj6wilh4ytvcs7.onion -i6y6ivorwakd7nw3.onion -ubqj4rsu3nqtxmtp.onion - diff --git a/depend/zcash/contrib/spendfrom/README.md b/depend/zcash/contrib/spendfrom/README.md deleted file mode 100644 index c0a9c9ccf..000000000 --- a/depend/zcash/contrib/spendfrom/README.md +++ /dev/null @@ -1,35 +0,0 @@ -### SpendFrom ### - -Use the raw transactions API to send coins received on a particular -address (or addresses). - -### Usage: ### -Depends on [jsonrpc](http://json-rpc.org/). - - spendfrom.py --from=FROMADDRESS1[,FROMADDRESS2] --to=TOADDRESS --amount=amount \ - --fee=fee --datadir=/path/to/.bitcoin --testnet --dry_run - -With no arguments, outputs a list of amounts associated with addresses. - -With arguments, sends coins received by the `FROMADDRESS` addresses to the `TOADDRESS`. - -### Notes ### - -- You may explicitly specify how much fee to pay (a fee more than 1% of the amount -will fail, though, to prevent bitcoin-losing accidents). Spendfrom may fail if -it thinks the transaction would never be confirmed (if the amount being sent is -too small, or if the transaction is too many bytes for the fee). - -- If a change output needs to be created, the change will be sent to the last -`FROMADDRESS` (if you specify just one `FROMADDRESS`, change will go back to it). - -- If `--datadir` is not specified, the default datadir is used. - -- The `--dry_run` option will just create and sign the transaction and print -the transaction data (as hexadecimal), instead of broadcasting it. - -- If the transaction is created and broadcast successfully, a transaction id -is printed. - -- If this was a tool for end-users and not programmers, it would have much friendlier -error-handling. diff --git a/depend/zcash/contrib/spendfrom/setup.py b/depend/zcash/contrib/spendfrom/setup.py deleted file mode 100644 index 01b9768a5..000000000 --- a/depend/zcash/contrib/spendfrom/setup.py +++ /dev/null @@ -1,9 +0,0 @@ -from distutils.core import setup -setup(name='btcspendfrom', - version='1.0', - description='Command-line utility for bitcoin "coin control"', - author='Gavin Andresen', - author_email='gavin@bitcoinfoundation.org', - requires=['jsonrpc'], - scripts=['spendfrom.py'], - ) diff --git a/depend/zcash/contrib/spendfrom/spendfrom.py b/depend/zcash/contrib/spendfrom/spendfrom.py deleted file mode 100755 index 0729234eb..000000000 --- a/depend/zcash/contrib/spendfrom/spendfrom.py +++ /dev/null @@ -1,267 +0,0 @@ -#!/usr/bin/env python -# -# Use the raw transactions API to spend bitcoins received on particular addresses, -# and send any change back to that same address. -# -# Example usage: -# spendfrom.py # Lists available funds -# spendfrom.py --from=ADDRESS --to=ADDRESS --amount=11.00 -# -# Assumes it will talk to a bitcoind or Bitcoin-Qt running -# on localhost. -# -# Depends on jsonrpc -# - -from decimal import * -import getpass -import math -import os -import os.path -import platform -import sys -import time -from jsonrpc import ServiceProxy, json - -BASE_FEE=Decimal("0.001") - -def check_json_precision(): - """Make sure json library being used does not lose precision converting BTC values""" - n = Decimal("20000000.00000003") - satoshis = int(json.loads(json.dumps(float(n)))*1.0e8) - if satoshis != 2000000000000003: - raise RuntimeError("JSON encode/decode loses precision") - -def determine_db_dir(): - """Return the default location of the bitcoin data directory""" - if platform.system() == "Darwin": - return os.path.expanduser("~/Library/Application Support/Bitcoin/") - elif platform.system() == "Windows": - return os.path.join(os.environ['APPDATA'], "Bitcoin") - return os.path.expanduser("~/.bitcoin") - -def read_bitcoin_config(dbdir): - """Read the bitcoin.conf file from dbdir, returns dictionary of settings""" - from ConfigParser import SafeConfigParser - - class FakeSecHead(object): - def __init__(self, fp): - self.fp = fp - self.sechead = '[all]\n' - def readline(self): - if self.sechead: - try: return self.sechead - finally: self.sechead = None - else: - s = self.fp.readline() - if s.find('#') != -1: - s = s[0:s.find('#')].strip() +"\n" - return s - - config_parser = SafeConfigParser() - config_parser.readfp(FakeSecHead(open(os.path.join(dbdir, "bitcoin.conf")))) - return dict(config_parser.items("all")) - -def connect_JSON(config): - """Connect to a bitcoin JSON-RPC server""" - testnet = config.get('testnet', '0') - testnet = (int(testnet) > 0) # 0/1 in config file, convert to True/False - if not 'rpcport' in config: - config['rpcport'] = 18232 if testnet else 8232 - connect = "http://%s:%s@127.0.0.1:%s"%(config['rpcuser'], config['rpcpassword'], config['rpcport']) - try: - result = ServiceProxy(connect) - # ServiceProxy is lazy-connect, so send an RPC command mostly to catch connection errors, - # but also make sure the bitcoind we're talking to is/isn't testnet: - if result.getmininginfo()['testnet'] != testnet: - sys.stderr.write("RPC server at "+connect+" testnet setting mismatch\n") - sys.exit(1) - return result - except: - sys.stderr.write("Error connecting to RPC server at "+connect+"\n") - sys.exit(1) - -def unlock_wallet(bitcoind): - info = bitcoind.getinfo() - if 'unlocked_until' not in info: - return True # wallet is not encrypted - t = int(info['unlocked_until']) - if t <= time.time(): - try: - passphrase = getpass.getpass("Wallet is locked; enter passphrase: ") - bitcoind.walletpassphrase(passphrase, 5) - except: - sys.stderr.write("Wrong passphrase\n") - - info = bitcoind.getinfo() - return int(info['unlocked_until']) > time.time() - -def list_available(bitcoind): - address_summary = dict() - - address_to_account = dict() - for info in bitcoind.listreceivedbyaddress(0): - address_to_account[info["address"]] = info["account"] - - unspent = bitcoind.listunspent(0) - for output in unspent: - # listunspent doesn't give addresses, so: - rawtx = bitcoind.getrawtransaction(output['txid'], 1) - vout = rawtx["vout"][output['vout']] - pk = vout["scriptPubKey"] - - # This code only deals with ordinary pay-to-bitcoin-address - # or pay-to-script-hash outputs right now; anything exotic is ignored. - if pk["type"] != "pubkeyhash" and pk["type"] != "scripthash": - continue - - address = pk["addresses"][0] - if address in address_summary: - address_summary[address]["total"] += vout["value"] - address_summary[address]["outputs"].append(output) - else: - address_summary[address] = { - "total" : vout["value"], - "outputs" : [output], - "account" : address_to_account.get(address, "") - } - - return address_summary - -def select_coins(needed, inputs): - # Feel free to improve this, this is good enough for my simple needs: - outputs = [] - have = Decimal("0.0") - n = 0 - while have < needed and n < len(inputs): - outputs.append({ "txid":inputs[n]["txid"], "vout":inputs[n]["vout"]}) - have += inputs[n]["amount"] - n += 1 - return (outputs, have-needed) - -def create_tx(bitcoind, fromaddresses, toaddress, amount, fee): - all_coins = list_available(bitcoind) - - total_available = Decimal("0.0") - needed = amount+fee - potential_inputs = [] - for addr in fromaddresses: - if addr not in all_coins: - continue - potential_inputs.extend(all_coins[addr]["outputs"]) - total_available += all_coins[addr]["total"] - - if total_available < needed: - sys.stderr.write("Error, only %f BTC available, need %f\n"%(total_available, needed)); - sys.exit(1) - - # - # Note: - # Python's json/jsonrpc modules have inconsistent support for Decimal numbers. - # Instead of wrestling with getting json.dumps() (used by jsonrpc) to encode - # Decimals, I'm casting amounts to float before sending them to bitcoind. - # - outputs = { toaddress : float(amount) } - (inputs, change_amount) = select_coins(needed, potential_inputs) - if change_amount > BASE_FEE: # don't bother with zero or tiny change - change_address = fromaddresses[-1] - if change_address in outputs: - outputs[change_address] += float(change_amount) - else: - outputs[change_address] = float(change_amount) - - rawtx = bitcoind.createrawtransaction(inputs, outputs) - signed_rawtx = bitcoind.signrawtransaction(rawtx) - if not signed_rawtx["complete"]: - sys.stderr.write("signrawtransaction failed\n") - sys.exit(1) - txdata = signed_rawtx["hex"] - - return txdata - -def compute_amount_in(bitcoind, txinfo): - result = Decimal("0.0") - for vin in txinfo['vin']: - in_info = bitcoind.getrawtransaction(vin['txid'], 1) - vout = in_info['vout'][vin['vout']] - result = result + vout['value'] - return result - -def compute_amount_out(txinfo): - result = Decimal("0.0") - for vout in txinfo['vout']: - result = result + vout['value'] - return result - -def sanity_test_fee(bitcoind, txdata_hex, max_fee): - class FeeError(RuntimeError): - pass - try: - txinfo = bitcoind.decoderawtransaction(txdata_hex) - total_in = compute_amount_in(bitcoind, txinfo) - total_out = compute_amount_out(txinfo) - if total_in-total_out > max_fee: - raise FeeError("Rejecting transaction, unreasonable fee of "+str(total_in-total_out)) - - tx_size = len(txdata_hex)/2 - kb = tx_size/1000 # integer division rounds down - if kb > 1 and fee < BASE_FEE: - raise FeeError("Rejecting no-fee transaction, larger than 1000 bytes") - if total_in < 0.01 and fee < BASE_FEE: - raise FeeError("Rejecting no-fee, tiny-amount transaction") - # Exercise for the reader: compute transaction priority, and - # warn if this is a very-low-priority transaction - - except FeeError as err: - sys.stderr.write((str(err)+"\n")) - sys.exit(1) - -def main(): - import optparse - - parser = optparse.OptionParser(usage="%prog [options]") - parser.add_option("--from", dest="fromaddresses", default=None, - help="addresses to get bitcoins from") - parser.add_option("--to", dest="to", default=None, - help="address to get send bitcoins to") - parser.add_option("--amount", dest="amount", default=None, - help="amount to send") - parser.add_option("--fee", dest="fee", default="0.0", - help="fee to include") - parser.add_option("--datadir", dest="datadir", default=determine_db_dir(), - help="location of bitcoin.conf file with RPC username/password (default: %default)") - parser.add_option("--testnet", dest="testnet", default=False, action="store_true", - help="Use the test network") - parser.add_option("--dry_run", dest="dry_run", default=False, action="store_true", - help="Don't broadcast the transaction, just create and print the transaction data") - - (options, args) = parser.parse_args() - - check_json_precision() - config = read_bitcoin_config(options.datadir) - if options.testnet: config['testnet'] = True - bitcoind = connect_JSON(config) - - if options.amount is None: - address_summary = list_available(bitcoind) - for address,info in address_summary.iteritems(): - n_transactions = len(info['outputs']) - if n_transactions > 1: - print("%s %.8f %s (%d transactions)"%(address, info['total'], info['account'], n_transactions)) - else: - print("%s %.8f %s"%(address, info['total'], info['account'])) - else: - fee = Decimal(options.fee) - amount = Decimal(options.amount) - while unlock_wallet(bitcoind) == False: - pass # Keep asking for passphrase until they get it right - txdata = create_tx(bitcoind, options.fromaddresses.split(","), options.to, amount, fee) - sanity_test_fee(bitcoind, txdata, amount*Decimal("0.01")) - if options.dry_run: - print(txdata) - else: - txid = bitcoind.sendrawtransaction(txdata) - print(txid) - -if __name__ == '__main__': - main() diff --git a/depend/zcash/contrib/test-patches/README.md b/depend/zcash/contrib/test-patches/README.md deleted file mode 100644 index def40b0d6..000000000 --- a/depend/zcash/contrib/test-patches/README.md +++ /dev/null @@ -1,7 +0,0 @@ -### Test Patches ### - -These patches are applied when the automated pull-tester -tests each pull and when master is tested using jenkins. -You can find more information about the tests run at -[http://jenkins.bluematt.me/pull-tester/files/ -](http://jenkins.bluematt.me/pull-tester/files/) \ No newline at end of file diff --git a/depend/zcash/contrib/test-patches/temp-revert-2.patch b/depend/zcash/contrib/test-patches/temp-revert-2.patch deleted file mode 100644 index 1cd043d0d..000000000 --- a/depend/zcash/contrib/test-patches/temp-revert-2.patch +++ /dev/null @@ -1,20 +0,0 @@ -commit cfae26916dba311f6f75d444301c1f9362267c3e -Author: Matt Corallo -Date: Sun Mar 24 20:45:50 2013 -0400 - - Revert "Checkpoint at first block in 11 March chain fork" - - This reverts commit f817c496a1482d05b22c8e539de67f07db1c09d9. - -diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp -index 62234b9..9b11f0b 100644 ---- a/src/checkpoints.cpp -+++ b/src/checkpoints.cpp -@@ -44,7 +44,6 @@ namespace Checkpoints - (193000, uint256("0x000000000000059f452a5f7340de6682a977387c17010ff6e6c3bd83ca8b1317")) - (210000, uint256("0x000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e")) - (216116, uint256("0x00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e")) -- (225430, uint256("0x00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932")) - ; - static const CCheckpointData data = { - &mapCheckpoints, diff --git a/depend/zcash/contrib/verify-commits/gpg.sh b/depend/zcash/contrib/verify-commits/gpg.sh deleted file mode 100755 index 6b5137e7b..000000000 --- a/depend/zcash/contrib/verify-commits/gpg.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -INPUT=$(/dev/null); do - case "$LINE" in "[GNUPG:] VALIDSIG"*) - while read KEY; do - case "$LINE" in "[GNUPG:] VALIDSIG $KEY "*) VALID=true;; esac - done < ./contrib/verify-commits/trusted-keys - esac -done -if ! $VALID; then - exit 1 -fi -echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null diff --git a/depend/zcash/contrib/verify-commits/pre-push-hook.sh b/depend/zcash/contrib/verify-commits/pre-push-hook.sh deleted file mode 100755 index 607c0cac4..000000000 --- a/depend/zcash/contrib/verify-commits/pre-push-hook.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -if ! [[ "$2" =~ [git@]?[www.]?github.com[:|/]bitcoin/bitcoin[.git]? ]]; then - exit 0 -fi - -while read LINE; do - set -- A $LINE - if [ "$4" != "refs/heads/master" ]; then - continue - fi - if ! ./contrib/verify-commits/verify-commits.sh $3 > /dev/null 2>&1; then - echo "ERROR: A commit is not signed, can't push" - ./contrib/verify-commits/verify-commits.sh - exit 1 - fi -done < /dev/stdin diff --git a/depend/zcash/contrib/verify-commits/trusted-git-root b/depend/zcash/contrib/verify-commits/trusted-git-root deleted file mode 100644 index eb13f8762..000000000 --- a/depend/zcash/contrib/verify-commits/trusted-git-root +++ /dev/null @@ -1 +0,0 @@ -053038e5ba116cb319fb85f3cb3e062cf1b3df15 diff --git a/depend/zcash/contrib/verify-commits/trusted-keys b/depend/zcash/contrib/verify-commits/trusted-keys deleted file mode 100644 index 658ad0375..000000000 --- a/depend/zcash/contrib/verify-commits/trusted-keys +++ /dev/null @@ -1,5 +0,0 @@ -71A3B16735405025D447E8F274810B012346C9A6 -1F4410F6A89268CE3197A84C57896D2FF8F0B657 -01CDF4627A3B88AAE4A571C87588242FBE38D3A8 -AF8BE07C7049F3A26B239D5325B3083201782B2F -81291FA67D2C379A006A053FEAB5AF94D9E9ABE7 diff --git a/depend/zcash/contrib/verify-commits/verify-commits.sh b/depend/zcash/contrib/verify-commits/verify-commits.sh deleted file mode 100755 index 5841fa207..000000000 --- a/depend/zcash/contrib/verify-commits/verify-commits.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh - -DIR=$(dirname "$0") - -echo "Please verify all commits in the following list are not evil:" -git log "$DIR" - -VERIFIED_ROOT=$(cat "${DIR}/trusted-git-root") - -HAVE_FAILED=false -IS_SIGNED () { - if [ $1 = $VERIFIED_ROOT ]; then - return 0; - fi - if ! git -c "gpg.program=${DIR}/gpg.sh" verify-commit $1 > /dev/null 2>&1; then - return 1; - fi - local PARENTS=$(git show -s --format=format:%P $1) - for PARENT in $PARENTS; do - if IS_SIGNED $PARENT > /dev/null; then - return 0; - fi - done - if ! "$HAVE_FAILED"; then - echo "No parent of $1 was signed with a trusted key!" > /dev/stderr - echo "Parents are:" > /dev/stderr - for PARENT in $PARENTS; do - git show -s $PARENT > /dev/stderr - done - HAVE_FAILED=true - fi - return 1; -} - -if [ x"$1" = "x" ]; then - TEST_COMMIT="HEAD" -else - TEST_COMMIT="$1" -fi - -IS_SIGNED "$TEST_COMMIT" -RES=$? -if [ "$RES" = 1 ]; then - if ! "$HAVE_FAILED"; then - echo "$TEST_COMMIT was not signed with a trusted key!" - fi -else - echo "There is a valid path from $TEST_COMMIT to $VERIFIED_ROOT where all commits are signed!" -fi - -exit $RES diff --git a/depend/zcash/contrib/verifysfbinaries/README.md b/depend/zcash/contrib/verifysfbinaries/README.md deleted file mode 100644 index 1db3fe52f..000000000 --- a/depend/zcash/contrib/verifysfbinaries/README.md +++ /dev/null @@ -1,6 +0,0 @@ -### Verify Binaries ### -This script attempts to download the signature file `SHA256SUMS.asc` from https://bitcoin.org. - -It first checks if the signature passes, and then downloads the files specified in the file, and checks if the hashes of these files match those that are specified in the signature file. - -The script returns 0 if everything passes the checks. It returns 1 if either the signature check or the hash check doesn't pass. If an error occurs the return value is 2. diff --git a/depend/zcash/contrib/verifysfbinaries/verify.sh b/depend/zcash/contrib/verifysfbinaries/verify.sh deleted file mode 100755 index 3eb469388..000000000 --- a/depend/zcash/contrib/verifysfbinaries/verify.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash - -### This script attempts to download the signature file SHA256SUMS.asc from bitcoin.org -### It first checks if the signature passes, and then downloads the files specified in -### the file, and checks if the hashes of these files match those that are specified -### in the signature file. -### The script returns 0 if everything passes the checks. It returns 1 if either the -### signature check or the hash check doesn't pass. If an error occurs the return value is 2 - -function clean_up { - for file in $* - do - rm "$file" 2> /dev/null - done -} - -WORKINGDIR="/tmp/bitcoin" -TMPFILE="hashes.tmp" - -#this URL is used if a version number is not specified as an argument to the script -SIGNATUREFILE="https://bitcoin.org/bin/0.9.2.1/SHA256SUMS.asc" - -SIGNATUREFILENAME="SHA256SUMS.asc" -RCSUBDIR="test/" -BASEDIR="https://bitcoin.org/bin/" -VERSIONPREFIX="bitcoin-" -RCVERSIONSTRING="rc" - -if [ ! -d "$WORKINGDIR" ]; then - mkdir "$WORKINGDIR" -fi - -cd "$WORKINGDIR" - -#test if a version number has been passed as an argument -if [ -n "$1" ]; then - #let's also check if the version number includes the prefix 'bitcoin-', - # and add this prefix if it doesn't - if [[ $1 == "$VERSIONPREFIX"* ]]; then - VERSION="$1" - else - VERSION="$VERSIONPREFIX$1" - fi - - #now let's see if the version string contains "rc", and strip it off if it does - # and simultaneously add RCSUBDIR to BASEDIR, where we will look for SIGNATUREFILENAME - if [[ $VERSION == *"$RCVERSIONSTRING"* ]]; then - BASEDIR="$BASEDIR${VERSION/%-$RCVERSIONSTRING*}/" - BASEDIR="$BASEDIR$RCSUBDIR" - else - BASEDIR="$BASEDIR$VERSION/" - fi - - SIGNATUREFILE="$BASEDIR$SIGNATUREFILENAME" -else - BASEDIR="${SIGNATUREFILE%/*}/" -fi - -#first we fetch the file containing the signature -WGETOUT=$(wget -N "$BASEDIR$SIGNATUREFILENAME" 2>&1) - -#and then see if wget completed successfully -if [ $? -ne 0 ]; then - echo "Error: couldn't fetch signature file. Have you specified the version number in the following format?" - echo "[bitcoin-]-[rc[0-9]] (example: bitcoin-0.9.2-rc1)" - echo "wget output:" - echo "$WGETOUT"|sed 's/^/\t/g' - exit 2 -fi - -#then we check it -GPGOUT=$(gpg --yes --decrypt --output "$TMPFILE" "$SIGNATUREFILENAME" 2>&1) - -#return value 0: good signature -#return value 1: bad signature -#return value 2: gpg error - -RET="$?" -if [ $RET -ne 0 ]; then - if [ $RET -eq 1 ]; then - #and notify the user if it's bad - echo "Bad signature." - elif [ $RET -eq 2 ]; then - #or if a gpg error has occurred - echo "gpg error. Do you have Gavin's code signing key installed?" - fi - - echo "gpg output:" - echo "$GPGOUT"|sed 's/^/\t/g' - clean_up $SIGNATUREFILENAME $TMPFILE - exit "$RET" -fi - -#here we extract the filenames from the signature file -FILES=$(awk '{print $2}' "$TMPFILE") - -#and download these one by one -for file in in $FILES -do - wget --quiet -N "$BASEDIR$file" -done - -#check hashes -DIFF=$(diff <(sha256sum $FILES) "$TMPFILE") - -if [ $? -eq 1 ]; then - echo "Hashes don't match." - echo "Offending files:" - echo "$DIFF"|grep "^<"|awk '{print "\t"$3}' - exit 1 -elif [ $? -gt 1 ]; then - echo "Error executing 'diff'" - exit 2 -fi - -#everything matches! clean up the mess -clean_up $FILES $SIGNATUREFILENAME $TMPFILE - -exit 0 diff --git a/depend/zcash/depends/Makefile b/depend/zcash/depends/Makefile index 524c8eb93..e10c853c9 100644 --- a/depend/zcash/depends/Makefile +++ b/depend/zcash/depends/Makefile @@ -4,7 +4,7 @@ SOURCES_PATH ?= $(BASEDIR)/sources BASE_CACHE ?= $(BASEDIR)/built SDK_PATH ?= $(BASEDIR)/SDKs NO_WALLET ?= -PRIORITY_DOWNLOAD_PATH ?= https://download.z.cash/depends-sources +FALLBACK_DOWNLOAD_PATH ?= https://download.z.cash/depends-sources BUILD ?= $(shell ./config.guess) HOST ?= $(BUILD) @@ -14,8 +14,7 @@ HASH_LENGTH:=11 DOWNLOAD_CONNECT_TIMEOUT:=10 DOWNLOAD_RETRIES:=3 CRATE_REGISTRY:=vendored-sources - -LIBRUSTZCASH_OVERRIDE ?= +CRATE_ARCHIVE = $(SOURCES_PATH)/vendored-crates.tar.gz host:=$(BUILD) ifneq ($(HOST),) @@ -78,19 +77,18 @@ include packages/packages.mk wallet_packages_$(NO_WALLET) = $(wallet_packages) -NO_PROTON_$(WITH_PROTON) = 1 -proton_packages_$(NO_PROTON_) = $(proton_packages) - -packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(rust_packages) $(proton_packages_) $(wallet_packages_) +packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(wallet_packages_) native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) all_packages = $(packages) $(native_packages) -meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk cargo-checksum.sh +meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk +$(host_arch)_$(host_os)_native_binutils?=$($(host_os)_native_binutils) $(host_arch)_$(host_os)_native_toolchain?=$($(host_os)_native_toolchain) include funcs.mk +binutils_path=$($($(host_arch)_$(host_os)_native_binutils)_prefixbin) toolchain_path=$($($(host_arch)_$(host_os)_native_toolchain)_prefixbin) final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in) final_build_id+=$(shell echo -n $(final_build_id_long) | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH)) @@ -100,6 +98,12 @@ $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages) $(AT)echo copying packages: $^ $(AT)echo to: $(@D) $(AT)cd $(@D); $(foreach package,$^, tar xf $($(package)_cached); ) + $(AT)if test -f "$(CRATE_ARCHIVE)"; \ + then echo Extracting pre-vendored crates from $(CRATE_ARCHIVE)...; \ + tar xf $(CRATE_ARCHIVE) -C $(@D); \ + else echo Vendoring crates...; \ + $(@D)/native/bin/cargo vendor --locked --manifest-path $(BASEDIR)/../Cargo.toml $(@D)/$(CRATE_REGISTRY); \ + fi $(AT)touch $@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_build_id) @@ -107,17 +111,17 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_ $(AT)sed -e 's|@HOST@|$(host)|' \ -e 's|@CC@|$(toolchain_path)$(host_CC)|' \ -e 's|@CXX@|$(toolchain_path)$(host_CXX)|' \ - -e 's|@AR@|$(toolchain_path)$(host_AR)|' \ - -e 's|@RANLIB@|$(toolchain_path)$(host_RANLIB)|' \ - -e 's|@NM@|$(toolchain_path)$(host_NM)|' \ - -e 's|@STRIP@|$(toolchain_path)$(host_STRIP)|' \ + -e 's|@AR@|$(binutils_path)$(host_AR)|' \ + -e 's|@RANLIB@|$(binutils_path)$(host_RANLIB)|' \ + -e 's|@NM@|$(binutils_path)$(host_NM)|' \ + -e 's|@STRIP@|$(binutils_path)$(host_STRIP)|' \ -e 's|@build_os@|$(build_os)|' \ -e 's|@host_os@|$(host_os)|' \ -e 's|@CFLAGS@|$(strip $(host_CFLAGS) $(host_$(release_type)_CFLAGS))|' \ -e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \ -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \ -e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \ - -e 's|@rust_target@|$(call rust_target,rust,$(canonical_host),$(host_os))|' \ + -e 's|@rust_target@|$(call rust_target,native_rust,$(canonical_host),$(host_os))|' \ -e 's|@no_wallet@|$(NO_WALLET)|' \ -e 's|@debug@|$(DEBUG)|' \ $< > $@ @@ -139,9 +143,13 @@ define check_or_remove_sources endef check-packages: - @$(foreach package,$(all_packages),$(call check_or_remove_cached,$(package));) + @$(foreach package,$(packages),$(call check_or_remove_cached,$(package));) + @$(foreach package,$(rust_crates),$(call check_or_remove_cached,$(package));) + @$(foreach package,$(native_packages),$(call check_or_remove_cached,$(package));) check-sources: - @$(foreach package,$(all_packages),$(call check_or_remove_sources,$(package));) + @$(foreach package,$(packages),$(call check_or_remove_sources,$(package));) + @$(foreach package,$(rust_crates),$(call check_or_remove_sources,$(package));) + @$(foreach package,$(native_packages),$(call check_or_remove_sources,$(package));) $(host_prefix)/share/config.site: check-packages @@ -150,14 +158,25 @@ check-packages: check-sources install: check-packages $(host_prefix)/share/config.site +crates_download_dir=$(base_download_dir)/crates +download-crates: native_rust + $(AT)echo Vendoring crates... + $(AT)mkdir -p $(SOURCES_PATH) + $(AT)rm -rf $(crates_download_dir) + $(AT)mkdir -p $(crates_download_dir) + $(AT)tar xf $(native_rust_cached) -C $(crates_download_dir) + $(AT)$(crates_download_dir)/native/bin/cargo vendor --locked --manifest-path $(BASEDIR)/../Cargo.toml $(crates_download_dir)/$(CRATE_REGISTRY) + $(AT)cd $(crates_download_dir); find $(CRATE_REGISTRY) | sort | tar --no-recursion -czf $(CRATE_ARCHIVE) -T - + $(AT)rm -rf $(crates_download_dir) + download-one: check-sources $(all_sources) download-osx: - @$(MAKE) -s HOST=x86_64-apple-darwin11 download-one + @$(MAKE) -s HOST=x86_64-apple-darwin14 download-one download-linux: - @$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one + @$(MAKE) -s HOST=x86_64-pc-linux-gnu download-one download-win: @$(MAKE) -s HOST=x86_64-w64-mingw32 download-one -download: download-osx download-linux download-win +download: download-crates download-osx download-linux download-win -.PHONY: install cached download-one download-osx download-linux download-win download check-packages check-sources +.PHONY: install cached download-crates download-one download-osx download-linux download-win download check-packages check-sources diff --git a/depend/zcash/depends/README.md b/depend/zcash/depends/README.md index 1b976af7e..df312aabd 100644 --- a/depend/zcash/depends/README.md +++ b/depend/zcash/depends/README.md @@ -22,8 +22,11 @@ Common `host-platform-triplets` for cross compilation are: - `i686-w64-mingw32` for Win32 - `x86_64-w64-mingw32` for Win64 -- `x86_64-apple-darwin11` for MacOSX -- `arm-linux-gnueabihf` for Linux ARM +- `x86_64-apple-darwin16` for macOS +- `arm-linux-gnueabihf` for Linux ARM 32 bit +- `aarch64-linux-gnu` for Linux ARM 64 bit +- `riscv32-linux-gnu` for Linux RISC-V 32 bit +- `riscv64-linux-gnu` for Linux RISC-V 64 bit No other options are needed, the paths are automatically configured. @@ -33,10 +36,9 @@ The following can be set when running make: make FOO=bar SOURCES_PATH: downloaded sources will be placed here BASE_CACHE: built packages will be placed here SDK_PATH: Path where sdk's can be found (used by OSX) - PRIORITY_DOWNLOAD_PATH: Try fetching source files from here before using their own URLs + FALLBACK_DOWNLOAD_PATH: If a source file can't be fetched, try here before giving up NO_WALLET: Don't download/build/cache libs needed to enable the wallet DEBUG: disable some optimizations and enable more runtime checking - LIBRUSTZCASH_OVERRIDE: Path to a local librustzcash repository If some packages are not built, for example `make NO_WALLET=1`, the appropriate options will be passed to bitcoin's configure. In this case, `--disable-wallet`. diff --git a/depend/zcash/depends/builders/darwin.mk b/depend/zcash/depends/builders/darwin.mk index f8ff4e23a..bcb02b782 100644 --- a/depend/zcash/depends/builders/darwin.mk +++ b/depend/zcash/depends/builders/darwin.mk @@ -19,4 +19,5 @@ darwin_LIBTOOL:=$(shell xcrun -f libtool) darwin_OTOOL:=$(shell xcrun -f otool) darwin_NM:=$(shell xcrun -f nm) darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool) +darwin_native_binutils= darwin_native_toolchain= diff --git a/depend/zcash/depends/cargo-checksum.sh b/depend/zcash/depends/cargo-checksum.sh deleted file mode 100755 index 535cc0bfd..000000000 --- a/depend/zcash/depends/cargo-checksum.sh +++ /dev/null @@ -1,13 +0,0 @@ -echo "{\"files\":{$( -find . -type f | # Get list of file paths -grep -v $1 | # Exclude Makefile hashes -grep -v '[.]stamp_' | # Exclude Makefile stamps -sed 's|^[.]/||' | # Remove leading ./ -sort | # Sort (for uniformity) -xargs $2 | # Get SHA256 hashes (assumes standard 'H(A) A' format) -awk -v OFS='":"' '{print $2, $1}' | # 'H(A) A' -> 'A":"H(A)' -sed 's|^|"|' | # 'A":"H(A)' -> '"A":"H(A)' -sed 's|$|"|' | # '"A":"H(A)' -> '"A":"H(A)"' -tr '\n' ',' | # Concatenate lines with commas -sed 's|,$||' # Remove any trailing comma (to fit JSON spec) -)},\"package\":$3}" > .cargo-checksum.json diff --git a/depend/zcash/depends/config.guess b/depend/zcash/depends/config.guess index f357ec6c8..8d70ec2b2 100755 --- a/depend/zcash/depends/config.guess +++ b/depend/zcash/depends/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2020 Free Software Foundation, Inc. -timestamp='2015-03-04' +timestamp='2020-09-19' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ timestamp='2015-03-04' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,7 +27,7 @@ timestamp='2015-03-04' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . @@ -39,7 +39,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -84,8 +84,6 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 - # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a @@ -96,34 +94,40 @@ trap 'exit 1' 1 2 15 # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD="$driver" + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi @@ -132,30 +136,35 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "${UNAME_SYSTEM}" in +case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu - eval $set_cc_for_build - cat <<-EOF > $dummy.c + set_cc_for_build + cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else + #include + #ifdef __DEFINED_va_list + LIBC=musl + #else LIBC=gnu #endif + #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" ;; esac # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -169,27 +178,30 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` - machine=${arch}${endian}-unknown + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine="${arch}${endian}"-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + # to ELF recently (or will in the future) and ABI. + case "$UNAME_MACHINE_ARCH" in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -205,10 +217,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -216,38 +228,60 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" + echo "$machine-${os}${release}${abi-}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" + exit ;; + *:OS108:*:*) + echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" + exit ;; + *:Sortix:*:*) + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Twizzler:*:*) + echo "$UNAME_MACHINE"-unknown-twizzler + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in @@ -265,63 +299,54 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos + echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos + echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -333,7 +358,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} + echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos @@ -360,38 +385,38 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} + echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" + set_cc_for_build + SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in @@ -400,25 +425,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} + echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not @@ -429,44 +454,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} + echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} + echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} + echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} + echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} + echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} + echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} + echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} + echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -475,23 +500,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} + echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax @@ -517,17 +542,17 @@ EOF AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) @@ -544,7 +569,7 @@ EOF echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id @@ -553,17 +578,17 @@ EOF echo i386-ibm-aix exit ;; ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then + if test -x /usr/bin/oslevel ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include main() @@ -574,7 +599,7 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else @@ -588,27 +613,27 @@ EOF exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/lslpp ] ; then + if test -x /usr/bin/lslpp ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -623,28 +648,28 @@ EOF echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then + if test -x /usr/bin/getconf; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + case "$sc_cpu_version" in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + case "$sc_kernel_bits" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if test "$HP_ARCH" = ""; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include @@ -677,13 +702,13 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if test "$HP_ARCH" = hppa2.0w then - eval $set_cc_for_build + set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -694,23 +719,23 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include int main () @@ -735,11 +760,11 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) @@ -748,17 +773,17 @@ EOF *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + if test -x /usr/sbin/sysversion ; then + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) @@ -783,130 +808,123 @@ EOF echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} + echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" + exit ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi + else + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf + fi exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case "$UNAME_PROCESSOR" in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; esac + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin + echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 + echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 + echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 + echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case "$UNAME_MACHINE" in x86) - echo i586-pc-interix${UNAME_RELEASE} + echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} + echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} + echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin + echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin + echo x86_64-pc-cygwin exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix + *:Minix:*:*) + echo "$UNAME_MACHINE"-unknown-minix exit ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; @@ -916,132 +934,179 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) - eval $set_cc_for_build + set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; e2k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + k1om:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; + mips64el:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} + echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} + echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} + echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} + echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} + echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} + echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} + echo powerpcle-unknown-linux-"$LIBC" + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + set_cc_for_build + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_X32 >/dev/null + then + LIBCABI="$LIBC"x32 + fi + fi + echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI" exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1055,34 +1120,34 @@ EOF # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx + echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable + echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} + echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp + echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) @@ -1092,12 +1157,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1107,9 +1172,9 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) @@ -1129,9 +1194,9 @@ EOF exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) @@ -1151,9 +1216,9 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; @@ -1162,28 +1227,28 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} + echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} + echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} + echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} + echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} + echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 @@ -1194,7 +1259,7 @@ EOF *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi @@ -1214,23 +1279,23 @@ EOF exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos + echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} + echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + if test -d /usr/nec; then + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. @@ -1249,77 +1314,97 @@ EOF echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} + echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} + echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} + echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} + echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} + echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} + echo sx8r-nec-superux"$UNAME_RELEASE" + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} + echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" + exit ;; + arm64:Darwin:*:*) + echo aarch64-apple-darwin"$UNAME_RELEASE" exit ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} + echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1328,18 +1413,19 @@ EOF echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + # shellcheck disable=SC2154 + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 + echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 @@ -1360,14 +1446,14 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in + case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; @@ -1376,34 +1462,194 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos + echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros + echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx + echo "$UNAME_MACHINE"-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs exit ;; + *:Unleashed:*:*) + echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" + exit ;; +esac + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" < +#include +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) || defined(SIGLOST) +#include +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 <&2 < in order to provide the needed -information to handle your system. +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp @@ -1422,16 +1668,17 @@ hostinfo = `(hostinfo) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF +fi exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/depend/zcash/depends/config.site.in b/depend/zcash/depends/config.site.in index dbcb7a6e4..2947db997 100644 --- a/depend/zcash/depends/config.site.in +++ b/depend/zcash/depends/config.site.in @@ -32,7 +32,7 @@ export PKG_CONFIG_LIBDIR=$depends_prefix/lib/pkgconfig export PKG_CONFIG_PATH=$depends_prefix/share/pkgconfig CPPFLAGS="-I$depends_prefix/include/ $CPPFLAGS" -LDFLAGS="-L$depends_prefix/lib $LDFLAGS" +LDFLAGS="-L$depends_prefix/lib $LDFLAGS -static-libstdc++ -lc++abi" CC="@CC@" CXX="@CXX@" diff --git a/depend/zcash/depends/config.sub b/depend/zcash/depends/config.sub index 8f1229c6f..780c2bbaa 100755 --- a/depend/zcash/depends/config.sub +++ b/depend/zcash/depends/config.sub @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2020 Free Software Foundation, Inc. -timestamp='2015-03-08' +timestamp='2020-09-08' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ timestamp='2015-03-08' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -33,7 +33,7 @@ timestamp='2015-03-08' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -53,12 +53,11 @@ timestamp='2015-03-08' me=`echo "$0" | sed -e 's,.*/,,'` usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -68,7 +67,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -90,12 +89,12 @@ while test $# -gt 0 ; do - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -111,1231 +110,1167 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +# shellcheck disable=SC2162 +IFS="-" read field1 field2 field3 field4 <&2 + exit 1 ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + *-*-*-*) + basic_machine=$field1-$field2 + basic_os=$field3-$field4 ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$field1 + basic_os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + basic_os=linux-android + ;; + *) + basic_machine=$field1-$field2 + basic_os=$field3 + ;; + esac ;; - -psos*) - os=-psos + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + basic_os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + basic_os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + basic_os= + ;; + *) + basic_machine=$field1 + basic_os=$field2 + ;; + esac + ;; + esac ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + basic_os=bsd + ;; + a29khif) + basic_machine=a29k-amd + basic_os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + basic_os=scout + ;; + alliant) + basic_machine=fx80-alliant + basic_os= + ;; + altos | altos3068) + basic_machine=m68k-altos + basic_os= + ;; + am29k) + basic_machine=a29k-none + basic_os=bsd + ;; + amdahl) + basic_machine=580-amdahl + basic_os=sysv + ;; + amiga) + basic_machine=m68k-unknown + basic_os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + basic_os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + basic_os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + basic_os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + basic_os=bsd + ;; + aros) + basic_machine=i386-pc + basic_os=aros + ;; + aux) + basic_machine=m68k-apple + basic_os=aux + ;; + balance) + basic_machine=ns32k-sequent + basic_os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + basic_os=linux + ;; + cegcc) + basic_machine=arm-unknown + basic_os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + basic_os=bsd + ;; + convex-c2) + basic_machine=c2-convex + basic_os=bsd + ;; + convex-c32) + basic_machine=c32-convex + basic_os=bsd + ;; + convex-c34) + basic_machine=c34-convex + basic_os=bsd + ;; + convex-c38) + basic_machine=c38-convex + basic_os=bsd + ;; + cray) + basic_machine=j90-cray + basic_os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + basic_os= + ;; + da30) + basic_machine=m68k-da30 + basic_os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + basic_os= + ;; + delta88) + basic_machine=m88k-motorola + basic_os=sysv3 + ;; + dicos) + basic_machine=i686-pc + basic_os=dicos + ;; + djgpp) + basic_machine=i586-pc + basic_os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + basic_os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + basic_os=ose + ;; + gmicro) + basic_machine=tron-gmicro + basic_os=sysv + ;; + go32) + basic_machine=i386-pc + basic_os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + basic_os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + basic_os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + basic_os=hms + ;; + harris) + basic_machine=m88k-harris + basic_os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + basic_os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + basic_os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + basic_os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + basic_os=proelf + ;; + i386mach) + basic_machine=i386-mach + basic_os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + basic_os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + basic_os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + basic_os=sysv + ;; + merlin) + basic_machine=ns32k-utek + basic_os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + basic_os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + basic_os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + basic_os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + basic_os=coff + ;; + morphos) + basic_machine=powerpc-unknown + basic_os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + basic_os=moxiebox + ;; + msdos) + basic_machine=i386-pc + basic_os=msdos + ;; + msys) + basic_machine=i686-pc + basic_os=msys + ;; + mvs) + basic_machine=i370-ibm + basic_os=mvs + ;; + nacl) + basic_machine=le32-unknown + basic_os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + basic_os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + basic_os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + basic_os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + basic_os=newsos + ;; + news1000) + basic_machine=m68030-sony + basic_os=newsos + ;; + necv70) + basic_machine=v70-nec + basic_os=sysv + ;; + nh3000) + basic_machine=m68k-harris + basic_os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + basic_os=cxux + ;; + nindy960) + basic_machine=i960-intel + basic_os=nindy + ;; + mon960) + basic_machine=i960-intel + basic_os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + basic_os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + basic_os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + basic_os=ose + ;; + os68k) + basic_machine=m68k-none + basic_os=os68k + ;; + paragon) + basic_machine=i860-intel + basic_os=osf + ;; + parisc) + basic_machine=hppa-unknown + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp + ;; + pw32) + basic_machine=i586-unknown + basic_os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + basic_os=rdos + ;; + rdos32) + basic_machine=i386-pc + basic_os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + basic_os=coff + ;; + sa29200) + basic_machine=a29k-amd + basic_os=udi + ;; + sei) + basic_machine=mips-sei + basic_os=seiux + ;; + sequent) + basic_machine=i386-sequent + basic_os= + ;; + sps7) + basic_machine=m68k-bull + basic_os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + basic_os= + ;; + stratus) + basic_machine=i860-stratus + basic_os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + basic_os= + ;; + sun2os3) + basic_machine=m68000-sun + basic_os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + basic_os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + basic_os= + ;; + sun3os3) + basic_machine=m68k-sun + basic_os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + basic_os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + basic_os= + ;; + sun4os3) + basic_machine=sparc-sun + basic_os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + basic_os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + basic_os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + basic_os= + ;; + sv1) + basic_machine=sv1-cray + basic_os=unicos + ;; + symmetry) + basic_machine=i386-sequent + basic_os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + basic_os=unicos + ;; + t90) + basic_machine=t90-cray + basic_os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + basic_os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + basic_os=tpf + ;; + udi29k) + basic_machine=a29k-amd + basic_os=udi + ;; + ultra3) + basic_machine=a29k-nyu + basic_os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + basic_os=none + ;; + vaxv) + basic_machine=vax-dec + basic_os=sysv + ;; + vms) + basic_machine=vax-dec + basic_os=vms + ;; + vsta) + basic_machine=i386-pc + basic_os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + basic_os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + basic_os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + basic_os=vxworks + ;; + xbox) + basic_machine=i686-pc + basic_os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + basic_os=unicos + ;; + *) + basic_machine=$1 + basic_os= + ;; + esac ;; esac -# Decode aliases for certain CPU-COMPANY combinations. +# Decode 1-component or ad-hoc basic machines case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + op50n) + cpu=hppa1.1 + vendor=oki ;; - ms1) - basic_machine=mt-unknown + op60c) + cpu=hppa1.1 + vendor=oki ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown + ibm*) + cpu=i370 + vendor=ibm ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none + orion105) + cpu=clipper + vendor=highlevel ;; - xscaleeb) - basic_machine=armeb-unknown + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple ;; - - xscaleel) - basic_machine=armel-unknown + pmac | pmac-mpw) + cpu=powerpc + vendor=apple ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att + cpu=m68000 + vendor=att ;; 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=we32k + vendor=att ;; bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec + cpu=powerpc + vendor=ibm + basic_os=cnk ;; decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 + cpu=pdp10 + vendor=dec + basic_os=tops10 ;; decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 + cpu=pdp10 + vendor=dec + basic_os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 + cpu=m68k + vendor=motorola ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd + dpx2*) + cpu=m68k + vendor=bull + basic_os=sysv3 ;; encore | umax | mmax) - basic_machine=ns32k-encore + cpu=ns32k + vendor=encore ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose + elxsi) + cpu=elxsi + vendor=elxsi + basic_os=${basic_os:-bsd} ;; fx2800) - basic_machine=i860-alliant + cpu=i860 + vendor=alliant ;; genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 + cpu=ns32k + vendor=ns ;; h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp + cpu=m68000 + vendor=hp ;; hp9k3[2-9][0-9]) - basic_machine=m68k-hp + cpu=m68k + vendor=hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm + cpu=hppa1.0 + vendor=hp ;; i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=solaris2 ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta + j90 | j90-cray) + cpu=j90 + vendor=cray + basic_os=${basic_os:-unicos} ;; iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) + cpu=mips + vendor=sgi + case $basic_os in + irix*) ;; *) - os=-irix4 + basic_os=irix4 ;; esac ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; miniframe) - basic_machine=m68000-convergent + cpu=m68000 + vendor=convergent ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + basic_os=mint ;; news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) + cpu=mips + vendor=sony + basic_os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $basic_os in + openstep*) + ;; + nextstep*) ;; - -ns2*) - os=-nextstep2 + ns2*) + basic_os=nextstep2 ;; *) - os=-nextstep3 + basic_os=nextstep3 ;; esac ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem + cpu=np1 + vendor=gould ;; op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k + cpu=hppa1.1 + vendor=oki + basic_os=proelf ;; pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; pbd) - basic_machine=sparc-tti + cpu=sparc + vendor=tti ;; pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + cpu=m68k + vendor=tti ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + pc532) + cpu=ns32k + vendor=pc532 ;; pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown + cpu=pn + vendor=gould ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + power) + cpu=power + vendor=ibm ;; ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff + cpu=i386 + vendor=ibm ;; rm[46]00) - basic_machine=mips-siemens + cpu=mips + vendor=siemens ;; rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm + cpu=romp + vendor=ibm ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown + sde) + cpu=mipsisa32 + vendor=sde + basic_os=${basic_os:-elf} ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown + simso-wrs) + cpu=sparclite + vendor=wrs + basic_os=vxworks ;; - sde) - basic_machine=mipsisa32-sde - os=-elf + tower | tower-32) + cpu=m68k + vendor=ncr ;; - sei) - basic_machine=mips-sei - os=-seiux + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu ;; - sequent) - basic_machine=i386-sequent + w65) + cpu=w65 + vendor=wdc ;; - sh) - basic_machine=sh-hitachi - os=-hms + w89k-*) + cpu=hppa1.1 + vendor=winbond + basic_os=proelf ;; - sh5el) - basic_machine=sh5le-unknown + none) + cpu=none + vendor=none ;; - sh64) - basic_machine=sh64-unknown + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 + + *-*) + # shellcheck disable=SC2162 + IFS="-" read cpu vendor <&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bpf | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ + | m88110 | m88k | maxq | mb | mcore | mep | metag \ + | microblaze | microblazeel \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64eb | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv64 \ + | rl78 | romp | rs6000 | rx \ + | s390 | s390x \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 \ + | wasm32 | wasm64 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1343,200 +1278,209 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if test x$basic_os != x then + +# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just +# set os. +case $basic_os in + gnu/linux*) + kernel=linux + os=`echo $basic_os | sed -e 's|gnu/linux|gnu|'` + ;; + nto-qnx*) + kernel=nto + os=`echo $basic_os | sed -e 's|nto-qnx|qnx|'` + ;; + *-*) + # shellcheck disable=SC2162 + IFS="-" read kernel os <&2 - exit 1 + # No normalization, but not necessarily accepted, that comes below. ;; esac + else # Here we handle the default operating systems that come with various machines. @@ -1549,261 +1493,352 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +kernel= +case $cpu-$vendor in score-*) - os=-elf + os=elf ;; spu-*) - os=-elf + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + kernel=linux + os=gnu ;; arm*-semi) - os=-aout + os=aout ;; c4x-* | tic4x-*) - os=-coff + os=coff ;; c8051-*) - os=-elf + os=elf + ;; + clipper-intergraph) + os=clix ;; hexagon-*) - os=-elf + os=elf ;; tic54x-*) - os=-coff + os=coff ;; tic55x-*) - os=-coff + os=coff ;; tic6x-*) - os=-coff + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; mep-*) - os=-elf + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 ;; - *-be) - os=-beos + pru-*) + os=elf ;; - *-haiku) - os=-haiku + *-be) + os=beos ;; *-ibm) - os=-aix + os=aix ;; *-knuth) - os=-mmixware + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna + os=luna ;; - *-next ) - os=-nextstep + *-next) + os=nextstep ;; *-sequent) - os=-ptx + os=ptx ;; *-crds) - os=-unos + os=unos ;; *-ns) - os=-genix + os=genix ;; i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 + os=mvs ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint + ;; + *-wrs) + os=vxworks ;; *) - os=-none + os=none ;; esac + fi +# Now, validate our (potentially fixed-up) OS. +case $os in + # Sometimes we do "kernel-abi", so those need to count as OSes. + musl* | newlib* | uclibc*) + ;; + # Likewise for "kernel-libc" + eabi | eabihf | gnueabi | gnueabihf) + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ + | hiux* | abug | nacl* | netware* | windows* \ + | os9* | macos* | osx* | ios* \ + | mpw* | magic* | mmixware* | mon960* | lnews* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | mirbsd* | netbsd* | dicos* | openedition* | ose* \ + | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | mint* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + none) + ;; + *) + echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os in + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* ) + ;; + -dietlibc* | -newlib* | -musl* | -uclibc* ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + kfreebsd*-gnu* | kopensolaris*-gnu*) + ;; + nto-qnx*) + ;; + *-eabi* | *-gnueabi*) + ;; + -*) + # Blank kernel with real OS is always fine. + ;; + *-*) + echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + exit 1 + ;; +esac + # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) +case $vendor in + unknown) + case $cpu-$os in + *-riscix*) vendor=acorn ;; - -sunos*) + *-sunos*) vendor=sun ;; - -cnk*|-aix*) + *-cnk* | *-aix*) vendor=ibm ;; - -beos*) + *-beos*) vendor=be ;; - -hpux*) + *-hpux*) vendor=hp ;; - -mpeix*) + *-mpeix*) vendor=hp ;; - -hiux*) + *-hiux*) vendor=hitachi ;; - -unos*) + *-unos*) vendor=crds ;; - -dgux*) + *-dgux*) vendor=dg ;; - -luna*) + *-luna*) vendor=omron ;; - -genix*) + *-genix*) vendor=ns ;; - -mvs* | -opened*) + *-clix*) + vendor=intergraph + ;; + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) vendor=ibm ;; - -os400*) + s390-* | s390x-*) vendor=ibm ;; - -ptx*) + *-ptx*) vendor=sequent ;; - -tpf*) + *-tpf*) vendor=ibm ;; - -vxsim* | -vxworks* | -windiss*) + *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; - -aux*) + *-aux*) vendor=apple ;; - -hms*) + *-hms*) vendor=hitachi ;; - -mpw* | -macos*) + *-mpw* | *-macos*) vendor=apple ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; - -vos*) + *-vos*) vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/depend/zcash/depends/funcs.mk b/depend/zcash/depends/funcs.mk index 35ca5abcf..0649fae1c 100644 --- a/depend/zcash/depends/funcs.mk +++ b/depend/zcash/depends/funcs.mk @@ -19,32 +19,19 @@ define int_get_all_dependencies $(sort $(foreach dep,$(2),$(2) $(call int_get_all_dependencies,$(1),$($(dep)_dependencies)))) endef +define download_and_check_file +($(build_DOWNLOAD) "$(1)/$(2).temp" $(3) && echo "$(4) $(1)/$(2).temp" > $(1)/.$(2).hash && $(build_SHA256SUM) -c $(1)/.$(2).hash) +endef + define fetch_file (test -f $$($(1)_source_dir)/$(4) || \ ( mkdir -p $$($(1)_download_dir) && echo Fetching $(1)... && \ - ( $(build_DOWNLOAD) "$$($(1)_download_dir)/$(4).temp" "$(PRIORITY_DOWNLOAD_PATH)/$(4)" || \ - $(build_DOWNLOAD) "$$($(1)_download_dir)/$(4).temp" "$(2)/$(3)" ) && \ - echo "$(5) $$($(1)_download_dir)/$(4).temp" > $$($(1)_download_dir)/.$(4).hash && \ - $(build_SHA256SUM) -c $$($(1)_download_dir)/.$(4).hash && \ + ( $(call download_and_check_file,$$($(1)_download_dir),$(4),"$(2)/$(3)",$(5)) || \ + $(call download_and_check_file,$$($(1)_download_dir),$(4),"$(FALLBACK_DOWNLOAD_PATH)/$(4)",$(5)) ) && \ mv $$($(1)_download_dir)/$(4).temp $$($(1)_source_dir)/$(4) && \ rm -rf $$($(1)_download_dir) )) endef -define generate_crate_checksum -$(BASEDIR)/cargo-checksum.sh "$($(1)_file_name)" "$(build_SHA256SUM)" "\"$($(1)_sha256_hash)\"" -endef - -define generate_unpackaged_crate_checksum -$(BASEDIR)/cargo-checksum.sh "$($(1)_file_name)" "$(build_SHA256SUM)" "null" -endef - -define vendor_crate_source -mkdir -p $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY) && \ -cp -r $($(1)_extract_dir) $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY)/$($(1)_crate_versioned_name) && \ -cd $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY)/$($(1)_crate_versioned_name) && \ -rm -r `basename $($(1)_patch_dir)` .stamp_* .$($(1)_file_name).hash -endef - define int_get_build_recipe_hash $(eval $(1)_all_file_checksums:=$(shell $(build_SHA256SUM) $(meta_depends) packages/$(1).mk $(addprefix $(PATCHES_PATH)/$(1)/,$($(1)_patches)) | cut -d" " -f1)) $(eval $(1)_recipe_hash:=$(shell echo -n "$($(1)_all_file_checksums)" | $(build_SHA256SUM) | cut -d" " -f1)) @@ -52,19 +39,19 @@ endef define int_get_build_id $(eval $(1)_dependencies += $($(1)_$(host_arch)_$(host_os)_dependencies) $($(1)_$(host_os)_dependencies)) -$(eval $(1)_all_dependencies:=$(call int_get_all_dependencies,$(1),$($($(1)_type)_native_toolchain) $($(1)_dependencies))) +$(eval $(1)_all_dependencies:=$(call int_get_all_dependencies,$(1),$($($(1)_type)_native_toolchain) $($($(1)_type)_native_binutils) $($(1)_dependencies))) $(foreach dep,$($(1)_all_dependencies),$(eval $(1)_build_id_deps+=$(dep)-$($(dep)_version)-$($(dep)_recipe_hash))) $(eval $(1)_build_id_long:=$(1)-$($(1)_version)-$($(1)_recipe_hash)-$(release_type) $($(1)_build_id_deps)) $(eval $(1)_build_id:=$(shell echo -n "$($(1)_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))) final_build_id_long+=$($(package)_build_id_long) #override platform specific files and hashes -$(eval $(1)_file_name=$(if $($(1)_exact_file_name),$($(1)_exact_file_name),$(if $($(1)_file_name_$(host_os)),$($(1)_file_name_$(host_os)),$($(1)_file_name)))) -$(eval $(1)_sha256_hash=$(if $($(1)_exact_sha256_hash),$($(1)_exact_sha256_hash),$(if $($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash)))) +$(eval $(1)_file_name=$(if $($(1)_exact_file_name),$($(1)_exact_file_name),$(if $($(1)_file_name_$(host_arch)_$(host_os)),$($(1)_file_name_$(host_arch)_$(host_os)),$(if $($(1)_file_name_$(host_os)),$($(1)_file_name_$(host_os)),$($(1)_file_name))))) +$(eval $(1)_sha256_hash=$(if $($(1)_exact_sha256_hash),$($(1)_exact_sha256_hash),$(if $($(1)_sha256_hash_$(host_arch)_$(host_os)),$($(1)_sha256_hash_$(host_arch)_$(host_os)),$(if $($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash))))) +$(eval $(1)_download_file=$(if $($(1)_exact_download_file),$($(1)_exact_download_file),$(if $($(1)_download_file_$(host_arch)_$(host_os)),$($(1)_download_file_$(host_arch)_$(host_os)),$(if $($(1)_download_file_$(host_os)),$($(1)_download_file_$(host_os)),$(if $($(1)_download_file),$($(1)_download_file),$($(1)_file_name)))))) #compute package-specific paths $(1)_build_subdir?=. -$(1)_download_file?=$($(1)_file_name) $(1)_source_dir:=$(SOURCES_PATH) $(1)_source:=$$($(1)_source_dir)/$($(1)_file_name) $(1)_staging_dir=$(base_staging_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id) @@ -148,7 +135,7 @@ $(1)_config_env+=PKG_CONFIG_PATH=$($($(1)_type)_prefix)/share/pkgconfig $(1)_config_env+=PATH="$(build_prefix)/bin:$(PATH)" $(1)_build_env+=PATH="$(build_prefix)/bin:$(PATH)" $(1)_stage_env+=PATH="$(build_prefix)/bin:$(PATH)" -$(1)_autoconf=./configure --host=$($($(1)_type)_host) --disable-dependency-tracking --prefix=$($($(1)_type)_prefix) $$($(1)_config_opts) CC="$$($(1)_cc)" CXX="$$($(1)_cxx)" +$(1)_autoconf=./configure --host=$($($(1)_type)_host) --prefix=$($($(1)_type)_prefix) $$($(1)_config_opts) CC="$$($(1)_cc)" CXX="$$($(1)_cxx)" ifneq ($($(1)_nm),) $(1)_autoconf += NM="$$($(1)_nm)" @@ -258,4 +245,4 @@ $(foreach package,$(all_packages),$(eval $(call int_config_attach_build_config,$ $(foreach package,$(all_packages),$(eval $(call int_add_cmds,$(package)))) #special exception: if a toolchain package exists, all non-native packages depend on it -$(foreach package,$(packages),$(eval $($(package)_unpacked): |$($($(host_arch)_$(host_os)_native_toolchain)_cached) )) +$(foreach package,$(packages),$(eval $($(package)_unpacked): |$($($(host_arch)_$(host_os)_native_toolchain)_cached) $($($(host_arch)_$(host_os)_native_binutils)_cached) )) diff --git a/depend/zcash/depends/hosts/darwin.mk b/depend/zcash/depends/hosts/darwin.mk index 939988197..81ff993a4 100644 --- a/depend/zcash/depends/hosts/darwin.mk +++ b/depend/zcash/depends/hosts/darwin.mk @@ -1,9 +1,35 @@ -OSX_MIN_VERSION=10.8 -OSX_SDK_VERSION=10.11 -OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk -LD64_VERSION=253.9 -darwin_CC=clang -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -darwin_CXX=clang++ -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -stdlib=libc++ +OSX_MIN_VERSION=10.12 +OSX_SDK_VERSION=10.15.1 +XCODE_VERSION=11.3.1 +XCODE_BUILD_ID=11C505 +LD64_VERSION=530 + +OSX_SDK=$(SDK_PATH)/Xcode-$(XCODE_VERSION)-$(XCODE_BUILD_ID)-extracted-SDK-with-libcxx-headers + +# Flag explanations: +# +# -mlinker-version +# +# Ensures that modern linker features are enabled. See here for more +# details: https://github.com/bitcoin/bitcoin/pull/19407. +# +# -B$(build_prefix)/bin +# +# Explicitly point to our binaries (e.g. cctools) so that they are +# ensured to be found and preferred over other possibilities. +# +# -nostdinc++ -isystem $(OSX_SDK)/usr/include/c++/v1 +# +# Forces clang to use the libc++ headers from our SDK and completely +# forget about the libc++ headers from the standard directories +# +# TODO: Once we start requiring a clang version that has the +# -stdlib++-isystem flag first introduced here: +# https://reviews.llvm.org/D64089, we should use that instead. Read the +# differential summary there for more details. +# +darwin_CC=clang -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -B$(build_prefix)/bin +darwin_CXX=clang++ -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -stdlib=libc++ -mlinker-version=$(LD64_VERSION) -B$(build_prefix)/bin -nostdinc++ -isystem $(OSX_SDK)/usr/include/c++/v1 darwin_CFLAGS=-pipe darwin_CXXFLAGS=$(darwin_CFLAGS) @@ -14,4 +40,5 @@ darwin_release_CXXFLAGS=$(darwin_release_CFLAGS) darwin_debug_CFLAGS=-O1 darwin_debug_CXXFLAGS=$(darwin_debug_CFLAGS) +darwin_native_binutils=native_cctools darwin_native_toolchain=native_cctools diff --git a/depend/zcash/depends/hosts/default.mk b/depend/zcash/depends/hosts/default.mk index 6f60d6b3f..a6f0f3a56 100644 --- a/depend/zcash/depends/hosts/default.mk +++ b/depend/zcash/depends/hosts/default.mk @@ -1,12 +1,22 @@ -default_host_CC = $(host_toolchain)gcc -default_host_CXX = $(host_toolchain)g++ -default_host_AR = $(host_toolchain)ar -default_host_RANLIB = $(host_toolchain)ranlib -default_host_STRIP = $(host_toolchain)strip +# Flag explanations: +# +# -B$(build_prefix)/bin +# +# Explicitly point to our binaries (e.g. cctools) so that they are +# ensured to be found and preferred over other possibilities. +# +default_host_CC = clang -target $(host) -B$(build_prefix)/bin +default_host_CXX = clang++ -target $(host) -B$(build_prefix)/bin -stdlib=libc++ +default_host_AR = llvm-ar +default_host_RANLIB = llvm-ranlib +default_host_STRIP = llvm-strip default_host_LIBTOOL = $(host_toolchain)libtool default_host_INSTALL_NAME_TOOL = $(host_toolchain)install_name_tool default_host_OTOOL = $(host_toolchain)otool -default_host_NM = $(host_toolchain)nm +default_host_NM = llvm-nm + +$(host_os)_native_binutils?=native_clang +$(host_os)_native_toolchain?=native_clang define add_host_tool_func $(host_os)_$1?=$$(default_host_$1) diff --git a/depend/zcash/depends/hosts/freebsd.mk b/depend/zcash/depends/hosts/freebsd.mk index 07436aef8..9eddcc6e1 100644 --- a/depend/zcash/depends/hosts/freebsd.mk +++ b/depend/zcash/depends/hosts/freebsd.mk @@ -9,23 +9,12 @@ freebsd_debug_CXXFLAGS=$(freebsd_debug_CFLAGS) freebsd_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -ifeq (86,$(findstring 86,$(build_arch))) -i686_freebsd_CC=gcc -m32 -i686_freebsd_CXX=g++ -m32 -i686_freebsd_AR=ar -i686_freebsd_RANLIB=ranlib -i686_freebsd_NM=nm -i686_freebsd_STRIP=strip +# Changes below have not been tested. If you try to build on FreeBSD, +# please let us know how it goes. + +freebsd_LDFLAGS?=-fuse-ld=lld -x86_64_freebsd_CC=gcc -m64 -x86_64_freebsd_CXX=g++ -m64 -x86_64_freebsd_AR=ar -x86_64_freebsd_RANLIB=ranlib -x86_64_freebsd_NM=nm -x86_64_freebsd_STRIP=strip -else i686_freebsd_CC=$(default_host_CC) -m32 i686_freebsd_CXX=$(default_host_CXX) -m32 x86_64_freebsd_CC=$(default_host_CC) -m64 x86_64_freebsd_CXX=$(default_host_CXX) -m64 -endif diff --git a/depend/zcash/depends/hosts/linux.mk b/depend/zcash/depends/hosts/linux.mk index 31748d662..fb2db9b76 100644 --- a/depend/zcash/depends/hosts/linux.mk +++ b/depend/zcash/depends/hosts/linux.mk @@ -9,23 +9,17 @@ linux_debug_CXXFLAGS=$(linux_debug_CFLAGS) linux_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -ifeq (86,$(findstring 86,$(build_arch))) -i686_linux_CC=gcc -m32 -i686_linux_CXX=g++ -m32 -i686_linux_AR=ar -i686_linux_RANLIB=ranlib -i686_linux_NM=nm -i686_linux_STRIP=strip +linux_LDFLAGS?=-fuse-ld=lld -x86_64_linux_CC=gcc -m64 -x86_64_linux_CXX=g++ -m64 -x86_64_linux_AR=ar -x86_64_linux_RANLIB=ranlib -x86_64_linux_NM=nm -x86_64_linux_STRIP=strip -else i686_linux_CC=$(default_host_CC) -m32 i686_linux_CXX=$(default_host_CXX) -m32 x86_64_linux_CC=$(default_host_CC) -m64 x86_64_linux_CXX=$(default_host_CXX) -m64 + +# Clang doesn't appear to find these multilib paths by default, +# so help it out if we are cross-compiling. +ifneq ($(canonical_host),$(build)) + # CFLAGS is copied to CXXFLAGS after it is fully-evaluated. + linux_CFLAGS += -idirafter /usr/$(host)/include + linux_LDFLAGS += -L/usr/$(host)/lib endif diff --git a/depend/zcash/depends/hosts/mingw32.mk b/depend/zcash/depends/hosts/mingw32.mk index 2248973a1..ed1910e66 100644 --- a/depend/zcash/depends/hosts/mingw32.mk +++ b/depend/zcash/depends/hosts/mingw32.mk @@ -1,5 +1,7 @@ mingw32_CFLAGS=-pipe -mingw32_CXXFLAGS=$(mingw32_CFLAGS) +mingw32_CXXFLAGS=$(mingw32_CFLAGS) -isystem $(host_prefix)/include/c++/v1 + +mingw32_LDFLAGS?=-fuse-ld=lld mingw32_release_CFLAGS=-O1 mingw32_release_CXXFLAGS=$(mingw32_release_CFLAGS) diff --git a/depend/zcash/depends/packages.md b/depend/zcash/depends/packages.md index 7d2bd4670..14bb8f3d9 100644 --- a/depend/zcash/depends/packages.md +++ b/depend/zcash/depends/packages.md @@ -5,6 +5,9 @@ The package "mylib" will be used here as an example General tips: - mylib_foo is written as $(package)_foo in order to make recipes more similar. +- Secondary dependency packages relative to the Zcash binaries/libraries (i.e. + those not in `ALLOWED_LIBRARIES` in `contrib/devtools/symbol-check.py`) should + be built statically. See [below](#secondary-dependencies) for more details. ## Identifiers Each package is required to define at least these variables: @@ -146,3 +149,38 @@ $($(package)_config_opts) will be appended. Most autotools projects can be properly staged using: $(MAKE) DESTDIR=$($(package)_staging_dir) install + +## Build outputs: + +In general, the output of a depends package should not contain any libtool +archives. Instead, the package should output `.pc` (`pkg-config`) files where +possible. + +From the [Gentoo Wiki entry](https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Handling_Libtool_Archives): + +> Libtool pulls in all direct and indirect dependencies into the .la files it +> creates. This leads to massive overlinking, which is toxic to the Gentoo +> ecosystem, as it leads to a massive number of unnecessary rebuilds. + +## Secondary dependencies: + +Secondary dependency packages relative to the Zcash binaries/libraries (i.e. +those not in `ALLOWED_LIBRARIES` in `contrib/devtools/symbol-check.py`) +should be built statically. The arguments for statically linking secondary +dependencies are similar to those for primary dependencies: it is preferable +for promptness of security updates; consensus compatibility; ease of +debugging and reproduction of user issues; avoiding unintended breakage +due to incompatible changes; and portability across OS distributions. It also +improves general build reliability as illustrated by the following example: + +When linking an executable against a shared library `libprimary` that has its +own shared dependency `libsecondary`, we may need to specify the path to +`libsecondary` on the link command using the `-rpath/-rpath-link` options, it is +not sufficient to just say `libprimary`. + +For us, it's much easier to just link a static `libsecondary` into a shared +`libprimary`. Especially because in our case, we are linking against a dummy +`libprimary` anyway that we'll throw away. We don't care if the end-user has a +static or dynamic `libseconday`, that's not our concern. With a static +`libseconday`, when we need to link `libprimary` into our executable, there's no +dependency chain to worry about as `libprimary` has all the symbols. diff --git a/depend/zcash/depends/packages/bdb.mk b/depend/zcash/depends/packages/bdb.mk index fae0783cf..5a5950059 100644 --- a/depend/zcash/depends/packages/bdb.mk +++ b/depend/zcash/depends/packages/bdb.mk @@ -4,9 +4,14 @@ $(package)_download_path=https://download.oracle.com/berkeley-db $(package)_file_name=db-$($(package)_version).tar.gz $(package)_sha256_hash=47612c8991aa9ac2f6be721267c8d3cdccf5ac83105df8e50809daea24e95dc7 $(package)_build_subdir=build_unix +$(package)_patches=winioctl-and-atomic_init_db.patch + +ifneq ($(host_os),darwin) +$(package)_dependencies=libcxx +endif define $(package)_set_vars -$(package)_config_opts=--disable-shared --enable-cxx --disable-replication +$(package)_config_opts=--disable-shared --enable-cxx --disable-replication --enable-option-checking $(package)_config_opts_mingw32=--enable-mingw $(package)_config_opts_linux=--with-pic $(package)_config_opts_freebsd=--with-pic @@ -14,13 +19,12 @@ ifneq ($(build_os),darwin) $(package)_config_opts_darwin=--disable-atomicsupport endif $(package)_config_opts_aarch64=--disable-atomicsupport -$(package)_cxxflags=-std=c++17 +$(package)_cxxflags+=-std=c++17 +$(package)_ldflags+=-static-libstdc++ -lc++abi endef define $(package)_preprocess_cmds - sed -i.old 's/WinIoCtl.h/winioctl.h/g' src/dbinc/win_db.h && \ - sed -i.old 's/__atomic_compare_exchange\\(/__atomic_compare_exchange_db(/' src/dbinc/atomic.h && \ - sed -i.old 's/atomic_init/atomic_init_db/' src/dbinc/atomic.h src/mp/mp_region.c src/mp/mp_mvcc.c src/mp/mp_fget.c src/mutex/mut_method.c src/mutex/mut_tas.c + patch -p1 <$($(package)_patch_dir)/winioctl-and-atomic_init_db.patch endef define $(package)_config_cmds @@ -32,5 +36,11 @@ define $(package)_build_cmds endef define $(package)_stage_cmds - $(MAKE) DESTDIR=$($(package)_staging_dir) install_lib install_include + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + cd $(BASEDIR)/../zcutil && \ + mkdir -p bin && \ + mv -f $($(package)_staging_dir)$(host_prefix)/bin/db_* bin endef diff --git a/depend/zcash/depends/packages/boost.mk b/depend/zcash/depends/packages/boost.mk index 914cb4b02..c99846d0c 100644 --- a/depend/zcash/depends/packages/boost.mk +++ b/depend/zcash/depends/packages/boost.mk @@ -1,9 +1,13 @@ package=boost -$(package)_version=1_70_0 -$(package)_download_path=https://dl.bintray.com/boostorg/release/1.70.0/source +$(package)_version=1_74_0 +$(package)_download_path=https://dl.bintray.com/boostorg/release/1.74.0/source $(package)_file_name=$(package)_$($(package)_version).tar.bz2 -$(package)_sha256_hash=430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778 -$(package)_patches=darwin.diff +$(package)_sha256_hash=83bfc1507731a0906e387fc28b7ef5417d591429e51e788417fe9ff025e116b1 +$(package)_patches=iostreams-106.patch signals2-noise.patch + +ifneq ($(host_os),darwin) +$(package)_dependencies=libcxx +endif define $(package)_set_vars $(package)_config_opts_release=variant=release @@ -16,18 +20,20 @@ $(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win3 $(package)_config_opts_x86_64_mingw32=address-model=64 $(package)_config_opts_i686_mingw32=address-model=32 $(package)_config_opts_i686_linux=address-model=32 architecture=x86 -$(package)_toolset_$(host_os)=gcc +$(package)_toolset_$(host_os)=clang $(package)_archiver_$(host_os)=$($(package)_ar) $(package)_toolset_darwin=darwin $(package)_archiver_darwin=$($(package)_libtool) $(package)_config_libraries=chrono,filesystem,program_options,system,thread,test -$(package)_cxxflags=-std=c++17 -fvisibility=hidden +$(package)_cxxflags+=-std=c++17 -fvisibility=hidden $(package)_cxxflags_linux=-fPIC $(package)_cxxflags_freebsd=-fPIC +$(package)_ldflags+=-static-libstdc++ -lc++abi endef define $(package)_preprocess_cmds - patch -p1 < $($(package)_patch_dir)/darwin.diff + patch -p2 < $($(package)_patch_dir)/iostreams-106.patch && \ + patch -p2 < $($(package)_patch_dir)/signals2-noise.patch endef define $(package)_config_cmds @@ -42,3 +48,12 @@ endef define $(package)_stage_cmds ./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install endef + +# Boost uses the MSVC convention of libboost_foo.lib as the naming pattern when +# compiling for Windows, even though we use MinGW which follows the libfoo.a +# convention. This causes issues with lld, so we rename all .lib files to .a. +ifeq ($(host_os),mingw32) +define $(package)_postprocess_cmds + for f in lib/*.lib; do mv -- "$$$$f" "$$$${f%.lib}.a"; done +endef +endif diff --git a/depend/zcash/depends/packages/crate_aes.mk b/depend/zcash/depends/packages/crate_aes.mk deleted file mode 100644 index 0e2a29392..000000000 --- a/depend/zcash/depends/packages/crate_aes.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_aes -$(package)_crate_name=aes -$(package)_version=0.3.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_aes_soft.mk b/depend/zcash/depends/packages/crate_aes_soft.mk deleted file mode 100644 index 5dcd153ee..000000000 --- a/depend/zcash/depends/packages/crate_aes_soft.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_aes_soft -$(package)_crate_name=aes-soft -$(package)_version=0.3.3 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_aesni.mk b/depend/zcash/depends/packages/crate_aesni.mk deleted file mode 100644 index dfd93bce2..000000000 --- a/depend/zcash/depends/packages/crate_aesni.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_aesni -$(package)_crate_name=aesni -$(package)_version=0.6.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_arrayref.mk b/depend/zcash/depends/packages/crate_arrayref.mk deleted file mode 100644 index 186f5e77b..000000000 --- a/depend/zcash/depends/packages/crate_arrayref.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_arrayref -$(package)_crate_name=arrayref -$(package)_version=0.3.5 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_arrayvec.mk b/depend/zcash/depends/packages/crate_arrayvec.mk deleted file mode 100644 index faa3b4f55..000000000 --- a/depend/zcash/depends/packages/crate_arrayvec.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_arrayvec -$(package)_crate_name=arrayvec -$(package)_version=0.4.11 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_autocfg.mk b/depend/zcash/depends/packages/crate_autocfg.mk deleted file mode 100644 index 1b36846ed..000000000 --- a/depend/zcash/depends/packages/crate_autocfg.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_autocfg -$(package)_crate_name=autocfg -$(package)_version=0.1.6 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_bellman.mk b/depend/zcash/depends/packages/crate_bellman.mk deleted file mode 100644 index 49f63e5b4..000000000 --- a/depend/zcash/depends/packages/crate_bellman.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_bellman -$(package)_crate_name=bellman -$(package)_version=0.6.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=2be536193834affcd8a6d362963e66dec8c6bca4d2009f5bac55ec9002776ff2 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_bigint.mk b/depend/zcash/depends/packages/crate_bigint.mk deleted file mode 100644 index 6dae98362..000000000 --- a/depend/zcash/depends/packages/crate_bigint.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_bigint -$(package)_crate_name=bigint -$(package)_version=4.4.1 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_bit_vec.mk b/depend/zcash/depends/packages/crate_bit_vec.mk deleted file mode 100644 index 40575088e..000000000 --- a/depend/zcash/depends/packages/crate_bit_vec.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_bit_vec -$(package)_crate_name=bit-vec -$(package)_version=0.4.4 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_blake2b_simd.mk b/depend/zcash/depends/packages/crate_blake2b_simd.mk deleted file mode 100644 index c9e3ce0c8..000000000 --- a/depend/zcash/depends/packages/crate_blake2b_simd.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_blake2b_simd -$(package)_crate_name=blake2b_simd -$(package)_version=0.5.8 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=5850aeee1552f495dd0250014cf64b82b7c8879a89d83b33bbdace2cc4f63182 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_blake2s_simd.mk b/depend/zcash/depends/packages/crate_blake2s_simd.mk deleted file mode 100644 index bea01c9b1..000000000 --- a/depend/zcash/depends/packages/crate_blake2s_simd.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_blake2s_simd -$(package)_crate_name=blake2s_simd -$(package)_version=0.5.8 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=979da0ce13c897d6be19e005ea77ac12b0fea0157aeeee7feb8c49f91386f0ea -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_block_buffer.mk b/depend/zcash/depends/packages/crate_block_buffer.mk deleted file mode 100644 index 26d0b5e48..000000000 --- a/depend/zcash/depends/packages/crate_block_buffer.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_block_buffer -$(package)_crate_name=block-buffer -$(package)_version=0.7.3 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_block_cipher_trait.mk b/depend/zcash/depends/packages/crate_block_cipher_trait.mk deleted file mode 100644 index 553bd52a9..000000000 --- a/depend/zcash/depends/packages/crate_block_cipher_trait.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_block_cipher_trait -$(package)_crate_name=block-cipher-trait -$(package)_version=0.6.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_block_padding.mk b/depend/zcash/depends/packages/crate_block_padding.mk deleted file mode 100644 index 310a14cf6..000000000 --- a/depend/zcash/depends/packages/crate_block_padding.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_block_padding -$(package)_crate_name=block-padding -$(package)_version=0.1.4 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_byte_tools.mk b/depend/zcash/depends/packages/crate_byte_tools.mk deleted file mode 100644 index a5dff7279..000000000 --- a/depend/zcash/depends/packages/crate_byte_tools.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_byte_tools -$(package)_crate_name=byte-tools -$(package)_version=0.3.1 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_byteorder.mk b/depend/zcash/depends/packages/crate_byteorder.mk deleted file mode 100644 index cd991687d..000000000 --- a/depend/zcash/depends/packages/crate_byteorder.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_byteorder -$(package)_crate_name=byteorder -$(package)_version=1.3.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_c2_chacha.mk b/depend/zcash/depends/packages/crate_c2_chacha.mk deleted file mode 100644 index fe29c2101..000000000 --- a/depend/zcash/depends/packages/crate_c2_chacha.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_c2_chacha -$(package)_crate_name=c2-chacha -$(package)_version=0.2.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_cfg_if.mk b/depend/zcash/depends/packages/crate_cfg_if.mk deleted file mode 100644 index af67660f9..000000000 --- a/depend/zcash/depends/packages/crate_cfg_if.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_cfg_if -$(package)_crate_name=cfg-if -$(package)_version=0.1.9 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_constant_time_eq.mk b/depend/zcash/depends/packages/crate_constant_time_eq.mk deleted file mode 100644 index 2ed631238..000000000 --- a/depend/zcash/depends/packages/crate_constant_time_eq.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_constant_time_eq -$(package)_crate_name=constant_time_eq -$(package)_version=0.1.4 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_crossbeam.mk b/depend/zcash/depends/packages/crate_crossbeam.mk deleted file mode 100644 index 144f35007..000000000 --- a/depend/zcash/depends/packages/crate_crossbeam.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_crossbeam -$(package)_crate_name=crossbeam -$(package)_version=0.7.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=2d818a4990769aac0c7ff1360e233ef3a41adcb009ebb2036bf6915eb0f6b23c -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_crossbeam_channel.mk b/depend/zcash/depends/packages/crate_crossbeam_channel.mk deleted file mode 100644 index 618268f41..000000000 --- a/depend/zcash/depends/packages/crate_crossbeam_channel.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_crossbeam_channel -$(package)_crate_name=crossbeam-channel -$(package)_version=0.3.9 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_crossbeam_deque.mk b/depend/zcash/depends/packages/crate_crossbeam_deque.mk deleted file mode 100644 index 881a2c75b..000000000 --- a/depend/zcash/depends/packages/crate_crossbeam_deque.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_crossbeam_deque -$(package)_crate_name=crossbeam-deque -$(package)_version=0.7.1 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_crossbeam_epoch.mk b/depend/zcash/depends/packages/crate_crossbeam_epoch.mk deleted file mode 100644 index b68701642..000000000 --- a/depend/zcash/depends/packages/crate_crossbeam_epoch.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_crossbeam_epoch -$(package)_crate_name=crossbeam-epoch -$(package)_version=0.7.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_crossbeam_queue.mk b/depend/zcash/depends/packages/crate_crossbeam_queue.mk deleted file mode 100644 index 70616caf5..000000000 --- a/depend/zcash/depends/packages/crate_crossbeam_queue.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_crossbeam_queue -$(package)_crate_name=crossbeam-queue -$(package)_version=0.1.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_crossbeam_utils.mk b/depend/zcash/depends/packages/crate_crossbeam_utils.mk deleted file mode 100644 index eabfa26c4..000000000 --- a/depend/zcash/depends/packages/crate_crossbeam_utils.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_crossbeam_utils -$(package)_crate_name=crossbeam-utils -$(package)_version=0.6.6 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_crunchy.mk b/depend/zcash/depends/packages/crate_crunchy.mk deleted file mode 100644 index d984ba848..000000000 --- a/depend/zcash/depends/packages/crate_crunchy.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_crunchy -$(package)_crate_name=crunchy -$(package)_version=0.1.6 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_crypto_api.mk b/depend/zcash/depends/packages/crate_crypto_api.mk deleted file mode 100644 index e65f6a659..000000000 --- a/depend/zcash/depends/packages/crate_crypto_api.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_crypto_api -$(package)_crate_name=crypto_api -$(package)_version=0.2.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=2f855e87e75a4799e18b8529178adcde6fd4f97c1449ff4821e747ff728bb102 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_crypto_api_chachapoly.mk b/depend/zcash/depends/packages/crate_crypto_api_chachapoly.mk deleted file mode 100644 index 5ae64dcac..000000000 --- a/depend/zcash/depends/packages/crate_crypto_api_chachapoly.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_crypto_api_chachapoly -$(package)_crate_name=crypto_api_chachapoly -$(package)_version=0.2.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=95b2ad7cab08fd71addba81df5077c49df208effdfb3118a1519f9cdeac5aaf2 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_curve25519_dalek.mk b/depend/zcash/depends/packages/crate_curve25519_dalek.mk deleted file mode 100644 index 23469d0fc..000000000 --- a/depend/zcash/depends/packages/crate_curve25519_dalek.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_curve25519_dalek -$(package)_crate_name=curve25519-dalek -$(package)_version=2.1.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_digest.mk b/depend/zcash/depends/packages/crate_digest.mk deleted file mode 100644 index 63d7c74e1..000000000 --- a/depend/zcash/depends/packages/crate_digest.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_digest -$(package)_crate_name=digest -$(package)_version=0.8.1 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_directories.mk b/depend/zcash/depends/packages/crate_directories.mk deleted file mode 100644 index 7a3a93d53..000000000 --- a/depend/zcash/depends/packages/crate_directories.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_directories -$(package)_crate_name=directories -$(package)_version=1.0.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_ed25519_zebra.mk b/depend/zcash/depends/packages/crate_ed25519_zebra.mk deleted file mode 100644 index 7eada7b4b..000000000 --- a/depend/zcash/depends/packages/crate_ed25519_zebra.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_ed25519_zebra -$(package)_crate_name=ed25519-zebra -$(package)_version=2.0.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=beeba2b02b91dc7cc2d1f42c96b9e82db4cd20ad1c326f1dbf64ac8943c7bf32 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_fake_simd.mk b/depend/zcash/depends/packages/crate_fake_simd.mk deleted file mode 100644 index 44331b71a..000000000 --- a/depend/zcash/depends/packages/crate_fake_simd.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_fake_simd -$(package)_crate_name=fake-simd -$(package)_version=0.1.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_ff.mk b/depend/zcash/depends/packages/crate_ff.mk deleted file mode 100644 index 05372070e..000000000 --- a/depend/zcash/depends/packages/crate_ff.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_ff -$(package)_crate_name=ff -$(package)_version=0.6.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=c4b967a3ee6ae993f0094174257d404a5818f58be79d67a1aea1ec8996d28906 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_ff_derive.mk b/depend/zcash/depends/packages/crate_ff_derive.mk deleted file mode 100644 index 2d3440472..000000000 --- a/depend/zcash/depends/packages/crate_ff_derive.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_ff_derive -$(package)_crate_name=ff_derive -$(package)_version=0.6.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=a3776aaf60a45037a9c3cabdd8542b38693acaa3e241ff957181b72579d29feb -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_fpe.mk b/depend/zcash/depends/packages/crate_fpe.mk deleted file mode 100644 index 12baf031c..000000000 --- a/depend/zcash/depends/packages/crate_fpe.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_fpe -$(package)_crate_name=fpe -$(package)_version=0.2.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=21988a326139165b75e3196bc6962ca638e5fb0c95102fbf152a3743174b01e4 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_futures.mk b/depend/zcash/depends/packages/crate_futures.mk deleted file mode 100644 index fba10a2a4..000000000 --- a/depend/zcash/depends/packages/crate_futures.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_futures -$(package)_crate_name=futures -$(package)_version=0.1.29 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_futures_cpupool.mk b/depend/zcash/depends/packages/crate_futures_cpupool.mk deleted file mode 100644 index 0ff2069ed..000000000 --- a/depend/zcash/depends/packages/crate_futures_cpupool.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_futures_cpupool -$(package)_crate_name=futures-cpupool -$(package)_version=0.1.8 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_generic_array.mk b/depend/zcash/depends/packages/crate_generic_array.mk deleted file mode 100644 index c84854ab8..000000000 --- a/depend/zcash/depends/packages/crate_generic_array.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_generic_array -$(package)_crate_name=generic-array -$(package)_version=0.12.3 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_getrandom.mk b/depend/zcash/depends/packages/crate_getrandom.mk deleted file mode 100644 index 460ab8b15..000000000 --- a/depend/zcash/depends/packages/crate_getrandom.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_getrandom -$(package)_crate_name=getrandom -$(package)_version=0.1.12 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_group.mk b/depend/zcash/depends/packages/crate_group.mk deleted file mode 100644 index 6931c7a51..000000000 --- a/depend/zcash/depends/packages/crate_group.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_group -$(package)_crate_name=group -$(package)_version=0.6.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=f15be54742789e36f03307c8fdf0621201e1345e94f1387282024178b5e9ec8c -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_hex.mk b/depend/zcash/depends/packages/crate_hex.mk deleted file mode 100644 index c24120d05..000000000 --- a/depend/zcash/depends/packages/crate_hex.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_hex -$(package)_crate_name=hex -$(package)_version=0.3.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77 -$(package)_crate_versioned_name="$($(package)_crate_name) 0.3.2" - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_hex2.mk b/depend/zcash/depends/packages/crate_hex2.mk deleted file mode 100644 index c589bc4ec..000000000 --- a/depend/zcash/depends/packages/crate_hex2.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_hex2 -$(package)_crate_name=hex -$(package)_version=0.4.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35 -$(package)_crate_versioned_name="$($(package)_crate_name) 0.4.2" - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_lazy_static.mk b/depend/zcash/depends/packages/crate_lazy_static.mk deleted file mode 100644 index 50f4f6ffc..000000000 --- a/depend/zcash/depends/packages/crate_lazy_static.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_lazy_static -$(package)_crate_name=lazy_static -$(package)_version=1.4.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_libc.mk b/depend/zcash/depends/packages/crate_libc.mk deleted file mode 100644 index a8752b964..000000000 --- a/depend/zcash/depends/packages/crate_libc.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_libc -$(package)_crate_name=libc -$(package)_version=0.2.62 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_log.mk b/depend/zcash/depends/packages/crate_log.mk deleted file mode 100644 index 3bc1ec01a..000000000 --- a/depend/zcash/depends/packages/crate_log.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_log -$(package)_crate_name=log -$(package)_version=0.4.8 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_memoffset.mk b/depend/zcash/depends/packages/crate_memoffset.mk deleted file mode 100644 index c4e9fcd27..000000000 --- a/depend/zcash/depends/packages/crate_memoffset.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_memoffset -$(package)_crate_name=memoffset -$(package)_version=0.5.1 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_nodrop.mk b/depend/zcash/depends/packages/crate_nodrop.mk deleted file mode 100644 index 70d589b5c..000000000 --- a/depend/zcash/depends/packages/crate_nodrop.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_nodrop -$(package)_crate_name=nodrop -$(package)_version=0.1.13 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_num_bigint.mk b/depend/zcash/depends/packages/crate_num_bigint.mk deleted file mode 100644 index 3b97d94f7..000000000 --- a/depend/zcash/depends/packages/crate_num_bigint.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_num_bigint -$(package)_crate_name=num-bigint -$(package)_version=0.2.3 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=f9c3f34cdd24f334cb265d9bf8bfa8a241920d026916785747a92f0e55541a1a -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_num_cpus.mk b/depend/zcash/depends/packages/crate_num_cpus.mk deleted file mode 100644 index 63e07acfa..000000000 --- a/depend/zcash/depends/packages/crate_num_cpus.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_num_cpus -$(package)_crate_name=num_cpus -$(package)_version=1.10.1 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_num_integer.mk b/depend/zcash/depends/packages/crate_num_integer.mk deleted file mode 100644 index 5e9c455a5..000000000 --- a/depend/zcash/depends/packages/crate_num_integer.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_num_integer -$(package)_crate_name=num-integer -$(package)_version=0.1.41 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_num_traits.mk b/depend/zcash/depends/packages/crate_num_traits.mk deleted file mode 100644 index 19d87838f..000000000 --- a/depend/zcash/depends/packages/crate_num_traits.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_num_traits -$(package)_crate_name=num-traits -$(package)_version=0.2.8 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_opaque_debug.mk b/depend/zcash/depends/packages/crate_opaque_debug.mk deleted file mode 100644 index 7c493bba3..000000000 --- a/depend/zcash/depends/packages/crate_opaque_debug.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_opaque_debug -$(package)_crate_name=opaque-debug -$(package)_version=0.2.3 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_pairing.mk b/depend/zcash/depends/packages/crate_pairing.mk deleted file mode 100644 index 454b8f106..000000000 --- a/depend/zcash/depends/packages/crate_pairing.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_pairing -$(package)_crate_name=pairing -$(package)_version=0.16.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=b8290dea210a712682cd65031dc2b34fd132cf2729def3df7ee08f0737ff5ed6 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_ppv_lite86.mk b/depend/zcash/depends/packages/crate_ppv_lite86.mk deleted file mode 100644 index 30641f95a..000000000 --- a/depend/zcash/depends/packages/crate_ppv_lite86.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_ppv_lite86 -$(package)_crate_name=ppv-lite86 -$(package)_version=0.2.5 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_proc_macro2.mk b/depend/zcash/depends/packages/crate_proc_macro2.mk deleted file mode 100644 index 4e59111aa..000000000 --- a/depend/zcash/depends/packages/crate_proc_macro2.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_proc_macro2 -$(package)_crate_name=proc-macro2 -$(package)_version=1.0.3 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_quote.mk b/depend/zcash/depends/packages/crate_quote.mk deleted file mode 100644 index 48e0c8ea1..000000000 --- a/depend/zcash/depends/packages/crate_quote.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_quote -$(package)_crate_name=quote -$(package)_version=1.0.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_rand.mk b/depend/zcash/depends/packages/crate_rand.mk deleted file mode 100644 index 7832db1b3..000000000 --- a/depend/zcash/depends/packages/crate_rand.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_rand -$(package)_crate_name=rand -$(package)_version=0.7.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_rand_chacha.mk b/depend/zcash/depends/packages/crate_rand_chacha.mk deleted file mode 100644 index ed2953fab..000000000 --- a/depend/zcash/depends/packages/crate_rand_chacha.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_rand_chacha -$(package)_crate_name=rand_chacha -$(package)_version=0.2.1 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_rand_core.mk b/depend/zcash/depends/packages/crate_rand_core.mk deleted file mode 100644 index 230b257c9..000000000 --- a/depend/zcash/depends/packages/crate_rand_core.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_rand_core -$(package)_crate_name=rand_core -$(package)_version=0.5.1 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_rand_hc.mk b/depend/zcash/depends/packages/crate_rand_hc.mk deleted file mode 100644 index 3d5155359..000000000 --- a/depend/zcash/depends/packages/crate_rand_hc.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_rand_hc -$(package)_crate_name=rand_hc -$(package)_version=0.2.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_rand_xorshift.mk b/depend/zcash/depends/packages/crate_rand_xorshift.mk deleted file mode 100644 index 6daa22805..000000000 --- a/depend/zcash/depends/packages/crate_rand_xorshift.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_rand_xorshift -$(package)_crate_name=rand_xorshift -$(package)_version=0.2.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_rustc_version.mk b/depend/zcash/depends/packages/crate_rustc_version.mk deleted file mode 100644 index f3c7410ee..000000000 --- a/depend/zcash/depends/packages/crate_rustc_version.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_rustc_version -$(package)_crate_name=rustc_version -$(package)_version=0.2.3 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_scopeguard.mk b/depend/zcash/depends/packages/crate_scopeguard.mk deleted file mode 100644 index a3a778dc4..000000000 --- a/depend/zcash/depends/packages/crate_scopeguard.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_scopeguard -$(package)_crate_name=scopeguard -$(package)_version=1.0.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_semver.mk b/depend/zcash/depends/packages/crate_semver.mk deleted file mode 100644 index 2ef1ba869..000000000 --- a/depend/zcash/depends/packages/crate_semver.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_semver -$(package)_crate_name=semver -$(package)_version=0.9.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_semver_parser.mk b/depend/zcash/depends/packages/crate_semver_parser.mk deleted file mode 100644 index 9316860ac..000000000 --- a/depend/zcash/depends/packages/crate_semver_parser.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_semver_parser -$(package)_crate_name=semver-parser -$(package)_version=0.7.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_serde.mk b/depend/zcash/depends/packages/crate_serde.mk deleted file mode 100644 index 944c7c948..000000000 --- a/depend/zcash/depends/packages/crate_serde.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_serde -$(package)_crate_name=serde -$(package)_version=1.0.113 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=6135c78461981c79497158ef777264c51d9d0f4f3fc3a4d22b915900e42dac6a -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_serde_derive.mk b/depend/zcash/depends/packages/crate_serde_derive.mk deleted file mode 100644 index a61dc3c76..000000000 --- a/depend/zcash/depends/packages/crate_serde_derive.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_serde_derive -$(package)_crate_name=serde_derive -$(package)_version=1.0.113 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=93c5eaa17d0954cb481cdcfffe9d84fcfa7a1a9f2349271e678677be4c26ae31 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_sha2.mk b/depend/zcash/depends/packages/crate_sha2.mk deleted file mode 100644 index 344582dbb..000000000 --- a/depend/zcash/depends/packages/crate_sha2.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_sha2 -$(package)_crate_name=sha2 -$(package)_version=0.8.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_subtle.mk b/depend/zcash/depends/packages/crate_subtle.mk deleted file mode 100644 index bd43b168c..000000000 --- a/depend/zcash/depends/packages/crate_subtle.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_subtle -$(package)_crate_name=subtle -$(package)_version=2.2.3 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=502d53007c02d7605a05df1c1a73ee436952781653da5d0bf57ad608f66932c1 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_syn.mk b/depend/zcash/depends/packages/crate_syn.mk deleted file mode 100644 index 557e8db3a..000000000 --- a/depend/zcash/depends/packages/crate_syn.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_syn -$(package)_crate_name=syn -$(package)_version=1.0.11 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_thiserror.mk b/depend/zcash/depends/packages/crate_thiserror.mk deleted file mode 100644 index 15234384b..000000000 --- a/depend/zcash/depends/packages/crate_thiserror.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_thiserror -$(package)_crate_name=thiserror -$(package)_version=1.0.20 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_thiserror_impl.mk b/depend/zcash/depends/packages/crate_thiserror_impl.mk deleted file mode 100644 index 4d7f8b475..000000000 --- a/depend/zcash/depends/packages/crate_thiserror_impl.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_thiserror_impl -$(package)_crate_name=thiserror-impl -$(package)_version=1.0.20 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_typenum.mk b/depend/zcash/depends/packages/crate_typenum.mk deleted file mode 100644 index f02fa5001..000000000 --- a/depend/zcash/depends/packages/crate_typenum.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_typenum -$(package)_crate_name=typenum -$(package)_version=1.11.2 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_unicode_xid.mk b/depend/zcash/depends/packages/crate_unicode_xid.mk deleted file mode 100644 index 16f7be517..000000000 --- a/depend/zcash/depends/packages/crate_unicode_xid.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_unicode_xid -$(package)_crate_name=unicode-xid -$(package)_version=0.2.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_wasi.mk b/depend/zcash/depends/packages/crate_wasi.mk deleted file mode 100644 index 613c52627..000000000 --- a/depend/zcash/depends/packages/crate_wasi.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_wasi -$(package)_crate_name=wasi -$(package)_version=0.7.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_winapi.mk b/depend/zcash/depends/packages/crate_winapi.mk deleted file mode 100644 index b8f86a00b..000000000 --- a/depend/zcash/depends/packages/crate_winapi.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_winapi -$(package)_crate_name=winapi -$(package)_version=0.3.8 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_winapi_i686_pc_windows_gnu.mk b/depend/zcash/depends/packages/crate_winapi_i686_pc_windows_gnu.mk deleted file mode 100644 index ff8c5e76f..000000000 --- a/depend/zcash/depends/packages/crate_winapi_i686_pc_windows_gnu.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_winapi_i686_pc_windows_gnu -$(package)_crate_name=winapi-i686-pc-windows-gnu -$(package)_version=0.4.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_winapi_x86_64_pc_windows_gnu.mk b/depend/zcash/depends/packages/crate_winapi_x86_64_pc_windows_gnu.mk deleted file mode 100644 index 725baf00f..000000000 --- a/depend/zcash/depends/packages/crate_winapi_x86_64_pc_windows_gnu.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_winapi_x86_64_pc_windows_gnu -$(package)_crate_name=winapi-x86_64-pc-windows-gnu -$(package)_version=0.4.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_zcash_history.mk b/depend/zcash/depends/packages/crate_zcash_history.mk deleted file mode 100644 index fd5570fa4..000000000 --- a/depend/zcash/depends/packages/crate_zcash_history.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_zcash_history -$(package)_crate_name=zcash_history -$(package)_version=0.2.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=abfbab9accba014bbf3098d5aa66c1714d0db4abe25b999b8400bbd626ccd2f4 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_zcash_primitives.mk b/depend/zcash/depends/packages/crate_zcash_primitives.mk deleted file mode 100644 index 8d22560ff..000000000 --- a/depend/zcash/depends/packages/crate_zcash_primitives.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_zcash_primitives -$(package)_crate_name=zcash_primitives -$(package)_version=0.2.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=8f33b9e4f3b4db97234fc79ea67b12f2d5778bde8f3eab6dbba52eb54c596585 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_zcash_proofs.mk b/depend/zcash/depends/packages/crate_zcash_proofs.mk deleted file mode 100644 index c3e40b0f3..000000000 --- a/depend/zcash/depends/packages/crate_zcash_proofs.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_zcash_proofs -$(package)_crate_name=zcash_proofs -$(package)_version=0.2.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=2011f78f14d5121248d3b4f921434207b1d870fb3bf2efc7d784cae79b19bfbc -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/crate_zeroize.mk b/depend/zcash/depends/packages/crate_zeroize.mk deleted file mode 100644 index ffdb96dde..000000000 --- a/depend/zcash/depends/packages/crate_zeroize.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_zeroize -$(package)_crate_name=zeroize -$(package)_version=1.1.0 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/googletest.mk b/depend/zcash/depends/packages/googletest.mk index 98ef97842..857f75789 100644 --- a/depend/zcash/depends/packages/googletest.mk +++ b/depend/zcash/depends/packages/googletest.mk @@ -1,14 +1,19 @@ package=googletest -$(package)_version=1.8.0 +$(package)_version=1.8.1 $(package)_download_path=https://github.com/google/$(package)/archive/ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_download_file=release-$($(package)_version).tar.gz -$(package)_sha256_hash=58a6f4277ca2bc8565222b3bbd58a177609e9c488e8a72649359ba51450db7d8 +$(package)_sha256_hash=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c + +ifneq ($(host_os),darwin) +$(package)_dependencies=libcxx +endif define $(package)_set_vars $(package)_cxxflags+=-std=c++17 $(package)_cxxflags_linux=-fPIC $(package)_cxxflags_freebsd=-fPIC +$(package)_ldflags+=-static-libstdc++ -lc++abi endef define $(package)_build_cmds diff --git a/depend/zcash/depends/packages/libcxx.mk b/depend/zcash/depends/packages/libcxx.mk new file mode 100644 index 000000000..18df88905 --- /dev/null +++ b/depend/zcash/depends/packages/libcxx.mk @@ -0,0 +1,73 @@ +package=libcxx +$(package)_version=$(native_clang_version) + +ifneq ($(canonical_host),$(build)) +ifneq ($(host_os),mingw32) +# Clang is provided pre-compiled for a bunch of targets; fetch the one we need +# and stage its copies of the static libraries. +$(package)_download_path=https://releases.llvm.org/$($(package)_version) +$(package)_download_file_aarch64_linux=clang+llvm-$($(package)_version)-aarch64-linux-gnu.tar.xz +$(package)_file_name_aarch64_linux=clang-llvm-$($(package)_version)-aarch64-linux-gnu.tar.xz +$(package)_sha256_hash_aarch64_linux=998e9ae6e89bd3f029ed031ad9355c8b43441302c0e17603cf1de8ee9939e5c9 +$(package)_download_file_linux=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz +$(package)_file_name_linux=clang-llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz +$(package)_sha256_hash_linux=9ef854b71949f825362a119bf2597f744836cb571131ae6b721cd102ffea8cd0 + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/lib && \ + cp lib/libc++.a $($(package)_staging_prefix_dir)/lib && \ + cp lib/libc++abi.a $($(package)_staging_prefix_dir)/lib +endef + +else +# For Windows cross-compilation, use the MSYS2 binaries. +$(package)_download_path=http://repo.msys2.org/mingw/x86_64 +$(package)_download_file=mingw-w64-x86_64-libc++-9.0.1-1-any.pkg.tar.xz +$(package)_file_name=mingw-w64-x86_64-libcxx-9.0.1-1-any.pkg.tar.xz +$(package)_sha256_hash=04e77c5d0e3a9efc9cc8ca3b6549af9a9eef6e20d53076295efbdfba76c5f5de + +$(package)_libcxxabi_download_file=mingw-w64-x86_64-libc++abi-9.0.1-1-any.pkg.tar.xz +$(package)_libcxxabi_file_name=mingw-w64-x86_64-libc++abi-9.0.1-1-any.pkg.tar.xz +$(package)_libcxxabi_sha256_hash=e8a38084dc05c9f6bd4ded4fe1cdbbe16f7280d66426a76b2c3c23d0575aad5c + +$(package)_extra_sources += $($(package)_libcxxabi_file_name) + +define $(package)_fetch_cmds +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_libcxxabi_download_file),$($(package)_libcxxabi_file_name),$($(package)_libcxxabi_sha256_hash)) +endef + +define $(package)_extract_cmds + mkdir -p $($(package)_extract_dir) && \ + echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_libcxxabi_sha256_hash) $($(package)_source_dir)/$($(package)_libcxxabi_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + mkdir -p libcxxabi && \ + tar --no-same-owner --strip-components=1 -C libcxxabi -xf $($(package)_source_dir)/$($(package)_libcxxabi_file_name) && \ + tar --no-same-owner --strip-components=1 -xf $($(package)_source) +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/lib && \ + mv include/ $($(package)_staging_prefix_dir) && \ + cp lib/libc++.a $($(package)_staging_prefix_dir)/lib && \ + cp libcxxabi/lib/libc++abi.a $($(package)_staging_prefix_dir)/lib +endef +endif + +else +# For native compilation, use the static libraries from native_clang. +# We explicitly stage them so that subsequent dependencies don't link to the +# shared libraries distributed with Clang. +define $(package)_fetch_cmds +endef + +define $(package)_extract_cmds +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/lib && \ + cp $(build_prefix)/lib/libc++.a $($(package)_staging_prefix_dir)/lib && \ + cp $(build_prefix)/lib/libc++abi.a $($(package)_staging_prefix_dir)/lib +endef +endif diff --git a/depend/zcash/depends/packages/libevent.mk b/depend/zcash/depends/packages/libevent.mk index 7119176f2..2930b5e96 100644 --- a/depend/zcash/depends/packages/libevent.mk +++ b/depend/zcash/depends/packages/libevent.mk @@ -1,19 +1,17 @@ package=libevent -$(package)_version=2.1.8 +$(package)_version=2.1.12 $(package)_download_path=https://github.com/libevent/libevent/archive/ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_download_file=release-$($(package)_version)-stable.tar.gz -$(package)_sha256_hash=316ddb401745ac5d222d7c529ef1eada12f58f6376a66c1118eee803cb70f83d -$(package)_patches=detect-arch4random_addrandom.patch detect-arch4random_addrandom-fix.patch +$(package)_sha256_hash=7180a979aaa7000e1264da484f712d403fcf7679b1e9212c4e3d09f5c93efc24 define $(package)_preprocess_cmds - patch -p1 <$($(package)_patch_dir)/detect-arch4random_addrandom.patch && \ - patch -p1 <$($(package)_patch_dir)/detect-arch4random_addrandom-fix.patch && \ ./autogen.sh endef define $(package)_set_vars $(package)_config_opts=--disable-shared --disable-openssl --disable-libevent-regress + $(package)_config_opts += --disable-dependency-tracking --enable-option-checking $(package)_config_opts_release=--disable-debug-mode $(package)_config_opts_linux=--with-pic $(package)_config_opts_freebsd=--with-pic @@ -32,4 +30,5 @@ define $(package)_stage_cmds endef define $(package)_postprocess_cmds + rm lib/*.la endef diff --git a/depend/zcash/depends/packages/native_ccache.mk b/depend/zcash/depends/packages/native_ccache.mk index b63c18b90..4c5dde76d 100644 --- a/depend/zcash/depends/packages/native_ccache.mk +++ b/depend/zcash/depends/packages/native_ccache.mk @@ -1,8 +1,8 @@ package=native_ccache -$(package)_version=3.3.1 -$(package)_download_path=https://www.samba.org/ftp/ccache -$(package)_file_name=ccache-$($(package)_version).tar.bz2 -$(package)_sha256_hash=cb6e4bafbb19ba0a2ec43386b123a5f92a20e1e3384c071d5d13e0cb3c84bf73 +$(package)_version=3.7.12 +$(package)_download_path=https://github.com/ccache/ccache/releases/download/v$($(package)_version) +$(package)_file_name=ccache-$($(package)_version).tar.gz +$(package)_sha256_hash=d2abe88d4c283ce960e233583061127b156ffb027c6da3cf10770fc0c7244194 define $(package)_set_vars $(package)_config_opts= diff --git a/depend/zcash/depends/packages/native_cctools.mk b/depend/zcash/depends/packages/native_cctools.mk index a065256c1..5febaa3b9 100644 --- a/depend/zcash/depends/packages/native_cctools.mk +++ b/depend/zcash/depends/packages/native_cctools.mk @@ -1,49 +1,53 @@ package=native_cctools -$(package)_version=807d6fd1be5d2224872e381870c0a75387fe05e6 -$(package)_download_path=https://github.com/theuni/cctools-port/archive +$(package)_version=55562e4073dea0fbfd0b20e0bf69ffe6390c7f97 +$(package)_download_path=https://github.com/tpoechtrager/cctools-port/archive $(package)_file_name=$($(package)_version).tar.gz -$(package)_sha256_hash=a09c9ba4684670a0375e42d9d67e7f12c1f62581a27f28f7c825d6d7032ccc6a +$(package)_sha256_hash=e51995a843533a3dac155dd0c71362dd471597a2d23f13dff194c6285362f875 $(package)_build_subdir=cctools -$(package)_clang_version=3.7.1 -$(package)_clang_download_path=https://llvm.org/releases/$($(package)_clang_version) -$(package)_clang_download_file=clang+llvm-$($(package)_clang_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz -$(package)_clang_file_name=clang-llvm-$($(package)_clang_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz -$(package)_clang_sha256_hash=99b28a6b48e793705228a390471991386daa33a9717cd9ca007fcdde69608fd9 -$(package)_extra_sources=$($(package)_clang_file_name) +$(package)_dependencies=native_clang +$(package)_patches=ignore-otool.diff + +$(package)_libtapi_version=3efb201881e7a76a21e0554906cf306432539cef +$(package)_libtapi_download_path=https://github.com/tpoechtrager/apple-libtapi/archive +$(package)_libtapi_download_file=$($(package)_libtapi_version).tar.gz +$(package)_libtapi_file_name=$($(package)_libtapi_version).tar.gz +$(package)_libtapi_sha256_hash=380c1ca37cfa04a8699d0887a8d3ee1ad27f3d08baba78887c73b09485c0fbd3 + +$(package)_extra_sources += $($(package)_libtapi_file_name) define $(package)_fetch_cmds $(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \ -$(call fetch_file,$(package),$($(package)_clang_download_path),$($(package)_clang_download_file),$($(package)_clang_file_name),$($(package)_clang_sha256_hash)) +$(call fetch_file,$(package),$($(package)_libtapi_download_path),$($(package)_libtapi_download_file),$($(package)_libtapi_file_name),$($(package)_libtapi_sha256_hash)) endef define $(package)_extract_cmds mkdir -p $($(package)_extract_dir) && \ echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ - echo "$($(package)_clang_sha256_hash) $($(package)_source_dir)/$($(package)_clang_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_libtapi_sha256_hash) $($(package)_source_dir)/$($(package)_libtapi_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ - mkdir -p toolchain/bin toolchain/lib/clang/3.5/include && \ - tar --no-same-owner --strip-components=1 -C toolchain -xf $($(package)_source_dir)/$($(package)_clang_file_name) && \ - rm -f toolchain/lib/libc++abi.so* && \ - echo "#!/bin/sh" > toolchain/bin/$(host)-dsymutil && \ - echo "exit 0" >> toolchain/bin/$(host)-dsymutil && \ - chmod +x toolchain/bin/$(host)-dsymutil && \ + mkdir -p libtapi && \ + tar --no-same-owner --strip-components=1 -C libtapi -xf $($(package)_source_dir)/$($(package)_libtapi_file_name) && \ tar --no-same-owner --strip-components=1 -xf $($(package)_source) endef define $(package)_set_vars -$(package)_config_opts=--target=$(host) --disable-lto-support -$(package)_ldflags+=-Wl,-rpath=\\$$$$$$$$\$$$$$$$$ORIGIN/../lib -$(package)_cc=$($(package)_extract_dir)/toolchain/bin/clang -$(package)_cxx=$($(package)_extract_dir)/toolchain/bin/clang++ + $(package)_config_opts=--target=$(host) --with-libtapi=$($(package)_extract_dir) + $(package)_ldflags+=-Wl,-rpath=\\$$$$$$$$\$$$$$$$$ORIGIN/../lib + $(package)_config_opts+=--enable-lto-support --with-llvm-config=$(build_prefix)/bin/llvm-config + $(package)_cc=$(build_prefix)/bin/clang + $(package)_cxx=$(build_prefix)/bin/clang++ endef define $(package)_preprocess_cmds - cd $($(package)_build_subdir); ./autogen.sh && \ - sed -i.old "/define HAVE_PTHREADS/d" ld64/src/ld/InputFiles.h + patch -p1 < $($(package)_patch_dir)/ignore-otool.diff && \ + cd $($(package)_build_subdir); DO_NOT_UPDATE_CONFIG_SCRIPTS=1 ./autogen.sh endef define $(package)_config_cmds - $($(package)_autoconf) + rm -f $(build_prefix)/lib/libc++abi.so* && \ + CC=$($(package)_cc) CXX=$($(package)_cxx) INSTALLPREFIX=$($(package)_extract_dir) ../libtapi/build.sh && \ + CC=$($(package)_cc) CXX=$($(package)_cxx) INSTALLPREFIX=$($(package)_extract_dir) ../libtapi/install.sh && \ + $($(package)_config_env) $($(package)_autoconf) endef define $(package)_build_cmds @@ -52,14 +56,7 @@ endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install && \ - cd $($(package)_extract_dir)/toolchain && \ - mkdir -p $($(package)_staging_prefix_dir)/lib/clang/$($(package)_clang_version)/include && \ - mkdir -p $($(package)_staging_prefix_dir)/bin $($(package)_staging_prefix_dir)/include && \ - cp bin/clang $($(package)_staging_prefix_dir)/bin/ &&\ - cp -P bin/clang++ $($(package)_staging_prefix_dir)/bin/ &&\ - cp lib/libLTO.so $($(package)_staging_prefix_dir)/lib/ && \ - cp -rf lib/clang/$($(package)_clang_version)/include/* $($(package)_staging_prefix_dir)/lib/clang/$($(package)_clang_version)/include/ && \ - cp bin/llvm-dsymutil $($(package)_staging_prefix_dir)/bin/$(host)-dsymutil && \ - if `test -d include/c++/`; then cp -rf include/c++/ $($(package)_staging_prefix_dir)/include/; fi && \ - if `test -d lib/c++/`; then cp -rf lib/c++/ $($(package)_staging_prefix_dir)/lib/; fi + mkdir -p $($(package)_staging_prefix_dir)/lib/ && \ + cd $($(package)_extract_dir) && \ + cp lib/libtapi.so.6 $($(package)_staging_prefix_dir)/lib/ endef diff --git a/depend/zcash/depends/packages/native_clang.mk b/depend/zcash/depends/packages/native_clang.mk new file mode 100644 index 000000000..dfef49f66 --- /dev/null +++ b/depend/zcash/depends/packages/native_clang.mk @@ -0,0 +1,37 @@ +package=native_clang +$(package)_major_version=8 +$(package)_version=8.0.0 +$(package)_download_path=https://releases.llvm.org/$($(package)_version) +$(package)_download_file_linux=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz +$(package)_file_name_linux=clang-llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz +$(package)_sha256_hash_linux=9ef854b71949f825362a119bf2597f744836cb571131ae6b721cd102ffea8cd0 +$(package)_download_file_darwin=clang+llvm-$($(package)_version)-x86_64-apple-darwin.tar.xz +$(package)_file_name_darwin=clang-llvm-$($(package)_version)-x86_64-apple-darwin.tar.xz +$(package)_sha256_hash_darwin=94ebeb70f17b6384e052c47fef24a6d70d3d949ab27b6c83d4ab7b298278ad6f + +# Ensure we have clang native to the builder, not the target host +ifneq ($(canonical_host),$(build)) +$(package)_exact_download_file=$($(package)_download_file_$(build_os)) +$(package)_exact_file_name=$($(package)_file_name_$(build_os)) +$(package)_exact_sha256_hash=$($(package)_sha256_hash_$(build_os)) +endif + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/bin && \ + cp bin/clang-$($(package)_major_version) $($(package)_staging_prefix_dir)/bin && \ + cp bin/lld $($(package)_staging_prefix_dir)/bin && \ + cp bin/llvm-ar $($(package)_staging_prefix_dir)/bin && \ + cp bin/llvm-config $($(package)_staging_prefix_dir)/bin && \ + cp bin/llvm-nm $($(package)_staging_prefix_dir)/bin && \ + cp bin/llvm-objcopy $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/clang $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/clang++ $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/ld.lld $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/ld64.lld $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/lld-link $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/llvm-ranlib $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/llvm-strip $($(package)_staging_prefix_dir)/bin && \ + mv include/ $($(package)_staging_prefix_dir) && \ + mv lib/ $($(package)_staging_prefix_dir) && \ + mv libexec/ $($(package)_staging_prefix_dir) +endef diff --git a/depend/zcash/depends/packages/rust.mk b/depend/zcash/depends/packages/native_rust.mk similarity index 73% rename from depend/zcash/depends/packages/rust.mk rename to depend/zcash/depends/packages/native_rust.mk index 2546a733e..400cef222 100644 --- a/depend/zcash/depends/packages/rust.mk +++ b/depend/zcash/depends/packages/native_rust.mk @@ -1,22 +1,23 @@ -package=rust -$(package)_version=1.42.0 +package=native_rust +$(package)_version=1.44.1 $(package)_download_path=https://static.rust-lang.org/dist $(package)_file_name_linux=rust-$($(package)_version)-x86_64-unknown-linux-gnu.tar.gz -$(package)_sha256_hash_linux=7d1e07ad9c8a33d8d039def7c0a131c5917aa3ea0af3d0cc399c6faf7b789052 +$(package)_sha256_hash_linux=a41df89a461a580536aeb42755e43037556fba2e527dd13a1e1bb0749de28202 $(package)_file_name_darwin=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz -$(package)_sha256_hash_darwin=db1055c46e0d54b99da05e88c71fea21b3897e74a4f5ff9390e934f3f050c0a8 +$(package)_sha256_hash_darwin=a5464e7bcbce9647607904a4afa8362382f1fc55d39e7bbaf4483ac00eb5d56a $(package)_file_name_freebsd=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz -$(package)_sha256_hash_freebsd=230bcf17e4383fba85d3c87fe25d17737459fe561a5f4668fe70dcac2da4e17c +$(package)_sha256_hash_freebsd=36a14498f9d1d7fb50d6fc01740960a99aff3d4c4c3d2e4fff2795ac8042c957 # Mapping from GCC canonical hosts to Rust targets # If a mapping is not present, we assume they are identical, unless $host_os is # "darwin", in which case we assume x86_64-apple-darwin. +$(package)_rust_target_x86_64-pc-linux-gnu=x86_64-unknown-linux-gnu $(package)_rust_target_x86_64-w64-mingw32=x86_64-pc-windows-gnu # Mapping from Rust targets to SHA-256 hashes -$(package)_rust_std_sha256_hash_aarch64-unknown-linux-gnu=1343f51fc87049327233cee8941629c3d7dfdc425d359385f93665de3d46711b -$(package)_rust_std_sha256_hash_x86_64-apple-darwin=1d61e9ed5d29e1bb4c18e13d551c6d856c73fb8b410053245dc6e0d3b3a0e92c -$(package)_rust_std_sha256_hash_x86_64-pc-windows-gnu=8a8389f3860df6f42fbf8b76a62ddc7b9b6fe6d0fb526dcfc42faab1005bfb6d +$(package)_rust_std_sha256_hash_aarch64-unknown-linux-gnu=666c6d1f2c65a9bb6e20ae68a6eaa1c5aadee44ff4eb43c593836fe7daba1441 +$(package)_rust_std_sha256_hash_x86_64-apple-darwin=716305d18cfa88151b0446e8c1424e07831affa215d0c9a221c31a918f18b498 +$(package)_rust_std_sha256_hash_x86_64-pc-windows-gnu=d82ee422b024451c0001ee4dd4282e948405df7a3c315b2791880ed68c1ff88b define rust_target $(if $($(1)_rust_target_$(2)),$($(1)_rust_target_$(2)),$(if $(findstring darwin,$(3)),x86_64-apple-darwin,$(2))) @@ -46,12 +47,12 @@ define $(package)_extract_cmds endef define $(package)_stage_cmds - bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig && \ - ../$(canonical_host)/install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig + bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(build_prefix) --disable-ldconfig && \ + ../$(canonical_host)/install.sh --destdir=$($(package)_staging_dir) --prefix=$(build_prefix) --disable-ldconfig endef else define $(package)_stage_cmds - bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig + bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(build_prefix) --disable-ldconfig endef endif diff --git a/depend/zcash/depends/packages/openssl.mk b/depend/zcash/depends/packages/openssl.mk deleted file mode 100644 index 28ae448ff..000000000 --- a/depend/zcash/depends/packages/openssl.mk +++ /dev/null @@ -1,116 +0,0 @@ -package=openssl -$(package)_version=1.1.1a -$(package)_download_path=https://www.openssl.org/source/old/1.1.1 -$(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=fc20130f8b7cbd2fb918b2f14e2f429e109c31ddd0fb38fc5d71d9ffed3f9f41 - -define $(package)_set_vars -$(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)" -$(package)_config_opts=--prefix=$(host_prefix) --openssldir=$(host_prefix)/etc/openssl -$(package)_config_opts+=no-afalgeng -$(package)_config_opts+=no-asm -$(package)_config_opts+=no-async -$(package)_config_opts+=no-bf -$(package)_config_opts+=no-blake2 -$(package)_config_opts+=no-camellia -$(package)_config_opts+=no-capieng -$(package)_config_opts+=no-cast -$(package)_config_opts+=no-chacha -$(package)_config_opts+=no-cmac -$(package)_config_opts+=no-cms -$(package)_config_opts+=no-comp -$(package)_config_opts+=no-crypto-mdebug -$(package)_config_opts+=no-crypto-mdebug-backtrace -$(package)_config_opts+=no-ct -$(package)_config_opts+=no-des -$(package)_config_opts+=no-dgram -$(package)_config_opts+=no-dsa -$(package)_config_opts+=no-dso -$(package)_config_opts+=no-dtls -$(package)_config_opts+=no-dtls1 -$(package)_config_opts+=no-dtls1-method -$(package)_config_opts+=no-dynamic-engine -$(package)_config_opts+=no-ec2m -$(package)_config_opts+=no-ec_nistp_64_gcc_128 -$(package)_config_opts+=no-egd -$(package)_config_opts+=no-engine -$(package)_config_opts+=no-err -$(package)_config_opts+=no-gost -$(package)_config_opts+=no-heartbeats -$(package)_config_opts+=no-idea -$(package)_config_opts+=no-md2 -$(package)_config_opts+=no-md4 -$(package)_config_opts+=no-mdc2 -$(package)_config_opts+=no-multiblock -$(package)_config_opts+=no-nextprotoneg -$(package)_config_opts+=no-ocb -$(package)_config_opts+=no-ocsp -$(package)_config_opts+=no-poly1305 -$(package)_config_opts+=no-posix-io -$(package)_config_opts+=no-psk -$(package)_config_opts+=no-rc2 -$(package)_config_opts+=no-rc4 -$(package)_config_opts+=no-rc5 -$(package)_config_opts+=no-rdrand -$(package)_config_opts+=no-rfc3779 -$(package)_config_opts+=no-rmd160 -$(package)_config_opts+=no-scrypt -$(package)_config_opts+=no-sctp -$(package)_config_opts+=no-seed -$(package)_config_opts+=no-shared -$(package)_config_opts+=no-sock -$(package)_config_opts+=no-srp -$(package)_config_opts+=no-srtp -$(package)_config_opts+=no-ssl -$(package)_config_opts+=no-ssl3 -$(package)_config_opts+=no-ssl3-method -$(package)_config_opts+=no-ssl-trace -$(package)_config_opts+=no-stdio -$(package)_config_opts+=no-tls -$(package)_config_opts+=no-tls1 -$(package)_config_opts+=no-tls1-method -$(package)_config_opts+=no-ts -$(package)_config_opts+=no-ui -$(package)_config_opts+=no-unit-test -$(package)_config_opts+=no-weak-ssl-ciphers -$(package)_config_opts+=no-whirlpool -$(package)_config_opts+=no-zlib -$(package)_config_opts+=no-zlib-dynamic -$(package)_config_opts+=$($(package)_cflags) $($(package)_cppflags) -$(package)_config_opts+=-DPURIFY -$(package)_config_opts_linux=-fPIC -Wa,--noexecstack -$(package)_config_opts_freebsd=-fPIC -Wa,--noexecstack -$(package)_config_opts_x86_64_linux=linux-x86_64 -$(package)_config_opts_i686_linux=linux-generic32 -$(package)_config_opts_arm_linux=linux-generic32 -$(package)_config_opts_aarch64_linux=linux-generic64 -$(package)_config_opts_mipsel_linux=linux-generic32 -$(package)_config_opts_mips_linux=linux-generic32 -$(package)_config_opts_powerpc_linux=linux-generic32 -$(package)_config_opts_x86_64_darwin=darwin64-x86_64-cc -$(package)_config_opts_x86_64_freebsd=BSD-x86_64 -$(package)_config_opts_i686_freebsd=BSD-generic32 -$(package)_config_opts_x86_64_mingw32=mingw64 -$(package)_config_opts_i686_mingw32=mingw -endef - -define $(package)_preprocess_cmds - sed -i.old 's/built on: $$$$date/built on: date not available/' util/mkbuildinf.pl && \ - sed -i.old "s|\"engines\", \"apps\", \"test\"|\"engines\"|" Configure -endef - -define $(package)_config_cmds - ./Configure $($(package)_config_opts) -endef - -define $(package)_build_cmds - $(MAKE) -j1 build_libs libcrypto.pc libssl.pc openssl.pc -endef - -define $(package)_stage_cmds - $(MAKE) DESTDIR=$($(package)_staging_dir) -j1 install_sw -endef - -define $(package)_postprocess_cmds - rm -rf share bin etc -endef diff --git a/depend/zcash/depends/packages/packages.mk b/depend/zcash/depends/packages/packages.mk index 75bcb4de0..3ab9925c7 100644 --- a/depend/zcash/depends/packages/packages.mk +++ b/depend/zcash/depends/packages/packages.mk @@ -1,95 +1,14 @@ -rust_crates := \ - crate_aes \ - crate_aesni \ - crate_aes_soft \ - crate_arrayref \ - crate_arrayvec \ - crate_autocfg \ - crate_bellman \ - crate_bigint \ - crate_bit_vec \ - crate_blake2b_simd \ - crate_blake2s_simd \ - crate_block_buffer \ - crate_block_cipher_trait \ - crate_block_padding \ - crate_byte_tools \ - crate_byteorder \ - crate_c2_chacha \ - crate_cfg_if \ - crate_constant_time_eq \ - crate_crossbeam_channel \ - crate_crossbeam_deque \ - crate_crossbeam_epoch \ - crate_crossbeam_queue \ - crate_crossbeam_utils \ - crate_crossbeam \ - crate_crunchy \ - crate_crypto_api_chachapoly \ - crate_crypto_api \ - crate_curve25519_dalek \ - crate_digest \ - crate_directories \ - crate_ed25519_zebra \ - crate_fake_simd \ - crate_ff_derive \ - crate_ff \ - crate_fpe \ - crate_futures_cpupool \ - crate_futures \ - crate_generic_array \ - crate_getrandom \ - crate_group \ - crate_hex \ - crate_hex2 \ - crate_lazy_static \ - crate_libc \ - crate_log \ - crate_memoffset \ - crate_nodrop \ - crate_num_bigint \ - crate_num_cpus \ - crate_num_integer \ - crate_num_traits \ - crate_opaque_debug \ - crate_pairing \ - crate_ppv_lite86 \ - crate_proc_macro2 \ - crate_quote \ - crate_rand_chacha \ - crate_rand_core \ - crate_rand_hc \ - crate_rand_xorshift \ - crate_rand \ - crate_rustc_version \ - crate_scopeguard \ - crate_semver_parser \ - crate_semver \ - crate_serde \ - crate_serde_derive \ - crate_sha2 \ - crate_subtle \ - crate_syn \ - crate_thiserror \ - crate_thiserror_impl \ - crate_typenum \ - crate_unicode_xid \ - crate_wasi \ - crate_winapi_i686_pc_windows_gnu \ - crate_winapi \ - crate_winapi_x86_64_pc_windows_gnu \ - crate_zcash_history \ - crate_zcash_primitives \ - crate_zcash_proofs \ - crate_zeroize -rust_packages := rust $(rust_crates) -proton_packages := proton zcash_packages := libsodium utfcpp -packages := boost openssl libevent zeromq $(zcash_packages) googletest -native_packages := native_ccache +packages := boost libevent zeromq $(zcash_packages) googletest +native_packages := native_clang native_ccache native_rust wallet_packages=bdb ifneq ($(build_os),darwin) darwin_native_packages=native_cctools endif + +# We use a complete SDK for Darwin, which includes libc++. +ifneq ($(host_os),darwin) +packages += libcxx +endif diff --git a/depend/zcash/depends/packages/proton.mk b/depend/zcash/depends/packages/proton.mk deleted file mode 100644 index 3d23f9322..000000000 --- a/depend/zcash/depends/packages/proton.mk +++ /dev/null @@ -1,24 +0,0 @@ -package=proton -$(package)_version=0.30.0 -$(package)_download_path=https://archive.apache.org/dist/qpid/proton/$($(package)_version) -$(package)_file_name=qpid-proton-$($(package)_version).tar.gz -$(package)_sha256_hash=e37fd8fb13391c3996f927839969a8f66edf35612392d0611eeac6e39e48dd33 -$(package)_patches=minimal-build.patch - -define $(package)_preprocess_cmds - patch -p1 < $($(package)_patch_dir)/minimal-build.patch && \ - mkdir -p build/proton-c/src -endef - -define $(package)_config_cmds - cd build; cmake .. -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=/ -DSYSINSTALL_BINDINGS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_PYTHON=OFF -DBUILD_RUBY=OFF -DBUILD_GO=OFF -DBUILD_STATIC_LIBS=ON -DLIB_SUFFIX= -DENABLE_JSONCPP= -endef - -define $(package)_build_cmds - cd build; $(MAKE) VERBOSE=1 -endef - -define $(package)_stage_cmds - cd build; $(MAKE) VERBOSE=1 DESTDIR=$($(package)_staging_prefix_dir) install -endef - diff --git a/depend/zcash/depends/packages/utfcpp.mk b/depend/zcash/depends/packages/utfcpp.mk index 40e6026f7..915522651 100644 --- a/depend/zcash/depends/packages/utfcpp.mk +++ b/depend/zcash/depends/packages/utfcpp.mk @@ -1,9 +1,9 @@ package=utfcpp -$(package)_version=3.1 +$(package)_version=3.1.2 $(package)_download_path=https://github.com/nemtrif/$(package)/archive/ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_download_file=v$($(package)_version).tar.gz -$(package)_sha256_hash=ab531c3fd5d275150430bfaca01d7d15e017a188183be932322f2f651506b096 +$(package)_sha256_hash=fea3bfa39fb8bd7368077ea5e1e0db9a8951f7e6fb6d9400b00ab3d92b807c6d define $(package)_stage_cmds cp -a ./source $($(package)_staging_dir)$(host_prefix)/include diff --git a/depend/zcash/depends/packages/vendorcrate.mk b/depend/zcash/depends/packages/vendorcrate.mk deleted file mode 100644 index 728eb71b5..000000000 --- a/depend/zcash/depends/packages/vendorcrate.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_CRATEFILE -$(package)_crate_name=CRATENAME -$(package)_version=CRATEVER -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=CRATEHASH -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depend/zcash/depends/packages/vendorcrate.sh b/depend/zcash/depends/packages/vendorcrate.sh deleted file mode 100755 index b76521ae4..000000000 --- a/depend/zcash/depends/packages/vendorcrate.sh +++ /dev/null @@ -1,12 +0,0 @@ -pkgdir=$(dirname $0) - -cratefile=$(echo "$1" | tr '-' '_') -cratename=$1 -cratever=$2 -cratehash=$(curl "https://static.crates.io/crates/$cratename/$cratename-$cratever.crate" | sha256sum | awk '{print $1}') - -cat "$pkgdir/vendorcrate.mk" | -sed "s/CRATEFILE/$cratefile/g" | -sed "s/CRATENAME/$cratename/g" | -sed "s/CRATEVER/$cratever/g" | -sed "s/CRATEHASH/$cratehash/g" > "$pkgdir/crate_$cratefile.mk" diff --git a/depend/zcash/depends/packages/zeromq.mk b/depend/zcash/depends/packages/zeromq.mk index af4243162..afc24ee1e 100644 --- a/depend/zcash/depends/packages/zeromq.mk +++ b/depend/zcash/depends/packages/zeromq.mk @@ -1,14 +1,27 @@ package=zeromq -$(package)_version=4.3.1 +$(package)_version=4.3.3 $(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version)/ $(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=bcbabe1e2c7d0eec4ed612e10b94b112dd5f06fcefa994a0c79a45d835cd21eb +$(package)_sha256_hash=9d9285db37ae942ed0780c016da87060497877af45094ff9e1a1ca736e3875a2 +$(package)_patches=windows-unused-variables.diff + +ifneq ($(host_os),darwin) +$(package)_dependencies=libcxx +endif define $(package)_set_vars - $(package)_config_opts=--without-documentation --disable-shared --disable-curve + $(package)_config_opts=--without-docs --disable-shared --disable-curve --disable-curve-keygen --disable-perf + $(package)_config_opts += --without-libgssapi_krb5 --without-pgm --without-norm --without-vmci + $(package)_config_opts += --disable-libunwind --disable-radix-tree --without-gcov --disable-dependency-tracking + $(package)_config_opts += --disable-drafts --enable-option-checking $(package)_config_opts_linux=--with-pic $(package)_config_opts_freebsd=--with-pic - $(package)_cxxflags=-std=c++17 + $(package)_cxxflags+=-std=c++17 + $(package)_ldflags+=-static-libstdc++ -lc++abi +endef + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/windows-unused-variables.diff endef define $(package)_config_cmds @@ -24,5 +37,5 @@ define $(package)_stage_cmds endef define $(package)_postprocess_cmds - rm -rf bin share + rm -rf bin share lib/*.la endef diff --git a/depend/zcash/depends/patches/bdb/winioctl-and-atomic_init_db.patch b/depend/zcash/depends/patches/bdb/winioctl-and-atomic_init_db.patch new file mode 100644 index 000000000..788da5be4 --- /dev/null +++ b/depend/zcash/depends/patches/bdb/winioctl-and-atomic_init_db.patch @@ -0,0 +1,136 @@ +diff --git a/src/dbinc/atomic.h b/src/dbinc/atomic.h +index e4420aa..4799b5f 100644 +--- a/src/dbinc/atomic.h ++++ b/src/dbinc/atomic.h +@@ -70,7 +70,7 @@ typedef struct { + * These have no memory barriers; the caller must include them when necessary. + */ + #define atomic_read(p) ((p)->value) +-#define atomic_init(p, val) ((p)->value = (val)) ++#define atomic_init_db(p, val) ((p)->value = (val)) + + #ifdef HAVE_ATOMIC_SUPPORT + +@@ -225,7 +225,7 @@ static inline int __atomic_compare_exchange_int( + #define atomic_dec(env, p) (--(p)->value) + #define atomic_compare_exchange(env, p, oldval, newval) \ + (DB_ASSERT(env, atomic_read(p) == (oldval)), \ +- atomic_init(p, (newval)), 1) ++ atomic_init_db(p, (newval)), 1) + #else + #define atomic_inc(env, p) __atomic_inc_int(env, p) + #define atomic_dec(env, p) __atomic_dec_int(env, p) +diff --git a/src/dbinc/win_db.h b/src/dbinc/win_db.h +index f5228f4..6e44659 100644 +--- a/src/dbinc/win_db.h ++++ b/src/dbinc/win_db.h +@@ -51,7 +51,7 @@ + #include + #include + #ifndef DB_WINCE +-#include ++#include + #endif + + #ifdef HAVE_GETADDRINFO +diff --git a/src/mp/mp_fget.c b/src/mp/mp_fget.c +index 59fe9fe..fa4ced7 100644 +--- a/src/mp/mp_fget.c ++++ b/src/mp/mp_fget.c +@@ -654,7 +654,7 @@ alloc: /* Allocate a new buffer header and data space. */ + + /* Initialize enough so we can call __memp_bhfree. */ + alloc_bhp->flags = 0; +- atomic_init(&alloc_bhp->ref, 1); ++ atomic_init_db(&alloc_bhp->ref, 1); + #ifdef DIAGNOSTIC + if ((uintptr_t)alloc_bhp->buf & (sizeof(size_t) - 1)) { + __db_errx(env, DB_STR("3025", +@@ -969,7 +969,7 @@ alloc: /* Allocate a new buffer header and data space. */ + MVCC_MPROTECT(bhp->buf, mfp->pagesize, + PROT_READ); + +- atomic_init(&alloc_bhp->ref, 1); ++ atomic_init_db(&alloc_bhp->ref, 1); + MUTEX_LOCK(env, alloc_bhp->mtx_buf); + alloc_bhp->priority = bhp->priority; + alloc_bhp->pgno = bhp->pgno; +diff --git a/src/mp/mp_mvcc.c b/src/mp/mp_mvcc.c +index 83c4d72..0a47202 100644 +--- a/src/mp/mp_mvcc.c ++++ b/src/mp/mp_mvcc.c +@@ -281,7 +281,7 @@ __memp_bh_freeze(dbmp, infop, hp, bhp, need_frozenp) + #else + memcpy(frozen_bhp, bhp, SSZA(BH, buf)); + #endif +- atomic_init(&frozen_bhp->ref, 0); ++ atomic_init_db(&frozen_bhp->ref, 0); + if (mutex != MUTEX_INVALID) + frozen_bhp->mtx_buf = mutex; + else if ((ret = __mutex_alloc(env, MTX_MPOOL_BH, +@@ -440,7 +440,7 @@ __memp_bh_thaw(dbmp, infop, hp, frozen_bhp, alloc_bhp) + #endif + alloc_bhp->mtx_buf = mutex; + MUTEX_LOCK(env, alloc_bhp->mtx_buf); +- atomic_init(&alloc_bhp->ref, 1); ++ atomic_init_db(&alloc_bhp->ref, 1); + F_CLR(alloc_bhp, BH_FROZEN); + } + +diff --git a/src/mp/mp_region.c b/src/mp/mp_region.c +index 4d95e4f..e97459c 100644 +--- a/src/mp/mp_region.c ++++ b/src/mp/mp_region.c +@@ -278,7 +278,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg) + MTX_MPOOL_FILE_BUCKET, 0, &htab[i].mtx_hash)) != 0) + return (ret); + SH_TAILQ_INIT(&htab[i].hash_bucket); +- atomic_init(&htab[i].hash_page_dirty, 0); ++ atomic_init_db(&htab[i].hash_page_dirty, 0); + } + + mtx_base = mtx_prev = MUTEX_INVALID; +@@ -332,7 +332,7 @@ no_prealloc: + DB_MUTEX_SHARED, &hp->mtx_hash)) != 0) + return (ret); + SH_TAILQ_INIT(&hp->hash_bucket); +- atomic_init(&hp->hash_page_dirty, 0); ++ atomic_init_db(&hp->hash_page_dirty, 0); + #ifdef HAVE_STATISTICS + hp->hash_io_wait = 0; + hp->hash_frozen = hp->hash_thawed = hp->hash_frozen_freed = 0; +diff --git a/src/mutex/mut_method.c b/src/mutex/mut_method.c +index 72b34de..a9f9868 100644 +--- a/src/mutex/mut_method.c ++++ b/src/mutex/mut_method.c +@@ -501,7 +501,7 @@ __atomic_compare_exchange_int(env, v, oldval, newval) + MUTEX_LOCK(env, mtx); + ret = atomic_read(v) == oldval; + if (ret) +- atomic_init(v, newval); ++ atomic_init_db(v, newval); + MUTEX_UNLOCK(env, mtx); + + return (ret); +diff --git a/src/mutex/mut_tas.c b/src/mutex/mut_tas.c +index 7899c4b..d9420fa 100644 +--- a/src/mutex/mut_tas.c ++++ b/src/mutex/mut_tas.c +@@ -47,7 +47,7 @@ __db_tas_mutex_init(env, mutex, flags) + + #ifdef HAVE_SHARED_LATCHES + if (F_ISSET(mutexp, DB_MUTEX_SHARED)) +- atomic_init(&mutexp->sharecount, 0); ++ atomic_init_db(&mutexp->sharecount, 0); + else + #endif + if (MUTEX_INIT(&mutexp->tas)) { +@@ -643,7 +643,7 @@ was_not_locked: + F_CLR(mutexp, DB_MUTEX_LOCKED); + /* Flush flag update before zeroing count */ + MEMBAR_EXIT(); +- atomic_init(&mutexp->sharecount, 0); ++ atomic_init_db(&mutexp->sharecount, 0); + } else { + DB_ASSERT(env, sharecount > 0); + MEMBAR_EXIT(); diff --git a/depend/zcash/depends/patches/boost/darwin.diff b/depend/zcash/depends/patches/boost/darwin.diff deleted file mode 100644 index ec3ed76e4..000000000 --- a/depend/zcash/depends/patches/boost/darwin.diff +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/darwin.jam b/darwin.jam -index 8d47741..641d8bb 100644 ---- a/tools/build/src/tools/darwin.jam -+++ b/tools/build/src/tools/darwin.jam -@@ -138,14 +138,14 @@ rule init ( version ? : command * : options * : requirement * ) - common.handle-options darwin : $(condition) : $(command) : $(options) ; - - # - GCC 4.0 and higher in Darwin does not have -fcoalesce-templates. -- if $(real-version) < "4.0.0" -- { -- flags darwin.compile.c++ OPTIONS $(condition) : -fcoalesce-templates ; -- } -+# if $(real-version) < "4.0.0" -+# { -+# flags darwin.compile.c++ OPTIONS $(condition) : -fcoalesce-templates ; -+# } - # - GCC 4.2 and higher in Darwin does not have -Wno-long-double. -- if $(real-version) < "4.2.0" -- { -- flags darwin.compile OPTIONS $(condition) : -Wno-long-double ; -- } -+# if $(real-version) < "4.2.0" -+# { -+# flags darwin.compile OPTIONS $(condition) : -Wno-long-double ; -+# } - # - GCC on Darwin with -pedantic, suppress unsupported long long warning - flags darwin.compile OPTIONS $(condition)/all : -Wno-long-long ; diff --git a/depend/zcash/depends/patches/boost/iostreams-106.patch b/depend/zcash/depends/patches/boost/iostreams-106.patch new file mode 100644 index 000000000..dcecd5d0d --- /dev/null +++ b/depend/zcash/depends/patches/boost/iostreams-106.patch @@ -0,0 +1,25 @@ +From 4e76f73826fd0a7067b837e4850a9051436f5ec5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= + +Date: Sun, 22 Dec 2019 10:26:38 +0100 +Subject: [PATCH] Fix build on windows with libc++ + +Proposed by @SquallATF in #67 +--- + include/boost/iostreams/detail/config/fpos.hpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/include/boost/iostreams/detail/config/fpos.hpp b/include/boost/iostreams/detail/config/fpos.hpp +index c5dc6cf59..a5835421f 100644 +--- a/include/boost/iostreams/detail/config/fpos.hpp ++++ b/include/boost/iostreams/detail/config/fpos.hpp +@@ -26,7 +26,8 @@ + + # if (defined(_YVALS) || defined(_CPPLIB_VER)) && !defined(__SGI_STL_PORT) && \ + !defined(_STLPORT_VERSION) && !defined(__QNX__) && !defined(_VX_CPU) && !defined(__VXWORKS__) \ +- && !((defined(BOOST_MSVC) || defined(BOOST_CLANG)) && _MSVC_STL_VERSION >= 141) ++ && !((defined(BOOST_MSVC) || defined(BOOST_CLANG)) && _MSVC_STL_VERSION >= 141) \ ++ && !defined(_LIBCPP_VERSION) + /**/ + + #include diff --git a/depend/zcash/depends/patches/boost/signals2-noise.patch b/depend/zcash/depends/patches/boost/signals2-noise.patch new file mode 100644 index 000000000..e0a9ce48f --- /dev/null +++ b/depend/zcash/depends/patches/boost/signals2-noise.patch @@ -0,0 +1,23 @@ +From fd27423fea5537bc857c1fa14bb0c25b994f77b3 Mon Sep 17 00:00:00 2001 +From: Frank Mori Hess +Date: Mon, 20 Jul 2020 14:17:05 -0400 +Subject: [PATCH] Fix warning about deprecated + boost/function_output_iterator.hpp + +--- + include/boost/signals2/detail/null_output_iterator.hpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/boost/signals2/detail/null_output_iterator.hpp b/include/boost/signals2/detail/null_output_iterator.hpp +index 9e986959..dee4373c 100644 +--- a/include/boost/signals2/detail/null_output_iterator.hpp ++++ b/include/boost/signals2/detail/null_output_iterator.hpp +@@ -11,7 +11,7 @@ + #ifndef BOOST_SIGNALS2_NULL_OUTPUT_ITERATOR_HPP + #define BOOST_SIGNALS2_NULL_OUTPUT_ITERATOR_HPP + +-#include ++#include + + namespace boost + { diff --git a/depend/zcash/depends/patches/libevent/detect-arch4random_addrandom-fix.patch b/depend/zcash/depends/patches/libevent/detect-arch4random_addrandom-fix.patch deleted file mode 100644 index 69e55bf11..000000000 --- a/depend/zcash/depends/patches/libevent/detect-arch4random_addrandom-fix.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 266f43af7798befa3d27bfabaa9ae699259c3924 Mon Sep 17 00:00:00 2001 -From: Azat Khuzhin -Date: Mon, 27 Mar 2017 15:50:23 +0300 -Subject: [PATCH] Fix arc4random_addrandom() detecting and fallback - (regression) - -But this is kind of hot-fix, we definitelly need more sane arc4random -compat layer. - -Fixes: #488 -Introduced-in: 6541168 ("Detect arch4random_addrandom() existence") ---- - event-config.h.cmake | 3 +++ - include/event2/util.h | 2 +- - 2 files changed, 4 insertions(+), 1 deletion(-) - -diff --git a/event-config.h.cmake b/event-config.h.cmake -index b7f0be57c..5c233a3d9 100644 ---- a/event-config.h.cmake -+++ b/event-config.h.cmake -@@ -53,6 +53,9 @@ - /* Define to 1 if you have the `arc4random_buf' function. */ - #cmakedefine EVENT__HAVE_ARC4RANDOM_BUF 1 - -+/* Define to 1 if you have the `arc4random_addrandom' function. */ -+#cmakedefine EVENT__HAVE_ARC4RANDOM_ADDRANDOM 1 -+ - /* Define if clock_gettime is available in libc */ - #cmakedefine EVENT__DNS_USE_CPU_CLOCK_FOR_ID 1 - -diff --git a/include/event2/util.h b/include/event2/util.h -index c4af2bd60..ca4048944 100644 ---- a/include/event2/util.h -+++ b/include/event2/util.h -@@ -842,7 +842,7 @@ int evutil_secure_rng_init(void); - EVENT2_EXPORT_SYMBOL - int evutil_secure_rng_set_urandom_device_file(char *fname); - --#ifdef EVENT__HAVE_ARC4RANDOM_ADDRANDOM -+#if !defined(EVENT__HAVE_ARC4RANDOM) || defined(EVENT__HAVE_ARC4RANDOM_ADDRANDOM) - /** Seed the random number generator with extra random bytes. - - You should almost never need to call this function; it should be diff --git a/depend/zcash/depends/patches/libevent/detect-arch4random_addrandom.patch b/depend/zcash/depends/patches/libevent/detect-arch4random_addrandom.patch deleted file mode 100644 index f8f2b947d..000000000 --- a/depend/zcash/depends/patches/libevent/detect-arch4random_addrandom.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 6541168d7037457b8e5c51cc354f11bd94e618b6 Mon Sep 17 00:00:00 2001 -From: Marek Sebera -Date: Mon, 6 Mar 2017 00:55:16 +0300 -Subject: [PATCH] Detect arch4random_addrandom() existence - -Refs: #370 -Refs: #475 ---- - CMakeLists.txt | 1 + - configure.ac | 1 + - evutil_rand.c | 2 ++ - include/event2/util.h | 2 ++ - 4 files changed, 6 insertions(+) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index a861e7d96..f609d02d0 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -338,6 +338,7 @@ CHECK_FUNCTION_EXISTS_EX(sysctl EVENT__HAVE_SYSCTL) - CHECK_FUNCTION_EXISTS_EX(accept4 EVENT__HAVE_ACCEPT4) - CHECK_FUNCTION_EXISTS_EX(arc4random EVENT__HAVE_ARC4RANDOM) - CHECK_FUNCTION_EXISTS_EX(arc4random_buf EVENT__HAVE_ARC4RANDOM_BUF) -+CHECK_FUNCTION_EXISTS_EX(arc4random_addrandom EVENT__HAVE_ARC4RANDOM_ADDRANDOM) - CHECK_FUNCTION_EXISTS_EX(epoll_create1 EVENT__HAVE_EPOLL_CREATE1) - CHECK_FUNCTION_EXISTS_EX(getegid EVENT__HAVE_GETEGID) - CHECK_FUNCTION_EXISTS_EX(geteuid EVENT__HAVE_GETEUID) -diff --git a/configure.ac b/configure.ac -index a127bbc91..e73c29b14 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -342,6 +342,7 @@ AC_CHECK_FUNCS([ \ - accept4 \ - arc4random \ - arc4random_buf \ -+ arc4random_addrandom \ - eventfd \ - epoll_create1 \ - fcntl \ -diff --git a/evutil_rand.c b/evutil_rand.c -index 046a14b07..4be0b1c5e 100644 ---- a/evutil_rand.c -+++ b/evutil_rand.c -@@ -192,12 +192,14 @@ evutil_secure_rng_get_bytes(void *buf, size_t n) - ev_arc4random_buf(buf, n); - } - -+#if !defined(EVENT__HAVE_ARC4RANDOM) || defined(EVENT__HAVE_ARC4RANDOM_ADDRANDOM) - void - evutil_secure_rng_add_bytes(const char *buf, size_t n) - { - arc4random_addrandom((unsigned char*)buf, - n>(size_t)INT_MAX ? INT_MAX : (int)n); - } -+#endif - - void - evutil_free_secure_rng_globals_(void) -diff --git a/include/event2/util.h b/include/event2/util.h -index dd4bbb69d..c4af2bd60 100644 ---- a/include/event2/util.h -+++ b/include/event2/util.h -@@ -842,6 +842,7 @@ int evutil_secure_rng_init(void); - EVENT2_EXPORT_SYMBOL - int evutil_secure_rng_set_urandom_device_file(char *fname); - -+#ifdef EVENT__HAVE_ARC4RANDOM_ADDRANDOM - /** Seed the random number generator with extra random bytes. - - You should almost never need to call this function; it should be -@@ -858,6 +859,7 @@ int evutil_secure_rng_set_urandom_device_file(char *fname); - */ - EVENT2_EXPORT_SYMBOL - void evutil_secure_rng_add_bytes(const char *dat, size_t datlen); -+#endif - - #ifdef __cplusplus - } diff --git a/depend/zcash/depends/patches/native_cctools/ignore-otool.diff b/depend/zcash/depends/patches/native_cctools/ignore-otool.diff new file mode 100644 index 000000000..fdb348ede --- /dev/null +++ b/depend/zcash/depends/patches/native_cctools/ignore-otool.diff @@ -0,0 +1,24 @@ +diff -ur cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97-orig/cctools/Makefile.am cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/Makefile.am +--- cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97-orig/cctools/Makefile.am 2020-07-30 15:01:05.680000000 +0100 ++++ cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/Makefile.am 2020-07-30 15:01:34.900000000 +0100 +@@ -1,7 +1,7 @@ + if ISDARWIN +-SUBDIRS=libstuff libmacho ar as misc otool efitools ld64 man ++SUBDIRS=libstuff libmacho ar as misc efitools ld64 man + else +-SUBDIRS=libobjc2 libstuff libmacho ar as misc otool efitools ld64 man ++SUBDIRS=libobjc2 libstuff libmacho ar as misc efitools ld64 man + endif + + ACLOCAL_AMFLAGS = -I m4 +diff -ur cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97-orig/cctools/configure.ac cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/configure.ac +--- cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97-orig/cctools/configure.ac 2020-07-30 15:01:05.680000000 +0100 ++++ cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/configure.ac 2020-07-30 15:01:47.330000000 +0100 +@@ -466,7 +466,6 @@ + AC_CONFIG_FILES([as/ppc64/Makefile]) + AC_CONFIG_FILES([man/Makefile]) + AC_CONFIG_FILES([misc/Makefile]) +-AC_CONFIG_FILES([otool/Makefile]) + AC_CONFIG_FILES([efitools/Makefile]) + AC_CONFIG_FILES([libobjc2/Makefile]) + AC_CONFIG_FILES([ld64/Makefile]) diff --git a/depend/zcash/depends/patches/proton/minimal-build.patch b/depend/zcash/depends/patches/proton/minimal-build.patch deleted file mode 100644 index dd138d2f6..000000000 --- a/depend/zcash/depends/patches/proton/minimal-build.patch +++ /dev/null @@ -1,314 +0,0 @@ -diff -ur a/c/CMakeLists.txt b/c/CMakeLists.txt ---- a/c/CMakeLists.txt 2019-12-09 07:17:00.000000000 -0700 -+++ b/c/CMakeLists.txt 2020-01-08 16:15:26.837987469 -0700 -@@ -428,18 +428,18 @@ - # Can't use target_link_libraries() because cmake 2.8.12 doesn't allow object libraries as the first param - # otherwise for cmake 3.9 and on this would be: - # target_link_libraries (qpid-proton-core-objects ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS}) --target_compile_definitions(qpid-proton-core-objects PRIVATE $) --target_compile_options (qpid-proton-core-objects PRIVATE $) --target_include_directories(qpid-proton-core-objects PRIVATE $) -- --add_library (qpid-proton-core SHARED $) --target_link_libraries (qpid-proton-core ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS}) --set_target_properties (qpid-proton-core -- PROPERTIES -- VERSION "${PN_LIB_CORE_VERSION}" -- SOVERSION "${PN_LIB_CORE_MAJOR_VERSION}" -- LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" --) -+#target_compile_definitions(qpid-proton-core-objects PRIVATE $) -+#target_compile_options (qpid-proton-core-objects PRIVATE $) -+#target_include_directories(qpid-proton-core-objects PRIVATE $) -+ -+#add_library (qpid-proton-core SHARED $) -+#target_link_libraries (qpid-proton-core ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS}) -+#set_target_properties (qpid-proton-core -+# PROPERTIES -+# VERSION "${PN_LIB_CORE_VERSION}" -+# SOVERSION "${PN_LIB_CORE_MAJOR_VERSION}" -+# LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" -+#) - - if (BUILD_STATIC_LIBS) - add_library (qpid-proton-core-static STATIC ${qpid-proton-core-src}) -@@ -454,14 +454,14 @@ - ${qpid-proton-include-extra} - ) - --add_library (qpid-proton SHARED $ ${qpid-proton-noncore-src}) --target_link_libraries (qpid-proton LINK_PRIVATE ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS} ${PROACTOR_LIBS}) --set_target_properties (qpid-proton -- PROPERTIES -- VERSION "${PN_LIB_LEGACY_VERSION}" -- SOVERSION "${PN_LIB_LEGACY_MAJOR_VERSION}" -- LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" --) -+# add_library (qpid-proton SHARED $ ${qpid-proton-noncore-src}) -+# target_link_libraries (qpid-proton LINK_PRIVATE ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS} ${PROACTOR_LIBS}) -+# set_target_properties (qpid-proton -+# PROPERTIES -+# VERSION "${PN_LIB_LEGACY_VERSION}" -+# SOVERSION "${PN_LIB_LEGACY_MAJOR_VERSION}" -+# LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" -+# ) - - if (BUILD_STATIC_LIBS) - add_library(qpid-proton-static STATIC ${qpid-proton-core-src} ${qpid-proton-noncore-src}) -@@ -482,15 +482,15 @@ - - if (qpid-proton-proactor) - set(HAS_PROACTOR True) -- add_library (qpid-proton-proactor SHARED ${qpid-proton-proactor}) -- target_link_libraries (qpid-proton-proactor LINK_PUBLIC qpid-proton-core) -- target_link_libraries (qpid-proton-proactor LINK_PRIVATE ${PLATFORM_LIBS} ${PROACTOR_LIBS}) -- set_target_properties (qpid-proton-proactor -- PROPERTIES -- VERSION "${PN_LIB_PROACTOR_VERSION}" -- SOVERSION "${PN_LIB_PROACTOR_MAJOR_VERSION}" -- LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" -- ) -+ # add_library (qpid-proton-proactor SHARED ${qpid-proton-proactor}) -+ # target_link_libraries (qpid-proton-proactor LINK_PUBLIC qpid-proton-core) -+ # target_link_libraries (qpid-proton-proactor LINK_PRIVATE ${PLATFORM_LIBS} ${PROACTOR_LIBS}) -+ # set_target_properties (qpid-proton-proactor -+ # PROPERTIES -+ # VERSION "${PN_LIB_PROACTOR_VERSION}" -+ # SOVERSION "${PN_LIB_PROACTOR_MAJOR_VERSION}" -+ # LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" -+ # ) - if (BUILD_STATIC_LIBS) - add_library (qpid-proton-proactor-static STATIC ${qpid-proton-proactor}) - endif(BUILD_STATIC_LIBS) -@@ -500,11 +500,11 @@ - if (BUILD_STATIC_LIBS) - set(STATIC_LIBS qpid-proton-static qpid-proton-core-static) - endif() --install(TARGETS qpid-proton qpid-proton-core ${STATIC_LIBS} -- EXPORT proton -- RUNTIME DESTINATION bin -- ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -- LIBRARY DESTINATION ${LIB_INSTALL_DIR}) -+# install(TARGETS qpid-proton qpid-proton-core ${STATIC_LIBS} -+# EXPORT proton -+# RUNTIME DESTINATION bin -+# ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -+# LIBRARY DESTINATION ${LIB_INSTALL_DIR}) - - # Install windows pdb files - if (MSVC) -@@ -520,11 +520,11 @@ - if (BUILD_STATIC_LIBS) - set(STATIC_LIBS qpid-proton-proactor-static) - endif() -- install(TARGETS qpid-proton-proactor ${STATIC_LIBS} -- EXPORT proton -- RUNTIME DESTINATION bin -- ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -- LIBRARY DESTINATION ${LIB_INSTALL_DIR}) -+ # install(TARGETS qpid-proton-proactor ${STATIC_LIBS} -+ # EXPORT proton -+ # RUNTIME DESTINATION bin -+ # ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -+ # LIBRARY DESTINATION ${LIB_INSTALL_DIR}) - - # Install windows pdb files - if (MSVC) -@@ -576,10 +576,10 @@ - ${CMAKE_CURRENT_BINARY_DIR}/ProtonConfigVersion.cmake - DESTINATION ${LIB_INSTALL_DIR}/cmake/Proton) - --add_subdirectory(docs) --add_subdirectory(examples) --add_subdirectory(tests) --add_subdirectory(tools) -+# add_subdirectory(docs) -+# add_subdirectory(examples) -+# add_subdirectory(tests) -+# add_subdirectory(tools) - - install (DIRECTORY examples/ - DESTINATION "${PROTON_SHARE}/examples/c" -diff -ur a/CMakeLists.txt b/CMakeLists.txt ---- a/CMakeLists.txt 2019-12-09 07:17:00.000000000 -0700 -+++ b/CMakeLists.txt 2019-12-19 18:11:57.128248724 -0700 -@@ -24,7 +24,7 @@ - set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/tools/cmake/Modules") - set (CMAKE_THREAD_PREFER_PTHREAD TRUE) - --include (CTest) -+# include (CTest) - include (CheckLanguage) - include (CheckLibraryExists) - include (CheckSymbolExists) -@@ -33,13 +33,13 @@ - find_package (OpenSSL) - find_package (Threads) - find_package (PythonInterp REQUIRED) --find_package (SWIG) -+# find_package (SWIG) - find_package (CyrusSASL) - --enable_testing () -+#enable_testing () - - # Set up runtime checks (valgrind, sanitizers etc.) --include(tests/RuntimeCheck.cmake) -+# include(tests/RuntimeCheck.cmake) - - ## Variables used across components - -@@ -260,7 +260,7 @@ - - set (SYSINSTALL_BINDINGS OFF CACHE BOOL "If SYSINSTALL_BINDINGS is OFF then proton bindings will be installed underneath ${BINDINGS_DIR} and each user will need to modify their interpreter configuration to load the appropriate binding. If SYSINSTALL_BINDINGS is ON, then each language interpreter will be queried for the appropriate directory and proton bindings will be installed and available system wide with no additional per user configuration.") - --set (BINDING_LANGS PYTHON RUBY) -+# set (BINDING_LANGS PYTHON RUBY) - - foreach (LANG ${BINDING_LANGS}) - set (SYSINSTALL_${LANG} OFF CACHE BOOL "Install ${LANG} bindings into interpreter specified location.") -@@ -315,7 +315,7 @@ - endif() - - # Prerequisites for Go --find_program(GO_EXE go) -+# find_program(GO_EXE go) - mark_as_advanced(GO_EXE) - if (GO_EXE) - set (DEFAULT_GO ON) -diff -ur a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt ---- a/cpp/CMakeLists.txt 2019-12-09 07:17:00.000000000 -0700 -+++ b/cpp/CMakeLists.txt 2020-01-08 16:20:18.855394195 -0700 -@@ -174,30 +174,30 @@ - set (CMAKE_DEBUG_POSTFIX "d") - endif () - --add_library(qpid-proton-cpp SHARED ${qpid-proton-cpp-source}) -+# add_library(qpid-proton-cpp SHARED ${qpid-proton-cpp-source}) - if(BUILD_STATIC_LIBS) - add_library(qpid-proton-cpp-static STATIC ${qpid-proton-cpp-source}) - set(STATIC_LIBS qpid-proton-cpp-static) - endif(BUILD_STATIC_LIBS) - --target_link_libraries (qpid-proton-cpp LINK_PRIVATE ${PLATFORM_LIBS} qpid-proton-core qpid-proton-proactor ${CONNECT_CONFIG_LIBS}) -+# target_link_libraries (qpid-proton-cpp LINK_PRIVATE ${PLATFORM_LIBS} qpid-proton-core qpid-proton-proactor ${CONNECT_CONFIG_LIBS}) - --set_target_properties ( -- qpid-proton-cpp -- PROPERTIES -- LINKER_LANGUAGE CXX -- VERSION "${PN_LIB_CPP_VERSION}" -- SOVERSION "${PN_LIB_CPP_MAJOR_VERSION}" -- LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" -- ) -+# set_target_properties ( -+# qpid-proton-cpp -+# PROPERTIES -+# LINKER_LANGUAGE CXX -+# VERSION "${PN_LIB_CPP_VERSION}" -+# SOVERSION "${PN_LIB_CPP_MAJOR_VERSION}" -+# LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" -+# ) - - ## Install - --install(TARGETS qpid-proton-cpp ${STATIC_LIBS} -- EXPORT proton-cpp -- RUNTIME DESTINATION bin -- ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -- LIBRARY DESTINATION ${LIB_INSTALL_DIR}) -+# install(TARGETS qpid-proton-cpp ${STATIC_LIBS} -+# EXPORT proton-cpp -+# RUNTIME DESTINATION bin -+# ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -+# LIBRARY DESTINATION ${LIB_INSTALL_DIR}) - - # Install windows qpid-proton-cpp pdb files - if (MSVC) -@@ -209,12 +209,12 @@ - - install (DIRECTORY "include/proton" DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.hpp") - install (FILES "${CMAKE_CURRENT_BINARY_DIR}/config_presets.hpp" DESTINATION "${INCLUDE_INSTALL_DIR}/proton/internal") --install (DIRECTORY "examples/" -- DESTINATION "${PROTON_SHARE}/examples/cpp" -- USE_SOURCE_PERMISSIONS -- PATTERN "ProtonCppConfig.cmake" EXCLUDE) -+# install (DIRECTORY "examples/" -+# DESTINATION "${PROTON_SHARE}/examples/cpp" -+# USE_SOURCE_PERMISSIONS -+# PATTERN "ProtonCppConfig.cmake" EXCLUDE) - --add_subdirectory(examples) -+# add_subdirectory(examples) - add_subdirectory(docs) - - # Pkg config file -@@ -268,40 +268,40 @@ - set(test_env ${test_env} "PATH=$") - endif() - --macro(add_cpp_test test) -- add_executable (${test} src/${test}.cpp) -- target_link_libraries (${test} qpid-proton-cpp ${PLATFORM_LIBS}) -- add_test (NAME cpp-${test} -- COMMAND ${PN_ENV_SCRIPT} -- ${test_env} ${TEST_EXE_PREFIX_CMD} $ ${ARGN}) --endmacro(add_cpp_test) -- --add_cpp_test(codec_test) --add_cpp_test(connection_driver_test) --add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests) --add_cpp_test(message_test) --add_cpp_test(map_test) --add_cpp_test(scalar_test) --add_cpp_test(value_test) --add_cpp_test(container_test) --add_cpp_test(reconnect_test) --add_cpp_test(link_test) --add_cpp_test(credit_test) --if (ENABLE_JSONCPP) -- add_cpp_test(connect_config_test) -- target_link_libraries(connect_config_test qpid-proton-core) # For pn_sasl_enabled -- set_tests_properties(cpp-connect_config_test PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") -- # Test data and output directories for connect_config_test -- file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/testdata" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") --endif() -+# macro(add_cpp_test test) -+# add_executable (${test} src/${test}.cpp) -+# target_link_libraries (${test} qpid-proton-cpp ${PLATFORM_LIBS}) -+# add_test (NAME cpp-${test} -+# COMMAND ${PN_ENV_SCRIPT} -- ${test_env} ${TEST_EXE_PREFIX_CMD} $ ${ARGN}) -+# endmacro(add_cpp_test) -+# -+# add_cpp_test(codec_test) -+# add_cpp_test(connection_driver_test) -+# add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests) -+# add_cpp_test(message_test) -+# add_cpp_test(map_test) -+# add_cpp_test(scalar_test) -+# add_cpp_test(value_test) -+# add_cpp_test(container_test) -+# add_cpp_test(reconnect_test) -+# add_cpp_test(link_test) -+# add_cpp_test(credit_test) -+# if (ENABLE_JSONCPP) -+# add_cpp_test(connect_config_test) -+# target_link_libraries(connect_config_test qpid-proton-core) # For pn_sasl_enabled -+# set_tests_properties(cpp-connect_config_test PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") -+# # Test data and output directories for connect_config_test -+# file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/testdata" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") -+# endif() - - # TODO aconway 2018-10-31: Catch2 tests - # This is a simple example of a C++ test using the Catch2 framework. - # See c/tests/ for more interesting examples. - # Eventually all the C++ tests will migrate to Catch2. - --include_directories(${CMAKE_SOURCE_DIR}/tests/include) --add_executable(cpp-test src/cpp-test.cpp src/url_test.cpp) --target_link_libraries(cpp-test qpid-proton-cpp ${PLATFORM_LIBS}) -+#include_directories(${CMAKE_SOURCE_DIR}/tests/include) -+#add_executable(cpp-test src/cpp-test.cpp src/url_test.cpp) -+#target_link_libraries(cpp-test qpid-proton-cpp ${PLATFORM_LIBS}) - - macro(add_catch_test tag) - add_test ( diff --git a/depend/zcash/depends/patches/zeromq/windows-unused-variables.diff b/depend/zcash/depends/patches/zeromq/windows-unused-variables.diff new file mode 100644 index 000000000..f013bab60 --- /dev/null +++ b/depend/zcash/depends/patches/zeromq/windows-unused-variables.diff @@ -0,0 +1,17 @@ +diff -ur zeromq-4.3.3-orig/src/clock.cpp zeromq-4.3.3/src/clock.cpp +--- zeromq-4.3.3-orig/src/clock.cpp 2020-10-13 13:44:04.190000000 +0100 ++++ zeromq-4.3.3/src/clock.cpp 2020-10-13 13:47:04.170000000 +0100 +@@ -126,9 +126,13 @@ + init_compatible_get_tick_count64 (); + #endif + ++#ifndef ZMQ_HAVE_WINDOWS + const uint64_t usecs_per_msec = 1000; ++#endif + const uint64_t usecs_per_sec = 1000000; ++#ifndef ZMQ_HAVE_WINDOWS + const uint64_t nsecs_per_usec = 1000; ++#endif + + zmq::clock_t::clock_t () : + _last_tsc (rdtsc ()), diff --git a/depend/zcash/doc/amqp.md b/depend/zcash/doc/amqp.md deleted file mode 100644 index a603f354b..000000000 --- a/depend/zcash/doc/amqp.md +++ /dev/null @@ -1,137 +0,0 @@ -# Block and Transaction Broadcasting With AMQP 1.0 (Experimental Feature) - -[AMQP](https://www.amqp.org/) is an enterprise-level message queuing -protocol for the reliable passing of real-time data and business -transactions between applications. AMQP supports both broker and -brokerless messaging. AMQP 1.0 is an open standard and has been -ratified as ISO/IEC 19464. - -The Zcash daemon can be configured to act as a trusted "border -router", implementing the Zcash P2P protocol and relay, making -consensus decisions, maintaining the local blockchain database, -broadcasting locally generated transactions into the network, and -providing a queryable RPC interface to interact on a polled basis for -requesting blockchain related data. However, there exists only a -limited service to notify external software of events like the arrival -of new blocks or transactions. - -The AMQP facility implements a notification interface through a set -of specific notifiers. Currently there are notifiers that publish -blocks and transactions. This read-only facility requires only the -connection of a corresponding AMQP subscriber port in receiving -software. - -Currently the facility is not authenticated nor is there any two-way -protocol involvement. Therefore, subscribers should validate the -received data since it may be out of date, incomplete or even invalid. - -Because AMQP is message oriented, subscribers receive transactions -and blocks all-at-once and do not need to implement any sort of -buffering or reassembly. - -## Prerequisites - -The AMQP feature in Zcash requires [Qpid Proton](https://qpid.apache.org/proton/) -version 0.17 or newer, which you will need to install if you are not -using the depends system. Typically, it is packaged by distributions as -something like *libqpid-proton*. The C++ wrapper for AMQP *is* required. - -In order to run the example Python client scripts in contrib/ one must -also install *python-qpid-proton*, though this is not necessary for -daemon operation. - -## Security WARNING - -Enabling this feature even on the loopback interface only (e.g. binding -it to localhost or 127.0.0.1) will still expose it to the wilds of the -Internet, because of an attack vector called DNS rebinding. DNS -rebinding allows an attacker located remotely on the Internet to trick -applications that you're running on the same computer as Zcashd to -contact your supposedly localhost-only AMQP port, then, depending on the -program they may be able to attempt to attack it. - -Do not enable this feature unless you are sure that you know what you -are doing, and that you have a strong reason for thinking that you are -not vulnerable to this type of attack. - -## Enabling - -By default, the AMQP feature is automatically compiled in if the -necessary prerequisites are found. To disable, use --disable-proton -during the *configure* step of building zcashd: - - $ ./configure --disable-proton (other options) - -To actually enable operation, one must set the appropriate options on -the commandline or in the configuration file. - -## Usage - -AMQP support is currently an experimental feature, so you must pass -the option: - - -experimentalfeatures - -Currently, the following notifications are supported: - - -amqppubhashtx=address - -amqppubhashblock=address - -amqppubrawblock=address - -amqppubrawtx=address - -The address must be a valid AMQP address, where the same address can be -used in more than notification. Note that SSL and SASL addresses are -not currently supported. - -Launch zcashd like this: - - $ zcashd -amqppubhashtx=amqp://127.0.0.1:5672 - -Or this: - - $ zcashd -amqppubhashtx=amqp://127.0.0.1:5672 \ - -amqppubrawtx=amqp://127.0.0.1:5672 \ - -amqppubrawblock=amqp://127.0.0.1:5672 \ - -amqppubhashblock=amqp://127.0.0.1:5672 \ - -debug=amqp - -The debug category `amqp` enables AMQP-related logging. - -Each notification has a topic and body, where the header corresponds -to the notification type. For instance, for the notification `-amqpubhashtx` -the topic is `hashtx` (no null terminator) and the body is the hexadecimal -transaction hash (32 bytes). This transaction hash and the block hash -found in `hashblock` are in RPC byte order. - -These options can also be provided in zcash.conf. - -Please see `contrib/amqp/amqp_sub.py` for a working example of an -AMQP server listening for messages. - -## Remarks - -From the perspective of zcashd, the local end of an AMQP link is write-only. - -No information is broadcast that wasn't already received from the public -P2P network. - -No authentication or authorization is done on peers that zcashd connects -to; it is assumed that the AMQP link is exposed only to trusted entities, -using other means such as firewalling. - -TLS support may be added once OpenSSL has been removed from the Zcash -project and alternative TLS implementations have been evaluated. - -SASL support may be added in a future update for secure communication. - -Note that when the block chain tip changes, a reorganisation may occur -and just the tip will be notified. It is up to the subscriber to -retrieve the chain from the last known block to the new tip. - -At present, zcashd does not try to resend a notification if there was -a problem confirming receipt. Support for delivery guarantees such as -*at-least-once* and *exactly-once* will be added in in a future update. - -Currently, zcashd appends an up-counting sequence number to each notification -which allows listeners to detect lost notifications. - diff --git a/depend/zcash/doc/authors.md b/depend/zcash/doc/authors.md index 28b2a3eaf..5683071d4 100644 --- a/depend/zcash/doc/authors.md +++ b/depend/zcash/doc/authors.md @@ -1,80 +1,87 @@ Zcash Contributors ================== -Jack Grigg (1027) +Jack Grigg (1050) Simon Liu (460) -Sean Bowe (325) -Eirik Ogilvie-Wigley (214) -Daira Hopwood (183) -Taylor Hornby (101) -Marshall Gaucher (99) -Wladimir J. van der Laan (96) +Sean Bowe (361) +Eirik Ogilvie-Wigley (216) +Daira Hopwood (214) +Taylor Hornby (109) +Alfredo Garcia (102) +Marshall Gaucher (100) +Wladimir J. van der Laan (99) Jay Graber (89) Jonas Schnelli (71) -Alfredo Garcia (71) -Pieter Wuille (66) +Kris Nuttycombe (69) +Pieter Wuille (67) Nathan Wilcox (56) -Larry Ruane (43) -Cory Fields (41) +Cory Fields (55) +Larry Ruane (52) +Ying Tong Lai (43) Kevin Gallagher (38) Marco Falke (31) Matt Corallo (25) -Kris Nuttycombe (25) -Dimitris Apostolou (22) +Dimitris Apostolou (23) Jonathan "Duke" Leto (18) +fanquake (16) Luke Dashjr (16) syd (15) avnish (14) +Per Grön (14) Jorge Timón (14) Gregory Maxwell (12) +Ariel Gabizon (12) Paige Peterson (11) -Ariel Gabizon (11) +Benjamin Winston (11) +Carl Dong (10) practicalswift (9) nomnombtc (9) -Benjamin Winston (9) kozyilmaz (8) -fanquake (8) Peter Todd (8) +Charlie O'Keefe (8) Pavel Janík (7) Jeff Garzik (7) -Charlie O'Keefe (7) Marius Kjærstad (6) Karl-Johan Alm (6) David Mercer (6) Daniel Cousens (6) +ying tong (5) ca333 (5) Suhas Daftuar (5) Philip Kaufmann (5) Patrick Strateman (5) Johnathan Corgan (5) +George Tankersley (5) Gavin Andresen (5) Gareth Davies (5) Alex Morcos (5) sandakersmann (4) gladcow (4) +Zancas Wilcox (4) WO (4) João Barbosa (4) Jeremy Rubin (4) James O'Beirne (4) -George Tankersley (4) Daniel Kraft (4) Ben Wilson (4) -zancas (3) lpescher (3) -Per Grön (3) +elbandi (3) Patick Strateman (3) NikVolf (3) MeshCollider (3) Jim Posen (3) Jason Davies (3) +Danny Willems (3) Alfie John (3) rofl0r (2) +noname45688@gmail.com (2) mruddy (2) kpcyrd (2) face (2) aniemerg (2) UdjinM6 (2) Tim Ruffing (2) +Solar Designer (2) Scott (2) Robert C. Seacord (2) Pejvan (2) @@ -89,16 +96,16 @@ ITH4Coinomia (2) Evan Klitzke (2) Dagur Valberg Johannsson (2) Casey Rodarmor (2) -Carl Dong (2) Bryant Eisenbach (2) Brad Miller (2) Bjorn Hjortsberg (2) +Anthony Towns (2) Amgad Abdelhafez (2) Alex Tsankov (2) zathras-crypto (1) unsystemizer (1) tpantin (1) -therealyingtong (1) +teor (1) ptschip (1) murrayn (1) mrbandrews (1) @@ -107,6 +114,7 @@ jeff-liang (1) jc (1) isle2983 (1) instagibbs (1) +ewillbefull@gmail.com (1) emilrus (1) dexX7 (1) daniel (1) @@ -124,6 +132,7 @@ Thomas Snider (1) Stephen (1) S. Matthew English (1) Ross Nicoll (1) +Rod Vagg (1) Richard Littauer (1) René Nyffenegger (1) R E Broadley (1) @@ -141,6 +150,7 @@ Maxwell Gubler (1) Matt Quinn (1) Mark Friedenbach (1) Louis Nyffenegger (1) +LongShao007 (1) LitecoinZ (1) Leo Arias (1) Lauda (1) @@ -172,7 +182,7 @@ Bob McElrath (1) Bitcoin Error Log (1) Ben Woosley (1) Ashley Holman (1) -Anthony Towns (1) +Andrew Chow (1) Allan Niemerg (1) Alex van der Peet (1) Alex (1) diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.10.0.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.10.0.md deleted file mode 100644 index 986b8832e..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.10.0.md +++ /dev/null @@ -1,762 +0,0 @@ -Bitcoin Core version 0.10.0 is now available from: - - https://bitcoin.org/bin/0.10.0/ - -This is a new major version release, bringing both new features and -bug fixes. - -Please report bugs using the issue tracker at github: - - https://github.com/bitcoin/bitcoin/issues - -Upgrading and downgrading -========================= - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), then run the -installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or -bitcoind/bitcoin-qt (on Linux). - -Downgrading warning ---------------------- - -Because release 0.10.0 makes use of headers-first synchronization and parallel -block download (see further), the block files and databases are not -backwards-compatible with older versions of Bitcoin Core or other software: - -* Blocks will be stored on disk out of order (in the order they are -received, really), which makes it incompatible with some tools or -other programs. Reindexing using earlier versions will also not work -anymore as a result of this. - -* The block index database will now hold headers for which no block is -stored on disk, which earlier versions won't support. - -If you want to be able to downgrade smoothly, make a backup of your entire data -directory. Without this your node will need start syncing (or importing from -bootstrap.dat) anew afterwards. It is possible that the data from a completely -synchronised 0.10 node may be usable in older versions as-is, but this is not -supported and may break as soon as the older version attempts to reindex. - -This does not affect wallet forward or backward compatibility. - - -Notable changes -=============== - -Faster synchronization ----------------------- - -Bitcoin Core now uses 'headers-first synchronization'. This means that we first -ask peers for block headers (a total of 27 megabytes, as of December 2014) and -validate those. In a second stage, when the headers have been discovered, we -download the blocks. However, as we already know about the whole chain in -advance, the blocks can be downloaded in parallel from all available peers. - -In practice, this means a much faster and more robust synchronization. On -recent hardware with a decent network link, it can be as little as 3 hours -for an initial full synchronization. You may notice a slower progress in the -very first few minutes, when headers are still being fetched and verified, but -it should gain speed afterwards. - -A few RPCs were added/updated as a result of this: -- `getblockchaininfo` now returns the number of validated headers in addition to -the number of validated blocks. -- `getpeerinfo` lists both the number of blocks and headers we know we have in -common with each peer. While synchronizing, the heights of the blocks that we -have requested from peers (but haven't received yet) are also listed as -'inflight'. -- A new RPC `getchaintips` lists all known branches of the block chain, -including those we only have headers for. - -Transaction fee changes ------------------------ - -This release automatically estimates how high a transaction fee (or how -high a priority) transactions require to be confirmed quickly. The default -settings will create transactions that confirm quickly; see the new -'txconfirmtarget' setting to control the tradeoff between fees and -confirmation times. Fees are added by default unless the 'sendfreetransactions' -setting is enabled. - -Prior releases used hard-coded fees (and priorities), and would -sometimes create transactions that took a very long time to confirm. - -Statistics used to estimate fees and priorities are saved in the -data directory in the `fee_estimates.dat` file just before -program shutdown, and are read in at startup. - -New command line options for transaction fee changes: -- `-txconfirmtarget=n` : create transactions that have enough fees (or priority) -so they are likely to begin confirmation within n blocks (default: 1). This setting -is over-ridden by the -paytxfee option. -- `-sendfreetransactions` : Send transactions as zero-fee transactions if possible -(default: 0) - -New RPC commands for fee estimation: -- `estimatefee nblocks` : Returns approximate fee-per-1,000-bytes needed for -a transaction to begin confirmation within nblocks. Returns -1 if not enough -transactions have been observed to compute a good estimate. -- `estimatepriority nblocks` : Returns approximate priority needed for -a zero-fee transaction to begin confirmation within nblocks. Returns -1 if not -enough free transactions have been observed to compute a good -estimate. - -RPC access control changes --------------------------- - -Subnet matching for the purpose of access control is now done -by matching the binary network address, instead of with string wildcard matching. -For the user this means that `-rpcallowip` takes a subnet specification, which can be - -- a single IP address (e.g. `1.2.3.4` or `fe80::0012:3456:789a:bcde`) -- a network/CIDR (e.g. `1.2.3.0/24` or `fe80::0000/64`) -- a network/netmask (e.g. `1.2.3.4/255.255.255.0` or `fe80::0012:3456:789a:bcde/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff`) - -An arbitrary number of `-rpcallow` arguments can be given. An incoming connection will be accepted if its origin address -matches one of them. - -For example: - -| 0.9.x and before | 0.10.x | -|--------------------------------------------|---------------------------------------| -| `-rpcallowip=192.168.1.1` | `-rpcallowip=192.168.1.1` (unchanged) | -| `-rpcallowip=192.168.1.*` | `-rpcallowip=192.168.1.0/24` | -| `-rpcallowip=192.168.*` | `-rpcallowip=192.168.0.0/16` | -| `-rpcallowip=*` (dangerous!) | `-rpcallowip=::/0` (still dangerous!) | - -Using wildcards will result in the rule being rejected with the following error in debug.log: - - Error: Invalid -rpcallowip subnet specification: *. Valid are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). - - -REST interface --------------- - -A new HTTP API is exposed when running with the `-rest` flag, which allows -unauthenticated access to public node data. - -It is served on the same port as RPC, but does not need a password, and uses -plain HTTP instead of JSON-RPC. - -Assuming a local RPC server running on port 8332, it is possible to request: -- Blocks: http://localhost:8332/rest/block/*HASH*.*EXT* -- Blocks without transactions: http://localhost:8332/rest/block/notxdetails/*HASH*.*EXT* -- Transactions (requires `-txindex`): http://localhost:8332/rest/tx/*HASH*.*EXT* - -In every case, *EXT* can be `bin` (for raw binary data), `hex` (for hex-encoded -binary) or `json`. - -For more details, see the `doc/REST-interface.md` document in the repository. - -RPC Server "Warm-Up" Mode -------------------------- - -The RPC server is started earlier now, before most of the expensive -intialisations like loading the block index. It is available now almost -immediately after starting the process. However, until all initialisations -are done, it always returns an immediate error with code -28 to all calls. - -This new behaviour can be useful for clients to know that a server is already -started and will be available soon (for instance, so that they do not -have to start it themselves). - -Improved signing security -------------------------- - -For 0.10 the security of signing against unusual attacks has been -improved by making the signatures constant time and deterministic. - -This change is a result of switching signing to use libsecp256k1 -instead of OpenSSL. Libsecp256k1 is a cryptographic library -optimized for the curve Bitcoin uses which was created by Bitcoin -Core developer Pieter Wuille. - -There exist attacks[1] against most ECC implementations where an -attacker on shared virtual machine hardware could extract a private -key if they could cause a target to sign using the same key hundreds -of times. While using shared hosts and reusing keys are inadvisable -for other reasons, it's a better practice to avoid the exposure. - -OpenSSL has code in their source repository for derandomization -and reduction in timing leaks that we've eagerly wanted to use for a -long time, but this functionality has still not made its -way into a released version of OpenSSL. Libsecp256k1 achieves -significantly stronger protection: As far as we're aware this is -the only deployed implementation of constant time signing for -the curve Bitcoin uses and we have reason to believe that -libsecp256k1 is better tested and more thoroughly reviewed -than the implementation in OpenSSL. - -[1] https://eprint.iacr.org/2014/161.pdf - -Watch-only wallet support -------------------------- - -The wallet can now track transactions to and from wallets for which you know -all addresses (or scripts), even without the private keys. - -This can be used to track payments without needing the private keys online on a -possibly vulnerable system. In addition, it can help for (manual) construction -of multisig transactions where you are only one of the signers. - -One new RPC, `importaddress`, is added which functions similarly to -`importprivkey`, but instead takes an address or script (in hexadecimal) as -argument. After using it, outputs credited to this address or script are -considered to be received, and transactions consuming these outputs will be -considered to be sent. - -The following RPCs have optional support for watch-only: -`getbalance`, `listreceivedbyaddress`, `listreceivedbyaccount`, -`listtransactions`, `listaccounts`, `listsinceblock`, `gettransaction`. See the -RPC documentation for those methods for more information. - -Compared to using `getrawtransaction`, this mechanism does not require -`-txindex`, scales better, integrates better with the wallet, and is compatible -with future block chain pruning functionality. It does mean that all relevant -addresses need to added to the wallet before the payment, though. - -Consensus library ------------------ - -Starting from 0.10.0, the Bitcoin Core distribution includes a consensus library. - -The purpose of this library is to make the verification functionality that is -critical to Bitcoin's consensus available to other applications, e.g. to language -bindings such as [python-bitcoinlib](https://pypi.python.org/pypi/python-bitcoinlib) or -alternative node implementations. - -This library is called `libbitcoinconsensus.so` (or, `.dll` for Windows). -Its interface is defined in the C header [bitcoinconsensus.h](https://github.com/bitcoin/bitcoin/blob/0.10/src/script/bitcoinconsensus.h). - -In its initial version the API includes two functions: - -- `bitcoinconsensus_verify_script` verifies a script. It returns whether the indicated input of the provided serialized transaction -correctly spends the passed scriptPubKey under additional constraints indicated by flags -- `bitcoinconsensus_version` returns the API version, currently at an experimental `0` - -The functionality is planned to be extended to e.g. UTXO management in upcoming releases, but the interface -for existing methods should remain stable. - -Standard script rules relaxed for P2SH addresses ------------------------------------------------- - -The IsStandard() rules have been almost completely removed for P2SH -redemption scripts, allowing applications to make use of any valid -script type, such as "n-of-m OR y", hash-locked oracle addresses, etc. -While the Bitcoin protocol has always supported these types of script, -actually using them on mainnet has been previously inconvenient as -standard Bitcoin Core nodes wouldn't relay them to miners, nor would -most miners include them in blocks they mined. - -bitcoin-tx ----------- - -It has been observed that many of the RPC functions offered by bitcoind are -"pure functions", and operate independently of the bitcoind wallet. This -included many of the RPC "raw transaction" API functions, such as -createrawtransaction. - -bitcoin-tx is a newly introduced command line utility designed to enable easy -manipulation of bitcoin transactions. A summary of its operation may be -obtained via "bitcoin-tx --help" Transactions may be created or signed in a -manner similar to the RPC raw tx API. Transactions may be updated, deleting -inputs or outputs, or appending new inputs and outputs. Custom scripts may be -easily composed using a simple text notation, borrowed from the bitcoin test -suite. - -This tool may be used for experimenting with new transaction types, signing -multi-party transactions, and many other uses. Long term, the goal is to -deprecate and remove "pure function" RPC API calls, as those do not require a -server round-trip to execute. - -Other utilities "bitcoin-key" and "bitcoin-script" have been proposed, making -key and script operations easily accessible via command line. - -Mining and relay policy enhancements ------------------------------------- - -Bitcoin Core's block templates are now for version 3 blocks only, and any mining -software relying on its `getblocktemplate` must be updated in parallel to use -libblkmaker either version 0.4.2 or any version from 0.5.1 onward. -If you are solo mining, this will affect you the moment you upgrade Bitcoin -Core, which must be done prior to BIP66 achieving its 951/1001 status. -If you are mining with the stratum mining protocol: this does not affect you. -If you are mining with the getblocktemplate protocol to a pool: this will affect -you at the pool operator's discretion, which must be no later than BIP66 -achieving its 951/1001 status. - -The `prioritisetransaction` RPC method has been added to enable miners to -manipulate the priority of transactions on an individual basis. - -Bitcoin Core now supports BIP 22 long polling, so mining software can be -notified immediately of new templates rather than having to poll periodically. - -Support for BIP 23 block proposals is now available in Bitcoin Core's -`getblocktemplate` method. This enables miners to check the basic validity of -their next block before expending work on it, reducing risks of accidental -hardforks or mining invalid blocks. - -Two new options to control mining policy: -- `-datacarrier=0/1` : Relay and mine "data carrier" (OP_RETURN) transactions -if this is 1. -- `-datacarriersize=n` : Maximum size, in bytes, we consider acceptable for -"data carrier" outputs. - -The relay policy has changed to more properly implement the desired behavior of not -relaying free (or very low fee) transactions unless they have a priority above the -AllowFreeThreshold(), in which case they are relayed subject to the rate limiter. - -BIP 66: strict DER encoding for signatures ------------------------------------------- - -Bitcoin Core 0.10 implements BIP 66, which introduces block version 3, and a new -consensus rule, which prohibits non-DER signatures. Such transactions have been -non-standard since Bitcoin v0.8.0 (released in February 2013), but were -technically still permitted inside blocks. - -This change breaks the dependency on OpenSSL's signature parsing, and is -required if implementations would want to remove all of OpenSSL from the -consensus code. - -The same miner-voting mechanism as in BIP 34 is used: when 751 out of a -sequence of 1001 blocks have version number 3 or higher, the new consensus -rule becomes active for those blocks. When 951 out of a sequence of 1001 -blocks have version number 3 or higher, it becomes mandatory for all blocks. - -Backward compatibility with current mining software is NOT provided, thus miners -should read the first paragraph of "Mining and relay policy enhancements" above. - -0.10.0 Change log -================= - -Detailed release notes follow. This overview includes changes that affect external -behavior, not code moves, refactors or string updates. - -RPC: -- `f923c07` Support IPv6 lookup in bitcoin-cli even when IPv6 only bound on localhost -- `b641c9c` Fix addnode "onetry": Connect with OpenNetworkConnection -- `171ca77` estimatefee / estimatepriority RPC methods -- `b750cf1` Remove cli functionality from bitcoind -- `f6984e8` Add "chain" to getmininginfo, improve help in getblockchaininfo -- `99ddc6c` Add nLocalServices info to RPC getinfo -- `cf0c47b` Remove getwork() RPC call -- `2a72d45` prioritisetransaction -- `e44fea5` Add an option `-datacarrier` to allow users to disable relaying/mining data carrier transactions -- `2ec5a3d` Prevent easy RPC memory exhaustion attack -- `d4640d7` Added argument to getbalance to include watchonly addresses and fixed errors in balance calculation -- `83f3543` Added argument to listaccounts to include watchonly addresses -- `952877e` Showing 'involvesWatchonly' property for transactions returned by 'listtransactions' and 'listsinceblock'. It is only appended when the transaction involves a watchonly address -- `d7d5d23` Added argument to listtransactions and listsinceblock to include watchonly addresses -- `f87ba3d` added includeWatchonly argument to 'gettransaction' because it affects balance calculation -- `0fa2f88` added includedWatchonly argument to listreceivedbyaddress/...account -- `6c37f7f` `getrawchangeaddress`: fail when keypool exhausted and wallet locked -- `ff6a7af` getblocktemplate: longpolling support -- `c4a321f` Add peerid to getpeerinfo to allow correlation with the logs -- `1b4568c` Add vout to ListTransactions output -- `b33bd7a` Implement "getchaintips" RPC command to monitor blockchain forks -- `733177e` Remove size limit in RPC client, keep it in server -- `6b5b7cb` Categorize rpc help overview -- `6f2c26a` Closely track mempool byte total. Add "getmempoolinfo" RPC -- `aa82795` Add detailed network info to getnetworkinfo RPC -- `01094bd` Don't reveal whether password is <20 or >20 characters in RPC -- `57153d4` rpc: Compute number of confirmations of a block from block height -- `ff36cbe` getnetworkinfo: export local node's client sub-version string -- `d14d7de` SanitizeString: allow '(' and ')' -- `31d6390` Fixed setaccount accepting foreign address -- `b5ec5fe` update getnetworkinfo help with subversion -- `ad6e601` RPC additions after headers-first -- `33dfbf5` rpc: Fix leveldb iterator leak, and flush before `gettxoutsetinfo` -- `2aa6329` Enable customising node policy for datacarrier data size with a -datacarriersize option -- `f877aaa` submitblock: Use a temporary CValidationState to determine accurately the outcome of ProcessBlock -- `e69a587` submitblock: Support for returning specific rejection reasons -- `af82884` Add "warmup mode" for RPC server -- `e2655e0` Add unauthenticated HTTP REST interface to public blockchain data -- `683dc40` Disable SSLv3 (in favor of TLS) for the RPC client and server -- `44b4c0d` signrawtransaction: validate private key -- `9765a50` Implement BIP 23 Block Proposal -- `f9de17e` Add warning comment to getinfo - -Command-line options: -- `ee21912` Use netmasks instead of wildcards for IP address matching -- `deb3572` Add `-rpcbind` option to allow binding RPC port on a specific interface -- `96b733e` Add `-version` option to get just the version -- `1569353` Add `-stopafterblockimport` option -- `77cbd46` Let -zapwallettxes recover transaction meta data -- `1c750db` remove -tor compatibility code (only allow -onion) -- `4aaa017` rework help messages for fee-related options -- `4278b1d` Clarify error message when invalid -rpcallowip -- `6b407e4` -datadir is now allowed in config files -- `bdd5b58` Add option `-sysperms` to disable 077 umask (create new files with system default umask) -- `cbe39a3` Add "bitcoin-tx" command line utility and supporting modules -- `dbca89b` Trigger -alertnotify if network is upgrading without you -- `ad96e7c` Make -reindex cope with out-of-order blocks -- `16d5194` Skip reindexed blocks individually -- `ec01243` --tracerpc option for regression tests -- `f654f00` Change -genproclimit default to 1 -- `3c77714` Make -proxy set all network types, avoiding a connect leak -- `57be955` Remove -printblock, -printblocktree, and -printblockindex -- `ad3d208` remove -maxorphanblocks config parameter since it is no longer functional - -Block and transaction handling: -- `7a0e84d` ProcessGetData(): abort if a block file is missing from disk -- `8c93bf4` LoadBlockIndexDB(): Require block db reindex if any `blk*.dat` files are missing -- `77339e5` Get rid of the static chainMostWork (optimization) -- `4e0eed8` Allow ActivateBestChain to release its lock on cs_main -- `18e7216` Push cs_mains down in ProcessBlock -- `fa126ef` Avoid undefined behavior using CFlatData in CScript serialization -- `7f3b4e9` Relax IsStandard rules for pay-to-script-hash transactions -- `c9a0918` Add a skiplist to the CBlockIndex structure -- `bc42503` Use unordered_map for CCoinsViewCache with salted hash (optimization) -- `d4d3fbd` Do not flush the cache after every block outside of IBD (optimization) -- `ad08d0b` Bugfix: make CCoinsViewMemPool support pruned entries in underlying cache -- `5734d4d` Only remove actualy failed blocks from setBlockIndexValid -- `d70bc52` Rework block processing benchmark code -- `714a3e6` Only keep setBlockIndexValid entries that are possible improvements -- `ea100c7` Reduce maximum coinscache size during verification (reduce memory usage) -- `4fad8e6` Reject transactions with excessive numbers of sigops -- `b0875eb` Allow BatchWrite to destroy its input, reducing copying (optimization) -- `92bb6f2` Bypass reloading blocks from disk (optimization) -- `2e28031` Perform CVerifyDB on pcoinsdbview instead of pcoinsTip (reduce memory usage) -- `ab15b2e` Avoid copying undo data (optimization) -- `341735e` Headers-first synchronization -- `afc32c5` Fix rebuild-chainstate feature and improve its performance -- `e11b2ce` Fix large reorgs -- `ed6d1a2` Keep information about all block files in memory -- `a48f2d6` Abstract context-dependent block checking from acceptance -- `7e615f5` Fixed mempool sync after sending a transaction -- `51ce901` Improve chainstate/blockindex disk writing policy -- `a206950` Introduce separate flushing modes -- `9ec75c5` Add a locking mechanism to IsInitialBlockDownload to ensure it never goes from false to true -- `868d041` Remove coinbase-dependant transactions during reorg -- `723d12c` Remove txn which are invalidated by coinbase maturity during reorg -- `0cb8763` Check against MANDATORY flags prior to accepting to mempool -- `8446262` Reject headers that build on an invalid parent -- `008138c` Bugfix: only track UTXO modification after lookup - -P2P protocol and network code: -- `f80cffa` Do not trigger a DoS ban if SCRIPT_VERIFY_NULLDUMMY fails -- `c30329a` Add testnet DNS seed of Alex Kotenko -- `45a4baf` Add testnet DNS seed of Andreas Schildbach -- `f1920e8` Ping automatically every 2 minutes (unconditionally) -- `806fd19` Allocate receive buffers in on the fly -- `6ecf3ed` Display unknown commands received -- `aa81564` Track peers' available blocks -- `caf6150` Use async name resolving to improve net thread responsiveness -- `9f4da19` Use pong receive time rather than processing time -- `0127a9b` remove SOCKS4 support from core and GUI, use SOCKS5 -- `40f5cb8` Send rejects and apply DoS scoring for errors in direct block validation -- `dc942e6` Introduce whitelisted peers -- `c994d2e` prevent SOCKET leak in BindListenPort() -- `a60120e` Add built-in seeds for .onion -- `60dc8e4` Allow -onlynet=onion to be used -- `3a56de7` addrman: Do not propagate obviously poor addresses onto the network -- `6050ab6` netbase: Make SOCKS5 negotiation interruptible -- `604ee2a` Remove tx from AlreadyAskedFor list once we receive it, not when we process it -- `efad808` Avoid reject message feedback loops -- `71697f9` Separate protocol versioning from clientversion -- `20a5f61` Don't relay alerts to peers before version negotiation -- `b4ee0bd` Introduce preferred download peers -- `845c86d` Do not use third party services for IP detection -- `12a49ca` Limit the number of new addressses to accumulate -- `35e408f` Regard connection failures as attempt for addrman -- `a3a7317` Introduce 10 minute block download timeout -- `3022e7d` Require sufficent priority for relay of free transactions -- `58fda4d` Update seed IPs, based on bitcoin.sipa.be crawler data -- `18021d0` Remove bitnodes.io from dnsseeds. - -Validation: -- `6fd7ef2` Also switch the (unused) verification code to low-s instead of even-s -- `584a358` Do merkle root and txid duplicates check simultaneously -- `217a5c9` When transaction outputs exceed inputs, show the offending amounts so as to aid debugging -- `f74fc9b` Print input index when signature validation fails, to aid debugging -- `6fd59ee` script.h: set_vch() should shift a >32 bit value -- `d752ba8` Add SCRIPT_VERIFY_SIGPUSHONLY (BIP62 rule 2) (test only) -- `698c6ab` Add SCRIPT_VERIFY_MINIMALDATA (BIP62 rules 3 and 4) (test only) -- `ab9edbd` script: create sane error return codes for script validation and remove logging -- `219a147` script: check ScriptError values in script tests -- `0391423` Discourage NOPs reserved for soft-fork upgrades -- `98b135f` Make STRICTENC invalid pubkeys fail the script rather than the opcode -- `307f7d4` Report script evaluation failures in log and reject messages -- `ace39db` consensus: guard against openssl's new strict DER checks -- `12b7c44` Improve robustness of DER recoding code -- `76ce5c8` fail immediately on an empty signature - -Build system: -- `f25e3ad` Fix build in OS X 10.9 -- `65e8ba4` build: Switch to non-recursive make -- `460b32d` build: fix broken boost chrono check on some platforms -- `9ce0774` build: Fix windows configure when using --with-qt-libdir -- `ea96475` build: Add mention of --disable-wallet to bdb48 error messages -- `1dec09b` depends: add shared dependency builder -- `c101c76` build: Add --with-utils (bitcoin-cli and bitcoin-tx, default=yes). Help string consistency tweaks. Target sanity check fix -- `e432a5f` build: add option for reducing exports (v2) -- `6134b43` Fixing condition 'sabotaging' MSVC build -- `af0bd5e` osx: fix signing to make Gatekeeper happy (again) -- `a7d1f03` build: fix dynamic boost check when --with-boost= is used -- `d5fd094` build: fix qt test build when libprotobuf is in a non-standard path -- `2cf5f16` Add libbitcoinconsensus library -- `914868a` build: add a deterministic dmg signer -- `2d375fe` depends: bump openssl to 1.0.1k -- `b7a4ecc` Build: Only check for boost when building code that requires it - -Wallet: -- `b33d1f5` Use fee/priority estimates in wallet CreateTransaction -- `4b7b1bb` Sanity checks for estimates -- `c898846` Add support for watch-only addresses -- `d5087d1` Use script matching rather than destination matching for watch-only -- `d88af56` Fee fixes -- `a35b55b` Dont run full check every time we decrypt wallet -- `3a7c348` Fix make_change to not create half-satoshis -- `f606bb9` fix a possible memory leak in CWalletDB::Recover -- `870da77` fix possible memory leaks in CWallet::EncryptWallet -- `ccca27a` Watch-only fixes -- `9b1627d` [Wallet] Reduce minTxFee for transaction creation to 1000 satoshis -- `a53fd41` Deterministic signing -- `15ad0b5` Apply AreSane() checks to the fees from the network -- `11855c1` Enforce minRelayTxFee on wallet created tx and add a maxtxfee option - -GUI: -- `c21c74b` osx: Fix missing dock menu with qt5 -- `b90711c` Fix Transaction details shows wrong To: -- `516053c` Make links in 'About Bitcoin Core' clickable -- `bdc83e8` Ensure payment request network matches client network -- `65f78a1` Add GUI view of peer information -- `06a91d9` VerifyDB progress reporting -- `fe6bff2` Add BerkeleyDB version info to RPCConsole -- `b917555` PeerTableModel: Fix potential deadlock. #4296 -- `dff0e3b` Improve rpc console history behavior -- `95a9383` Remove CENT-fee-rule from coin control completely -- `56b07d2` Allow setting listen via GUI -- `d95ba75` Log messages with type>QtDebugMsg as non-debug -- `8969828` New status bar Unit Display Control and related changes -- `674c070` seed OpenSSL PNRG with Windows event data -- `509f926` Payment request parsing on startup now only changes network if a valid network name is specified -- `acd432b` Prevent balloon-spam after rescan -- `7007402` Implement SI-style (thin space) thoudands separator -- `91cce17` Use fixed-point arithmetic in amount spinbox -- `bdba2dd` Remove an obscure option no-one cares about -- `bd0aa10` Replace the temporary file hack currently used to change Bitcoin-Qt's dock icon (OS X) with a buffer-based solution -- `94e1b9e` Re-work overviewpage UI -- `8bfdc9a` Better looking trayicon -- `b197bf3` disable tray interactions when client model set to 0 -- `1c5f0af` Add column Watch-only to transactions list -- `21f139b` Fix tablet crash. closes #4854 -- `e84843c` Broken addresses on command line no longer trigger testnet -- `a49f11d` Change splash screen to normal window -- `1f9be98` Disable App Nap on OSX 10.9+ -- `27c3e91` Add proxy to options overridden if necessary -- `4bd1185` Allow "emergency" shutdown during startup -- `d52f072` Don't show wallet options in the preferences menu when running with -disablewallet -- `6093aa1` Qt: QProgressBar CPU-Issue workaround -- `0ed9675` [Wallet] Add global boolean whether to send free transactions (default=true) -- `ed3e5e4` [Wallet] Add global boolean whether to pay at least the custom fee (default=true) -- `e7876b2` [Wallet] Prevent user from paying a non-sense fee -- `c1c9d5b` Add Smartfee to GUI -- `e0a25c5` Make askpassphrase dialog behave more sanely -- `94b362d` On close of splashscreen interrupt verifyDB -- `b790d13` English translation update -- `8543b0d` Correct tooltip on address book page - -Tests: -- `b41e594` Fix script test handling of empty scripts -- `d3a33fc` Test CHECKMULTISIG with m == 0 and n == 0 -- `29c1749` Let tx (in)valid tests use any SCRIPT_VERIFY flag -- `6380180` Add rejection of non-null CHECKMULTISIG dummy values -- `21bf3d2` Add tests for BoostAsioToCNetAddr -- `b5ad5e7` Add Python test for -rpcbind and -rpcallowip -- `9ec0306` Add CODESEPARATOR/FindAndDelete() tests -- `75ebced` Added many rpc wallet tests -- `0193fb8` Allow multiple regression tests to run at once -- `92a6220` Hook up sanity checks -- `3820e01` Extend and move all crypto tests to crypto_tests.cpp -- `3f9a019` added list/get received by address/ account tests -- `a90689f` Remove timing-based signature cache unit test -- `236982c` Add skiplist unit tests -- `f4b00be` Add CChain::GetLocator() unit test -- `b45a6e8` Add test for getblocktemplate longpolling -- `cdf305e` Set -discover=0 in regtest framework -- `ed02282` additional test for OP_SIZE in script_valid.json -- `0072d98` script tests: BOOLAND, BOOLOR decode to integer -- `833ff16` script tests: values that overflow to 0 are true -- `4cac5db` script tests: value with trailing 0x00 is true -- `89101c6` script test: test case for 5-byte bools -- `d2d9dc0` script tests: add tests for CHECKMULTISIG limits -- `d789386` Add "it works" test for bitcoin-tx -- `df4d61e` Add bitcoin-tx tests -- `aa41ac2` Test IsPushOnly() with invalid push -- `6022b5d` Make `script_{valid,invalid}.json` validation flags configurable -- `8138cbe` Add automatic script test generation, and actual checksig tests -- `ed27e53` Add coins_tests with a large randomized CCoinViewCache test -- `9df9cf5` Make SCRIPT_VERIFY_STRICTENC compatible with BIP62 -- `dcb9846` Extend getchaintips RPC test -- `554147a` Ensure MINIMALDATA invalid tests can only fail one way -- `dfeec18` Test every numeric-accepting opcode for correct handling of the numeric minimal encoding rule -- `2b62e17` Clearly separate PUSHDATA and numeric argument MINIMALDATA tests -- `16d78bd` Add valid invert of invalid every numeric opcode tests -- `f635269` tests: enable alertnotify test for Windows -- `7a41614` tests: allow rpc-tests to get filenames for bitcoind and bitcoin-cli from the environment -- `5122ea7` tests: fix forknotify.py on windows -- `fa7f8cd` tests: remove old pull-tester scripts -- `7667850` tests: replace the old (unused since Travis) tests with new rpc test scripts -- `f4e0aef` Do signature-s negation inside the tests -- `1837987` Optimize -regtest setgenerate block generation -- `2db4c8a` Fix node ranges in the test framework -- `a8b2ce5` regression test only setmocktime RPC call -- `daf03e7` RPC tests: create initial chain with specific timestamps -- `8656dbb` Port/fix txnmall.sh regression test -- `ca81587` Test the exact order of CHECKMULTISIG sig/pubkey evaluation -- `7357893` Prioritize and display -testsafemode status in UI -- `f321d6b` Add key generation/verification to ECC sanity check -- `132ea9b` miner_tests: Disable checkpoints so they don't fail the subsidy-change test -- `bc6cb41` QA RPC tests: Add tests block block proposals -- `f67a9ce` Use deterministically generated script tests -- `11d7a7d` [RPC] add rpc-test for http keep-alive (persistent connections) -- `34318d7` RPC-test based on invalidateblock for mempool coinbase spends -- `76ec867` Use actually valid transactions for script tests -- `c8589bf` Add actual signature tests -- `e2677d7` Fix smartfees test for change to relay policy -- `263b65e` tests: run sanity checks in tests too - -Miscellaneous: -- `122549f` Fix incorrect checkpoint data for testnet3 -- `5bd02cf` Log used config file to debug.log on startup -- `68ba85f` Updated Debian example bitcoin.conf with config from wiki + removed some cruft and updated comments -- `e5ee8f0` Remove -beta suffix -- `38405ac` Add comment regarding experimental-use service bits -- `be873f6` Issue warning if collecting RandSeed data failed -- `8ae973c` Allocate more space if necessary in RandSeedAddPerfMon -- `675bcd5` Correct comment for 15-of-15 p2sh script size -- `fda3fed` libsecp256k1 integration -- `2e36866` Show nodeid instead of addresses in log (for anonymity) unless otherwise requested -- `cd01a5e` Enable paranoid corruption checks in LevelDB >= 1.16 -- `9365937` Add comment about never updating nTimeOffset past 199 samples -- `403c1bf` contrib: remove getwork-based pyminer (as getwork API call has been removed) -- `0c3e101` contrib: Added systemd .service file in order to help distributions integrate bitcoind -- `0a0878d` doc: Add new DNSseed policy -- `2887bff` Update coding style and add .clang-format -- `5cbda4f` Changed LevelDB cursors to use scoped pointers to ensure destruction when going out of scope -- `b4a72a7` contrib/linearize: split output files based on new-timestamp-year or max-file-size -- `e982b57` Use explicit fflush() instead of setvbuf() -- `234bfbf` contrib: Add init scripts and docs for Upstart and OpenRC -- `01c2807` Add warning about the merkle-tree algorithm duplicate txid flaw -- `d6712db` Also create pid file in non-daemon mode -- `772ab0e` contrib: use batched JSON-RPC in linarize-hashes (optimization) -- `7ab4358` Update bash-completion for v0.10 -- `6e6a36c` contrib: show pull # in prompt for github-merge script -- `5b9f842` Upgrade leveldb to 1.18, make chainstate databases compatible between ARM and x86 (issue #2293) -- `4e7c219` Catch UTXO set read errors and shutdown -- `867c600` Catch LevelDB errors during flush -- `06ca065` Fix CScriptID(const CScript& in) in empty script case - -Credits -======= - -Thanks to everyone who contributed to this release: - -- 21E14 -- Adam Weiss -- Aitor Pazos -- Alexander Jeng -- Alex Morcos -- Alon Muroch -- Andreas Schildbach -- Andrew Poelstra -- Andy Alness -- Ashley Holman -- Benedict Chan -- Ben Holden-Crowther -- Bryan Bishop -- BtcDrak -- Christian von Roques -- Clinton Christian -- Cory Fields -- Cozz Lovan -- daniel -- Daniel Kraft -- David Hill -- Derek701 -- dexX7 -- dllud -- Dominyk Tiller -- Doug -- elichai -- elkingtowa -- ENikS -- Eric Shaw -- Federico Bond -- Francis GASCHET -- Gavin Andresen -- Giuseppe Mazzotta -- Glenn Willen -- Gregory Maxwell -- gubatron -- HarryWu -- himynameismartin -- Huang Le -- Ian Carroll -- imharrywu -- Jameson Lopp -- Janusz Lenar -- JaSK -- Jeff Garzik -- JL2035 -- Johnathan Corgan -- Jonas Schnelli -- jtimon -- Julian Haight -- Kamil Domanski -- kazcw -- kevin -- kiwigb -- Kosta Zertsekel -- LongShao007 -- Luke Dashjr -- Mark Friedenbach -- Mathy Vanvoorden -- Matt Corallo -- Matthew Bogosian -- Micha -- Michael Ford -- Mike Hearn -- mrbandrews -- mruddy -- ntrgn -- Otto Allmendinger -- paveljanik -- Pavel Vasin -- Peter Todd -- phantomcircuit -- Philip Kaufmann -- Pieter Wuille -- pryds -- randy-waterhouse -- R E Broadley -- Rose Toomey -- Ross Nicoll -- Roy Badami -- Ruben Dario Ponticelli -- Rune K. Svendsen -- Ryan X. Charles -- Saivann -- sandakersmann -- SergioDemianLerner -- shshshsh -- sinetek -- Stuart Cardall -- Suhas Daftuar -- Tawanda Kembo -- Teran McKinney -- tm314159 -- Tom Harding -- Trevin Hofmann -- Whit J -- Wladimir J. van der Laan -- Yoichi Hirai -- Zak Wilcox - -As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/). - diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.10.1.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.10.1.md deleted file mode 100644 index 8f59f1f68..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.10.1.md +++ /dev/null @@ -1,143 +0,0 @@ -Bitcoin Core version 0.10.1 is now available from: - - - -This is a new minor version release, bringing bug fixes and translation -updates. It is recommended to upgrade to this version. - -Please report bugs using the issue tracker at github: - - - -Upgrading and downgrading -========================= - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), then run the -installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or -bitcoind/bitcoin-qt (on Linux). - -Downgrade warning ------------------- - -Because release 0.10.0 and later makes use of headers-first synchronization and -parallel block download (see further), the block files and databases are not -backwards-compatible with pre-0.10 versions of Bitcoin Core or other software: - -* Blocks will be stored on disk out of order (in the order they are -received, really), which makes it incompatible with some tools or -other programs. Reindexing using earlier versions will also not work -anymore as a result of this. - -* The block index database will now hold headers for which no block is -stored on disk, which earlier versions won't support. - -If you want to be able to downgrade smoothly, make a backup of your entire data -directory. Without this your node will need start syncing (or importing from -bootstrap.dat) anew afterwards. It is possible that the data from a completely -synchronised 0.10 node may be usable in older versions as-is, but this is not -supported and may break as soon as the older version attempts to reindex. - -This does not affect wallet forward or backward compatibility. - -Notable changes -=============== - -This is a minor release and hence there are no notable changes. -For the notable changes in 0.10, refer to the release notes for the -0.10.0 release at https://github.com/bitcoin/bitcoin/blob/v0.10.0/doc/release-notes.md - -0.10.1 Change log -================= - -Detailed release notes follow. This overview includes changes that affect external -behavior, not code moves, refactors or string updates. - -RPC: -- `7f502be` fix crash: createmultisig and addmultisigaddress -- `eae305f` Fix missing lock in submitblock - -Block (database) and transaction handling: -- `1d2cdd2` Fix InvalidateBlock to add chainActive.Tip to setBlockIndexCandidates -- `c91c660` fix InvalidateBlock to repopulate setBlockIndexCandidates -- `002c8a2` fix possible block db breakage during re-index -- `a1f425b` Add (optional) consistency check for the block chain data structures -- `1c62e84` Keep mempool consistent during block-reorgs -- `57d1f46` Fix CheckBlockIndex for reindex -- `bac6fca` Set nSequenceId when a block is fully linked - -P2P protocol and network code: -- `78f64ef` don't trickle for whitelisted nodes -- `ca301bf` Reduce fingerprinting through timestamps in 'addr' messages. -- `200f293` Ignore getaddr messages on Outbound connections. -- `d5d8998` Limit message sizes before transfer -- `aeb9279` Better fingerprinting protection for non-main-chain getdatas. -- `cf0218f` Make addrman's bucket placement deterministic (countermeasure 1 against eclipse attacks, see http://cs-people.bu.edu/heilman/eclipse/) -- `0c6f334` Always use a 50% chance to choose between tried and new entries (countermeasure 2 against eclipse attacks) -- `214154e` Do not bias outgoing connections towards fresh addresses (countermeasure 2 against eclipse attacks) -- `aa587d4` Scale up addrman (countermeasure 6 against eclipse attacks) -- `139cd81` Cap nAttempts penalty at 8 and switch to pow instead of a division loop - -Validation: -- `d148f62` Acquire CCheckQueue's lock to avoid race condition - -Build system: -- `8752b5c` 0.10 fix for crashes on OSX 10.6 - -Wallet: -- N/A - -GUI: -- `2c08406` some mac specifiy cleanup (memory handling, unnecessary code) -- `81145a6` fix OSX dock icon window reopening -- `786cf72` fix a issue where "command line options"-action overwrite "Preference"-action (on OSX) - -Tests: -- `1117378` add RPC test for InvalidateBlock - -Miscellaneous: -- `c9e022b` Initialization: set Boost path locale in main thread -- `23126a0` Sanitize command strings before logging them. -- `323de27` Initialization: setup environment before starting Qt tests -- `7494e09` Initialization: setup environment before starting tests -- `df45564` Initialization: set fallback locale as environment variable - -Credits -======= - -Thanks to everyone who directly contributed to this release: - -- Alex Morcos -- Cory Fields -- dexX7 -- fsb4000 -- Gavin Andresen -- Gregory Maxwell -- Ivan Pustogarov -- Jonas Schnelli -- Matt Corallo -- mrbandrews -- Pieter Wuille -- Ruben de Vries -- Suhas Daftuar -- Wladimir J. van der Laan - -And all those who contributed additional code review and/or security research: -- 21E14 -- Alison Kendler -- Aviv Zohar -- Ethan Heilman -- Evil-Knievel -- fanquake -- Jeff Garzik -- Jonas Nick -- Luke Dashjr -- Patrick Strateman -- Philip Kaufmann -- Sergio Demian Lerner -- Sharon Goldberg - -As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/). diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.10.2.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.10.2.md deleted file mode 100644 index 192ed69d2..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.10.2.md +++ /dev/null @@ -1,86 +0,0 @@ -Bitcoin Core version 0.10.2 is now available from: - - - -This is a new minor version release, bringing minor bug fixes and translation -updates. It is recommended to upgrade to this version. - -Please report bugs using the issue tracker at github: - - - -Upgrading and downgrading -========================= - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), then run the -installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or -bitcoind/bitcoin-qt (on Linux). - -Downgrade warning ------------------- - -Because release 0.10.0 and later makes use of headers-first synchronization and -parallel block download (see further), the block files and databases are not -backwards-compatible with pre-0.10 versions of Bitcoin Core or other software: - -* Blocks will be stored on disk out of order (in the order they are -received, really), which makes it incompatible with some tools or -other programs. Reindexing using earlier versions will also not work -anymore as a result of this. - -* The block index database will now hold headers for which no block is -stored on disk, which earlier versions won't support. - -If you want to be able to downgrade smoothly, make a backup of your entire data -directory. Without this your node will need start syncing (or importing from -bootstrap.dat) anew afterwards. It is possible that the data from a completely -synchronised 0.10 node may be usable in older versions as-is, but this is not -supported and may break as soon as the older version attempts to reindex. - -This does not affect wallet forward or backward compatibility. - -Notable changes -=============== - -This fixes a serious problem on Windows with data directories that have non-ASCII -characters (https://github.com/bitcoin/bitcoin/issues/6078). - -For other platforms there are no notable changes. - -For the notable changes in 0.10, refer to the release notes -at https://github.com/bitcoin/bitcoin/blob/v0.10.0/doc/release-notes.md - -0.10.2 Change log -================= - -Detailed release notes follow. This overview includes changes that affect external -behavior, not code moves, refactors or string updates. - -Wallet: -- `824c011` fix boost::get usage with boost 1.58 - -Miscellaneous: -- `da65606` Avoid crash on start in TestBlockValidity with gen=1. -- `424ae66` don't imbue boost::filesystem::path with locale "C" on windows (fixes #6078) - -Credits -======= - -Thanks to everyone who directly contributed to this release: - -- Cory Fields -- Gregory Maxwell -- Jonas Schnelli -- Wladimir J. van der Laan - -And all those who contributed additional code review and/or security research: - -- dexX7 -- Pieter Wuille -- vayvanne - -As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/). diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.10.3.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.10.3.md deleted file mode 100644 index 8a110e562..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.10.3.md +++ /dev/null @@ -1,165 +0,0 @@ -Bitcoin Core version 0.10.3 is now available from: - - - -This is a new minor version release, bringing security fixes and translation -updates. It is recommended to upgrade to this version as soon as possible. - -Please report bugs using the issue tracker at github: - - - -Upgrading and downgrading -========================= - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), then run the -installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or -bitcoind/bitcoin-qt (on Linux). - -Downgrade warning ------------------- - -Because release 0.10.0 and later makes use of headers-first synchronization and -parallel block download (see further), the block files and databases are not -backwards-compatible with pre-0.10 versions of Bitcoin Core or other software: - -* Blocks will be stored on disk out of order (in the order they are -received, really), which makes it incompatible with some tools or -other programs. Reindexing using earlier versions will also not work -anymore as a result of this. - -* The block index database will now hold headers for which no block is -stored on disk, which earlier versions won't support. - -If you want to be able to downgrade smoothly, make a backup of your entire data -directory. Without this your node will need start syncing (or importing from -bootstrap.dat) anew afterwards. It is possible that the data from a completely -synchronised 0.10 node may be usable in older versions as-is, but this is not -supported and may break as soon as the older version attempts to reindex. - -This does not affect wallet forward or backward compatibility. - -Notable changes -=============== - -Fix buffer overflow in bundled upnp ------------------------------------- - -Bundled miniupnpc was updated to 1.9.20151008. This fixes a buffer overflow in -the XML parser during initial network discovery. - -Details can be found here: http://talosintel.com/reports/TALOS-2015-0035/ - -This applies to the distributed executables only, not when building from source or -using distribution provided packages. - -Additionally, upnp has been disabled by default. This may result in a lower -number of reachable nodes on IPv4, however this prevents future libupnpc -vulnerabilities from being a structural risk to the network -(see https://github.com/bitcoin/bitcoin/pull/6795). - -Test for LowS signatures before relaying ------------------------------------------ - -Make the node require the canonical 'low-s' encoding for ECDSA signatures when -relaying or mining. This removes a nuisance malleability vector. - -Consensus behavior is unchanged. - -If widely deployed this change would eliminate the last remaining known vector -for nuisance malleability on SIGHASH_ALL P2PKH transactions. On the down-side -it will block most transactions made by sufficiently out of date software. - -Unlike the other avenues to change txids on transactions this -one was randomly violated by all deployed bitcoin software prior to -its discovery. So, while other malleability vectors where made -non-standard as soon as they were discovered, this one has remained -permitted. Even BIP62 did not propose applying this rule to -old version transactions, but conforming implementations have become -much more common since BIP62 was initially written. - -Bitcoin Core has produced compatible signatures since a28fb70e in -September 2013, but this didn't make it into a release until 0.9 -in March 2014; Bitcoinj has done so for a similar span of time. -Bitcoinjs and electrum have been more recently updated. - -This does not replace the need for BIP62 or similar, as miners can -still cooperate to break transactions. Nor does it replace the -need for wallet software to handle malleability sanely[1]. This -only eliminates the cheap and irritating DOS attack. - -[1] On the Malleability of Bitcoin Transactions -Marcin Andrychowicz, Stefan Dziembowski, Daniel Malinowski, Åukasz Mazurek -http://fc15.ifca.ai/preproceedings/bitcoin/paper_9.pdf - -Minimum relay fee default increase ------------------------------------ - -The default for the `-minrelaytxfee` setting has been increased from `0.00001` -to `0.00005`. - -This is necessitated by the current transaction flooding, causing -outrageous memory usage on nodes due to the mempool ballooning. This is a -temporary measure, bridging the time until a dynamic method for determining -this fee is merged (which will be in 0.12). - -(see https://github.com/bitcoin/bitcoin/pull/6793, as well as the 0.11.0 -release notes, in which this value was suggested) - -0.10.3 Change log -================= - -Detailed release notes follow. This overview includes changes that affect external -behavior, not code moves, refactors or string updates. - -- #6186 `e4a7d51` Fix two problems in CSubnet parsing -- #6153 `ebd7d8d` Parameter interaction: disable upnp if -proxy set -- #6203 `ecc96f5` Remove P2SH coinbase flag, no longer interesting -- #6226 `181771b` json: fail read_string if string contains trailing garbage -- #6244 `09334e0` configure: Detect (and reject) LibreSSL -- #6276 `0fd8464` Fix getbalance * 0 -- #6274 `be64204` Add option `-alerts` to opt out of alert system -- #6319 `3f55638` doc: update mailing list address -- #6438 `7e66e9c` openssl: avoid config file load/race -- #6439 `255eced` Updated URL location of netinstall for Debian -- #6412 `0739e6e` Test whether created sockets are select()able -- #6694 `f696ea1` [QT] fix thin space word wrap line brake issue -- #6704 `743cc9e` Backport bugfixes to 0.10 -- #6769 `1cea6b0` Test LowS in standardness, removes nuisance malleability vector. -- #6789 `093d7b5` Update miniupnpc to 1.9.20151008 -- #6795 `f2778e0` net: Disable upnp by default -- #6797 `91ef4d9` Do not store more than 200 timedata samples -- #6793 `842c48d` Bump minrelaytxfee default - -Credits -======= - -Thanks to everyone who directly contributed to this release: - -- Adam Weiss -- Alex Morcos -- Casey Rodarmor -- Cory Fields -- fanquake -- Gregory Maxwell -- Jonas Schnelli -- J Ross Nicoll -- Luke Dashjr -- Pavel Vasin -- Pieter Wuille -- randy-waterhouse -- ฿tcDrak -- Tom Harding -- Veres Lajos -- Wladimir J. van der Laan - -And all those who contributed additional code review and/or security research: - -- timothy on IRC for reporting the issue -- Vulnerability in miniupnp discovered by Aleksandar Nikolic of Cisco Talos - -As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/). diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.11.1.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.11.1.md deleted file mode 100644 index 799205691..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.11.1.md +++ /dev/null @@ -1,172 +0,0 @@ -Bitcoin Core version 0.11.1 is now available from: - - - -This is a new minor version release, bringing security fixes. It is recommended -to upgrade to this version as soon as possible. - -Please report bugs using the issue tracker at github: - - - -Upgrading and downgrading -========================= - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), then run the -installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or -bitcoind/bitcoin-qt (on Linux). - -Downgrade warning ------------------- - -Because release 0.10.0 and later makes use of headers-first synchronization and -parallel block download (see further), the block files and databases are not -backwards-compatible with pre-0.10 versions of Bitcoin Core or other software: - -* Blocks will be stored on disk out of order (in the order they are -received, really), which makes it incompatible with some tools or -other programs. Reindexing using earlier versions will also not work -anymore as a result of this. - -* The block index database will now hold headers for which no block is -stored on disk, which earlier versions won't support. - -If you want to be able to downgrade smoothly, make a backup of your entire data -directory. Without this your node will need start syncing (or importing from -bootstrap.dat) anew afterwards. It is possible that the data from a completely -synchronised 0.10 node may be usable in older versions as-is, but this is not -supported and may break as soon as the older version attempts to reindex. - -This does not affect wallet forward or backward compatibility. There are no -known problems when downgrading from 0.11.x to 0.10.x. - -Notable changes -=============== - -Fix buffer overflow in bundled upnp ------------------------------------- - -Bundled miniupnpc was updated to 1.9.20151008. This fixes a buffer overflow in -the XML parser during initial network discovery. - -Details can be found here: http://talosintel.com/reports/TALOS-2015-0035/ - -This applies to the distributed executables only, not when building from source or -using distribution provided packages. - -Additionally, upnp has been disabled by default. This may result in a lower -number of reachable nodes on IPv4, however this prevents future libupnpc -vulnerabilities from being a structural risk to the network -(see https://github.com/bitcoin/bitcoin/pull/6795). - -Test for LowS signatures before relaying ------------------------------------------ - -Make the node require the canonical 'low-s' encoding for ECDSA signatures when -relaying or mining. This removes a nuisance malleability vector. - -Consensus behavior is unchanged. - -If widely deployed this change would eliminate the last remaining known vector -for nuisance malleability on SIGHASH_ALL P2PKH transactions. On the down-side -it will block most transactions made by sufficiently out of date software. - -Unlike the other avenues to change txids on transactions this -one was randomly violated by all deployed bitcoin software prior to -its discovery. So, while other malleability vectors where made -non-standard as soon as they were discovered, this one has remained -permitted. Even BIP62 did not propose applying this rule to -old version transactions, but conforming implementations have become -much more common since BIP62 was initially written. - -Bitcoin Core has produced compatible signatures since a28fb70e in -September 2013, but this didn't make it into a release until 0.9 -in March 2014; Bitcoinj has done so for a similar span of time. -Bitcoinjs and electrum have been more recently updated. - -This does not replace the need for BIP62 or similar, as miners can -still cooperate to break transactions. Nor does it replace the -need for wallet software to handle malleability sanely[1]. This -only eliminates the cheap and irritating DOS attack. - -[1] On the Malleability of Bitcoin Transactions -Marcin Andrychowicz, Stefan Dziembowski, Daniel Malinowski, Åukasz Mazurek -http://fc15.ifca.ai/preproceedings/bitcoin/paper_9.pdf - -Minimum relay fee default increase ------------------------------------ - -The default for the `-minrelaytxfee` setting has been increased from `0.00001` -to `0.00005`. - -This is necessitated by the current transaction flooding, causing -outrageous memory usage on nodes due to the mempool ballooning. This is a -temporary measure, bridging the time until a dynamic method for determining -this fee is merged (which will be in 0.12). - -(see https://github.com/bitcoin/bitcoin/pull/6793, as well as the 0.11 -release notes, in which this value was suggested) - -0.11.1 Change log -================= - -Detailed release notes follow. This overview includes changes that affect -behavior, not code moves, refactors and string updates. For convenience in locating -the code changes and accompanying discussion, both the pull request and -git merge commit are mentioned. - -- #6438 `2531438` openssl: avoid config file load/race -- #6439 `980f820` Updated URL location of netinstall for Debian -- #6384 `8e5a969` qt: Force TLS1.0+ for SSL connections -- #6471 `92401c2` Depends: bump to qt 5.5 -- #6224 `93b606a` Be even stricter in processing unrequested blocks -- #6571 `100ac4e` libbitcoinconsensus: avoid a crash in multi-threaded environments -- #6545 `649f5d9` Do not store more than 200 timedata samples. -- #6694 `834e299` [QT] fix thin space word wrap line break issue -- #6703 `1cd7952` Backport bugfixes to 0.11 -- #6750 `5ed8d0b` Recent rejects backport to v0.11 -- #6769 `71cc9d9` Test LowS in standardness, removes nuisance malleability vector. -- #6789 `b4ad73f` Update miniupnpc to 1.9.20151008 -- #6785 `b4dc33e` Backport to v0.11: In (strCommand == "tx"), return if AlreadyHave() -- #6412 `0095b9a` Test whether created sockets are select()able -- #6795 `4dbcec0` net: Disable upnp by default -- #6793 `e7bcc4a` Bump minrelaytxfee default - -Credits -======= - -Thanks to everyone who directly contributed to this release: - -- Adam Weiss -- Alex Morcos -- Casey Rodarmor -- Cory Fields -- fanquake -- Gregory Maxwell -- Jonas Schnelli -- J Ross Nicoll -- Luke Dashjr -- Pavel Janík -- Pavel Vasin -- Peter Todd -- Pieter Wuille -- randy-waterhouse -- Ross Nicoll -- Suhas Daftuar -- tailsjoin -- ฿tcDrak -- Tom Harding -- Veres Lajos -- Wladimir J. van der Laan - -And those who contributed additional code review and/or security research: - -- timothy on IRC for reporting the issue -- Vulnerability in miniupnp discovered by Aleksandar Nikolic of Cisco Talos - -As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/). - diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.11.2.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.11.2.md deleted file mode 100644 index 2351b8065..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.11.2.md +++ /dev/null @@ -1,217 +0,0 @@ -Bitcoin Core version 0.11.2 is now available from: - - - -This is a new minor version release, bringing bug fixes, the BIP65 -(CLTV) consensus change, and relay policy preparation for BIP113. It is -recommended to upgrade to this version as soon as possible. - -Please report bugs using the issue tracker at github: - - - -Upgrading and downgrading -========================= - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), then run the -installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or -bitcoind/bitcoin-qt (on Linux). - -Downgrade warning ------------------- - -Because release 0.10.0 and later makes use of headers-first synchronization and -parallel block download (see further), the block files and databases are not -backwards-compatible with pre-0.10 versions of Bitcoin Core or other software: - -* Blocks will be stored on disk out of order (in the order they are -received, really), which makes it incompatible with some tools or -other programs. Reindexing using earlier versions will also not work -anymore as a result of this. - -* The block index database will now hold headers for which no block is -stored on disk, which earlier versions won't support. - -If you want to be able to downgrade smoothly, make a backup of your entire data -directory. Without this your node will need start syncing (or importing from -bootstrap.dat) anew afterwards. It is possible that the data from a completely -synchronised 0.10 node may be usable in older versions as-is, but this is not -supported and may break as soon as the older version attempts to reindex. - -This does not affect wallet forward or backward compatibility. There are no -known problems when downgrading from 0.11.x to 0.10.x. - -Notable changes since 0.11.1 -============================ - -BIP65 soft fork to enforce OP_CHECKLOCKTIMEVERIFY opcode --------------------------------------------------------- - -This release includes several changes related to the [BIP65][] soft fork -which redefines the existing OP_NOP2 opcode as OP_CHECKLOCKTIMEVERIFY -(CLTV) so that a transaction output can be made unspendable until a -specified point in the future. - -1. This release will only relay and mine transactions spending a CLTV - output if they comply with the BIP65 rules as provided in code. - -2. This release will produce version 4 blocks by default. Please see the - *notice to miners* below. - -3. Once 951 out of a sequence of 1,001 blocks on the local node's best block - chain contain version 4 (or higher) blocks, this release will no - longer accept new version 3 blocks and it will only accept version 4 - blocks if they comply with the BIP65 rules for CLTV. - -For more information about the soft-forking change, please see - - -Graphs showing the progress towards block version 4 adoption may be -found at the URLs below: - -- Block versions over the last 50,000 blocks as progress towards BIP65 - consensus enforcement: - -- Block versions over the last 2,000 blocks showing the days to the - earliest possible BIP65 consensus-enforced block: - -**Notice to miners:** Bitcoin Core’s block templates are now for -version 4 blocks only, and any mining software relying on its -getblocktemplate must be updated in parallel to use libblkmaker either -version 0.4.3 or any version from 0.5.2 onward. - -- If you are solo mining, this will affect you the moment you upgrade - Bitcoin Core, which must be done prior to BIP65 achieving its 951/1001 - status. - -- If you are mining with the stratum mining protocol: this does not - affect you. - -- If you are mining with the getblocktemplate protocol to a pool: this - will affect you at the pool operator’s discretion, which must be no - later than BIP65 achieving its 951/1001 status. - -[BIP65]: https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki - -BIP113 mempool-only locktime enforcement using GetMedianTimePast() ----------------------------------------------------------------- - -Bitcoin transactions currently may specify a locktime indicating when -they may be added to a valid block. Current consensus rules require -that blocks have a block header time greater than the locktime specified -in any transaction in that block. - -Miners get to choose what time they use for their header time, with the -consensus rule being that no node will accept a block whose time is more -than two hours in the future. This creates a incentive for miners to -set their header times to future values in order to include locktimed -transactions which weren't supposed to be included for up to two more -hours. - -The consensus rules also specify that valid blocks may have a header -time greater than that of the median of the 11 previous blocks. This -GetMedianTimePast() time has a key feature we generally associate with -time: it can't go backwards. - -[BIP113][] specifies a soft fork (**not enforced in this release**) that -weakens this perverse incentive for individual miners to use a future -time by requiring that valid blocks have a computed GetMedianTimePast() -greater than the locktime specified in any transaction in that block. - -Mempool inclusion rules currently require transactions to be valid for -immediate inclusion in a block in order to be accepted into the mempool. -This release begins applying the BIP113 rule to received transactions, -so transaction whose time is greater than the GetMedianTimePast() will -no longer be accepted into the mempool. - -**Implication for miners:** you will begin rejecting transactions that -would not be valid under BIP113, which will prevent you from producing -invalid blocks if/when BIP113 is enforced on the network. Any -transactions which are valid under the current rules but not yet valid -under the BIP113 rules will either be mined by other miners or delayed -until they are valid under BIP113. Note, however, that time-based -locktime transactions are more or less unseen on the network currently. - -**Implication for users:** GetMedianTimePast() always trails behind the -current time, so a transaction locktime set to the present time will be -rejected by nodes running this release until the median time moves -forward. To compensate, subtract one hour (3,600 seconds) from your -locktimes to allow those transactions to be included in mempools at -approximately the expected time. - -[BIP113]: https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki - -Windows bug fix for corrupted UTXO database on unclean shutdowns ----------------------------------------------------------------- - -Several Windows users reported that they often need to reindex the -entire blockchain after an unclean shutdown of Bitcoin Core on Windows -(or an unclean shutdown of Windows itself). Although unclean shutdowns -remain unsafe, this release no longer relies on memory-mapped files for -the UTXO database, which significantly reduced the frequency of unclean -shutdowns leading to required reindexes during testing. - -For more information, see: - -Other fixes for database corruption on Windows are expected in the -next major release. - -0.11.2 Change log -================= - -Detailed release notes follow. This overview includes changes that affect -behavior, not code moves, refactors and string updates. For convenience in locating -the code changes and accompanying discussion, both the pull request and -git merge commit are mentioned. - -- #6124 `684636b` Make CScriptNum() take nMaxNumSize as an argument -- #6124 `4fa7a04` Replace NOP2 with CHECKLOCKTIMEVERIFY (BIP65) -- #6124 `6ea5ca4` Enable CHECKLOCKTIMEVERIFY as a standard script verify flag -- #6351 `5e82e1c` Add CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic -- #6353 `ba1da90` Show softfork status in getblockchaininfo -- #6351 `6af25b0` Add BIP65 to getblockchaininfo softforks list -- #6688 `01878c9` Fix locking in GetTransaction -- #6653 `b3eaa30` [Qt] Raise debug window when requested -- #6600 `1e672ae` Debian/Ubuntu: Include bitcoin-tx binary -- #6600 `2394f4d` Debian/Ubuntu: Split bitcoin-tx into its own package -- #5987 `33d6825` Bugfix: Allow mining on top of old tip blocks for testnet -- #6852 `21e58b8` build: make sure OpenSSL heeds noexecstack -- #6846 `af6edac` alias `-h` for `--help` -- #6867 `95a5039` Set TCP_NODELAY on P2P sockets. -- #6856 `dfe55bd` Do not allow blockfile pruning during reindex. -- #6566 `a1d3c6f` Add rules--presently disabled--for using GetMedianTimePast as end point for lock-time calculations -- #6566 `f720c5f` Enable policy enforcing GetMedianTimePast as the end point of lock-time constraints -- #6917 `0af5b8e` leveldb: Win32WritableFile without memory mapping -- #6948 `4e895b0` Always flush block and undo when switching to new file - -Credits -======= - -Thanks to everyone who directly contributed to this release: - -- Alex Morcos -- ฿tcDrak -- Chris Kleeschulte -- Daniel Cousens -- Diego Viola -- Eric Lombrozo -- Esteban Ordano -- Gregory Maxwell -- Luke Dashjr -- Marco Falke -- Mark Friedenbach -- Matt Corallo -- Micha -- Mitchell Cash -- Peter Todd -- Pieter Wuille -- Wladimir J. van der Laan -- Zak Wilcox - -And those who contributed additional code review and/or security research. - -As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/). diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.12.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.12.md deleted file mode 100644 index 38715bc75..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.12.md +++ /dev/null @@ -1,13 +0,0 @@ -Version 0.3.12 is now available. - -Features: -* json-rpc errors return a more standard error object. (thanks to Gavin Andresen) -* json-rpc command line returns exit codes. -* json-rpc "backupwallet" command. -* Recovers and continues if an exception is caused by a message you received. Other nodes shouldn't be able to cause an exception, and it hasn't happened before, but if a way is found to cause an exception, this would keep it from being used to stop network nodes. - -If you have json-rpc code that checks the contents of the error string, you need to change it to expect error objects of the form {"code":,"message":}, which is the standard. See this thread: -http://www.bitcoin.org/smf/index.php?topic=969.0 - -Download: -http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.3.12/ diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.13.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.13.md deleted file mode 100644 index 2b95ff233..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.13.md +++ /dev/null @@ -1,26 +0,0 @@ -Version 0.3.13 is now available. You should upgrade to prevent potential problems with 0/unconfirmed transactions. Note: 0.3.13 prevents problems if you haven't already spent a 0/unconfirmed transaction, but if that already happened, you need 0.3.13.2. - -Changes: -* Don't count or spend payments until they have 1 confirmation. -* Internal version number from 312 to 31300. -* Only accept transactions sent by IP address if -allowreceivebyip is specified. -* Dropped DB_PRIVATE Berkeley DB flag. -* Fix problem sending the last cent with sub-cent fractional change. -* Auto-detect whether to use 128-bit 4-way SSE2 on Linux. -Gavin Andresen: -* Option -rpcallowip= to accept json-rpc connections from another machine. -* Clean shutdown on SIGTERM on Linux. - -Download: -http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.3.13/ - -(Thanks Laszlo for the Mac OSX build!) - -Note: -The SSE2 auto-detect in the Linux 64-bit version doesn't work with AMD in 64-bit mode. Please try this instead and let me know if it gets it right: -http://www.bitcoin.org/download/bitcoin-0.3.13.1-specialbuild-linux64.tar.gz - -You can still control the SSE2 use manually with -4way and -4way=0. - -Version 0.3.13.2 (SVN rev 161) has improvements for the case where you already had 0/unconfirmed transactions that you might have already spent. Here's a Windows build of it: -http://www.bitcoin.org/download/bitcoin-0.3.13.2-win32-setup.exe diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.14.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.14.md deleted file mode 100644 index e73052ed9..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.14.md +++ /dev/null @@ -1,11 +0,0 @@ -Version 0.3.14 is now available -http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.3.14/ - -Changes: -* Key pool feature for safer wallet backup -Gavin Andresen: -* TEST network mode with switch -testnet -* Option to use SSL for JSON-RPC connections on unix/osx -* validateaddress RPC command -eurekafag: -* Russian translation diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.15.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.15.md deleted file mode 100644 index b98052ef5..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.15.md +++ /dev/null @@ -1,6 +0,0 @@ -* paytxfee switch is now per KB, so it adds the correct fee for large transactions -* sending avoids using coins with less than 6 confirmations if it can -* BitcoinMiner processes transactions in priority order based on age of dependencies -* make sure generation doesn't start before block 74000 downloaded -* bugfixes by Dean Gores -* testnet, keypoololdest and paytxfee added to getinfo diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.16.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.16.md deleted file mode 100644 index 743f84f30..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.16.md +++ /dev/null @@ -1 +0,0 @@ -Never released. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.17.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.17.md deleted file mode 100644 index d3604b8f8..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.17.md +++ /dev/null @@ -1,12 +0,0 @@ -Version 0.3.17 is now available. - -Changes: -* new getwork, thanks m0mchil -* added transaction fee setting in UI options menu -* free transaction limits -* sendtoaddress returns transaction id instead of "sent" -* getaccountaddress - -The UI transaction fee setting was easy since it was still there from 0.1.5 and all I had to do was re-enable it. - -The accounts-based commands: move, sendfrom and getbalance will be in the next release. We still have some more changes to make first. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.18.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.18.md deleted file mode 100644 index ab1c2e069..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.18.md +++ /dev/null @@ -1,11 +0,0 @@ -Changes: -* Fixed a wallet.dat compatibility problem if you downgraded from 0.3.17 and then upgraded again -* IsStandard() check to only include known transaction types in blocks -* Jgarzik's optimisation to speed up the initial block download a little - -The main addition in this release is the Accounts-Based JSON-RPC commands that Gavin's been working on (more details at http://www.bitcoin.org/smf/index.php?topic=1886.0). -* getaccountaddress -* sendfrom -* move -* getbalance -* listtransactions diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.19.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.19.md deleted file mode 100644 index fcd867561..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.19.md +++ /dev/null @@ -1,9 +0,0 @@ -There's more work to do on DoS, but I'm doing a quick build of what I have so far in case it's needed, before venturing into more complex ideas. The build for this is version 0.3.19. - -- Added some DoS controls -As Gavin and I have said clearly before, the software is not at all resistant to DoS attack. This is one improvement, but there are still more ways to attack than I can count. - -I'm leaving the -limitfreerelay part as a switch for now and it's there if you need it. - -- Removed "safe mode" alerts -"safe mode" alerts was a temporary measure after the 0.3.9 overflow bug. We can say all we want that users can just run with "-disablesafemode", but it's better just not to have it for the sake of appearances. It was never intended as a long term feature. Safe mode can still be triggered by seeing a longer (greater total PoW) invalid block chain. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.20.1.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.20.1.md deleted file mode 100644 index 6c5682ea4..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.20.1.md +++ /dev/null @@ -1 +0,0 @@ -Never released or release notes were lost. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.20.2.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.20.2.md deleted file mode 100644 index 09ecb736b..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.20.2.md +++ /dev/null @@ -1,17 +0,0 @@ -The maxsendbuffer bug (0.3.20.1 clients not being able to download the block chain from other 0.3.20.1 clients) was only going to get -worse as people upgraded, so I cherry-picked the bug fix and created a minor release yesterday. - -The Amazon Machine Images I used to do the builds are available: - - ami-38a05251 Bitcoin-v0.3.20.2 Mingw (Windows; Administrator password 'bitcoin development') - ami-30a05259 Bitcoin_0.3.20.2 Linux32 - ami-8abc4ee3 Bitcoin_0.3.20.2 Linux64 - -(mac build will be done soon) - -If you have already downloaded version 0.3.20.1, please either add this to your bitcoin.conf file: - - maxsendbuffer=10000 - maxreceivebuffer=10000 - -... or download the new version. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.20.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.20.md deleted file mode 100644 index 9ae21802e..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.20.md +++ /dev/null @@ -1,22 +0,0 @@ -Please checkout the git integration branch from: - -https://github.com/bitcoin/bitcoin - -... and help test. The new features that need testing are: - -* -nolisten : https://github.com/bitcoin/bitcoin/pull/11 -* -rescan : scan block chain for missing wallet transactions -* -printtoconsole : https://github.com/bitcoin/bitcoin/pull/37 -* RPC gettransaction details : https://github.com/bitcoin/bitcoin/pull/24 -* listtransactions new features : https://github.com/bitcoin/bitcoin/pull/10 - -Bug fixes that also need testing: - -* -maxconnections= : https://github.com/bitcoin/bitcoin/pull/42 -* RPC listaccounts minconf : https://github.com/bitcoin/bitcoin/pull/27 -* RPC move, add time to output : https://github.com/bitcoin/bitcoin/pull/21 -* ...and several improvements to --help output. - -This needs more testing on Windows! Please drop me a quick private message, email, or IRC message if you are able to do some testing. If you find bugs, please open an issue at: - -https://github.com/bitcoin/bitcoin/issues diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.21.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.21.md deleted file mode 100644 index f3b6bc426..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.21.md +++ /dev/null @@ -1,20 +0,0 @@ -Binaries for Bitcoin version 0.3.21 are available at: - https://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.3.21/ - -Changes and new features from the 0.3.20 release include: - -* Universal Plug and Play support. Enable automatic opening of a port for incoming connections by running bitcoin or bitcoind with the - -upnp=1 command line switch or using the Options dialog box. - -* Support for full-precision bitcoin amounts. You can now send, and bitcoin will display, bitcoin amounts smaller than 0.01. However, sending fewer than 0.01 bitcoins still requires a 0.01 bitcoin fee (so you can send 1.0001 bitcoins without a fee, but you will be asked to pay a fee if you try to send 0.0001). - -* A new method of finding bitcoin nodes to connect with, via DNS A records. Use the -dnsseed option to enable. - -For developers, changes to bitcoin's remote-procedure-call API: - -* New rpc command "sendmany" to send bitcoins to more than one address in a single transaction. - -* Several bug fixes, including a serious intermittent bug that would sometimes cause bitcoind to stop accepting rpc requests. - -* -logtimestamps option, to add a timestamp to each line in debug.log. - -* Immature blocks (newly generated, under 120 confirmations) are now shown in listtransactions. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.22.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.22.md deleted file mode 100644 index 4c05e3e5e..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.22.md +++ /dev/null @@ -1,16 +0,0 @@ -Download URL: https://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.3.22/ - -This is largely a bugfix and TX fee schedule release. We also hope to make 0.3.23 a quick release, to fix problems that the network has seen due to explosive growth in the past week. - -Notable changes: -* Client will accept and relay TX's with 0.0005 BTC fee schedule (users still pay 0.01 BTC per kb, until next version) -* Non-standard transactions accepted on testnet -* Source code tree reorganized (prep for autotools build) -* Remove "Generate Coins" option from GUI, and remove 4way SSE miner. Internal reference CPU miner remains available, but users are directed to external miners for best hash production. -* IRC is overflowing. Client now bootstraps to channels #bitcoin00 - #bitcoin99 -* DNS names now may be used with -addnode, -connect (requires -dns to enable) - -RPC changes: -* 'listtransactions' adds 'from' param, for range queries -* 'move' may take account balances negative -* 'settxfee' added, to manually set TX fee diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.23.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.23.md deleted file mode 100644 index c1d520e49..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.23.md +++ /dev/null @@ -1,10 +0,0 @@ -Win32, Linux, MacOSX and source releases for bitcoin v0.3.23 have been uploaded to -https://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.3.23/ - -This is another quick bugfix release, trying to deal with the influx of new bitcoin users. - -Main items of note: - -* P2P connect-to-node logic changed to reduce timeout a bit. The network saw a huge influx of new users, who do not permit incoming connections. This change is a short-term hack, to more quickly hunt for useful P2P connections. Better "leaf node" logic is in the works, but this should let us limp along until then. One may use -upnp to properly forward ports, and help the network. -* Transaction fee reduced to 0.0005 for new transactions -* Client will relay transactions with fees as low as 0.0001 BTC diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.24.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.24.md deleted file mode 100644 index d35ac66f2..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.3.24.md +++ /dev/null @@ -1,20 +0,0 @@ -Bitcoin v0.3.24 is now available for download at -https://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.3.24/ - -This is another bug fix release. We had hoped to have wallet encryption ready for release, but more urgent fixes for existing clients were needed -- most notably block download problems were getting severe. Wallet encryption is ready for testing at https://github.com/bitcoin/bitcoin/pull/352 for the git-savvy, and hopefully will follow shortly in the next release, v0.4. - -Notable fixes in v0.3.24, and the main reasons for this release: - -F1) Block downloads were failing or taking unreasonable amounts of time to complete, because the increased size of the block chain was bumping up against some earlier buffer-size DoS limits. - -F2) Fix crash caused by loss/lack of network connection. - -Notable changes in v0.3.24: - -C1) DNS seeding enabled by default. - -C2) UPNP enabled by default in the GUI client. The percentage of bitcoin clients that accept incoming connections is quite small, and that is a problem. This should help. bitcoind, and unofficial builds, are unchanged (though we encourage use of "-upnp" to help the network!) - -C3) Initial unit testing framework. Bitcoin sorely needs automated tests, and this is a beginning. Contributions welcome. - -C4) Internal wallet code cleanup. While invisible to an end user, this change provides the basis for v0.4's wallet encryption. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.0.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.0.md deleted file mode 100644 index 145072a36..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.0.md +++ /dev/null @@ -1,70 +0,0 @@ -Bitcoin version 0.4.0 is now available for download at: -http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.4.0/ - -The main feature in this release is wallet private key encryption; -you can set a passphrase that must be entered before sending coins. -See below for more information; if you decide to encrypt your wallet, -WRITE DOWN YOUR PASSPHRASE AND PUT IT IN A SECURE LOCATION. If you -forget or lose your wallet passphrase, you lose your bitcoins. -Previous versions of bitcoin are unable to read encrypted wallets, -and will crash on startup if the wallet is encrypted. - -Also note: bitcoin version 0.4 uses a newer version of Berkeley DB -(bdb version 4.8) than previous versions (bdb 4.7). If you upgrade -to version 0.4 and then revert back to an earlier version of bitcoin -the it may be unable to start because bdb 4.7 cannot read bdb 4.8 -"log" files. - - -Notable bug fixes from version 0.3.24: - -Fix several bitcoin-becomes-unresponsive bugs due to multithreading -deadlocks. - -Optimize database writes for large (lots of inputs) transactions -(fixes a potential denial-of-service attack) - - -Wallet Encryption - -Bitcoin supports native wallet encryption so that people who steal your -wallet file don't automatically get access to all of your Bitcoins. -In order to enable this feature, choose "Encrypt Wallet" from the -Options menu. You will be prompted to enter a passphrase, which -will be used as the key to encrypt your wallet and will be needed -every time you wish to send Bitcoins. If you lose this passphrase, -you will lose access to spend all of the bitcoins in your wallet, -no one, not even the Bitcoin developers can recover your Bitcoins. -This means you are responsible for your own security, store your -passphrase in a secure location and do not forget it. - -Remember that the encryption built into bitcoin only encrypts the -actual keys which are required to send your bitcoins, not the full -wallet. This means that someone who steals your wallet file will -be able to see all the addresses which belong to you, as well as the -relevant transactions, you are only protected from someone spending -your coins. - -It is recommended that you backup your wallet file before you -encrypt your wallet. To do this, close the Bitcoin client and -copy the wallet.dat file from ~/.bitcoin/ on Linux, /Users/(user -name)/Application Support/Bitcoin/ on Mac OSX, and %APPDATA%/Bitcoin/ -on Windows (that is /Users/(user name)/AppData/Roaming/Bitcoin on -Windows Vista and 7 and /Documents and Settings/(user name)/Application -Data/Bitcoin on Windows XP). Once you have copied that file to a -safe location, reopen the Bitcoin client and Encrypt your wallet. -If everything goes fine, delete the backup and enjoy your encrypted -wallet. Note that once you encrypt your wallet, you will never be -able to go back to a version of the Bitcoin client older than 0.4. - -Keep in mind that you are always responsible for your own security. -All it takes is a slightly more advanced wallet-stealing trojan which -installs a keylogger to steal your wallet passphrase as you enter it -in addition to your wallet file and you have lost all your Bitcoins. -Wallet encryption cannot keep you safe if you do not practice -good security, such as running up-to-date antivirus software, only -entering your wallet passphrase in the Bitcoin client and using the -same passphrase only as your wallet passphrase. - -See the doc/README file in the bitcoin source for technical details -of wallet encryption. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.1.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.1.md deleted file mode 100644 index ac471a8d7..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.1.md +++ /dev/null @@ -1,38 +0,0 @@ -Bitcoin version 0.4.1 is now available for download at: -http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.4.1/ - -This is a bugfix only release based on 0.4.0. - -Please report bugs by replying to this forum thread. - -MAJOR BUG FIX (CVE-2011-4447) - -The wallet encryption feature introduced in Bitcoin version 0.4.0 did not sufficiently secure the private keys. An attacker who -managed to get a copy of your encrypted wallet.dat file might be able to recover some or all of the unencrypted keys and steal the -associated coins. - -If you have a previously encrypted wallet.dat, the first time you run wxbitcoin or bitcoind the wallet will be rewritten, Bitcoin will -shut down, and you will be prompted to restart it to run with the new, properly encrypted file. - -If you had a previously encrypted wallet.dat that might have been copied or stolen (for example, you backed it up to a public -location) you should send all of your bitcoins to yourself using a new bitcoin address and stop using any previously generated addresses. - -Wallets encrypted with this version of Bitcoin are written properly. - -Technical note: the encrypted wallet's 'keypool' will be regenerated the first time you request a new bitcoin address; to be certain that the -new private keys are properly backed up you should: - -1. Run Bitcoin and let it rewrite the wallet.dat file - -2. Run it again, then ask it for a new bitcoin address. -wxBitcoin: new address visible on main window -bitcoind: run the 'walletpassphrase' RPC command to unlock the wallet, then run the 'getnewaddress' RPC command. - -3. If your encrypted wallet.dat may have been copied or stolen, send all of your bitcoins to the new bitcoin address. - -4. Shut down Bitcoin, then backup the wallet.dat file. -IMPORTANT: be sure to request a new bitcoin address before backing up, so that the 'keypool' is regenerated and backed up. - -"Security in depth" is always a good idea, so choosing a secure location for the backup and/or encrypting the backup before uploading it is recommended. And as in previous releases, if your machine is infected by malware there are several ways an attacker might steal your bitcoins. - -Thanks to Alan Reiner (etotheipi) for finding and reporting this bug. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.2.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.2.md deleted file mode 100644 index 6c5682ea4..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.2.md +++ /dev/null @@ -1 +0,0 @@ -Never released or release notes were lost. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.3.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.3.md deleted file mode 100644 index fea1ae75b..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.3.md +++ /dev/null @@ -1,21 +0,0 @@ -bitcoind version 0.4.3 is now available for download at: -http://luke.dashjr.org/programs/bitcoin/files/bitcoind-0.4.3/ (until Gavin uploads to SourceForge) - -This is a bugfix-only release based on 0.4.0. - -Please note that the wxBitcoin GUI client is no longer maintained nor supported. If someone would like to step up to maintain this, they should contact Luke-Jr. - -Please report bugs for the daemon only using the issue tracker at github: -https://github.com/bitcoin/bitcoin/issues - -Stable source code is hosted at Gitorious: -http://gitorious.org/bitcoin/bitcoind-stable/archive-tarball/v0.4.3#.tar.gz - -BUG FIXES - -Cease locking memory used by non-sensitive information (this caused a huge performance hit on some platforms, especially noticable during initial blockchain download). -Fixed some address-handling deadlocks (client freezes). -No longer accept inbound connections over the internet when Bitcoin is being used with Tor (identity leak). -Use the correct base transaction fee of 0.0005 BTC for accepting transactions into mined blocks (since 0.4.0, it was incorrectly accepting 0.0001 BTC which was only meant to be relayed). -Add new DNS seeds (maintained by Pieter Wuille and Luke Dashjr). - diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.4.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.4.md deleted file mode 100644 index f435ba716..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.4.md +++ /dev/null @@ -1,30 +0,0 @@ -Bitcoin version 0.4.4 is now available for download at: -http://luke.dashjr.org/programs/bitcoin/files/bitcoind-0.4.4/ - -This is a bugfix-only release based on 0.4.0. - -Please note that the wxBitcoin GUI client is no longer maintained nor supported. If someone would like to step up to maintain this, they should contact Luke-Jr. - -Please report bugs for the daemon only using the issue tracker at github: -https://github.com/bitcoin/bitcoin/issues - -Stable source code is hosted at Gitorious: -http://gitorious.org/bitcoin/bitcoind-stable/archive-tarball/v0.4.4#.tar.gz - -BUG FIXES - -Limit the number of orphan transactions stored in memory, to prevent a potential denial-of-service attack by flooding orphan transactions. Also never store invalid transactions at all. -Fix possible buffer overflow on systems with very long application data paths. This is not exploitable. -Resolved multiple bugs preventing long-term unlocking of encrypted wallets (issue #922). -Only send local IP in "version" messages if it is globally routable (ie, not private), and try to get such an IP from UPnP if applicable. -Reannounce UPnP port forwards every 20 minutes, to workaround routers expiring old entries, and allow the -upnp option to override any stored setting. -Various memory leaks and potential null pointer deferences have been -fixed. -Several shutdown issues have been fixed. -Check that keys stored in the wallet are valid at startup, and if not, -report corruption. -Various build fixes. -If no password is specified to bitcoind, recommend a secure password. -Update hard-coded fallback seed nodes, choosing recent ones with long uptime and versions at least 0.4.0. -Add checkpoint at block 168,000. - diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.5.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.5.md deleted file mode 100644 index 6c5682ea4..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.5.md +++ /dev/null @@ -1 +0,0 @@ -Never released or release notes were lost. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.6.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.6.md deleted file mode 100644 index 07c5e4b69..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.4.6.md +++ /dev/null @@ -1,37 +0,0 @@ -bitcoind version 0.4.6 is now available for download at: -Windows: installer | zip (sig) -Source: tar.gz -bitcoind and Bitcoin-Qt version 0.6.0.7 are also tagged in git, but it is recommended to upgrade to 0.6.1. - -These are bugfix-only releases. - -Please report bugs by replying to this forum thread. Note that the 0.4.x wxBitcoin GUI client is no longer maintained nor supported. If someone would like to step up to maintain this, they should contact Luke-Jr. - -BUG FIXES - -Version 0.6.0 allowed importing invalid "private keys", which would be unspendable; 0.6.0.7 will now verify the private key is valid, and refuse to import an invalid one -Verify status of encrypt/decrypt calls to detect failed padding -Check blocks for duplicate transactions earlier. Fixes #1167 -Upgrade Windows builds to OpenSSL 1.0.1b -Set label when selecting an address that already has a label. Fixes #1080 (Bitcoin-Qt) -JSON-RPC listtransactions's from/count handling is now fixed -Optimize and fix multithreaded access, when checking whether we already know about transactions -Fix potential networking deadlock -Proper support for Growl 1.3 notifications -Display an error, rather than crashing, if encoding a QR Code failed (0.6.0.7) -Don't erroneously set "Display addresses" for users who haven't explicitly enabled it (Bitcoin-Qt) -Some non-ASCII input in JSON-RPC expecting hexadecimal may have been misinterpreted rather than rejected -Missing error condition checking added -Do not show green tick unless all known blocks are downloaded. Fixes #921 (Bitcoin-Qt) -Increase time ago of last block for "up to date" status from 30 to 90 minutes -Show a message box when runaway exception happens (Bitcoin-Qt) -Use a messagebox to display the error when -server is provided without providing a rpc password -Show error message instead of exception crash when unable to bind RPC port (Bitcoin-Qt) -Correct sign message bitcoin address tooltip. Fixes #1050 (Bitcoin-Qt) -Removed "(no label)" from QR Code dialog titlebar if we have no label (0.6.0.7) -Removed an ugly line break in tooltip for mature transactions (0.6.0.7) -Add missing tooltip and key shortcut in settings dialog (part of #1088) (Bitcoin-Qt) -Work around issue in boost::program_options that prevents from compiling in clang -Fixed bugs occurring only on platforms with unsigned characters (such as ARM). -Rename make_windows_icon.py to .sh as it is a shell script. Fixes #1099 (Bitcoin-Qt) -Various trivial internal corrections to types used for counting/size loops and warnings diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.0.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.0.md deleted file mode 100644 index baa409b5f..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.0.md +++ /dev/null @@ -1,70 +0,0 @@ -Bitcoin version 0.5.0 is now available for download at: -http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.5.0/ - -The major change for this release is a completely new graphical interface that uses the Qt user interface toolkit. - -This release include German, Spanish, Spanish-Castilian, Norwegian and Dutch translations. More translations are welcome; join the project at Transifex if you can help: -https://www.transifex.net/projects/p/bitcoin/ - -Please report bugs using the issue tracker at github: -https://github.com/bitcoin/bitcoin/issues - -For Ubuntu users, there is a new ppa maintained by Matt Corallo which you can add to your system so that it will automatically keep bitcoin up-to-date. Just type "sudo apt-add-repository ppa:bitcoin/bitcoin" in your terminal, then install the bitcoin-qt package. - -MAJOR BUG FIX (CVE-2011-4447) - -The wallet encryption feature introduced in Bitcoin version 0.4.0 did not sufficiently secure the private keys. An attacker who -managed to get a copy of your encrypted wallet.dat file might be able to recover some or all of the unencrypted keys and steal the -associated coins. - -If you have a previously encrypted wallet.dat, the first time you run bitcoin-qt or bitcoind the wallet will be rewritten, Bitcoin will -shut down, and you will be prompted to restart it to run with the new, properly encrypted file. - -If you had a previously encrypted wallet.dat that might have been copied or stolen (for example, you backed it up to a public -location) you should send all of your bitcoins to yourself using a new bitcoin address and stop using any previously generated addresses. - -Wallets encrypted with this version of Bitcoin are written properly. - -Technical note: the encrypted wallet's 'keypool' will be regenerated the first time you request a new bitcoin address; to be certain that the -new private keys are properly backed up you should: - -1. Run Bitcoin and let it rewrite the wallet.dat file - -2. Run it again, then ask it for a new bitcoin address. -Bitcoin-Qt: Address Book, then New Address... -bitcoind: run the 'walletpassphrase' RPC command to unlock the wallet, then run the 'getnewaddress' RPC command. - -3. If your encrypted wallet.dat may have been copied or stolen, send all of your bitcoins to the new bitcoin address. - -4. Shut down Bitcoin, then backup the wallet.dat file. -IMPORTANT: be sure to request a new bitcoin address before backing up, so that the 'keypool' is regenerated and backed up. - -"Security in depth" is always a good idea, so choosing a secure location for the backup and/or encrypting the backup before uploading it is recommended. And as in previous releases, if your machine is infected by malware there are several ways an attacker might steal your bitcoins. - -Thanks to Alan Reiner (etotheipi) for finding and reporting this bug. - -MAJOR GUI CHANGES - -"Splash" graphics at startup that show address/wallet/blockchain loading progress. - -"Synchronizing with network" progress bar to show block-chain download progress. - -Icons at the bottom of the window that show how well connected you are to the network, with tooltips to display details. - -Drag and drop support for bitcoin: URIs on web pages. - -Export transactions as a .csv file. - -Many other GUI improvements, large and small. - -RPC CHANGES - -getmemorypool : new RPC command, provides everything needed to construct a block with a custom generation transaction and submit a solution - -listsinceblock : new RPC command, list transactions since given block - -signmessage/verifymessage : new RPC commands to sign a message with one of your private keys or verify that a message signed by the private key associated with a bitcoin address. - -GENERAL CHANGES - -Faster initial block download. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.1.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.1.md deleted file mode 100644 index d56bff6d9..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.1.md +++ /dev/null @@ -1,43 +0,0 @@ -Bitcoin version 0.5.1 is now available for download at: -http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.5.1/ - -This is a bugfix-only release. - -This release includes 13 translations, including 5 new translations: -Italian, Hungarian, Ukranian, Portuguese (Brazilian) and Simplified Chinese. -More translations are welcome; join the project at Transifex if you can help: -https://www.transifex.net/projects/p/bitcoin/ - -Please report bugs using the issue tracker at github: -https://github.com/bitcoin/bitcoin/issues - -Project source code is hosted at github; we are no longer -distributing .tar.gz files here, you can get them -directly from github: -https://github.com/bitcoin/bitcoin/tarball/v0.5.1 # .tar.gz -https://github.com/bitcoin/bitcoin/zipball/v0.5.1 # .zip - -For Ubuntu users, there is a new ppa maintained by Matt Corallo which -you can add to your system so that it will automatically keep -bitcoin up-to-date. Just type -sudo apt-add-repository ppa:bitcoin/bitcoin -in your terminal, then install the bitcoin-qt package. - - -BUG FIXES - -Re-enable SSL support for the JSON-RPC interface (it was unintentionally -disabled for the 0.5.0 release binaries). - -The code that finds peers via "dns seeds" no longer stops bitcoin startup -if one of the dns seed machines is down. - -Tooltips on the transaction list view were rendering incorrectly (as black boxes -or with a transparent background). - -Prevent a denial-of-service attack involving flooding a bitcoin node with -orphan blocks. - -The wallet passphrase dialog now warns you if the caps lock key was pressed. - -Improved searching in addresses and labels in bitcoin-qt. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.2.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.2.md deleted file mode 100644 index f79816668..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.2.md +++ /dev/null @@ -1,22 +0,0 @@ -Bitcoin version 0.5.2 is now available for download at: -http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.5.2/ - -This is a bugfix-only release based on 0.5.1. - -Please report bugs using the issue tracker at github: -https://github.com/bitcoin/bitcoin/issues - -Stable source code is hosted at Gitorious: -http://gitorious.org/bitcoin/bitcoind-stable/archive-tarball/v0.5.2#.tar.gz - -BUG FIXES - -Check all transactions in blocks after the last checkpoint (0.5.0 and 0.5.1 skipped checking ECDSA signatures during initial blockchain download). -Cease locking memory used by non-sensitive information (this caused a huge performance hit on some platforms, especially noticable during initial blockchain download; this was -not a security vulnerability). -Fixed some address-handling deadlocks (client freezes). -No longer accept inbound connections over the internet when Bitcoin is being used with Tor (identity leak). -Re-enable SSL support for the JSON-RPC interface (it was unintentionally disabled for the 0.5.0 and 0.5.1 release Linux binaries). -Use the correct base transaction fee of 0.0005 BTC for accepting transactions into mined blocks (since 0.4.0, it was incorrectly accepting 0.0001 BTC which was only meant to be relayed). -Don't show "IP" for transactions which are not necessarily IP transactions. -Add new DNS seeds (maintained by Pieter Wuille and Luke Dashjr). diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.3.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.3.md deleted file mode 100644 index 7c84c5332..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.3.md +++ /dev/null @@ -1,42 +0,0 @@ -Bitcoin version 0.5.3 is now available for download at: -http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.5.3/ - -This is a bugfix-only release based on 0.5.1. -It also includes a few protocol updates. - -Please report bugs using the issue tracker at github: -https://github.com/bitcoin/bitcoin/issues - -Stable source code is hosted at Gitorious: -http://gitorious.org/bitcoin/bitcoind-stable/archive-tarball/v0.5.3#.tar.gz - -PROTOCOL UPDATES - -BIP 30: Introduce a new network rule: "a block is not valid if it contains a transaction whose hash already exists in the block chain, unless all that transaction's outputs were already spent before said block" beginning on March 15, 2012, 00:00 UTC. -On testnet, allow mining of min-difficulty blocks if 20 minutes have gone by without mining a regular-difficulty block. This is to make testing Bitcoin easier, and will not affect normal mode. - -BUG FIXES - -Limit the number of orphan transactions stored in memory, to prevent a potential denial-of-service attack by flooding orphan transactions. Also never store invalid transactions at all. -Fix possible buffer overflow on systems with very long application data paths. This is not exploitable. -Resolved multiple bugs preventing long-term unlocking of encrypted wallets -(issue #922). -Only send local IP in "version" messages if it is globally routable (ie, not private), and try to get such an IP from UPnP if applicable. -Reannounce UPnP port forwards every 20 minutes, to workaround routers expiring old entries, and allow the -upnp option to override any stored setting. -Skip splash screen when -min is used, and fix Minimize to Tray function. -Do not blank "label" in Bitcoin-Qt "Send" tab, if the user has already entered something. -Correct various labels and messages. -Various memory leaks and potential null pointer deferences have been fixed. -Handle invalid Bitcoin URIs using "bitcoin://" instead of "bitcoin:". -Several shutdown issues have been fixed. -Revert to "global progress indication", as starting from zero every time was considered too confusing for many users. -Check that keys stored in the wallet are valid at startup, and if not, report corruption. -Enable accessible widgets on Windows, so that people with screen readers such as NVDA can make sense of it. -Various build fixes. -If no password is specified to bitcoind, recommend a secure password. -Automatically focus and scroll to new "Send coins" entries in Bitcoin-Qt. -Show a message box for --help on Windows, for Bitcoin-Qt. -Add missing "About Qt" menu option to show built-in Qt About dialog. -Don't show "-daemon" as an option for Bitcoin-Qt, since it isn't available. -Update hard-coded fallback seed nodes, choosing recent ones with long uptime and versions at least 0.4.0. -Add checkpoint at block 168,000. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.4.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.4.md deleted file mode 100644 index fcde3ac4e..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.4.md +++ /dev/null @@ -1,39 +0,0 @@ -Bitcoin version 0.5.4 is now available for download at: -http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.5.4/ -NOTE: 0.5.4rc3 is being renamed to 0.5.4 final with no changes. - -This is a bugfix-only release in the 0.5.x series, plus a few protocol updates. - -Please report bugs using the issue tracker at github: -https://github.com/bitcoin/bitcoin/issues - -Stable source code is hosted at Gitorious: -http://gitorious.org/bitcoin/bitcoind-stable/archive-tarball/v0.5.4#.tar.gz - -PROTOCOL UPDATES - -BIP 16: Special-case "pay to script hash" logic to enable minimal validation of new transactions. -Support for validating message signatures produced with compressed public keys. - -BUG FIXES - -Build with thread-safe MingW libraries for Windows, fixing a dangerous memory corruption scenario when exceptions are thrown. -Fix broken testnet mining. -Stop excess inventory relay during initial block download. -When disconnecting a node, clear the received buffer so that we do not process any already received messages. -Yet another attempt at implementing "minimize to tray" that works on all operating systems. -Fix Bitcoin-Qt notifications under Growl 1.3. -Increase required age of Bitcoin-Qt's "not up to date" status from 30 to 90 minutes. -Implemented missing verifications that led to crash on entering some wrong passphrases for encrypted wallets. -Fix default filename suffixes in GNOME save dialog. -Make the "Send coins" tab use the configured unit type, even on the first attempt. -Print detailed wallet loading errors to debug.log when it is corrupt. -Allocate exactly the amount of space needed for signing transactions, instead of a fixed 10k buffer. -Workaround for improbable memory access violation. -Check wallet's minimum version before trying to load it. -Remove wxBitcoin properly when installing Bitcoin-Qt over it. (Windows) -Detail reorganization information better in debug log. -Use a messagebox to display the error when -server is provided without configuring a RPC password. -Testing suite build now honours provided CXXFLAGS. -Removed an extraneous line-break in mature transaction tooltips. -Fix some grammatical errors in translation process documentation. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.5.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.5.md deleted file mode 100644 index 75ebc3e6b..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.5.5.md +++ /dev/null @@ -1,37 +0,0 @@ -bitcoind and Bitcoin-Qt version 0.5.5 are now available for download at: -Windows: installer | zip (sig) -Source: tar.gz -bitcoind and Bitcoin-Qt version 0.6.0.7 are also tagged in git, but it is recommended to upgrade to 0.6.1. - -These are bugfix-only releases. - -Please report bugs by replying to this forum thread. Note that the 0.4.x wxBitcoin GUI client is no longer maintained nor supported. If someone would like to step up to maintain this, they should contact Luke-Jr. - -BUG FIXES - -Version 0.6.0 allowed importing invalid "private keys", which would be unspendable; 0.6.0.7 will now verify the private key is valid, and refuse to import an invalid one -Verify status of encrypt/decrypt calls to detect failed padding -Check blocks for duplicate transactions earlier. Fixes #1167 -Upgrade Windows builds to OpenSSL 1.0.1b -Set label when selecting an address that already has a label. Fixes #1080 (Bitcoin-Qt) -JSON-RPC listtransactions's from/count handling is now fixed -Optimize and fix multithreaded access, when checking whether we already know about transactions -Fix potential networking deadlock -Proper support for Growl 1.3 notifications -Display an error, rather than crashing, if encoding a QR Code failed (0.6.0.7) -Don't erroneously set "Display addresses" for users who haven't explicitly enabled it (Bitcoin-Qt) -Some non-ASCII input in JSON-RPC expecting hexadecimal may have been misinterpreted rather than rejected -Missing error condition checking added -Do not show green tick unless all known blocks are downloaded. Fixes #921 (Bitcoin-Qt) -Increase time ago of last block for "up to date" status from 30 to 90 minutes -Show a message box when runaway exception happens (Bitcoin-Qt) -Use a messagebox to display the error when -server is provided without providing a rpc password -Show error message instead of exception crash when unable to bind RPC port (Bitcoin-Qt) -Correct sign message bitcoin address tooltip. Fixes #1050 (Bitcoin-Qt) -Removed "(no label)" from QR Code dialog titlebar if we have no label (0.6.0.7) -Removed an ugly line break in tooltip for mature transactions (0.6.0.7) -Add missing tooltip and key shortcut in settings dialog (part of #1088) (Bitcoin-Qt) -Work around issue in boost::program_options that prevents from compiling in clang -Fixed bugs occurring only on platforms with unsigned characters (such as ARM). -Rename make_windows_icon.py to .sh as it is a shell script. Fixes #1099 (Bitcoin-Qt) -Various trivial internal corrections to types used for counting/size loops and warnings diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.6.0.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.6.0.md deleted file mode 100644 index 1963a3625..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.6.0.md +++ /dev/null @@ -1,138 +0,0 @@ -Bitcoin version 0.6.0 is now available for download at: -http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.6.0/test/ - -This release includes more than 20 language localizations. -More translations are welcome; join the -project at Transifex to help: -https://www.transifex.net/projects/p/bitcoin/ - -Please report bugs using the issue tracker at github: -https://github.com/bitcoin/bitcoin/issues - -Project source code is hosted at github; we are no longer -distributing .tar.gz files here, you can get them -directly from github: -https://github.com/bitcoin/bitcoin/tarball/v0.6.0 # .tar.gz -https://github.com/bitcoin/bitcoin/zipball/v0.6.0 # .zip - -For Ubuntu users, there is a ppa maintained by Matt Corallo which -you can add to your system so that it will automatically keep -bitcoin up-to-date. Just type -sudo apt-add-repository ppa:bitcoin/bitcoin -in your terminal, then install the bitcoin-qt package. - - -KNOWN ISSUES - -Shutting down while synchronizing with the network -(downloading the blockchain) can take more than a minute, -because database writes are queued to speed up download -time. - - -NEW FEATURES SINCE BITCOIN VERSION 0.5 - -Initial network synchronization should be much faster -(one or two hours on a typical machine instead of ten or more -hours). - -Backup Wallet menu option. - -Bitcoin-Qt can display and save QR codes for sending -and receiving addresses. - -New context menu on addresses to copy/edit/delete them. - -New Sign Message dialog that allows you to prove that you -own a bitcoin address by creating a digital -signature. - -New wallets created with this version will -use 33-byte 'compressed' public keys instead of -65-byte public keys, resulting in smaller -transactions and less traffic on the bitcoin -network. The shorter keys are already supported -by the network but wallet.dat files containing -short keys are not compatible with earlier -versions of Bitcoin-Qt/bitcoind. - -New command-line argument -blocknotify= -that will spawn a shell process to run -when a new block is accepted. - -New command-line argument -splash=0 to disable -Bitcoin-Qt's initial splash screen - -validateaddress JSON-RPC api command output includes -two new fields for addresses in the wallet: -pubkey : hexadecimal public key -iscompressed : true if pubkey is a short 33-byte key - -New JSON-RPC api commands for dumping/importing -private keys from the wallet (dumprivkey, importprivkey). - -New JSON-RPC api command for getting information about -blocks (getblock, getblockhash). - -New JSON-RPC api command (getmininginfo) for getting -extra information related to mining. The getinfo -JSON-RPC command no longer includes mining-related -information (generate/genproclimit/hashespersec). - - - -NOTABLE CHANGES - -BIP30 implemented (security fix for an attack involving -duplicate "coinbase transactions"). - -The -nolisten, -noupnp and -nodnsseed command-line -options were renamed to -listen, -upnp and -dnsseed, -with a default value of 1. The old names are still -supported for compatibility (so specifying -nolisten -is automatically interpreted as -listen=0; every -boolean argument can now be specified as either --foo or -nofoo). - -The -noirc command-line options was renamed to --irc, with a default value of 0. Run -irc=1 to -get the old behavior. - -Three fill-up-available-memory denial-of-service -attacks were fixed. - - -NOT YET IMPLEMENTED FEATURES - -Support for clicking on bitcoin: URIs and -opening/launching Bitcoin-Qt is available only on Linux, -and only if you configure your desktop to launch -Bitcoin-Qt. All platforms support dragging and dropping -bitcoin: URIs onto the Bitcoin-Qt window to start -payment. - - -PRELIMINARY SUPPORT FOR MULTISIGNATURE TRANSACTIONS - -This release has preliminary support for multisignature -transactions-- transactions that require authorization -from more than one person or device before they -will be accepted by the bitcoin network. - -Prior to this release, multisignature transactions -were considered 'non-standard' and were ignored; -with this release multisignature transactions are -considered standard and will start to be relayed -and accepted into blocks. - -It is expected that future releases of Bitcoin-Qt -will support the creation of multisignature transactions, -once enough of the network has upgraded so relaying -and validating them is robust. - -For this release, creation and testing of multisignature -transactions is limited to the bitcoin test network using -the "addmultisigaddress" JSON-RPC api call. - -Short multisignature address support is included in this -release, as specified in BIP 13 and BIP 16. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.6.1.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.6.1.md deleted file mode 100644 index ef7966ecd..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.6.1.md +++ /dev/null @@ -1,2 +0,0 @@ -Never released - diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.6.2.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.6.2.md deleted file mode 100644 index bb85fb23a..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.6.2.md +++ /dev/null @@ -1,50 +0,0 @@ -Bitcoin version 0.6.2 is now available for download at: -http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.6.2/ - -This is a bug-fix and code-cleanup release, with no major new features. - -Please report bugs using the github issue tracker at: -https://github.com/bitcoin/bitcoin/issues - - -NOTABLE CHANGES - -Much faster shutdowns. However, the blkindex.dat file is no longer -portable to different data directories by default. If you need a -portable blkindex.dat file then run with the new -detachdb=1 option -or the "Detach databases at shutdown" GUI preference. - -Fixed https://github.com/bitcoin/bitcoin/issues/1065, a bug that -could cause long-running nodes to crash. - -Mac and Windows binaries are compiled against OpenSSL 1.0.1b (Linux -binaries are dynamically linked to the version of OpenSSL on the system). - - -CHANGE SUMMARY - -Use 'git shortlog --no-merges v0.6.0..' for a summary of this release. - -Source codebase changes: -- Many source code cleanups and warnings fixes. Close to building with -Wall -- Locking overhaul, and several minor locking fixes -- Several source code portability fixes, e.g. FreeBSD - -JSON-RPC interface changes: -- addmultisigaddress enabled for mainnet (previously only enabled for testnet) - -Network protocol changes: -- protocol version 60001 -- added nonce value to "ping" message (BIP 31) -- added new "pong" message (BIP 31) - -Backend storage changes: -- Less redundant database flushing, especially during initial block download -- Shutdown improvements (see above) - -Qt user interface: -- minor URI handling improvements -- progressbar improvements -- error handling improvements (show message box rather than console exception, -etc.) -- by popular request, make 4th bar of connection icon green diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.6.3.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.6.3.md deleted file mode 100644 index 28bb20e10..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.6.3.md +++ /dev/null @@ -1,29 +0,0 @@ -Bitcoin version 0.6.3 is now available for download at: - http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.6.3/ - -This is a bug-fix release, with no new features. - -Please report bugs using the issue tracker at github: - https://github.com/bitcoin/bitcoin/issues - -CHANGE SUMMARY - -Fixed a serious denial-of-service attack that could cause the -bitcoin process to become unresponsive. Thanks to Sergio Lerner -for finding and responsibly reporting the problem. (CVE-2012-3789) - -Optimized the process of checking transaction signatures, to -speed up processing of new block messages and make propagating -blocks across the network faster. - -Fixed an obscure bug that could cause the bitcoin process to get -stuck on an invalid block-chain, if the invalid chain was -hundreds of blocks long. - -Bitcoin-Qt no longer automatically selects the first address -in the address book (Issue #1384). - -Fixed minimize-to-dock behavior of Bitcon-Qt on the Mac. - -Added a block checkpoint at block 185,333 to speed up initial -blockchain download. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.7.0.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.7.0.md deleted file mode 100644 index d33a58f99..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.7.0.md +++ /dev/null @@ -1,169 +0,0 @@ -Bitcoin version 0.7.0 is now available for download at: - http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.7.0/ - -We recommend that everybody running prior versions of bitcoind/Bitcoin-Qt -upgrade to this release, except for users running Mac OSX 10.5. - -Please report bugs using the issue tracker at github: - https://github.com/bitcoin/bitcoin/issues - -Project source code is hosted at github; you can get -source-only tarballs/zipballs directly from there: - https://github.com/bitcoin/bitcoin/tarball/v0.7.0 # .tar.gz - https://github.com/bitcoin/bitcoin/zipball/v0.7.0 # .zip - -Ubuntu Linux users can use the "Personal Package Archive" (PPA) -maintained by Matt Corallo to automatically keep -bitcoin up-to-date. Just type - sudo apt-add-repository ppa:bitcoin/bitcoin - sudo apt-get update -in your terminal, then install the bitcoin-qt package: - sudo apt-get install bitcoin-qt - - -How to Upgrade - -If you are running an older version, shut it down. Wait -until it has completely shut down (which might take a few minutes for older -versions), then run the installer (on Windows) or just copy over -Code: -/Applications/Bitcoin-Qt -(on Mac) or -Code: -bitcoind/bitcoin-qt -(on Linux). - -If you were running on Linux with a version that might have been compiled -with a different version of Berkeley DB (for example, if you were using the -PPA and are switching to the binary release), then run the old version again -with the -detachdb argument and shut it down; if you do not, then the new -version will not be able to read the database files and will exit with an error. - -Incompatible Changes - -* Replaced the 'getmemorypool' RPC command with 'getblocktemplate/submitblock' - and 'getrawmempool' commands. -* Remove deprecated RPC 'getblocknumber' - -Bitcoin Improvement Proposals implemented - -BIP 22 - 'getblocktemplate', 'submitblock' RPCs -BIP 34 - block version 2, height in coinbase -BIP 35 - 'mempool' message, extended 'getdata' message behavior - - -Core bitcoin handling and blockchain database - -* Reduced CPU usage, by eliminating some redundant hash calculations -* Cache signature verifications, to eliminate redundant signature checks -* Transactions with zero-value outputs are considered non-standard -* Mining: when creating new blocks, sort 'paid' area by fee-per-kb -* Database: better validation of on-disk stored data -* Database: minor optimizations and reliability improvements -* -loadblock=FILE will import an external block file -* Additional DoS (denial-of-service) prevention measures -* New blockchain checkpoint at block 193,000 - - -JSON-RPC API - -* Internal HTTP server is now thread-per-connection, rather than - a single-threaded queue that would stall on network I/O. -* Internal HTTP server supports HTTP/1.1, pipelined requests and - connection keep-alive. -* Support JSON-RPC 2.0 batches, to encapsulate multiple JSON-RPC requests - within a single HTTP request. -* IPv6 support -* Added raw transaction API. See https://gist.github.com/2839617 -* Added 'getrawmempool', to list contents of TX memory pool -* Added 'getpeerinfo', to list data about each connected network peer -* Added 'listaddressgroupings' for better coin control -* Rework getblock call. -* Remove deprecated RPC 'getblocknumber' -* Remove superceded RPC 'getmemorypool' (see BIP 22, above) -* listtransactions output now displays "smart" times for transactions, - and 'blocktime' and 'timereceived' fields were added - - -P2P networking - -* IPv6 support -* Tor hidden service support (see doc/Tor.txt) -* Attempts to fix "stuck blockchain download" problems -* Replace BDB database "addr.dat" with internally-managed "peers.dat" - file containing peer address data. -* Lower default send buffer from 10MB to 1MB -* proxy: SOCKS5 by default -* Support connecting by hostnames passed to proxy -* Add -seednode connections, and use this instead of DNS seeds when proxied -* Added -externalip and -discover -* Add -onlynet to connect only to a given network (IPv4, IPv6, or Tor) -* Separate listening sockets, -bind= - - -Qt GUI - -* Add UI RPC console / debug window -* Re-Enable URI handling on Windows, add safety checks and tray-notifications -* Harmonize the use of ellipsis ("...") to be used in menus, but not on buttons -* Add 2 labels to the overviewpage that display Wallet and Transaction status (obsolete or current) -* Extend the optionsdialog (e.g. language selection) and re-work it to a tabbed UI -* Merge sign/verify message into a single window with tabbed UI -* Ensure a changed bitcoin unit immediately updates all GUI elements that use units -* Update QR Code dialog -* Improve error reporting at startup -* Fine-grained UI updates for a much smoother UI during block downloads -* Remove autocorrection of 0/i in addresses in UI -* Reorganize tray icon menu into more logical order -* Persistently poll for balance change when number of blocks changed -* Much better translations -* Override progress bar design on platforms with segmented progress bars to assist with readability -* Added 'immature balance' display on the overview page -* (Windows only): enable ASLR and DEP for bitcoin-qt.exe -* (Windows only): add meta-data to bitcoin-qt.exe (e.g. description) - -Internal codebase - -* Additional unit tests -* Compile warning fixes - - -Miscellaneous - -* Reopen debug.log upon SIGHUP -* Bash programmable completion for bitcoind(1) -* On supported OS's, each thread is given a useful name - - -Thanks to everybody who contributed to this release: - -Chris Moore -Christian von Roques -David Joel Schwartz -Douglas Huff -Fordy -Gavin Andresen -Giel van Schijndel -Gregory Maxwell -Jeff Garzik -Luke Dashjr -Matt Corallo -Michael Ford -Michael Hendricks -Peter Todd -Philip Kaufmann -Pieter Wuille -R E Broadley -Ricardo M. Correia -Rune K. Svendsen -Scott Ellis -Stephane Glondu -Wladimir J. van der Laan -cardpuncher -coderrr -fanquake -grimd34th -sje397 -xanatos - -Thanks to Sergio Lerner for reporting denial-of-service vulnerabilities fixed in this release. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.7.1.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.7.1.md deleted file mode 100644 index 22e910c09..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.7.1.md +++ /dev/null @@ -1,110 +0,0 @@ -Bitcoin version 0.7.1 is now available from: - http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.7.1/ - -This is a bug-fix minor release. - -Please report bugs using the issue tracker at github: - https://github.com/bitcoin/bitcoin/issues - -Project source code is hosted at github; you can get -source-only tarballs/zipballs directly from there: - https://github.com/bitcoin/bitcoin/tarball/v0.7.1 # .tar.gz - https://github.com/bitcoin/bitcoin/zipball/v0.7.1 # .zip - -Ubuntu Linux users can use the "Personal Package Archive" (PPA) -maintained by Matt Corallo to automatically keep -up-to-date. Just type: - sudo apt-add-repository ppa:bitcoin/bitcoin - sudo apt-get update -in your terminal, then install the bitcoin-qt package: - sudo apt-get install bitcoin-qt - -KNOWN ISSUES ------------- - -Mac OSX 10.5 is no longer supported. - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait -until it has completely shut down (which might take a few minutes for older -versions), then run the installer (on Windows) or just copy over -/Applications/Bitcoin-Qt (on Mac) or bitcoind/bitcoin-qt (on Linux). - -If you were running on Linux with a version that might have been compiled -with a different version of Berkeley DB (for example, if you were using an -Ubuntu PPA version), then run the old version again with the -detachdb -argument and shut it down; if you do not, then the new version will not -be able to read the database files and will exit with an error. - -Explanation of -detachdb (and the new "stop true" RPC command): -The Berkeley DB database library stores data in both ".dat" and -"log" files, so the database is always in a consistent state, -even in case of power failure or other sudden shutdown. The -format of the ".dat" files is portable between different -versions of Berkeley DB, but the "log" files are not-- even minor -version differences may have incompatible "log" files. The --detachdb option moves any pending changes from the "log" files -to the "blkindex.dat" file for maximum compatibility, but makes -shutdown much slower. Note that the "wallet.dat" file is always -detached, and versions prior to 0.6.0 detached all databases -at shutdown. - -New features ------------- - -* Added a boolean argument to the RPC 'stop' command, if true sets - -detachdb to create standalone database .dat files before shutting down. - -* -salvagewallet command-line option, which moves any existing wallet.dat - to wallet.{timestamp}.dat and then attempts to salvage public/private - keys and master encryption keys (if the wallet is encrypted) into - a new wallet.dat. This should only be used if your wallet becomes - corrupted, and is not intended to replace regular wallet backups. - -* Import $DataDir/bootstrap.dat automatically, if it exists. - -Dependency changes ------------------- - -* Qt 4.8.2 for Windows builds - -* openssl 1.0.1c - -Bug fixes ---------- - -* Clicking on a bitcoin: URI on Windows should now launch Bitcoin-Qt properly. - -* When running -testnet, use RPC port 18332 by default. - -* Better detection and handling of corrupt wallet.dat and blkindex.dat files. - Previous versions would crash with a DB_RUNRECOVERY exception, this - version detects most problems and tells you how to recover if it - cannot recover itself. - -* Fixed an uninitialized variable bug that could cause transactions to - be reported out of order. - -* Fixed a bug that could cause occasional crashes on exit. - -* Warn the user that they need to create fresh wallet backups after they - encrypt their wallet. - ----------------------------------------------------- -Thanks to everybody who contributed to this release: - -Gavin Andresen -Jeff Garzik -Luke Dashjr -Mark Friedenbach -Matt Corallo -Philip Kaufmann -Pieter Wuille -Rune K. Svendsen -Virgil Dupras -Wladimir J. van der Laan -fanquake -kjj2 -xanatos diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.7.2.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.7.2.md deleted file mode 100644 index 40af34962..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.7.2.md +++ /dev/null @@ -1,68 +0,0 @@ -Bitcoin version 0.7.2 is now available from: - http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.7.2 - -This is a bug-fix minor release. - -Please report bugs using the issue tracker at github: - https://github.com/bitcoin/bitcoin/issues - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait -until it has completely shut down (which might take a few minutes for older -versions), then run the installer (on Windows) or just copy over -/Applications/Bitcoin-Qt (on Mac) or bitcoind/bitcoin-qt (on Linux). - -If you were running on Linux with a version that might have been compiled -with a different version of Berkeley DB (for example, if you were using an -Ubuntu PPA version), then run the old version again with the -detachdb -argument and shut it down; if you do not, then the new version will not -be able to read the database files and will exit with an error. - -Explanation of -detachdb (and the new "stop true" RPC command): -The Berkeley DB database library stores data in both ".dat" and -"log" files, so the database is always in a consistent state, -even in case of power failure or other sudden shutdown. The -format of the ".dat" files is portable between different -versions of Berkeley DB, but the "log" files are not-- even minor -version differences may have incompatible "log" files. The --detachdb option moves any pending changes from the "log" files -to the "blkindex.dat" file for maximum compatibility, but makes -shutdown much slower. Note that the "wallet.dat" file is always -detached, and versions prior to 0.6.0 detached all databases -at shutdown. - -Bug fixes ---------- - -* Prevent RPC 'move' from deadlocking. This was caused by trying to lock the - database twice. - -* Fix use-after-free problems in initialization and shutdown, the latter of - which caused Bitcoin-Qt to crash on Windows when exiting. - -* Correct library linking so building on Windows natively works. - -* Avoid a race condition and out-of-bounds read in block creation/mining code. - -* Improve platform compatibility quirks, including fix for 100% CPU utilization - on FreeBSD 9. - -* A few minor corrections to error handling, and updated translations. - -* OSX 10.5 supported again - ----------------------------------------------------- -Thanks to everybody who contributed to this release: - -Alex -dansmith -Gavin Andresen -Gregory Maxwell -Jeff Garzik -Luke Dashjr -Philip Kaufmann -Pieter Wuille -Wladimir J. van der Laan -grimd34th diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.0.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.0.md deleted file mode 100644 index 4e98a7740..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.0.md +++ /dev/null @@ -1,139 +0,0 @@ -Bitcoin-Qt version 0.8.0 is now available from: - http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.0/ - -This is a major release designed to improve performance and handle the -increasing volume of transactions on the network. - -Please report bugs using the issue tracker at github: - https://github.com/bitcoin/bitcoin/issues - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait -until it has completely shut down (which might take a few minutes for older -versions), then run the installer (on Windows) or just copy over -/Applications/Bitcoin-Qt (on Mac) or bitcoind/bitcoin-qt (on Linux). - -The first time you run after the upgrade a re-indexing process will be -started that will take anywhere from 30 minutes to several hours, -depending on the speed of your machine. - -Incompatible Changes --------------------- - -This release no longer maintains a full index of historical transaction ids -by default, so looking up an arbitrary transaction using the getrawtransaction -RPC call will not work. If you need that functionality, you must run once -with -txindex=1 -reindex=1 to rebuild block-chain indices (see below for more -details). - -Improvements ------------- - -Mac and Windows binaries are signed with certificates owned by the Bitcoin -Foundation, to be compatible with the new security features in OSX 10.8 and -Windows 8. - -LevelDB, a fast, open-source, non-relational database from Google, is -now used to store transaction and block indices. LevelDB works much better -on machines with slow I/O and is faster in general. Berkeley DB is now only -used for the wallet.dat file (public and private wallet keys and transactions -relevant to you). - -Pieter Wuille implemented many optimizations to the way transactions are -verified, so a running, synchronized node uses less working memory and does -much less I/O. He also implemented parallel signature checking, so if you -have a multi-CPU machine all CPUs will be used to verify transactions. - -New Features ------------- - -"Bloom filter" support in the network protocol for sending only relevant transactions to -lightweight clients. - -contrib/verifysfbinaries is a shell-script to verify that the binary downloads -at sourceforge have not been tampered with. If you are able, you can help make -everybody's downloads more secure by running this occasionally to check PGP -signatures against download file checksums. - -contrib/spendfrom is a python-language command-line utility that demonstrates -how to use the "raw transactions" JSON-RPC api to send coins received from particular -addresses (also known as "coin control"). - -New/changed settings (command-line or bitcoin.conf file) --------------------------------------------------------- - -dbcache : controls LevelDB memory usage. - -par : controls how many threads to use to validate transactions. Defaults to the number -of CPUs on your machine, use -par=1 to limit to a single CPU. - -txindex : maintains an extra index of old, spent transaction ids so they will be found -by the getrawtransaction JSON-RPC method. - -reindex : rebuild block and transaction indices from the downloaded block data. - -New JSON-RPC API Features -------------------------- - -lockunspent / listlockunspent allow locking transaction outputs for a period of time so -they will not be spent by other processes that might be accessing the same wallet. - -addnode / getaddednodeinfo methods, to connect to specific peers without restarting. - -importprivkey now takes an optional boolean parameter (default true) to control whether -or not to rescan the blockchain for transactions after importing a new private key. - -Important Bug Fixes -------------------- - -Privacy leak: the position of the "change" output in most transactions was not being -properly randomized, making network analysis of the transaction graph to identify -users' wallets easier. - -Zero-confirmation transaction vulnerability: accepting zero-confirmation transactions -(transactions that have not yet been included in a block) from somebody you do not -trust is still not recommended, because there will always be ways for attackers to -double-spend zero-confirmation transactions. However, this release includes a bug -fix that makes it a little bit more difficult for attackers to double-spend a -certain type ("lockTime in the future") of zero-confirmation transaction. - -Dependency Changes ------------------- - -Qt 4.8.3 (compiling against older versions of Qt 4 should continue to work) - - -Thanks to everybody who contributed to this release: ----------------------------------------------------- - -Alexander Kjeldaas -Andrey Alekseenko -Arnav Singh -Christian von Roques -Eric Lombrozo -Forrest Voight -Gavin Andresen -Gregory Maxwell -Jeff Garzik -Luke Dashjr -Matt Corallo -Mike Cassano -Mike Hearn -Peter Todd -Philip Kaufmann -Pieter Wuille -Richard Schwab -Robert Backhaus -Rune K. Svendsen -Sergio Demian Lerner -Wladimir J. van der Laan -burger2 -default -fanquake -grimd34th -justmoon -redshark1802 -tucenaber -xanatos diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.1.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.1.md deleted file mode 100644 index 4fd546bee..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.1.md +++ /dev/null @@ -1,22 +0,0 @@ -Bitcoin-Qt/bitcoind version 0.8.1 is now available from: - http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.1/ - -This is a maintenance release that adds a new network rule to avoid -a chain-forking incompatibility with versions 0.7.2 and earlier. - -Please report bugs using the issue tracker at github: - https://github.com/bitcoin/bitcoin/issues - - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait -until it has completely shut down (which might take a few minutes for older -versions), then run the installer (on Windows) or just copy over -/Applications/Bitcoin-Qt (on Mac) or bitcoind/bitcoin-qt (on Linux). - -If you are upgrading from version 0.7.2 or earlier, the first time you -run 0.8.1 your blockchain files will be re-indexed, which will take -anywhere from 30 minutes to several hours, depending on the speed of -your machine. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.2.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.2.md deleted file mode 100644 index eea9ba2a2..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.2.md +++ /dev/null @@ -1,137 +0,0 @@ -Bitcoin-Qt version 0.8.2 is now available from: - http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.2/ - -This is a maintenance release that fixes many bugs and includes -a few small new features. - -Please report bugs using the issue tracker at github: - https://github.com/bitcoin/bitcoin/issues - - -How to Upgrade - -If you are running an older version, shut it down. Wait -until it has completely shut down (which might take a few minutes for older -versions), then run the installer (on Windows) or just copy over -/Applications/Bitcoin-Qt (on Mac) or bitcoind/bitcoin-qt (on Linux). - -If you are upgrading from version 0.7.2 or earlier, the first time you -run 0.8.2 your blockchain files will be re-indexed, which will take -anywhere from 30 minutes to several hours, depending on the speed of -your machine. - -0.8.2 Release notes - -Fee Policy changes - -The default fee for low-priority transactions is lowered from 0.0005 BTC -(for each 1,000 bytes in the transaction; an average transaction is -about 500 bytes) to 0.0001 BTC. - -Payments (transaction outputs) of 0.543 times the minimum relay fee -(0.00005430 BTC) are now considered 'non-standard', because storing them -costs the network more than they are worth and spending them will usually -cost their owner more in transaction fees than they are worth. - -Non-standard transactions are not relayed across the network, are not included -in blocks by most miners, and will not show up in your wallet until they are -included in a block. - -The default fee policy can be overridden using the -mintxfee and -minrelaytxfee -command-line options, but note that we intend to replace the hard-coded fees -with code that automatically calculates and suggests appropriate fees in the -0.9 release and note that if you set a fee policy significantly different from -the rest of the network your transactions may never confirm. - -Bitcoin-Qt changes - -* New icon and splash screen -* Improve reporting of synchronization process -* Remove hardcoded fee recommendations -* Improve metadata of executable on MacOSX and Windows -* Move export button to individual tabs instead of toolbar -* Add "send coins" command to context menu in address book -* Add "copy txid" command to copy transaction IDs from transaction overview -* Save & restore window size and position when showing & hiding window -* New translations: Arabic (ar), Bosnian (bs), Catalan (ca), Welsh (cy), - Esperanto (eo), Interlingua (la), Latvian (lv) and many improvements - to current translations - -MacOSX: -* OSX support for click-to-pay (bitcoin:) links -* Fix GUI disappearing problem on MacOSX (issue #1522) - -Linux/Unix: -* Copy addresses to middle-mouse-button clipboard - - -Command-line options - -* -walletnotify will call a command on receiving transactions that affect the wallet. -* -alertnotify will call a command on receiving an alert from the network. -* -par now takes a negative number, to leave a certain amount of cores free. - -JSON-RPC API changes - -* fixed a getblocktemplate bug that caused excessive CPU creating blocks. -* listunspent now lists account and address information. -* getinfo now also returns the time adjustment estimated from your peers. -* getpeerinfo now returns bytessent, bytesrecv and syncnode. -* gettxoutsetinfo returns statistics about the unspent transaction output database. -* gettxout returns information about a specific unspent transaction output. - - -Networking changes - -* Significant changes to the networking code, reducing latency and memory consumption. -* Avoid initial block download stalling. -* Remove IRC seeding support. -* Performance tweaks. -* Added testnet DNS seeds. - -Wallet compatibility/rescuing - -* Cases where wallets cannot be opened in another version/installation should be reduced. -* -salvagewallet now works for encrypted wallets. - - -Known Bugs - -* Entering the 'getblocktemplate' or 'getwork' RPC commands into the Bitcoin-Qt debug -console will cause Bitcoin-Qt to crash. Run Bitcoin-Qt with the -server command-line -option to workaround. - -Thanks to everybody who contributed to the 0.8.2 release! - -APerson241 -Andrew Poelstra -Calvin Owens -Chuck LeDuc Díaz -Colin Dean -David Griffith -David Serrano -Eric Lombrozo -Gavin Andresen -Gregory Maxwell -Jeff Garzik -Jonas Schnelli -Larry Gilbert -Luke Dashjr -Matt Corallo -Michael Ford -Mike Hearn -Patrick Brown -Peter Todd -Philip Kaufmann -Pieter Wuille -Richard Schwab -Roman Mindalev -Scott Howard -Tariq Bashir -Warren Togami -Wladimir J. van der Laan -freewil -gladoscc -kjj2 -mb300sd -super3 diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.3.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.3.md deleted file mode 100644 index 856c20aa3..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.3.md +++ /dev/null @@ -1,18 +0,0 @@ -Bitcoin-Qt version 0.8.3 is now available from: - http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.3/ - -This is a maintenance release to fix a denial-of-service attack that -can cause nodes to crash. - -Please report bugs using the issue tracker at github: - https://github.com/bitcoin/bitcoin/issues - -0.8.3 Release notes - -Truncate over-size messages to prevent a memory exhaustion attack. - -Fix a regression that causes excessive re-writing of the 'peers.dat' file. - - -Thanks to Peter Todd for responsibly disclosing the vulnerability -( CVE-2013-4627 ) and creating a fix. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.4.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.4.md deleted file mode 100644 index c6f31f1fa..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.4.md +++ /dev/null @@ -1,83 +0,0 @@ -Bitcoin-Qt version 0.8.4 is now available from: - http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.4/ - -This is a maintenance release to fix a critical bug and three -security issues; we urge all users to upgrade. - -Please report bugs using the issue tracker at github: - https://github.com/bitcoin/bitcoin/issues - - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait -until it has completely shut down (which might take a few minutes for older -versions), then run the installer (on Windows) or just copy over -/Applications/Bitcoin-Qt (on Mac) or bitcoind/bitcoin-qt (on Linux). - -If you are upgrading from version 0.7.2 or earlier, the first time you -run 0.8.4 your blockchain files will be re-indexed, which will take -anywhere from 30 minutes to several hours, depending on the speed of -your machine. - -0.8.4 Release notes -=================== - -Security issues ---------------- - -An attacker could send a series of messages that resulted in -an integer division-by-zero error in the Bloom Filter handling -code, causing the Bitcoin-Qt or bitcoind process to crash. -Bloom filters were introduced with version 0.8, so versions 0.8.0 -through 0.8.3 are vulnerable to this critical denial-of-service attack. - -A constant-time algorithm is now used to check RPC password -guess attempts; fixes https://github.com/bitcoin/bitcoin/issues/2838 -(CVE-2013-4165) - -Implement a better fix for the fill-memory-with-orphan-transactions -attack that was fixed in 0.8.3. See -https://bitslog.wordpress.com/2013/07/18/buggy-cve-2013-4627-patch-open-new-vectors-of-attack/ -for a description of the weaknesses of the previous fix. -(CVE-2013-4627) - -Bugs fixed ----------- - -Fix multi-block reorg transaction resurrection. - -Fix non-standard disconnected transactions causing mempool orphans. -This bug could cause nodes running with the -debug flag to crash. - -OSX: use 'FD_FULLSYNC' with LevelDB, which will (hopefully!) -prevent the database corruption issues many people have -experienced on OSX. - -Linux: clicking on bitcoin: links was broken if you were using -a Gnome-based desktop. - -Fix a hang-at-shutdown bug that only affects users that compile -their own version of Bitcoin against Boost versions 1.50-1.52. - -Other changes -------------- - -Checkpoint at block 250,000 to speed up initial block downloads -and make the progress indicator when downloading more accurate. - - -Thanks to everybody who contributed to the 0.8.4 releases! ----------------------------------------------------------- - -Pieter Wuille -Warren Togami -Patrick Strateman -pakt -Gregory Maxwell -Sergio Demian Lerner -grayleonard -Cory Fields -Matt Corallo -Gavin Andresen diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.5.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.5.md deleted file mode 100644 index aa93fe7c7..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.5.md +++ /dev/null @@ -1,44 +0,0 @@ -Bitcoin-Qt version 0.8.5 is now available from: - http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.5/ - -This is a maintenance release to fix a critical bug; -we urge all users to upgrade. - -Please report bugs using the issue tracker at github: - https://github.com/bitcoin/bitcoin/issues - - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait -until it has completely shut down (which might take a few minutes for older -versions), then run the installer (on Windows) or just copy over -/Applications/Bitcoin-Qt (on Mac) or bitcoind/bitcoin-qt (on Linux). - -If you are upgrading from version 0.7.2 or earlier, the first time you -run 0.8.5 your blockchain files will be re-indexed, which will take -anywhere from 30 minutes to several hours, depending on the speed of -your machine. - -0.8.5 Release notes -=================== - -Bugs fixed ----------- - -Transactions with version numbers larger than 0x7fffffff were -incorrectly being relayed and included in blocks. - -Blocks containing transactions with version numbers larger -than 0x7fffffff caused the code that checks for LevelDB database -inconsistencies at startup to erroneously report database -corruption and suggest that you reindex your database. - -This release also contains a non-critical fix to the code that -enforces BIP 34 (block height in the coinbase transaction). - --- - -Thanks to Gregory Maxwell and Pieter Wuille for quickly -identifying and fixing the transaction version number bug. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.6.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.6.md deleted file mode 100644 index 39a45e0db..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.8.6.md +++ /dev/null @@ -1,66 +0,0 @@ -Bitcoin-Qt version 0.8.6 final is now available from: - - http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.6/ - -This is a maintenance release to fix a critical bug; we urge all users to upgrade. - -Please report bugs using the issue tracker at github: - - https://github.com/bitcoin/bitcoin/issues - -How to Upgrade --------------- - -If you already downloaded 0.8.6rc1 you do not need to re-download. This release is exactly the same. - -If you are running an older version, shut it down. Wait -until it has completely shut down (which might take a few minutes for older -versions), then run the installer (on Windows) or just copy over -/Applications/Bitcoin-Qt (on Mac) or bitcoind/bitcoin-qt (on Linux). - -If you are upgrading from version 0.7.2 or earlier, the first time you -run 0.8.6 your blockchain files will be re-indexed, which will take -anywhere from 30 minutes to several hours, depending on the speed of -your machine. - -0.8.6 Release notes -=================== - -- Default block size increase for miners. - (see https://gist.github.com/gavinandresen/7670433#086-accept-into-block) - -- Remove the all-outputs-must-be-greater-than-CENT-to-qualify-as-free rule for relaying - (see https://gist.github.com/gavinandresen/7670433#086-relaying) - -- Lower maximum size for free transaction creation - (see https://gist.github.com/gavinandresen/7670433#086-wallet) - -- OSX block chain database corruption fixes - - Update leveldb to 1.13 - - Use fcntl with `F_FULLSYNC` instead of fsync on OSX - - Use native Darwin memory barriers - - Replace use of mmap in leveldb for improved reliability (only on OSX) - -- Fix nodes forwarding transactions with empty vins and getting banned - -- Network code performance and robustness improvements - -- Additional debug.log logging for diagnosis of network problems, log timestamps by default - -- Fix Bitcoin-Qt startup crash when clicking dock icon on OSX - -- Fix memory leaks in CKey::SetCompactSignature() and Key::SignCompact() - -- Fix rare GUI crash on send - -- Various small GUI, documentation and build fixes - -Warning -------- - -- There have been frequent reports of users running out of virtual memory on 32-bit systems - during the initial sync. - Hence it is recommended to use a 64-bit executable if possible. - A 64-bit executable for Windows is planned for 0.9. - -Note: Gavin Andresen's GPG signing key for SHA256SUMS.asc has been changed from key id 1FC730C1 to sub key 7BF6E212 (see https://github.com/bitcoin/bitcoin.org/pull/279). diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.0.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.0.md deleted file mode 100644 index 170410ca4..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.0.md +++ /dev/null @@ -1,411 +0,0 @@ -Bitcoin Core version 0.9.0 is now available from: - - https://bitcoin.org/bin/0.9.0/ - -This is a new major version release, bringing both new features and -bug fixes. - -Please report bugs using the issue tracker at github: - - https://github.com/bitcoin/bitcoin/issues - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), uninstall all -earlier versions of Bitcoin, then run the installer (on Windows) or just copy -over /Applications/Bitcoin-Qt (on Mac) or bitcoind/bitcoin-qt (on Linux). - -If you are upgrading from version 0.7.2 or earlier, the first time you run -0.9.0 your blockchain files will be re-indexed, which will take anywhere from -30 minutes to several hours, depending on the speed of your machine. - -On Windows, do not forget to uninstall all earlier versions of the Bitcoin -client first, especially if you are switching to the 64-bit version. - -Windows 64-bit installer -------------------------- - -New in 0.9.0 is the Windows 64-bit version of the client. There have been -frequent reports of users running out of virtual memory on 32-bit systems -during the initial sync. Because of this it is recommended to install the -64-bit version if your system supports it. - -NOTE: Release candidate 2 Windows binaries are not code-signed; use PGP -and the SHA256SUMS.asc file to make sure your binaries are correct. -In the final 0.9.0 release, Windows setup.exe binaries will be code-signed. - -OSX 10.5 / 32-bit no longer supported -------------------------------------- - -0.9.0 drops support for older Macs. The minimum requirements are now: -* A 64-bit-capable CPU (see http://support.apple.com/kb/ht3696); -* Mac OS 10.6 or later (see https://support.apple.com/kb/ht1633). - -Downgrading warnings --------------------- - -The 'chainstate' for this release is not always compatible with previous -releases, so if you run 0.9 and then decide to switch back to a -0.8.x release you might get a blockchain validation error when starting the -old release (due to 'pruned outputs' being omitted from the index of -unspent transaction outputs). - -Running the old release with the -reindex option will rebuild the chainstate -data structures and correct the problem. - -Also, the first time you run a 0.8.x release on a 0.9 wallet it will rescan -the blockchain for missing spent coins, which will take a long time (tens -of minutes on a typical machine). - -Rebranding to Bitcoin Core ---------------------------- - -To reduce confusion between Bitcoin-the-network and Bitcoin-the-software we -have renamed the reference client to Bitcoin Core. - - -OP_RETURN and data in the block chain -------------------------------------- -On OP_RETURN: There was been some confusion and misunderstanding in -the community, regarding the OP_RETURN feature in 0.9 and data in the -blockchain. This change is not an endorsement of storing data in the -blockchain. The OP_RETURN change creates a provably-prunable output, -to avoid data storage schemes -- some of which were already deployed -- -that were storing arbitrary data such as images as forever-unspendable -TX outputs, bloating bitcoin's UTXO database. - -Storing arbitrary data in the blockchain is still a bad idea; it is less -costly and far more efficient to store non-currency data elsewhere. - -Autotools build system ------------------------ - -For 0.9.0 we switched to an autotools-based build system instead of individual -(q)makefiles. - -Using the standard "./autogen.sh; ./configure; make" to build Bitcoin-Qt and -bitcoind makes it easier for experienced open source developers to contribute -to the project. - -Be sure to check doc/build-*.md for your platform before building from source. - -Bitcoin-cli -------------- - -Another change in the 0.9 release is moving away from the bitcoind executable -functioning both as a server and as a RPC client. The RPC client functionality -("tell the running bitcoin daemon to do THIS") was split into a separate -executable, 'bitcoin-cli'. The RPC client code will eventually be removed from -bitcoind, but will be kept for backwards compatibility for a release or two. - -`walletpassphrase` RPC ------------------------ - -The behavior of the `walletpassphrase` RPC when the wallet is already unlocked -has changed between 0.8 and 0.9. - -The 0.8 behavior of `walletpassphrase` is to fail when the wallet is already unlocked: - - > walletpassphrase 1000 - walletunlocktime = now + 1000 - > walletpassphrase 10 - Error: Wallet is already unlocked (old unlock time stays) - -The new behavior of `walletpassphrase` is to set a new unlock time overriding -the old one: - - > walletpassphrase 1000 - walletunlocktime = now + 1000 - > walletpassphrase 10 - walletunlocktime = now + 10 (overriding the old unlock time) - -Transaction malleability-related fixes --------------------------------------- - -This release contains a few fixes for transaction ID (TXID) malleability -issues: - -- -nospendzeroconfchange command-line option, to avoid spending - zero-confirmation change -- IsStandard() transaction rules tightened to prevent relaying and mining of - mutated transactions -- Additional information in listtransactions/gettransaction output to - report wallet transactions that conflict with each other because - they spend the same outputs. -- Bug fixes to the getbalance/listaccounts RPC commands, which would report - incorrect balances for double-spent (or mutated) transactions. -- New option: -zapwallettxes to rebuild the wallet's transaction information - -Transaction Fees ----------------- - -This release drops the default fee required to relay transactions across the -network and for miners to consider the transaction in their blocks to -0.01mBTC per kilobyte. - -Note that getting a transaction relayed across the network does NOT guarantee -that the transaction will be accepted by a miner; by default, miners fill -their blocks with 50 kilobytes of high-priority transactions, and then with -700 kilobytes of the highest-fee-per-kilobyte transactions. - -The minimum relay/mining fee-per-kilobyte may be changed with the -minrelaytxfee option. Note that previous releases incorrectly used -the mintxfee setting to determine which low-priority transactions should -be considered for inclusion in blocks. - -The wallet code still uses a default fee for low-priority transactions of -0.1mBTC per kilobyte. During periods of heavy transaction volume, even this -fee may not be enough to get transactions confirmed quickly; the mintxfee -option may be used to override the default. - -0.9.0 Release notes -======================= - -RPC: - -- New notion of 'conflicted' transactions, reported as confirmations: -1 -- 'listreceivedbyaddress' now provides tx ids -- Add raw transaction hex to 'gettransaction' output -- Updated help and tests for 'getreceivedby(account|address)' -- In 'getblock', accept 2nd 'verbose' parameter, similar to getrawtransaction, - but defaulting to 1 for backward compatibility -- Add 'verifychain', to verify chain database at runtime -- Add 'dumpwallet' and 'importwallet' RPCs -- 'keypoolrefill' gains optional size parameter -- Add 'getbestblockhash', to return tip of best chain -- Add 'chainwork' (the total work done by all blocks since the genesis block) - to 'getblock' output -- Make RPC password resistant to timing attacks -- Clarify help messages and add examples -- Add 'getrawchangeaddress' call for raw transaction change destinations -- Reject insanely high fees by default in 'sendrawtransaction' -- Add RPC call 'decodescript' to decode a hex-encoded transaction script -- Make 'validateaddress' provide redeemScript -- Add 'getnetworkhashps' to get the calculated network hashrate -- New RPC 'ping' command to request ping, new 'pingtime' and 'pingwait' fields - in 'getpeerinfo' output -- Adding new 'addrlocal' field to 'getpeerinfo' output -- Add verbose boolean to 'getrawmempool' -- Add rpc command 'getunconfirmedbalance' to obtain total unconfirmed balance -- Explicitly ensure that wallet is unlocked in `importprivkey` -- Add check for valid keys in `importprivkey` - -Command-line options: - -- New option: -nospendzeroconfchange to never spend unconfirmed change outputs -- New option: -zapwallettxes to rebuild the wallet's transaction information -- Rename option '-tor' to '-onion' to better reflect what it does -- Add '-disablewallet' mode to let bitcoind run entirely without wallet (when - built with wallet) -- Update default '-rpcsslciphers' to include TLSv1.2 -- make '-logtimestamps' default on and rework help-message -- RPC client option: '-rpcwait', to wait for server start -- Remove '-logtodebugger' -- Allow `-noserver` with bitcoind - -Block-chain handling and storage: - -- Update leveldb to 1.15 -- Check for correct genesis (prevent cases where a datadir from the wrong - network is accidentally loaded) -- Allow txindex to be removed and add a reindex dialog -- Log aborted block database rebuilds -- Store orphan blocks in serialized form, to save memory -- Limit the number of orphan blocks in memory to 750 -- Fix non-standard disconnected transactions causing mempool orphans -- Add a new checkpoint at block 279,000 - -Wallet: - -- Bug fixes and new regression tests to correctly compute - the balance of wallets containing double-spent (or mutated) transactions -- Store key creation time. Calculate whole-wallet birthday. -- Optimize rescan to skip blocks prior to birthday -- Let user select wallet file with -wallet=foo.dat -- Consider generated coins mature at 101 instead of 120 blocks -- Improve wallet load time -- Don't count txins for priority to encourage sweeping -- Don't create empty transactions when reading a corrupted wallet -- Fix rescan to start from beginning after importprivkey -- Only create signatures with low S values - -Mining: - -- Increase default -blockmaxsize/prioritysize to 750K/50K -- 'getblocktemplate' does not require a key to create a block template -- Mining code fee policy now matches relay fee policy - -Protocol and network: - -- Drop the fee required to relay a transaction to 0.01mBTC per kilobyte -- Send tx relay flag with version -- New 'reject' P2P message (BIP 0061, see - https://gist.github.com/gavinandresen/7079034 for draft) -- Dump addresses every 15 minutes instead of 10 seconds -- Relay OP_RETURN data TxOut as standard transaction type -- Remove CENT-output free transaction rule when relaying -- Lower maximum size for free transaction creation -- Send multiple inv messages if mempool.size > MAX_INV_SZ -- Split MIN_PROTO_VERSION into INIT_PROTO_VERSION and MIN_PEER_PROTO_VERSION -- Do not treat fFromMe transaction differently when broadcasting -- Process received messages one at a time without sleeping between messages -- Improve logging of failed connections -- Bump protocol version to 70002 -- Add some additional logging to give extra network insight -- Added new DNS seed from bitcoinstats.com - -Validation: - -- Log reason for non-standard transaction rejection -- Prune provably-unspendable outputs, and adapt consistency check for it. -- Detect any sufficiently long fork and add a warning -- Call the -alertnotify script when we see a long or invalid fork -- Fix multi-block reorg transaction resurrection -- Reject non-canonically-encoded serialization sizes -- Reject dust amounts during validation -- Accept nLockTime transactions that finalize in the next block - -Build system: - -- Switch to autotools-based build system -- Build without wallet by passing `--disable-wallet` to configure, this - removes the BerkeleyDB dependency -- Upgrade gitian dependencies (libpng, libz, libupnpc, boost, openssl) to more - recent versions -- Windows 64-bit build support -- Solaris compatibility fixes -- Check integrity of gitian input source tarballs -- Enable full GCC Stack-smashing protection for all OSes - -GUI: - -- Switch to Qt 5.2.0 for Windows build -- Add payment request (BIP 0070) support -- Improve options dialog -- Show transaction fee in new send confirmation dialog -- Add total balance in overview page -- Allow user to choose data directory on first start, when data directory is - missing, or when the -choosedatadir option is passed -- Save and restore window positions -- Add vout index to transaction id in transactions details dialog -- Add network traffic graph in debug window -- Add open URI dialog -- Add Coin Control Features -- Improve receive coins workflow: make the 'Receive' tab into a form to request - payments, and move historical address list functionality to File menu. -- Rebrand to `Bitcoin Core` -- Move initialization/shutdown to a thread. This prevents "Not responding" - messages during startup. Also show a window during shutdown. -- Don't regenerate autostart link on every client startup -- Show and store message of normal bitcoin:URI -- Fix richtext detection hang issue on very old Qt versions -- OS X: Make use of the 10.8+ user notification center to display Growl-like - notifications -- OS X: Added NSHighResolutionCapable flag to Info.plist for better font - rendering on Retina displays. -- OS X: Fix bitcoin-qt startup crash when clicking dock icon -- Linux: Fix Gnome bitcoin: URI handler - -Miscellaneous: - -- Add Linux script (contrib/qos/tc.sh) to limit outgoing bandwidth -- Add '-regtest' mode, similar to testnet but private with instant block - generation with 'setgenerate' RPC. -- Add 'linearize.py' script to contrib, for creating bootstrap.dat -- Add separate bitcoin-cli client - -Credits --------- - -Thanks to everyone who contributed to this release: - -- Andrey -- Ashley Holman -- b6393ce9-d324-4fe1-996b-acf82dbc3d53 -- bitsofproof -- Brandon Dahler -- Calvin Tam -- Christian Decker -- Christian von Roques -- Christopher Latham -- Chuck -- coblee -- constantined -- Cory Fields -- Cozz Lovan -- daniel -- Daniel Larimer -- David Hill -- Dmitry Smirnov -- Drak -- Eric Lombrozo -- fanquake -- fcicq -- Florin -- frewil -- Gavin Andresen -- Gregory Maxwell -- gubatron -- Guillermo Céspedes Tabárez -- Haakon Nilsen -- HaltingState -- Han Lin Yap -- harry -- Ian Kelling -- Jeff Garzik -- Johnathan Corgan -- Jonas Schnelli -- Josh Lehan -- Josh Triplett -- Julian Langschaedel -- Kangmo -- Lake Denman -- Luke Dashjr -- Mark Friedenbach -- Matt Corallo -- Michael Bauer -- Michael Ford -- Michagogo -- Midnight Magic -- Mike Hearn -- Nils Schneider -- Noel Tiernan -- Olivier Langlois -- patrick s -- Patrick Strateman -- paveljanik -- Peter Todd -- phantomcircuit -- phelixbtc -- Philip Kaufmann -- Pieter Wuille -- Rav3nPL -- R E Broadley -- regergregregerrge -- Robert Backhaus -- Roman Mindalev -- Rune K. Svendsen -- Ryan Niebur -- Scott Ellis -- Scott Willeke -- Sergey Kazenyuk -- Shawn Wilkinson -- Sined -- sje -- Subo1978 -- super3 -- Tamas Blummer -- theuni -- Thomas Holenstein -- Timon Rapp -- Timothy Stranex -- Tom Geller -- Torstein Husebø -- Vaclav Vobornik -- vhf / victor felder -- Vinnie Falco -- Warren Togami -- Wil Bown -- Wladimir J. van der Laan diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.1.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.1.md deleted file mode 100644 index 0552053d2..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.1.md +++ /dev/null @@ -1,53 +0,0 @@ -Bitcoin Core version 0.9.1 is now available from: - - https://bitcoin.org/bin/0.9.1/ - -This is a security update. It is recommended to upgrade to this release -as soon as possible. - -It is especially important to upgrade if you currently have version -0.9.0 installed and are using the graphical interface OR you are using -bitcoind from any pre-0.9.1 version, and have enabled SSL for RPC and -have configured allowip to allow rpc connections from potentially -hostile hosts. - -Please report bugs using the issue tracker at github: - - https://github.com/bitcoin/bitcoin/issues - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), then run the -installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or -bitcoind/bitcoin-qt (on Linux). - -If you are upgrading from version 0.7.2 or earlier, the first time you run -0.9.1 your blockchain files will be re-indexed, which will take anywhere from -30 minutes to several hours, depending on the speed of your machine. - -0.9.1 Release notes -======================= - -No code changes were made between 0.9.0 and 0.9.1. Only the dependencies were changed. - -- Upgrade OpenSSL to 1.0.1g. This release fixes the following vulnerabilities which can - affect the Bitcoin Core software: - - - CVE-2014-0160 ("heartbleed") - A missing bounds check in the handling of the TLS heartbeat extension can - be used to reveal up to 64k of memory to a connected client or server. - - - CVE-2014-0076 - The Montgomery ladder implementation in OpenSSL does not ensure that - certain swap operations have a constant-time behavior, which makes it - easier for local users to obtain ECDSA nonces via a FLUSH+RELOAD cache - side-channel attack. - -- Add statically built executables to Linux build - -Credits --------- - -Credits go to the OpenSSL team for fixing the vulnerabilities quickly. diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.2.1.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.2.1.md deleted file mode 100644 index 3168ad1a5..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.2.1.md +++ /dev/null @@ -1,207 +0,0 @@ -Bitcoin Core version 0.9.2.1 is now available from: - - https://bitcoin.org/bin/0.9.2.1/ - -This is a new minor version release, bringing mostly bug fixes and some minor -improvements. OpenSSL has been updated because of a security issue (CVE-2014-0224). -Upgrading to this release is recommended. - -Please report bugs using the issue tracker at github: - - https://github.com/bitcoin/bitcoin/issues - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), then run the -installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or -bitcoind/bitcoin-qt (on Linux). - -If you are upgrading from version 0.7.2 or earlier, the first time you run -0.9.2.1 your blockchain files will be re-indexed, which will take anywhere from -30 minutes to several hours, depending on the speed of your machine. - -Downgrading warnings --------------------- - -The 'chainstate' for this release is not always compatible with previous -releases, so if you run 0.9.x and then decide to switch back to a -0.8.x release you might get a blockchain validation error when starting the -old release (due to 'pruned outputs' being omitted from the index of -unspent transaction outputs). - -Running the old release with the -reindex option will rebuild the chainstate -data structures and correct the problem. - -Also, the first time you run a 0.8.x release on a 0.9 wallet it will rescan -the blockchain for missing spent coins, which will take a long time (tens -of minutes on a typical machine). - -Important changes -================== - -Gitian OSX build ------------------ - -The deterministic build system that was already used for Windows and Linux -builds is now used for OSX as well. Although the resulting executables have -been tested quite a bit, there could be possible regressions. Be sure to report -these on the Github bug tracker mentioned above. - -Compatibility of Linux build ------------------------------ - -For Linux we now build against Qt 4.6, and filter the symbols for libstdc++ and glibc. -This brings back compatibility with - -- Debian 6+ / Tails -- Ubuntu 10.04 -- CentOS 6.5 - -0.9.2 - 0.9.2.1 Release notes -======================= - -The OpenSSL dependency in the gitian builds has been upgraded to 1.0.1h because of CVE-2014-0224. - -RPC: - -- Add `getwalletinfo`, `getblockchaininfo` and `getnetworkinfo` calls (will replace hodge-podge `getinfo` at some point) -- Add a `relayfee` field to `getnetworkinfo` -- Fix RPC related shutdown hangs and leaks -- Always show syncnode in `getpeerinfo` -- `sendrawtransaction`: report the reject code and reason, and make it possible to re-send transactions that are already in the mempool -- `getmininginfo` show right genproclimit - -Command-line options: - -- Fix `-printblocktree` output -- Show error message if ReadConfigFile fails - -Block-chain handling and storage: - -- Fix for GetBlockValue() after block 13,440,000 (BIP42) -- Upgrade leveldb to 1.17 - -Protocol and network code: - -- Per-peer block download tracking and stalled download detection -- Add new DNS seed from bitnodes.io -- Prevent socket leak in ThreadSocketHandler and correct some proxy related socket leaks -- Use pnode->nLastRecv as sync score (was the wrong way around) - -Wallet: - -- Make GetAvailableCredit run GetHash() only once per transaction (performance improvement) -- Lower paytxfee warning threshold from 0.25 BTC to 0.01 BTC -- Fix importwallet nTimeFirstKey (trigger necessary rescans) -- Log BerkeleyDB version at startup -- CWallet init fix - -Build system: - -- Add OSX build descriptors to gitian -- Fix explicit --disable-qt-dbus -- Don't require db_cxx.h when compiling with wallet disabled and GUI enabled -- Improve missing boost error reporting -- Upgrade miniupnpc version to 1.9 -- gitian-linux: --enable-glibc-back-compat for binary compatibility with old distributions -- gitian: don't export any symbols from executable -- gitian: build against Qt 4.6 -- devtools: add script to check symbols from Linux gitian executables -- Remove build-time no-IPv6 setting - -GUI: - -- Fix various coin control visual issues -- Show number of in/out connections in debug console -- Show weeks as well as years behind for long timespans behind -- Enable and disable the Show and Remove buttons for requested payments history based on whether any entry is selected. -- Show also value for options overridden on command line in options dialog -- Fill in label from address book also for URIs -- Fixes feel when resizing the last column on tables (issue #2862) -- Fix ESC in disablewallet mode -- Add expert section to wallet tab in optionsdialog -- Do proper boost::path conversion (fixes unicode in datadir) -- Only override -datadir if different from the default (fixes -datadir in config file) -- Show rescan progress at start-up -- Show importwallet progress -- Get required locks upfront in polling functions (avoids hanging on locks) -- Catch Windows shutdown events while client is running -- Optionally add third party links to transaction context menu -- Check for !pixmap() before trying to export QR code (avoids crashes when no QR code could be generated) -- Fix "Start bitcoin on system login" - -Miscellaneous: - -- Replace non-threadsafe C functions (gmtime, strerror and setlocale) -- Add missing cs_main and wallet locks -- Avoid exception at startup when system locale not recognized -- Changed bitrpc.py's raw_input to getpass for passwords to conceal characters during command line input -- devtools: add a script to fetch and postprocess translations - -Credits --------- - -Thanks to everyone who contributed to this release: - -- Addy Yeow -- Altoidnerd -- Andrea D'Amore -- Andreas Schildbach -- Bardi Harborow -- Brandon Dahler -- Bryan Bishop -- Chris Beams -- Christian von Roques -- Cory Fields -- Cozz Lovan -- daniel -- Daniel Newton -- David A. Harding -- ditto-b -- duanemoody -- Eric S. Bullington -- Fabian Raetz -- Gavin Andresen -- Gregory Maxwell -- gubatron -- Haakon Nilsen -- harry -- Hector Jusforgues -- Isidoro Ghezzi -- Jeff Garzik -- Johnathan Corgan -- jtimon -- Kamil Domanski -- langerhans -- Luke Dashjr -- Manuel Araoz -- Mark Friedenbach -- Matt Corallo -- Matthew Bogosian -- Meeh -- Michael Ford -- Michagogo -- Mikael Wikman -- Mike Hearn -- olalonde -- paveljanik -- peryaudo -- Philip Kaufmann -- philsong -- Pieter Wuille -- R E Broadley -- richierichrawr -- Rune K. Svendsen -- rxl -- shshshsh -- Simon de la Rouviere -- Stuart Cardall -- super3 -- Telepatheic -- Thomas Zander -- Torstein Husebø -- Warren Togami -- Wladimir J. van der Laan -- Yoichi Hirai diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.2.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.2.md deleted file mode 100644 index a2749e549..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.2.md +++ /dev/null @@ -1,207 +0,0 @@ -Bitcoin Core version 0.9.2 is now available from: - - https://bitcoin.org/bin/0.9.2/ - -This is a new minor version release, bringing mostly bug fixes and some minor -improvements. OpenSSL has been updated because of a security issue (CVE-2014-0224). -Upgrading to this release is recommended. - -Please report bugs using the issue tracker at github: - - https://github.com/bitcoin/bitcoin/issues - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), then run the -installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or -bitcoind/bitcoin-qt (on Linux). - -If you are upgrading from version 0.7.2 or earlier, the first time you run -0.9.2 your blockchain files will be re-indexed, which will take anywhere from -30 minutes to several hours, depending on the speed of your machine. - -Downgrading warnings --------------------- - -The 'chainstate' for this release is not always compatible with previous -releases, so if you run 0.9.x and then decide to switch back to a -0.8.x release you might get a blockchain validation error when starting the -old release (due to 'pruned outputs' being omitted from the index of -unspent transaction outputs). - -Running the old release with the -reindex option will rebuild the chainstate -data structures and correct the problem. - -Also, the first time you run a 0.8.x release on a 0.9 wallet it will rescan -the blockchain for missing spent coins, which will take a long time (tens -of minutes on a typical machine). - -Important changes -================== - -Gitian OSX build ------------------ - -The deterministic build system that was already used for Windows and Linux -builds is now used for OSX as well. Although the resulting executables have -been tested quite a bit, there could be possible regressions. Be sure to report -these on the Github bug tracker mentioned above. - -Compatibility of Linux build ------------------------------ - -For Linux we now build against Qt 4.6, and filter the symbols for libstdc++ and glibc. -This brings back compatibility with - -- Debian 6+ / Tails -- Ubuntu 10.04 -- CentOS 6.5 - -0.9.2 Release notes -======================= - -The OpenSSL dependency in the gitian builds has been upgraded to 1.0.1h because of CVE-2014-0224. - -RPC: - -- Add `getwalletinfo`, `getblockchaininfo` and `getnetworkinfo` calls (will replace hodge-podge `getinfo` at some point) -- Add a `relayfee` field to `getnetworkinfo` -- Fix RPC related shutdown hangs and leaks -- Always show syncnode in `getpeerinfo` -- `sendrawtransaction`: report the reject code and reason, and make it possible to re-send transactions that are already in the mempool -- `getmininginfo` show right genproclimit - -Command-line options: - -- Fix `-printblocktree` output -- Show error message if ReadConfigFile fails - -Block-chain handling and storage: - -- Fix for GetBlockValue() after block 13,440,000 (BIP42) -- Upgrade leveldb to 1.17 - -Protocol and network code: - -- Per-peer block download tracking and stalled download detection -- Add new DNS seed from bitnodes.io -- Prevent socket leak in ThreadSocketHandler and correct some proxy related socket leaks -- Use pnode->nLastRecv as sync score (was the wrong way around) - -Wallet: - -- Make GetAvailableCredit run GetHash() only once per transaction (performance improvement) -- Lower paytxfee warning threshold from 0.25 BTC to 0.01 BTC -- Fix importwallet nTimeFirstKey (trigger necessary rescans) -- Log BerkeleyDB version at startup -- CWallet init fix - -Build system: - -- Add OSX build descriptors to gitian -- Fix explicit --disable-qt-dbus -- Don't require db_cxx.h when compiling with wallet disabled and GUI enabled -- Improve missing boost error reporting -- Upgrade miniupnpc version to 1.9 -- gitian-linux: --enable-glibc-back-compat for binary compatibility with old distributions -- gitian: don't export any symbols from executable -- gitian: build against Qt 4.6 -- devtools: add script to check symbols from Linux gitian executables -- Remove build-time no-IPv6 setting - -GUI: - -- Fix various coin control visual issues -- Show number of in/out connections in debug console -- Show weeks as well as years behind for long timespans behind -- Enable and disable the Show and Remove buttons for requested payments history based on whether any entry is selected. -- Show also value for options overridden on command line in options dialog -- Fill in label from address book also for URIs -- Fixes feel when resizing the last column on tables (issue #2862) -- Fix ESC in disablewallet mode -- Add expert section to wallet tab in optionsdialog -- Do proper boost::path conversion (fixes unicode in datadir) -- Only override -datadir if different from the default (fixes -datadir in config file) -- Show rescan progress at start-up -- Show importwallet progress -- Get required locks upfront in polling functions (avoids hanging on locks) -- Catch Windows shutdown events while client is running -- Optionally add third party links to transaction context menu -- Check for !pixmap() before trying to export QR code (avoids crashes when no QR code could be generated) -- Fix "Start bitcoin on system login" - -Miscellaneous: - -- Replace non-threadsafe C functions (gmtime, strerror and setlocale) -- Add missing cs_main and wallet locks -- Avoid exception at startup when system locale not recognized -- Changed bitrpc.py's raw_input to getpass for passwords to conceal characters during command line input -- devtools: add a script to fetch and postprocess translations - -Credits --------- - -Thanks to everyone who contributed to this release: - -- Addy Yeow -- Altoidnerd -- Andrea D'Amore -- Andreas Schildbach -- Bardi Harborow -- Brandon Dahler -- Bryan Bishop -- Chris Beams -- Christian von Roques -- Cory Fields -- Cozz Lovan -- daniel -- Daniel Newton -- David A. Harding -- ditto-b -- duanemoody -- Eric S. Bullington -- Fabian Raetz -- Gavin Andresen -- Gregory Maxwell -- gubatron -- Haakon Nilsen -- harry -- Hector Jusforgues -- Isidoro Ghezzi -- Jeff Garzik -- Johnathan Corgan -- jtimon -- Kamil Domanski -- langerhans -- Luke Dashjr -- Manuel Araoz -- Mark Friedenbach -- Matt Corallo -- Matthew Bogosian -- Meeh -- Michael Ford -- Michagogo -- Mikael Wikman -- Mike Hearn -- olalonde -- paveljanik -- peryaudo -- Philip Kaufmann -- philsong -- Pieter Wuille -- R E Broadley -- richierichrawr -- Rune K. Svendsen -- rxl -- shshshsh -- Simon de la Rouviere -- Stuart Cardall -- super3 -- Telepatheic -- Thomas Zander -- Torstein Husebø -- Warren Togami -- Wladimir J. van der Laan -- Yoichi Hirai diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.3.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.3.md deleted file mode 100644 index 0765a360b..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.3.md +++ /dev/null @@ -1,101 +0,0 @@ -Bitcoin Core version 0.9.3 is now available from: - - https://bitcoin.org/bin/0.9.3/ - -This is a new minor version release, bringing only bug fixes and updated -translations. Upgrading to this release is recommended. - -Please report bugs using the issue tracker at github: - - https://github.com/bitcoin/bitcoin/issues - -Upgrading and downgrading -========================== - -How to Upgrade --------------- - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), then run the -installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or -bitcoind/bitcoin-qt (on Linux). - -If you are upgrading from version 0.7.2 or earlier, the first time you run -0.9.3 your blockchain files will be re-indexed, which will take anywhere from -30 minutes to several hours, depending on the speed of your machine. - -Downgrading warnings --------------------- - -The 'chainstate' for this release is not always compatible with previous -releases, so if you run 0.9.x and then decide to switch back to a -0.8.x release you might get a blockchain validation error when starting the -old release (due to 'pruned outputs' being omitted from the index of -unspent transaction outputs). - -Running the old release with the -reindex option will rebuild the chainstate -data structures and correct the problem. - -Also, the first time you run a 0.8.x release on a 0.9 wallet it will rescan -the blockchain for missing spent coins, which will take a long time (tens -of minutes on a typical machine). - -0.9.3 Release notes -======================= - -RPC: -- Avoid a segfault on getblock if it can't read a block from disk -- Add paranoid return value checks in base58 - -Protocol and network code: -- Don't poll showmyip.com, it doesn't exist anymore -- Add a way to limit deserialized string lengths and use it -- Add a new checkpoint at block 295,000 -- Increase IsStandard() scriptSig length -- Avoid querying DNS seeds, if we have open connections -- Remove a useless millisleep in socket handler -- Stricter memory limits on CNode -- Better orphan transaction handling -- Add `-maxorphantx=` and `-maxorphanblocks=` options for control over the maximum orphan transactions and blocks - -Wallet: -- Check redeemScript size does not exceed 520 byte limit -- Ignore (and warn about) too-long redeemScripts while loading wallet - -GUI: -- fix 'opens in testnet mode when presented with a BIP-72 link with no fallback' -- AvailableCoins: acquire cs_main mutex -- Fix unicode character display on MacOSX - -Miscellaneous: -- key.cpp: fail with a friendlier message on missing ssl EC support -- Remove bignum dependency for scripts -- Upgrade OpenSSL to 1.0.1i (see https://www.openssl.org/news/secadv_20140806.txt - just to be sure, no critical issues for Bitcoin Core) -- Upgrade miniupnpc to 1.9.20140701 -- Fix boost detection in build system on some platforms - -Credits --------- - -Thanks to everyone who contributed to this release: - -- Andrew Poelstra -- Cory Fields -- Gavin Andresen -- Jeff Garzik -- Johnathan Corgan -- Julian Haight -- Michael Ford -- Pavel Vasin -- Peter Todd -- phantomcircuit -- Pieter Wuille -- Rose Toomey -- Ruben Dario Ponticelli -- shshshsh -- Trevin Hofmann -- Warren Togami -- Wladimir J. van der Laan -- Zak Wilcox - -As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/). diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.4.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.4.md deleted file mode 100644 index 7ee73246a..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.4.md +++ /dev/null @@ -1,95 +0,0 @@ -Bitcoin Core version 0.9.4 is now available from: - - https://bitcoin.org/bin/0.9.4/ - -This is a new minor version release, bringing only bug fixes and updated -translations. Upgrading to this release is recommended. - -Please report bugs using the issue tracker at github: - - https://github.com/bitcoin/bitcoin/issues - -How to Upgrade -=============== - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), then run the -installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or -bitcoind/bitcoin-qt (on Linux). - -OpenSSL Warning -================ - -OpenSSL 1.0.0p / 1.0.1k was recently released and is being pushed out by -various operating system maintainers. Review by Gregory Maxwell determined that -this update is incompatible with the Bitcoin system and could lead to consensus -forks. - -Bitcoin Core released binaries from https://bitcoin.org are unaffected, -as are any built with the gitian deterministic build system. - -However, if you are running either - -- The Ubuntu PPA from https://launchpad.net/~bitcoin/+archive/ubuntu/bitcoin -- A third-party or self-compiled Bitcoin Core - -upgrade to Bitcoin Core 0.9.4, which includes a workaround, **before** updating -OpenSSL. - -The incompatibility is due to the OpenSSL update changing the -behavior of ECDSA validation to reject any signature which is -not encoded in a very rigid manner. This was a result of -OpenSSL's change for CVE-2014-8275 "Certificate fingerprints -can be modified". - -We are specifically aware of potential hard-forks due to signature -encoding handling and had been hoping to close them via BIP62 in 0.10. -BIP62's purpose is to improve transaction malleability handling and -as a side effect rigidly defines the encoding for signatures, but the -overall scope of BIP62 has made it take longer than we'd like to -deploy. - -0.9.4 changelog -================ - -Validation: -- `b8e81b7` consensus: guard against openssl's new strict DER checks -- `60c51f1` fail immediately on an empty signature -- `037bfef` Improve robustness of DER recoding code - -Command-line options: -- `cd5164a` Make -proxy set all network types, avoiding a connect leak. - -P2P: -- `bb424e4` Limit the number of new addressses to accumulate - -RPC: -- `0a94661` Disable SSLv3 (in favor of TLS) for the RPC client and server. - -Build system: -- `f047dfa` gitian: openssl-1.0.1i.tar.gz -> openssl-1.0.1k.tar.gz -- `5b9f78d` build: Fix OSX build when using Homebrew and qt5 -- `ffab1dd` Keep symlinks when copying into .app bundle -- `613247f` osx: fix signing to make Gatekeeper happy (again) - -Miscellaneous: -- `25b49b5` Refactor -alertnotify code -- `2743529` doc: Add instructions for consistent Mac OS X build names - -Credits --------- - -Thanks to who contributed to this release, at least: - -- Cory Fields -- Gavin Andresen -- Gregory Maxwell -- Jeff Garzik -- Luke Dashjr -- Matt Corallo -- Pieter Wuille -- Saivann -- Sergio Demian Lerner -- Wladimir J. van der Laan - -As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/). diff --git a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.5.md b/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.5.md deleted file mode 100644 index bed0af987..000000000 --- a/depend/zcash/doc/bitcoin-release-notes/release-notes-0.9.5.md +++ /dev/null @@ -1,60 +0,0 @@ -Bitcoin Core version 0.9.5 is now available from: - - https://bitcoin.org/bin/0.9.5/ - -This is a new minor version release, with the goal of backporting BIP66. There -are also a few bug fixes and updated translations. Upgrading to this release is -recommended. - -Please report bugs using the issue tracker at github: - - https://github.com/bitcoin/bitcoin/issues - -How to Upgrade -=============== - -If you are running an older version, shut it down. Wait until it has completely -shut down (which might take a few minutes for older versions), then run the -installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or -bitcoind/bitcoin-qt (on Linux). - -Notable changes -================ - -Mining and relay policy enhancements ------------------------------------- - -Bitcoin Core's block templates are now for version 3 blocks only, and any mining -software relying on its `getblocktemplate` must be updated in parallel to use -libblkmaker either version 0.4.2 or any version from 0.5.1 onward. -If you are solo mining, this will affect you the moment you upgrade Bitcoin -Core, which must be done prior to BIP66 achieving its 951/1001 status. -If you are mining with the stratum mining protocol: this does not affect you. -If you are mining with the getblocktemplate protocol to a pool: this will affect -you at the pool operator's discretion, which must be no later than BIP66 -achieving its 951/1001 status. - -0.9.5 changelog -================ - -- `74f29c2` Check pindexBestForkBase for null -- `9cd1dd9` Fix priority calculation in CreateTransaction -- `6b4163b` Sanitize command strings before logging them. -- `3230b32` Raise version of created blocks, and enforce DERSIG in mempool -- `989d499` Backport of some of BIP66's tests -- `ab03660` Implement BIP 66 validation rules and switchover logic -- `8438074` build: fix dynamic boost check when --with-boost= is used - -Credits --------- - -Thanks to who contributed to this release, at least: - -- 21E14 -- Alex Morcos -- Cory Fields -- Gregory Maxwell -- Pieter Wuille -- Wladimir J. van der Laan - -As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/). diff --git a/depend/zcash/doc/init.md b/depend/zcash/doc/init.md deleted file mode 100644 index fba4b5411..000000000 --- a/depend/zcash/doc/init.md +++ /dev/null @@ -1,102 +0,0 @@ -*** Warning: This document has not been updated for Zcash and may be inaccurate. *** - -Sample init scripts and service configuration for bitcoind -========================================================== - -Sample scripts and configuration files for systemd, Upstart and OpenRC -can be found in the contrib/init folder. - - contrib/init/bitcoind.service: systemd service unit configuration - contrib/init/bitcoind.openrc: OpenRC compatible SysV style init script - contrib/init/bitcoind.openrcconf: OpenRC conf.d file - contrib/init/bitcoind.conf: Upstart service configuration file - contrib/init/bitcoind.init: CentOS compatible SysV style init script - -1. Service User ---------------------------------- - -All three startup configurations assume the existence of a "bitcoin" user -and group. They must be created before attempting to use these scripts. - -2. Configuration ---------------------------------- - -At a bare minimum, bitcoind requires that the rpcpassword setting be set -when running as a daemon. If the configuration file does not exist or this -setting is not set, bitcoind will shutdown promptly after startup. - -This password does not have to be remembered or typed as it is mostly used -as a fixed token that bitcoind and client programs read from the configuration -file, however it is recommended that a strong and secure password be used -as this password is security critical to securing the wallet should the -wallet be enabled. - -If bitcoind is run with "-daemon" flag, and no rpcpassword is set, it will -print a randomly generated suitable password to stderr. You can also -generate one from the shell yourself like this: - -bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo' - - -For an example configuration file that describes the configuration settings, -see contrib/debian/examples/bitcoin.conf. - -3. Paths ---------------------------------- - -All three configurations assume several paths that might need to be adjusted. - -Binary: /usr/bin/bitcoind -Configuration file: /etc/bitcoin/bitcoin.conf -Data directory: /var/lib/bitcoind -PID file: /var/run/bitcoind/bitcoind.pid (OpenRC and Upstart) - /var/lib/bitcoind/bitcoind.pid (systemd) -Lock file: /var/lock/subsys/bitcoind (CentOS) - -The configuration file, PID directory (if applicable) and data directory -should all be owned by the bitcoin user and group. It is advised for security -reasons to make the configuration file and data directory only readable by the -bitcoin user and group. Access to bitcoin-cli and other bitcoind rpc clients -can then be controlled by group membership. - -4. Installing Service Configuration ------------------------------------ - -4a) systemd - -Installing this .service file consists of just copying it to -/usr/lib/systemd/system directory, followed by the command -"systemctl daemon-reload" in order to update running systemd configuration. - -To test, run "systemctl start bitcoind" and to enable for system startup run -"systemctl enable bitcoind" - -4b) OpenRC - -Rename bitcoind.openrc to bitcoind and drop it in /etc/init.d. Double -check ownership and permissions and make it executable. Test it with -"/etc/init.d/bitcoind start" and configure it to run on startup with -"rc-update add bitcoind" - -4c) Upstart (for Debian/Ubuntu based distributions) - -Drop bitcoind.conf in /etc/init. Test by running "service bitcoind start" -it will automatically start on reboot. - -NOTE: This script is incompatible with CentOS 5 and Amazon Linux 2014 as they -use old versions of Upstart and do not supply the start-stop-daemon utility. - -4d) CentOS - -Copy bitcoind.init to /etc/init.d/bitcoind. Test by running "service bitcoind start". - -Using this script, you can adjust the path and flags to the bitcoind program by -setting the BITCOIND and FLAGS environment variables in the file -/etc/sysconfig/bitcoind. You can also use the DAEMONOPTS environment variable here. - -5. Auto-respawn ------------------------------------ - -Auto respawning is currently only configured for Upstart and systemd. -Reasonable defaults have been chosen but YMMV. - diff --git a/depend/zcash/doc/man/zcash-cli.1 b/depend/zcash/doc/man/zcash-cli.1 index 9ce96bc64..bdb784111 100644 --- a/depend/zcash/doc/man/zcash-cli.1 +++ b/depend/zcash/doc/man/zcash-cli.1 @@ -1,9 +1,9 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.13. -.TH ZCASH-CLI "1" "July 2020" "zcash-cli v3.1.0-rc2" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.16. +.TH ZCASH-CLI "1" "September 2020" "zcash-cli v4.0.0" "User Commands" .SH NAME -zcash-cli \- manual page for zcash-cli v3.1.0-rc2 +zcash-cli \- manual page for zcash-cli v4.0.0 .SH DESCRIPTION -Zcash RPC client version v3.1.0\-rc2 +Zcash RPC client version v4.0.0 .PP In order to ensure you are adequately protecting your privacy when using Zcash, please see . @@ -84,7 +84,3 @@ This is experimental software. Distributed under the MIT software license, see the accompanying file COPYING or . - -This product includes software developed by the OpenSSL Project for use in the -OpenSSL Toolkit and cryptographic software written -by Eric Young. diff --git a/depend/zcash/doc/man/zcash-tx.1 b/depend/zcash/doc/man/zcash-tx.1 index 178e1fe8f..9d735273e 100644 --- a/depend/zcash/doc/man/zcash-tx.1 +++ b/depend/zcash/doc/man/zcash-tx.1 @@ -1,9 +1,9 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.13. -.TH ZCASH-TX "1" "July 2020" "zcash-tx v3.1.0-rc2" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.16. +.TH ZCASH-TX "1" "September 2020" "zcash-tx v4.0.0" "User Commands" .SH NAME -zcash-tx \- manual page for zcash-tx v3.1.0-rc2 +zcash-tx \- manual page for zcash-tx v4.0.0 .SH DESCRIPTION -Zcash zcash\-tx utility version v3.1.0\-rc2 +Zcash zcash\-tx utility version v4.0.0 .SS "Usage:" .TP zcash\-tx [options] [commands] @@ -98,7 +98,3 @@ This is experimental software. Distributed under the MIT software license, see the accompanying file COPYING or . - -This product includes software developed by the OpenSSL Project for use in the -OpenSSL Toolkit and cryptographic software written -by Eric Young. diff --git a/depend/zcash/doc/man/zcashd.1 b/depend/zcash/doc/man/zcashd.1 index 778d45bd8..85efde4cd 100644 --- a/depend/zcash/doc/man/zcashd.1 +++ b/depend/zcash/doc/man/zcashd.1 @@ -1,9 +1,9 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.13. -.TH ZCASHD "1" "July 2020" "zcashd v3.1.0-rc2" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.16. +.TH ZCASHD "1" "September 2020" "zcashd v4.0.0" "User Commands" .SH NAME -zcashd \- manual page for zcashd v3.1.0-rc2 +zcashd \- manual page for zcashd v4.0.0 .SH DESCRIPTION -Zcash Daemon version v3.1.0\-rc2 +Zcash Daemon version v4.0.0 .PP In order to ensure you are adequately protecting your privacy when using Zcash, please see . @@ -51,6 +51,10 @@ Run in the background as a daemon and accept commands .IP Specify data directory .HP +\fB\-paramsdir=\fR +.IP +Specify Zcash network parameters directory +.HP \fB\-dbcache=\fR .IP Set database cache size in megabytes (4 to 16384, default: 450) @@ -74,7 +78,7 @@ Keep at most unconnectable transactions in memory (default: 100) .HP \fB\-par=\fR .IP -Set the number of script verification threads (\fB\-4\fR to 16, 0 = auto, <0 = +Set the number of script verification threads (\fB\-16\fR to 16, 0 = auto, <0 = leave that many cores free, default: 0) .HP \fB\-pid=\fR @@ -514,7 +518,3 @@ This is experimental software. Distributed under the MIT software license, see the accompanying file COPYING or . - -This product includes software developed by the OpenSSL Project for use in the -OpenSSL Toolkit and cryptographic software written -by Eric Young. diff --git a/depend/zcash/doc/release-notes.md b/depend/zcash/doc/release-notes.md index e9198c402..dbbc76796 100644 --- a/depend/zcash/doc/release-notes.md +++ b/depend/zcash/doc/release-notes.md @@ -4,45 +4,21 @@ release-notes at release time) Notable changes =============== -Network Upgrade 4: Canopy --------------------------- - -The code preparations for the Canopy network upgrade are finished and included in this release. The following ZIPs are being deployed: - -- [ZIP 207: Funding Streams](https://zips.z.cash/zip-0207) -- [ZIP 211: Disabling Addition of New Value to the Sprout Value Pool](https://zips.z.cash/zip-0211) -- [ZIP 212: Allow Recipient to Derive Sapling Ephemeral Secret from Note Plaintext](https://zips.z.cash/zip-0212) -- [ZIP 214: Consensus rules for a Zcash Development Fund](https://zips.z.cash/zip-0214) -- [ZIP 215: Explicitly Defining and Modifying Ed25519 Validation Rules](https://zips.z.cash/zip-0215) - -Canopy will activate on testnet at height TODO, and can also be activated at a specific height in regtest mode by setting the config option `-nuparams=0xe9ff75a6:HEIGHT`. - -Canopy will activate on mainnet at height 1046400. - -See [ZIP 251](https://zips.z.cash/zip-0251) for additional information about the deployment process for Canopy. - -Flush witness data to disk only when it's consistent ------------------------------------------------------ -This fix prevents the wallet database from getting into an inconsistent state. By flushing witness data to disk from the wallet thread instead of the main thread, we ensure that the on-disk block height is always the same as the witness data height. Previously, the database occasionally got into a state where the latest block height was one ahead of the witness data. This then triggered an assertion failure in `CWallet::IncrementNoteWitnesses()` upon restarting after a zcashd shutdown. - -Note that this code change will not automatically repair a data directory that has been affected by this problem; that requires starting zcashd with the `-rescan` or `-reindex` options. - -New DNS seeders ----------------- -DNS seeders hosted at "zfnd.org" and "yolo.money" have been added to the list in `chainparams.cpp`. They're running [CoreDNS](https://coredns.io) with a [Zcash crawler plugin](https://github.com/ZcashFoundation/dnsseeder), the result of a Zcash Foundation in-house development effort to replace `zcash-seeder` with something memory-safe and easier to maintain. - -These are validly operated seeders per the [existing policy](https://zcash.readthedocs.io/en/latest/rtd_pages/dnsseed_policy.html). For general questions related to either seeder, contact george@zfnd.org or mention @gtank in the Zcash Foundation's Discord. For bug reports, open an issue on the [dnsseeder](https://github.com/ZcashFoundation/dnsseeder) repo. - -Changed command-line options ------------------------------ -- `-debuglogfile=` can be used to specify an alternative debug logging file. - -RPC methods ------------- -- `joinSplitPubKey` and `joinSplitSig` have been added to verbose transaction outputs. This enables the transaction's binary form to be fully reconstructed from the RPC output. -- The output of `getblockchaininfo` now includes an `estimatedheight` parameter. This can be shown in UIs as an indication of the current chain height while `zcashd` is syncing, but should not be relied upon when creating transactions. - -Metrics screen ------------------------ -- A progress bar is now visible when in Initial Block Download mode, showing both the prefetched headers and validated blocks. It is only printed for TTY output. Additionally, the "not mining" message is no longer shown on mainnet, as the built-in CPU miner is not effective at the current network difficulty. -- The number of block headers prefetched during Initial Block Download is now displayed alongside the number of validated blocks. With current compile-time defaults, a Zcash node prefetches up to 160 block headers per request without a limit on how far it can prefetch, but only up to 16 full blocks at a time. +Migration to Clang and static libc++ +------------------------------------ + +`zcashd` now builds its C++ (and C) dependencies entirely with a pinned version +of Clang, and statically links libc++ instead of dynamically linking libstdc++. +This migration enables us to reliably use newer C++ features while supporting +older LTS platforms, be more confident in the compiler's optimisations, and +leverage security features such as sanitisers and efficient fuzzing. + +Additionally, because both Clang and rustc use LLVM as their backend, we can +optimise across the FFI boundary between them. This reduces the cost of moving +between C++ and Rust, making it easier to build more functionality in Rust +(though not making it costless, as we still need to work within the constraints +of the C ABI). + +The system compiler is still used to compile a few native dependencies (used by +the build machine to then compile `zcashd` for the target machine). These will +likely also be migrated to use the pinned Clang in a future release. diff --git a/depend/zcash/doc/release-notes/release-notes-3.0.0.md b/depend/zcash/doc/release-notes/release-notes-3.0.0.md index 8cda60ba9..479636a56 100644 --- a/depend/zcash/doc/release-notes/release-notes-3.0.0.md +++ b/depend/zcash/doc/release-notes/release-notes-3.0.0.md @@ -27,6 +27,7 @@ that can be generated locally with the `z_getnewaddress` RPC command. Restart your node, and block templates produced by the `getblocktemplate` RPC command will now have coinbase transactions that mine directly into this shielded address. + Changelog ========= diff --git a/depend/zcash/doc/release-notes/release-notes-3.1.0.md b/depend/zcash/doc/release-notes/release-notes-3.1.0.md new file mode 100644 index 000000000..b96995c95 --- /dev/null +++ b/depend/zcash/doc/release-notes/release-notes-3.1.0.md @@ -0,0 +1,274 @@ +Notable changes +=============== + +Network Upgrade 4: Canopy +-------------------------- + +The code preparations for the Canopy network upgrade are finished and included in this release. The following ZIPs are being deployed: + +- [ZIP 207: Funding Streams](https://zips.z.cash/zip-0207) +- [ZIP 211: Disabling Addition of New Value to the Sprout Value Pool](https://zips.z.cash/zip-0211) +- [ZIP 212: Allow Recipient to Derive Sapling Ephemeral Secret from Note Plaintext](https://zips.z.cash/zip-0212) +- [ZIP 214: Consensus rules for a Zcash Development Fund](https://zips.z.cash/zip-0214) +- [ZIP 215: Explicitly Defining and Modifying Ed25519 Validation Rules](https://zips.z.cash/zip-0215) + +Canopy will activate on testnet at height 1028500, and can also be activated at a specific height in regtest mode by setting the config option `-nuparams=0xe9ff75a6:HEIGHT`. Note that v3.1.0 enables Canopy support on the testnet. + +Canopy will activate on mainnet at height 1046400. + +See [ZIP 251](https://zips.z.cash/zip-0251) for additional information about the deployment process for Canopy. + +Debian 8 "Jessie" will no longer be supported after v3.1.0, due to its [end-of-life](https://www.debian.org/News/2020/20200709#:~:text=The%20Debian%20Long%20Term%20Support,security%20updates%20for%20Debian%208) on June 30th, 2020. This will allow us to direct more resources to supporting Debian 10 Buster, other Linux distributions, and other platforms such as Windows and macOS. + +Flush witness data to disk only when it's consistent +----------------------------------------------------- +This fix prevents the wallet database from getting into an inconsistent state. By flushing witness data to disk from the wallet thread instead of the main thread, we ensure that the on-disk block height is always the same as the witness data height. Previously, the database occasionally got into a state where the latest block height was one ahead of the witness data. This then triggered an assertion failure in `CWallet::IncrementNoteWitnesses()` upon restarting after a zcashd shutdown. + +Note that this code change will not automatically repair a data directory that has been affected by this problem; that requires starting zcashd with the `-rescan` or `-reindex` options. + +New DNS seeders +---------------- +DNS seeders hosted at "zfnd.org" and "yolo.money" have been added to the list in `chainparams.cpp`. They're running [CoreDNS](https://coredns.io) with a [Zcash crawler plugin](https://github.com/ZcashFoundation/dnsseeder), the result of a Zcash Foundation in-house development effort to replace `zcash-seeder` with something memory-safe and easier to maintain. + +These are validly operated seeders per the [existing policy](https://zcash.readthedocs.io/en/latest/rtd_pages/dnsseed_policy.html). For general questions related to either seeder, contact george@zfnd.org or mention @gtank in the Zcash Foundation's Discord. For bug reports, open an issue on the [dnsseeder](https://github.com/ZcashFoundation/dnsseeder) repo. + +Changed command-line options +----------------------------- +- `-debuglogfile=` can be used to specify an alternative debug logging file. + +RPC methods +------------ +- `joinSplitPubKey` and `joinSplitSig` have been added to verbose transaction outputs. This enables the transaction's binary form to be fully reconstructed from the RPC output. +- The output of `getblockchaininfo` now includes an `estimatedheight` parameter. This can be shown in UIs as an indication of the current chain height while `zcashd` is syncing, but should not be relied upon when creating transactions. + +Metrics screen +----------------------- +- A progress bar is now visible when in Initial Block Download mode, showing both the prefetched headers and validated blocks. It is only printed for TTY output. Additionally, the "not mining" message is no longer shown on mainnet, as the built-in CPU miner is not effective at the current network difficulty. +- The number of block headers prefetched during Initial Block Download is now displayed alongside the number of validated blocks. With current compile-time defaults, a Zcash node prefetches up to 160 block headers per request without a limit on how far it can prefetch, but only up to 16 full blocks at a time. + +Changelog +========= + +Alfredo Garcia (28): + add estimatedheight to getblockchaininfo + add documentation and command line parsing to afl scripts + get fuzzing options from directory + add bool argument to get balance in satoshis to rpc getreceivedbyaddress + add documentation to flag + change argument name + add boolean inZat to getreceivedbyaccount + add boolean inZat to getbalance + add boolean inZat to z_getbalance + add amountZat field to listreceivedbyaddress and listreceivedbyaccount + add amountZat field to listtransactions, gettransaction and listsinceblock + add amountZat field to listunspent + add amountZat field to z_listreceivedbyaddress + replace with AssertionError assert_equal in receivedby.py + Fix casting in wallet.py + simplify inzat balances logic + Fix casting in listtransactions.py + add MINOR_CURRENCY_UNIT + remove additional not needed casts from py tests + change name of harden option + fix test cases + fix sort of options + remove not needed comments from wallet.py + update docs + add new parameters to rpc client and fix some bugs + initialize size_t + fix/improve docs + add log aporximation to metrics solution rates + +Anthony Towns (1): + test: Add tests for `-debuglogfile` with subdirs + +Daira Hopwood (24): + Rename NU4 to Canopy in constant and function names. + Rename golden/nu4.tar.gz to canopy.tar.gz. + Missing NU4->Canopy renames. + Remove unused import in qa/rpc-tests/listtransactions.py + Remove an unused CCriticalSection. + Add GetActiveFundingStreams function. + Tests for changes to getblocksubsidy. + Change getblocksubsidy RPC to take into account funding streams. + Use ValueFromAmount instead of double arithmetic, and improve variable names. + Cosmetic spacing changes. + Apply suggestions from code review + Change the format of `getblocksubsidy` output to use an array of funding stream objects. + Clean up some iterator usage. + Remove an unnecessary iterator increment. + Another cleanup. + Add key_constants.h to src/Makefile.am. + Fix an unintended consensus change in decryption of coinbase outputs. + More iterator cleanups. + src/metrics.cpp: cosmetic whitespace changes. + Metrics screen: display hash rates using SI prefixes rather than as powers of 2. + Add unit tests for DisplayDuration, DisplaySize, and DisplayHashRate. + Fix the formatting of the 3.0.0 release notes. + Fix --disable-mining build regression. closes #4634 + Allow Equihash validation tests to be compiled with --disable-mining. + +Danny Willems (3): + librustzcash: make the header C compatible + Use assert.h instead of define manually static_assert + Use preprocessor for ENTRY_SERIALIZED_LENGTH + +Eirik Ogilvie-Wigley (2): + Resolve decimal vs float issues + Various improvements + +George Tankersley (1): + Add ZF and gtank's DNS seeders + +Jack Grigg (21): + Use the cached consensusBranchId in DisconnectBlock + qa: Smoke test driver + qa: Run Zcash node for smoke tests + qa: Simple smoke tests + qa: Transaction chain smoke test + qa: Use slick-bitcoinrpc for smoke tests + qa: Don't allow smoke tests with mainnet wallet.dat + qa: Improve reliability of smoke tests + qa: Improve reliability of smoke test cleanup + metrics: Fix indents + metrics: Draw IBD progress bar showing headers and blocks + metrics: Don't show "not mining" text for mainnet + qa: Add --use-faucet flag to smoke tests + qa: Remove unused timeout configuration from wait_for_balance + qa: Add --automate flag to smoke tests + metrics: Switch to ANSI colour codes for progress bar + metrics: Only print IBD progress bar on TTY + Implement zip-207 and zip-214. + Use Rust Equihash validator unconditionally + Remove C++ Equihash validator + Revert "Pass the block height through to CheckEquihashSolution()" + +Kris Nuttycombe (31): + Identify `-fundingstream` parameter as being regtest-only + Use for..: rather than BOOST_FOREACH + Trivial error message fix. + Minor fixes for ZIP-207 review comments. + Trivial copyright fix. + Replace BOOST_FOREACH with for..: + Qualified imports of std:: types + Capitalization fixes from code review + Minor naming change FundingStreamShare -> FundingStreamElement + Record-constructor syntax for funding stream initialization. + Update HalvingHeight documentation. + Fix pyflakes. + Fix funding stream end-height-exclusion bugs + Add `RegtestDeactivateCanopy` calls to restore shared regtest params. + Move test-only code into test sources. + Trivial comment correction. + Minor help message correction. + Pass by const reference where possible. + Use uint32_t for vFundingStreams indexing. + Fix incorrect subtraction of Halving(blossomActivationHeight) from halvingIndex + Fix ordering of transparent outputs such that miner reward is vout[0] + Use ed25519-zebra from crates.io. + Remove assertion that was breaking regtest in the case that blossom activates after the halving. + Use for..in rather than an indexed loop. + Make evident the relationship between chainparams and key IO. + Rename KeyInfo -> KeyConstants and move out of Consensus namespace. + Fix typo in constant. + Fix assertion check in GetBlockSubsidy + Apply suggestions from code review + Trivial whitespace fix. + Zero-initialize HistoryNode values. + +Larry Ruane (7): + add python test to reproduce bug 4301 + flush witness cache correctly + review, cleanup: eliminate uninitialized variable + self.sync_all(), not time.sleep(4) + fix pyflakes CI errors + undo flushing witness data on shutdown + sync before stopping nodes + +Rod Vagg (1): + Add joinSplitPubKey and joinSplitSig to RPC + +Sean Bowe (23): + Add implementations of PRF_expand calls that obtain esk and rcm. + Remove bare SaplingNote constructor. + Add a getter method to obtain rcm from a Sapling note plaintext. + Add support for receiving v2 Sapling note plaintexts. + Change transaction builder and miner to use v2 Sapling note plaintexts after Canopy activates. + Make ed25519-zebra available via librustzcash. + Change to version of ed25519-zebra crate which is compliant with ZIP 215. + Enforce ZIP 215 rules upon activation of Canopy. + Add test that a weird signature successfully validates. + Remove bincode crate. + Remove unused curve25519-dalek dev-dependency. + Minor adjustments to librustzcash and tests. + Redirect git checkouts of ebfull/ed25519-zebra through our vendored sources in offline mode. + Require that shielded coinbase output note plaintexts are version 2 if Canopy is active. + Make transaction builder take the next block height into account for use of v2 note plaintexts. + Turn return values for libsodium-like API into constants for clarity. + Add more exhaustive tests for ZIP 215 compatibility. + Cargo fmt + Remove unused imports from remove_sprout_shielding RPC test. + Migrate ZIP 215 test vectors to gtest suite. + Change LIBSODIUM_ERROR to -1. + Hash "Zcash" to align tests with ZIP 215 test vectors. + Remove outdated comment. + +Solar Designer (2): + Fix typos in ProcessMessage() "headers" + During initial blocks download, also report the number of headers + +Taylor Hornby (3): + Fix undefined behavior in gtest tests + Add missing header for std::invalid_argument + Fix bug in CScheduler + +Wladimir J. van der Laan (3): + Add `-debuglogfile` option + test: Add test for `-debuglogfile` + doc: Update release notes for `-debuglogfile` + +ewillbefull@gmail.com (1): + Add dev fund addresses for testnet NU4 activation. + +Marshall Gaucher (1): + Add helpers for tapping and donating to the testnet faucet + +therealyingtong (35): + Add RPC tests for post-Heartwood rollback + Reject v1 plaintexts after grace period + Check epk vs esk whenever caller has esk + Refactor SaplingNotePlaintext::decrypt + Add gtests for v2 plaintexts + Add contextual check to main.cpp + Add gtests + Add checks to z_ methods in rpcwallet + Add RPC tests + Replace leadByte in SaplingNote with is_zip_212 + Throw error in plaintext deserialization + Pass pindex to AddToWalletIfInvolvingMe() + Remove plaintext check from AddSaplingSpend + Remove plaintext check from GetFilteredNotes + Refactor bool is_zip_212 to enum Zip212Enabled + Minor changes + Remove old SaplingNote() constructor + Pass nHeight instead of pindex to AddToWalletIfInvolvingMe() + Directly call RegtestActivate* in gtests + Update release notes for v3.1.0 + make-release.py: Versioning changes for 3.1.0-rc1. + make-release.py: Updated manpages for 3.1.0-rc1. + make-release.py: Updated release notes and changelog for 3.1.0-rc1. + Undo manual DEPRECATION_HEIGHT + make-release.py: Versioning changes for 3.1.0-rc2. + make-release.py: Updated manpages for 3.1.0-rc2. + make-release.py: Updated release notes and changelog for 3.1.0-rc2. + Edit release notes to specify that rc2 does not enable Canopy support on the testnet + Set Canopy testnet activation height to 1020500 + Set PROTOCOL_VERSION to 170012 + Pass HistoryNode struct to librustzcash FFI + Delay testnet activation height by one week + Use 51 Testnet Dev Fund addresses, and adjust the end heights. + make-release.py: Versioning changes for 3.1.0. + make-release.py: Updated manpages for 3.1.0. + +ying tong (1): + Apply suggestions from code review diff --git a/depend/zcash/doc/release-notes/release-notes-4.0.0-rc1.md b/depend/zcash/doc/release-notes/release-notes-4.0.0-rc1.md new file mode 100644 index 000000000..b25b85ebd --- /dev/null +++ b/depend/zcash/doc/release-notes/release-notes-4.0.0-rc1.md @@ -0,0 +1,276 @@ +Notable changes +=============== + +The mainnet activation of the Canopy network upgrade is supported by the 4.0.0 +release, with an activation height of 1046400, which should occur roughly in the +middle of November — following the targeted EOS halt of our 3.1.0 release. +Please upgrade to this release, or any subsequent release, in order to follow +the Canopy network upgrade. + +The following ZIPs are being deployed as part of this upgrade: + +* [ZIP 207: Funding Streams](https://zips.z.cash/zip-0207) in conjunction with [ZIP 214: Consensus rules for a Zcash Development Fund](https://zips.z.cash/zip-0214) +* [ZIP 211: Disabling Addition of New Value to the Sprout Value Pool](https://zips.z.cash/zip-0211) +* [ZIP 212: Allow Recipient to Derive Sapling Ephemeral Secret from Note Plaintext](https://zips.z.cash/zip-0212) +* [ZIP 215: Explicitly Defining and Modifying Ed25519 Validation Rules](https://zips.z.cash/zip-0215) + +In order to help the ecosystem prepare for the mainnet activation, Canopy has +already been activated on the Zcash testnet. Any node version 3.1.0 or higher, +including this release, supports the Canopy activation on testnet. + +Disabling new value in the Sprout value pool +-------------------------------------------- + +After the mainnet activation of Canopy, it will not be possible to send funds to +Sprout z-addresses from any _other_ kind of address, as described in [ZIP 211](https://zips.z.cash/zip-0211). +It will still be possible to send funds _from_ a Sprout z-address and to send +funds between Sprout addresses. Users of Sprout z-addresses are encouraged to +use Sapling z-addresses instead, and to migrate their remaining Sprout funds +into a Sapling z-address using the migration utility in zcashd: set `migrate=1` +in your `zcash.conf` file, or use the `z_setmigration` RPC. + +New logging system +------------------ + +The `zcashd` logging system is now powered by the Rust `tracing` crate. This +has two main benefits: + +- `tracing` supports the concept of "spans", which represent periods of time + with a beginning and end. These enable logging additional information about + temporality and causality of events. (Regular log lines, which represent + moments in time, are called `events` in `tracing`.) +- Spans and events are structured, and can record typed data in addition to text + messages. This structure can then be filtered dynamically. + +The existing `-debug=target` config flags are mapped to `tracing` log filters, +and will continue to correctly enable additional logging when starting `zcashd`. +A new `setlogfilter` RPC method has been introduced that enables reconfiguring +the log filter at runtime. See `zcash-cli help setlogfilter` for its syntax. + +As a minor note, `zcashd` no longer reopens the `debug.log` file on `SIGHUP`. +This behaviour was originally introduced in upstream Bitcoin Core to support log +rotation using external tools. `tracing` supports log rotation internally (which +is currently disabled), as well as a variety of interesting backends (such as +`journald` and OpenTelemetry integration); we are investigating how these might +be exposed in future releases. + +Compatibility +------------- +macOS versions earlier than 10.12 (Sierra) are no longer supported. + +Changelog +========= + +Alfredo Garcia (3): + only allow duplicates for certain options of the config + install bdb binaries + add more allowed duplicates + +Andrew Chow (1): + Fix naming of macOS SDK and clarify version + +Carl Dong (8): + contrib: macdeploy: Correctly generate macOS SDK + Adapt rest of tooling to new SDK naming scheme + native_cctools: Don't use libc++ from pinned clang + contrib: macdeploy: Use apple-sdk-tools instead of xar+pbzx + contrib: macdeploy: Remove historical extraction notes + depends: Decouple toolchain + binutils + depends: Specify path to native binaries as clang argument + depends: Add justifications for macOS clang flags + +Charlie O'Keefe (1): + Remove 'jessie' (debian 8) from suites list in linux gitian descriptors + +Cory Fields (14): + crypto: add AES 128/256 CBC classes + crypto: add aes cbc tests + crypter: fix the stored initialization vector size + crypter: constify encrypt/decrypt + crypter: hook up the new aes cbc classes + crypter: add a BytesToKey clone to replace the use of openssl + crypter: add tests for crypter + build: Enumerate ctaes rather than globbing + depends: bump MacOS toolchain + macos: Bump to xcode 11.3.1 and 10.15 SDK + darwin: pass mlinker-version so that clang enables new features + depends: specify libc++ header location for darwin + depends: enable lto support for Apple's ld64 + depends: bump native_cctools for fixed lto with external clang + +Daira Hopwood (6): + zcutil/distclean.sh: remove BDB utility programs. + Update .gitignore. + Fix a return status issue. + Update Makefile.am + Newer version of checksec.sh from https://github.com/slimm609/checksec.sh/commit/a6df608ac077689b2160e521db6601abc7b9e26e + Repair full_test_suite.py for new checksec.sh. + +Dimitris Apostolou (1): + Remove deprecated contrib utilities + +Jack Grigg (67): + Move GrothProof and SproutProof definitions into zcash/Proof.hpp + Remove unused declarations left over from libsnark verification + Make ZCJoinSplit::prove static and remove ZCJoinSplit globals + Move ProofVerifier out of the libzcash namespace + Move JSDescription::Verify to ProofVerifier::VerifySprout + Skip Sprout proof verification for ProofVerifier::Disabled + Send alert to put pre-Heartwood nodes into safe mode. + Squashed 'src/crypto/ctaes/' content from commit 003a4acfc + build: shuffle gtest Makefile so that crypto can be used by the wallet + metrics: Collect general stats before clearing screen + Debian: Add copyright entries for ctaes and secp256k1 + Revert "Rename FALLBACK_DOWNLOAD_PATH to PRIORITY_DOWNLOAD_PATH" + Revert "Try downloading from our mirror first to avoid headaches." + depends: Use FALLBACK_DOWNLOAD_PATH if the primary's hash doesn't match + test: Remove obsolete TransactionBuilder test + Add tracing to librustzcash dependencies + FFI wrapper around tracing crate + Replace C++ logging with tracing logging + Use a tracing EnvFilter directive for -debug flags + Add support for reloading the tracing filter + Add an RPC method for setting the tracing filter directives + Add support for tracing spans + Add some spans to the Zcash codebase + FFI: Extract common codeunit types into a rust/types.h header + tracing: Use 'static constexpr' hack in macros + wallet: Fix logging to satisfy constexpr requirements + FFI: Add missing includes + init: Place additional constraints on pathDebug + rpc: Throw error in setlogfilter if filter reloading fails + tracing: Log field values that aren't valid UTF-8 + tracing: Document macro arguments that MUST be static constant UTF-8 strings + doc: Update release notes for tracing backend + qa: Add tracing dependencies to updatecheck.py + depends: tracing-core 0.1.13 + Revert "Add check-depends step to STAGE_COMMANDS list" + contrib: Update macdeploy README + depends: Rework Rust integration + depends: Add platform-specific overrides for download files + depends: Split check-packages and check-sources across categories + FFI: Fix tracing log path handling on Windows + tracing: Add MAP macro + tracing: Add support for event fields + tracing: Add support for span fields + tracing: Format field values with Display + Add fields to logging in CNode and UpdateTip + util: Use DEBUG level for LogPrint(), leaving INFO for LogPrintf() + tracing: Parse log_path into an Option + tracing: Rework tracing_init into a single function + init: Rework tracing_init call + init: Add spans for initialization and shutdown + Replace libsodium's randombytes_buf with rand_core::OsRng::fill_bytes + consensus: Add assertions for Params::HalvingHeight parameters + consensus: Document the empty conditional branch in ContextualCheckBlock + consensus: Statically check funding stream numerators and denominators + consensus: Clearly gate active funding stream elements on Canopy + Replace libsodium's crypto_sign with ed25519-zebra + ed25519: Panic (triggering abort) if nullptr passed into APIs + test: Update ZIP 215 test cases from ed25519-zebra + depends: Migrate to zcash_* 0.3.0 Rust crates + FFI: Remove circuit parameter hashes from librustzcash_init_zksnark_params + FFI: Migrate to bls12_381 and jubjub crates + depends: cargo update + qa: Update list of postponed crate versions + FFI: Rename to librustzcash_sapling_compute_cmu + FFI: Rename r to rcm + debian: Rename X11 to Expat-with-advertising-clause in copyright + Adjust GetActiveFundingStream* comments + +Kris Nuttycombe (13): + Remove amqp code and Proton library depenencies & flags. + Remove Proton license from contrib/debian/copyright + consensus: Clean up some whitespace and variable names + consensus: Refactor Sprout contextual rules to match the rest + consensus: Remove canopyActive gate around GetActiveFundingStreamElements + consensus: Combine heartwoodActive conditionals + consensus: Add a placeholder for !canopyActive + consensus: Move overwinterActive rules ahead of saplingActive rules + consensus: Combine saplingActive conditionals + consensus: Move Sapling-disabled Overwinter rules above Sapling rules + consensus: Reorder Overwinter+!Sapling rules + consensus: Remove redundant contextual consensus rules + Add comment in lieu of redundant overwinter version check & fix tests. + +Larry Ruane (2): + flush wallet db (SetBestChain()) on clean shutdown + wallet: lock cs_main while accessing chainActive + +LongShao007 (1): + fix bug of bdb.mk + +Per Grön (11): + Get rid of implicit hidden dependencies between test .cpp files + Add missing #includes to test_block.cpp + Add actual header file for utilities in gtest/utils.cpp + Fix linkage issue with consts in primitives/block.h + Remove Checkpoints_tests.cpp + libsnark: Don't (implicitly) rely on other tests initializing the public params + Add missing libsnark initialization call + Don't clobber cwd in rpc_wallet_tests.cpp + Include header files within the source tree using "" instead of <> + Be consistent about what path to include bitcoin-config.h with + Be consistent with how to #include test data headers + +Pieter Wuille (1): + Add ctaes-based constant time AES implementation + +Sean Bowe (4): + Postpone boost 1.74.0 update + Postpone rust updates + make-release.py: Versioning changes for 4.0.0-rc1. + make-release.py: Updated manpages for 4.0.0-rc1. + +Taylor Hornby (5): + Implement system for postponing dependency updates. + Change release instructions to block the release when dependencies are not updated and not postponed. + Enforce pre-release dependency update check in make-release.py + Extend deadline for postponing dependency updates + Add new dependencies to updatecheck.py, add a flag we can use to have our CI test it. + +Ariel Gabizon (1): + explain expiry error + +Benjamin Winston (2): + Added support for afl-clang-fast. + Added libfuzzer support. + +elbandi (3): + Allow configure params directory + Add paramsdir option for manpage + Throw error if -paramsdir not a valid directory + +fanquake (8): + depends: set OSX_MIN_VERSION to 10.10 + doc: mention that macOS 10.10 is now required + scripted-diff: prefer MAC_OSX over __APPLE__ + build: set minimum supported macOS to 10.12 + depends: clang 6.0.1 + depends: native_cctools 921, ld64 409.12, libtapi 1000.10.8 + build: use macOS 10.14 SDK + doc: explain why passing -mlinker-version is required + +noname45688@gmail.com (2): + Updating to Python 3 + Update to Python 3 + +teor (1): + Fix a comment typo in pow.cpp + +Ying Tong Lai (11): + Add Debian8 deprecation to release notes + Add missing curly braces after if statement + Add test for garbage memory in history nodes + Add documentation specific to ZIP 212 + Move esk derivation check to beginning of plaintext_checks_without_height() + Define PRF diversifiers in prf.h + assert(leadbyte == 0x02) after every if(leadbyte != 0x01) + Update doc/release-notes/release-notes-3.1.0.md + Make sure garbage bytes are different + Rename PRV_DIVERSIFIER to PRF_TAG + Add link to ZIP212 in coinbase comment + +Zancas Wilcox (1): + make deprecation.h include consensus/params.h + diff --git a/depend/zcash/doc/release-notes/release-notes-4.0.0.md b/depend/zcash/doc/release-notes/release-notes-4.0.0.md new file mode 100644 index 000000000..cd675c434 --- /dev/null +++ b/depend/zcash/doc/release-notes/release-notes-4.0.0.md @@ -0,0 +1,290 @@ +Notable changes +=============== + +The mainnet activation of the Canopy network upgrade is supported by the 4.0.0 +release, with an activation height of 1046400, which should occur roughly in the +middle of November — following the targeted EOS halt of our 3.1.0 release. +Please upgrade to this release, or any subsequent release, in order to follow +the Canopy network upgrade. + +The following ZIPs are being deployed as part of this upgrade: + +* [ZIP 207: Funding Streams](https://zips.z.cash/zip-0207) in conjunction with [ZIP 214: Consensus rules for a Zcash Development Fund](https://zips.z.cash/zip-0214) +* [ZIP 211: Disabling Addition of New Value to the Sprout Value Pool](https://zips.z.cash/zip-0211) +* [ZIP 212: Allow Recipient to Derive Sapling Ephemeral Secret from Note Plaintext](https://zips.z.cash/zip-0212) +* [ZIP 215: Explicitly Defining and Modifying Ed25519 Validation Rules](https://zips.z.cash/zip-0215) + +In order to help the ecosystem prepare for the mainnet activation, Canopy has +already been activated on the Zcash testnet. Any node version 3.1.0 or higher, +including this release, supports the Canopy activation on testnet. + +Disabling new value in the Sprout value pool +-------------------------------------------- + +After the mainnet activation of Canopy, it will not be possible to send funds to +Sprout z-addresses from any _other_ kind of address, as described in [ZIP 211](https://zips.z.cash/zip-0211). +It will still be possible to send funds _from_ a Sprout z-address and to send +funds between Sprout addresses. Users of Sprout z-addresses are encouraged to +use Sapling z-addresses instead, and to migrate their remaining Sprout funds +into a Sapling z-address using the migration utility in zcashd: set `migrate=1` +in your `zcash.conf` file, or use the `z_setmigration` RPC. + +New logging system +------------------ + +The `zcashd` logging system is now powered by the Rust `tracing` crate. This +has two main benefits: + +- `tracing` supports the concept of "spans", which represent periods of time + with a beginning and end. These enable logging additional information about + temporality and causality of events. (Regular log lines, which represent + moments in time, are called `events` in `tracing`.) +- Spans and events are structured, and can record typed data in addition to text + messages. This structure can then be filtered dynamically. + +The existing `-debug=target` config flags are mapped to `tracing` log filters, +and will continue to correctly enable additional logging when starting `zcashd`. +A new `setlogfilter` RPC method has been introduced that enables reconfiguring +the log filter at runtime. See `zcash-cli help setlogfilter` for its syntax. + +As a minor note, `zcashd` no longer reopens the `debug.log` file on `SIGHUP`. +This behaviour was originally introduced in upstream Bitcoin Core to support log +rotation using external tools. `tracing` supports log rotation internally (which +is currently disabled), as well as a variety of interesting backends (such as +`journald` and OpenTelemetry integration); we are investigating how these might +be exposed in future releases. + +Compatibility +------------- +macOS versions earlier than 10.12 (Sierra) are no longer supported. + +Changelog +========= + +Alfredo Garcia (3): + only allow duplicates for certain options of the config + install bdb binaries + add more allowed duplicates + +Andrew Chow (1): + Fix naming of macOS SDK and clarify version + +Carl Dong (8): + contrib: macdeploy: Correctly generate macOS SDK + Adapt rest of tooling to new SDK naming scheme + native_cctools: Don't use libc++ from pinned clang + contrib: macdeploy: Use apple-sdk-tools instead of xar+pbzx + contrib: macdeploy: Remove historical extraction notes + depends: Decouple toolchain + binutils + depends: Specify path to native binaries as clang argument + depends: Add justifications for macOS clang flags + +Charlie O'Keefe (1): + Remove 'jessie' (debian 8) from suites list in linux gitian descriptors + +Cory Fields (14): + crypto: add AES 128/256 CBC classes + crypto: add aes cbc tests + crypter: fix the stored initialization vector size + crypter: constify encrypt/decrypt + crypter: hook up the new aes cbc classes + crypter: add a BytesToKey clone to replace the use of openssl + crypter: add tests for crypter + build: Enumerate ctaes rather than globbing + depends: bump MacOS toolchain + macos: Bump to xcode 11.3.1 and 10.15 SDK + darwin: pass mlinker-version so that clang enables new features + depends: specify libc++ header location for darwin + depends: enable lto support for Apple's ld64 + depends: bump native_cctools for fixed lto with external clang + +Daira Hopwood (7): + zcutil/distclean.sh: remove BDB utility programs. + Update .gitignore. + Fix a return status issue. + Update Makefile.am + Newer version of checksec.sh from https://github.com/slimm609/checksec.sh/commit/a6df608ac077689b2160e521db6601abc7b9e26e + Repair full_test_suite.py for new checksec.sh. + Clarify a comment about the ZF and MG addresses + +Dimitris Apostolou (1): + Remove deprecated contrib utilities + +Jack Grigg (65): + Move GrothProof and SproutProof definitions into zcash/Proof.hpp + Remove unused declarations left over from libsnark verification + Make ZCJoinSplit::prove static and remove ZCJoinSplit globals + Move ProofVerifier out of the libzcash namespace + Move JSDescription::Verify to ProofVerifier::VerifySprout + Skip Sprout proof verification for ProofVerifier::Disabled + Send alert to put pre-Heartwood nodes into safe mode. + Squashed 'src/crypto/ctaes/' content from commit 003a4acfc + build: shuffle gtest Makefile so that crypto can be used by the wallet + metrics: Collect general stats before clearing screen + Debian: Add copyright entries for ctaes and secp256k1 + Revert "Rename FALLBACK_DOWNLOAD_PATH to PRIORITY_DOWNLOAD_PATH" + Revert "Try downloading from our mirror first to avoid headaches." + depends: Use FALLBACK_DOWNLOAD_PATH if the primary's hash doesn't match + test: Remove obsolete TransactionBuilder test + Add tracing to librustzcash dependencies + FFI wrapper around tracing crate + Replace C++ logging with tracing logging + Use a tracing EnvFilter directive for -debug flags + Add support for reloading the tracing filter + Add an RPC method for setting the tracing filter directives + Add support for tracing spans + Add some spans to the Zcash codebase + FFI: Extract common codeunit types into a rust/types.h header + tracing: Use 'static constexpr' hack in macros + wallet: Fix logging to satisfy constexpr requirements + FFI: Add missing includes + init: Place additional constraints on pathDebug + rpc: Throw error in setlogfilter if filter reloading fails + tracing: Log field values that aren't valid UTF-8 + tracing: Document macro arguments that MUST be static constant UTF-8 strings + doc: Update release notes for tracing backend + qa: Add tracing dependencies to updatecheck.py + depends: tracing-core 0.1.13 + Revert "Add check-depends step to STAGE_COMMANDS list" + contrib: Update macdeploy README + depends: Rework Rust integration + depends: Add platform-specific overrides for download files + depends: Split check-packages and check-sources across categories + FFI: Fix tracing log path handling on Windows + tracing: Add MAP macro + tracing: Add support for event fields + tracing: Add support for span fields + tracing: Format field values with Display + Add fields to logging in CNode and UpdateTip + util: Use DEBUG level for LogPrint(), leaving INFO for LogPrintf() + tracing: Parse log_path into an Option + tracing: Rework tracing_init into a single function + init: Rework tracing_init call + init: Add spans for initialization and shutdown + Replace libsodium's randombytes_buf with rand_core::OsRng::fill_bytes + consensus: Add assertions for Params::HalvingHeight parameters + consensus: Document the empty conditional branch in ContextualCheckBlock + consensus: Statically check funding stream numerators and denominators + consensus: Clearly gate active funding stream elements on Canopy + Replace libsodium's crypto_sign with ed25519-zebra + ed25519: Panic (triggering abort) if nullptr passed into APIs + test: Update ZIP 215 test cases from ed25519-zebra + depends: Migrate to zcash_* 0.3.0 Rust crates + FFI: Remove circuit parameter hashes from librustzcash_init_zksnark_params + FFI: Migrate to bls12_381 and jubjub crates + depends: cargo update + qa: Update list of postponed crate versions + FFI: Rename to librustzcash_sapling_compute_cmu + FFI: Rename r to rcm + +Kris Nuttycombe (13): + Remove amqp code and Proton library depenencies & flags. + Remove Proton license from contrib/debian/copyright + consensus: Clean up some whitespace and variable names + consensus: Refactor Sprout contextual rules to match the rest + consensus: Remove canopyActive gate around GetActiveFundingStreamElements + consensus: Combine heartwoodActive conditionals + consensus: Add a placeholder for !canopyActive + consensus: Move overwinterActive rules ahead of saplingActive rules + consensus: Combine saplingActive conditionals + consensus: Move Sapling-disabled Overwinter rules above Sapling rules + consensus: Reorder Overwinter+!Sapling rules + consensus: Remove redundant contextual consensus rules + Add comment in lieu of redundant overwinter version check & fix tests. + +Larry Ruane (2): + flush wallet db (SetBestChain()) on clean shutdown + wallet: lock cs_main while accessing chainActive + +LongShao007 (1): + fix bug of bdb.mk + +Per Grön (11): + Get rid of implicit hidden dependencies between test .cpp files + Add missing #includes to test_block.cpp + Add actual header file for utilities in gtest/utils.cpp + Fix linkage issue with consts in primitives/block.h + Remove Checkpoints_tests.cpp + libsnark: Don't (implicitly) rely on other tests initializing the public params + Add missing libsnark initialization call + Don't clobber cwd in rpc_wallet_tests.cpp + Include header files within the source tree using "" instead of <> + Be consistent about what path to include bitcoin-config.h with + Be consistent with how to #include test data headers + +Pieter Wuille (1): + Add ctaes-based constant time AES implementation + +Sean Bowe (13): + Postpone boost 1.74.0 update + Postpone rust updates + make-release.py: Versioning changes for 4.0.0-rc1. + make-release.py: Updated manpages for 4.0.0-rc1. + make-release.py: Updated release notes and changelog for 4.0.0-rc1. + Add release notes to describe the Canopy network upgrade. + Update names of contributors in release notes. + Specify 4.0.0 in release notes + Add dev fund addresses for mainnet. + Set activation height for Canopy on mainnet. + Postpone updates for dependencies until after 4.0.0 release. + make-release.py: Versioning changes for 4.0.0. + make-release.py: Updated manpages for 4.0.0. + +Taylor Hornby (5): + Implement system for postponing dependency updates. + Change release instructions to block the release when dependencies are not updated and not postponed. + Enforce pre-release dependency update check in make-release.py + Extend deadline for postponing dependency updates + Add new dependencies to updatecheck.py, add a flag we can use to have our CI test it. + +Ariel Gabizon (1): + explain expiry error + +Benjamin Winston (2): + Added support for afl-clang-fast. + Added libfuzzer support. + +elbandi (3): + Allow configure params directory + Add paramsdir option for manpage + Throw error if -paramsdir not a valid directory + +fanquake (8): + depends: set OSX_MIN_VERSION to 10.10 + doc: mention that macOS 10.10 is now required + scripted-diff: prefer MAC_OSX over `__APPLE__` + build: set minimum supported macOS to 10.12 + depends: clang 6.0.1 + depends: native_cctools 921, ld64 409.12, libtapi 1000.10.8 + build: use macOS 10.14 SDK + doc: explain why passing -mlinker-version is required + +noname45688@gmail.com (2): + Updating to Python 3 + Update to Python 3 + +Jack Grigg (2): + debian: Rename X11 to Expat-with-advertising-clause in copyright + Adjust GetActiveFundingStream* comments + +teor (1): + Fix a comment typo in pow.cpp + +Ying Tong Lai (7): + Add Debian8 deprecation to release notes + Add missing curly braces after if statement + Add test for garbage memory in history nodes + Add documentation specific to ZIP 212 + Move esk derivation check to beginning of plaintext_checks_without_height() + Define PRF diversifiers in prf.h + assert(leadbyte == 0x02) after every if(leadbyte != 0x01) + +ying tong (4): + Update doc/release-notes/release-notes-3.1.0.md + Make sure garbage bytes are different + Rename PRV_DIVERSIFIER to PRF_TAG + Add link to ZIP212 in coinbase comment + +Zancas Wilcox (1): + make deprecation.h include consensus/params.h + diff --git a/depend/zcash/doc/release-process.md b/depend/zcash/doc/release-process.md index 44d43364f..3bfec0b3a 100644 --- a/depend/zcash/doc/release-process.md +++ b/depend/zcash/doc/release-process.md @@ -26,6 +26,16 @@ Ensure that new performance metrics appear on that site. Update `src/chainparams.cpp` nMinimumChainWork with information from the getblockchaininfo rpc. +Check that dependencies are up-to-date or have been postponed: + +``` +$ ./qa/zcash/updatecheck.py +``` + +If there are updates that have not been postponed, review their changelogs +for urgent security fixes, and if there aren't any, postpone the update by +adding a line to `qa/zcash/postponed-updates.txt`. + ### Protocol Safety Checks: If this release changes the behavior of the protocol or fixes a serious diff --git a/depend/zcash/doc/zmq.md b/depend/zcash/doc/zmq.md index f75566dc4..e7e5469bf 100644 --- a/depend/zcash/doc/zmq.md +++ b/depend/zcash/doc/zmq.md @@ -33,9 +33,10 @@ buffering or reassembly. ## Prerequisites -The ZeroMQ feature in Zcash requires ZeroMQ API version 4.x or -newer, which you will need to install if you are not using the depends -system. Typically, it is packaged by distributions as something like +The ZeroMQ feature in Zcash requires the ZeroMQ API >= 4.0.0 +[libzmq](https://github.com/zeromq/libzmq/releases), which you will +need to install if you are not using the depends system. +Typically, it is packaged by distributions as something like *libzmq5-dev*. The C++ wrapper for ZeroMQ is *not* needed. In order to run the example Python client scripts in contrib/ one must diff --git a/depend/zcash/libzcash_script.pc.in b/depend/zcash/libzcash_script.pc.in index fb0433e1c..bd288484f 100644 --- a/depend/zcash/libzcash_script.pc.in +++ b/depend/zcash/libzcash_script.pc.in @@ -8,4 +8,3 @@ Description: Library for verifying scripts against the Zcash consensus protocol. Version: @PACKAGE_VERSION@ Libs: -L${libdir} -lzcash_script Cflags: -I${includedir} -Requires.private: libcrypto diff --git a/depend/zcash/qa/pull-tester/rpc-tests.sh b/depend/zcash/qa/pull-tester/rpc-tests.sh index dc14dd7c7..b0dc2ec88 100755 --- a/depend/zcash/qa/pull-tester/rpc-tests.sh +++ b/depend/zcash/qa/pull-tester/rpc-tests.sh @@ -18,6 +18,7 @@ testScripts=( 'wallet_changeaddresses.py' 'wallet_changeindicator.py' 'wallet_import_export.py' + 'wallet_sendmany_any_taddr.py' 'wallet_shieldingcoinbase.py' 'wallet_shieldcoinbase_sprout.py' 'wallet_shieldcoinbase_sapling.py' @@ -90,6 +91,7 @@ testScripts=( 'post_heartwood_rollback.py' 'feature_logging.py' 'remove_sprout_shielding.py' + 'feature_walletfile.py' ); testScriptsExt=( 'getblocktemplate_longpoll.py' @@ -114,10 +116,6 @@ if [ "x$ENABLE_ZMQ" = "x1" ]; then testScripts+=('zmq_test.py') fi -if [ "x$ENABLE_PROTON" = "x1" ]; then - testScripts+=('proton_test.py') -fi - extArg="-extended" passOn=${@#$extArg} diff --git a/depend/zcash/qa/pull-tester/tests-config.sh.in b/depend/zcash/qa/pull-tester/tests-config.sh.in index 6dc511432..6386a8c48 100755 --- a/depend/zcash/qa/pull-tester/tests-config.sh.in +++ b/depend/zcash/qa/pull-tester/tests-config.sh.in @@ -11,7 +11,6 @@ EXEEXT="@EXEEXT@" @BUILD_BITCOIN_UTILS_TRUE@ENABLE_UTILS=1 @BUILD_BITCOIND_TRUE@ENABLE_BITCOIND=1 @ENABLE_ZMQ_TRUE@ENABLE_ZMQ=1 -@ENABLE_PROTON_TRUE@ENABLE_PROTON=1 REAL_BITCOIND="$BUILDDIR/src/zcashd${EXEEXT}" REAL_BITCOINCLI="$BUILDDIR/src/zcash-cli${EXEEXT}" diff --git a/depend/zcash/qa/rpc-tests/addressindex.py b/depend/zcash/qa/rpc-tests/addressindex.py index 30198a38a..0ed542923 100755 --- a/depend/zcash/qa/rpc-tests/addressindex.py +++ b/depend/zcash/qa/rpc-tests/addressindex.py @@ -10,7 +10,7 @@ # getaddresstxids # getaddressbalance # getaddressdeltas -# getaddressutxos - available only for insightexplorer +# getaddressutxos # getaddressmempool @@ -338,7 +338,7 @@ def check_balance(node_index, address, expected_balance, expected_received=None) assert_equal(deltas_info['end']['hash'], block_hash) # Test getaddressutxos by comparing results with deltas - utxos = self.nodes[1].getaddressutxos(addr1) + utxos = self.nodes[3].getaddressutxos(addr1) # The value 4 note was spent, so won't show up in the utxo list, # so for comparison, remove the 4 (and -4 for output) from the diff --git a/depend/zcash/qa/rpc-tests/feature_walletfile.py b/depend/zcash/qa/rpc-tests/feature_walletfile.py new file mode 100755 index 000000000..61404414b --- /dev/null +++ b/depend/zcash/qa/rpc-tests/feature_walletfile.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +# Copyright (c) 2017 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +"""Test wallet file location.""" + +import os + +from test_framework.util import start_node, stop_node, assert_start_raises_init_error + +from test_framework.test_framework import BitcoinTestFramework + +class WalletFileTest(BitcoinTestFramework): + def set_test_params(self): + self.num_nodes = 1 + self.setup_clean_chain = True + + def run_test(self): + # test default wallet location + assert os.path.isfile(os.path.join(self.options.tmpdir, "node0", "regtest", "wallet.dat")) + + # test alternative wallet file name in datadir + stop_node(self.nodes[0], 0) + self.nodes[0] = start_node(0, self.options.tmpdir, ["-wallet=altwallet.dat"]) + assert os.path.isfile(os.path.join(self.options.tmpdir, "node0", "regtest", "altwallet.dat")) + + # test wallet file outside datadir + tempname = os.path.join(self.options.tmpdir, "outsidewallet.dat") + stop_node(self.nodes[0], 0) + self.nodes[0] = start_node(0, self.options.tmpdir, ["-wallet=%s" % tempname]) + assert os.path.isfile(tempname) + + # test the case where absolute path does not exist + assert not os.path.isdir("/this_directory_must_not_exist") + invalidpath = os.path.join("/this_directory_must_not_exist/", "foo.dat") + stop_node(self.nodes[0], 0) + assert_start_raises_init_error(0, "-wallet=%s" % invalidpath, + "Error: Absolute path %s does not exist") + + # relative path does not exist + invalidpath = os.path.join("wallet", "foo.dat") + assert_start_raises_init_error(0, "-wallet=%s" % invalidpath, + "Error: Relative path %s does not exist") + + # create dir and retry + os.mkdir(os.path.join(self.options.tmpdir, "node0", "regtest", "wallet")) + self.nodes[0] = start_node(0, self.options.tmpdir, ["-wallet=%s" % invalidpath]) + +if __name__ == '__main__': + WalletFileTest().main() diff --git a/depend/zcash/qa/rpc-tests/httpbasics.py b/depend/zcash/qa/rpc-tests/httpbasics.py index 47de2b75b..bd78684ca 100755 --- a/depend/zcash/qa/rpc-tests/httpbasics.py +++ b/depend/zcash/qa/rpc-tests/httpbasics.py @@ -10,7 +10,7 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, start_nodes, str_to_b64str -from http.client import HTTPConnection +from http.client import HTTPConnection, BAD_REQUEST, NOT_FOUND from urllib.parse import urlparse class HTTPBasicsTest (BitcoinTestFramework): @@ -90,5 +90,19 @@ def run_test(self): assert_equal(b'"error":null' in out1, True) assert_equal(conn.sock!=None, True) # connection must be closed because bitcoind should use keep-alive by default + # Check excessive request size + conn = HTTPConnection(urlNode2.hostname, urlNode2.port) + conn.connect() + conn.request('GET', '/' + ('x'*1000), '', headers) + out1 = conn.getresponse() + assert_equal(out1.status, NOT_FOUND) + + conn = HTTPConnection(urlNode2.hostname, urlNode2.port) + conn.connect() + conn.request('GET', '/' + ('x'*10000), '', headers) + out1 = conn.getresponse() + assert_equal(out1.status, BAD_REQUEST) + + if __name__ == '__main__': HTTPBasicsTest().main() diff --git a/depend/zcash/qa/rpc-tests/proton_test.py b/depend/zcash/qa/rpc-tests/proton_test.py deleted file mode 100755 index fd1c5cf95..000000000 --- a/depend/zcash/qa/rpc-tests/proton_test.py +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (c) 2017 The Zcash developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or https://www.opensource.org/licenses/mit-license.php . - -# -# Test Proton interface (provides AMQP 1.0 messaging support). -# -# Requirements: -# Python library for Qpid Proton: -# https://pypi.python.org/pypi/python-qpid-proton -# To install: -# pip install python-qpid-proton -# - -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, bytes_to_hex_str, \ - start_nodes - -from proton.handlers import MessagingHandler -from proton.reactor import Container - -import threading - - -class Server(MessagingHandler): - - def __init__(self, url, limit): - super(Server, self).__init__() - self.url = url - self.counter = limit - self.blockhashes = [] - self.txids = [] - self.blockseq = -1 - self.txidseq = -1 - - def on_start(self, event): - print("Proton listening on:", self.url) - self.container = event.container - self.acceptor = event.container.listen(self.url) - - def on_message(self, event): - m = event.message - hash = bytes_to_hex_str(m.body) - sequence = m.properties['x-opt-sequence-number'] - if m.subject == "hashtx": - self.txids.append(hash) - - # Test that sequence id is incrementing - assert(sequence == 1 + self.txidseq) - self.txidseq = sequence - elif m.subject == "hashblock": - self.blockhashes.append(hash) - - # Test that sequence id is incrementing - assert(sequence == 1 + self.blockseq) - self.blockseq = sequence - - self.counter = self.counter - 1 - if self.counter == 0: - self.container.stop() - - -class ProtonTest (BitcoinTestFramework): - - port = 25672 - numblocks = 10 # must be even, as two nodes generate equal number - assert(numblocks % 2 == 0) - - def setup_nodes(self): - - # Launch proton server in background thread - # It terminates after receiving numblocks * 2 messages (one for coinbase, one for block) - self.server = Server("127.0.0.1:%i" % self.port, self.numblocks * 2) - self.container = Container(self.server) - self.t1 = threading.Thread(target=self.container.run) - self.t1.start() - - return start_nodes(4, self.options.tmpdir, extra_args=[ - ['-experimentalfeatures', '-debug=amqp', '-amqppubhashtx=amqp://127.0.0.1:'+str(self.port), - '-amqppubhashblock=amqp://127.0.0.1:'+str(self.port)], - [], - [], - [] - ]) - - def run_test(self): - self.sync_all() - baseheight = self.nodes[0].getblockcount() # 200 blocks already mined - - # generate some blocks - self.nodes[0].generate(self.numblocks//2) - self.sync_all() - self.nodes[1].generate(self.numblocks//2) - self.sync_all() - - # wait for server to finish - self.t1.join() - - # sequence numbers have already been checked in the server's message handler - - # sanity check that we have the right number of block hashes and coinbase txids - assert_equal(len(self.server.blockhashes), self.numblocks) - assert_equal(len(self.server.txids), self.numblocks) - - # verify that each block has the correct coinbase txid - for i in range(0, self.numblocks): - height = baseheight + i + 1 - blockhash = self.nodes[0].getblockhash(height) - assert_equal(blockhash, self.server.blockhashes[i]) - resp = self.nodes[0].getblock(blockhash) - coinbase = resp["tx"][0] - assert_equal(coinbase, self.server.txids[i]) - - -if __name__ == '__main__': - ProtonTest().main() diff --git a/depend/zcash/qa/rpc-tests/rest.py b/depend/zcash/qa/rpc-tests/rest.py index 79dbe0921..acc5d943f 100755 --- a/depend/zcash/qa/rpc-tests/rest.py +++ b/depend/zcash/qa/rpc-tests/rest.py @@ -94,9 +94,9 @@ def run_test(self): n = vout['n'] - ###################################### - # GETUTXOS: query a unspent outpoint # - ###################################### + ####################################### + # GETUTXOS: query an unspent outpoint # + ####################################### json_request = '/checkmempool/'+txid+'-'+str(n) json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json') json_obj = json.loads(json_string) @@ -109,9 +109,9 @@ def run_test(self): assert_equal(json_obj['utxos'][0]['value'], 0.1) - ################################################ - # GETUTXOS: now query a already spent outpoint # - ################################################ + ################################################# + # GETUTXOS: now query an already spent outpoint # + ################################################# json_request = '/checkmempool/'+vintx+'-0' json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json') json_obj = json.loads(json_string) @@ -173,24 +173,24 @@ def run_test(self): json_request = '/'+txid+'-'+str(n) json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json') json_obj = json.loads(json_string) - assert_equal(len(json_obj['utxos']), 0) # there should be a outpoint because it has just added to the mempool + assert_equal(len(json_obj['utxos']), 0) # there should be an outpoint because it has just added to the mempool json_request = '/checkmempool/'+txid+'-'+str(n) json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json') json_obj = json.loads(json_string) - assert_equal(len(json_obj['utxos']), 1) # there should be a outpoint because it has just added to the mempool + assert_equal(len(json_obj['utxos']), 1) # there should be an outpoint because it has just added to the mempool # do some invalid requests json_request = '{"checkmempool' response = http_post_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request, True) - assert_equal(response.status, 500) # must be a 500 because we send a invalid json request + assert_equal(response.status, 500) # must be a 500 because we send an invalid json request json_request = '{"checkmempool' response = http_post_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'bin', json_request, True) - assert_equal(response.status, 500) # must be a 500 because we send a invalid bin request + assert_equal(response.status, 500) # must be a 500 because we send an invalid bin request response = http_post_call(url.hostname, url.port, '/rest/getutxos/checkmempool'+self.FORMAT_SEPARATOR+'bin', '', True) - assert_equal(response.status, 500) # must be a 500 because we send a invalid bin request + assert_equal(response.status, 500) # must be a 500 because we send an invalid bin request # test limits json_request = '/checkmempool/' diff --git a/depend/zcash/qa/rpc-tests/smartfees.py b/depend/zcash/qa/rpc-tests/smartfees.py index 18ac087be..8caab8808 100755 --- a/depend/zcash/qa/rpc-tests/smartfees.py +++ b/depend/zcash/qa/rpc-tests/smartfees.py @@ -15,7 +15,7 @@ from decimal import Decimal, ROUND_DOWN # Construct 2 trivial P2SH's and the ScriptSigs that spend them -# So we can create many many transactions without needing to spend +# So we can create many transactions without needing to spend # time signing. P2SH_1 = "2MySexEGVzZpRgNQ1JdjdP5bRETznm3roQ2" # P2SH of "OP_1 OP_DROP" P2SH_2 = "2NBdpwq8Aoo1EEKEXPNrKvr5xQr3M9UfcZA" # P2SH of "OP_2 OP_DROP" diff --git a/depend/zcash/qa/rpc-tests/test_framework/authproxy.py b/depend/zcash/qa/rpc-tests/test_framework/authproxy.py index 119228a1f..391482c89 100644 --- a/depend/zcash/qa/rpc-tests/test_framework/authproxy.py +++ b/depend/zcash/qa/rpc-tests/test_framework/authproxy.py @@ -48,7 +48,7 @@ class JSONRPCException(Exception): def __init__(self, rpc_error): - Exception.__init__(self) + Exception.__init__(self, rpc_error.get("message")) self.error = rpc_error def EncodeDecimal(o): diff --git a/depend/zcash/qa/rpc-tests/test_framework/equihash.py b/depend/zcash/qa/rpc-tests/test_framework/equihash.py index d74aa6e13..e05544fb4 100755 --- a/depend/zcash/qa/rpc-tests/test_framework/equihash.py +++ b/depend/zcash/qa/rpc-tests/test_framework/equihash.py @@ -108,9 +108,9 @@ def hash_xi(digest, xi): def count_zeroes(h): # Convert to binary string if type(h) == bytearray: - h = ''.join('{0:08b}'.format(x, 'b') for x in h) + h = ''.join('{0:08b}'.format(x) for x in h) else: - h = ''.join('{0:08b}'.format(ord(x), 'b') for x in h) + h = ''.join('{0:08b}'.format(ord(x)) for x in h) # Count leading zeroes return (h+'1').index('1') @@ -283,9 +283,9 @@ def zcash_person(n, k): def print_hash(h): if type(h) == bytearray: - return ''.join('{0:02x}'.format(x, 'x') for x in h) + return ''.join('{0:02x}'.format(x) for x in h) else: - return ''.join('{0:02x}'.format(ord(x), 'x') for x in h) + return ''.join('{0:02x}'.format(ord(x)) for x in h) def validate_params(n, k): if (k >= n): diff --git a/depend/zcash/qa/rpc-tests/test_framework/mininode.py b/depend/zcash/qa/rpc-tests/test_framework/mininode.py index ca55f6d9b..04a7ef773 100755 --- a/depend/zcash/qa/rpc-tests/test_framework/mininode.py +++ b/depend/zcash/qa/rpc-tests/test_framework/mininode.py @@ -575,7 +575,7 @@ def serialize(self): return r def __repr__(self): - return "JSDescription(vpub_old=%i.%08i vpub_new=%i.%08i anchor=%064x onetimePubKey=%064x randomSeed=%064x proof=%r)" \ + return "JSDescription(vpub_old=%i vpub_new=%i anchor=%064x onetimePubKey=%064x randomSeed=%064x proof=%r)" \ % (self.vpub_old, self.vpub_new, self.anchor, self.onetimePubKey, self.randomSeed, self.proof) @@ -780,7 +780,7 @@ def __repr__(self): r += " vJoinSplit=%r" % (self.vJoinSplit,) if len(self.vJoinSplit) > 0: r += " joinSplitPubKey=%064x joinSplitSig=%064x" \ - (self.joinSplitPubKey, self.joinSplitSig) + % (self.joinSplitPubKey, self.joinSplitSig) if len(self.shieldedSpends) > 0 or len(self.shieldedOutputs) > 0: r += " bindingSig=%064x" % (self.bindingSig,) r += ")" diff --git a/depend/zcash/qa/rpc-tests/test_framework/util.py b/depend/zcash/qa/rpc-tests/test_framework/util.py index 05885d122..610689413 100644 --- a/depend/zcash/qa/rpc-tests/test_framework/util.py +++ b/depend/zcash/qa/rpc-tests/test_framework/util.py @@ -518,12 +518,21 @@ def assert_greater_than(thing1, thing2): raise AssertionError("%s <= %s"%(str(thing1),str(thing2))) def assert_raises(exc, fun, *args, **kwds): + assert_raises_message(exc, None, fun, *args, **kwds) + +def assert_raises_message(ExceptionType, errstr, func, *args, **kwargs): + """ + Asserts that func throws and that the exception contains 'errstr' + in its message. + """ try: - fun(*args, **kwds) - except exc: - pass + func(*args, **kwargs) + except ExceptionType as e: + if errstr is not None and errstr not in str(e): + raise AssertionError("Invalid exception string: Couldn't find %r in %r" % ( + errstr, str(e))) except Exception as e: - raise AssertionError("Unexpected exception raised: "+type(e).__name__) + raise AssertionError("Unexpected exception raised: " + type(e).__name__) else: raise AssertionError("No exception raised") diff --git a/depend/zcash/qa/rpc-tests/wallet.py b/depend/zcash/qa/rpc-tests/wallet.py index c4c14b2eb..83d4cf4c5 100755 --- a/depend/zcash/qa/rpc-tests/wallet.py +++ b/depend/zcash/qa/rpc-tests/wallet.py @@ -335,8 +335,6 @@ def run_test (self): mytxid = wait_and_assert_operationid_status(self.nodes[2], self.nodes[2].z_sendmany(mytaddr, recipients)) - self.sync_all() - self.nodes[2].generate(1) self.sync_all() # check balances @@ -344,10 +342,18 @@ def run_test (self): zsendmanyfee = Decimal('0.0001') node2utxobalance = Decimal('23.998') - zsendmanynotevalue - zsendmanyfee + # check shielded balance status with getwalletinfo + wallet_info = self.nodes[2].getwalletinfo() + assert_equal(Decimal(wallet_info["shielded_unconfirmed_balance"]), zsendmanynotevalue) + assert_equal(Decimal(wallet_info["shielded_balance"]), Decimal('0.0')) + + self.nodes[2].generate(1) + self.sync_all() + assert_equal(self.nodes[2].getbalance(), node2utxobalance) assert_equal(self.nodes[2].getbalance("*"), node2utxobalance) - # check zaddr balance + # check zaddr balance with z_getbalance assert_equal(self.nodes[2].z_getbalance(myzaddr), zsendmanynotevalue) # check via z_gettotalbalance @@ -356,6 +362,11 @@ def run_test (self): assert_equal(Decimal(resp["private"]), zsendmanynotevalue) assert_equal(Decimal(resp["total"]), node2utxobalance + zsendmanynotevalue) + # check confirmed shielded balance with getwalletinfo + wallet_info = self.nodes[2].getwalletinfo() + assert_equal(Decimal(wallet_info["shielded_unconfirmed_balance"]), Decimal('0.0')) + assert_equal(Decimal(wallet_info["shielded_balance"]), zsendmanynotevalue) + # there should be at least one joinsplit mytxdetails = self.nodes[2].gettransaction(mytxid) myvjoinsplits = mytxdetails["vjoinsplit"] diff --git a/depend/zcash/qa/rpc-tests/wallet_anchorfork.py b/depend/zcash/qa/rpc-tests/wallet_anchorfork.py index 86c56e72d..ebebfe748 100755 --- a/depend/zcash/qa/rpc-tests/wallet_anchorfork.py +++ b/depend/zcash/qa/rpc-tests/wallet_anchorfork.py @@ -80,11 +80,15 @@ def run_test (self): # Partition A, node 0 mines a block with the transaction self.nodes[0].generate(1) + # Same as self.sync_all() but only for node 0 + sync_blocks(self.nodes[:1]) + sync_mempools(self.nodes[:1]) # Partition B, node 1 mines the same joinsplit transaction txid2 = self.nodes[1].sendrawtransaction(rawhex) assert_equal(txid, txid2) self.nodes[1].generate(1) + # Same as self.sync_all() but only for nodes 1 and 2 sync_blocks(self.nodes[1:]) sync_mempools(self.nodes[1:]) diff --git a/depend/zcash/qa/rpc-tests/wallet_sendmany_any_taddr.py b/depend/zcash/qa/rpc-tests/wallet_sendmany_any_taddr.py new file mode 100755 index 000000000..d88b09e2f --- /dev/null +++ b/depend/zcash/qa/rpc-tests/wallet_sendmany_any_taddr.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +# Copyright (c) 2020 The Zcash developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://www.opensource.org/licenses/mit-license.php . + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import ( + assert_equal, + wait_and_assert_operationid_status, +) + +# Test ANY_TADDR special string in z_sendmany +class WalletSendManyAnyTaddr(BitcoinTestFramework): + def run_test(self): + # Sanity-check the test harness + assert_equal(self.nodes[0].getblockcount(), 200) + + # Create the addresses we will be using. + recipient = self.nodes[1].z_getnewaddress() + node3zaddr = self.nodes[3].z_getnewaddress() + node3taddr1 = self.nodes[3].getnewaddress() + node3taddr2 = self.nodes[3].getnewaddress() + + # We should not be able to spend multiple coinbase UTXOs at once. + wait_and_assert_operationid_status( + self.nodes[3], + self.nodes[3].z_sendmany('ANY_TADDR', [{'address': recipient, 'amount': 100}]), + 'failed', + 'Could not find any non-coinbase UTXOs to spend. Coinbase UTXOs can only be sent to a single zaddr recipient from a single taddr.', + ) + + # Prepare some non-coinbase UTXOs + wait_and_assert_operationid_status( + self.nodes[3], + self.nodes[3].z_shieldcoinbase("*", node3zaddr, 0)['opid'], + ) + self.sync_all() + self.nodes[0].generate(1) + self.sync_all() + assert_equal(self.nodes[3].z_getbalance(node3zaddr), 250) + + wait_and_assert_operationid_status( + self.nodes[3], + self.nodes[3].z_sendmany( + node3zaddr, + [ + {'address': node3taddr1, 'amount': 60}, + {'address': node3taddr2, 'amount': 75}, + ], + ), + ) + self.sync_all() + self.nodes[0].generate(1) + self.sync_all() + + # Check the various balances. + assert_equal(self.nodes[1].z_getbalance(recipient), 0) + assert_equal(self.nodes[3].z_getbalance(node3taddr1), 60) + assert_equal(self.nodes[3].z_getbalance(node3taddr2), 75) + + # We should be able to spend multiple UTXOs at once + wait_and_assert_operationid_status( + self.nodes[3], + self.nodes[3].z_sendmany('ANY_TADDR', [{'address': recipient, 'amount': 100}]), + ) + + self.sync_all() + self.nodes[0].generate(1) + self.sync_all() + + # The recipient has their funds! + assert_equal(self.nodes[1].z_getbalance(recipient), 100) + + # Change is sent to a new t-address. + assert_equal(self.nodes[3].z_getbalance(node3taddr1), 0) + assert_equal(self.nodes[3].z_getbalance(node3taddr2), 0) + +if __name__ == '__main__': + WalletSendManyAnyTaddr().main() diff --git a/depend/zcash/qa/zcash/checksec.sh b/depend/zcash/qa/zcash/checksec.sh index 4e5f7aee4..f4c37e855 100755 --- a/depend/zcash/qa/zcash/checksec.sh +++ b/depend/zcash/qa/zcash/checksec.sh @@ -1,75 +1,80 @@ -#!/bin/bash +#!/usr/bin/env bash # -# The BSD License (https://www.opensource.org/licenses/bsd-license.php) +# The BSD License (http://www.opensource.org/licenses/bsd-license.php) # specifies the terms and conditions of use for checksec.sh: # -# Copyright (c) 2009-2011, Tobias Klein. +# Copyright (c) 2014-2020, Brian Davis +# Copyright (c) 2013, Robin David +# Copyright (c) 2009-2011, Tobias Klein # All rights reserved. # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions # are met: -# -# * Redistributions of source code must retain the above copyright +# +# * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the # distribution. -# * Neither the name of Tobias Klein nor the name of trapkit.de may be -# used to endorse or promote products derived from this software +# * Neither the name of Tobias Klein nor the name of trapkit.de may be +# used to endorse or promote products derived from this software # without specific prior written permission. # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. # +# --- Modified Version --- +# Name : checksec.sh +# Version : 1.7.0 +# Author : Brian Davis +# Date : Feburary 2014 +# Download: https://github.com/slimm609/checksec.sh +# +# --- Modified Version --- +# Name : checksec.sh +# Version : based on 1.5 +# Author : Robin David +# Date : October 2013 +# Download: https://github.com/RobinDavid/checksec +# +# --- Original version --- # Name : checksec.sh # Version : 1.5 # Author : Tobias Klein # Date : November 2011 # Download: http://www.trapkit.de/tools/checksec.html # Changes : http://www.trapkit.de/tools/checksec_changes.txt -# -# Description: -# -# Modern Linux distributions offer some mitigation techniques to make it -# harder to exploit software vulnerabilities reliably. Mitigations such -# as RELRO, NoExecute (NX), Stack Canaries, Address Space Layout -# Randomization (ASLR) and Position Independent Executables (PIE) have -# made reliably exploiting any vulnerabilities that do exist far more -# challenging. The checksec.sh script is designed to test what *standard* -# Linux OS and PaX (http://pax.grsecurity.net/) security features are being -# used. -# -# As of version 1.3 the script also lists the status of various Linux kernel -# protection mechanisms. -# -# Credits: -# -# Thanks to Brad Spengler (grsecurity.net) for the PaX support. -# Thanks to Jon Oberheide (jon.oberheide.org) for the kernel support. -# Thanks to Ollie Whitehouse (Research In Motion) for rpath/runpath support. -# -# Others that contributed to checksec.sh (in no particular order): -# -# Simon Ruderich, Denis Scherbakov, Stefan Kuttler, Radoslaw Madej, -# Anthony G. Basile, Martin Vaeth and Brian Davis. -# + +#set global lang to C +export LC_ALL="C" # global vars -have_readelf=1 +debug=false verbose=false - +format="cli" +SCRIPT_NAME="checksec" +SCRIPT_URL="https://github.com/slimm609/checksec.sh/raw/master/${SCRIPT_NAME}" +SIG_URL="https://github.com/slimm609/checksec.sh/raw/master/$(basename ${SCRIPT_NAME} .sh).sig" +SCRIPT_VERSION=2020071902 +SCRIPT_MAJOR=2 +SCRIPT_MINOR=3 +SCRIPT_REVISION=0 +pkg_release=false +commandsmissing=false +OPT=0 +extended_checks=false # FORTIFY_SOURCE vars FS_end=_chk FS_cnt_total=0 @@ -78,43 +83,253 @@ FS_cnt_unchecked=0 FS_chk_func_libc=0 FS_functions=0 FS_libc=0 - + +# check for required files and deps first +# check if command exists +command_exists () { + type "${1}" > /dev/null 2>&1; +} + +if [[ $(id -u) != 0 ]]; then + export PATH=${PATH}:/sbin/:/usr/sbin/ +fi + +for command in cat awk sed sysctl uname mktemp openssl grep stat file find sort head ps readlink basename id which xargs; do + if ! (command_exists ${command}); then + >&2 echo -e "\e[31mWARNING: '${command}' not found! It's required for most checks.\e[0m" + commandsmissing=true + fi +done + +if [[ ${commandsmissing} == true ]]; then + >&2 echo -e "\n\e[31mWARNING: Not all necessary commands found. Some tests might not work!\e[0m\n" + sleep 2 +fi + +if (command_exists readelf); then + readelf="readelf -W" +elif (command_exists eu-readelf); then + readelf="eu-readelf -W" +elif (command_exists greadelf); then + readelf="greadelf -W" +else + echo -e "\n\e[31mERROR: readelf is a required tool for almost all tests. Aborting...\e[0m\n" + exit +fi + +sysarch=$(uname -m) +if [[ "${sysarch}" == "x86_64" ]]; then + arch="64" +elif [[ "${sysarch}" == "i?86" ]]; then + arch="32" +elif [[ "${sysarch}" =~ "arm" ]]; then + arch="arm" +elif [[ "${sysarch}" =~ "aarch64" ]]; then + arch="aarch64" +fi + +#openssl public key for verification of updates +read -r PUBKEY < /dev/null 2>&1 ; then + ${debug} && echo "fetching update via wget" + wget --no-check-certificate -O "${2}" "${1}" >/dev/null 2>&1 + elif type curl > /dev/null 2>&1 ; then + ${debug} && echo "fetching update via curl" + curl --insecure --remote-name -o "${2}" "${1}" >/dev/null 2>&1 + else + echo 'Warning: Neither wget nor curl is available. online updates unavailable' >&2 + exit 1 + fi +} + +# Version compare +vercomp() { + if [[ "${1}" == "${2}" ]] + then + return 0 + fi + local IFS=. + local i ver1="${1}" ver2="${2}" + # fill empty fields in ver1 with zeros + for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) + do + ver1[i]=0 + done + for ((i=0; i<${#ver1[@]}; i++)) + do + if [[ -z ${ver2[i]} ]] + then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + if ((10#${ver1[i]} > 10#${ver2[i]})) + then + return 1 + fi + if ((10#${ver1[i]} < 10#${ver2[i]})) + then + return 2 + fi + done + return 0 +} + +# Update/Upgrade +# shellcheck disable=SC2120 +upgrade() { + if ${pkg_release}; then + printf "\033[31mError: Unknown option '%s'.\033[m\n\n" "${1}" + help + exit 1 + fi + umask 027 + TMP_FILE=$(mktemp /tmp/checksec.XXXXXXXXXX) + SIG_FILE=$(mktemp /tmp/checksec_sig.XXXXXXXX) + PUBKEY_FILE=$(mktemp /tmp/checksec_pubkey.XXXXXXXXXX) + fetch "${SCRIPT_URL}" "${TMP_FILE}" + fetch "${SIG_URL}" "${SIG_FILE}" + echo "${PUBKEY}" | base64 -d > "${PUBKEY_FILE}" + if ! openssl dgst -sha256 -verify "${PUBKEY_FILE}" -signature "${SIG_FILE}" "${TMP_FILE}" >/dev/null 2>&1; then + echo "file signature does not match. Update may be tampered" + rm -f "${TMP_FILE}" "${SIG_FILE}" "${PUBKEY_FILE}" >/dev/null 2>&1 + exit 1 + fi + UPDATE_VERSION=$(grep "^SCRIPT_VERSION" "${TMP_FILE}" | awk -F"=" '{ print $2 }') + if [[ "${SCRIPT_VERSION}" != "${UPDATE_VERSION}" ]]; then + PERMS=$(stat -c "%a" "$0") + rm -f "${SIG_FILE}" "${PUBKEY_FILE}" >/dev/null 2>&1 + mv "${TMP_FILE}" "$0" >/dev/null 2>&1 + exit_status=$? + if [[ "${exit_status}" -eq "0" ]]; then + echo "checksec.sh updated - Rev. ${UPDATE_VERSION}" + chmod "${PERMS}" "${0}" + else + echo "Error: Could not update... Please check permissions" + rm -f "${TMP_FILE}" >/dev/null 2>&1 + exit 1 + fi + else + echo "checksec.sh not updated... Already on latest version" + rm -f "${TMP_FILE}" "${SIG_FILE}" "${PUBKEY_FILE}" >/dev/null 2>&1 + exit 1 + fi + exit 0 +} + # version information version() { - echo "checksec v1.5, Tobias Klein, www.trapkit.de, November 2011" - echo + echo "checksec v${SCRIPT_MAJOR}.${SCRIPT_MINOR}.${SCRIPT_REVISION}, Brian Davis, github.com/slimm609/checksec.sh, Dec 2015" + echo "Based off checksec v1.5, Tobias Klein, www.trapkit.de, November 2011" + echo } # help help() { - echo "Usage: checksec [OPTION]" + echo "Usage: checksec [--format={cli,csv,xml,json}] [OPTION]" + echo echo echo "Options:" echo - echo " --file " - echo " --dir [-v]" - echo " --proc " + echo " ## Checksec Options" + echo " --file={file}" + echo " --dir={directory}" + echo " --proc={process name}" echo " --proc-all" - echo " --proc-libs " - echo " --kernel" - echo " --fortify-file " - echo " --fortify-proc " + echo " --proc-libs={process ID}" + echo " --kernel[=kconfig]" + echo " --fortify-file={executable-file}" + echo " --fortify-proc={process ID}" echo " --version" echo " --help" + if ! ${pkg_release}; then + echo " --update or --upgrade" + fi + echo + echo " ## Modifiers" + echo " --debug" + echo " --verbose" + echo " --format={cli,csv,xml,json}" + echo " --output={cli,csv,xml,json}" + echo " --extended" echo echo "For more information, see:" - echo " http://www.trapkit.de/tools/checksec.html" + echo " http://github.com/slimm609/checksec.sh" echo } -# check if command exists -command_exists () { - type $1 > /dev/null 2>&1; +# format +format () { + list="cli csv xml json" + if [[ -n "${output_format}" ]]; then + if [[ ! ${list} =~ ${output_format} ]]; then + printf "\033[31mError: Please provide a valid format {cli, csv, xml, json}.\033[m\n\n" + exit 1 + fi + fi + if [[ "${output_format}" == "xml" ]]; then + echo '' + fi + format="${output_format}" +} + +#run help if nothing is passed +if [[ $# -lt 1 ]]; then + help + exit 1 +fi + +echo_message() { + if [[ ${format} == "csv" ]]; then + echo -n -e "$2" + elif [[ ${format} == "xml" ]]; then + echo -n -e "$3" + elif [[ ${format} == "json" ]]; then + echo -n -e "$4" + else #default to cli + echo -n -e "${1}" + fi +} + +# check selinux status +getsestatus() { + local status + ${debug} && echo -e "\n***fuction getsestatus" + if (command_exists getenforce); then + ${debug} && echo "***fuction getsestatus->getenforce" + sestatus=$(getenforce) + if [[ "${sestatus}" == "Disabled" ]]; then + status=0 + elif [[ "${sestatus}" == "Permissive" ]]; then + status=1 + elif [[ "${sestatus}" == "Enforcing" ]]; then + status=2 + fi + elif (command_exists sestatus); then + ${debug} && echo "***fuction getsestatus->sestatus" + sestatus=$(sestatus | grep "SELinux status" | awk '{ print $3}') + if [[ "${sestatus}" == "disabled" ]]; then + status=0 + elif [[ "${sestatus}" == "enabled" ]]; then + sestatus2=$(sestatus | grep "Current" | awk '{ print $3}') + if [[ "${sestatus2}" == "permissive" ]]; then + status=1 + elif [[ "${sestatus2}" == "enforcing" ]]; then + status=2 + fi + fi + fi +return ${status} } # check if directory exists dir_exists () { - if [ -d $1 ] ; then + ${debug} && echo "fuction dir_exists" + if [[ -d "${1}" ]] ; then return 0 else return 1 @@ -123,7 +338,8 @@ dir_exists () { # check user privileges root_privs () { - if [ $(/usr/bin/id -u) -eq 0 ] ; then + ${debug} && echo "***function root_privs" + if [[ $(/usr/bin/id -u) -eq 0 ]] ; then return 0 else return 1 @@ -132,80 +348,189 @@ root_privs () { # check if input is numeric isNumeric () { + ${debug} && echo "***function isNumeric" echo "$@" | grep -q -v "[^0-9]" } # check if input is a string isString () { - echo "$@" | grep -q -v "[^A-Za-z]" + ${debug} && echo "***function isString" + echo "$@" | grep -q -v "[^ A-Z_a-z]" } # check file(s) filecheck() { + ${debug} && echo "***function filecheck" # check for RELRO support - if readelf -l $1 2>/dev/null | grep -q 'GNU_RELRO'; then - if readelf -d $1 2>/dev/null | grep -q 'BIND_NOW'; then - echo -n -e '\033[32mFull RELRO \033[m ' + ${debug} && echo "***function filecheck->RELRO" + if ${readelf} -l "${1}" 2>/dev/null | grep -q 'GNU_RELRO'; then + if ${readelf} -d "${1}" 2>/dev/null | grep -q 'BIND_NOW'; then + echo_message '\033[32mFull RELRO \033[m ' 'Full RELRO,' '/dev/null | grep -q '__stack_chk_fail'; then - echo -n -e '\033[32mCanary found \033[m ' + ${debug} && echo -e "\n***function filecheck->canary" + if ${readelf} -s "${1}" 2>/dev/null | grep -Eq '__stack_chk_fail|__intel_security_cookie'; then + echo_message '\033[32mCanary found \033[m ' 'Canary found,' ' canary="yes"' '"canary":"yes",' else - echo -n -e '\033[31mNo canary found\033[m ' + echo_message '\033[31mNo canary found\033[m ' 'No Canary found,' ' canary="no"' '"canary":"no",' fi # check for NX support - if readelf -W -l $1 2>/dev/null | grep 'GNU_STACK' | grep -q 'RWE'; then - echo -n -e '\033[31mNX disabled\033[m ' + ${debug} && echo -e "\n***function filecheck->nx" + if ${readelf} -l "${1}" 2>/dev/null | grep -q 'GNU_STACK'; then + if ${readelf} -l "${1}" 2>/dev/null | grep 'GNU_STACK' | grep -q 'RWE'; then + echo_message '\033[31mNX disabled\033[m ' 'NX disabled,' ' nx="no"' '"nx":"no",' + else + echo_message '\033[32mNX enabled \033[m ' 'NX enabled,' ' nx="yes"' '"nx":"yes",' + fi else - echo -n -e '\033[32mNX enabled \033[m ' - fi + echo_message '\033[31mNX disabled\033[m ' 'NX disabled,' ' nx="no"' '"nx":"no",' + fi # check for PIE support - if readelf -h $1 2>/dev/null | grep -q 'Type:[[:space:]]*EXEC'; then - echo -n -e '\033[31mNo PIE \033[m ' - elif readelf -h $1 2>/dev/null | grep -q 'Type:[[:space:]]*DYN'; then - if readelf -d $1 2>/dev/null | grep -q '(DEBUG)'; then - echo -n -e '\033[32mPIE enabled \033[m ' - else - echo -n -e '\033[33mDSO \033[m ' + ${debug} && echo -e "\n***function filecheck->pie" + if ${readelf} -h "${1}" 2>/dev/null | grep -q 'Type:[[:space:]]*EXEC'; then + echo_message '\033[31mNo PIE \033[m ' 'No PIE,' ' pie="no"' '"pie":"no",' + elif ${readelf} -h "${1}" 2>/dev/null | grep -q 'Type:[[:space:]]*DYN'; then + if ${readelf} -d "${1}" 2>/dev/null | grep -q 'DEBUG'; then + echo_message '\033[32mPIE enabled \033[m ' 'PIE enabled,' ' pie="yes"' '"pie":"yes",' + else + echo_message '\033[33mDSO \033[m ' 'DSO,' ' pie="dso"' '"pie":"dso",' fi + elif ${readelf} -h "${1}" 2>/dev/null | grep -q 'Type:[[:space:]]*REL'; then + echo_message '\033[33mREL \033[m ' 'REL,' ' pie="rel"' '"pie":"rel",' else - echo -n -e '\033[33mNot an ELF file\033[m ' - fi + echo_message '\033[33mNot an ELF file\033[m ' 'Not an ELF file,' ' pie="not_elf"' '"pie":"not_elf",' + fi + + if ${extended_checks}; then + # check for selfrando support + ${debug} && echo -e "\n***function filecheck->selfrando" + if ${readelf} -S "${1}" 2>/dev/null | grep -c txtrp | grep -q '1'; then + echo_message '\033[32mSelfrando enabled \033[m ' + else + echo_message '\033[31mNo Selfrando \033[m ' + fi + fi + + if ${extended_checks}; then + # check if compiled with Clang CFI + ${debug} && echo -e "\n***function filecheck->clangcfi" + #if $readelf -s "$1" 2>/dev/null | grep -Eq '\.cfi'; then + read -r cfifunc <<< "$($readelf -s "${1}" 2>/dev/null | grep .cfi | awk '{ print $8 }')" + func=${cfifunc/.cfi/} + if [ -n "$cfifunc" ] && $readelf -s "$1" 2>/dev/null | grep -q "$func$"; then + echo_message '\033[32mClang CFI found \033[m ' 'with CFI,' ' clangcfi="yes"' '"clangcfi":"yes",' + else + echo_message '\033[31mNo Clang CFI found\033[m ' 'without CFI,' ' clangcfi="no"' '"clangcfi":"no",' + fi + + # check if compiled with Clang SafeStack + ${debug} && echo -e "\n***function filecheck->safestack" + if $readelf -s "$1" 2>/dev/null | grep -Eq '__safestack_init'; then + echo_message '\033[32mSafeStack found \033[m ' 'with SafeStack,' ' safestack="yes"' '"safestack":"yes",' + else + echo_message '\033[31mNo SafeStack found\033[m ' 'without SafeStack,' ' safestack="no"' '"safestack":"no",' + fi + fi # check for rpath / run path - if readelf -d $1 2>/dev/null | grep -q 'rpath'; then - echo -n -e '\033[31mRPATH \033[m ' + ${debug} && echo -e "\n***function filecheck->rpath" + # search for a line that matches RPATH and extract the colon-separated path list within brackets + # example input: "0x000000000000000f (RPATH) Library rpath: [/lib/systemd:/lib/apparmor]" + IFS=: read -r -a rpath_array <<< "$(${readelf} -d "${1}" 2>/dev/null | awk -F'[][]' '/RPATH/ {print $2}')" + if [[ "${#rpath_array[@]}" -gt 0 ]]; then + if xargs stat -c %A <<< "${rpath_array[*]}" 2>/dev/null | grep -q 'rw'; then + echo_message '\033[31mRW-RPATH \033[m ' 'RPATH,' ' rpath="yes"' '"rpath":"yes",' + else + echo_message '\033[31mRPATH \033[m ' 'RPATH,' ' rpath="yes"' '"rpath":"yes",' + fi else - echo -n -e '\033[32mNo RPATH \033[m ' + echo_message '\033[32mNo RPATH \033[m ' 'No RPATH,' ' rpath="no"' '"rpath":"no",' fi - if readelf -d $1 2>/dev/null | grep -q 'runpath'; then - echo -n -e '\033[31mRUNPATH \033[m ' + ${debug} && echo -e "\n***function filecheck->runpath" + # search for a line that matches RUNPATH and extract the colon-separated path list within brackets + IFS=: read -r -a runpath_array <<< "$(${readelf} -d "${1}" 2>/dev/null | awk -F'[][]' '/RUNPATH/ {print $2}')" + if [[ "${#runpath_array[@]}" -gt 0 ]]; then + if xargs stat -c %A <<< "${runpath_array[*]}" 2>/dev/null | grep -q 'rw'; then + echo_message '\033[31mRW-RUNPATH \033[m ' 'RUNPATH,' ' runpath="yes"' '"runpath":"yes",' + else + echo_message '\033[31mRUNPATH \033[m ' 'RUNPATH,' ' runpath="yes"' '"runpath":"yes",' + fi + else + echo_message '\033[32mNo RUNPATH \033[m ' 'No RUNPATH,' ' runpath="no"' '"runpath":"no",' + fi + + # check for stripped symbols in the binary + IFS=" " read -r -a SYM_cnt <<< "$(${readelf} --symbols "${1}" 2>/dev/null | grep '\.symtab' | cut -d' ' -f5 | cut -d: -f1))" + if ${readelf} --symbols "${1}" 2>/dev/null | grep -q '\.symtab'; then + echo_message "\033[31m${SYM_cnt[0]} Symbols\t\033[m " 'Symbols,' ' symbols="yes"' '"symbols":"yes",' + else + echo_message '\033[32mNo Symbols\t\033[m ' 'No Symbols,' ' symbols="no"' '"symbols":"no",' + fi + + # check for FORTIFY SOURCE + ${debug} && echo "***function filecheck->fortify" + if [[ -e /lib/libc.so.6 ]] ; then + FS_libc=/lib/libc.so.6 + elif [[ -e /lib/libc.so.7 ]] ; then + FS_libc=/lib/libc.so.7 + elif [[ -e /lib/libc.so ]] ; then + FS_libc=/lib/libc.so + elif [[ -e /lib64/libc.so.6 ]] ; then + FS_libc=/lib64/libc.so.6 + elif [[ -e /lib/i386-linux-gnu/libc.so.6 ]] ; then + FS_libc=/lib/i386-linux-gnu/libc.so.6 + elif [[ -e /lib/x86_64-linux-gnu/libc.so.6 ]] ; then + FS_libc=/lib/x86_64-linux-gnu/libc.so.6 + elif [[ -e /lib/arm-linux-gnueabihf/libc.so.6 ]] ; then + FS_libc=/lib/arm-linux-gnueabihf/libc.so.6 + elif [[ -e /lib/aarch64-linux-gnu/libc.so.6 ]] ; then + FS_libc=/lib/aarch64-linux-gnu/libc.so.6 + elif [[ -e /usr/x86_64-gentoo-linux-musl/bin/ld ]] ; then + FS_libc=/usr/x86_64-gentoo-linux-musl/bin/ld else - echo -n -e '\033[32mNo RUNPATH \033[m ' + printf "\033[31mError: libc not found.\033[m\n\n" + exit 1 fi + + FS_chk_func_libc="$(${readelf} -s $FS_libc 2>/dev/null | sed -ne 's/.*__\(.*_chk\)@@.*/\1/p')" + FS_func_libc="${FS_chk_func_libc//_chk/}" + FS_functions="$(${readelf} --dyn-syms "${1}" 2>/dev/null | awk '{ print $8 }' | sed -e 's/_*//' -e 's/@.*//' -e '/^$/d')" + FS_cnt_checked=$(grep -cFxf <(sort <<< "${FS_chk_func_libc}") <(sort <<< "${FS_functions}")) + FS_cnt_unchecked=$(grep -cFxf <(sort <<< "${FS_func_libc}") <(sort <<< "${FS_functions}")) + FS_cnt_total=$((FS_cnt_unchecked+FS_cnt_checked)) + + if grep -q '_chk$' <<<"$FS_functions"; then + echo_message '\033[32mYes\033[m' 'Yes,' ' fortify_source="yes" ' '"fortify_source":"yes",' + else + echo_message "\033[31mNo\033[m" "No," ' fortify_source="no" ' '"fortify_source":"no",' + fi + echo_message "\t${FS_cnt_checked}\t" "${FS_cnt_checked}", "fortified=\"${FS_cnt_checked}\" " "\"fortified\":\"${FS_cnt_checked}\"," + echo_message "\t${FS_cnt_total}\t\t" "${FS_cnt_total}" "fortify-able=\"${FS_cnt_total}\"" "\"fortify-able\":\"${FS_cnt_total}\"" } # check process(es) proccheck() { + ${debug} && echo -e "\n***function proccheck" # check for RELRO support - if readelf -l $1/exe 2>/dev/null | grep -q 'Program Headers'; then - if readelf -l $1/exe 2>/dev/null | grep -q 'GNU_RELRO'; then - if readelf -d $1/exe 2>/dev/null | grep -q 'BIND_NOW'; then - echo -n -e '\033[32mFull RELRO \033[m ' + ${debug} && echo "***function proccheck->RELRO" + if ${readelf} -l "${1}/exe" 2>/dev/null | grep -q 'Program Headers'; then + if ${readelf} -l "${1}/exe" 2>/dev/null | grep -q 'GNU_RELRO'; then + if ${readelf} -d "${1}/exe" 2>/dev/null | grep -q 'BIND_NOW'; then + echo_message '\033[32mFull RELRO \033[m ' 'Full RELRO,' ' relro="full"' '"relro":"full",' else - echo -n -e '\033[33mPartial RELRO \033[m ' + echo_message '\033[33mPartial RELRO\033[m ' 'Partial RELRO,' ' relro="partial"' '"relro":"partial",' fi else - echo -n -e '\033[31mNo RELRO \033[m ' + echo_message '\033[31mNo RELRO \033[m ' 'No RELRO,' ' relro="no"' '"relro":"no",' fi else echo -n -e '\033[31mPermission denied (please run as root)\033[m\n' @@ -213,670 +538,1520 @@ proccheck() { fi # check for stack canary support - if readelf -s $1/exe 2>/dev/null | grep -q 'Symbol table'; then - if readelf -s $1/exe 2>/dev/null | grep -q '__stack_chk_fail'; then - echo -n -e '\033[32mCanary found \033[m ' + ${debug} && echo -e "\n***function proccheck->canary" + if ${readelf} -s "${1}/exe" 2>/dev/null | grep -q 'Symbol table'; then + if ${readelf} -s "${1}/exe" 2>/dev/null | grep -Eq '__stack_chk_fail|__intel_security_cookie'; then + echo_message '\033[32mCanary found \033[m ' 'Canary found,' ' canary="yes"' '"canary":"yes",' else - echo -n -e '\033[31mNo canary found \033[m ' + echo_message '\033[31mNo canary found \033[m ' 'No Canary found,' ' canary="no"' '"canary":"no",' fi else - if [ "$1" != "1" ] ; then - echo -n -e '\033[33mPermission denied \033[m ' + if [[ "${1}" == "1" ]] ; then + echo_message '\033[33mPermission denied \033[m ' 'Permission denied,' ' canary="Permission denied"' '"canary":"Permission denied",' else - echo -n -e '\033[33mNo symbol table found\033[m ' + echo_message '\033[33mNo symbol table found \033[m ' 'No symbol table found,' ' canary="No symbol table found"' '"canary":"No symbol table found",' fi fi + if ${extended_checks}; then + # check if compiled with Clang CFI + $debug && echo -e "\n***function proccheck->clangcfi" + #if $readelf -s "$1" 2>/dev/null | grep -Eq '\.cfi'; then + read -r -a cfifunc <<< "$($readelf -s "$1/exe" 2>/dev/null | grep .cfi | awk '{ print $8 }')" + func=${cfifunc/.cfi/} + # TODO: fix this check properly, need more clang CFI files to be able to test properly + # shellcheck disable=SC2128 + if [ -n "$cfifunc" ] && $readelf -s "$1/exe" 2>/dev/null | grep -q "$func$"; then + echo_message '\033[32mClang CFI found \033[m ' 'with CFI,' ' clangcfi="yes"' '"clangcfi":"yes",' + else + echo_message '\033[31mNo Clang CFI found\033[m ' 'without CFI,' ' clangcfi="no"' '"clangcfi":"no",' + fi + + # check if compiled with Clang SafeStack + $debug && echo -e "\n***function proccheck->safestack" + if $readelf -s "$1/exe" 2>/dev/null | grep -Eq '__safestack_init'; then + echo_message '\033[32mSafeStack found \033[m ' 'with SafeStack,' ' safestack="yes"' '"safestack":"yes",' + else + echo_message '\033[31mNo SafeStack found\033[m ' 'without SafeStack,' ' safestack="no"' '"safestack":"no",' + fi + fi + + # check for Seccomp mode + ${debug} && echo -e "\n***function proccheck->Seccomp" + seccomp=$(grep 'Seccomp:' "${1}/status" 2> /dev/null | cut -b10) + if [[ "${seccomp}" == "1" ]] ; then + echo_message '\033[32mSeccomp strict\033[m ' 'Seccomp strict,' ' seccomp="strict"' '"seccomp":"strict",' + elif [[ "${seccomp}" == "2" ]] ; then + echo_message '\033[32mSeccomp-bpf \033[m ' 'Seccomp-bpf,' ' seccomp="bpf"' '"seccomp":"bpf",' + else + echo_message '\033[31mNo Seccomp \033[m ' 'No Seccomp,' ' seccomp="no"' '"seccomp":"no",' + fi + # first check for PaX support - if cat $1/status 2> /dev/null | grep -q 'PaX:'; then - pageexec=( $(cat $1/status 2> /dev/null | grep 'PaX:' | cut -b6) ) - segmexec=( $(cat $1/status 2> /dev/null | grep 'PaX:' | cut -b10) ) - mprotect=( $(cat $1/status 2> /dev/null | grep 'PaX:' | cut -b8) ) - randmmap=( $(cat $1/status 2> /dev/null | grep 'PaX:' | cut -b9) ) - if [[ "$pageexec" = "P" || "$segmexec" = "S" ]] && [[ "$mprotect" = "M" && "$randmmap" = "R" ]] ; then - echo -n -e '\033[32mPaX enabled\033[m ' - elif [[ "$pageexec" = "p" && "$segmexec" = "s" && "$randmmap" = "R" ]] ; then - echo -n -e '\033[33mPaX ASLR only\033[m ' - elif [[ "$pageexec" = "P" || "$segmexec" = "S" ]] && [[ "$mprotect" = "m" && "$randmmap" = "R" ]] ; then - echo -n -e '\033[33mPaX mprot off \033[m' - elif [[ "$pageexec" = "P" || "$segmexec" = "S" ]] && [[ "$mprotect" = "M" && "$randmmap" = "r" ]] ; then - echo -n -e '\033[33mPaX ASLR off\033[m ' - elif [[ "$pageexec" = "P" || "$segmexec" = "S" ]] && [[ "$mprotect" = "m" && "$randmmap" = "r" ]] ; then - echo -n -e '\033[33mPaX NX only\033[m ' - else - echo -n -e '\033[31mPaX disabled\033[m ' + ${debug} && echo -e "\n***function proccheck->PAX" + if grep -q 'PaX:' "${1}/status" 2> /dev/null ; then + pageexec=$(grep 'PaX:' "${1}/status" 2> /dev/null | cut -b6) + segmexec=$(grep 'PaX:' "${1}/status" 2> /dev/null | cut -b10) + mprotect=$(grep 'PaX:' "${1}/status" 2> /dev/null | cut -b8) + randmmap=$(grep 'PaX:' "${1}/status" 2> /dev/null | cut -b9) + if [[ "${pageexec}" = "P" || "${segmexec}" = "S" ]] && [[ "${mprotect}" = "M" && "${randmmap}" = "R" ]] ; then + echo_message '\033[32mPaX enabled\033[m ' 'Pax enabled,' ' pax="yes"' '"pax":"yes",' + elif [[ "${pageexec}" = "p" && "${segmexec}" = "s" && "${randmmap}" = "R" ]] ; then + echo_message '\033[33mPaX ASLR only\033[m ' 'Pax ASLR only,' ' pax="aslr_only"' '"pax":"aslr_only",' + elif [[ "${pageexec}" = "P" || "${segmexec}" = "S" ]] && [[ "${mprotect}" = "m" && "${randmmap}" = "R" ]] ; then + echo_message '\033[33mPaX mprot off \033[m' 'Pax mprot off,' ' pax="mprot_off"' '"pax":"mprot_off",' + elif [[ "${pageexec}" = "P" || "${segmexec}" = "S" ]] && [[ "${mprotect}" = "M" && "${randmmap}" = "r" ]] ; then + echo_message '\033[33mPaX ASLR off\033[m ' 'Pax ASLR off,' ' pax="aslr_off"' '"pax":"aslr_off",' + elif [[ "${pageexec}" = "P" || "${segmexec}" = "S" ]] && [[ "${mprotect}" = "m" && "${randmmap}" = "r" ]] ; then + echo_message '\033[33mPaX NX only\033[m ' 'Pax NX only,' ' pax="nx_only"' '"pax":"nx_only",' + else + echo_message '\033[31mPaX disabled\033[m ' 'Pax disabled,' ' pax="no"' '"pax":"no",' fi # fallback check for NX support - elif readelf -W -l $1/exe 2>/dev/null | grep 'GNU_STACK' | grep -q 'RWE'; then - echo -n -e '\033[31mNX disabled\033[m ' + ${debug} && echo -e "\n***function proccheck->NX" + elif ${readelf} -l "${1}/exe" 2>/dev/null | grep 'GNU_STACK' | grep -q 'RWE'; then + echo_message '\033[31mNX disabled\033[m ' 'NX disabled,' ' nx="no"' '"nx":"no",' else - echo -n -e '\033[32mNX enabled \033[m ' - fi + echo_message '\033[32mNX enabled \033[m ' 'NX enabled,' ' pax="yes"' '"nx":"yes",' + fi # check for PIE support - if readelf -h $1/exe 2>/dev/null | grep -q 'Type:[[:space:]]*EXEC'; then - echo -n -e '\033[31mNo PIE \033[m ' - elif readelf -h $1/exe 2>/dev/null | grep -q 'Type:[[:space:]]*DYN'; then - if readelf -d $1/exe 2>/dev/null | grep -q '(DEBUG)'; then - echo -n -e '\033[32mPIE enabled \033[m ' - else - echo -n -e '\033[33mDynamic Shared Object\033[m ' + ${debug} && echo -e "\n***function proccheck->PIE" + if ${readelf} -h "${1}/exe" 2>/dev/null | grep -q 'Type:[[:space:]]*EXEC'; then + echo_message '\033[31mNo PIE \033[m ' 'No PIE,' ' pie="no"' '"pie":"no",' + elif ${readelf} -h "${1}/exe" 2>/dev/null | grep -q 'Type:[[:space:]]*DYN'; then + if ${readelf} -d "${1}/exe" 2>/dev/null | grep -q 'DEBUG'; then + echo_message '\033[32mPIE enabled \033[m ' 'PIE enabled,' ' pie="yes"' '"pie":"yes",' + else + echo_message '\033[33mDynamic Shared Object\033[m ' 'Dynamic Shared Object,' ' pie="dso"' '"pie":"dso",' + fi + else + echo_message '\033[33mNot an ELF file \033[m ' 'Not an ELF file,' ' pie="not_elf"' '"pie":"not_elf",' + fi + + if ${extended_checks}; then + # check for selfrando support + ${debug} && echo -e "\n***function proccheck->selfrando" + if ${readelf} -S "${1}/exe" 2>/dev/null | grep -c txtrp | grep -q '1'; then + echo_message '\033[32mSelfrando enabled \033[m ' + else + echo_message '\033[31mNo Selfrando \033[m ' fi + fi + + #check for forifty source support + FS_functions="$(${readelf} -s "${1}/exe" 2>/dev/null | awk '{ print $8 }' | sed 's/_*//' | sed -e 's/@.*//')" + if grep -q '_chk$' <<<"$FS_functions"; then + echo_message '\033[32mYes\033[m' 'Yes' " fortify_source='yes'>" '"fortify_source":"yes" }' else - echo -n -e '\033[33mNot an ELF file \033[m ' + echo_message "\033[31mNo\033[m" "No" " fortify_source='no'>" '"fortify_source":"no" }' fi } # check mapped libraries libcheck() { - libs=( $(awk '{ print $6 }' /proc/$1/maps | grep '/' | sort -u | xargs file | grep ELF | awk '{ print $1 }' | sed 's/:/ /') ) - - printf "\n* Loaded libraries (file information, # of mapped files: ${#libs[@]}):\n\n" - - for element in $(seq 0 $((${#libs[@]} - 1))) + ${debug} && echo "***function libcheck" + IFS=" " read -r -a libs <<< "$(awk '{ print $6 }' "/proc/${1}/maps" | grep '/' | sort -u | xargs file | grep ELF | awk '{ print $1 }' | sed 's/:/ /')" + echo_message "\n* Loaded libraries (file information, # of mapped files: ${#libs[@]}):\n\n" "" "" "\"libs\": {" + + for ((element=0; element<${#libs[@]}; element++)) do - echo " ${libs[$element]}:" - echo -n " " - filecheck ${libs[$element]} - printf "\n\n" + echo_message " ${libs[$element]}:\n" "${libs[$element]}," "" "" + echo_message " " "" " " "" + filecheck "${libs[$element]}" + if [[ ${element} == $((${#libs[@]} - 1)) ]]; then + echo_message "\n\n" "\n" " filename='${libs[$element]}' />\n" "" + else + echo_message "\n\n" "\n" " filename='${libs[$element]}' />\n" "}," + fi done } # check for system-wide ASLR support aslrcheck() { + ${debug} && echo "***function aslrcheck" # PaX ASLR support - if !(cat /proc/1/status 2> /dev/null | grep -q 'Name:') ; then - echo -n -e ':\033[33m insufficient privileges for PaX ASLR checks\033[m\n' - echo -n -e ' Fallback to standard Linux ASLR check' + ${debug} && echo -e "\n***function aslrcheck->PAX ASLR" + if ! (grep -q 'Name:' /proc/1/status 2> /dev/null) ; then + echo_message '\033[33m insufficient privileges for PaX ASLR checks\033[m\n' '' '' '' + echo_message ' Fallback to standard Linux ASLR check' '' '' '' fi - - if cat /proc/1/status 2> /dev/null | grep -q 'PaX:'; then - printf ": " - if cat /proc/1/status 2> /dev/null | grep 'PaX:' | grep -q 'R'; then - echo -n -e '\033[32mPaX ASLR enabled\033[m\n\n' + + if grep -q 'PaX:' /proc/1/status 2> /dev/null; then + if grep -q 'PaX:' /proc/1/status 2> /dev/null | grep -q 'R'; then + echo_message '\033[32mPaX ASLR enabled\033[m\n\n' '' '' '' else - echo -n -e '\033[31mPaX ASLR disabled\033[m\n\n' + echo_message '\033[31mPaX ASLR disabled\033[m\n\n' '' '' '' fi else + ${debug} && echo -e "\n***function aslrcheck->randomize_va_space" # standard Linux 'kernel.randomize_va_space' ASLR support # (see the kernel file 'Documentation/sysctl/kernel.txt' for a detailed description) - printf " (kernel.randomize_va_space): " - if /sbin/sysctl -a 2>/dev/null | grep -q 'kernel.randomize_va_space = 1'; then - echo -n -e '\033[33mOn (Setting: 1)\033[m\n\n' - printf " Description - Make the addresses of mmap base, stack and VDSO page randomized.\n" - printf " This, among other things, implies that shared libraries will be loaded to \n" - printf " random addresses. Also for PIE-linked binaries, the location of code start\n" - printf " is randomized. Heap addresses are *not* randomized.\n\n" - elif /sbin/sysctl -a 2>/dev/null | grep -q 'kernel.randomize_va_space = 2'; then - echo -n -e '\033[32mOn (Setting: 2)\033[m\n\n' - printf " Description - Make the addresses of mmap base, heap, stack and VDSO page randomized.\n" - printf " This, among other things, implies that shared libraries will be loaded to random \n" - printf " addresses. Also for PIE-linked binaries, the location of code start is randomized.\n\n" - elif /sbin/sysctl -a 2>/dev/null | grep -q 'kernel.randomize_va_space = 0'; then - echo -n -e '\033[31mOff (Setting: 0)\033[m\n' - else - echo -n -e '\033[31mNot supported\033[m\n' - fi - printf " See the kernel file 'Documentation/sysctl/kernel.txt' for more details.\n\n" - fi + echo_message " (kernel.randomize_va_space): " '' '' '' + if sysctl -a 2>/dev/null | grep -q 'kernel.randomize_va_space = 1'; then + echo_message '\033[33mPartial (Setting: 1)\033[m\n\n' '' '' '' + echo_message " Description - Make the addresses of mmap base, stack and VDSO page randomized.\n" '' '' '' + echo_message " This, among other things, implies that shared libraries will be loaded to \n" '' '' '' + echo_message " random addresses. Also for PIE-linked binaries, the location of code start\n" '' '' '' + echo_message " is randomized. Heap addresses are *not* randomized.\n\n" '' '' '' + elif sysctl -a 2>/dev/null | grep -q 'kernel.randomize_va_space = 2'; then + echo_message '\033[32mFull (Setting: 2)\033[m\n\n' '' '' '' + echo_message " Description - Make the addresses of mmap base, heap, stack and VDSO page randomized.\n" '' '' '' + echo_message " This, among other things, implies that shared libraries will be loaded to random \n" '' '' '' + echo_message " addresses. Also for PIE-linked binaries, the location of code start is randomized.\n\n" '' '' '' + elif sysctl -a 2>/dev/null | grep -q 'kernel.randomize_va_space = 0'; then + echo_message '\033[31mNone (Setting: 0)\033[m\n' '' '' '' + else + echo_message '\033[31mNot supported\033[m\n' '' '' '' + fi + echo_message " See the kernel file 'Documentation/sysctl/kernel.txt' for more details.\n\n" '' '' '' + fi } # check cpu nx flag nxcheck() { - if grep -q nx /proc/cpuinfo; then - echo -n -e '\033[32mYes\033[m\n\n' + ${debug} && echo -e "\n***function nxcheck" + if grep -qFw nx /proc/cpuinfo; then + echo_message '\033[32mYes\033[m\n\n' '' '' '' else - echo -n -e '\033[31mNo\033[m\n\n' + echo_message '\033[31mNo\033[m\n\n' '' '' '' fi } +#Check core dumps restricted? +coredumpcheck() { + ${debug} && echo -e "\n***function coredumpcheck" + coreValue=$(grep -Exic "hard[[:blank:]]+core[[:blank:]]+0" /etc/security/limits.conf) + coreValueDefault=$(grep -Exic "\*[[:blank:]]+hard[[:blank:]]+core[[:blank:]]+0" /etc/security/limits.conf) + dumpableValue=$(sysctl -b -e fs.suid_dumpable) + if { [[ "${coreValue}" == 1 ]] || [[ "${coreValueDefault}" == 1 ]]; } && { [[ "${dumpableValue}" == 0 ]] || [[ "${dumpableValue}" == 2 ]]; }; then + echo_message '\033[32mRestricted\033[m\n\n' '' '' '' + else + echo_message '\033[31mNot Restricted\033[m\n\n' '' '' '' + fi +} + # check for kernel protection mechanisms kernelcheck() { - printf " Description - List the status of kernel protection mechanisms. Rather than\n" - printf " inspect kernel mechanisms that may aid in the prevention of exploitation of\n" - printf " userspace processes, this option lists the status of kernel configuration\n" - printf " options that harden the kernel itself against attack.\n\n" - printf " Kernel config: " - - if [ -f /proc/config.gz ] ; then + ${debug} && echo "***function kernelcheck" + echo_message " Description - List the status of kernel protection mechanisms. Rather than\n" '' '' '' + echo_message " inspect kernel mechanisms that may aid in the prevention of exploitation of\n" '' '' '' + echo_message " userspace processes, this option lists the status of kernel configuration\n" '' '' '' + echo_message " options that harden the kernel itself against attack.\n\n" '' '' '' + echo_message " Kernel config:\n" '' '' '{ "kernel": ' + + if [[ ! "${1}" == "" ]] ; then + kconfig="cat ${1}" + echo_message " Warning: The config ${1} on disk may not represent running kernel config!\n\n" "${1}" "" '{ "KernelConfig":"not_found" } }' exit 0 fi + ${debug} && ${kconfig} | grep "CONFIG_GRKERNSEC" + ${debug} && ${kconfig} | grep "CONFIG_PAX" + + echo_message " Vanilla Kernel ASLR: " "" "" "" + randomize_va=$(sysctl -b -e kernel.randomize_va_space) + if [[ "x${randomize_va}" == "x2" ]]; then + echo_message "\033[32mFull\033[m\n" "Full," " randomize_va_space='full'" ', "randomize_va_space":"full"' + elif [[ "x${randomize_va}" == "x1" ]]; then + echo_message "\033[33mPartial\033[m\n" "Partial," " randomize_va_space='partial'" ', "randomize_va_space":"partial"' + else + echo_message "\033[31mNone\033[m\n" "None," " randomize_va_space='none'" ', "randomize_va_space":"none"' + fi - printf " GCC stack protector support: " - if $kconfig | grep -qi 'CONFIG_CC_STACKPROTECTOR=y'; then - printf "\033[32mEnabled\033[m\n" + echo_message " NX protection: " "" "" "" + if (command_exists dmesg) && (root_privs); then + nx_protection=$(dmesg -t 2>/dev/null | grep -Fw NX) + if [[ "x${nx_protection}" == "xNX (Execute Disable) protection: active" ]]; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " nx_protection='yes'" ', "nx_protection":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " nx_protection='no'" ', "nx_protection":"no"' + fi else - printf "\033[31mDisabled\033[m\n" + echo_message "\033[33mSkipped\033[m\n" "Skipped," " nx_protection='skipped'" ', "nx_protection":"skipped"' fi - printf " Strict user copy checks: " - if $kconfig | grep -qi 'CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y'; then - printf "\033[32mEnabled\033[m\n" + echo_message " Protected symlinks: " "" "" "" + symlink=$(sysctl -b -e fs.protected_symlinks) + if [[ "x${symlink}" == "x1" ]]; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " protect_symlinks='yes'" ', "protect_symlinks":"yes"' else - printf "\033[31mDisabled\033[m\n" + echo_message "\033[31mDisabled\033[m\n" "Disabled," " protect_symlinks='no'" ', "protect_symlinks":"no"' fi - printf " Enforce read-only kernel data: " - if $kconfig | grep -qi 'CONFIG_DEBUG_RODATA=y'; then - printf "\033[32mEnabled\033[m\n" + echo_message " Protected hardlinks: " "" "" "" + hardlink=$(sysctl -b -e fs.protected_hardlinks) + if [[ "x${hardlink}" == "x1" ]]; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " protect_hardlinks='yes'" ', "protect_hardlinks":"yes"' else - printf "\033[31mDisabled\033[m\n" + echo_message "\033[31mDisabled\033[m\n" "Disabled," " protect_hardlinks='no'" ', "protect_hardlinks":"no"' fi - printf " Restrict /dev/mem access: " - if $kconfig | grep -qi 'CONFIG_STRICT_DEVMEM=y'; then - printf "\033[32mEnabled\033[m\n" + + echo_message " Protected fifos: " "" "" "" + fifos=$(sysctl -b -e fs.protected_fifos) + if [[ "x${fifos}" == "x" ]]; then + echo_message "\033[33mUnsupported\033[m\n" "Unsupported," " protect_fifos='unsupported'" ', "protect_fifos":"unsupported"' + elif [[ "x${fifos}" == "x2" ]]; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " protect_fifos='yes'" ', "protect_fifos":"yes"' else - printf "\033[31mDisabled\033[m\n" + echo_message "\033[31mDisabled\033[m\n" "Disabled," " protect_fifos='no'" ', "protect_fifos":"no"' fi - printf " Restrict /dev/kmem access: " - if $kconfig | grep -qi 'CONFIG_DEVKMEM=y'; then - printf "\033[31mDisabled\033[m\n" + echo_message " Protected regular: " "" "" "" + regular=$(sysctl -b -e fs.protected_regular) + if [[ "x${regular}" == "x" ]]; then + echo_message "\033[33mUnsupported\033[m\n" "Unsupported," " protect_regular='unsupported'" ', "protect_regular":"unsupported"' + elif [[ "x${regular}" == "x2" ]]; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " protect_regular='yes'" ', "protect_regular":"yes"' else - printf "\033[32mEnabled\033[m\n" + echo_message "\033[31mDisabled\033[m\n" "Disabled," " protect_regular='no'" ', "protect_regular":"no"' fi - printf "\n" - printf "* grsecurity / PaX: " + echo_message " Ipv4 reverse path filtering: " "" "" "" + ipv4_rpath=$(sysctl -b -e net.ipv4.conf.all.rp_filter) + if [[ "x${ipv4_rpath}" == "x1" ]]; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " ipv4_rpath='yes'" ', "ipv4_rpath":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " ipv4_rpath='no'" ', "ipv4_rpath":"no"' + fi + + echo_message " Kernel heap randomization: " "" "" "" + # NOTE: y means it turns off kernel heap randomization for backwards compatability (libc5) + if ${kconfig} | grep -qi 'CONFIG_COMPAT_BRK=y'; then + echo_message "\033[31mDisabled\033[m\n" "Disabled," " kernel_heap_randomization='no'" ', "kernel_heap_randomization":"no"' + else + echo_message "\033[32mEnabled\033[m\n" "Enabled," " kernel_heap_randomization='yes'" ', "kernel_heap_randomization":"yes"' + fi - if $kconfig | grep -qi 'CONFIG_GRKERNSEC=y'; then - if $kconfig | grep -qi 'CONFIG_GRKERNSEC_HIGH=y'; then - printf "\033[32mHigh GRKERNSEC\033[m\n\n" - elif $kconfig | grep -qi 'CONFIG_GRKERNSEC_MEDIUM=y'; then - printf "\033[33mMedium GRKERNSEC\033[m\n\n" - elif $kconfig | grep -qi 'CONFIG_GRKERNSEC_LOW=y'; then - printf "\033[31mLow GRKERNSEC\033[m\n\n" + if ${kconfig} | grep -qi 'CONFIG_CC_STACKPROTECTOR' || ${kconfig} | grep -qa 'CONFIG_STACKPROTECTOR'; then + echo_message " GCC stack protector support: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_CC_STACKPROTECTOR=y' || ${kconfig} | grep -qi 'CONFIG_STACKPROTECTOR=y' ; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " gcc_stack_protector='yes'" ', "gcc_stack_protector":"yes"' + + if ${kconfig} | grep -qi 'CONFIG_CC_STACKPROTECTOR_STRONG' || ${kconfig} | grep -qi 'CONFIG_STACKPROTECTOR_STRONG'; then + echo_message " GCC stack protector strong: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_CC_STACKPROTECTOR_STRONG=y' || ${kconfig} | grep -qi 'CONFIG_STACKPROTECTOR_STRONG=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " gcc_stack_protector_strong='yes'" ', "gcc_stack_protector_strong":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " gcc_stack_protector_strong='no'" ', "gcc_stack_protector_strong":"no"' + fi + fi else - printf "\033[33mCustom GRKERNSEC\033[m\n\n" + echo_message "\033[31mDisabled\033[m\n" "Disabled," " gcc_stack_protector='no'" ', "gcc_stack_protector":"no"' fi + fi - printf " Non-executable kernel pages: " - if $kconfig | grep -qi 'CONFIG_PAX_KERNEXEC=y'; then - printf "\033[32mEnabled\033[m\n" + if ${kconfig} | grep -qi 'CONFIG_GCC_PLUGIN_STRUCTLEAK'; then + echo_message " GCC structleak plugin: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_GCC_PLUGIN_STRUCTLEAK=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " gcc_structleak='yes'" ', "gcc_structleak":"yes"' + echo_message " GCC structleak by ref plugin: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " gcc_structleak_byref='yes'" ', "gcc_structleak_byref":"yes"' + else + echo_message "\033[32mEnabled\033[m\n" "Enabled," " gcc_structleak_byref='no'" ', "gcc_structleak_byref":"no"' + fi else - printf "\033[31mDisabled\033[m\n" + echo_message "\033[31mDisabled\033[m\n" "Disabled," " gcc_structleak='no'" ', "gcc_structleak":"no"' fi + fi - printf " Prevent userspace pointer deref: " - if $kconfig | grep -qi 'CONFIG_PAX_MEMORY_UDEREF=y'; then - printf "\033[32mEnabled\033[m\n" + if ${kconfig} | grep -qi 'CONFIG_SLAB_FREELIST_RANDOM'; then + echo_message " SLAB freelist randomization: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_SLAB_FREELIST_RANDOM=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " slab_freelist_randomization='yes'" ', "slab_freelist_randomization":"yes"' else - printf "\033[31mDisabled\033[m\n" + echo_message "\033[31mDisabled\033[m\n" "Disabled," " slab_freelist_randomization='no'" ', "slab_freelist_randomization":"no"' fi + fi - printf " Prevent kobject refcount overflow: " - if $kconfig | grep -qi 'CONFIG_PAX_REFCOUNT=y'; then - printf "\033[32mEnabled\033[m\n" + if ${kconfig} | grep -qi 'CPU_SW_DOMAIN_PAN=y'; then + echo_message " Use CPU domains: " "" "" "" + if ${kconfig} | grep -qi 'CPU_SW_DOMAIN_PAN=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " cpu_sw_domain'yes'" ', "cpu_sw_domain":"yes"' else - printf "\033[31mDisabled\033[m\n" + echo_message "\033[31mDisabled\033[m\n" "Disabled," " cpu_sw_domain='no'" ', "cpu_sw_domain":"no"' fi + fi + - printf " Bounds check heap object copies: " - if $kconfig | grep -qi 'CONFIG_PAX_USERCOPY=y'; then - printf "\033[32mEnabled\033[m\n" + if ${kconfig} | grep -qi 'CONFIG_VMAP_STACK'; then + echo_message " Virtually-mapped kernel stack: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_VMAP_STACK=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " virtually_mapped_stack='yes'" ', "virtually_mapped_stack":"yes"' else - printf "\033[31mDisabled\033[m\n" + echo_message "\033[31mDisabled\033[m\n" "Disabled," " virtually_mapped_stack='no'" ', "virtually_mapped_stack":"no"' fi + fi + - printf " Disable writing to kmem/mem/port: " - if $kconfig | grep -qi 'CONFIG_GRKERNSEC_KMEM=y'; then - printf "\033[32mEnabled\033[m\n" + if ${kconfig} | grep -qi 'CONFIG_DEVMEM'; then + if ${kconfig} | grep -qi 'CONFIG_DEVMEM=y'; then + echo_message " Restrict /dev/mem access: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_STRICT_DEVMEM=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " restrict_dev_mem_access='yes'" ', "restrict_dev_mem_access":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " restrict_dev_mem_access='no'" ', "restrict_dev_mem_access":"no"' + fi + + echo_message " Restrict I/O access to /dev/mem: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_IO_STRICT_DEVMEM=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " restrict_io_dev_mem_access='yes'" ', "restrict_io_dev_mem_access":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " restrict_io_dev_mem_access='no'" ', "restrict_io_dev_mem_access":"no"' + fi + fi + fi + + + if ! ${kconfig} | grep -qi 'CONFIG_PAX'; then + if ${kconfig} | grep -qi 'CONFIG_DEBUG_RODATA' || ${kconfig} | grep -qi '|CONFIG_STRICT_KERNEL_RWX'; then + echo_message " Enforce read-only kernel data: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_DEBUG_RODATA=y\|CONFIG_STRICT_KERNEL_RWX=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " ro_kernel_data='yes'" ', "ro_kernel_data":"yes"' + echo_message " Enforce read-only module data: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_STRICT_MODULE_RWX=y\|CONFIG_DEBUG_SET_MODULE_RONX'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " ro_module_data='yes'" ', "ro_module_data":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " ro_module_data='no'" ', "ro_module_data":"no"' + fi + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " ro_kernel_data='no'" ', "ro_kernel_data":"no"' + fi + fi + fi + + if ${kconfig} | grep -qi 'CONFIG_REFCOUNT_FULL'; then + echo_message " Full reference count validation: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_REFCOUNT_FULL=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " full_refcount_validation='yes'" ', "full_refcount_validation":"yes"' else - printf "\033[31mDisabled\033[m\n" + echo_message "\033[31mDisabled\033[m\n" "Disabled," " full_refcount_validation='no'" ', "full_refcount_validation":"no"' fi + fi + + echo_message " Exec Shield: " """" "" + execshield=$(sysctl -b -e kernel.exec-shield) + if [[ "x${execshield}" == "x" ]]; then + echo_message '\033[32mUnsupported\033[m\n\n' '' '' '' + elif [[ "x${execshield}" == "x1" ]]; then + echo_message '\033[32mEnabled\033[m\n\n' '' '' '' + else + echo_message '\033[31mDisabled\033[m\n\n' '' '' '' + fi - printf " Disable privileged I/O: " - if $kconfig | grep -qi 'CONFIG_GRKERNSEC_IO=y'; then - printf "\033[32mEnabled\033[m\n" + if ${kconfig} | grep -qi 'CONFIG_HARDENED_USERCOPY'; then + echo_message " Hardened Usercopy: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_HARDENED_USERCOPY=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " hardened_usercopy='yes'" ', "hardened_usercopy":"yes"' else - printf "\033[31mDisabled\033[m\n" + echo_message "\033[31mDisabled\033[m\n" "Disabled," " hardened_usercopy='no'" ', "hardened_usercopy":"no"' fi + fi - printf " Harden module auto-loading: " - if $kconfig | grep -qi 'CONFIG_GRKERNSEC_MODHARDEN=y'; then - printf "\033[32mEnabled\033[m\n" + if ${kconfig} | grep -qi 'CONFIG_FORTIFY_SOURCE'; then + echo_message " Harden str/mem functions: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_FORTIFY_SOURCE=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " fortify_source='yes'" ', "fortify_source":"yes"' else - printf "\033[31mDisabled\033[m\n" + echo_message "\033[31mDisabled\033[m\n" "Disabled," " fortify_source='no'" ', "fortify_source":"no"' fi + fi - printf " Hide kernel symbols: " - if $kconfig | grep -qi 'CONFIG_GRKERNSEC_HIDESYM=y'; then - printf "\033[32mEnabled\033[m\n" + if ${kconfig} | grep -qi 'CONFIG_DEVKMEM'; then + echo_message " Restrict /dev/kmem access: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_DEVKMEM=y'; then + echo_message "\033[31mDisabled\033[m\n" "Disabled," " restrict_dev_kmem_access='no'" ', "restrict_dev_kmem_access":"no"' else - printf "\033[31mDisabled\033[m\n" + echo_message "\033[32mEnabled\033[m\n" "Enabled," " restrict_dev_kmem_access='yes'" ', "restrict_dev_kmem_access":"yes"' + fi + fi + + #x86 only + if [[ "${arch}" == "32" ]] || [[ "${arch}" == "64" ]]; then + echo_message "\n" "\n" "" "" + echo_message "* X86 only: \n" "" "" "" + + if ! ${kconfig} | grep -qi 'CONFIG_PAX_SIZE_OVERFLOW=y'; then + if ${kconfig} | grep -qi 'CONFIG_DEBUG_STRICT_USER_COPY_CHECKS'; then + echo_message " Strict user copy checks: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " strict_user_copy_check='yes'" ', "strict_user_copy_check":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " strict_user_copy_check='no'" ', "strict_user_copy_check":"no"' + fi + fi + fi + + if ${kconfig} | grep -qi 'CONFIG_RANDOMIZE_BASE' || ${kconfig} | grep -qi 'CONFIG_PAX_ASLR'; then + echo_message " Address space layout randomization: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_RANDOMIZE_BASE=y' || ${kconfig} | grep -qi 'CONFIG_PAX_ASLR=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " random_address_space_layout='yes'" ', "random_address_space_layout":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " random_address_space_layout='no'" ', "random_address_space_layout":"no"' + fi + fi + fi + + #ARM only + if [[ "${arch}" == "arm" ]]; then + echo_message "\n" "\n" "\n" "" + echo_message "* ARM only: \n" "" "" "" + + if ${kconfig} | grep -qi 'CONFIG_ARM_KERNMEM_PERMS'; then + echo_message " Restrict kernel memory permissions: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_ARM_KERNMEM_PERMS=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " arm_kernmem_perms='yes'" ', "arm_kernmem_perms":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " arm_kernmem_perms='no'" ', "arm_kernmem_perms":"no"' + fi + fi + + if ${kconfig} | grep -qi 'CONFIG_DEBUG_ALIGN_RODATA'; then + echo_message " Make rodata strictly non-excutable: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_DEBUG_ALIGN_RODATA=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " arm_strict_rodata='yes'" ', "arm_strict_rodata":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " arm_strict_rodata='no'" ', "arm_strict_rodata":"no"' + fi + fi + + fi + + #ARM64 only + if [[ "${arch}" == "aarch64" ]]; then + echo_message "\n" "\n" "\n" "" + echo_message "* ARM64 only: \n" "" "" "" + + if ${kconfig} | grep -qi 'CONFIG_UNMAP_KERNEL_AT_EL0'; then + echo_message " Unmap kernel in userspace (KAISER): " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_UNMAP_KERNEL_AT_EL0=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " unmap_kernel_in_userspace='yes'" ', "unmap_kernel_in_userspace":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " unmap_kernel_in_userspace='no'" ', "unmap_kernel_in_userspace":"no"' + fi + fi + + if ${kconfig} | grep -qi 'CONFIG_HARDEN_BRANCH_PREDICTOR'; then + echo_message " Harden branch predictor: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_HARDEN_BRANCH_PREDICTOR=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " harden_branch_predictor='yes'" ', "harden_branch_predictor":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " harden_branch_predictor='no'" ', "harden_branch_predictor":"no"' + fi + fi + + if ${kconfig} | grep -qi 'CONFIG_HARDEN_EL2_VECTORS'; then + echo_message " Harden EL2 vector mapping: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_HARDEN_EL2_VECTORS=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " harden_el2_vector_mapping='yes'" ', "harden_el2_vector_mapping":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " harden_el2_vector_mapping='no'" ', "harden_el2_vector_mapping":"no"' + fi + fi + + if ${kconfig} | grep -qi 'CONFIG_ARM64_SSBD'; then + echo_message " Speculative store bypass disable: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_ARM64_SSBD=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " speculative_store_bypass_disable='yes'" ', "speculative_store_bypass_disable":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " speculative_store_bypass_disable='no'" ', "speculative_store_bypass_disable":"no"' + fi fi + + if ${kconfig} | grep -qi 'CONFIG_ARM64_SW_TTBR0_PAN'; then + echo_message " Emulate privileged access never: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_ARM64_SW_TTBR0_PAN=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " emulate_privileged_access_never='yes'" ', "emulate_privileged_access_never":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " emulate_privileged_access_never='no'" ', "emulate_privileged_access_never":"no"' + fi + fi + + if ${kconfig} | grep -qi 'CONFIG_RANDOMIZE_BASE'; then + echo_message " Randomize address of kernel image: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_RANDOMIZE_BASE=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " randomize_kernel_address='yes'" ', "randomize_kernel_address":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " randomize_kernel_address='no'" ', "randomize_kernel_address":"no"' + fi + fi + + if ${kconfig} | grep -qi 'CONFIG_RANDOMIZE_MODULE_REGION_FULL'; then + echo_message " Randomize module region over 4GB: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_RANDOMIZE_MODULE_REGION_FULL=y'; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " randomize_module_region_full='yes'" ', "randomize_module_region_full":"yes"' + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " randomize_module_region_full='no'" ', "randomize_module_region_full":"no"' + fi + fi + fi + + echo_message "" "" ">" "}," + + + echo_message "\n" "\n" "\n" "" + echo_message "* SELinux: " "" "" "" + if ${kconfig} | grep -qi 'CONFIG_SECURITY_SELINUX=y'; then + getsestatus + sestatus=$? + if [[ ${sestatus} == 0 ]]; then + echo_message "\033[31mDisabled\033[m\n" "Disabled,," " \n" " }" + echo_message "* grsecurity / PaX: " "" "" "" + + if ${kconfig} | grep -qi 'CONFIG_GRKERNSEC=y'; then + if ${kconfig} | grep -qi 'CONFIG_GRKERNSEC_HIGH=y'; then + echo_message "\033[32mHigh GRKERNSEC\033[m\n\n" "High GRKERNSEC," " /dev/null || echo $?) + if [[ "x${grcheck}" != "x255" ]] && [[ "x${grcheck}" != "x0" ]]; then + echo_message "\033[32mEnabled\033[m\n" "Enabled," " grsec_sysctl_${command}='yes'" ", \"grsec_sysctl_${command}\":\"yes\"" + else + echo_message "\033[31mDisabled\033[m\n" "Disabled," " grsec_sysctl_${command}='no'" ", \"grsec_sysctl_${command}\":\"no\"" + fi + if [[ "${command}" == "tpe_restrict_all" ]]; then + echo_message "" "" "" " } }" + else + echo_message "" "" "" "" + fi + done + echo_message "" "" " />\n\n" "" fi else - printf "\033[31mNo KERNHEAP\033[m\n\n" - printf " The KERNHEAP hardening patchset is available here:\n" - printf " https://www.subreption.com/kernheap/\n\n" + echo_message "\033[31mNo GRKERNSEC\033[m\n\n" "No GRKERNSEC,,,,,,,," " \n\n" ', "grsecurity": { "grsecurity_config":"no" } }' + echo_message " The grsecurity / PaX patchset is available here:\n" "" "" "" + echo_message " http://grsecurity.net/\n" "" "" "" fi } # --- FORTIFY_SOURCE subfunctions (start) --- - # is FORTIFY_SOURCE supported by libc? FS_libc_check() { - printf "* FORTIFY_SOURCE support available (libc) : " + ${debug} && echo "***function FS_libc_check" + echo_message "* FORTIFY_SOURCE support available (libc) : " "" "" - if [ "${#FS_chk_func_libc[@]}" != "0" ] ; then - printf "\033[32mYes\033[m\n" + if [[ "${#FS_chk_func_libc[@]}" != "0" ]] ; then + echo_message "\033[32mYes\033[m\n" "Yes," " libc_fortify_source='yes' " ', "libc_fortify_source":"yes"' else - printf "\033[31mNo\033[m\n" + echo_message "\033[31mNo\033[m\n" "No," " libc_fortify_source='no' " ', "libc_fortify_source":"no"' exit 1 fi } # was the binary compiled with FORTIFY_SOURCE? FS_binary_check() { - printf "* Binary compiled with FORTIFY_SOURCE support: " + ${debug} && echo "***function FS_binary_check" + echo_message "* Binary compiled with FORTIFY_SOURCE support: " "" "" "" - for FS_elem_functions in $(seq 0 $((${#FS_functions[@]} - 1))) + for ((FS_elem_functions=0; FS_elem_functions<${#FS_functions[@]}; FS_elem_functions++)) do - if [[ ${FS_functions[$FS_elem_functions]} =~ _chk ]] ; then - printf "\033[32mYes\033[m\n" + if [[ ${FS_functions[$FS_elem_functions]} =~ _chk$ ]] ; then + echo_message "\033[32mYes\033[m\n" "Yes\n" " binary_compiled_with_fortify='yes'>\n" ', "binary_compiled_with_fortify":"yes"' return fi done - printf "\033[31mNo\033[m\n" + echo_message "\033[31mNo\033[m\n" "No\n" " binary_compiled_with_fortify='no'>\n" ', "binary_compiled_with_fortify":"no"' exit 1 } FS_comparison() { - echo - printf " ------ EXECUTABLE-FILE ------- . -------- LIBC --------\n" - printf " FORTIFY-able library functions | Checked function names\n" - printf " -------------------------------------------------------\n" - - for FS_elem_libc in $(seq 0 $((${#FS_chk_func_libc[@]} - 1))) + ${debug} && echo "***function FS_comparison" + echo_message "\n" "" "" + echo_message " ------ EXECUTABLE-FILE ------- . -------- LIBC --------\n" "" "" "" + echo_message " Fortifiable library functions | Checked function names\n" "" "" "" + echo_message " -------------------------------------------------------\n" "" "" "" + + ${debug} && echo -e "\n***function FS_comparison->FS_elem_libc" + for ((FS_elem_libc=0; FS_elem_libc<${#FS_chk_func_libc[@]}; FS_elem_libc++)) do - for FS_elem_functions in $(seq 0 $((${#FS_functions[@]} - 1))) + ${debug} && echo -e "\n***function FS_comparison->FS_elem_libc->FS_elem_functions" + for ((FS_elem_functions=0; FS_elem_functions<${#FS_functions[@]}; FS_elem_functions++)) do FS_tmp_func=${FS_functions[$FS_elem_functions]} FS_tmp_libc=${FS_chk_func_libc[$FS_elem_libc]} - if [[ $FS_tmp_func =~ ^$FS_tmp_libc$ ]] ; then - printf " \033[31m%-30s\033[m | __%s%s\n" $FS_tmp_func $FS_tmp_libc $FS_end - let FS_cnt_total++ - let FS_cnt_unchecked++ - elif [[ $FS_tmp_func =~ ^$FS_tmp_libc(_chk) ]] ; then - printf " \033[32m%-30s\033[m | __%s%s\n" $FS_tmp_func $FS_tmp_libc $FS_end - let FS_cnt_total++ - let FS_cnt_checked++ + if [[ ${FS_tmp_func} =~ ^${FS_tmp_libc}$ ]] ; then + if [[ ${format} == "cli" ]]; then + printf " \033[31m%-30s\033[m | __%s%s\n" "${FS_tmp_func}" "${FS_tmp_libc}" "${FS_end}" + else + if [[ $FS_elem_functions == 0 ]]; then + echo_message "" "${FS_tmp_func},${FS_tmp_libc},yes\n" " \n" ", \"function\": { \"name\":\"${FS_tmp_func}\", \"libc\":\"${FS_tmp_libc}\", \"fortifiable\":\"yes\" }" + elif [[ $FS_elem_functions == $((${#FS_functions[@]} - 1 )) ]]; then + echo_message "" "${FS_tmp_func},${FS_tmp_libc},yes\n" " \n" ", \"function\": { \"name\":\"${FS_tmp_func}\", \"libc\":\"${FS_tmp_libc}\", \"fortifiable\":\"yes\" }" + else + echo_message "" "${FS_tmp_func},${FS_tmp_libc},yes\n" " \n" ", \"function\": { \"name\":\"${FS_tmp_func}\", \"libc\":\"${FS_tmp_libc}\", \"fortifiable\":\"yes\" }" + fi + fi + (( FS_cnt_total++ )) + (( FS_cnt_unchecked++ )) + elif [[ ${FS_tmp_func} =~ ^${FS_tmp_libc}(_chk)$ ]] ; then + if [[ ${format} == "cli" ]]; then + printf " \033[32m%-30s\033[m | __%s%s\n" "${FS_tmp_func}" "${FS_tmp_libc}" "${FS_end}" + else + if [[ $FS_elem_functions == 0 ]]; then + echo_message "" "${FS_tmp_func},${FS_tmp_libc},no\n" " \n" ", \"function\": { \"name\":\"${FS_tmp_func}\", \"libc\":\"${FS_tmp_libc}\", \"fortifiable\":\"no\" }" + elif [[ $FS_elem_functions == $((${#FS_functions[@]} - 1 )) ]]; then + echo_message "" "${FS_tmp_func},${FS_tmp_libc},no\n" " \n" ", \"function\": { \"name\":\"${FS_tmp_func}\", \"libc\":\"${FS_tmp_libc}\", \"fortifiable\":\"no\" }" + else + echo_message "" "${FS_tmp_func},${FS_tmp_libc},no\n" " \n" ", \"function\": { \"name\":\"${FS_tmp_func}\", \"libc\":\"${FS_tmp_libc}\", \"fortifiable\":\"no\" }" fi + fi + (( FS_cnt_total++ )) + (( FS_cnt_checked++ )) + fi done done } FS_summary() { - echo - printf "SUMMARY:\n\n" - printf "* Number of checked functions in libc : ${#FS_chk_func_libc[@]}\n" - printf "* Total number of library functions in the executable: ${#FS_functions[@]}\n" - printf "* Number of FORTIFY-able functions in the executable : %s\n" $FS_cnt_total - printf "* Number of checked functions in the executable : \033[32m%s\033[m\n" $FS_cnt_checked - printf "* Number of unchecked functions in the executable : \033[31m%s\033[m\n" $FS_cnt_unchecked - echo + ${debug} && echo "***function FS_summary" + echo_message "\n" "" "\n" "" + echo_message "SUMMARY:\n\n" "" "" "" + echo_message "* Number of checked functions in libc : ${#FS_chk_func_libc[@]}\n" "${#FS_chk_func_libc[@]}," " " ", \"nb_unchecked_func\":\"${FS_cnt_unchecked}\" } " + echo_message "\n" "\n" "\n" "" } -# --- FORTIFY_SOURCE subfunctions (end) --- - -if !(command_exists readelf) ; then - printf "\033[31mWarning: 'readelf' not found! It's required for most checks.\033[m\n\n" - have_readelf=0 -fi - -# parse command-line arguments -case "$1" in - - --version) - version - exit 0 - ;; +debug_report() { + echo "***** Checksec debug *****" + failed=false + id + uname -a + + echo "checksec version: ${SCRIPT_MAJOR}.${SCRIPT_MINOR}.${SCRIPT_REVISION} -- ${SCRIPT_VERSION}" + + if [[ -f /etc/os-release ]]; then + # freedesktop.org and systemd + # shellcheck disable=SC1091 + source /etc/os-release + # shellcheck disable=SC2153 + OS=${NAME} + VER=${VERSION_ID} + elif type lsb_release >/dev/null 2>&1; then + # linuxbase.org + OS=$(lsb_release -si) + VER=$(lsb_release -sr) + elif [[ -f /etc/lsb-release ]]; then + # For some versions of Debian/Ubuntu without lsb_release command + # shellcheck disable=SC1091 + source /etc/lsb-release + OS=${DISTRIB_ID} + VER=${DISTRIB_RELEASE} + elif [[ -f /etc/debian_version ]]; then + # Older Debian/Ubuntu/etc. + OS=Debian + VER=$(cat /etc/debian_version) + elif [[ -f /etc/SuSe-release ]]; then + # Older SuSE/etc. + OS=$(cat /etc/SuSe-release) + VER=$(uname -r) + elif [[ -f /etc/redhat-release ]]; then + # Older Red Hat, CentOS, etc. + OS=$(cat /etc/redhat-release) + VER=$(uname -r) + else + # Fall back to uname, e.g. "Linux ", also works for BSD, etc. + OS=$(uname -s) + VER=$(uname -r) + fi - --help) - help - exit 0 - ;; + echo "OS=${OS}" + echo "VER=${VER}" + + for command in cat awk sysctl uname mktemp openssl grep stat file find head ps readlink basename id which wget curl readelf eu-readelf; do + path="$(command -v ${command})" + if [[ -e "${path}" ]]; then + ls -l "${path}" + if [[ -L "${path}" ]]; then + absolutepath=$(readlink -f "${path}") + ls -l "${absolutepath}" + file "${absolutepath}" + else + file "${path}" + fi + else + echo "*** can not find command ${command}" + failed=true + fi + done - --dir) - if [ "$3" = "-v" ] ; then - verbose=true - fi - if [ $have_readelf -eq 0 ] ; then + if [[ ${failed} ]]; then exit 1 - fi - if [ -z "$2" ] ; then + fi +} + +chk_dir () { + if [[ -z "${CHK_DIR}" ]] ; then printf "\033[31mError: Please provide a valid directory.\033[m\n\n" exit 1 fi # remove trailing slashes - tempdir=`echo $2 | sed -e "s/\/*$//"` - if [ ! -d $tempdir ] ; then - printf "\033[31mError: The directory '$tempdir' does not exist.\033[m\n\n" + tempdir=$(echo "${CHK_DIR}" | sed -e "s/\/*$//") + if [[ ! -d "${tempdir}" ]] ; then + printf "\033[31mError: The directory '%s' does not exist.\033[m\n\n" "${tempdir}" exit 1 fi - cd $tempdir - printf "RELRO STACK CANARY NX PIE RPATH RUNPATH FILE\n" - for N in [A-Za-z]*; do - if [ "$N" != "[A-Za-z]*" ]; then - # read permissions? - if [ ! -r $N ]; then - printf "\033[31mError: No read permissions for '$tempdir/$N' (run as root).\033[m\n" + if ${extended_checks}; then + echo_message "RELRO STACK CANARY NX PIE SELFRANDO Clang CFI SafeStack RPATH RUNPATH Symbols \tFORTIFY\tFortified\tFortifiable Filename\n" '' "\n" "{ \"dir\": { \"name\":\"$tempdir\" }" + else + echo_message "RELRO STACK CANARY NX PIE RPATH RUNPATH Symbols \tFORTIFY\tFortified\tFortifiable Filename\n" '' "\n" "{ \"dir\": { \"name\":\"$tempdir\" }" + fi + fdircount=0 + fdirtotal=0 + + while read -r N; do + if [[ "${N}" != "[A-Za-z1-0]*" ]]; then + out=$(file "$(readlink -f "${N}")") + if [[ ${out} =~ ELF ]] ; then + (( fdirtotal++ )) + fi + fi + done < <(find "${tempdir}" -type f 2>/dev/null) + if [[ $fdirtotal -gt 0 ]]; then + echo_message "" "" "" "," + fi + while read -r N; do + if [[ "${N}" != "[A-Za-z1-0]*" ]]; then + # read permissions? + if [[ ! -r "${N}" ]]; then + printf "\033[31mError: No read permissions for '%s' (run as root).\033[m\n" ", ${N}" + else + # ELF executable? + out=$(file "$(readlink -f "${N}")") + if [[ ! ${out} =~ ELF ]] ; then + if [[ "${verbose}" = "true" ]] ; then + echo_message "\033[34m*** Not an ELF file: ${tempdir}/" "" "" "" + file "${N}" + echo_message "\033[m" "" "" "" + fi else - # ELF executable? - out=`file $N` - if [[ ! $out =~ ELF ]] ; then - if [ "$verbose" = "true" ] ; then - printf "\033[34m*** Not an ELF file: $tempdir/" - file $N - printf "\033[m" - fi - else - filecheck $N - if [ `find $tempdir/$N \( -perm -004000 -o -perm -002000 \) -type f -print` ]; then - printf "\033[37;41m%s%s\033[m" $2 $N - else - printf "%s%s" $tempdir/ $N - fi - echo + (( fdircount++ )) + echo_message "" "" " " "" + filecheck "${N}" + if [[ "$(find "${N}" \( -perm -004000 -o -perm -002000 \) -type f -print)" ]]; then + echo_message "\033[37;41m${N}\033[m\n" ",${N}\n" " filename='${N}' />\n" ", \"filename\":\"${N}\"}" + else + echo_message "${N}\n" ",${N}\n" " filename='${N}' />\n" ", \"filename\":\"${N}\"}" + fi + if [[ "${fdircount}" == "${fdirtotal}" ]]; then + echo_message "" "" "" "" + else + echo_message "" "" "" "," fi fi - fi - done - exit 0 - ;; - - --file) - if [ $have_readelf -eq 0 ] ; then - exit 1 fi - if [ -z "$2" ] ; then + fi + done < <(find "${tempdir}" -type f 2>/dev/null) + echo_message "" "" "\n" "}" +} + +chk_file () { + if [[ -z "${CHK_FILE}" ]] ; then printf "\033[31mError: Please provide a valid file.\033[m\n\n" - exit 1 + exit 1 fi + # does the file exist? - if [ ! -e $2 ] ; then - printf "\033[31mError: The file '$2' does not exist.\033[m\n\n" + if [[ ! -e "${CHK_FILE}" ]] ; then + printf "\033[31mError: The file '%s' does not exist.\033[m\n\n" "${CHK_FILE}" exit 1 fi + # read permissions? - if [ ! -r $2 ] ; then - printf "\033[31mError: No read permissions for '$2' (run as root).\033[m\n\n" + if [[ ! -r "${CHK_FILE}" ]] ; then + printf "\033[31mError: No read permissions for '%s' (run as root).\033[m\n\n" "${CHK_FILE}" exit 1 fi + # ELF executable? - out=`file $2` - if [[ ! $out =~ ELF ]] ; then + out=$(file "$(readlink -f "${CHK_FILE}")") + if [[ ! ${out} =~ ELF ]] ; then printf "\033[31mError: Not an ELF file: " - file $2 + file "${CHK_FILE}" printf "\033[m\n" exit 1 fi - printf "RELRO STACK CANARY NX PIE RPATH RUNPATH FILE\n" - filecheck $2 - if [ `find $2 \( -perm -004000 -o -perm -002000 \) -type f -print` ] ; then - printf "\033[37;41m%s%s\033[m" $2 $N + if ${extended_checks}; then + echo_message "RELRO STACK CANARY NX PIE SELFRANDO Clang CFI SafeStack RPATH RUNPATH\tSymbols\t\tFORTIFY\tFortified\tFortifiable\tFILE\n" '' '' '{' else - printf "%s" $2 + echo_message "RELRO STACK CANARY NX PIE RPATH RUNPATH\tSymbols\t\tFORTIFY\tFortified\tFortifiable\tFILE\n" '' '' '{' fi - echo - exit 0 - ;; - - --proc-all) - if [ $have_readelf -eq 0 ] ; then - exit 1 + filecheck "${CHK_FILE}" + if [[ "$(find "${CHK_FILE}" \( -perm -004000 -o -perm -002000 \) -type f -print)" ]] ; then + echo_message "\033[37;41m${CHK_FILE}\033[m\n" ",${CHK_FILE}\n" " filename='${CHK_FILE}'/>\n" " } }" + else + echo_message "${CHK_FILE}\n" ",${CHK_FILE}\n" " filename='${CHK_FILE}'/>\n" " } }" fi - cd /proc - printf "* System-wide ASLR" +} + +chk_proc_all () { + cd /proc || exit + echo_message "* System-wide ASLR" "" "" "" aslrcheck - printf "* Does the CPU support NX: " - nxcheck - printf " COMMAND PID RELRO STACK CANARY NX/PaX PIE\n" + echo_message "* Does the CPU support NX: " "" "" "" + nxcheck + echo_message "* Core-Dumps access to all users: " "" "" "" + coredumpcheck + if ${extended_checks}; then + echo_message " COMMAND PID RELRO STACK CANARY Clang CFI SafeStack SECCOMP NX/PaX PIE SELFRANDO FORTIFY\n" "" "" '{' + else + echo_message " COMMAND PID RELRO STACK CANARY SECCOMP NX/PaX PIE FORTIFY\n" "" "" '{' + fi + lastpid=0 + currpid=0 for N in [1-9]*; do - if [ $N != $$ ] && readlink -q $N/exe > /dev/null; then - printf "%16s" `head -1 $N/status | cut -b 7-` - printf "%7d " $N - proccheck $N - echo + if [[ "${N}" != "$$" ]] && readlink -q "${N}"/exe > /dev/null; then + (( lastpid++ )) fi done - if [ ! -e /usr/bin/id ] ; then - printf "\n\033[33mNote: If you are running 'checksec.sh' as an unprivileged user, you\n" - printf " will not see all processes. Please run the script as root.\033[m\n\n" - else - if !(root_privs) ; then - printf "\n\033[33mNote: You are running 'checksec.sh' as an unprivileged user.\n" - printf " Too see all processes, please run the script as root.\033[m\n\n" + for N in [1-9]*; do + if [[ "${N}" != "$$" ]] && readlink -q "${N}"/exe > /dev/null; then + (( currpid++ )) + name=$(head -1 "${N}"/status | cut -b 7-) + if [[ $format == "cli" ]]; then + printf "%16s" "${name}" + printf "%7d " "${N}" + else + echo_message "" "${N}," " \n" "" + else + echo_message "\n" "\n" "\n" "," + fi + fi + done + echo_message "" "" "" " }\n" + if [[ ! -e /usr/bin/id ]] ; then + echo_message "\n\033[33mNote: If you are running 'checksec.sh' as an unprivileged user, you\n" "" "" "" + echo_message " will not see all processes. Please run the script as root.\033[m\n\n" "" "" "\n" + else + if ! (root_privs) ; then + echo_message "\n\033[33mNote: You are running 'checksec.sh' as an unprivileged user.\n" "" "" "" + echo_message " Too see all processes, please run the script as root.\033[m\n\n" "" "" "\n" fi fi - exit 0 - ;; +} - --proc) - if [ $have_readelf -eq 0 ] ; then +chk_proc () { + if [[ -z "${CHK_PROC}" ]] ; then + printf "\033[31mError: Please provide a valid process name.\033[m\n\n" exit 1 fi - if [ -z "$2" ] ; then + if ! (isString "${CHK_PROC}") ; then printf "\033[31mError: Please provide a valid process name.\033[m\n\n" exit 1 fi - if !(isString "$2") ; then - printf "\033[31mError: Please provide a valid process name.\033[m\n\n" - exit 1 + cd /proc || exit + IFS=" " read -r -a fpids <<<"$(pgrep -d ' ' "${CHK_PROC}")" + if [[ ${#fpids} -eq 0 ]]; then + printf "\033[31mError: No process with the given name found.\033[m\n\n" + exit 1 fi - cd /proc - printf "* System-wide ASLR" + echo_message "* System-wide ASLR" '' '' '' aslrcheck - printf "* Does the CPU support NX: " + echo_message "* Does the CPU support NX: " '' '' '' nxcheck - printf " COMMAND PID RELRO STACK CANARY NX/PaX PIE\n" - for N in `ps -Ao pid,comm | grep $2 | cut -b1-6`; do - if [ -d $N ] ; then - printf "%16s" `head -1 $N/status | cut -b 7-` - printf "%7d " $N - # read permissions? - if [ ! -r $N/exe ] ; then - if !(root_privs) ; then - printf "\033[31mNo read permissions for '/proc/$N/exe' (run as root).\033[m\n\n" + if ${extended_checks}; then + echo_message " COMMAND PID RELRO STACK CANARY Clang CFI SafeStack SECCOMP NX/PaX PIE SELFRANDO FORTIFY\n" "" "" '{' + else + echo_message " COMMAND PID RELRO STACK CANARY SECCOMP NX/PaX PIE FORTIFY\n" "" "" '{' + fi + pos=$(( ${#fpids[*]} - 1 )) + last=${fpids[$pos]} + for N in "${fpids[@]}"; do + if [[ -d "${N}" ]] ; then + name=$(head -1 "${N}"/status | cut -b 7-) + if [[ $format == "cli" ]]; then + printf "%16s" "${name}" + printf "%7d " "${N}" + else + echo_message "" "${N}," "\n" "" + else + echo_message "\n" "\n" "\n" "," + fi fi done - exit 0 - ;; + echo_message "\n" "\n" "\n" "}\n" +} - --proc-libs) - if [ $have_readelf -eq 0 ] ; then +chk_proc_libs () { + if [[ -z "${CHK_PROC_LIBS}" ]] ; then + printf "\033[31mError: Please provide a valid process ID.\033[m\n\n" exit 1 fi - if [ -z "$2" ] ; then + if ! (isNumeric "${CHK_PROC_LIBS}") ; then printf "\033[31mError: Please provide a valid process ID.\033[m\n\n" exit 1 fi - if !(isNumeric "$2") ; then - printf "\033[31mError: Please provide a valid process ID.\033[m\n\n" - exit 1 - fi - cd /proc - printf "* System-wide ASLR" + cd /proc || exit + echo_message "* System-wide ASLR" '' '' '' aslrcheck - printf "* Does the CPU support NX: " + echo_message "* Does the CPU support NX: " '' '' '' nxcheck - printf "* Process information:\n\n" - printf " COMMAND PID RELRO STACK CANARY NX/PaX PIE\n" - N=$2 - if [ -d $N ] ; then - printf "%16s" `head -1 $N/status | cut -b 7-` - printf "%7d " $N - # read permissions? - if [ ! -r $N/exe ] ; then - if !(root_privs) ; then - printf "\033[31mNo read permissions for '/proc/$N/exe' (run as root).\033[m\n\n" + echo_message "* Process information:\n\n" "" "" "" + if ${extended_checks}; then + echo_message " COMMAND PID RELRO STACK CANARY Clang CFI SafeStack SECCOMP NX/PaX PIE Fortify Source\n" '' '' '' + else + echo_message " COMMAND PID RELRO STACK CANARY SECCOMP NX/PaX PIE Fortify Source\n" '' '' '' + fi + N=${CHK_PROC_LIBS} + if [[ -d "${N}" ]] ; then + name=$(head -1 "${N}/status" | cut -b 7-) + if [[ "${format}" == "cli" ]]; then + printf "%16s" "${name}" + printf "%7d " "${N}" + else + echo_message "" "${name}," "\n" "} } }" fi - exit 0 - ;; - - --kernel) - cd /proc - printf "* Kernel protection information:\n\n" - kernelcheck - exit 0 - ;; +} - --fortify-file) - if [ $have_readelf -eq 0 ] ; then - exit 1 +chk_fortify_file () { + # if first char of pathname is '~' replace it with '${HOME}' + if [[ "${CHK_FORTIFY_FILE:0:1}" = '~' ]] ; then + CHK_FORTIFY_FILE=${HOME}/${CHK_FORTIFY_FILE:1} fi - if [ -z "$2" ] ; then + + if [[ -z "${CHK_FORTIFY_FILE}" ]] ; then printf "\033[31mError: Please provide a valid file.\033[m\n\n" - exit 1 + exit 1 fi # does the file exist? - if [ ! -e $2 ] ; then - printf "\033[31mError: The file '$2' does not exist.\033[m\n\n" + if [[ ! -f "${CHK_FORTIFY_FILE}" ]] ; then + printf "\033[31mError: The file '%s' does not exist.\033[m\n\n" "${CHK_FORTIFY_FILE}" exit 1 fi # read permissions? - if [ ! -r $2 ] ; then - printf "\033[31mError: No read permissions for '$2' (run as root).\033[m\n\n" + if [[ ! -r "${CHK_FORTIFY_FILE}" ]] ; then + printf "\033[31mError: No read permissions for '%s' (run as root).\033[m\n\n" "${CHK_FORTIFY_FILE}" exit 1 fi # ELF executable? - out=`file $2` - if [[ ! $out =~ ELF ]] ; then + out=$(file "$(readlink -f "${CHK_FORTIFY_FILE}")") + if [[ ! ${out} =~ ELF ]] ; then printf "\033[31mError: Not an ELF file: " - file $2 + file "${CHK_FORTIFY_FILE}" printf "\033[m\n" exit 1 fi - if [ -e /lib/libc.so.6 ] ; then + + if [[ -e /lib/libc.so.6 ]] ; then FS_libc=/lib/libc.so.6 - elif [ -e /lib64/libc.so.6 ] ; then + elif [[ -e /lib64/libc.so.6 ]] ; then FS_libc=/lib64/libc.so.6 - elif [ -e /lib/i386-linux-gnu/libc.so.6 ] ; then + elif [[ -e /lib/i386-linux-gnu/libc.so.6 ]] ; then FS_libc=/lib/i386-linux-gnu/libc.so.6 - elif [ -e /lib/x86_64-linux-gnu/libc.so.6 ] ; then + elif [[ -e /lib/x86_64-linux-gnu/libc.so.6 ]] ; then FS_libc=/lib/x86_64-linux-gnu/libc.so.6 + elif [[ -e /lib/arm-linux-gnueabihf/libc.so.6 ]] ; then + FS_libc=/lib/arm-linux-gnueabihf/libc.so.6 + elif [[ -e /lib/aarch64-linux-gnu/libc.so.6 ]] ; then + FS_libc=/lib/aarch64-linux-gnu/libc.so.6 else printf "\033[31mError: libc not found.\033[m\n\n" exit 1 fi - FS_chk_func_libc=( $(readelf -s $FS_libc | grep _chk@@ | awk '{ print $8 }' | cut -c 3- | sed -e 's/_chk@.*//') ) - FS_functions=( $(readelf -s $2 | awk '{ print $8 }' | sed 's/_*//' | sed -e 's/@.*//') ) - + FS_chk_func_libc=() + FS_functions=() + while IFS='' read -r line; do FS_chk_func_libc+=("$line"); done < <(${readelf} -s ${FS_libc} 2>/dev/null | grep _chk@@ | awk '{ print $8 }' | cut -c 3- | sed -e 's/_chk@.*//') + while IFS='' read -r line; do FS_functions+=("$line"); done < <(${readelf} -s "${CHK_FORTIFY_FILE}" 2>/dev/null | awk '{ print $8 }' | sed 's/_*//' | sed -e 's/@.*//') + echo_message "" "" "\n" "} }" +} - exit 0 - ;; - - --fortify-proc) - if [ $have_readelf -eq 0 ] ; then +chk_fortify_proc () { + if [[ -z "${CHK_FORTIFY_PROC}" ]] ; then + printf "\033[31mError: Please provide a valid process ID.\033[m\n\n" exit 1 fi - if [ -z "$2" ] ; then + if ! (isNumeric "${CHK_FORTIFY_PROC}") ; then printf "\033[31mError: Please provide a valid process ID.\033[m\n\n" exit 1 fi - if !(isNumeric "$2") ; then - printf "\033[31mError: Please provide a valid process ID.\033[m\n\n" - exit 1 - fi - cd /proc - N=$2 - if [ -d $N ] ; then + cd /proc || exit + N=${CHK_FORTIFY_PROC} + if [[ -d "${N}" ]] ; then # read permissions? - if [ ! -r $N/exe ] ; then - if !(root_privs) ; then - printf "\033[31mNo read permissions for '/proc/$N/exe' (run as root).\033[m\n\n" + if [[ ! -r "${N}/exe" ]] ; then + if ! (root_privs) ; then + printf "\033[31mNo read permissions for '/proc/%s/exe' (run as root).\033[m\n\n" "${N}" exit 1 fi - if [ ! `readlink $N/exe` ] ; then + if [[ ! "$(readlink "${N}/exe")" ]] ; then printf "\033[31mPermission denied. Requested process ID belongs to a kernel thread.\033[m\n\n" exit 1 fi exit 1 fi - if [ -e /lib/libc.so.6 ] ; then + if [[ -e /lib/libc.so.6 ]] ; then FS_libc=/lib/libc.so.6 - elif [ -e /lib64/libc.so.6 ] ; then + elif [[ -e /lib64/libc.so.6 ]] ; then FS_libc=/lib64/libc.so.6 - elif [ -e /lib/i386-linux-gnu/libc.so.6 ] ; then + elif [[ -e /lib/i386-linux-gnu/libc.so.6 ]] ; then FS_libc=/lib/i386-linux-gnu/libc.so.6 - elif [ -e /lib/x86_64-linux-gnu/libc.so.6 ] ; then + elif [[ -e /lib/x86_64-linux-gnu/libc.so.6 ]] ; then FS_libc=/lib/x86_64-linux-gnu/libc.so.6 else printf "\033[31mError: libc not found.\033[m\n\n" exit 1 fi - printf "* Process name (PID) : %s (%d)\n" `head -1 $N/status | cut -b 7-` $N - FS_chk_func_libc=( $(readelf -s $FS_libc | grep _chk@@ | awk '{ print $8 }' | cut -c 3- | sed -e 's/_chk@.*//') ) - FS_functions=( $(readelf -s $2/exe | awk '{ print $8 }' | sed 's/_*//' | sed -e 's/@.*//') ) - + name=$(head -1 "${N}/status" | cut -b 7-) + echo_message "* Process name (PID) : ${name} (${N})\n" "" "" "" + + FS_chk_func_libc=() + FS_functions=() + while IFS='' read -r line; do FS_chk_func_libc+=("$line"); done < <(${readelf} -s $FS_libc 2>/dev/null | grep _chk@@ | awk '{ print $8 }' | cut -c 3- | sed -e 's/_chk@.*//') + while IFS='' read -r line; do FS_functions+=("$line"); done < <(${readelf} -s "${CHK_FORTIFY_PROC}/exe" 2>/dev/null | awk '{ print $8 }' | sed 's/_*//' | sed -e 's/@.*//') + echo_message "" "" "\n" "} }" fi - exit 0 - ;; +} - *) - if [ "$#" != "0" ] ; then - printf "\033[31mError: Unknown option '$1'.\033[m\n\n" - fi - help +chk_kernel () { + if [[ ${CHK_KERNEL} == "kernel" ]]; then + CHK_KERNEL="" + fi + if [[ -e "${CHK_KERNEL}" ]] && [[ ! -d "${CHK_KERNEL}" ]]; then + if [[ -s "$(pwd -P)/${CHK_KERNEL}" ]]; then + configfile=$(pwd -P)/${CHK_KERNEL} + elif [[ -s "${CHK_KERNEL}" ]]; then + configfile=${CHK_KERNEL} + else + "Error: config file specified do not exist" + exit 1 + fi + echo_message "* Kernel protection information for : $configfile \n\n" "" "" "" + cd /proc && kernelcheck "$configfile" || exit + else + cd /proc || exit + echo_message "* Kernel protection information:\n\n" "" "" "" + kernelcheck + fi +} + +optspec=":h-:" +while getopts "${optspec}" optchar; do + case "${optchar}" in + -) + case "${OPTARG}" in + version) + version + exit 0 + ;; + debug) + debug=true + ;; + trace) + export BASH_XTRACEFD=5 + export PS4='(${BASH_SOURCE##*/}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' + set -x + ;; + help) + help + exit 0 + ;; + debug_report) + debug_report + exit 0 + ;; + update|upgrade) + # shellcheck disable=SC2119 + upgrade + exit 0 + ;; + format=*|output=*) + output_format=${OPTARG#*=} + format + ;; + verbose) + verbose=true + ;; + extended) + extended_checks=true + ;; + dir=*|dir) + CHK_DIR=${OPTARG#*=}; + OPT=$((OPT + 1)) + CHK_FUNCTION="chk_dir" + ;; + file=*|file) + CHK_FILE=${OPTARG#*=}; + OPT=$((OPT + 1)) + CHK_FUNCTION="chk_file" + ;; + proc-all) + OPT=$((OPT + 1)) + CHK_FUNCTION="chk_proc_all" + ;; + proc=*|proc) + CHK_PROC=${OPTARG#*=}; + OPT=$((OPT + 1)) + CHK_FUNCTION="chk_proc" + ;; + proc-libs=*|proc-libs) + CHK_PROC_LIBS=${OPTARG#*=}; + OPT=$((OPT + 1)) + CHK_FUNCTION="chk_proc_libs" + ;; + fortify-file=*|fortify-file) + CHK_FORTIFY_FILE=${OPTARG#*=}; + OPT=$((OPT + 1)) + CHK_FUNCTION="chk_fortify_file" + ;; + fortify-proc=*|fortify-proc) + CHK_FORTIFY_PROC=${OPTARG#*=}; + OPT=$((OPT + 1)) + CHK_FUNCTION="chk_fortify_proc" + ;; + kernel=*|kernel) + CHK_KERNEL=${OPTARG#*=}; + OPT=$((OPT + 1)) + CHK_FUNCTION="chk_kernel" + ;; + *) + printf "\033[31mError: Unknown option %s.\033[m\n\n" "${OPTARG}" + exit 1 + ;; + esac;; + *) + help + exit 0 + ;; + esac +done + +if [[ "${OPT}" == 0 ]]; then + printf "\033[31mError: No option selected. Please select an option.\033[m\n\n" + exit 1 +elif [[ "${OPT}" != 1 ]]; then + printf "\033[31mError: To many options selected. Please select one at a time.\033[m\n\n" exit 1 - ;; -esac +fi + +for variable in CHK_DIR CHK_FILE CHK_FORTIFY_FILE CHK_FORTIFY_PROC CHK_PROC CHK_PROC_LIBS; do + if [[ -n ${!variable+x} ]]; then + if [[ -z "${!variable}" ]]; then + printf "\033[31mError: Option Required.\033[m\n\n" + help + exit 1 + fi + fi +done + +# call the function +${CHK_FUNCTION} diff --git a/depend/zcash/qa/zcash/full_test_suite.py b/depend/zcash/qa/zcash/full_test_suite.py index a2e60a197..461fec5cd 100755 --- a/depend/zcash/qa/zcash/full_test_suite.py +++ b/depend/zcash/qa/zcash/full_test_suite.py @@ -21,6 +21,22 @@ def repofile(filename): return os.path.join(REPOROOT, filename) +def get_arch_dir(): + depends_dir = os.path.join(REPOROOT, 'depends') + + arch_dir = os.path.join(depends_dir, 'x86_64-pc-linux-gnu') + if os.path.isdir(arch_dir): + return arch_dir + + # Not Linux, try MacOS + arch_dirs = glob(os.path.join(depends_dir, 'x86_64-apple-darwin*')) + if arch_dirs: + # Just try the first one; there will only be one in CI + return arch_dirs[0] + + print("!!! cannot find architecture dir under depends/ !!!") + return None + # # Custom test runners @@ -32,7 +48,7 @@ def repofile(filename): def test_rpath_runpath(filename): output = subprocess.check_output( - [repofile('qa/zcash/checksec.sh'), '--file', repofile(filename)] + [repofile('qa/zcash/checksec.sh'), '--file=' + repofile(filename)] ) if RE_RPATH_RUNPATH.search(output.decode('utf-8')): print('PASS: %s has no RPATH or RUNPATH.' % filename) @@ -44,7 +60,7 @@ def test_rpath_runpath(filename): def test_fortify_source(filename): proc = subprocess.Popen( - [repofile('qa/zcash/checksec.sh'), '--fortify-file', repofile(filename)], + [repofile('qa/zcash/checksec.sh'), '--fortify-file=' + repofile(filename)], stdout=subprocess.PIPE, ) line1 = proc.stdout.readline() @@ -78,23 +94,20 @@ def check_security_hardening(): # NOTE: checksec.sh does not reliably determine whether FORTIFY_SOURCE # is enabled for the entire binary. See issue #915. - ret &= test_fortify_source('src/zcashd') - ret &= test_fortify_source('src/zcash-cli') - ret &= test_fortify_source('src/zcash-gtest') - ret &= test_fortify_source('src/zcash-tx') - ret &= test_fortify_source('src/test/test_bitcoin') + # FORTIFY_SOURCE does mostly nothing for Clang before 10, which we don't + # pin yet, so we disable these tests. + # ret &= test_fortify_source('src/zcashd') + # ret &= test_fortify_source('src/zcash-cli') + # ret &= test_fortify_source('src/zcash-gtest') + # ret &= test_fortify_source('src/zcash-tx') + # ret &= test_fortify_source('src/test/test_bitcoin') return ret def ensure_no_dot_so_in_depends(): - depends_dir = os.path.join(REPOROOT, 'depends') - arch_dir = os.path.join(depends_dir, 'x86_64-unknown-linux-gnu') - if not os.path.isdir(arch_dir): - # Not Linux, try MacOS - arch_dirs = glob(os.path.join(depends_dir, 'x86_64-apple-darwin*')) - if arch_dirs: - # Just try the first one; there will only be one in CI - arch_dir = arch_dirs[0] + arch_dir = get_arch_dir() + if arch_dir is None: + return False exit_code = 0 @@ -120,36 +133,35 @@ def ensure_no_dot_so_in_depends(): return exit_code == 0 def util_test(): + python = [] + if os.path.isfile('/usr/local/bin/python3'): + python = ['/usr/local/bin/python3'] + return subprocess.call( - [repofile('src/test/bitcoin-util-test.py')], + python + [repofile('src/test/bitcoin-util-test.py')], cwd=repofile('src'), env={'PYTHONPATH': repofile('src/test'), 'srcdir': repofile('src')} ) == 0 def rust_test(): - depends_dir = os.path.join(REPOROOT, 'depends', 'x86_64-unknown-linux-gnu') - if not os.path.isdir(depends_dir): - depends_dir = os.path.join(REPOROOT, 'depends', 'x86_64-apple-darwin') - - if os.path.isdir(depends_dir): - rust_env = os.environ.copy() - rust_env['RUSTC'] = os.path.join(depends_dir, 'native', 'bin', 'rustc') - return subprocess.call([ - os.path.join(depends_dir, 'native', 'bin', 'cargo'), - 'test', - '--manifest-path', - os.path.join(REPOROOT, 'Cargo.toml'), - ], env=rust_env) == 0 - - # Didn't manage to run anything - return False + arch_dir = get_arch_dir() + if arch_dir is None: + return False + + rust_env = os.environ.copy() + rust_env['RUSTC'] = os.path.join(arch_dir, 'native', 'bin', 'rustc') + return subprocess.call([ + os.path.join(arch_dir, 'native', 'bin', 'cargo'), + 'test', + '--manifest-path', + os.path.join(REPOROOT, 'Cargo.toml'), + ], env=rust_env) == 0 # # Tests # STAGES = [ - 'check-depends', 'rust-test', 'btest', 'gtest', @@ -162,7 +174,6 @@ def rust_test(): ] STAGE_COMMANDS = { - 'check-depends': ['qa/zcash/test-depends-sources-mirror.py'], 'rust-test': rust_test, 'btest': [repofile('src/test/test_bitcoin'), '-p'], 'gtest': [repofile('src/zcash-gtest')], @@ -217,11 +228,14 @@ def main(): sys.exit(1) # Run the stages - passed = True + all_passed = True for s in args.stage: - passed &= run_stage(s) + passed = run_stage(s) + if not passed: + print("!!! Stage %s failed !!!" % (s,)) + all_passed &= passed - if not passed: + if not all_passed: print("!!! One or more test stages failed !!!") sys.exit(1) diff --git a/depend/zcash/qa/zcash/postponed-updates.txt b/depend/zcash/qa/zcash/postponed-updates.txt new file mode 100644 index 000000000..3752e2516 --- /dev/null +++ b/depend/zcash/qa/zcash/postponed-updates.txt @@ -0,0 +1,99 @@ +# List of Postponed Dependency Updates +# +# The format is: name version expiration, e.g. +# bdb 18.1.40 2020-09-01 +# + +# Clang is pinned to a version that matches the Rust version. +# This will be Clang 9 intially, which we are postponing until after the +# initial Clang PR is merged. +# libc++ is pinned to the same version as Clang. +native_clang 8.0.1 2020-11-01 +native_clang 9.0.0 2020-11-01 +native_clang 9.0.1 2020-11-01 +native_clang 10.0.0 2021-01-20 +native_clang 10.0.1 2021-01-20 +native_clang 11.0.0 2021-01-20 +libcxx 8.0.1 2020-11-01 +libcxx 9.0.0 2020-11-01 +libcxx 9.0.1 2020-11-01 +libcxx 10.0.0 2021-01-20 +libcxx 10.0.1 2021-01-20 +libcxx 11.0.0 2021-01-20 + +bdb 18.1.40 2021-01-20 + +# We currently pin Rust 1.44.1, and plan to re-evaluate this in 2021 if +# we haven't already upgraded before then. In the meantime, postpone +# current and scheduled subsequent releases through the end of the year. +native_rust 1.45.0 2021-01-20 +native_rust 1.45.1 2021-01-20 +native_rust 1.45.2 2021-01-20 +native_rust 1.46.0 2021-01-20 +native_rust 1.47.0 2021-01-20 +native_rust 1.48.0 2021-01-20 +native_rust 1.49.0 2021-01-20 + +# Google Test 1.10.0 requires adding CMake to the depends system. +googletest 1.10.0 2021-01-20 + +# The aes crate depends on "aesni ^0.8" +crate_aesni 0.9.0 2020-11-01 + +# The bigint crate depends on "crunchy ^0.1.5" +crate_crunchy 0.2.1 2020-11-01 +crate_crunchy 0.2.2 2020-11-01 + +# These are being deferred until after 4.0.0 to avoid blocking the release. +crate_time 0.1.44 2021-01-20 +crate_redox_users 0.3.5 2021-01-20 + +# The chrono crate depends on "time ^0.1.43", and is highly unlikely to +# upgrade to v0.2: https://github.com/chronotope/chrono/issues/400 +crate_time 0.2.0 2021-02-01 +crate_time 0.2.1 2021-02-01 +crate_time 0.2.2 2021-02-01 +crate_time 0.2.3 2021-02-01 +crate_time 0.2.4 2021-02-01 +crate_time 0.2.5 2021-02-01 +crate_time 0.2.6 2021-02-01 +crate_time 0.2.7 2021-02-01 +crate_time 0.2.8 2021-02-01 +crate_time 0.2.9 2021-02-01 +crate_time 0.2.10 2021-02-01 +crate_time 0.2.11 2021-02-01 +crate_time 0.2.12 2021-02-01 +crate_time 0.2.13 2021-02-01 +crate_time 0.2.14 2021-02-01 +crate_time 0.2.15 2021-02-01 +crate_time 0.2.16 2021-02-01 + +# The futures-cpupool crate depends on "futures ^0.1", which was last +# updated 3 years ago. We plan to move away from it when we refactor +# bellman's multicore support. +crate_futures 0.2.0 2021-02-01 +crate_futures 0.2.1 2021-02-01 +crate_futures 0.3.0 2021-02-01 +crate_futures 0.3.1 2021-02-01 +crate_futures 0.3.2 2021-02-01 +crate_futures 0.3.3 2021-02-01 +crate_futures 0.3.4 2021-02-01 +crate_futures 0.3.5 2021-02-01 + +# The redox_users crate depends on: +# - "redox_syscall ^0.1" +# - "rust-argon2 ^0.7", which in turn depends on "base64 ^0.11" +# +# redox_users 0.3.5 depends on rust-argon2 ^0.8 which will address some of this. +crate_base64 0.12.0 2020-11-01 +crate_base64 0.12.1 2020-11-01 +crate_base64 0.12.2 2020-11-01 +crate_base64 0.12.3 2020-11-01 +crate_redox_syscall 0.2.0 2020-11-01 +crate_redox_syscall 0.2.1 2020-11-01 +crate_rust_argon2 0.8.0 2020-11-01 +crate_rust_argon2 0.8.1 2020-11-01 +crate_rust_argon2 0.8.2 2020-11-01 + +# tracing 0.1.20 was yanked. +crate_tracing 0.1.20 9999-12-31 diff --git a/depend/zcash/qa/zcash/updatecheck.py b/depend/zcash/qa/zcash/updatecheck.py index 59d0aa66a..38ae8761f 100755 --- a/depend/zcash/qa/zcash/updatecheck.py +++ b/depend/zcash/qa/zcash/updatecheck.py @@ -25,11 +25,18 @@ # .mk files in depends/packages, this script will exit with # a nonzero status. The latter case would suggest someone added a new dependency # without adding a corresponding entry to get_dependency_list() below. +# +# To test the script itself, run it with --functionality-test as the only +# argument. This will exercise the full functionality of the script, but will +# only return a non-zero exit status when there's something wrong with the +# script itself, for example if a new file was added to depends/packages/ but +# wasn't added to this script. import requests import os import re import sys +import datetime SOURCE_ROOT = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..") # The email for this account is taylor@electriccoin.co and the token does not @@ -50,6 +57,11 @@ def get_dependency_list(): GithubTagReleaseLister("google", "googletest", "^release-(\d+)\.(\d+)\.(\d+)$", { "release-1.8.1": (1, 8, 1) }), DependsVersionGetter("googletest")), + # libc++ matches the Clang version + Dependency("libcxx", + GithubTagReleaseLister("llvm", "llvm-project", "^llvmorg-(\d+)\.(\d+).(\d+)$", + { "llvmorg-11.0.0": (11, 0, 0), "llvmorg-9.0.1-rc3": None}), + DependsVersionGetter("native_clang")), Dependency("libevent", GithubTagReleaseLister("libevent", "libevent", "^release-(\d+)\.(\d+)\.(\d+)-stable$", { "release-2.0.22-stable": (2, 0, 22), "release-2.1.9-beta": None }), @@ -62,18 +74,14 @@ def get_dependency_list(): GithubTagReleaseLister("ccache", "ccache", "^v?(\d+)\.(\d+)(?:\.(\d+))?$", { "v3.5.1": (3, 5, 1), "v3.6": (3, 6)}), DependsVersionGetter("native_ccache")), - Dependency("openssl", - GithubTagReleaseLister("openssl", "openssl", "^OpenSSL_(\d+)_(\d+)_(\d+)([a-z]+)?$", - { "OpenSSL_1_1_1b": (1, 1, 1, 'b'), "OpenSSL_1_1_1-pre9": None }), - DependsVersionGetter("openssl")), - Dependency("proton", - GithubTagReleaseLister("apache", "qpid-proton", "^(\d+)\.(\d+)(?:\.(\d+))?$", - { "0.27.0": (0, 27, 0), "0.10": (0, 10), "0.12.0-rc": None }), - DependsVersionGetter("proton")), - Dependency("rust", + Dependency("native_clang", + GithubTagReleaseLister("llvm", "llvm-project", "^llvmorg-(\d+)\.(\d+).(\d+)$", + { "llvmorg-11.0.0": (11, 0, 0), "llvmorg-9.0.1-rc3": None}), + DependsVersionGetter("native_clang")), + Dependency("native_rust", GithubTagReleaseLister("rust-lang", "rust", "^(\d+)\.(\d+)(?:\.(\d+))?$", { "1.33.0": (1, 33, 0), "0.9": (0, 9) }), - DependsVersionGetter("rust")), + DependsVersionGetter("native_rust")), Dependency("zeromq", GithubTagReleaseLister("zeromq", "libzmq", "^v(\d+)\.(\d+)(?:\.(\d+))?$", { "v4.3.1": (4, 3, 1), "v4.2.0-rc1": None }), @@ -92,35 +100,61 @@ def get_dependency_list(): DependsVersionGetter("utfcpp")) ] - # Rust crates. + # Rust crates (filename portion: depends/packages/crate_.mk). crates = [ - "aes", "aesni", "aes_soft", "arrayvec", "bellman", - "arrayref", "autocfg", "bigint", "blake2b_simd", "blake2s_simd", - "bit_vec", "block_cipher_trait", "byteorder", - "block_buffer", "block_padding", "c2_chacha", "cfg_if", "crunchy", - "byte_tools", "constant_time_eq", "crossbeam", "digest", "fpe", + "addchain", "aes", "aesni", "aes_soft", "ansi_term", + "arrayvec", "arrayref", "autocfg", + "base64", "bellman", "bigint", "bit_vec", "blake2b_simd", "blake2s_simd", + "block_buffer", "block_cipher", "block_modes", "block_padding", + "bls12_381", "byteorder", + "cfg_if", "chrono", "constant_time_eq", "cpuid_bool", "crossbeam_channel", "crossbeam_deque", "crossbeam_epoch", - "crossbeam_utils", "crossbeam_queue", "crypto_api", "crypto_api_chachapoly", - "directories", "fake_simd", "ff", "ff_derive", "getrandom", "hex", "log", - "futures_cpupool", "futures", "generic_array", "group", - "lazy_static", "libc", "nodrop", "num_bigint", - "memoffset", "ppv_lite86", "proc_macro2", "quote", - "num_cpus", "num_integer", "num_traits", "opaque_debug", "pairing", - "rand", "typenum", + "crossbeam_utils", "crossbeam_queue", "crossbeam", + "crunchy", "crypto_api", "crypto_api_chachapoly", "curve25519_dalek", + "directories", "dirs_sys", "digest", + "ed25519_zebra", "equihash", + "ff", "ff_derive", "fpe", "futures_cpupool", "futures", + "generic_array", "getrandom", "group", + "hermit_abi", "hex", "jubjub", "log", + "lazy_static", "libc", "matchers", "maybe_uninit", "memoffset", + "num_bigint", "num_cpus", "num_integer", "num_traits", + "ppv_lite86", "proc_macro2", "quote", + "opaque_debug", "pairing", "rand", "typenum", "rand_chacha", "rand_core", "rand_hc", "rand_xorshift", - "rustc_version", "scopeguard", "semver", "semver_parser", "sha2", "syn", - "unicode_xid", "wasi", - "winapi_i686_pc_windows_gnu", "winapi", "winapi_x86_64_pc_windows_gnu", - "zcash_history", "zcash_primitives", "zcash_proofs" + "redox_syscall", "redox_users", + "regex", "regex_automata", "regex_syntax", "rust_argon2", + "scopeguard", "serde", + "serde_derive", "sha2", "sharded_slab", "subtle", "syn", "thiserror", + "thiserror_impl", "thread_local", "time", "tracing", "tracing_appender", + "tracing_attributes", "tracing_core", "tracing_subscriber", + "unicode_xid", "version_check", "wasi", + "winapi_i686_pc_windows_gnu", "winapi", + "winapi_x86_64_pc_windows_gnu", "zcash_history", "zcash_primitives", + "zcash_proofs", "zeroize" ] + # Sometimes we need multiple versions of a crate, in which case there can't + # be a direct mapping between the filename portion and the crate name. + crate_name_exceptions = { + } + for crate in crates: - dependencies.append( - Dependency("crate_" + crate, - RustCrateReleaseLister(crate), - DependsVersionGetter("crate_" + crate) - ) - ) + if crate in crate_name_exceptions.keys(): + crate_name = crate_name_exceptions[crate] + else: + crate_name = crate + + # Rust dependency checks are temporarily disabled: + # https://github.com/zcash/zcash/issues/4726 + # No-op statement to keep pyflakes happy: + crate_name = crate_name + + # dependencies.append( + # Dependency("crate_" + crate, + # RustCrateReleaseLister(crate_name), + # DependsVersionGetter("crate_" + crate) + # ) + # ) return dependencies @@ -258,7 +292,7 @@ def known_releases(self): for match in re.findall("Berkeley DB (\d+)\.(\d+)\.(\d+)\.tar.gz", page): release_versions.add(Version(match)) - if Version((6, 2, 38)) not in release_versions: + if len(release_versions) == 0: raise RuntimeError("Missing expected version from Oracle web page.") return list(release_versions) @@ -268,14 +302,16 @@ def __init__(self, name): self.name = name def current_version(self): - mk_file_path = os.path.join(SOURCE_ROOT, "depends", "packages", safe(self.name) + ".mk") + mk_file_path = os.path.join(SOURCE_ROOT, "depends", "packages", safe_depends(self.name) + ".mk") mk_file = open(mk_file_path, 'r').read() regexp_whitelist = [ "package\)_version=(\d+)\.(\d+)\.(\d+)$", "package\)_version=(\d+)\.(\d+)$", "package\)_version=(\d+)_(\d+)_(\d+)$", - "package\)_version=(\d+)\.(\d+)\.(\d+)([a-z])$" + "package\)_version=(\d+)\.(\d+)\.(\d+)([a-z])$", + # Workaround for wasi 0.9.0 preview + "package\)_version=(\d+)\.(\d+)\.(\d+)\+wasi-snapshot-preview1$", ] current_version = None @@ -312,12 +348,45 @@ def current_version(self): else: raise RuntimeError("Couldn't parse univalue's version from its configure.ac") +class PostponedUpdates(): + def __init__(self): + self.postponedlist = dict() + + postponedlist_path = os.path.join( + os.path.dirname(__file__), + "postponed-updates.txt" + ) + + file = open(postponedlist_path, 'r') + for line in file.readlines(): + stripped = re.sub('#.*$', '', line).strip() + if stripped != "": + match = re.match('^(\S+)\s+(\S+)\s+(\S+)$', stripped) + if match: + postponed_name = match.groups()[0] + postponed_version = Version(match.groups()[1].split(".")) + postpone_expiration = datetime.datetime.strptime(match.groups()[2], '%Y-%m-%d') + if datetime.datetime.utcnow() < postpone_expiration: + self.postponedlist[(postponed_name, str(postponed_version))] = True + else: + raise RuntimeError("Could not parse line in postponed-updates.txt:" + line) + + + def is_postponed(self, name, version): + return (name, str(version)) in self.postponedlist + def safe(string): if re.match('^[a-zA-Z0-9_-]*$', string): return string else: raise RuntimeError("Potentially-dangerous string encountered.") +def safe_depends(string): + if re.match('^[a-zA-Z0-9._-]*$', string): + return string + else: + raise RuntimeError("Potentially-dangerous string encountered.") + def print_row(name, status, current_version, known_versions): COL_FMT_LARGE = "{:<35}" COL_FMT_SMALL = "{:<18}" @@ -334,8 +403,6 @@ def main(): untracked = [ # packages.mk is not a dependency, it just specifies the list of them all. "packages", - # just a template - "vendorcrate", # This package doesn't have conventional version numbers "native_cctools" ] @@ -356,30 +423,51 @@ def main(): sys.exit(status) deps = get_dependency_list() + postponed = PostponedUpdates() for dependency in deps: if dependency.name in unchecked_dependencies: unchecked_dependencies.remove(dependency.name) - if len(sys.argv) == 2 and sys.argv[1] == "skipcheck": - print("Skipping the actual dependency update checks.") + if dependency.is_up_to_date(): + print_row( + dependency.name, + "up to date", + str(dependency.current_version()), + "") else: - if dependency.is_up_to_date(): - print_row( - dependency.name, - "up to date", - str(dependency.current_version()), - "") - else: - print_row( - dependency.name, - "OUT OF DATE", - str(dependency.current_version()), - str(list(map(str, dependency.released_versions_after_current_version())))) - status = 1 + # The status can either be POSTPONED or OUT OF DATE depending + # on whether or not all the new versions are whitelisted. + status_text = "POSTPONED" + newver_list = "[" + for newver in dependency.released_versions_after_current_version(): + if postponed.is_postponed(dependency.name, newver): + newver_list += str(newver) + " (postponed)," + else: + newver_list += str(newver) + "," + status_text = "OUT OF DATE" + status = 1 + + newver_list = newver_list[:-1] + "]" + + print_row( + dependency.name, + status_text, + str(dependency.current_version()), + newver_list + ) if len(unchecked_dependencies) > 0: unchecked_dependencies.sort() print("WARNING: The following dependencies are not being checked for updates by this script: " + ', '.join(unchecked_dependencies)) - status = 2 + sys.exit(2) + + if len(sys.argv) == 2 and sys.argv[1] == "--functionality-test": + print("We're only testing this script's functionality. The exit status will only be nonzero if there's a problem with the script itself.") + sys.exit(0) + + if status == 0: + print("Ready to release. All dependencies are up-to-date or postponed.") + elif status == 1: + print("Release is BLOCKED. There are new dependency updates that have not been postponed.") sys.exit(status) diff --git a/depend/zcash/rust-toolchain b/depend/zcash/rust-toolchain index a50908ca3..d724e4390 100644 --- a/depend/zcash/rust-toolchain +++ b/depend/zcash/rust-toolchain @@ -1 +1 @@ -1.42.0 +1.44.1 diff --git a/depend/zcash/src/Makefile.am b/depend/zcash/src/Makefile.am index 5460b2f3e..11a1aea1d 100644 --- a/depend/zcash/src/Makefile.am +++ b/depend/zcash/src/Makefile.am @@ -11,23 +11,8 @@ AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_C AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS) EXTRA_LIBRARIES = -if EMBEDDED_LEVELDB -LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/include -LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/helpers/memenv -LIBLEVELDB += $(builddir)/leveldb/libleveldb.a -LIBMEMENV += $(builddir)/leveldb/libmemenv.a - -# NOTE: This dependency is not strictly necessary, but without it make may try to build both in parallel, which breaks the LevelDB build system in a race -$(LIBLEVELDB): $(LIBMEMENV) - -$(LIBLEVELDB) $(LIBMEMENV): - @echo "Building LevelDB ..." && $(MAKE) -C $(@D) $(@F) CXX="$(CXX)" \ - CC="$(CC)" PLATFORM=$(TARGET_OS) AR="$(AR)" $(LEVELDB_TARGET_FLAGS) \ - OPT="$(AM_CXXFLAGS) $(PIE_FLAGS) $(CXXFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -D__STDC_LIMIT_MACROS" -endif - BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config -BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS) +BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) BITCOIN_CONFIG_INCLUDES += -I$(srcdir)/rust/include BITCOIN_INCLUDES += -I$(srcdir)/rust/include @@ -47,9 +32,6 @@ LIBZCASH=libzcash.a if ENABLE_ZMQ LIBBITCOIN_ZMQ=libbitcoin_zmq.a endif -if ENABLE_PROTON -LIBBITCOIN_PROTON=libbitcoin_proton.a -endif if BUILD_BITCOIN_LIBS LIBZCASH_SCRIPT=libzcash_script.la endif @@ -86,19 +68,7 @@ endif cargo-build: $(CARGO_CONFIGURED) $(RUST_ENV_VARS) $(CARGO) build $(RUST_BUILD_OPTS) $(rust_verbose) --manifest-path $(top_srcdir)/Cargo.toml -if TARGET_WINDOWS -LIBRUSTZCASH_WIN=$(top_builddir)/target/$(RUST_TARGET)/release/rustzcash.lib - -$(LIBRUSTZCASH_WIN): cargo-build - -# This ensures that the Rust library is correctly linked in by libtool. -# See https://github.com/rust-lang/rust/issues/69904 for the underlying cause. -$(LIBRUSTZCASH): $(LIBRUSTZCASH_WIN) - $(AM_V_at)cp $< $@ - -else $(LIBRUSTZCASH): cargo-build -endif $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*) $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) @@ -116,7 +86,6 @@ EXTRA_LIBRARIES += \ $(LIBBITCOIN_CLI) \ $(LIBBITCOIN_WALLET) \ $(LIBBITCOIN_ZMQ) \ - $(LIBBITCOIN_PROTON) \ $(LIBZCASH) lib_LTLIBRARIES = $(LIBZCASH_SCRIPT) @@ -156,11 +125,6 @@ BITCOIN_CORE_H = \ addrman.h \ alert.h \ amount.h \ - amqp/amqpabstractnotifier.h \ - amqp/amqpconfig.h \ - amqp/amqpnotificationinterface.h \ - amqp/amqppublishnotifier.h \ - amqp/amqpsender.h \ arith_uint256.h \ asyncrpcoperation.h \ asyncrpcqueue.h \ @@ -200,6 +164,7 @@ BITCOIN_CORE_H = \ keystore.h \ dbwrapper.h \ limitedmap.h \ + logging.h \ main.h \ memusage.h \ merkleblock.h \ @@ -341,15 +306,6 @@ libbitcoin_zmq_a_SOURCES = \ zmq/zmqpublishnotifier.cpp endif -if ENABLE_PROTON -libbitcoin_proton_a_CPPFLAGS = $(BITCOIN_INCLUDES) -libbitcoin_proton_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -libbitcoin_proton_a_SOURCES = \ - amqp/amqpabstractnotifier.cpp \ - amqp/amqpnotificationinterface.cpp \ - amqp/amqppublishnotifier.cpp -endif - # wallet: zcashd, but only linked when wallet enabled libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) @@ -458,6 +414,7 @@ libbitcoin_util_a_SOURCES = \ compat/glibc_sanity.cpp \ compat/glibcxx_sanity.cpp \ compat/strnlen.cpp \ + logging.cpp \ random.cpp \ rpc/protocol.cpp \ support/cleanse.cpp \ @@ -502,23 +459,20 @@ zcashd_LDADD = \ $(LIBUNIVALUE) \ $(LIBBITCOIN_UTIL) \ $(LIBBITCOIN_ZMQ) \ - $(LIBBITCOIN_PROTON) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH) \ $(LIBRUSTZCASH) \ $(LIBLEVELDB) \ + $(LIBLEVELDB_SSE42) \ $(LIBMEMENV) \ $(LIBSECP256K1) zcashd_LDADD += \ $(BOOST_LIBS) \ $(BDB_LIBS) \ - $(SSL_LIBS) \ - $(CRYPTO_LIBS) \ $(EVENT_PTHREADS_LIBS) \ $(EVENT_LIBS) \ $(ZMQ_LIBS) \ - $(PROTON_LIBS) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) @@ -537,8 +491,6 @@ zcash_cli_LDADD = \ $(LIBUNIVALUE) \ $(LIBBITCOIN_UTIL) \ $(BOOST_LIBS) \ - $(SSL_LIBS) \ - $(CRYPTO_LIBS) \ $(EVENT_LIBS) \ $(LIBZCASH) \ $(LIBRUSTZCASH) \ @@ -567,7 +519,7 @@ zcash_tx_LDADD = \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) -zcash_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) +zcash_tx_LDADD += $(BOOST_LIBS) # # zcash protocol primitives # @@ -624,15 +576,14 @@ CTAES_DIST += crypto/ctaes/ctaes.h CTAES_DIST += crypto/ctaes/README.md CTAES_DIST += crypto/ctaes/test.c -CLEANFILES = leveldb/libleveldb.a leveldb/libmemenv.a *.gcda *.gcno */*.gcno wallet/*/*.gcno +CLEANFILES = *.gcda *.gcno */*.gcno wallet/*/*.gcno DISTCLEANFILES = obj/build.h -EXTRA_DIST = leveldb $(CTAES_DIST) rust +EXTRA_DIST = $(CTAES_DIST) rust clean-local: rm -f $(top_srcdir)/.cargo/config $(top_srcdir)/.cargo/.configured-for-* - -$(MAKE) -C leveldb clean -$(MAKE) -C secp256k1 clean -$(MAKE) -C univalue clean rm -f leveldb/*/*.gcno leveldb/helpers/memenv/*.gcno @@ -664,6 +615,10 @@ endif @test -f $(PROTOC) $(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(abspath $( - static AMQPAbstractNotifier* Create() - { - return new T(); - } - - std::string GetType() const { return type; } - void SetType(const std::string &t) { type = t; } - std::string GetAddress() const { return address; } - void SetAddress(const std::string &a) { address = a; } - - virtual bool Initialize() = 0; - virtual void Shutdown() = 0; - - virtual bool NotifyBlock(const CBlockIndex *pindex); - virtual bool NotifyTransaction(const CTransaction &transaction); - -protected: - std::string type; - std::string address; -}; - -#endif // ZCASH_AMQP_AMQPABSTRACTNOTIFIER_H diff --git a/depend/zcash/src/amqp/amqpconfig.h b/depend/zcash/src/amqp/amqpconfig.h deleted file mode 100644 index 8b2fd6a88..000000000 --- a/depend/zcash/src/amqp/amqpconfig.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or https://www.opensource.org/licenses/mit-license.php . - -#ifndef ZCASH_AMQP_AMQPCONFIG_H -#define ZCASH_AMQP_AMQPCONFIG_H - -#if defined(HAVE_CONFIG_H) -#include "config/bitcoin-config.h" -#endif - -#include -#include - -#if ENABLE_PROTON -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#include "primitives/block.h" -#include "primitives/transaction.h" - -#endif // ZCASH_AMQP_AMQPCONFIG_H diff --git a/depend/zcash/src/amqp/amqpnotificationinterface.cpp b/depend/zcash/src/amqp/amqpnotificationinterface.cpp deleted file mode 100644 index 27f98f690..000000000 --- a/depend/zcash/src/amqp/amqpnotificationinterface.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or https://www.opensource.org/licenses/mit-license.php . - -#include "amqpnotificationinterface.h" -#include "amqppublishnotifier.h" - -#include "version.h" -#include "main.h" -#include "streams.h" -#include "util.h" - -// AMQP 1.0 Support -// -// The boost::signals2 signals and slot system is thread safe, so CValidationInterface listeners -// can be invoked from any thread. -// -// Currently signals are fired from main.cpp so the callbacks should be invoked on the same thread. -// It should be safe to share objects responsible for sending, as they should not be run concurrently -// across different threads. -// -// Developers should be mindful of where notifications are fired to avoid potential race conditions. -// For example, different signals targeting the same address could be fired from different threads -// in different parts of the system around the same time. -// -// Like the ZMQ notification interface, if a notifier fails to send a message, the notifier is shut down. -// - -AMQPNotificationInterface::AMQPNotificationInterface() -{ -} - -AMQPNotificationInterface::~AMQPNotificationInterface() -{ - Shutdown(); - - for (std::list::iterator i = notifiers.begin(); i != notifiers.end(); ++i) { - delete *i; - } -} - -AMQPNotificationInterface* AMQPNotificationInterface::CreateWithArguments(const std::map &args) -{ - AMQPNotificationInterface* notificationInterface = nullptr; - std::map factories; - std::list notifiers; - - factories["pubhashblock"] = AMQPAbstractNotifier::Create; - factories["pubhashtx"] = AMQPAbstractNotifier::Create; - factories["pubrawblock"] = AMQPAbstractNotifier::Create; - factories["pubrawtx"] = AMQPAbstractNotifier::Create; - - for (std::map::const_iterator i=factories.begin(); i!=factories.end(); ++i) { - std::map::const_iterator j = args.find("-amqp" + i->first); - if (j!=args.end()) { - AMQPNotifierFactory factory = i->second; - std::string address = j->second; - AMQPAbstractNotifier *notifier = factory(); - notifier->SetType(i->first); - notifier->SetAddress(address); - notifiers.push_back(notifier); - } - } - - if (!notifiers.empty()) { - notificationInterface = new AMQPNotificationInterface(); - notificationInterface->notifiers = notifiers; - - if (!notificationInterface->Initialize()) { - delete notificationInterface; - notificationInterface = nullptr; - } - } - - return notificationInterface; -} - -// Called at startup to conditionally set up -bool AMQPNotificationInterface::Initialize() -{ - LogPrint("amqp", "amqp: Initialize notification interface\n"); - - std::list::iterator i = notifiers.begin(); - for (; i != notifiers.end(); ++i) { - AMQPAbstractNotifier *notifier = *i; - if (notifier->Initialize()) { - LogPrint("amqp", "amqp: Notifier %s ready (address = %s)\n", notifier->GetType(), notifier->GetAddress()); - } else { - LogPrint("amqp", "amqp: Notifier %s failed (address = %s)\n", notifier->GetType(), notifier->GetAddress()); - break; - } - } - - if (i != notifiers.end()) { - return false; - } - - return true; -} - -// Called during shutdown sequence -void AMQPNotificationInterface::Shutdown() -{ - LogPrint("amqp", "amqp: Shutdown notification interface\n"); - - for (std::list::iterator i = notifiers.begin(); i != notifiers.end(); ++i) { - AMQPAbstractNotifier *notifier = *i; - notifier->Shutdown(); - } -} - -void AMQPNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindex) -{ - for (std::list::iterator i = notifiers.begin(); i != notifiers.end(); ) { - AMQPAbstractNotifier *notifier = *i; - if (notifier->NotifyBlock(pindex)) { - i++; - } else { - notifier->Shutdown(); - i = notifiers.erase(i); - } - } -} - -void AMQPNotificationInterface::SyncTransaction(const CTransaction &tx, const CBlock *pblock, const int nHeight) -{ - for (std::list::iterator i = notifiers.begin(); i != notifiers.end(); ) { - AMQPAbstractNotifier *notifier = *i; - if (notifier->NotifyTransaction(tx)) { - i++; - } else { - notifier->Shutdown(); - i = notifiers.erase(i); - } - } -} diff --git a/depend/zcash/src/amqp/amqpnotificationinterface.h b/depend/zcash/src/amqp/amqpnotificationinterface.h deleted file mode 100644 index ef0ac7f34..000000000 --- a/depend/zcash/src/amqp/amqpnotificationinterface.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or https://www.opensource.org/licenses/mit-license.php . - -#ifndef ZCASH_AMQP_AMQPNOTIFICATIONINTERFACE_H -#define ZCASH_AMQP_AMQPNOTIFICATIONINTERFACE_H - -#include "validationinterface.h" -#include -#include - -class CBlockIndex; -class AMQPAbstractNotifier; - -class AMQPNotificationInterface : public CValidationInterface -{ -public: - virtual ~AMQPNotificationInterface(); - - static AMQPNotificationInterface* CreateWithArguments(const std::map &args); - -protected: - bool Initialize(); - void Shutdown(); - - // CValidationInterface - void SyncTransaction(const CTransaction &tx, const CBlock *pblock, const int nHeight); - void UpdatedBlockTip(const CBlockIndex *pindex); - -private: - AMQPNotificationInterface(); - - std::list notifiers; -}; - -#endif // ZCASH_AMQP_AMQPNOTIFICATIONINTERFACE_H diff --git a/depend/zcash/src/amqp/amqppublishnotifier.cpp b/depend/zcash/src/amqp/amqppublishnotifier.cpp deleted file mode 100644 index 2dc780273..000000000 --- a/depend/zcash/src/amqp/amqppublishnotifier.cpp +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or https://www.opensource.org/licenses/mit-license.php . - -#include "amqppublishnotifier.h" -#include "chainparams.h" -#include "main.h" -#include "util.h" - -#include "amqpsender.h" - -#include -#include - -static std::multimap mapPublishNotifiers; - -static const char *MSG_HASHBLOCK = "hashblock"; -static const char *MSG_HASHTX = "hashtx"; -static const char *MSG_RAWBLOCK = "rawblock"; -static const char *MSG_RAWTX = "rawtx"; - -// Invoke this method from a new thread to run the proton container event loop. -void AMQPAbstractPublishNotifier::SpawnProtonContainer() -{ - try { - proton::default_container(*handler_).run(); - } - catch (const proton::error_condition &e) { - LogPrint("amqp", "amqp: container error: %s\n", e.what()); - } - catch (const std::runtime_error &e) { - LogPrint("amqp", "amqp: runtime error: %s\n", e.what()); - } - catch (const std::exception &e) { - LogPrint("amqp", "amqp: exception: %s\n", e.what()); - } - catch (...) { - LogPrint("amqp", "amqp: unknown error\n"); - } - handler_->terminate(); -} - -bool AMQPAbstractPublishNotifier::Initialize() -{ - std::multimap::iterator i = mapPublishNotifiers.find(address); - - if (i == mapPublishNotifiers.end()) { - try { - handler_ = std::make_shared(address); - thread_ = std::make_shared(&AMQPAbstractPublishNotifier::SpawnProtonContainer, this); - } - catch (std::exception &e) { - LogPrint("amqp", "amqp: initialization error: %s\n", e.what()); - return false; - } - mapPublishNotifiers.insert(std::make_pair(address, this)); - } else { - // copy the shared ptrs to the message handler and the thread where the proton container is running - handler_ = i->second->handler_; - thread_ = i->second->thread_; - mapPublishNotifiers.insert(std::make_pair(address, this)); - } - - return true; -} - - -void AMQPAbstractPublishNotifier::Shutdown() -{ - LogPrint("amqp", "amqp: Shutdown notifier %s at %s\n", GetType(), GetAddress()); - - int count = mapPublishNotifiers.count(address); - - // remove this notifier from the list of publishers using this address - typedef std::multimap::iterator iterator; - std::pair iterpair = mapPublishNotifiers.equal_range(address); - - for (iterator it = iterpair.first; it != iterpair.second; ++it) { - if (it->second == this) { - mapPublishNotifiers.erase(it); - break; - } - } - - // terminate the connection if this is the last publisher using this address - if (count == 1) { - handler_->terminate(); - if (thread_.get() != nullptr) { - if (thread_->joinable()) { - thread_->join(); - } - } - } -} - - -bool AMQPAbstractPublishNotifier::SendMessage(const char *command, const void* data, size_t size) -{ - try { - proton::binary content; - const char *p = (const char *)data; - content.assign(p, p + size); - - proton::message message(content); - message.subject(std::string(command)); - proton::message::property_map & props = message.properties(); - props.put("x-opt-sequence-number", sequence_); - handler_->publish(message); - - } catch (proton::error_condition &e) { - LogPrint("amqp", "amqp: error : %s\n", e.what()); - return false; - } - catch (const std::runtime_error &e) { - LogPrint("amqp", "amqp: runtime error: %s\n", e.what()); - return false; - } - catch (const std::exception &e) { - LogPrint("amqp", "amqp: exception: %s\n", e.what()); - return false; - } - catch (...) { - LogPrint("amqp", "amqp: unknown error\n"); - return false; - } - - sequence_++; - - return true; -} - -bool AMQPPublishHashBlockNotifier::NotifyBlock(const CBlockIndex *pindex) -{ - uint256 hash = pindex->GetBlockHash(); - LogPrint("amqp", "amqp: Publish hashblock %s\n", hash.GetHex()); - char data[32]; - for (unsigned int i = 0; i < 32; i++) - data[31 - i] = hash.begin()[i]; - return SendMessage(MSG_HASHBLOCK, data, 32); -} - -bool AMQPPublishHashTransactionNotifier::NotifyTransaction(const CTransaction &transaction) -{ - uint256 hash = transaction.GetHash(); - LogPrint("amqp", "amqp: Publish hashtx %s\n", hash.GetHex()); - char data[32]; - for (unsigned int i = 0; i < 32; i++) - data[31 - i] = hash.begin()[i]; - return SendMessage(MSG_HASHTX, data, 32); -} - -bool AMQPPublishRawBlockNotifier::NotifyBlock(const CBlockIndex *pindex) -{ - LogPrint("amqp", "amqp: Publish rawblock %s\n", pindex->GetBlockHash().GetHex()); - - const Consensus::Params& consensusParams = Params().GetConsensus(); - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - { - LOCK(cs_main); - CBlock block; - if(!ReadBlockFromDisk(block, pindex, consensusParams)) { - LogPrint("amqp", "amqp: Can't read block from disk"); - return false; - } - - ss << block; - } - - return SendMessage(MSG_RAWBLOCK, &(*ss.begin()), ss.size()); -} - -bool AMQPPublishRawTransactionNotifier::NotifyTransaction(const CTransaction &transaction) -{ - uint256 hash = transaction.GetHash(); - LogPrint("amqp", "amqp: Publish rawtx %s\n", hash.GetHex()); - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << transaction; - return SendMessage(MSG_RAWTX, &(*ss.begin()), ss.size()); -} diff --git a/depend/zcash/src/amqp/amqppublishnotifier.h b/depend/zcash/src/amqp/amqppublishnotifier.h deleted file mode 100644 index 2eca74444..000000000 --- a/depend/zcash/src/amqp/amqppublishnotifier.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or https://www.opensource.org/licenses/mit-license.php . - -#ifndef ZCASH_AMQP_AMQPPUBLISHNOTIFIER_H -#define ZCASH_AMQP_AMQPPUBLISHNOTIFIER_H - -#include "amqpabstractnotifier.h" -#include "amqpconfig.h" -#include "amqpsender.h" - -#include -#include - -class CBlockIndex; - -class AMQPAbstractPublishNotifier : public AMQPAbstractNotifier -{ -private: - uint64_t sequence_; // memory only, per notifier instance: upcounting message sequence number - - std::shared_ptr thread_; // proton container thread, may be shared between notifiers - std::shared_ptr handler_; // proton container message handler, may be shared between notifiers - -public: - bool SendMessage(const char *command, const void* data, size_t size); - bool Initialize(); - void Shutdown(); - void SpawnProtonContainer(); -}; - -class AMQPPublishHashBlockNotifier : public AMQPAbstractPublishNotifier -{ -public: - bool NotifyBlock(const CBlockIndex *pindex); -}; - -class AMQPPublishHashTransactionNotifier : public AMQPAbstractPublishNotifier -{ -public: - bool NotifyTransaction(const CTransaction &transaction); -}; - -class AMQPPublishRawBlockNotifier : public AMQPAbstractPublishNotifier -{ -public: - bool NotifyBlock(const CBlockIndex *pindex); -}; - -class AMQPPublishRawTransactionNotifier : public AMQPAbstractPublishNotifier -{ -public: - bool NotifyTransaction(const CTransaction &transaction); -}; - -#endif // ZCASH_AMQP_AMQPPUBLISHNOTIFIER_H diff --git a/depend/zcash/src/amqp/amqpsender.h b/depend/zcash/src/amqp/amqpsender.h deleted file mode 100644 index eb365d3ec..000000000 --- a/depend/zcash/src/amqp/amqpsender.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or https://www.opensource.org/licenses/mit-license.php . - -#ifndef ZCASH_AMQP_AMQPSENDER_H -#define ZCASH_AMQP_AMQPSENDER_H - -#include "amqpconfig.h" - -#include -#include -#include -#include - -class AMQPSender : public proton::messaging_handler { - private: - std::deque messages_; - proton::url url_; - proton::connection conn_; - proton::sender sender_; - std::mutex lock_; - std::atomic terminated_ = {false}; - - public: - - AMQPSender(const std::string& url) : url_(url) {} - - // Callback to initialize the container when run() is invoked - void on_container_start(proton::container& c) override { - proton::duration t(10000); // milliseconds - proton::connection_options opts = proton::connection_options().idle_timeout(t); - conn_ = c.connect(url_, opts); - sender_ = conn_.open_sender(url_.path()); - } - - // Remote end signals when the local end can send (i.e. has credit) - void on_sendable(proton::sender &s) override { - dispatch(); - } - - // Publish message by adding to queue and trying to dispatch it - void publish(const proton::message &m) { - add_message(m); - dispatch(); - } - - // Add message to queue - void add_message(const proton::message &m) { - std::lock_guard guard(lock_); - messages_.push_back(m); - } - - // Send messages in queue - void dispatch() { - std::lock_guard guard(lock_); - - if (isTerminated()) { - throw std::runtime_error("amqp connection was terminated"); - } - - if (!conn_.active()) { - throw std::runtime_error("amqp connection is not active"); - } - - while (messages_.size() > 0) { - if (sender_.credit()) { - const proton::message& m = messages_.front(); - sender_.send(m); - messages_.pop_front(); - } else { - break; - } - } - } - - // Close connection to remote end. Container event-loop, by default, will auto-stop. - void terminate() { - std::lock_guard guard(lock_); - conn_.close(); - terminated_.store(true); - } - - bool isTerminated() const { - return terminated_.load(); - } - - void on_transport_error(proton::transport &t) override { - t.connection().close(); - throw t.error(); - } - - void on_connection_error(proton::connection &c) override { - c.close(); - throw c.error(); - } - - void on_session_error(proton::session &s) override { - s.connection().close(); - throw s.error(); - } - - void on_receiver_error(proton::receiver &r) override { - r.connection().close(); - throw r.error(); - } - - void on_sender_error(proton::sender &s) override { - s.connection().close(); - throw s.error(); - } - -}; - - -#endif //ZCASH_AMQP_AMQPSENDER_H diff --git a/depend/zcash/src/bench/bench_bitcoin.cpp b/depend/zcash/src/bench/bench_bitcoin.cpp index 816efb012..719c72746 100644 --- a/depend/zcash/src/bench/bench_bitcoin.cpp +++ b/depend/zcash/src/bench/bench_bitcoin.cpp @@ -34,13 +34,10 @@ main(int argc, char** argv) librustzcash_init_zksnark_params( reinterpret_cast(sapling_spend_str.c_str()), sapling_spend_str.length(), - "8270785a1a0d0bc77196f000ee6d221c9c9894f55307bd9357c3f0105d31ca63991ab91324160d8f53e2bbd3c2633a6eb8bdf5205d822e7f3f73edac51b2b70c", reinterpret_cast(sapling_output_str.c_str()), sapling_output_str.length(), - "657e3d38dbb5cb5e7dd2970e8b03d69b4787dd907285b5a7f0790dcc8072f60bf593b32cc2d1c030e00ff5ae64bf84c5c3beb84ddc841d48264b4a171744d028", reinterpret_cast(sprout_groth16_str.c_str()), - sprout_groth16_str.length(), - "e9b238411bd6c0ec4791e9d04245ec350c9c5744f5610dfcce4365d5ca49dfefd5054e371842b3f88fa1b9d7e8e075249b3ebabd167fa8b0f3161292d36c180a" + sprout_groth16_str.length() ); benchmark::BenchRunner::RunAll(); diff --git a/depend/zcash/src/bench/lockedpool.cpp b/depend/zcash/src/bench/lockedpool.cpp index 5df5b1ac6..4226d6b82 100644 --- a/depend/zcash/src/bench/lockedpool.cpp +++ b/depend/zcash/src/bench/lockedpool.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php . #include "bench.h" @@ -21,21 +21,21 @@ static void LockedPool(benchmark::State& state) std::vector addr; for (int x=0; x> 16) & (MSIZE-1)); } bool lsb = s & 1; s >>= 1; if (lsb) - s ^= 0xf00f00f0; // LFSR period 0xf7ffffe0 + s ^= 0xf00f00f0; // LFSR period 0xf7ffffe1 } } for (void *ptr: addr) @@ -44,4 +44,3 @@ static void LockedPool(benchmark::State& state) } BENCHMARK(LockedPool); - diff --git a/depend/zcash/src/bench/verification.cpp b/depend/zcash/src/bench/verification.cpp index 2fff0c8a4..870c14704 100644 --- a/depend/zcash/src/bench/verification.cpp +++ b/depend/zcash/src/bench/verification.cpp @@ -15,7 +15,7 @@ #include "version.h" #include "librustzcash.h" -#include "sodium.h" +#include static void ECDSA(benchmark::State& state) { @@ -75,20 +75,20 @@ static void ECDSA(benchmark::State& state) static void JoinSplitSig(benchmark::State& state) { - uint256 joinSplitPubKey; - unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES]; + Ed25519VerificationKey joinSplitPubKey; + Ed25519SigningKey joinSplitPrivKey; uint256 dataToBeSigned; - std::array joinSplitSig; + Ed25519Signature joinSplitSig; - crypto_sign_keypair(joinSplitPubKey.begin(), joinSplitPrivKey); - crypto_sign_detached(&joinSplitSig[0], nullptr, dataToBeSigned.begin(), 32, joinSplitPrivKey); + ed25519_generate_keypair(&joinSplitPrivKey, &joinSplitPubKey); + ed25519_sign(&joinSplitPrivKey, dataToBeSigned.begin(), 32, &joinSplitSig); while (state.KeepRunning()) { // Declared with warn_unused_result. - auto res = crypto_sign_verify_detached( - &joinSplitSig[0], - dataToBeSigned.begin(), 32, - joinSplitPubKey.begin()); + auto res = ed25519_verify( + &joinSplitPubKey, + &joinSplitSig, + dataToBeSigned.begin(), 32); } } diff --git a/depend/zcash/src/bitcoind.cpp b/depend/zcash/src/bitcoind.cpp index d7fe0ef6d..54b6359ed 100644 --- a/depend/zcash/src/bitcoind.cpp +++ b/depend/zcash/src/bitcoind.cpp @@ -170,6 +170,11 @@ bool AppInit(int argc, char* argv[]) // Set this early so that parameter interactions go to console InitLogging(); + + // Now that we have logging set up, start the initialization span. + auto span = TracingSpan("info", "main", "Init"); + auto spanGuard = span.Enter(); + InitParameterInteraction(); fRet = AppInit2(threadGroup, scheduler); } diff --git a/depend/zcash/src/chain.h b/depend/zcash/src/chain.h index 01dbf090d..01204fdc8 100644 --- a/depend/zcash/src/chain.h +++ b/depend/zcash/src/chain.h @@ -589,7 +589,7 @@ class CChain { /** Return the maximal height in the chain. Is equal to chain.Tip() ? chain.Tip()->nHeight : -1. */ int Height() const { - return vChain.size() - 1; + return int(vChain.size()) - 1; } /** Set/initialize a chain with a given tip. */ diff --git a/depend/zcash/src/chainparams.cpp b/depend/zcash/src/chainparams.cpp index 3d39006e4..1b750b1d6 100644 --- a/depend/zcash/src/chainparams.cpp +++ b/depend/zcash/src/chainparams.cpp @@ -125,8 +125,7 @@ class CMainParams : public CChainParams { consensus.vUpgrades[Consensus::UPGRADE_HEARTWOOD].nProtocolVersion = 170011; consensus.vUpgrades[Consensus::UPGRADE_HEARTWOOD].nActivationHeight = 903000; consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nProtocolVersion = 170013; - consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight = - Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; + consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight = 1046400; consensus.nFundingPeriodLength = consensus.nPostBlossomSubsidyHalvingInterval / 48; @@ -152,24 +151,78 @@ class CMainParams : public CChainParams { keyConstants.bech32HRPs[SAPLING_EXTENDED_SPEND_KEY] = "secret-extended-key-main"; keyConstants.bech32HRPs[SAPLING_EXTENDED_FVK] = "zxviews"; - // TODO: This `if` can be removed once canopy activation height is set. - if (consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight != Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT) { - std::vector addresses(48, ""); + { + std::vector ecc_addresses = { + "t3LmX1cxWPPPqL4TZHx42HU3U5ghbFjRiif", + "t3Toxk1vJQ6UjWQ42tUJz2rV2feUWkpbTDs", + "t3ZBdBe4iokmsjdhMuwkxEdqMCFN16YxKe6", + "t3ZuaJziLM8xZ32rjDUzVjVtyYdDSz8GLWB", + "t3bAtYWa4bi8VrtvqySxnbr5uqcG9czQGTZ", + "t3dktADfb5Rmxncpe1HS5BRS5Gcj7MZWYBi", + "t3hgskquvKKoCtvxw86yN7q8bzwRxNgUZmc", + "t3R1VrLzwcxAZzkX4mX3KGbWpNsgtYtMntj", + "t3ff6fhemqPMVujD3AQurxRxTdvS1pPSaa2", + "t3cEUQFG3KYnFG6qYhPxSNgGi3HDjUPwC3J", + "t3WR9F5U4QvUFqqx9zFmwT6xFqduqRRXnaa", + "t3PYc1LWngrdUrJJbHkYPCKvJuvJjcm85Ch", + "t3bgkjiUeatWNkhxY3cWyLbTxKksAfk561R", + "t3Z5rrR8zahxUpZ8itmCKhMSfxiKjUp5Dk5", + "t3PU1j7YW3fJ67jUbkGhSRto8qK2qXCUiW3", + "t3S3yaT7EwNLaFZCamfsxxKwamQW2aRGEkh", + "t3eutXKJ9tEaPSxZpmowhzKhPfJvmtwTEZK", + "t3gbTb7brxLdVVghSPSd3ycGxzHbUpukeDm", + "t3UCKW2LrHFqPMQFEbZn6FpjqnhAAbfpMYR", + "t3NyHsrnYbqaySoQqEQRyTWkjvM2PLkU7Uu", + "t3QEFL6acxuZwiXtW3YvV6njDVGjJ1qeaRo", + "t3PdBRr2S1XTDzrV8bnZkXF3SJcrzHWe1wj", + "t3ZWyRPpWRo23pKxTLtWsnfEKeq9T4XPxKM", + "t3he6QytKCTydhpztykFsSsb9PmBT5JBZLi", + "t3VWxWDsLb2TURNEP6tA1ZSeQzUmPKFNxRY", + "t3NmWLvZkbciNAipauzsFRMxoZGqmtJksbz", + "t3cKr4YxVPvPBG1mCvzaoTTdBNokohsRJ8n", + "t3T3smGZn6BoSFXWWXa1RaoQdcyaFjMfuYK", + "t3gkDUe9Gm4GGpjMk86TiJZqhztBVMiUSSA", + "t3eretuBeBXFHe5jAqeSpUS1cpxVh51fAeb", + "t3dN8g9zi2UGJdixGe9txeSxeofLS9t3yFQ", + "t3S799pq9sYBFwccRecoTJ3SvQXRHPrHqvx", + "t3fhYnv1S5dXwau7GED3c1XErzt4n4vDxmf", + "t3cmE3vsBc5xfDJKXXZdpydCPSdZqt6AcNi", + "t3h5fPdjJVHaH4HwynYDM5BB3J7uQaoUwKi", + "t3Ma35c68BgRX8sdLDJ6WR1PCrKiWHG4Da9", + "t3LokMKPL1J8rkJZvVpfuH7dLu6oUWqZKQK", + "t3WFFGbEbhJWnASZxVLw2iTJBZfJGGX73mM", + "t3L8GLEsUn4QHNaRYcX3EGyXmQ8kjpT1zTa", + "t3PgfByBhaBSkH8uq4nYJ9ZBX4NhGCJBVYm", + "t3WecsqKDhWXD4JAgBVcnaCC2itzyNZhJrv", + "t3ZG9cSfopnsMQupKW5v9sTotjcP5P6RTbn", + "t3hC1Ywb5zDwUYYV8LwhvF5rZ6m49jxXSG5", + "t3VgMqDL15ZcyQDeqBsBW3W6rzfftrWP2yB", + "t3LC94Y6BwLoDtBoK2NuewaEbnko1zvR9rm", + "t3cWCUZJR3GtALaTcatrrpNJ3MGbMFVLRwQ", + "t3YYF4rPLVxDcF9hHFsXyc5Yq1TFfbojCY6", + "t3XHAGxRP2FNfhAjxGjxbrQPYtQQjc3RCQD", + }; + + // ZF and MG each use a single address repeated 48 times, + // once for each funding period. + std::vector zf_addresses(48, "t3dvVE3SQEi7kqNzwrfNePxZ1d4hUyztBA1"); + std::vector mg_addresses(48, "t3XyYW8yBFRuMnfvm5KLGFbEVz25kckZXym"); + consensus.AddZIP207FundingStream( keyConstants, Consensus::FS_ZIP214_ECC, consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight, 2726400, - addresses); + ecc_addresses); consensus.AddZIP207FundingStream( keyConstants, Consensus::FS_ZIP214_ZF, consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight, 2726400, - addresses); + zf_addresses); consensus.AddZIP207FundingStream( keyConstants, Consensus::FS_ZIP214_MG, consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight, 2726400, - addresses); + mg_addresses); } // The best chain should have at least this much work. @@ -227,7 +280,6 @@ class CMainParams : public CChainParams { (525000, uint256S("0x0000000001a36c500378be8862d9bf1bea8f1616da6e155971b608139cc7e39b")), 1556722044, // * UNIX timestamp of last checkpoint block 4653556, // * total number of transactions between genesis and last checkpoint - // (the tx=... number in the SetBestChain debug.log lines) 5106 // * estimated number of transactions per day after checkpoint // total number of tx / (checkpoint block height / (24 * 24)) }; @@ -354,8 +406,7 @@ class CTestNetParams : public CChainParams { consensus.vUpgrades[Consensus::UPGRADE_HEARTWOOD].hashActivationBlock = uint256S("05688d8a0e9ff7c04f6f05e6d695dc5ab43b9c4803342d77ae360b2b27d2468e"); consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nProtocolVersion = 170012; - consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight = - Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; + consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight = 1028500; consensus.nFundingPeriodLength = consensus.nPostBlossomSubsidyHalvingInterval / 48; @@ -381,24 +432,81 @@ class CTestNetParams : public CChainParams { keyConstants.bech32HRPs[SAPLING_EXTENDED_SPEND_KEY] = "secret-extended-key-test"; keyConstants.bech32HRPs[SAPLING_EXTENDED_FVK] = "zxviewtestsapling"; - // TODO: This `if` can be removed once canopy activation height is set. - if (consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight != Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT) { - std::vector addresses(48, ""); + // Testnet funding streams + { + std::vector ecc_addresses = { + "t26ovBdKAJLtrvBsE2QGF4nqBkEuptuPFZz", + "t26ovBdKAJLtrvBsE2QGF4nqBkEuptuPFZz", + "t26ovBdKAJLtrvBsE2QGF4nqBkEuptuPFZz", + "t26ovBdKAJLtrvBsE2QGF4nqBkEuptuPFZz", + "t2NNHrgPpE388atmWSF4DxAb3xAoW5Yp45M", + "t2VMN28itPyMeMHBEd9Z1hm6YLkQcGA1Wwe", + "t2CHa1TtdfUV8UYhNm7oxbzRyfr8616BYh2", + "t2F77xtr28U96Z2bC53ZEdTnQSUAyDuoa67", + "t2ARrzhbgcpoVBDPivUuj6PzXzDkTBPqfcT", + "t278aQ8XbvFR15mecRguiJDQQVRNnkU8kJw", + "t2Dp1BGnZsrTXZoEWLyjHmg3EPvmwBnPDGB", + "t2KzeqXgf4ju33hiSqCuKDb8iHjPCjMq9iL", + "t2Nyxqv1BiWY1eUSiuxVw36oveawYuo18tr", + "t2DKFk5JRsVoiuinK8Ti6eM4Yp7v8BbfTyH", + "t2CUaBca4k1x36SC4q8Nc8eBoqkMpF3CaLg", + "t296SiKL7L5wvFmEdMxVLz1oYgd6fTfcbZj", + "t29fBCFbhgsjL3XYEZ1yk1TUh7eTusB6dPg", + "t2FGofLJXa419A76Gpf5ncxQB4gQXiQMXjK", + "t2ExfrnRVnRiXDvxerQ8nZbcUQvNvAJA6Qu", + "t28JUffLp47eKPRHKvwSPzX27i9ow8LSXHx", + "t2JXWPtrtyL861rFWMZVtm3yfgxAf4H7uPA", + "t2QdgbJoWfYHgyvEDEZBjHmgkr9yNJff3Hi", + "t2QW43nkco8r32ZGRN6iw6eSzyDjkMwCV3n", + "t2DgYDXMJTYLwNcxighQ9RCgPxMVATRcUdC", + "t2Bop7dg33HGZx3wunnQzi2R2ntfpjuti3M", + "t2HVeEwovcLq9RstAbYkqngXNEsCe2vjJh9", + "t2HxbP5keQSx7p592zWQ5bJ5GrMmGDsV2Xa", + "t2TJzUg2matao3mztBRJoWnJY6ekUau6tPD", + "t29pMzxmo6wod25YhswcjKv3AFRNiBZHuhj", + "t2QBQMRiJKYjshJpE6RhbF7GLo51yE6d4wZ", + "t2F5RqnqguzZeiLtYHFx4yYfy6pDnut7tw5", + "t2CHvyZANE7XCtg8AhZnrcHCC7Ys1jJhK13", + "t2BRzpMdrGWZJ2upsaNQv6fSbkbTy7EitLo", + "t2BFixHGQMAWDY67LyTN514xRAB94iEjXp3", + "t2Uvz1iVPzBEWfQBH1p7NZJsFhD74tKaG8V", + "t2CmFDj5q6rJSRZeHf1SdrowinyMNcj438n", + "t2ErNvWEReTfPDBaNizjMPVssz66aVZh1hZ", + "t2GeJQ8wBUiHKDVzVM5ZtKfY5reCg7CnASs", + "t2L2eFtkKv1G6j55kLytKXTGuir4raAy3yr", + "t2EK2b87dpPazb7VvmEGc8iR6SJ289RywGL", + "t2DJ7RKeZJxdA4nZn8hRGXE8NUyTzjujph9", + "t2K1pXo4eByuWpKLkssyMLe8QKUbxnfFC3H", + "t2TB4mbSpuAcCWkH94Leb27FnRxo16AEHDg", + "t2Phx4gVL4YRnNsH3jM1M7jE4Fo329E66Na", + "t2VQZGmeNomN8c3USefeLL9nmU6M8x8CVzC", + "t2RicCvTVTY5y9JkreSRv3Xs8q2K67YxHLi", + "t2JrSLxTGc8wtPDe9hwbaeUjCrCfc4iZnDD", + "t2Uh9Au1PDDSw117sAbGivKREkmMxVC5tZo", + "t2FDwoJKLeEBMTy3oP7RLQ1Fihhvz49a3Bv", + "t2FY18mrgtb7QLeHA8ShnxLXuW8cNQ2n1v8", + "t2L15TkDYum7dnQRBqfvWdRe8Yw3jVy9z7g", + }; + + // ZF and MG use the same address for each funding period + std::vector zf_addresses(51, "t27eWDgjFYJGVXmzrXeVjnb5J3uXDM9xH9v"); + std::vector mg_addresses(51, "t2Gvxv2uNM7hbbACjNox4H6DjByoKZ2Fa3P"); + consensus.AddZIP207FundingStream( keyConstants, Consensus::FS_ZIP214_ECC, - consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight, 2726400, - addresses); + consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight, 2796000, + ecc_addresses); consensus.AddZIP207FundingStream( keyConstants, Consensus::FS_ZIP214_ZF, - consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight, 2726400, - addresses); + consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight, 2796000, + zf_addresses); consensus.AddZIP207FundingStream( keyConstants, Consensus::FS_ZIP214_MG, - consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight, 2726400, - addresses); + consensus.vUpgrades[Consensus::UPGRADE_CANOPY].nActivationHeight, 2796000, + mg_addresses); } // On testnet we activate this rule 6 blocks after Blossom activation. From block 299188 and @@ -459,7 +567,6 @@ class CTestNetParams : public CChainParams { (38000, uint256S("0x001e9a2d2e2892b88e9998cf7b079b41d59dd085423a921fe8386cecc42287b8")), 1486897419, // * UNIX timestamp of last checkpoint block 47163, // * total number of transactions between genesis and last checkpoint - // (the tx=... number in the SetBestChain debug.log lines) 715 // total number of tx / (checkpoint block height / (24 * 24)) }; diff --git a/depend/zcash/src/checkpoints.cpp b/depend/zcash/src/checkpoints.cpp index fbbb862cb..84c9c008b 100644 --- a/depend/zcash/src/checkpoints.cpp +++ b/depend/zcash/src/checkpoints.cpp @@ -78,4 +78,12 @@ namespace Checkpoints { return NULL; } + bool IsAncestorOfLastCheckpoint(const CCheckpointData& data, const CBlockIndex* pindex) + { + CBlockIndex *pindexLastCheckpoint = GetLastCheckpoint(data); + return pindexLastCheckpoint && pindexLastCheckpoint->GetAncestor(pindex->nHeight) == pindex; + } + + + } // namespace Checkpoints diff --git a/depend/zcash/src/checkpoints.h b/depend/zcash/src/checkpoints.h index b6501bc9a..b62b43280 100644 --- a/depend/zcash/src/checkpoints.h +++ b/depend/zcash/src/checkpoints.h @@ -27,6 +27,7 @@ CBlockIndex* GetLastCheckpoint(const CCheckpointData& data); double GuessVerificationProgress(const CCheckpointData& data, CBlockIndex* pindex, bool fSigchecks = true); +bool IsAncestorOfLastCheckpoint(const CCheckpointData& data, const CBlockIndex* pindex); } //namespace Checkpoints #endif // BITCOIN_CHECKPOINTS_H diff --git a/depend/zcash/src/clientversion.h b/depend/zcash/src/clientversion.h index 955d52b3b..9cee57fde 100644 --- a/depend/zcash/src/clientversion.h +++ b/depend/zcash/src/clientversion.h @@ -15,10 +15,10 @@ */ //! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it -#define CLIENT_VERSION_MAJOR 3 -#define CLIENT_VERSION_MINOR 1 +#define CLIENT_VERSION_MAJOR 4 +#define CLIENT_VERSION_MINOR 0 #define CLIENT_VERSION_REVISION 0 -#define CLIENT_VERSION_BUILD 26 +#define CLIENT_VERSION_BUILD 50 //! Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true diff --git a/depend/zcash/src/coins.cpp b/depend/zcash/src/coins.cpp index 365b984fd..f2999df13 100644 --- a/depend/zcash/src/coins.cpp +++ b/depend/zcash/src/coins.cpp @@ -467,7 +467,7 @@ void CCoinsViewCache::PushHistoryNode(uint32_t epochId, const HistoryNode node) // special case, it just goes into the cache right away historyCache.Extend(node); - if (librustzcash_mmr_hash_node(epochId, node.data(), historyCache.root.begin()) != 0) { + if (librustzcash_mmr_hash_node(epochId, &node, historyCache.root.begin()) != 0) { throw std::runtime_error("hashing node failed"); }; @@ -480,7 +480,7 @@ void CCoinsViewCache::PushHistoryNode(uint32_t epochId, const HistoryNode node) PreloadHistoryTree(epochId, false, entries, entry_indices); uint256 newRoot; - std::array appendBuf; + std::array appendBuf = {}; uint32_t appends = librustzcash_mmr_append( epochId, @@ -488,9 +488,9 @@ void CCoinsViewCache::PushHistoryNode(uint32_t epochId, const HistoryNode node) entry_indices.data(), entries.data(), entry_indices.size(), - node.data(), + &node, newRoot.begin(), - appendBuf.data()->data() + appendBuf.data() ); for (size_t i = 0; i < appends; i++) { @@ -506,6 +506,7 @@ void CCoinsViewCache::PopHistoryNode(uint32_t epochId) { switch (historyCache.length) { case 0: + { // Caller is generally not expected to pop from empty tree! Caller // should switch to previous epoch and pop history from there. @@ -517,22 +518,29 @@ void CCoinsViewCache::PopHistoryNode(uint32_t epochId) { // back. // Sensible action is to truncate the history cache: + } case 1: + { // Just resetting tree to empty historyCache.Truncate(0); historyCache.root = uint256(); return; + } case 2: + { // - A tree with one leaf has length 1. // - A tree with two leaves has length 3. throw std::runtime_error("a history tree cannot have two nodes"); + } case 3: + { + const HistoryNode tmpHistoryRoot = GetHistoryAt(epochId, 0); // After removing a leaf from a tree with two leaves, we are left // with a single-node tree, whose root is just the hash of that // node. if (librustzcash_mmr_hash_node( epochId, - GetHistoryAt(epochId, 0).data(), + &tmpHistoryRoot, newRoot.begin() ) != 0) { throw std::runtime_error("hashing node failed"); @@ -540,7 +548,9 @@ void CCoinsViewCache::PopHistoryNode(uint32_t epochId) { historyCache.Truncate(1); historyCache.root = newRoot; return; + } default: + { // This is a non-elementary pop, so use the full tree logic. std::vector entries; std::vector entry_indices; @@ -560,6 +570,7 @@ void CCoinsViewCache::PopHistoryNode(uint32_t epochId) { historyCache.Truncate(historyCache.length - numberOfDeletes); historyCache.root = newRoot; return; + } } } diff --git a/depend/zcash/src/consensus/funding.cpp b/depend/zcash/src/consensus/funding.cpp index 4b32d3fd8..7cec13080 100644 --- a/depend/zcash/src/consensus/funding.cpp +++ b/depend/zcash/src/consensus/funding.cpp @@ -10,7 +10,7 @@ namespace Consensus * General information about each funding stream. * Ordered by Consensus::FundingStreamIndex. */ -const struct FSInfo FundingStreamInfo[Consensus::MAX_FUNDING_STREAMS] = { +constexpr struct FSInfo FundingStreamInfo[Consensus::MAX_FUNDING_STREAMS] = { { .recipient = "Electric Coin Company", .specification = "https://zips.z.cash/zip-0214", @@ -31,6 +31,16 @@ const struct FSInfo FundingStreamInfo[Consensus::MAX_FUNDING_STREAMS] = { } }; +static constexpr bool validateFundingStreamInfo(uint32_t idx) { + return (idx >= Consensus::MAX_FUNDING_STREAMS || ( + FundingStreamInfo[idx].valueNumerator < FundingStreamInfo[idx].valueDenominator && + FundingStreamInfo[idx].valueNumerator < (INT64_MAX / MAX_MONEY) && + validateFundingStreamInfo(idx + 1))); +} +static_assert( + validateFundingStreamInfo(Consensus::FIRST_FUNDING_STREAM), + "Invalid FundingStreamInfo"); + CAmount FSInfo::Value(CAmount blockSubsidy) const { // Integer division is floor division for nonnegative integers in C++ @@ -43,17 +53,22 @@ std::set GetActiveFundingStreamElements( const Consensus::Params& params) { std::set> requiredElements; - for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) { - // The following indexed access is safe as Consensus::MAX_FUNDING_STREAMS is used - // in the definition of vFundingStreams. - auto fs = params.vFundingStreams[idx]; - // Funding period is [startHeight, endHeight) - if (fs && nHeight >= fs.value().GetStartHeight() && nHeight < fs.value().GetEndHeight()) { - requiredElements.insert(std::make_pair( - fs.value().RecipientAddress(params, nHeight), - FundingStreamInfo[idx].Value(blockSubsidy))); + + // Funding streams are disabled if Canopy is not active. + if (params.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_CANOPY)) { + for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) { + // The following indexed access is safe as Consensus::MAX_FUNDING_STREAMS is used + // in the definition of vFundingStreams. + auto fs = params.vFundingStreams[idx]; + // Funding period is [startHeight, endHeight) + if (fs && nHeight >= fs.value().GetStartHeight() && nHeight < fs.value().GetEndHeight()) { + requiredElements.insert(std::make_pair( + fs.value().RecipientAddress(params, nHeight), + FundingStreamInfo[idx].Value(blockSubsidy))); + } } } + return requiredElements; }; @@ -62,12 +77,17 @@ std::vector GetActiveFundingStreams( const Consensus::Params& params) { std::vector activeStreams; - for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) { - auto fs = params.vFundingStreams[idx]; - if (fs && nHeight >= fs.value().GetStartHeight() && nHeight < fs.value().GetEndHeight()) { - activeStreams.push_back(FundingStreamInfo[idx]); + + // Funding streams are disabled if Canopy is not active. + if (params.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_CANOPY)) { + for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) { + auto fs = params.vFundingStreams[idx]; + if (fs && nHeight >= fs.value().GetStartHeight() && nHeight < fs.value().GetEndHeight()) { + activeStreams.push_back(FundingStreamInfo[idx]); + } } } + return activeStreams; }; diff --git a/depend/zcash/src/consensus/funding.h b/depend/zcash/src/consensus/funding.h index fafe32099..7d14b8106 100644 --- a/depend/zcash/src/consensus/funding.h +++ b/depend/zcash/src/consensus/funding.h @@ -12,11 +12,17 @@ namespace Consensus { struct FSInfo { - std::string recipient; - std::string specification; + const char* recipient; + const char* specification; uint64_t valueNumerator; uint64_t valueDenominator; + /** + * Returns the inherent value of this funding stream. + * + * For the active funding streams at a given height, use + * GetActiveFundingStreams() or GetActiveFundingStreamElements(). + */ CAmount Value(CAmount blockSubsidy) const; }; diff --git a/depend/zcash/src/consensus/params.cpp b/depend/zcash/src/consensus/params.cpp index 2eb1ad5f8..cc519337b 100644 --- a/depend/zcash/src/consensus/params.cpp +++ b/depend/zcash/src/consensus/params.cpp @@ -47,6 +47,9 @@ namespace Consensus { * first halving. */ int Params::HalvingHeight(int nHeight, int halvingIndex) const { + assert(nHeight >= 0); + assert(halvingIndex > 0); + // zip208 // HalvingHeight(i) := max({ height ⦂ N | Halving(height) < i }) + 1 // diff --git a/depend/zcash/src/consensus/params.h b/depend/zcash/src/consensus/params.h index 9e13625ac..7e3ed68bd 100644 --- a/depend/zcash/src/consensus/params.h +++ b/depend/zcash/src/consensus/params.h @@ -169,7 +169,7 @@ struct Params { uint256 hashGenesisBlock; - bool fCoinbaseMustBeShielded; + bool fCoinbaseMustBeShielded = false; /** Needs to evenly divide MAX_SUBSIDY to avoid rounding errors. */ int nSubsidySlowStartInterval; diff --git a/depend/zcash/src/crypto/common.h b/depend/zcash/src/crypto/common.h index 002ef778a..381fd7f96 100644 --- a/depend/zcash/src/crypto/common.h +++ b/depend/zcash/src/crypto/common.h @@ -6,7 +6,7 @@ #define BITCOIN_CRYPTO_COMMON_H #if defined(HAVE_CONFIG_H) -#include "bitcoin-config.h" +#include "config/bitcoin-config.h" #endif #include diff --git a/depend/zcash/src/crypto/equihash.cpp b/depend/zcash/src/crypto/equihash.cpp index c7ea9ba58..bcd43c371 100644 --- a/depend/zcash/src/crypto/equihash.cpp +++ b/depend/zcash/src/crypto/equihash.cpp @@ -16,64 +16,61 @@ #include "config/bitcoin-config.h" #endif -#ifdef ENABLE_MINING - #include "compat/endian.h" #include "crypto/equihash.h" #include "util.h" -#include -#include #include -#include -static EhSolverCancelledException solver_cancelled; - -eh_HashState::eh_HashState( - size_t length, unsigned char personalization[BLAKE2bPersonalBytes]) +void eh_HashState::Update(const unsigned char *input, size_t inputLen) { - state = rust_blake2b_init(length, personalization); + blake2b_update(inner.get(), input, inputLen); } -eh_HashState::eh_HashState(const eh_HashState& baseState) +void eh_HashState::Finalize(unsigned char *hash, size_t hLen) { - state = rust_blake2b_clone(baseState.state); + blake2b_finalize(inner.get(), hash, hLen); } -eh_HashState::~eh_HashState() -{ - rust_blake2b_free(state); -} +// Used in TestEquihashValidator. -void eh_HashState::Update(const unsigned char *input, size_t inputLen) +void CompressArray(const unsigned char* in, size_t in_len, + unsigned char* out, size_t out_len, + size_t bit_len, size_t byte_pad) { - rust_blake2b_update(state, input, inputLen); -} + assert(bit_len >= 8); + assert(8*sizeof(uint32_t) >= 7+bit_len); -void eh_HashState::Finalize(unsigned char *hash, size_t hLen) -{ - rust_blake2b_finalize(state, hash, hLen); -} + size_t in_width { (bit_len+7)/8 + byte_pad }; + assert(out_len == bit_len*in_len/(8*in_width)); -template -void Equihash::InitialiseState(eh_HashState& base_state) -{ - uint32_t le_N = htole32(N); - uint32_t le_K = htole32(K); - unsigned char personalization[BLAKE2bPersonalBytes] = {}; - memcpy(personalization, "ZcashPoW", 8); - memcpy(personalization+8, &le_N, 4); - memcpy(personalization+12, &le_K, 4); - base_state = eh_HashState((512/N)*N/8, personalization); -} + uint32_t bit_len_mask { ((uint32_t)1 << bit_len) - 1 }; -void GenerateHash(const eh_HashState& base_state, eh_index g, - unsigned char* hash, size_t hLen) -{ - eh_HashState state(base_state); - eh_index lei = htole32(g); - state.Update((const unsigned char*) &lei, sizeof(eh_index)); - state.Finalize(hash, hLen); + // The acc_bits least-significant bits of acc_value represent a bit sequence + // in big-endian order. + size_t acc_bits = 0; + uint32_t acc_value = 0; + + size_t j = 0; + for (size_t i = 0; i < out_len; i++) { + // When we have fewer than 8 bits left in the accumulator, read the next + // input element. + if (acc_bits < 8) { + acc_value = acc_value << bit_len; + for (size_t x = byte_pad; x < in_width; x++) { + acc_value = acc_value | ( + ( + // Apply bit_len_mask across byte boundaries + in[j+x] & ((bit_len_mask >> (8*(in_width-x-1))) & 0xFF) + ) << (8*(in_width-x-1))); // Big-endian + } + j += in_width; + acc_bits += bit_len; + } + + acc_bits -= 8; + out[i] = (acc_value >> acc_bits) & 0xFF; + } } void ExpandArray(const unsigned char* in, size_t in_len, @@ -119,52 +116,62 @@ void ExpandArray(const unsigned char* in, size_t in_len, } } -void CompressArray(const unsigned char* in, size_t in_len, - unsigned char* out, size_t out_len, - size_t bit_len, size_t byte_pad) +// Big-endian so that lexicographic array comparison is equivalent to integer +// comparison +void EhIndexToArray(const eh_index i, unsigned char* array) { - assert(bit_len >= 8); - assert(8*sizeof(uint32_t) >= 7+bit_len); + BOOST_STATIC_ASSERT(sizeof(eh_index) == 4); + eh_index bei = htobe32(i); + memcpy(array, &bei, sizeof(eh_index)); +} - size_t in_width { (bit_len+7)/8 + byte_pad }; - assert(out_len == bit_len*in_len/(8*in_width)); +std::vector GetMinimalFromIndices(std::vector indices, + size_t cBitLen) +{ + assert(((cBitLen+1)+7)/8 <= sizeof(eh_index)); + size_t lenIndices { indices.size()*sizeof(eh_index) }; + size_t minLen { (cBitLen+1)*lenIndices/(8*sizeof(eh_index)) }; + size_t bytePad { sizeof(eh_index) - ((cBitLen+1)+7)/8 }; + std::vector array(lenIndices); + for (int i = 0; i < indices.size(); i++) { + EhIndexToArray(indices[i], array.data()+(i*sizeof(eh_index))); + } + std::vector ret(minLen); + CompressArray(array.data(), lenIndices, + ret.data(), minLen, cBitLen+1, bytePad); + return ret; +} - uint32_t bit_len_mask { ((uint32_t)1 << bit_len) - 1 }; +#ifdef ENABLE_MINING - // The acc_bits least-significant bits of acc_value represent a bit sequence - // in big-endian order. - size_t acc_bits = 0; - uint32_t acc_value = 0; - size_t j = 0; - for (size_t i = 0; i < out_len; i++) { - // When we have fewer than 8 bits left in the accumulator, read the next - // input element. - if (acc_bits < 8) { - acc_value = acc_value << bit_len; - for (size_t x = byte_pad; x < in_width; x++) { - acc_value = acc_value | ( - ( - // Apply bit_len_mask across byte boundaries - in[j+x] & ((bit_len_mask >> (8*(in_width-x-1))) & 0xFF) - ) << (8*(in_width-x-1))); // Big-endian - } - j += in_width; - acc_bits += bit_len; - } +#include +#include +#include - acc_bits -= 8; - out[i] = (acc_value >> acc_bits) & 0xFF; - } +#include + +static EhSolverCancelledException solver_cancelled; + +template +void Equihash::InitialiseState(eh_HashState& base_state) +{ + uint32_t le_N = htole32(N); + uint32_t le_K = htole32(K); + unsigned char personalization[BLAKE2bPersonalBytes] = {}; + memcpy(personalization, "ZcashPoW", 8); + memcpy(personalization+8, &le_N, 4); + memcpy(personalization+12, &le_K, 4); + base_state = eh_HashState((512/N)*N/8, personalization); } -// Big-endian so that lexicographic array comparison is equivalent to integer -// comparison -void EhIndexToArray(const eh_index i, unsigned char* array) +void GenerateHash(const eh_HashState& base_state, eh_index g, + unsigned char* hash, size_t hLen) { - BOOST_STATIC_ASSERT(sizeof(eh_index) == 4); - eh_index bei = htobe32(i); - memcpy(array, &bei, sizeof(eh_index)); + eh_HashState state(base_state); + eh_index lei = htole32(g); + state.Update((const unsigned char*) &lei, sizeof(eh_index)); + state.Finalize(hash, hLen); } // Big-endian so that lexicographic array comparison is equivalent to integer @@ -206,23 +213,6 @@ std::vector GetIndicesFromMinimal(std::vector minimal, return ret; } -std::vector GetMinimalFromIndices(std::vector indices, - size_t cBitLen) -{ - assert(((cBitLen+1)+7)/8 <= sizeof(eh_index)); - size_t lenIndices { indices.size()*sizeof(eh_index) }; - size_t minLen { (cBitLen+1)*lenIndices/(8*sizeof(eh_index)) }; - size_t bytePad { sizeof(eh_index) - ((cBitLen+1)+7)/8 }; - std::vector array(lenIndices); - for (int i = 0; i < indices.size(); i++) { - EhIndexToArray(indices[i], array.data()+(i*sizeof(eh_index))); - } - std::vector ret(minLen); - CompressArray(array.data(), lenIndices, - ret.data(), minLen, cBitLen+1, bytePad); - return ret; -} - template StepRow::StepRow(const unsigned char* hashIn, size_t hInLen, size_t hLen, size_t cBitLen) diff --git a/depend/zcash/src/crypto/equihash.h b/depend/zcash/src/crypto/equihash.h index 8be9f165a..8e30778a9 100644 --- a/depend/zcash/src/crypto/equihash.h +++ b/depend/zcash/src/crypto/equihash.h @@ -5,6 +5,28 @@ #ifndef BITCOIN_EQUIHASH_H #define BITCOIN_EQUIHASH_H + +#include +#include + +inline constexpr size_t equihash_solution_size(unsigned int N, unsigned int K) { + return (1 << K)*(N/(K+1)+1)/8; +} + +typedef uint32_t eh_index; +typedef uint8_t eh_trunc; + +std::vector GetMinimalFromIndices(std::vector indices, + size_t cBitLen); +void CompressArray(const unsigned char* in, size_t in_len, + unsigned char* out, size_t out_len, + size_t bit_len, size_t byte_pad=0); +void ExpandArray(const unsigned char* in, size_t in_len, + unsigned char* out, size_t out_len, + size_t bit_len, size_t byte_pad=0); +void EhIndexToArray(const eh_index i, unsigned char* array); + + #ifdef ENABLE_MINING #include "crypto/sha256.h" @@ -14,42 +36,44 @@ #include #include #include -#include #include -#include #include #include struct eh_HashState { - BLAKE2bState* state; + std::unique_ptr inner; + + eh_HashState() : inner(nullptr, blake2b_free) {} + + eh_HashState(size_t length, unsigned char personalization[BLAKE2bPersonalBytes]) : inner(blake2b_init(length, personalization), blake2b_free) {} - eh_HashState() {} - eh_HashState(size_t length, unsigned char personalization[BLAKE2bPersonalBytes]); - eh_HashState(const eh_HashState& baseState); - ~eh_HashState(); + eh_HashState(eh_HashState&& baseState) : inner(std::move(baseState.inner)) {} + eh_HashState(const eh_HashState& baseState) : inner(blake2b_clone(baseState.inner.get()), blake2b_free) {} + eh_HashState& operator=(eh_HashState&& baseState) + { + if (this != &baseState) { + inner = std::move(baseState.inner); + } + return *this; + } + eh_HashState& operator=(const eh_HashState& baseState) + { + if (this != &baseState) { + inner.reset(blake2b_clone(baseState.inner.get())); + } + return *this; + } void Update(const unsigned char *input, size_t inputLen); void Finalize(unsigned char *hash, size_t hLen); }; -typedef uint32_t eh_index; -typedef uint8_t eh_trunc; - -void ExpandArray(const unsigned char* in, size_t in_len, - unsigned char* out, size_t out_len, - size_t bit_len, size_t byte_pad=0); -void CompressArray(const unsigned char* in, size_t in_len, - unsigned char* out, size_t out_len, - size_t bit_len, size_t byte_pad=0); - eh_index ArrayToEhIndex(const unsigned char* array); eh_trunc TruncateIndex(const eh_index i, const unsigned int ilen); std::vector GetIndicesFromMinimal(std::vector minimal, size_t cBitLen); -std::vector GetMinimalFromIndices(std::vector indices, - size_t cBitLen); template class StepRow @@ -167,10 +191,6 @@ class EhSolverCancelledException : public std::exception inline constexpr const size_t max(const size_t A, const size_t B) { return A > B ? A : B; } -inline constexpr size_t equihash_solution_size(unsigned int N, unsigned int K) { - return (1 << K)*(N/(K+1)+1)/8; -} - template class Equihash { diff --git a/depend/zcash/src/deprecation.h b/depend/zcash/src/deprecation.h index 9561f2fe7..52203fcea 100644 --- a/depend/zcash/src/deprecation.h +++ b/depend/zcash/src/deprecation.h @@ -5,15 +5,20 @@ #ifndef ZCASH_DEPRECATION_H #define ZCASH_DEPRECATION_H +#include "consensus/params.h" // Deprecation policy: -// * Shut down 16 weeks' worth of blocks after the estimated release block height. -// * A warning is shown during the 2 weeks' worth of blocks prior to shut down. -static const int APPROX_RELEASE_HEIGHT = 902000; -static const int WEEKS_UNTIL_DEPRECATION = 16; -static const int DEPRECATION_HEIGHT = APPROX_RELEASE_HEIGHT + (WEEKS_UNTIL_DEPRECATION * 7 * 24 * 48); +// Per https://zips.z.cash/zip-0200 +// Shut down nodes running this version of code, 16 weeks' worth of blocks after the estimated +// release block height. A warning is shown during the 14 days' worth of blocks prior to shut down. +static const int APPROX_RELEASE_HEIGHT = 957287; +static const int RELEASE_TO_DEPRECATION_WEEKS = 16; +static const int EXPECTED_BLOCKS_PER_HOUR = 3600 / Consensus::POST_BLOSSOM_POW_TARGET_SPACING; +static_assert(EXPECTED_BLOCKS_PER_HOUR == 48, "The value of Consensus::POST_BLOSSOM_POW_TARGET_SPACING was chosen such that this assertion holds."); +static const int ACTIVATION_TO_DEPRECATION_BLOCKS = (RELEASE_TO_DEPRECATION_WEEKS * 7 * 24 * EXPECTED_BLOCKS_PER_HOUR); +static const int DEPRECATION_HEIGHT = APPROX_RELEASE_HEIGHT + ACTIVATION_TO_DEPRECATION_BLOCKS; // Number of blocks before deprecation to warn users -static const int DEPRECATION_WARN_LIMIT = 14 * 24 * 48; // 2 weeks +static const int DEPRECATION_WARN_LIMIT = 14 * 24 * EXPECTED_BLOCKS_PER_HOUR; /** * Checks whether the node is deprecated based on the current block height, and diff --git a/depend/zcash/src/fuzzing/CheckBlock/fuzz.cpp b/depend/zcash/src/fuzzing/CheckBlock/fuzz.cpp index 57ab7b4eb..4757ab4ca 100644 --- a/depend/zcash/src/fuzzing/CheckBlock/fuzz.cpp +++ b/depend/zcash/src/fuzzing/CheckBlock/fuzz.cpp @@ -2,11 +2,43 @@ #include "chainparams.h" #include "proof_verifier.h" -int main (int argc, char *argv[]) { +extern bool CheckBlock( + const CBlock& block, + CValidationState& state, + const CChainParams& chainparams, + libzcash::ProofVerifier& verifier, + bool fCheckPOW = true, + bool fCheckMerkleRoot = true); + +bool init_done = false; + +const CChainParams& chainparams = NULL; +auto verifier = libzcash::ProofVerifier::Strict(); + + +int fuzz_CheckBlock(CBlock block) { int retval = 0; - SelectParams(CBaseChainParams::MAIN); + if (!init_done) { + SelectParams(CBaseChainParams::MAIN); + chainparams = Params() + init_done = true; + } + + CValidationState state; + + // We don't check the PoW or Merkle tree root in order to reach more code. + + if (!CheckBlock(block, state, chainparams, verifier, false, false)) { + retval = -1; + } + + return retval; +} +#ifdef FUZZ_WITH_AFL + +int main (int argc, char *argv[]) { CBlock block; CAutoFile filein(fopen(argv[1], "rb"), SER_DISK, CLIENT_VERSION); try { @@ -14,17 +46,22 @@ int main (int argc, char *argv[]) { } catch (const std::exception& e) { return -1; } + return fuzz_CheckBlock(block); +} - // We don't load the SNARK parameters because it's too slow. This means that - // valid blocks with shielded transactions will generate a crash. +#endif // FUZZ_WITH_AFL +#ifdef FUZZ_WITH_LIBFUZZER - const CChainParams& chainparams = Params(); - auto verifier = ProofVerifier::Disabled(); - CValidationState state; - // We don't check the PoW or Merkle tree root in order to reach more code. - if (!CheckBlock(block, state, chainparams, verifier, false, false)) { - retval = -1; +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + CBlock block; + CDataStream ds((const char *)Data, (const char *)Data+Size, SER_NETWORK, PROTOCOL_VERSION); + try { + ds >> block; + } catch (const std::exception &e) { + return -1; } - - return retval; + fuzz_CheckBlock(block); + return 0; // Non-zero return values are reserved for future use. } + +#endif diff --git a/depend/zcash/src/fuzzing/DecodeHexTx/fuzz.cpp b/depend/zcash/src/fuzzing/DecodeHexTx/fuzz.cpp index 6e8f0e9f4..8cf74d503 100644 --- a/depend/zcash/src/fuzzing/DecodeHexTx/fuzz.cpp +++ b/depend/zcash/src/fuzzing/DecodeHexTx/fuzz.cpp @@ -1,10 +1,18 @@ +#include +#include + extern bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx); +// actual fuzzer + bool fuzz_DecodeHexTxFunction (const std::string& strHexTx) { CTransaction tx; return DecodeHexTx(tx, strHexTx); } +#ifdef FUZZ_WITH_AFL + +// AFL int fuzz_DecodeHexTx (int argc, char *argv[]) { std::ifstream t(argv[1]); @@ -15,3 +23,17 @@ int fuzz_DecodeHexTx (int argc, char *argv[]) { } int main (int argc, char *argv[]) { return fuzz_DecodeHexTx(argc, argv); } + +#endif +#ifdef FUZZ_WITH_LIBFUZZER + +// libfuzzer + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + std::string s; + s.assign((const char *)Data, Size); + fuzz_DecodeHexTxFunction (s); + return 0; // Non-zero return values are reserved for future use. +} + +#endif diff --git a/depend/zcash/src/fuzzing/DeserializeAddrMan/fuzz.cpp b/depend/zcash/src/fuzzing/DeserializeAddrMan/fuzz.cpp index 1b520efc8..2ffdec11d 100644 --- a/depend/zcash/src/fuzzing/DeserializeAddrMan/fuzz.cpp +++ b/depend/zcash/src/fuzzing/DeserializeAddrMan/fuzz.cpp @@ -1,6 +1,9 @@ #include "addrman.h" #include "streams.h" + +#ifdef FUZZ_WITH_AFL + int main (int argc, char *argv[]) { CAddrMan addrman; CAutoFile filein(fopen(argv[1], "rb"), SER_DISK, CLIENT_VERSION); @@ -11,3 +14,20 @@ int main (int argc, char *argv[]) { return -1; } } + +#endif + +#ifdef FUZZ_WITH_LIBFUZZER + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + CAddrMan addrman; + CDataStream ds(Data, Data+Size, SER_DISK, CLIENT_VERSION); + try { + ds >> addrman; + } catch (const std::exception &e) { + return 0; + } + return 0; // Non-zero return values are reserved for future use. +} + +#endif diff --git a/depend/zcash/src/fuzzing/DeserializeTx/fuzz.cpp b/depend/zcash/src/fuzzing/DeserializeTx/fuzz.cpp index 0eedf4be4..39b66228b 100644 --- a/depend/zcash/src/fuzzing/DeserializeTx/fuzz.cpp +++ b/depend/zcash/src/fuzzing/DeserializeTx/fuzz.cpp @@ -1,3 +1,7 @@ +#include + +// actual fuzzer + bool fuzz_TxDeserializeFunction (const std::vector txData) { CTransaction tx; CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); @@ -9,6 +13,9 @@ bool fuzz_TxDeserializeFunction (const std::vector txData) { } } +#ifdef FUZZ_WITH_AFL + +// AFL int fuzz_TxDeserialize (int argc, char *argv[]) { std::ifstream t(argv[1]); @@ -19,3 +26,18 @@ int fuzz_TxDeserialize (int argc, char *argv[]) { } int main (int argc, char *argv[]) { return fuzz_TxDeserialize(argc, argv); } + +#endif + +#ifdef FUZZ_WITH_LIBFUZZER + +// libFuzzer + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + std::vector vect(Size); + memcpy(vect.data(), Data, Size); + fuzz_TxDeserializeFunction(vect); + return 0; // Non-zero return values are reserved for future use. +} + +#endif diff --git a/depend/zcash/src/fuzzing/ReadFeeEstimates/fuzz.cpp b/depend/zcash/src/fuzzing/ReadFeeEstimates/fuzz.cpp index 1bdf2cf1d..e066fc792 100644 --- a/depend/zcash/src/fuzzing/ReadFeeEstimates/fuzz.cpp +++ b/depend/zcash/src/fuzzing/ReadFeeEstimates/fuzz.cpp @@ -1,5 +1,7 @@ #include "txmempool.h" +#ifdef FUZZ_WITH_AFL + int main (int argc, char *argv[]) { CFeeRate rate; CTxMemPool mempool(rate); @@ -11,3 +13,22 @@ int main (int argc, char *argv[]) { return -1; } } + +#endif + +#ifdef FUZZ_WITH_LIBFUZZER + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + CFeeRate rate; + CTxMemPool mempool(rate); + CAutoFile est_filein(fmemopen(Data, Size, "rb"), SER_DISK, CLIENT_VERSION); + + if (mempool.ReadFeeEstimates(est_filein)) { + return 0; + } else { + return -1; + } +} + + +#endif diff --git a/depend/zcash/src/fuzzing/UniValue__Read/dict b/depend/zcash/src/fuzzing/UniValue__Read/dict new file mode 100644 index 000000000..bbf7ec5df --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/dict @@ -0,0 +1,7 @@ +kw1="{" +kw2="}" +kw5="[" +kw6="]" +kw7=":" +kw8="," +kw9="\"" diff --git a/depend/zcash/src/fuzzing/UniValue__Read/fuzz.cpp b/depend/zcash/src/fuzzing/UniValue__Read/fuzz.cpp new file mode 100644 index 000000000..90409b147 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/fuzz.cpp @@ -0,0 +1,29 @@ +#include "univalue.h" + +int fuzz_UniValue_Read(std::string notquitejson) { + UniValue valRequest; + if (!valRequest.read(notquitejson)) { + return -1; + } + return 0; +} + +#ifdef FUZZ_WITH_AFL + +#error "The AFL version of this fuzzer has not yet been implemented." + +int main (int argc, char *argv[]) { + // not implemented + return 0; +} + +#endif // FUZZ_WITH_AFL +#ifdef FUZZ_WITH_LIBFUZZER + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + std::string s; + s.assign((const char *)Data, Size); + return fuzz_UniValue_Read(s); +} + +#endif diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail1.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail1.json new file mode 100644 index 000000000..8feb01a6d --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail1.json @@ -0,0 +1 @@ +"This is a string that never ends, yes it goes on and on, my friends. diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail10.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail10.json new file mode 100644 index 000000000..5d8c0047b --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail10.json @@ -0,0 +1 @@ +{"Extra value after close": true} "misplaced quoted value" \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail11.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail11.json new file mode 100644 index 000000000..76eb95b45 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail11.json @@ -0,0 +1 @@ +{"Illegal expression": 1 + 2} \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail12.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail12.json new file mode 100644 index 000000000..77580a452 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail12.json @@ -0,0 +1 @@ +{"Illegal invocation": alert()} \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail13.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail13.json new file mode 100644 index 000000000..379406b59 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail13.json @@ -0,0 +1 @@ +{"Numbers cannot have leading zeroes": 013} \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail14.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail14.json new file mode 100644 index 000000000..0ed366b38 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail14.json @@ -0,0 +1 @@ +{"Numbers cannot be hex": 0x14} \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail15.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail15.json new file mode 100644 index 000000000..fc8376b60 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail15.json @@ -0,0 +1 @@ +["Illegal backslash escape: \x15"] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail16.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail16.json new file mode 100644 index 000000000..3fe21d4b5 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail16.json @@ -0,0 +1 @@ +[\naked] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail17.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail17.json new file mode 100644 index 000000000..62b9214ae --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail17.json @@ -0,0 +1 @@ +["Illegal backslash escape: \017"] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail18.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail18.json new file mode 100644 index 000000000..edac92716 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail18.json @@ -0,0 +1 @@ +[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail19.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail19.json new file mode 100644 index 000000000..3b9c46fa9 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail19.json @@ -0,0 +1 @@ +{"Missing colon" null} \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail2.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail2.json new file mode 100644 index 000000000..6b7c11e5a --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail2.json @@ -0,0 +1 @@ +["Unclosed array" \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail20.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail20.json new file mode 100644 index 000000000..27c1af3e7 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail20.json @@ -0,0 +1 @@ +{"Double colon":: null} \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail21.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail21.json new file mode 100644 index 000000000..62474573b --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail21.json @@ -0,0 +1 @@ +{"Comma instead of colon", null} \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail22.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail22.json new file mode 100644 index 000000000..a7752581b --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail22.json @@ -0,0 +1 @@ +["Colon instead of comma": false] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail23.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail23.json new file mode 100644 index 000000000..494add1ca --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail23.json @@ -0,0 +1 @@ +["Bad value", truth] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail24.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail24.json new file mode 100644 index 000000000..caff239bf --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail24.json @@ -0,0 +1 @@ +['single quote'] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail25.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail25.json new file mode 100644 index 000000000..8b7ad23e0 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail25.json @@ -0,0 +1 @@ +[" tab character in string "] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail26.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail26.json new file mode 100644 index 000000000..845d26a6a --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail26.json @@ -0,0 +1 @@ +["tab\ character\ in\ string\ "] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail27.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail27.json new file mode 100644 index 000000000..6b01a2ca4 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail27.json @@ -0,0 +1,2 @@ +["line +break"] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail28.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail28.json new file mode 100644 index 000000000..621a0101c --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail28.json @@ -0,0 +1,2 @@ +["line\ +break"] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail29.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail29.json new file mode 100644 index 000000000..47ec421bb --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail29.json @@ -0,0 +1 @@ +[0e] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail3.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail3.json new file mode 100644 index 000000000..168c81eb7 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail3.json @@ -0,0 +1 @@ +{unquoted_key: "keys must be quoted"} \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail30.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail30.json new file mode 100644 index 000000000..8ab0bc4b8 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail30.json @@ -0,0 +1 @@ +[0e+] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail31.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail31.json new file mode 100644 index 000000000..1cce602b5 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail31.json @@ -0,0 +1 @@ +[0e+-1] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail32.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail32.json new file mode 100644 index 000000000..45cba7396 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail32.json @@ -0,0 +1 @@ +{"Comma instead if closing brace": true, \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail33.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail33.json new file mode 100644 index 000000000..ca5eb19dc --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail33.json @@ -0,0 +1 @@ +["mismatch"} \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail34.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail34.json new file mode 100644 index 000000000..3f8be1728 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail34.json @@ -0,0 +1 @@ +{} garbage \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail35.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail35.json new file mode 100644 index 000000000..de30ca5c4 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail35.json @@ -0,0 +1 @@ +[ true true true [] [] [] ] diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail36.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail36.json new file mode 100644 index 000000000..f82eb8e1f --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail36.json @@ -0,0 +1 @@ +{"a":} diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail37.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail37.json new file mode 100644 index 000000000..3294dc3a4 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail37.json @@ -0,0 +1 @@ +{"a":1 "b":2} diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail38.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail38.json new file mode 100644 index 000000000..b245e2e46 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail38.json @@ -0,0 +1 @@ +["\ud834"] diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail39.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail39.json new file mode 100644 index 000000000..7c9e263f2 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail39.json @@ -0,0 +1 @@ +["\udd61"] diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail4.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail4.json new file mode 100644 index 000000000..9de168bf3 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail4.json @@ -0,0 +1 @@ +["extra comma",] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail40.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail40.json new file mode 100644 index 000000000..664dc9e24 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail40.json @@ -0,0 +1 @@ +["…¡"] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail41.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail41.json new file mode 100644 index 000000000..0de342a2b --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail41.json @@ -0,0 +1 @@ +["ð…"] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail42.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail42.json new file mode 100644 index 000000000..9c7565adb Binary files /dev/null and b/depend/zcash/src/fuzzing/UniValue__Read/input/fail42.json differ diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail5.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail5.json new file mode 100644 index 000000000..ddf3ce3d2 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail5.json @@ -0,0 +1 @@ +["double extra comma",,] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail6.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail6.json new file mode 100644 index 000000000..ed91580e1 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail6.json @@ -0,0 +1 @@ +[ , "<-- missing value"] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail7.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail7.json new file mode 100644 index 000000000..8a96af3e4 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail7.json @@ -0,0 +1 @@ +["Comma after the close"], \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail8.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail8.json new file mode 100644 index 000000000..b28479c6e --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail8.json @@ -0,0 +1 @@ +["Extra close"]] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/fail9.json b/depend/zcash/src/fuzzing/UniValue__Read/input/fail9.json new file mode 100644 index 000000000..5815574f3 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/fail9.json @@ -0,0 +1 @@ +{"Extra comma": true,} \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/pass1.json b/depend/zcash/src/fuzzing/UniValue__Read/input/pass1.json new file mode 100644 index 000000000..70e268543 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/pass1.json @@ -0,0 +1,58 @@ +[ + "JSON Test Pattern pass1", + {"object with 1 member":["array with 1 element"]}, + {}, + [], + -42, + true, + false, + null, + { + "integer": 1234567890, + "real": -9876.543210, + "e": 0.123456789e-12, + "E": 1.234567890E+34, + "": 23456789012E66, + "zero": 0, + "one": 1, + "space": " ", + "quote": "\"", + "backslash": "\\", + "controls": "\b\f\n\r\t", + "slash": "/ & \/", + "alpha": "abcdefghijklmnopqrstuvwyz", + "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ", + "digit": "0123456789", + "0123456789": "digit", + "special": "`1~!@#$%^&*()_+-={':[,]}|;.?", + "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A", + "true": true, + "false": false, + "null": null, + "array":[ ], + "object":{ }, + "address": "50 St. James Street", + "url": "http://www.JSON.org/", + "comment": "// /* */": " ", + " s p a c e d " :[1,2 , 3 + +, + +4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7], + "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}", + "quotes": "" \u0022 %22 0x22 034 "", + "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" +: "A key can be any string" + }, + 0.5 ,98.6 +, +99.44 +, + +1066, +1e1, +0.1e1, +1e-1, +1e00,2e+00,2e-00 +,"rosebud"] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/pass2.json b/depend/zcash/src/fuzzing/UniValue__Read/input/pass2.json new file mode 100644 index 000000000..d3c63c7ad --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/pass2.json @@ -0,0 +1 @@ +[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] \ No newline at end of file diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/pass3.json b/depend/zcash/src/fuzzing/UniValue__Read/input/pass3.json new file mode 100644 index 000000000..4528d51f1 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/pass3.json @@ -0,0 +1,6 @@ +{ + "JSON Test Pattern pass3": { + "The outermost value": "must be an object or array.", + "In this test": "It is an object." + } +} diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/round1.json b/depend/zcash/src/fuzzing/UniValue__Read/input/round1.json new file mode 100644 index 000000000..a711e7308 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/round1.json @@ -0,0 +1 @@ +["\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007f"] diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/round2.json b/depend/zcash/src/fuzzing/UniValue__Read/input/round2.json new file mode 100644 index 000000000..b766cccc6 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/round2.json @@ -0,0 +1 @@ +["a§■ðŽ’ð…¡"] diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/round3.json b/depend/zcash/src/fuzzing/UniValue__Read/input/round3.json new file mode 100644 index 000000000..7182dc2f9 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/round3.json @@ -0,0 +1 @@ +"abcdefghijklmnopqrstuvwxyz" diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/round4.json b/depend/zcash/src/fuzzing/UniValue__Read/input/round4.json new file mode 100644 index 000000000..7f8f011eb --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/round4.json @@ -0,0 +1 @@ +7 diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/round5.json b/depend/zcash/src/fuzzing/UniValue__Read/input/round5.json new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/round5.json @@ -0,0 +1 @@ +true diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/round6.json b/depend/zcash/src/fuzzing/UniValue__Read/input/round6.json new file mode 100644 index 000000000..c508d5366 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/round6.json @@ -0,0 +1 @@ +false diff --git a/depend/zcash/src/fuzzing/UniValue__Read/input/round7.json b/depend/zcash/src/fuzzing/UniValue__Read/input/round7.json new file mode 100644 index 000000000..19765bd50 --- /dev/null +++ b/depend/zcash/src/fuzzing/UniValue__Read/input/round7.json @@ -0,0 +1 @@ +null diff --git a/depend/zcash/src/gtest/main.cpp b/depend/zcash/src/gtest/main.cpp index 5c6230e3f..3a2771b7a 100644 --- a/depend/zcash/src/gtest/main.cpp +++ b/depend/zcash/src/gtest/main.cpp @@ -31,13 +31,10 @@ int main(int argc, char **argv) { librustzcash_init_zksnark_params( reinterpret_cast(sapling_spend_str.c_str()), sapling_spend_str.length(), - "8270785a1a0d0bc77196f000ee6d221c9c9894f55307bd9357c3f0105d31ca63991ab91324160d8f53e2bbd3c2633a6eb8bdf5205d822e7f3f73edac51b2b70c", reinterpret_cast(sapling_output_str.c_str()), sapling_output_str.length(), - "657e3d38dbb5cb5e7dd2970e8b03d69b4787dd907285b5a7f0790dcc8072f60bf593b32cc2d1c030e00ff5ae64bf84c5c3beb84ddc841d48264b4a171744d028", reinterpret_cast(sprout_groth16_str.c_str()), - sprout_groth16_str.length(), - "e9b238411bd6c0ec4791e9d04245ec350c9c5744f5610dfcce4365d5ca49dfefd5054e371842b3f88fa1b9d7e8e075249b3ebabd167fa8b0f3161292d36c180a" + sprout_groth16_str.length() ); testing::InitGoogleMock(&argc, argv); diff --git a/depend/zcash/src/gtest/test_allocator.cpp b/depend/zcash/src/gtest/test_allocator.cpp new file mode 100644 index 000000000..00ad41581 --- /dev/null +++ b/depend/zcash/src/gtest/test_allocator.cpp @@ -0,0 +1,22 @@ +#include + +#include "support/allocators/secure.h" + +TEST(AllocatorTests, LockedPoolAbortOnDoubleFree) { + LockedPoolManager &pool = LockedPoolManager::Instance(); + + // We should be able to allocate and free memory. + void *a0 = pool.alloc(16); + pool.free(a0); + + // Process terminates on double-free. + EXPECT_DEATH(pool.free(a0), "Arena: invalid or double free"); +} + +TEST(AllocatorTests, LockedPoolAbortOnFreeInvalidPointer) { + LockedPoolManager &pool = LockedPoolManager::Instance(); + bool notInPool = false; + + // Process terminates if we try to free memory that wasn't allocated by the pool. + EXPECT_DEATH(pool.free(¬InPool), "LockedPool: invalid address not pointing to any arena"); +} diff --git a/depend/zcash/src/gtest/test_block.cpp b/depend/zcash/src/gtest/test_block.cpp index 302c5882c..24dea8c3d 100644 --- a/depend/zcash/src/gtest/test_block.cpp +++ b/depend/zcash/src/gtest/test_block.cpp @@ -1,6 +1,8 @@ #include #include "primitives/block.h" +#include "streams.h" +#include "version.h" TEST(BlockTests, HeaderSizeIsExpected) { diff --git a/depend/zcash/src/gtest/test_checkblock.cpp b/depend/zcash/src/gtest/test_checkblock.cpp index 8f60c575c..b92f9ca76 100644 --- a/depend/zcash/src/gtest/test_checkblock.cpp +++ b/depend/zcash/src/gtest/test_checkblock.cpp @@ -32,7 +32,7 @@ TEST(CheckBlock, VersionTooLow) { MockCValidationState state; EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "version-too-low", false)).Times(1); - EXPECT_FALSE(CheckBlock(block, state, Params(), verifier, false, false)); + EXPECT_FALSE(CheckBlock(block, state, Params(), verifier, false, false, true)); } @@ -65,7 +65,7 @@ TEST(CheckBlock, BlockSproutRejectsBadVersion) { auto verifier = ProofVerifier::Strict(); EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-version-too-low", false)).Times(1); - EXPECT_FALSE(CheckBlock(block, state, Params(), verifier, false, false)); + EXPECT_FALSE(CheckBlock(block, state, Params(), verifier, false, false, true)); } @@ -119,7 +119,7 @@ class ContextualCheckBlockTest : public ::testing::Test { // We now expect this to be a valid block. MockCValidationState state; - EXPECT_TRUE(ContextualCheckBlock(block, state, Params(), &indexPrev)); + EXPECT_TRUE(ContextualCheckBlock(block, state, Params(), &indexPrev, true)); } // Expects a height-1 block containing a given transaction to fail @@ -137,7 +137,7 @@ class ContextualCheckBlockTest : public ::testing::Test { // We now expect this to be an invalid block, for the given reason. MockCValidationState state; EXPECT_CALL(state, DoS(level, false, REJECT_INVALID, reason, false)).Times(1); - EXPECT_FALSE(ContextualCheckBlock(block, state, Params(), &indexPrev)); + EXPECT_FALSE(ContextualCheckBlock(block, state, Params(), &indexPrev, true)); } }; @@ -154,7 +154,7 @@ TEST_F(ContextualCheckBlockTest, BadCoinbaseHeight) { // Treating block as genesis should pass MockCValidationState state; - EXPECT_TRUE(ContextualCheckBlock(block, state, Params(), NULL)); + EXPECT_TRUE(ContextualCheckBlock(block, state, Params(), NULL, true)); // Give the transaction a Founder's Reward vout mtx.vout.push_back(CTxOut( @@ -168,20 +168,20 @@ TEST_F(ContextualCheckBlockTest, BadCoinbaseHeight) { CBlockIndex indexPrev {prev}; indexPrev.nHeight = 0; EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-cb-height", false)).Times(1); - EXPECT_FALSE(ContextualCheckBlock(block, state, Params(), &indexPrev)); + EXPECT_FALSE(ContextualCheckBlock(block, state, Params(), &indexPrev, true)); // Setting to an incorrect height should fail mtx.vin[0].scriptSig = CScript() << 2 << OP_0; CTransaction tx3 {mtx}; block.vtx[0] = tx3; EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-cb-height", false)).Times(1); - EXPECT_FALSE(ContextualCheckBlock(block, state, Params(), &indexPrev)); + EXPECT_FALSE(ContextualCheckBlock(block, state, Params(), &indexPrev, true)); // After correcting the scriptSig, should pass mtx.vin[0].scriptSig = CScript() << 1 << OP_0; CTransaction tx4 {mtx}; block.vtx[0] = tx4; - EXPECT_TRUE(ContextualCheckBlock(block, state, Params(), &indexPrev)); + EXPECT_TRUE(ContextualCheckBlock(block, state, Params(), &indexPrev, true)); } // TEST PLAN: first, check that each ruleset accepts its own transaction type. @@ -311,7 +311,7 @@ TEST_F(ContextualCheckBlockTest, BlockOverwinterRulesRejectOtherTx) { { SCOPED_TRACE("BlockOverwinterRulesRejectSproutTx"); - ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "tx-overwinter-active"); + ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "tx-overwintered-flag-not-set"); } // Make it a Sapling transaction @@ -321,7 +321,7 @@ TEST_F(ContextualCheckBlockTest, BlockOverwinterRulesRejectOtherTx) { { SCOPED_TRACE("BlockOverwinterRulesRejectSaplingTx"); - ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "bad-overwinter-tx-version-group-id"); + ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "bad-tx-overwinter-version-too-high"); } } @@ -339,7 +339,7 @@ TEST_F(ContextualCheckBlockTest, BlockSaplingRulesRejectOtherTx) { { SCOPED_TRACE("BlockSaplingRulesRejectSproutTx"); - ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "tx-overwinter-active"); + ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "tx-overwintered-flag-not-set"); } // Make it an Overwinter transaction @@ -368,7 +368,7 @@ TEST_F(ContextualCheckBlockTest, BlockBlossomRulesRejectOtherTx) { { SCOPED_TRACE("BlockBlossomRulesRejectSproutTx"); - ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "tx-overwinter-active"); + ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "tx-overwintered-flag-not-set"); } // Make it an Overwinter transaction diff --git a/depend/zcash/src/gtest/test_checktransaction.cpp b/depend/zcash/src/gtest/test_checktransaction.cpp index 1e2338be9..a9b802ba9 100644 --- a/depend/zcash/src/gtest/test_checktransaction.cpp +++ b/depend/zcash/src/gtest/test_checktransaction.cpp @@ -1,6 +1,5 @@ #include #include -#include #include "main.h" #include "primitives/transaction.h" @@ -10,6 +9,7 @@ #include "zcash/JoinSplit.hpp" #include +#include TEST(ChecktransactionTests, CheckVpubNotBothNonzero) { CMutableTransaction tx; @@ -71,7 +71,7 @@ CMutableTransaction GetValidTransaction(uint32_t consensusBranchId=SPROUT_BRANCH mtx.vin[1].prevout.hash = uint256S("0000000000000000000000000000000000000000000000000000000000000002"); mtx.vin[1].prevout.n = 0; mtx.vout.resize(2); - // mtx.vout[0].scriptPubKey = + // mtx.vout[0].scriptPubKey = mtx.vout[0].nValue = 0; mtx.vout[1].nValue = 0; mtx.vJoinSplit.resize(2); @@ -92,10 +92,8 @@ CMutableTransaction GetValidTransaction(uint32_t consensusBranchId=SPROUT_BRANCH void CreateJoinSplitSignature(CMutableTransaction& mtx, uint32_t consensusBranchId) { // Generate an ephemeral keypair. - uint256 joinSplitPubKey; - unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES]; - crypto_sign_keypair(joinSplitPubKey.begin(), joinSplitPrivKey); - mtx.joinSplitPubKey = joinSplitPubKey; + Ed25519SigningKey joinSplitPrivKey; + ed25519_generate_keypair(&joinSplitPrivKey, &mtx.joinSplitPubKey); // Compute the correct hSig. // TODO: #966. @@ -109,10 +107,10 @@ void CreateJoinSplitSignature(CMutableTransaction& mtx, uint32_t consensusBranch } // Add the signature - assert(crypto_sign_detached(&mtx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey - ) == 0); + assert(ed25519_sign( + &joinSplitPrivKey, + dataToBeSigned.begin(), 32, + &mtx.joinSplitSig)); } TEST(ChecktransactionTests, ValidTransaction) { @@ -518,7 +516,7 @@ TEST(ChecktransactionTests, BadTxnsInvalidJoinsplitSignature) { auto chainparams = Params(); CMutableTransaction mtx = GetValidTransaction(); - mtx.joinSplitSig[0] += 1; + mtx.joinSplitSig.bytes[0] += 1; CTransaction tx(mtx); MockCValidationState state; @@ -607,8 +605,8 @@ TEST(ChecktransactionTests, NonCanonicalEd25519Signature) { // Add L to S, which starts at mtx.joinSplitSig[32]. unsigned int s = 0; for (size_t i = 0; i < 32; i++) { - s = mtx.joinSplitSig[32 + i] + L[i] + (s >> 8); - mtx.joinSplitSig[32 + i] = s & 0xff; + s = mtx.joinSplitSig.bytes[32 + i] + L[i] + (s >> 8); + mtx.joinSplitSig.bytes[32 + i] = s & 0xff; } CTransaction tx(mtx); @@ -816,7 +814,7 @@ TEST(ChecktransactionTests, SaplingSproutInputSumsTooLarge) { { // create JSDescription uint256 rt; - uint256 joinSplitPubKey; + Ed25519VerificationKey joinSplitPubKey; std::array inputs = { libzcash::JSInput(), libzcash::JSInput() @@ -951,7 +949,7 @@ TEST(ChecktransactionTests, OverwinterFlagNotSet) { CTransaction tx(mtx); MockCValidationState state; - EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "tx-overwinter-flag-not-set", false)).Times(1); + EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "tx-overwintered-flag-not-set", false)).Times(1); ContextualCheckTransaction(tx, state, Params(), 1, true); // Revert to default diff --git a/depend/zcash/src/gtest/test_consensus.cpp b/depend/zcash/src/gtest/test_consensus.cpp index 2484a1dfb..505db7d9d 100644 --- a/depend/zcash/src/gtest/test_consensus.cpp +++ b/depend/zcash/src/gtest/test_consensus.cpp @@ -167,7 +167,13 @@ TEST(ConsensusTests, ZIP215TestVectors) { ); ZIP215Check( "0100000000000000000000000000000000000000000000000000000000000000", - "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "0100000000000000000000000000000000000000000000000000000000000000", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", false, true ); @@ -245,8 +251,14 @@ TEST(ConsensusTests, ZIP215TestVectors) { ); ZIP215Check( "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a", - "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", - true, + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", + false, true ); ZIP215Check( @@ -323,7 +335,13 @@ TEST(ConsensusTests, ZIP215TestVectors) { ); ZIP215Check( "0000000000000000000000000000000000000000000000000000000000000080", - "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "0000000000000000000000000000000000000000000000000000000000000080", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", false, true ); @@ -401,7 +419,13 @@ TEST(ConsensusTests, ZIP215TestVectors) { ); ZIP215Check( "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05", - "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", false, true ); @@ -479,7 +503,13 @@ TEST(ConsensusTests, ZIP215TestVectors) { ); ZIP215Check( "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", - "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", false, true ); @@ -557,7 +587,13 @@ TEST(ConsensusTests, ZIP215TestVectors) { ); ZIP215Check( "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85", - "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", false, true ); @@ -635,7 +671,13 @@ TEST(ConsensusTests, ZIP215TestVectors) { ); ZIP215Check( "0000000000000000000000000000000000000000000000000000000000000000", - "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "0000000000000000000000000000000000000000000000000000000000000000", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", false, true ); @@ -713,7 +755,13 @@ TEST(ConsensusTests, ZIP215TestVectors) { ); ZIP215Check( "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa", - "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", false, true ); @@ -742,79 +790,169 @@ TEST(ConsensusTests, ZIP215TestVectors) { true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "0100000000000000000000000000000000000000000000000000000000000080", "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", false, true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "0100000000000000000000000000000000000000000000000000000000000080", "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a0000000000000000000000000000000000000000000000000000000000000000", false, true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "0100000000000000000000000000000000000000000000000000000000000080", "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", false, true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "0100000000000000000000000000000000000000000000000000000000000080", "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc050000000000000000000000000000000000000000000000000000000000000000", false, true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "0100000000000000000000000000000000000000000000000000000000000080", "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000", false, true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "0100000000000000000000000000000000000000000000000000000000000080", "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc850000000000000000000000000000000000000000000000000000000000000000", false, true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "0100000000000000000000000000000000000000000000000000000000000080", "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", false, true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "0100000000000000000000000000000000000000000000000000000000000080", "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa0000000000000000000000000000000000000000000000000000000000000000", false, true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "0100000000000000000000000000000000000000000000000000000000000080", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "0100000000000000000000000000000000000000000000000000000000000080", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "0100000000000000000000000000000000000000000000000000000000000080", + "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "0100000000000000000000000000000000000000000000000000000000000080", + "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "0100000000000000000000000000000000000000000000000000000000000080", + "eeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "0100000000000000000000000000000000000000000000000000000000000080", + "eeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a0000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", false, true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc050000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc850000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa0000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000", false, true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", false, true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "eeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000", false, true ); ZIP215Check( - "0000000000000000000000000000000000000000000000000000000000000080", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "eeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", false, true @@ -869,7 +1007,13 @@ TEST(ConsensusTests, ZIP215TestVectors) { ); ZIP215Check( "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", - "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", false, true ); @@ -909,7 +1053,6 @@ TEST(ConsensusTests, ZIP215TestVectors) { false, true ); - // This test vector was duplicated in the test vectors originally provided by Henry. ZIP215Check( "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", @@ -946,6 +1089,18 @@ TEST(ConsensusTests, ZIP215TestVectors) { false, true ); + ZIP215Check( + "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); ZIP215Check( "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000", @@ -1020,7 +1175,13 @@ TEST(ConsensusTests, ZIP215TestVectors) { ); ZIP215Check( "eeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", - "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "eeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", false, true ); @@ -1098,7 +1259,13 @@ TEST(ConsensusTests, ZIP215TestVectors) { ); ZIP215Check( "eeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + "01000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", + false, + true + ); + ZIP215Check( + "eeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000", false, true ); diff --git a/depend/zcash/src/gtest/test_deprecation.cpp b/depend/zcash/src/gtest/test_deprecation.cpp index ee24e9c94..badd29956 100644 --- a/depend/zcash/src/gtest/test_deprecation.cpp +++ b/depend/zcash/src/gtest/test_deprecation.cpp @@ -12,6 +12,7 @@ #include #include +using namespace boost::placeholders; using ::testing::StrictMock; static const std::string CLIENT_VERSION_STR = FormatVersion(CLIENT_VERSION); diff --git a/depend/zcash/src/gtest/test_equihash.cpp b/depend/zcash/src/gtest/test_equihash.cpp index 647e6511d..c4e0320af 100644 --- a/depend/zcash/src/gtest/test_equihash.cpp +++ b/depend/zcash/src/gtest/test_equihash.cpp @@ -7,6 +7,7 @@ #include "crypto/equihash.h" #include "uint256.h" +#include "utilstrencodings.h" void TestExpandAndCompress(const std::string &scope, size_t bit_len, size_t byte_pad, std::vector compact, @@ -50,7 +51,9 @@ void TestMinimalSolnRepr(const std::string &scope, size_t cBitLen, { SCOPED_TRACE(scope); +#if ENABLE_MINING EXPECT_EQ(indices, GetIndicesFromMinimal(minimal, cBitLen)); +#endif EXPECT_EQ(minimal, GetMinimalFromIndices(indices, cBitLen)); } @@ -70,6 +73,7 @@ TEST(EquihashTests, MinimalSolutionRepresentation) { ParseHex("000220000a7ffffe004d10014c800ffc00002fffff")); } +#if ENABLE_MINING TEST(EquihashTests, IsProbablyDuplicate) { std::shared_ptr p1 (new eh_trunc[4] {0, 1, 2, 3}, std::default_delete()); std::shared_ptr p2 (new eh_trunc[4] {0, 1, 1, 3}, std::default_delete()); @@ -80,7 +84,6 @@ TEST(EquihashTests, IsProbablyDuplicate) { ASSERT_TRUE(IsProbablyDuplicate<4>(p3, 4)); } -#ifdef ENABLE_MINING TEST(EquihashTests, CheckBasicSolverCancelled) { Equihash<48,5> Eh48_5; eh_HashState state; diff --git a/depend/zcash/src/gtest/test_foundersreward.cpp b/depend/zcash/src/gtest/test_foundersreward.cpp index 498b15fbd..c0915c6c7 100644 --- a/depend/zcash/src/gtest/test_foundersreward.cpp +++ b/depend/zcash/src/gtest/test_foundersreward.cpp @@ -150,7 +150,7 @@ TEST(FoundersRewardTest, RegtestGetLastBlockBlossom) { TEST(FoundersRewardTest, MainnetGetLastBlock) { SelectParams(CBaseChainParams::MAIN); - auto params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(); int lastFRHeight = GetLastFoundersRewardHeight(params); EXPECT_EQ(0, params.Halving(lastFRHeight)); EXPECT_EQ(1, params.Halving(lastFRHeight + 1)); diff --git a/depend/zcash/src/gtest/test_history.cpp b/depend/zcash/src/gtest/test_history.cpp index b271ecef8..9ea5bf427 100644 --- a/depend/zcash/src/gtest/test_history.cpp +++ b/depend/zcash/src/gtest/test_history.cpp @@ -169,3 +169,37 @@ TEST(History, EpochBoundaries) { EXPECT_EQ(view.GetHistoryLength(2), 0); } + +TEST(History, GarbageMemoryHash) { + const auto consensusBranchId = NetworkUpgradeInfo[Consensus::UPGRADE_HEARTWOOD].nBranchId; + + FakeCoinsViewDB fakeDB; + CCoinsViewCache view(&fakeDB); + + // Hash two history nodes + HistoryNode node0 = getLeafN(1); + HistoryNode node1 = getLeafN(2); + + view.PushHistoryNode(consensusBranchId, node0); + view.PushHistoryNode(consensusBranchId, node1); + + uint256 historyRoot = view.GetHistoryRoot(consensusBranchId); + + // Change garbage memory and re-hash nodes + FakeCoinsViewDB fakeDBGarbage; + CCoinsViewCache viewGarbage(&fakeDBGarbage); + + HistoryNode node0Garbage = getLeafN(1); + HistoryNode node1Garbage = getLeafN(2); + + node0Garbage.bytes[NODE_SERIALIZED_LENGTH - 1] = node0.bytes[NODE_SERIALIZED_LENGTH - 1] ^ 1; + node1Garbage.bytes[NODE_SERIALIZED_LENGTH - 1] = node1.bytes[NODE_SERIALIZED_LENGTH - 1] ^ 1; + + viewGarbage.PushHistoryNode(consensusBranchId, node0Garbage); + viewGarbage.PushHistoryNode(consensusBranchId, node1Garbage); + + uint256 historyRootGarbage = viewGarbage.GetHistoryRoot(consensusBranchId); + + // Check history root and garbage history root are equal + EXPECT_EQ(historyRoot, historyRootGarbage); +} diff --git a/depend/zcash/src/gtest/test_joinsplit.cpp b/depend/zcash/src/gtest/test_joinsplit.cpp index 1d629e768..a62a35430 100644 --- a/depend/zcash/src/gtest/test_joinsplit.cpp +++ b/depend/zcash/src/gtest/test_joinsplit.cpp @@ -19,6 +19,8 @@ #include +#include + using namespace libzcash; // Make the Groth proof for a Sprout statement, @@ -26,7 +28,7 @@ using namespace libzcash; JSDescription makeSproutProof( const std::array& inputs, const std::array& outputs, - const uint256& joinSplitPubKey, + const Ed25519VerificationKey& joinSplitPubKey, uint64_t vpub_old, uint64_t vpub_new, const uint256& rt @@ -36,7 +38,7 @@ JSDescription makeSproutProof( bool verifySproutProof( const JSDescription& jsdesc, - const uint256& joinSplitPubKey + const Ed25519VerificationKey& joinSplitPubKey ) { auto verifier = ProofVerifier::Strict(); @@ -59,7 +61,8 @@ void test_full_api() // Set up a JoinSplit description uint64_t vpub_old = 10; uint64_t vpub_new = 0; - uint256 joinSplitPubKey = random_uint256(); + Ed25519VerificationKey joinSplitPubKey; + GetRandBytes(joinSplitPubKey.bytes, ED25519_VERIFICATION_KEY_LEN); uint256 rt = tree.root(); JSDescription jsdesc; @@ -118,7 +121,8 @@ void test_full_api() vpub_old = 0; vpub_new = 1; rt = tree.root(); - auto joinSplitPubKey2 = random_uint256(); + Ed25519VerificationKey joinSplitPubKey2; + GetRandBytes(joinSplitPubKey2.bytes, ED25519_VERIFICATION_KEY_LEN); { std::array inputs = { @@ -166,7 +170,8 @@ void invokeAPI( ) { uint256 ephemeralKey; uint256 randomSeed; - uint256 joinSplitPubKey = random_uint256(); + Ed25519VerificationKey joinSplitPubKey; + GetRandBytes(joinSplitPubKey.bytes, ED25519_VERIFICATION_KEY_LEN); std::array macs; std::array nullifiers; std::array commitments; @@ -277,10 +282,13 @@ for test_input in TEST_VECTORS: }; BOOST_FOREACH(std::vector& v, tests) { + Ed25519VerificationKey joinSplitPubKey; + auto pubKeyBytes = uint256S(v[3]); + std::copy(pubKeyBytes.begin(), pubKeyBytes.end(), joinSplitPubKey.bytes); auto expected = ZCJoinSplit::h_sig( uint256S(v[0]), {uint256S(v[1]), uint256S(v[2])}, - uint256S(v[3]) + joinSplitPubKey ); EXPECT_EQ(expected, uint256S(v[4])); diff --git a/depend/zcash/src/gtest/test_mempool.cpp b/depend/zcash/src/gtest/test_mempool.cpp index 76f8c510e..5c6fd779f 100644 --- a/depend/zcash/src/gtest/test_mempool.cpp +++ b/depend/zcash/src/gtest/test_mempool.cpp @@ -167,7 +167,7 @@ TEST(Mempool, SproutV3TxWhenOverwinterActive) { LOCK(cs_main); EXPECT_FALSE(AcceptToMemoryPool(pool, state1, tx1, false, &missingInputs)); - EXPECT_EQ(state1.GetRejectReason(), "tx-overwinter-flag-not-set"); + EXPECT_EQ(state1.GetRejectReason(), "tx-overwintered-flag-not-set"); // Revert to default UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT); diff --git a/depend/zcash/src/gtest/test_metrics.cpp b/depend/zcash/src/gtest/test_metrics.cpp index 3fbadb63d..3a5453692 100644 --- a/depend/zcash/src/gtest/test_metrics.cpp +++ b/depend/zcash/src/gtest/test_metrics.cpp @@ -134,3 +134,45 @@ TEST(Metrics, NextUpgrade) { UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT); } + +TEST(Metrics, DisplayFunctions) { + EXPECT_EQ(DisplayDuration(0, DurationFormat::REDUCED), "0 seconds"); + EXPECT_EQ(DisplayDuration(59, DurationFormat::REDUCED), "59 seconds"); + EXPECT_EQ(DisplayDuration(60, DurationFormat::REDUCED), "1 minutes"); + EXPECT_EQ(DisplayDuration(61, DurationFormat::REDUCED), "1 minutes"); + EXPECT_EQ(DisplayDuration(3599, DurationFormat::REDUCED), "59 minutes"); + EXPECT_EQ(DisplayDuration(3600, DurationFormat::REDUCED), "1 hours"); + EXPECT_EQ(DisplayDuration(86399, DurationFormat::REDUCED), "23 hours"); + EXPECT_EQ(DisplayDuration(86400, DurationFormat::REDUCED), "1 days"); + EXPECT_EQ(DisplayDuration(8640000, DurationFormat::REDUCED), "100 days"); + EXPECT_EQ(DisplayDuration(185542587100800, DurationFormat::REDUCED), "2147483647 days"); + EXPECT_EQ(DisplayDuration(185542587187199, DurationFormat::REDUCED), "2147483647 days"); + + EXPECT_EQ(DisplayDuration(0, DurationFormat::FULL), "0 seconds"); + EXPECT_EQ(DisplayDuration(59, DurationFormat::FULL), "59 seconds"); + EXPECT_EQ(DisplayDuration(60, DurationFormat::FULL), "1 minutes, 0 seconds"); + EXPECT_EQ(DisplayDuration(61, DurationFormat::FULL), "1 minutes, 1 seconds"); + EXPECT_EQ(DisplayDuration(3599, DurationFormat::FULL), "59 minutes, 59 seconds"); + EXPECT_EQ(DisplayDuration(3600, DurationFormat::FULL), "1 hours, 0 minutes, 0 seconds"); + EXPECT_EQ(DisplayDuration(86399, DurationFormat::FULL), "23 hours, 59 minutes, 59 seconds"); + EXPECT_EQ(DisplayDuration(86400, DurationFormat::FULL), "1 days, 0 hours, 0 minutes, 0 seconds"); + EXPECT_EQ(DisplayDuration(8640000, DurationFormat::FULL), "100 days, 0 hours, 0 minutes, 0 seconds"); + EXPECT_EQ(DisplayDuration(185542587100800, DurationFormat::FULL), "2147483647 days, 0 hours, 0 minutes, 0 seconds"); + EXPECT_EQ(DisplayDuration(185542587187199, DurationFormat::FULL), "2147483647 days, 23 hours, 59 minutes, 59 seconds"); + + EXPECT_EQ(DisplaySize(0), "0 Bytes"); + EXPECT_EQ(DisplaySize(123), "123 Bytes"); + EXPECT_EQ(DisplaySize(123456), "120.56 KiB"); + EXPECT_EQ(DisplaySize(123456789), "117.74 MiB"); + EXPECT_EQ(DisplaySize(123456789012), "114.98 GiB"); + EXPECT_EQ(DisplaySize(1234567890123), "1.12 TiB"); + EXPECT_EQ(DisplaySize(INT64_MAX), "8388608.00 TiB"); + + EXPECT_EQ(DisplayHashRate(0.0), "0.000 Sol/s"); + EXPECT_EQ(DisplayHashRate(0.1234), "0.123 Sol/s"); + EXPECT_EQ(DisplayHashRate(123.45), "123.450 Sol/s"); + EXPECT_EQ(DisplayHashRate(1234.5), "1.234 kSol/s"); + EXPECT_EQ(DisplayHashRate(1234567.8), "1.235 MSol/s"); + EXPECT_EQ(DisplayHashRate(1234567890.1), "1.235 GSol/s"); + EXPECT_EQ(DisplayHashRate(1234567890123.4), "1.235 TSol/s"); +} diff --git a/depend/zcash/src/gtest/test_miner.cpp b/depend/zcash/src/gtest/test_miner.cpp index 9cfc32afd..61d454407 100644 --- a/depend/zcash/src/gtest/test_miner.cpp +++ b/depend/zcash/src/gtest/test_miner.cpp @@ -1,3 +1,4 @@ +#if ENABLE_MINING #include #include @@ -121,3 +122,4 @@ TEST(Miner, GetMinerAddress) { EXPECT_FALSE(IsValidMinerAddress(minerAddress)); } } +#endif // ENABLE_MINING diff --git a/depend/zcash/src/gtest/test_noteencryption.cpp b/depend/zcash/src/gtest/test_noteencryption.cpp index 5e46fa9b8..640dd64d6 100644 --- a/depend/zcash/src/gtest/test_noteencryption.cpp +++ b/depend/zcash/src/gtest/test_noteencryption.cpp @@ -190,7 +190,7 @@ TEST(NoteEncryption, RejectsInvalidNoteZip212Enabled) UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, overwinterActivationHeight); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_SAPLING, saplingActivationHeight); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_CANOPY, canopyActivationHeight); - auto params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(); using namespace libzcash; auto xsk = SaplingSpendingKey(uint256()).expanded_spending_key(); @@ -281,7 +281,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled) UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, overwinterActivationHeight); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_SAPLING, saplingActivationHeight); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_CANOPY, canopyActivationHeight); - auto params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(); using namespace libzcash; auto xsk = SaplingSpendingKey(uint256()).expanded_spending_key(); diff --git a/depend/zcash/src/gtest/test_random.cpp b/depend/zcash/src/gtest/test_random.cpp index d89702bcd..9ae2a6d82 100644 --- a/depend/zcash/src/gtest/test_random.cpp +++ b/depend/zcash/src/gtest/test_random.cpp @@ -1,9 +1,7 @@ #include #include "random.h" - -extern int GenZero(int n); -extern int GenMax(int n); +#include "gtest/utils.h" TEST(Random, MappedShuffle) { std::vector a {8, 4, 6, 3, 5}; diff --git a/depend/zcash/src/gtest/test_transaction.cpp b/depend/zcash/src/gtest/test_transaction.cpp index bbb01b9e3..66fe58ea5 100644 --- a/depend/zcash/src/gtest/test_transaction.cpp +++ b/depend/zcash/src/gtest/test_transaction.cpp @@ -1,5 +1,6 @@ #include +#include "gtest/utils.h" #include "primitives/transaction.h" #include "transaction_builder.h" #include "zcash/Note.hpp" @@ -7,8 +8,7 @@ #include -extern int GenZero(int n); -extern int GenMax(int n); +#include TEST(Transaction, JSDescriptionRandomized) { // construct a merkle tree @@ -31,7 +31,7 @@ TEST(Transaction, JSDescriptionRandomized) { auto witness = merkleTree.witness(); // create JSDescription - uint256 joinSplitPubKey; + Ed25519VerificationKey joinSplitPubKey; std::array inputs = { libzcash::JSInput(witness, note, k), libzcash::JSInput() // dummy input of zero value diff --git a/depend/zcash/src/gtest/test_transaction_builder.cpp b/depend/zcash/src/gtest/test_transaction_builder.cpp index bd9192f17..571988608 100644 --- a/depend/zcash/src/gtest/test_transaction_builder.cpp +++ b/depend/zcash/src/gtest/test_transaction_builder.cpp @@ -248,20 +248,10 @@ TEST(TransactionBuilder, SproutToSproutAndSapling) { RegtestDeactivateSapling(); } -TEST(TransactionBuilder, ThrowsOnSproutOutputWithoutParams) -{ - auto consensusParams = Params().GetConsensus(); - auto sk = libzcash::SproutSpendingKey::random(); - auto addr = sk.address(); - - auto builder = TransactionBuilder(consensusParams, 1); - ASSERT_THROW(builder.AddSproutOutput(addr, 10), std::runtime_error); -} - TEST(TransactionBuilder, ThrowsOnTransparentInputWithoutKeyStore) { SelectParams(CBaseChainParams::REGTEST); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); auto builder = TransactionBuilder(consensusParams, 1); ASSERT_THROW(builder.AddTransparentInput(COutPoint(), CScript(), 1), std::runtime_error); @@ -270,7 +260,7 @@ TEST(TransactionBuilder, ThrowsOnTransparentInputWithoutKeyStore) TEST(TransactionBuilder, RejectsInvalidTransparentOutput) { SelectParams(CBaseChainParams::REGTEST); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); // Default CTxDestination type is an invalid address CTxDestination taddr; @@ -281,7 +271,7 @@ TEST(TransactionBuilder, RejectsInvalidTransparentOutput) TEST(TransactionBuilder, RejectsInvalidTransparentChangeAddress) { SelectParams(CBaseChainParams::REGTEST); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); // Default CTxDestination type is an invalid address CTxDestination taddr; @@ -464,7 +454,7 @@ TEST(TransactionBuilder, CheckSaplingTxVersion) { SelectParams(CBaseChainParams::REGTEST); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::ALWAYS_ACTIVE); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); auto sk = libzcash::SaplingSpendingKey::random(); auto expsk = sk.expanded_spending_key(); diff --git a/depend/zcash/src/gtest/test_validation.cpp b/depend/zcash/src/gtest/test_validation.cpp index f809a02b6..0710ae30d 100644 --- a/depend/zcash/src/gtest/test_validation.cpp +++ b/depend/zcash/src/gtest/test_validation.cpp @@ -136,7 +136,7 @@ TEST(Validation, ContextualCheckInputsDetectsOldBranchId) { UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, 10); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_SAPLING, 20); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_BLOSSOM, 30); - auto consensusParams = Params(CBaseChainParams::REGTEST).GetConsensus(); + const Consensus::Params& consensusParams = Params(CBaseChainParams::REGTEST).GetConsensus(); auto overwinterBranchId = NetworkUpgradeInfo[Consensus::UPGRADE_OVERWINTER].nBranchId; auto saplingBranchId = NetworkUpgradeInfo[Consensus::UPGRADE_SAPLING].nBranchId; diff --git a/depend/zcash/src/gtest/utils.cpp b/depend/zcash/src/gtest/utils.cpp index 527e613e2..30d452c82 100644 --- a/depend/zcash/src/gtest/utils.cpp +++ b/depend/zcash/src/gtest/utils.cpp @@ -1,3 +1,5 @@ +#include "gtest/utils.h" + int GenZero(int n) { return 0; diff --git a/depend/zcash/src/gtest/utils.h b/depend/zcash/src/gtest/utils.h new file mode 100644 index 000000000..d3e433ff8 --- /dev/null +++ b/depend/zcash/src/gtest/utils.h @@ -0,0 +1,7 @@ +#ifndef BITCOIN_GTEST_UTILS_H +#define BITCOIN_GTEST_UTILS_H + +int GenZero(int n); +int GenMax(int n); + +#endif diff --git a/depend/zcash/src/hash.h b/depend/zcash/src/hash.h index 6a17df8e6..2c1d49b8b 100644 --- a/depend/zcash/src/hash.h +++ b/depend/zcash/src/hash.h @@ -90,20 +90,6 @@ inline uint256 Hash(const T1 p1begin, const T1 p1end, return result; } -/** Compute the 256-bit hash of the concatenation of three objects. */ -template -inline uint256 Hash(const T1 p1begin, const T1 p1end, - const T2 p2begin, const T2 p2end, - const T3 p3begin, const T3 p3end) { - static const unsigned char pblank[1] = {}; - uint256 result; - CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])) - .Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])) - .Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0])) - .Finalize((unsigned char*)&result); - return result; -} - /** Compute the 160-bit hash an object. */ template inline uint160 Hash160(const T1 pbegin, const T1 pend) @@ -174,24 +160,24 @@ class CBLAKE2bWriter int nVersion; CBLAKE2bWriter(int nTypeIn, int nVersionIn, const unsigned char* personal) : nType(nTypeIn), nVersion(nVersionIn) { - state = rust_blake2b_init(32, personal); + state = blake2b_init(32, personal); } ~CBLAKE2bWriter() { - rust_blake2b_free(state); + blake2b_free(state); } int GetType() const { return nType; } int GetVersion() const { return nVersion; } CBLAKE2bWriter& write(const char *pch, size_t size) { - rust_blake2b_update(state, (const unsigned char*)pch, size); + blake2b_update(state, (const unsigned char*)pch, size); return (*this); } // invalidates the object uint256 GetHash() { uint256 result; - rust_blake2b_finalize(state, (unsigned char*)&result, 32); + blake2b_finalize(state, (unsigned char*)&result, 32); return result; } diff --git a/depend/zcash/src/httpserver.cpp b/depend/zcash/src/httpserver.cpp index c962c2519..134057d51 100644 --- a/depend/zcash/src/httpserver.cpp +++ b/depend/zcash/src/httpserver.cpp @@ -12,6 +12,7 @@ #include "sync.h" #include "ui_interface.h" +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #include #include @@ -34,16 +36,15 @@ #endif #endif -#include // for to_lower() -#include -#include +/** Maximum size of http request (request line + headers) */ +static const size_t MAX_HEADERS_SIZE = 8192; /** HTTP request work item */ class HTTPWorkItem : public HTTPClosure { public: - HTTPWorkItem(HTTPRequest* req, const std::string &path, const HTTPRequestHandler& func): - req(req), path(path), func(func) + HTTPWorkItem(std::unique_ptr req, const std::string &path, const HTTPRequestHandler& func): + req(std::move(req)), path(path), func(func) { } void operator()() @@ -51,7 +52,7 @@ class HTTPWorkItem : public HTTPClosure func(req.get(), path); } - boost::scoped_ptr req; + std::unique_ptr req; private: std::string path; @@ -66,10 +67,9 @@ class WorkQueue { private: /** Mutex protects entire object */ - CWaitableCriticalSection cs; - CConditionVariable cond; - /* XXX in C++11 we can use std::unique_ptr here and avoid manual cleanup */ - std::deque queue; + std::mutex cs; + std::condition_variable cond; + std::deque> queue; bool running; size_t maxDepth; int numThreads; @@ -81,12 +81,12 @@ class WorkQueue WorkQueue &wq; ThreadCounter(WorkQueue &w): wq(w) { - boost::lock_guard lock(wq.cs); + std::lock_guard lock(wq.cs); wq.numThreads += 1; } ~ThreadCounter() { - boost::lock_guard lock(wq.cs); + std::lock_guard lock(wq.cs); wq.numThreads -= 1; wq.cond.notify_all(); } @@ -98,24 +98,20 @@ class WorkQueue numThreads(0) { } - /*( Precondition: worker threads have all stopped + /** Precondition: worker threads have all stopped * (call WaitExit) */ ~WorkQueue() { - while (!queue.empty()) { - delete queue.front(); - queue.pop_front(); - } } /** Enqueue a work item */ bool Enqueue(WorkItem* item) { - boost::unique_lock lock(cs); + std::unique_lock lock(cs); if (queue.size() >= maxDepth) { return false; } - queue.push_back(item); + queue.emplace_back(std::unique_ptr(item)); cond.notify_one(); return true; } @@ -124,31 +120,30 @@ class WorkQueue { ThreadCounter count(*this); while (running) { - WorkItem* i = 0; + std::unique_ptr i; { - boost::unique_lock lock(cs); + std::unique_lock lock(cs); while (running && queue.empty()) cond.wait(lock); if (!running) break; - i = queue.front(); + i = std::move(queue.front()); queue.pop_front(); } (*i)(); - delete i; } } /** Interrupt and exit loops */ void Interrupt() { - boost::unique_lock lock(cs); + std::unique_lock lock(cs); running = false; cond.notify_all(); } /** Wait for worker threads to exit */ void WaitExit() { - boost::unique_lock lock(cs); + std::unique_lock lock(cs); while (numThreads > 0) cond.wait(lock); } @@ -156,7 +151,7 @@ class WorkQueue /** Return current depth of queue */ size_t Depth() { - boost::unique_lock lock(cs); + std::unique_lock lock(cs); return queue.size(); } }; @@ -193,9 +188,10 @@ static bool ClientAllowed(const CNetAddr& netaddr) { if (!netaddr.IsValid()) return false; - BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets) + for (const CSubNet& subnet : rpc_allow_subnets) { if (subnet.Match(netaddr)) return true; + } return false; } @@ -207,7 +203,7 @@ static bool InitHTTPAllowList() rpc_allow_subnets.push_back(CSubNet("::1")); // always allow IPv6 localhost if (mapMultiArgs.count("-rpcallowip")) { const std::vector& vAllow = mapMultiArgs["-rpcallowip"]; - BOOST_FOREACH (std::string strAllow, vAllow) { + for (std::string strAllow : vAllow) { CSubNet subnet(strAllow); if (!subnet.IsValid()) { uiInterface.ThreadSafeMessageBox( @@ -219,8 +215,9 @@ static bool InitHTTPAllowList() } } std::string strAllowed; - BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets) + for (const CSubNet& subnet : rpc_allow_subnets) { strAllowed += subnet.ToString() + " "; + } LogPrint("http", "Allowing HTTP connections from: %s\n", strAllowed); return true; } @@ -285,12 +282,15 @@ static void http_request_cb(struct evhttp_request* req, void* arg) // Dispatch to worker thread if (i != iend) { - std::unique_ptr item(new HTTPWorkItem(hreq.release(), path, i->handler)); + std::unique_ptr item(new HTTPWorkItem(std::move(hreq), path, i->handler)); assert(workQueue); if (workQueue->Enqueue(item.get())) + { item.release(); /* if true, queue took ownership */ - else + } else { + LogPrintf("WARNING: request rejected because http work queue depth exceeded, it can be increased with the -rpcworkqueue= setting\n"); item->req->WriteReply(HTTP_INTERNAL, "Work queue depth exceeded"); + } } else { hreq->WriteReply(HTTP_NOTFOUND); } @@ -304,13 +304,14 @@ static void http_reject_request_cb(struct evhttp_request* req, void*) } /** Event dispatcher thread */ -static void ThreadHTTP(struct event_base* base, struct evhttp* http) +static bool ThreadHTTP(struct event_base* base, struct evhttp* http) { RenameThread("zcash-http"); LogPrint("http", "Entering http event loop\n"); event_base_dispatch(base); // Event loop will be interrupted by InterruptHTTPServer() LogPrint("http", "Exited http event loop\n"); + return event_base_got_break(base) == 0; } /** Bind HTTP server to specified addresses */ @@ -418,6 +419,7 @@ bool InitHTTPServer() } evhttp_set_timeout(http, GetArg("-rpcservertimeout", DEFAULT_HTTP_SERVER_TIMEOUT)); + evhttp_set_max_headers_size(http, MAX_HEADERS_SIZE); evhttp_set_max_body_size(http, MAX_SIZE); evhttp_set_gencb(http, http_request_cb, NULL); @@ -438,17 +440,20 @@ bool InitHTTPServer() return true; } -boost::thread threadHTTP; +std::thread threadHTTP; +std::future threadResult; bool StartHTTPServer() { LogPrint("http", "Starting HTTP server\n"); int rpcThreads = std::max((long)GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L); LogPrintf("HTTP: starting %d worker threads\n", rpcThreads); - threadHTTP = boost::thread(boost::bind(&ThreadHTTP, eventBase, eventHTTP)); + std::packaged_task task(ThreadHTTP); + threadResult = task.get_future(); + threadHTTP = std::thread(std::move(task), eventBase, eventHTTP); for (int i = 0; i < rpcThreads; i++) { - boost::thread rpc_worker(HTTPWorkQueueRun, workQueue); + std::thread rpc_worker(HTTPWorkQueueRun, workQueue); rpc_worker.detach(); } return true; @@ -459,7 +464,7 @@ void InterruptHTTPServer() LogPrint("http", "Interrupting HTTP server\n"); if (eventHTTP) { // Unlisten sockets - BOOST_FOREACH (evhttp_bound_socket *socket, boundSockets) { + for (evhttp_bound_socket *socket : boundSockets) { evhttp_del_accept_socket(eventHTTP, socket); } // Reject requests on current connections @@ -487,11 +492,11 @@ void StopHTTPServer() // master that appears to be solved, so in the future that solution // could be used again (if desirable). // (see discussion in https://github.com/bitcoin/bitcoin/pull/6990) - if (!threadHTTP.try_join_for(boost::chrono::milliseconds(2000))) { + if (threadResult.valid() && threadResult.wait_for(std::chrono::milliseconds(2000)) == std::future_status::timeout) { LogPrintf("HTTP event loop did not exit within allotted time, sending loopbreak\n"); event_base_loopbreak(eventBase); - threadHTTP.join(); } + threadHTTP.join(); } if (eventHTTP) { evhttp_free(eventHTTP); @@ -600,7 +605,7 @@ void HTTPRequest::WriteReply(int nStatus, const std::string& strReply) assert(evb); evbuffer_add(evb, strReply.data(), strReply.size()); HTTPEvent* ev = new HTTPEvent(eventBase, true, - boost::bind(evhttp_send_reply, req, nStatus, (const char*)NULL, (struct evbuffer *)NULL)); + std::bind(evhttp_send_reply, req, nStatus, (const char*)NULL, (struct evbuffer *)NULL)); ev->trigger(0); replySent = true; req = 0; // transferred back to main thread @@ -665,4 +670,3 @@ void UnregisterHTTPHandler(const std::string &prefix, bool exactMatch) pathHandlers.erase(i); } } - diff --git a/depend/zcash/src/httpserver.h b/depend/zcash/src/httpserver.h index 4a775f757..23c7f7f71 100644 --- a/depend/zcash/src/httpserver.h +++ b/depend/zcash/src/httpserver.h @@ -7,8 +7,7 @@ #include #include -#include -#include +#include static const int DEFAULT_HTTP_THREADS=4; static const int DEFAULT_HTTP_WORKQUEUE=16; @@ -86,7 +85,7 @@ class HTTPRequest /** * Get the request header specified by hdr, or an empty string. - * Return an pair (isPresent,string). + * Return a pair (isPresent,string). */ virtual std::pair GetHeader(const std::string& hdr); @@ -125,7 +124,7 @@ class HTTPClosure virtual ~HTTPClosure() {} }; -/** Event class. This can be used either as an cross-thread trigger or as a timer. +/** Event class. This can be used either as a cross-thread trigger or as a timer. */ class HTTPEvent { diff --git a/depend/zcash/src/init.cpp b/depend/zcash/src/init.cpp index 9f005a438..f2e6b3c0c 100644 --- a/depend/zcash/src/init.cpp +++ b/depend/zcash/src/init.cpp @@ -55,26 +55,24 @@ #include #include #include -#include +#include #include #include -#include #include #if ENABLE_ZMQ #include "zmq/zmqnotificationinterface.h" #endif -#if ENABLE_PROTON -#include "amqp/amqpnotificationinterface.h" -#endif - #include "librustzcash.h" using namespace std; +using namespace boost::placeholders; extern void ThreadSendAlert(); +TracingHandle* pTracingHandle = nullptr; + bool fFeeEstimatesInitialized = false; static const bool DEFAULT_PROXYRANDOMIZE = true; static const bool DEFAULT_REST_ENABLE = false; @@ -86,10 +84,6 @@ static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false; static CZMQNotificationInterface* pzmqNotificationInterface = NULL; #endif -#if ENABLE_PROTON -static AMQPNotificationInterface* pAMQPNotificationInterface = NULL; -#endif - #ifdef WIN32 // Win32 LevelDB doesn't use file descriptors, and the ones used for // accessing block files don't count towards the fd_set size limit @@ -183,7 +177,9 @@ void Interrupt(boost::thread_group& threadGroup) void Shutdown() { - LogPrintf("%s: In progress...\n", __func__); + auto span = TracingSpan("info", "main", "Shutdown"); + auto spanGuard = span.Enter(); + static CCriticalSection cs_Shutdown; TRY_LOCK(cs_Shutdown, lockShutdown); if (!lockShutdown) @@ -249,14 +245,6 @@ void Shutdown() } #endif -#if ENABLE_PROTON - if (pAMQPNotificationInterface) { - UnregisterValidationInterface(pAMQPNotificationInterface); - delete pAMQPNotificationInterface; - pAMQPNotificationInterface = NULL; - } -#endif - #ifndef WIN32 try { boost::filesystem::remove(GetPidFile()); @@ -271,7 +259,10 @@ void Shutdown() #endif globalVerifyHandle.reset(); ECC_Stop(); - LogPrintf("%s: done\n", __func__); + TracingInfo("main", "done"); + if (pTracingHandle) { + tracing_free(pTracingHandle); + } } /** @@ -320,7 +311,7 @@ void OnRPCStopped() void OnRPCPreCommand(const CRPCCommand& cmd) { // Observe safe mode - string strWarning = GetWarnings("rpc"); + string strWarning = GetWarnings("rpc").first; if (strWarning != "" && !GetBoolArg("-disablesafemode", DEFAULT_DISABLE_SAFEMODE) && !cmd.okSafeMode) throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning); @@ -348,9 +339,11 @@ std::string HelpMessage(HelpMessageMode mode) #endif } strUsage += HelpMessageOpt("-datadir=", _("Specify data directory")); + strUsage += HelpMessageOpt("-paramsdir=", _("Specify Zcash network parameters directory")); strUsage += HelpMessageOpt("-dbcache=", strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache)); strUsage += HelpMessageOpt("-debuglogfile=", strprintf(_("Specify location of debug log file: this can be an absolute path or a path relative to the data directory (default: %s)"), DEFAULT_DEBUGLOGFILE)); strUsage += HelpMessageOpt("-exportdir=", _("Specify directory to be used when exporting data")); + strUsage += HelpMessageOpt("-ibdskiptxverification", strprintf(_("Skip transaction verification during initial block download up to the last checkpoint height. Incompatible with flags that disable checkpoints. (default = %u)"), DEFAULT_IBD_SKIP_TX_VERIFICATION)); strUsage += HelpMessageOpt("-loadblock=", _("Imports blocks from external blk000??.dat file on startup")); strUsage += HelpMessageOpt("-maxorphantx=", strprintf(_("Keep at most unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS)); strUsage += HelpMessageOpt("-par=", strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"), @@ -416,14 +409,6 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-zmqpubrawtx=
", _("Enable publish raw transaction in
")); #endif -#if ENABLE_PROTON - strUsage += HelpMessageGroup(_("AMQP 1.0 notification options:")); - strUsage += HelpMessageOpt("-amqppubhashblock=
", _("Enable publish hash block in
")); - strUsage += HelpMessageOpt("-amqppubhashtx=
", _("Enable publish hash transaction in
")); - strUsage += HelpMessageOpt("-amqppubrawblock=
", _("Enable publish raw block in
")); - strUsage += HelpMessageOpt("-amqppubrawtx=
", _("Enable publish raw transaction in
")); -#endif - strUsage += HelpMessageGroup(_("Debugging/Testing options:")); if (showDebug) { @@ -436,13 +421,13 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-nuparams=hexBranchId:activationHeight", "Use given activation height for specified network upgrade (regtest-only)"); strUsage += HelpMessageOpt("-nurejectoldversions", strprintf("Reject peers that don't know about the current epoch (regtest-only) (default: %u)", DEFAULT_NU_REJECT_OLD_VERSIONS)); strUsage += HelpMessageOpt( - "-fundingstream=streamId:startHeight:endHeight:comma_delimited_addresses", + "-fundingstream=streamId:startHeight:endHeight:comma_delimited_addresses", "Use given addresses for block subsidy share paid to the funding stream with id (regtest-only)"); } string debugCategories = "addrman, alert, bench, coindb, db, estimatefee, http, libevent, lock, mempool, net, partitioncheck, pow, proxy, prune, " - "rand, reindex, rpc, selectcoins, tor, zmq, zrpc, zrpcunsafe (implies zrpc)"; // Don't translate these + "rand, receiveunsafe, reindex, rpc, selectcoins, tor, zmq, zrpc, zrpcunsafe (implies zrpc)"; // Don't translate these strUsage += HelpMessageOpt("-debug=", strprintf(_("Output debugging information (default: %u, supplying is optional)"), 0) + ". " + - _("If is not supplied or if = 1, output all debugging information.") + " " + _(" can be:") + " " + debugCategories + ". " + + _("If is not supplied or if = 1, output all debugging information.") + " " + _(" can be:") + " " + debugCategories + ". " + _("For multiple specific categories use -debug= multiple times.")); strUsage += HelpMessageOpt("-experimentalfeatures", _("Enable use of experimental features")); strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)")); @@ -523,11 +508,14 @@ std::string HelpMessage(HelpMessageMode mode) return strUsage; } -static void BlockNotifyCallback(const uint256& hashNewTip) +static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex) { + if (initialSync || !pBlockIndex) + return; + std::string strCmd = GetArg("-blocknotify", ""); - boost::replace_all(strCmd, "%s", hashNewTip.GetHex()); + boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex()); boost::thread t(runCommand, strCmd); // thread runs free } @@ -766,13 +754,10 @@ static void ZC_LoadParams( librustzcash_init_zksnark_params( reinterpret_cast(sapling_spend_str.c_str()), sapling_spend_str.length(), - "8270785a1a0d0bc77196f000ee6d221c9c9894f55307bd9357c3f0105d31ca63991ab91324160d8f53e2bbd3c2633a6eb8bdf5205d822e7f3f73edac51b2b70c", reinterpret_cast(sapling_output_str.c_str()), sapling_output_str.length(), - "657e3d38dbb5cb5e7dd2970e8b03d69b4787dd907285b5a7f0790dcc8072f60bf593b32cc2d1c030e00ff5ae64bf84c5c3beb84ddc841d48264b4a171744d028", reinterpret_cast(sprout_groth16_str.c_str()), - sprout_groth16_str.length(), - "e9b238411bd6c0ec4791e9d04245ec350c9c5744f5610dfcce4365d5ca49dfefd5054e371842b3f88fa1b9d7e8e075249b3ebabd167fa8b0f3161292d36c180a" + sprout_groth16_str.length() ); gettimeofday(&tv_end, 0); @@ -860,6 +845,25 @@ void InitLogging() fLogTimestamps = GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS); fLogIPs = GetBoolArg("-logips", DEFAULT_LOGIPS); + // Set up the initial filtering directive from the -debug flags. + std::string initialFilter = LogConfigFilter(); + + boost::filesystem::path pathDebug = GetDebugLogPath(); + const boost::filesystem::path::string_type& pathDebugStr = pathDebug.native(); + static_assert(sizeof(boost::filesystem::path::value_type) == sizeof(codeunit), + "native path has unexpected code unit size"); + const codeunit* pathDebugCStr = nullptr; + size_t pathDebugLen = 0; + if (!fPrintToConsole) { + pathDebugCStr = reinterpret_cast(pathDebugStr.c_str()); + pathDebugLen = pathDebugStr.length(); + } + + pTracingHandle = tracing_init( + pathDebugCStr, pathDebugLen, + initialFilter.c_str(), + fLogTimestamps); + LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); LogPrintf("Zcash version %s (%s)\n", FormatFullVersion(), CLIENT_DATE); } @@ -941,7 +945,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // Make sure enough file descriptors are available int nBind = std::max((int)mapArgs.count("-bind") + (int)mapArgs.count("-whitebind"), 1); nMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS); - nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0); + nMaxConnections = std::max(std::min(nMaxConnections, FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS), 0); int nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS); if (nFD < MIN_CORE_FILEDESCRIPTORS) return InitError(_("Not enough file descriptors available.")); @@ -959,6 +963,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) #endif } + // ensure that the user has not disabled checkpoints when requesting to + // skip transaction verification in initial block download. + if (GetBoolArg("-ibdskiptxverification", DEFAULT_IBD_SKIP_TX_VERIFICATION)) { + if (!GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED)) { + return InitError(_("-ibdskiptxverification requires checkpoints to be enabled; it is incompatible with flags that disable checkpoints")); + } + } + // ********************************************************* Step 3: parameter-to-internal-flags fDebug = !mapMultiArgs["-debug"].empty(); @@ -1000,6 +1012,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) mempool.SetMempoolCostLimit(mempoolTotalCostLimit, mempoolEvictionMemorySeconds); fCheckBlockIndex = GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks()); + fIBDSkipTxVerification = GetBoolArg("-ibdskiptxverification", DEFAULT_IBD_SKIP_TX_VERIFICATION); fCheckpointsEnabled = GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED); // -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency @@ -1142,8 +1155,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return InitError("Funding stream parameters malformed, expecting streamId:startHeight:endHeight:comma_delimited_addresses"); } int nFundingStreamId; - if (!ParseInt32(vStreamParams[0], &nFundingStreamId) || - nFundingStreamId < Consensus::FIRST_FUNDING_STREAM || + if (!ParseInt32(vStreamParams[0], &nFundingStreamId) || + nFundingStreamId < Consensus::FIRST_FUNDING_STREAM || nFundingStreamId >= Consensus::MAX_FUNDING_STREAMS) { return InitError(strprintf("Invalid streamId (%s)", vStreamParams[0])); } @@ -1204,13 +1217,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // if (GetBoolArg("-shrinkdebugfile", !fDebug)) // ShrinkDebugFile(); - if (fPrintToDebugLog) { - if (!OpenDebugLog()) { - return InitError(strprintf("Could not open debug log file %s", GetDebugLogPath().string())); - } - } - - LogPrintf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION)); #ifdef ENABLE_WALLET LogPrintf("Using BerkeleyDB version %s\n", DbEnv::version(0, 0, 0)); #endif @@ -1395,21 +1401,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } #endif -#if ENABLE_PROTON - pAMQPNotificationInterface = AMQPNotificationInterface::CreateWithArguments(mapArgs); - - if (pAMQPNotificationInterface) { - - // AMQP support is currently an experimental feature, so fail if user configured AMQP notifications - // without enabling experimental features. - if (!GetBoolArg("-experimentalfeatures", false)) { - return InitError(_("AMQP support requires -experimentalfeatures.")); - } - - RegisterValidationInterface(pAMQPNotificationInterface); - } -#endif - // ********************************************************* Step 7: load block chain fReindex = GetBoolArg("-reindex", false); diff --git a/depend/zcash/src/init.h b/depend/zcash/src/init.h index 8e96ff9d6..552d402ad 100644 --- a/depend/zcash/src/init.h +++ b/depend/zcash/src/init.h @@ -8,6 +8,8 @@ #include +#include + class CScheduler; class CWallet; @@ -16,6 +18,8 @@ namespace boost class thread_group; } // namespace boost +extern TracingHandle* pTracingHandle; + void StartShutdown(); bool ShutdownRequested(); /** Interrupt threads */ diff --git a/depend/zcash/src/key.cpp b/depend/zcash/src/key.cpp index 5027a19fb..28ef803f5 100644 --- a/depend/zcash/src/key.cpp +++ b/depend/zcash/src/key.cpp @@ -179,7 +179,7 @@ CPrivKey CKey::GetPrivKey() const { size_t privkeylen; privkey.resize(PRIVATE_KEY_SIZE); privkeylen = PRIVATE_KEY_SIZE; - ret = ec_privkey_export_der(secp256k1_context_sign, (unsigned char*)&privkey[0], &privkeylen, begin(), fCompressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED); + ret = ec_privkey_export_der(secp256k1_context_sign, privkey.data(), &privkeylen, begin(), fCompressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED); assert(ret); privkey.resize(privkeylen); return privkey; @@ -208,7 +208,7 @@ bool CKey::Sign(const uint256 &hash, std::vector& vchSig, uint32_ secp256k1_ecdsa_signature sig; int ret = secp256k1_ecdsa_sign(secp256k1_context_sign, &sig, hash.begin(), begin(), secp256k1_nonce_function_rfc6979, test_case ? extra_entropy : NULL); assert(ret); - secp256k1_ecdsa_signature_serialize_der(secp256k1_context_sign, (unsigned char*)&vchSig[0], &nSigLen, &sig); + secp256k1_ecdsa_signature_serialize_der(secp256k1_context_sign, vchSig.data(), &nSigLen, &sig); vchSig.resize(nSigLen); return true; } @@ -235,7 +235,7 @@ bool CKey::SignCompact(const uint256 &hash, std::vector& vchSig) secp256k1_ecdsa_recoverable_signature sig; int ret = secp256k1_ecdsa_sign_recoverable(secp256k1_context_sign, &sig, hash.begin(), begin(), secp256k1_nonce_function_rfc6979, NULL); assert(ret); - secp256k1_ecdsa_recoverable_signature_serialize_compact(secp256k1_context_sign, (unsigned char*)&vchSig[1], &rec, &sig); + secp256k1_ecdsa_recoverable_signature_serialize_compact(secp256k1_context_sign, &vchSig[1], &rec, &sig); assert(ret); assert(rec != -1); vchSig[0] = 27 + rec + (fCompressed ? 4 : 0); @@ -243,7 +243,7 @@ bool CKey::SignCompact(const uint256 &hash, std::vector& vchSig) } bool CKey::Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck=false) { - if (!ec_privkey_import_der(secp256k1_context_sign, (unsigned char*)begin(), &privkey[0], privkey.size())) + if (!ec_privkey_import_der(secp256k1_context_sign, (unsigned char*)begin(), privkey.data(), privkey.size())) return false; fCompressed = vchPubKey.IsCompressed(); fValid = true; @@ -286,8 +286,8 @@ void CExtKey::SetMaster(const unsigned char *seed, unsigned int nSeedLen) { static const unsigned char hashkey[] = {'B','i','t','c','o','i','n',' ','s','e','e','d'}; std::vector> vout(64); CHMAC_SHA512(hashkey, sizeof(hashkey)).Write(seed, nSeedLen).Finalize(vout.data()); - key.Set(&vout[0], &vout[32], true); - memcpy(chaincode.begin(), &vout[32], 32); + key.Set(vout.data(), vout.data() + 32, true); + memcpy(chaincode.begin(), vout.data() + 32, 32); nDepth = 0; nChild = 0; memset(vchFingerprint, 0, sizeof(vchFingerprint)); diff --git a/depend/zcash/src/key.h b/depend/zcash/src/key.h index 150548af5..c61f1dd02 100644 --- a/depend/zcash/src/key.h +++ b/depend/zcash/src/key.h @@ -62,11 +62,6 @@ class CKey keydata.resize(32); } - //! Destructor (again necessary because of memlocking). - ~CKey() - { - } - friend bool operator==(const CKey& a, const CKey& b) { return a.fCompressed == b.fCompressed && @@ -100,14 +95,14 @@ class CKey //! Check whether the public key corresponding to this private key is (to be) compressed. bool IsCompressed() const { return fCompressed; } - //! Initialize from a CPrivKey (serialized OpenSSL private key data). + //! Initialize from a CPrivKey (serialized OpenSSL-format private key data). bool SetPrivKey(const CPrivKey& vchPrivKey, bool fCompressed); //! Generate a new private key using a cryptographic PRNG. void MakeNewKey(bool fCompressed); /** - * Convert the private key to a CPrivKey (serialized OpenSSL private key data). + * Convert the private key to a CPrivKey (serialized OpenSSL-format private key data). * This is expensive. */ CPrivKey GetPrivKey() const; diff --git a/depend/zcash/src/leveldb/.travis.yml b/depend/zcash/src/leveldb/.travis.yml new file mode 100644 index 000000000..f5bd74c45 --- /dev/null +++ b/depend/zcash/src/leveldb/.travis.yml @@ -0,0 +1,13 @@ +language: cpp +compiler: +- clang +- gcc +os: +- linux +- osx +sudo: false +before_install: +- echo $LANG +- echo $LC_ALL +script: +- make -j 4 check diff --git a/depend/zcash/src/leveldb/Makefile b/depend/zcash/src/leveldb/Makefile index 2bd2cadcd..f7cc7d736 100644 --- a/depend/zcash/src/leveldb/Makefile +++ b/depend/zcash/src/leveldb/Makefile @@ -20,208 +20,405 @@ $(shell CC="$(CC)" CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" \ # this file is generated by the previous line to set build flags and sources include build_config.mk +TESTS = \ + db/autocompact_test \ + db/c_test \ + db/corruption_test \ + db/db_test \ + db/dbformat_test \ + db/fault_injection_test \ + db/filename_test \ + db/log_test \ + db/recovery_test \ + db/skiplist_test \ + db/version_edit_test \ + db/version_set_test \ + db/write_batch_test \ + helpers/memenv/memenv_test \ + issues/issue178_test \ + issues/issue200_test \ + table/filter_block_test \ + table/table_test \ + util/arena_test \ + util/bloom_test \ + util/cache_test \ + util/coding_test \ + util/crc32c_test \ + util/env_posix_test \ + util/env_test \ + util/hash_test + +UTILS = \ + db/db_bench \ + db/leveldbutil + +# Put the object files in a subdirectory, but the application at the top of the object dir. +PROGNAMES := $(notdir $(TESTS) $(UTILS)) + +# On Linux may need libkyotocabinet-dev for dependency. +BENCHMARKS = \ + doc/bench/db_bench_sqlite3 \ + doc/bench/db_bench_tree_db + CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT) CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) LDFLAGS += $(PLATFORM_LDFLAGS) LIBS += $(PLATFORM_LIBS) -LIBOBJECTS = $(SOURCES:.cc=.o) -MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o) - -TESTUTIL = ./util/testutil.o -TESTHARNESS = ./util/testharness.o $(TESTUTIL) +SIMULATOR_OUTDIR=out-ios-x86 +DEVICE_OUTDIR=out-ios-arm -# Note: iOS should probably be using libtool, not ar. ifeq ($(PLATFORM), IOS) +# Note: iOS should probably be using libtool, not ar. AR=xcrun ar +SIMULATORSDK=$(shell xcrun -sdk iphonesimulator --show-sdk-path) +DEVICESDK=$(shell xcrun -sdk iphoneos --show-sdk-path) +DEVICE_CFLAGS = -isysroot "$(DEVICESDK)" -arch armv6 -arch armv7 -arch armv7s -arch arm64 +SIMULATOR_CFLAGS = -isysroot "$(SIMULATORSDK)" -arch i686 -arch x86_64 +STATIC_OUTDIR=out-ios-universal +else +STATIC_OUTDIR=out-static +SHARED_OUTDIR=out-shared +STATIC_PROGRAMS := $(addprefix $(STATIC_OUTDIR)/, $(PROGNAMES)) +SHARED_PROGRAMS := $(addprefix $(SHARED_OUTDIR)/, db_bench) endif -TESTS = \ - arena_test \ - autocompact_test \ - bloom_test \ - c_test \ - cache_test \ - coding_test \ - corruption_test \ - crc32c_test \ - db_test \ - dbformat_test \ - env_test \ - filename_test \ - filter_block_test \ - hash_test \ - issue178_test \ - issue200_test \ - log_test \ - memenv_test \ - skiplist_test \ - table_test \ - version_edit_test \ - version_set_test \ - write_batch_test - -PROGRAMS = db_bench leveldbutil $(TESTS) -BENCHMARKS = db_bench_sqlite3 db_bench_tree_db - -LIBRARY = libleveldb.a -MEMENVLIBRARY = libmemenv.a +STATIC_LIBOBJECTS := $(addprefix $(STATIC_OUTDIR)/, $(SOURCES:.cc=.o)) +STATIC_MEMENVOBJECTS := $(addprefix $(STATIC_OUTDIR)/, $(MEMENV_SOURCES:.cc=.o)) + +DEVICE_LIBOBJECTS := $(addprefix $(DEVICE_OUTDIR)/, $(SOURCES:.cc=.o)) +DEVICE_MEMENVOBJECTS := $(addprefix $(DEVICE_OUTDIR)/, $(MEMENV_SOURCES:.cc=.o)) + +SIMULATOR_LIBOBJECTS := $(addprefix $(SIMULATOR_OUTDIR)/, $(SOURCES:.cc=.o)) +SIMULATOR_MEMENVOBJECTS := $(addprefix $(SIMULATOR_OUTDIR)/, $(MEMENV_SOURCES:.cc=.o)) + +SHARED_LIBOBJECTS := $(addprefix $(SHARED_OUTDIR)/, $(SOURCES:.cc=.o)) +SHARED_MEMENVOBJECTS := $(addprefix $(SHARED_OUTDIR)/, $(MEMENV_SOURCES:.cc=.o)) + +TESTUTIL := $(STATIC_OUTDIR)/util/testutil.o +TESTHARNESS := $(STATIC_OUTDIR)/util/testharness.o $(TESTUTIL) + +STATIC_TESTOBJS := $(addprefix $(STATIC_OUTDIR)/, $(addsuffix .o, $(TESTS))) +STATIC_UTILOBJS := $(addprefix $(STATIC_OUTDIR)/, $(addsuffix .o, $(UTILS))) +STATIC_ALLOBJS := $(STATIC_LIBOBJECTS) $(STATIC_MEMENVOBJECTS) $(STATIC_TESTOBJS) $(STATIC_UTILOBJS) $(TESTHARNESS) +DEVICE_ALLOBJS := $(DEVICE_LIBOBJECTS) $(DEVICE_MEMENVOBJECTS) +SIMULATOR_ALLOBJS := $(SIMULATOR_LIBOBJECTS) $(SIMULATOR_MEMENVOBJECTS) default: all # Should we build shared libraries? ifneq ($(PLATFORM_SHARED_EXT),) +# Many leveldb test apps use non-exported API's. Only build a subset for testing. +SHARED_ALLOBJS := $(SHARED_LIBOBJECTS) $(SHARED_MEMENVOBJECTS) $(TESTHARNESS) + ifneq ($(PLATFORM_SHARED_VERSIONED),true) -SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT) -SHARED2 = $(SHARED1) -SHARED3 = $(SHARED1) -SHARED = $(SHARED1) +SHARED_LIB1 = libleveldb.$(PLATFORM_SHARED_EXT) +SHARED_LIB2 = $(SHARED_LIB1) +SHARED_LIB3 = $(SHARED_LIB1) +SHARED_LIBS = $(SHARED_LIB1) +SHARED_MEMENVLIB = $(SHARED_OUTDIR)/libmemenv.a else # Update db.h if you change these. -SHARED_MAJOR = 1 -SHARED_MINOR = 18 -SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT) -SHARED2 = $(SHARED1).$(SHARED_MAJOR) -SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR) -SHARED = $(SHARED1) $(SHARED2) $(SHARED3) -$(SHARED1): $(SHARED3) - ln -fs $(SHARED3) $(SHARED1) -$(SHARED2): $(SHARED3) - ln -fs $(SHARED3) $(SHARED2) +SHARED_VERSION_MAJOR = 1 +SHARED_VERSION_MINOR = 20 +SHARED_LIB1 = libleveldb.$(PLATFORM_SHARED_EXT) +SHARED_LIB2 = $(SHARED_LIB1).$(SHARED_VERSION_MAJOR) +SHARED_LIB3 = $(SHARED_LIB1).$(SHARED_VERSION_MAJOR).$(SHARED_VERSION_MINOR) +SHARED_LIBS = $(SHARED_OUTDIR)/$(SHARED_LIB1) $(SHARED_OUTDIR)/$(SHARED_LIB2) $(SHARED_OUTDIR)/$(SHARED_LIB3) +$(SHARED_OUTDIR)/$(SHARED_LIB1): $(SHARED_OUTDIR)/$(SHARED_LIB3) + ln -fs $(SHARED_LIB3) $(SHARED_OUTDIR)/$(SHARED_LIB1) +$(SHARED_OUTDIR)/$(SHARED_LIB2): $(SHARED_OUTDIR)/$(SHARED_LIB3) + ln -fs $(SHARED_LIB3) $(SHARED_OUTDIR)/$(SHARED_LIB2) +SHARED_MEMENVLIB = $(SHARED_OUTDIR)/libmemenv.a endif -$(SHARED3): - $(CXX) $(LDFLAGS) $(PLATFORM_SHARED_LDFLAGS)$(SHARED2) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(SOURCES) -o $(SHARED3) $(LIBS) +$(SHARED_OUTDIR)/$(SHARED_LIB3): $(SHARED_LIBOBJECTS) + $(CXX) $(LDFLAGS) $(PLATFORM_SHARED_LDFLAGS)$(SHARED_LIB2) $(SHARED_LIBOBJECTS) -o $(SHARED_OUTDIR)/$(SHARED_LIB3) $(LIBS) endif # PLATFORM_SHARED_EXT -all: $(SHARED) $(LIBRARY) +all: $(SHARED_LIBS) $(SHARED_PROGRAMS) $(STATIC_OUTDIR)/libleveldb.a $(STATIC_OUTDIR)/libmemenv.a $(STATIC_PROGRAMS) -check: all $(PROGRAMS) $(TESTS) - for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done +check: $(STATIC_PROGRAMS) + for t in $(notdir $(TESTS)); do echo "***** Running $$t"; $(STATIC_OUTDIR)/$$t || exit 1; done clean: - -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk - -rm -rf ios-x86/* ios-arm/* + -rm -rf out-static out-shared out-ios-x86 out-ios-arm out-ios-universal + -rm -f build_config.mk + -rm -rf ios-x86 ios-arm -$(LIBRARY): $(LIBOBJECTS) - rm -f $@ - $(AR) -rs $@ $(LIBOBJECTS) +$(STATIC_OUTDIR): + mkdir $@ -db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) - $(CXX) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LIBS) +$(STATIC_OUTDIR)/db: | $(STATIC_OUTDIR) + mkdir $@ -db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) - $(CXX) $(LDFLAGS) doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lsqlite3 $(LIBS) +$(STATIC_OUTDIR)/helpers/memenv: | $(STATIC_OUTDIR) + mkdir -p $@ -db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) - $(CXX) $(LDFLAGS) doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lkyotocabinet $(LIBS) +$(STATIC_OUTDIR)/port: | $(STATIC_OUTDIR) + mkdir $@ -leveldbutil: db/leveldb_main.o $(LIBOBJECTS) - $(CXX) $(LDFLAGS) db/leveldb_main.o $(LIBOBJECTS) -o $@ $(LIBS) +$(STATIC_OUTDIR)/table: | $(STATIC_OUTDIR) + mkdir $@ -arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(STATIC_OUTDIR)/util: | $(STATIC_OUTDIR) + mkdir $@ -autocompact_test: db/autocompact_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) db/autocompact_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +.PHONY: STATIC_OBJDIRS +STATIC_OBJDIRS: \ + $(STATIC_OUTDIR)/db \ + $(STATIC_OUTDIR)/port \ + $(STATIC_OUTDIR)/table \ + $(STATIC_OUTDIR)/util \ + $(STATIC_OUTDIR)/helpers/memenv -bloom_test: util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(SHARED_OUTDIR): + mkdir $@ -c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(SHARED_OUTDIR)/db: | $(SHARED_OUTDIR) + mkdir $@ -cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(SHARED_OUTDIR)/helpers/memenv: | $(SHARED_OUTDIR) + mkdir -p $@ -coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(SHARED_OUTDIR)/port: | $(SHARED_OUTDIR) + mkdir $@ -corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(SHARED_OUTDIR)/table: | $(SHARED_OUTDIR) + mkdir $@ -crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(SHARED_OUTDIR)/util: | $(SHARED_OUTDIR) + mkdir $@ -db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +.PHONY: SHARED_OBJDIRS +SHARED_OBJDIRS: \ + $(SHARED_OUTDIR)/db \ + $(SHARED_OUTDIR)/port \ + $(SHARED_OUTDIR)/table \ + $(SHARED_OUTDIR)/util \ + $(SHARED_OUTDIR)/helpers/memenv -dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(DEVICE_OUTDIR): + mkdir $@ -env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(DEVICE_OUTDIR)/db: | $(DEVICE_OUTDIR) + mkdir $@ -filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(DEVICE_OUTDIR)/helpers/memenv: | $(DEVICE_OUTDIR) + mkdir -p $@ -filter_block_test: table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(DEVICE_OUTDIR)/port: | $(DEVICE_OUTDIR) + mkdir $@ -hash_test: util/hash_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) util/hash_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(DEVICE_OUTDIR)/table: | $(DEVICE_OUTDIR) + mkdir $@ -issue178_test: issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(DEVICE_OUTDIR)/util: | $(DEVICE_OUTDIR) + mkdir $@ -issue200_test: issues/issue200_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) issues/issue200_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +.PHONY: DEVICE_OBJDIRS +DEVICE_OBJDIRS: \ + $(DEVICE_OUTDIR)/db \ + $(DEVICE_OUTDIR)/port \ + $(DEVICE_OUTDIR)/table \ + $(DEVICE_OUTDIR)/util \ + $(DEVICE_OUTDIR)/helpers/memenv -log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(SIMULATOR_OUTDIR): + mkdir $@ -table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(SIMULATOR_OUTDIR)/db: | $(SIMULATOR_OUTDIR) + mkdir $@ -skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(SIMULATOR_OUTDIR)/helpers/memenv: | $(SIMULATOR_OUTDIR) + mkdir -p $@ -version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(SIMULATOR_OUTDIR)/port: | $(SIMULATOR_OUTDIR) + mkdir $@ -version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(SIMULATOR_OUTDIR)/table: | $(SIMULATOR_OUTDIR) + mkdir $@ -write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) +$(SIMULATOR_OUTDIR)/util: | $(SIMULATOR_OUTDIR) + mkdir $@ -$(MEMENVLIBRARY) : $(MEMENVOBJECTS) - rm -f $@ - $(AR) -rs $@ $(MEMENVOBJECTS) +.PHONY: SIMULATOR_OBJDIRS +SIMULATOR_OBJDIRS: \ + $(SIMULATOR_OUTDIR)/db \ + $(SIMULATOR_OUTDIR)/port \ + $(SIMULATOR_OUTDIR)/table \ + $(SIMULATOR_OUTDIR)/util \ + $(SIMULATOR_OUTDIR)/helpers/memenv -memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) - $(CXX) $(LDFLAGS) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LIBS) +$(STATIC_ALLOBJS): | STATIC_OBJDIRS +$(DEVICE_ALLOBJS): | DEVICE_OBJDIRS +$(SIMULATOR_ALLOBJS): | SIMULATOR_OBJDIRS +$(SHARED_ALLOBJS): | SHARED_OBJDIRS ifeq ($(PLATFORM), IOS) -# For iOS, create universal object files to be used on both the simulator and +$(DEVICE_OUTDIR)/libleveldb.a: $(DEVICE_LIBOBJECTS) + rm -f $@ + $(AR) -rs $@ $(DEVICE_LIBOBJECTS) + +$(SIMULATOR_OUTDIR)/libleveldb.a: $(SIMULATOR_LIBOBJECTS) + rm -f $@ + $(AR) -rs $@ $(SIMULATOR_LIBOBJECTS) + +$(DEVICE_OUTDIR)/libmemenv.a: $(DEVICE_MEMENVOBJECTS) + rm -f $@ + $(AR) -rs $@ $(DEVICE_MEMENVOBJECTS) + +$(SIMULATOR_OUTDIR)/libmemenv.a: $(SIMULATOR_MEMENVOBJECTS) + rm -f $@ + $(AR) -rs $@ $(SIMULATOR_MEMENVOBJECTS) + +# For iOS, create universal object libraries to be used on both the simulator and # a device. -PLATFORMSROOT=/Applications/Xcode.app/Contents/Developer/Platforms -SIMULATORROOT=$(PLATFORMSROOT)/iPhoneSimulator.platform/Developer -DEVICEROOT=$(PLATFORMSROOT)/iPhoneOS.platform/Developer -IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBundleShortVersionString) -IOSARCH=-arch armv6 -arch armv7 -arch armv7s -arch arm64 - -.cc.o: - mkdir -p ios-x86/$(dir $@) - xcrun -sdk iphonesimulator $(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -arch x86_64 -c $< -o ios-x86/$@ - mkdir -p ios-arm/$(dir $@) - xcrun -sdk iphoneos $(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk $(IOSARCH) -c $< -o ios-arm/$@ - xcrun lipo ios-x86/$@ ios-arm/$@ -create -output $@ - -.c.o: - mkdir -p ios-x86/$(dir $@) - xcrun -sdk iphonesimulator $(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -arch x86_64 -c $< -o ios-x86/$@ - mkdir -p ios-arm/$(dir $@) - xcrun -sdk iphoneos $(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk $(IOSARCH) -c $< -o ios-arm/$@ - xcrun lipo ios-x86/$@ ios-arm/$@ -create -output $@ +$(STATIC_OUTDIR)/libleveldb.a: $(STATIC_OUTDIR) $(DEVICE_OUTDIR)/libleveldb.a $(SIMULATOR_OUTDIR)/libleveldb.a + lipo -create $(DEVICE_OUTDIR)/libleveldb.a $(SIMULATOR_OUTDIR)/libleveldb.a -output $@ +$(STATIC_OUTDIR)/libmemenv.a: $(STATIC_OUTDIR) $(DEVICE_OUTDIR)/libmemenv.a $(SIMULATOR_OUTDIR)/libmemenv.a + lipo -create $(DEVICE_OUTDIR)/libmemenv.a $(SIMULATOR_OUTDIR)/libmemenv.a -output $@ else -.cc.o: +$(STATIC_OUTDIR)/libleveldb.a:$(STATIC_LIBOBJECTS) + rm -f $@ + $(AR) -rs $@ $(STATIC_LIBOBJECTS) + +$(STATIC_OUTDIR)/libmemenv.a:$(STATIC_MEMENVOBJECTS) + rm -f $@ + $(AR) -rs $@ $(STATIC_MEMENVOBJECTS) +endif + +$(SHARED_MEMENVLIB):$(SHARED_MEMENVOBJECTS) + rm -f $@ + $(AR) -rs $@ $(SHARED_MEMENVOBJECTS) + +$(STATIC_OUTDIR)/db_bench:db/db_bench.cc $(STATIC_LIBOBJECTS) $(TESTUTIL) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/db_bench.cc $(STATIC_LIBOBJECTS) $(TESTUTIL) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/db_bench_sqlite3:doc/bench/db_bench_sqlite3.cc $(STATIC_LIBOBJECTS) $(TESTUTIL) + $(CXX) $(LDFLAGS) $(CXXFLAGS) doc/bench/db_bench_sqlite3.cc $(STATIC_LIBOBJECTS) $(TESTUTIL) -o $@ -lsqlite3 $(LIBS) + +$(STATIC_OUTDIR)/db_bench_tree_db:doc/bench/db_bench_tree_db.cc $(STATIC_LIBOBJECTS) $(TESTUTIL) + $(CXX) $(LDFLAGS) $(CXXFLAGS) doc/bench/db_bench_tree_db.cc $(STATIC_LIBOBJECTS) $(TESTUTIL) -o $@ -lkyotocabinet $(LIBS) + +$(STATIC_OUTDIR)/leveldbutil:db/leveldbutil.cc $(STATIC_LIBOBJECTS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/leveldbutil.cc $(STATIC_LIBOBJECTS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/arena_test:util/arena_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) util/arena_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/autocompact_test:db/autocompact_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/autocompact_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/bloom_test:util/bloom_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) util/bloom_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/c_test:$(STATIC_OUTDIR)/db/c_test.o $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(STATIC_OUTDIR)/db/c_test.o $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/cache_test:util/cache_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) util/cache_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/coding_test:util/coding_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) util/coding_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/corruption_test:db/corruption_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/corruption_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/crc32c_test:util/crc32c_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) util/crc32c_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/db_test:db/db_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/db_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/dbformat_test:db/dbformat_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/dbformat_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/env_posix_test:util/env_posix_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) util/env_posix_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/env_test:util/env_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) util/env_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/fault_injection_test:db/fault_injection_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/fault_injection_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/filename_test:db/filename_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/filename_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/filter_block_test:table/filter_block_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) table/filter_block_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/hash_test:util/hash_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) util/hash_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/issue178_test:issues/issue178_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) issues/issue178_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/issue200_test:issues/issue200_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) issues/issue200_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/log_test:db/log_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/log_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/recovery_test:db/recovery_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/recovery_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/table_test:table/table_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) table/table_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/skiplist_test:db/skiplist_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/skiplist_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/version_edit_test:db/version_edit_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/version_edit_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/version_set_test:db/version_set_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/version_set_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/write_batch_test:db/write_batch_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) $(CXXFLAGS) db/write_batch_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(STATIC_OUTDIR)/memenv_test:$(STATIC_OUTDIR)/helpers/memenv/memenv_test.o $(STATIC_OUTDIR)/libmemenv.a $(STATIC_OUTDIR)/libleveldb.a $(TESTHARNESS) + $(XCRUN) $(CXX) $(LDFLAGS) $(STATIC_OUTDIR)/helpers/memenv/memenv_test.o $(STATIC_OUTDIR)/libmemenv.a $(STATIC_OUTDIR)/libleveldb.a $(TESTHARNESS) -o $@ $(LIBS) + +$(SHARED_OUTDIR)/db_bench:$(SHARED_OUTDIR)/db/db_bench.o $(SHARED_LIBS) $(TESTUTIL) + $(XCRUN) $(CXX) $(LDFLAGS) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(SHARED_OUTDIR)/db/db_bench.o $(TESTUTIL) $(SHARED_OUTDIR)/$(SHARED_LIB3) -o $@ $(LIBS) + +.PHONY: run-shared +run-shared: $(SHARED_OUTDIR)/db_bench + LD_LIBRARY_PATH=$(SHARED_OUTDIR) $(SHARED_OUTDIR)/db_bench + +$(SIMULATOR_OUTDIR)/%.o: %.cc + xcrun -sdk iphonesimulator $(CXX) $(CXXFLAGS) $(SIMULATOR_CFLAGS) -c $< -o $@ + +$(DEVICE_OUTDIR)/%.o: %.cc + xcrun -sdk iphoneos $(CXX) $(CXXFLAGS) $(DEVICE_CFLAGS) -c $< -o $@ + +$(SIMULATOR_OUTDIR)/%.o: %.c + xcrun -sdk iphonesimulator $(CC) $(CFLAGS) $(SIMULATOR_CFLAGS) -c $< -o $@ + +$(DEVICE_OUTDIR)/%.o: %.c + xcrun -sdk iphoneos $(CC) $(CFLAGS) $(DEVICE_CFLAGS) -c $< -o $@ + +$(STATIC_OUTDIR)/%.o: %.cc $(CXX) $(CXXFLAGS) -c $< -o $@ -.c.o: +$(STATIC_OUTDIR)/%.o: %.c $(CC) $(CFLAGS) -c $< -o $@ -endif + +$(SHARED_OUTDIR)/%.o: %.cc + $(CXX) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) -c $< -o $@ + +$(SHARED_OUTDIR)/%.o: %.c + $(CC) $(CFLAGS) $(PLATFORM_SHARED_CFLAGS) -c $< -o $@ + +$(STATIC_OUTDIR)/port/port_posix_sse.o: port/port_posix_sse.cc + $(CXX) $(CXXFLAGS) $(PLATFORM_SSEFLAGS) -c $< -o $@ + +$(SHARED_OUTDIR)/port/port_posix_sse.o: port/port_posix_sse.cc + $(CXX) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(PLATFORM_SSEFLAGS) -c $< -o $@ diff --git a/depend/zcash/src/leveldb/README b/depend/zcash/src/leveldb/README deleted file mode 100644 index 3618adeee..000000000 --- a/depend/zcash/src/leveldb/README +++ /dev/null @@ -1,51 +0,0 @@ -leveldb: A key-value store -Authors: Sanjay Ghemawat (sanjay@google.com) and Jeff Dean (jeff@google.com) - -The code under this directory implements a system for maintaining a -persistent key/value store. - -See doc/index.html for more explanation. -See doc/impl.html for a brief overview of the implementation. - -The public interface is in include/*.h. Callers should not include or -rely on the details of any other header files in this package. Those -internal APIs may be changed without warning. - -Guide to header files: - -include/db.h - Main interface to the DB: Start here - -include/options.h - Control over the behavior of an entire database, and also - control over the behavior of individual reads and writes. - -include/comparator.h - Abstraction for user-specified comparison function. If you want - just bytewise comparison of keys, you can use the default comparator, - but clients can write their own comparator implementations if they - want custom ordering (e.g. to handle different character - encodings, etc.) - -include/iterator.h - Interface for iterating over data. You can get an iterator - from a DB object. - -include/write_batch.h - Interface for atomically applying multiple updates to a database. - -include/slice.h - A simple module for maintaining a pointer and a length into some - other byte array. - -include/status.h - Status is returned from many of the public interfaces and is used - to report success and various kinds of errors. - -include/env.h - Abstraction of the OS environment. A posix implementation of - this interface is in util/env_posix.cc - -include/table.h -include/table_builder.h - Lower-level modules that most clients probably won't use directly diff --git a/depend/zcash/src/leveldb/README.md b/depend/zcash/src/leveldb/README.md index 480affb5c..a010c5085 100644 --- a/depend/zcash/src/leveldb/README.md +++ b/depend/zcash/src/leveldb/README.md @@ -1,5 +1,7 @@ **LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.** +[![Build Status](https://travis-ci.org/google/leveldb.svg?branch=master)](https://travis-ci.org/google/leveldb) + Authors: Sanjay Ghemawat (sanjay@google.com) and Jeff Dean (jeff@google.com) # Features @@ -10,9 +12,11 @@ Authors: Sanjay Ghemawat (sanjay@google.com) and Jeff Dean (jeff@google.com) * Multiple changes can be made in one atomic batch. * Users can create a transient snapshot to get a consistent view of data. * Forward and backward iteration is supported over the data. - * Data is automatically compressed using the [Snappy compression library](http://code.google.com/p/snappy). + * Data is automatically compressed using the [Snappy compression library](http://google.github.io/snappy/). * External activity (file system operations etc.) is relayed through a virtual interface so users can customize the operating system interactions. - * [Detailed documentation](http://htmlpreview.github.io/?https://github.com/google/leveldb/blob/master/doc/index.html) about how to use the library is included with the source code. + +# Documentation + [LevelDB library documentation](https://github.com/google/leveldb/blob/master/doc/index.md) is online and bundled with the source code. # Limitations @@ -20,6 +24,37 @@ Authors: Sanjay Ghemawat (sanjay@google.com) and Jeff Dean (jeff@google.com) * Only a single process (possibly multi-threaded) can access a particular database at a time. * There is no client-server support builtin to the library. An application that needs such support will have to wrap their own server around the library. +# Contributing to the leveldb Project +The leveldb project welcomes contributions. leveldb's primary goal is to be +a reliable and fast key/value store. Changes that are in line with the +features/limitations outlined above, and meet the requirements below, +will be considered. + +Contribution requirements: + +1. **POSIX only**. We _generally_ will only accept changes that are both + compiled, and tested on a POSIX platform - usually Linux. Very small + changes will sometimes be accepted, but consider that more of an + exception than the rule. + +2. **Stable API**. We strive very hard to maintain a stable API. Changes that + require changes for projects using leveldb _might_ be rejected without + sufficient benefit to the project. + +3. **Tests**: All changes must be accompanied by a new (or changed) test, or + a sufficient explanation as to why a new (or changed) test is not required. + +## Submitting a Pull Request +Before any pull request will be accepted the author must first sign a +Contributor License Agreement (CLA) at https://cla.developers.google.com/. + +In order to keep the commit timeline linear +[squash](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Squashing-Commits) +your changes down to a single commit and [rebase](https://git-scm.com/docs/git-rebase) +on google/leveldb/master. This keeps the commit timeline linear and more easily sync'ed +with the internal repository at Google. More information at GitHub's +[About Git rebase](https://help.github.com/articles/about-git-rebase/) page. + # Performance Here is a performance report (with explanations) from the run of the @@ -78,29 +113,30 @@ by the one or two disk seeks needed to fetch the data from disk. Write performance will be mostly unaffected by whether or not the working set fits in memory. - readrandom : 16.677 micros/op; (approximately 60,000 reads per second) - readseq : 0.476 micros/op; 232.3 MB/s - readreverse : 0.724 micros/op; 152.9 MB/s + readrandom : 16.677 micros/op; (approximately 60,000 reads per second) + readseq : 0.476 micros/op; 232.3 MB/s + readreverse : 0.724 micros/op; 152.9 MB/s LevelDB compacts its underlying storage data in the background to improve read performance. The results listed above were done immediately after a lot of random writes. The results after compactions (which are usually triggered automatically) are better. - readrandom : 11.602 micros/op; (approximately 85,000 reads per second) - readseq : 0.423 micros/op; 261.8 MB/s - readreverse : 0.663 micros/op; 166.9 MB/s + readrandom : 11.602 micros/op; (approximately 85,000 reads per second) + readseq : 0.423 micros/op; 261.8 MB/s + readreverse : 0.663 micros/op; 166.9 MB/s Some of the high cost of reads comes from repeated decompression of blocks read from disk. If we supply enough cache to the leveldb so it can hold the uncompressed blocks in memory, the read performance improves again: - readrandom : 9.775 micros/op; (approximately 100,000 reads per second before compaction) - readrandom : 5.215 micros/op; (approximately 190,000 reads per second after compaction) + readrandom : 9.775 micros/op; (approximately 100,000 reads per second before compaction) + readrandom : 5.215 micros/op; (approximately 190,000 reads per second after compaction) ## Repository contents -See doc/index.html for more explanation. See doc/impl.html for a brief overview of the implementation. +See [doc/index.md](doc/index.md) for more explanation. See +[doc/impl.md](doc/impl.md) for a brief overview of the implementation. The public interface is in include/*.h. Callers should not include or rely on the details of any other header files in this package. Those @@ -113,7 +149,7 @@ Guide to header files: * **include/options.h**: Control over the behavior of an entire database, and also control over the behavior of individual reads and writes. -* **include/comparator.h**: Abstraction for user-specified comparison function. +* **include/comparator.h**: Abstraction for user-specified comparison function. If you want just bytewise comparison of keys, you can use the default comparator, but clients can write their own comparator implementations if they want custom ordering (e.g. to handle different character encodings, etc.) @@ -130,7 +166,7 @@ length into some other byte array. * **include/status.h**: Status is returned from many of the public interfaces and is used to report success and various kinds of errors. -* **include/env.h**: +* **include/env.h**: Abstraction of the OS environment. A posix implementation of this interface is in util/env_posix.cc diff --git a/depend/zcash/src/leveldb/build_detect_platform b/depend/zcash/src/leveldb/build_detect_platform index a1101c1bd..ce8f3f9ce 100755 --- a/depend/zcash/src/leveldb/build_detect_platform +++ b/depend/zcash/src/leveldb/build_detect_platform @@ -56,13 +56,14 @@ fi COMMON_FLAGS= CROSS_COMPILE= PLATFORM_CCFLAGS= -PLATFORM_CXXFLAGS= +PLATFORM_CXXFLAGS="-std=c++17" PLATFORM_LDFLAGS= PLATFORM_LIBS= PLATFORM_SHARED_EXT="so" PLATFORM_SHARED_LDFLAGS="-shared -Wl,-soname -Wl," PLATFORM_SHARED_CFLAGS="-fPIC" PLATFORM_SHARED_VERSIONED=true +PLATFORM_SSEFLAGS= MEMCMP_FLAG= if [ "$CXX" = "g++" ]; then @@ -77,6 +78,7 @@ case "$TARGET_OS" in COMMON_FLAGS="$MEMCMP_FLAG -lpthread -DOS_LINUX -DCYGWIN" PLATFORM_LDFLAGS="-lpthread" PORT_FILE=port/port_posix.cc + PORT_SSE_FILE=port/port_posix_sse.cc ;; Darwin) PLATFORM=OS_MACOSX @@ -85,24 +87,28 @@ case "$TARGET_OS" in [ -z "$INSTALL_PATH" ] && INSTALL_PATH=`pwd` PLATFORM_SHARED_LDFLAGS="-dynamiclib -install_name $INSTALL_PATH/" PORT_FILE=port/port_posix.cc + PORT_SSE_FILE=port/port_posix_sse.cc ;; Linux) PLATFORM=OS_LINUX COMMON_FLAGS="$MEMCMP_FLAG -pthread -DOS_LINUX" PLATFORM_LDFLAGS="-pthread" PORT_FILE=port/port_posix.cc + PORT_SSE_FILE=port/port_posix_sse.cc ;; SunOS) PLATFORM=OS_SOLARIS COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_SOLARIS" PLATFORM_LIBS="-lpthread -lrt" PORT_FILE=port/port_posix.cc + PORT_SSE_FILE=port/port_posix_sse.cc ;; FreeBSD) PLATFORM=OS_FREEBSD COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_FREEBSD" PLATFORM_LIBS="-lpthread" PORT_FILE=port/port_posix.cc + PORT_SSE_FILE=port/port_posix_sse.cc ;; GNU/kFreeBSD) PLATFORM=OS_KFREEBSD @@ -115,24 +121,28 @@ case "$TARGET_OS" in COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_NETBSD" PLATFORM_LIBS="-lpthread -lgcc_s" PORT_FILE=port/port_posix.cc + PORT_SSE_FILE=port/port_posix_sse.cc ;; OpenBSD) PLATFORM=OS_OPENBSD COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_OPENBSD" PLATFORM_LDFLAGS="-pthread" PORT_FILE=port/port_posix.cc + PORT_SSE_FILE=port/port_posix_sse.cc ;; DragonFly) PLATFORM=OS_DRAGONFLYBSD COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_DRAGONFLYBSD" PLATFORM_LIBS="-lpthread" PORT_FILE=port/port_posix.cc + PORT_SSE_FILE=port/port_posix_sse.cc ;; OS_ANDROID_CROSSCOMPILE) PLATFORM=OS_ANDROID COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_ANDROID -DLEVELDB_PLATFORM_POSIX" PLATFORM_LDFLAGS="" # All pthread features are in the Android C library PORT_FILE=port/port_posix.cc + PORT_SSE_FILE=port/port_posix_sse.cc CROSS_COMPILE=true ;; HP-UX) @@ -140,6 +150,7 @@ case "$TARGET_OS" in COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_HPUX" PLATFORM_LDFLAGS="-pthread" PORT_FILE=port/port_posix.cc + PORT_SSE_FILE=port/port_posix_sse.cc # man ld: +h internal_name PLATFORM_SHARED_LDFLAGS="-shared -Wl,+h -Wl," ;; @@ -148,6 +159,7 @@ case "$TARGET_OS" in COMMON_FLAGS="$MEMCMP_FLAG -DOS_MACOSX" [ -z "$INSTALL_PATH" ] && INSTALL_PATH=`pwd` PORT_FILE=port/port_posix.cc + PORT_SSE_FILE=port/port_posix_sse.cc PLATFORM_SHARED_EXT= PLATFORM_SHARED_LDFLAGS= PLATFORM_SHARED_CFLAGS= @@ -175,14 +187,14 @@ DIRS="$PREFIX/db $PREFIX/util $PREFIX/table" set -f # temporarily disable globbing so that our patterns aren't expanded PRUNE_TEST="-name *test*.cc -prune" PRUNE_BENCH="-name *_bench.cc -prune" -PRUNE_TOOL="-name leveldb_main.cc -prune" +PRUNE_TOOL="-name leveldbutil.cc -prune" PORTABLE_FILES=`find $DIRS $PRUNE_TEST -o $PRUNE_BENCH -o $PRUNE_TOOL -o -name '*.cc' -print | sort | sed "s,^$PREFIX/,," | tr "\n" " "` set +f # re-enable globbing # The sources consist of the portable files, plus the platform-specific port # file. -echo "SOURCES=$PORTABLE_FILES $PORT_FILE" >> $OUTPUT +echo "SOURCES=$PORTABLE_FILES $PORT_FILE $PORT_SSE_FILE" >> $OUTPUT echo "MEMENV_SOURCES=helpers/memenv/memenv.cc" >> $OUTPUT if [ "$CROSS_COMPILE" = "true" ]; then @@ -191,30 +203,36 @@ if [ "$CROSS_COMPILE" = "true" ]; then else CXXOUTPUT="${TMPDIR}/leveldb_build_detect_platform-cxx.$$" - # If -std=c++0x works, use as fallback for when memory barriers + # As -std=c++17 works, use as fallback for when memory barriers # are not available. - $CXX $CXXFLAGS -std=c++0x -x c++ - -o $CXXOUTPUT 2>/dev/null < + COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT" + + # Test whether tcmalloc is available + $CXX $CXXFLAGS -x c++ - -o $CXXOUTPUT -ltcmalloc 2>/dev/null </dev/null </dev/null + + # Test if gcc SSE 4.2 is supported + $CXX $CXXFLAGS -x c++ - -o $CXXOUTPUT -msse4.2 2>/dev/null </dev/null fi +# Use the SSE 4.2 CRC32C intrinsics iff runtime checks indicate compiler supports them. +if [ -n "$PLATFORM_SSEFLAGS" ]; then + PLATFORM_SSEFLAGS="$PLATFORM_SSEFLAGS -DLEVELDB_PLATFORM_POSIX_SSE" +fi + PLATFORM_CCFLAGS="$PLATFORM_CCFLAGS $COMMON_FLAGS" PLATFORM_CXXFLAGS="$PLATFORM_CXXFLAGS $COMMON_FLAGS" @@ -225,6 +243,7 @@ echo "PLATFORM_LDFLAGS=$PLATFORM_LDFLAGS" >> $OUTPUT echo "PLATFORM_LIBS=$PLATFORM_LIBS" >> $OUTPUT echo "PLATFORM_CCFLAGS=$PLATFORM_CCFLAGS" >> $OUTPUT echo "PLATFORM_CXXFLAGS=$PLATFORM_CXXFLAGS" >> $OUTPUT +echo "PLATFORM_SSEFLAGS=$PLATFORM_SSEFLAGS" >> $OUTPUT echo "PLATFORM_SHARED_CFLAGS=$PLATFORM_SHARED_CFLAGS" >> $OUTPUT echo "PLATFORM_SHARED_EXT=$PLATFORM_SHARED_EXT" >> $OUTPUT echo "PLATFORM_SHARED_LDFLAGS=$PLATFORM_SHARED_LDFLAGS" >> $OUTPUT diff --git a/depend/zcash/src/leveldb/db/c.cc b/depend/zcash/src/leveldb/db/c.cc index 08ff0ad90..b23e3dcc9 100644 --- a/depend/zcash/src/leveldb/db/c.cc +++ b/depend/zcash/src/leveldb/db/c.cc @@ -5,7 +5,9 @@ #include "leveldb/c.h" #include +#ifndef WIN32 #include +#endif #include "leveldb/cache.h" #include "leveldb/comparator.h" #include "leveldb/db.h" diff --git a/depend/zcash/src/leveldb/db/corruption_test.cc b/depend/zcash/src/leveldb/db/corruption_test.cc index 96afc6891..37a484d25 100644 --- a/depend/zcash/src/leveldb/db/corruption_test.cc +++ b/depend/zcash/src/leveldb/db/corruption_test.cc @@ -36,7 +36,7 @@ class CorruptionTest { tiny_cache_ = NewLRUCache(100); options_.env = &env_; options_.block_cache = tiny_cache_; - dbname_ = test::TmpDir() + "/db_test"; + dbname_ = test::TmpDir() + "/corruption_test"; DestroyDB(dbname_, options_); db_ = NULL; diff --git a/depend/zcash/src/leveldb/db/db_bench.cc b/depend/zcash/src/leveldb/db/db_bench.cc index 705a170aa..9ac04c416 100644 --- a/depend/zcash/src/leveldb/db/db_bench.cc +++ b/depend/zcash/src/leveldb/db/db_bench.cc @@ -33,6 +33,7 @@ // readmissing -- read N missing keys in random order // readhot -- read N times in random order from 1% section of DB // seekrandom -- N random seeks +// open -- cost of opening a DB // crc32c -- repeated crc32c of 4K of data // acquireload -- load N*1000 times // Meta operations: @@ -83,6 +84,14 @@ static bool FLAGS_histogram = false; // (initialized to default value by "main") static int FLAGS_write_buffer_size = 0; +// Number of bytes written to each file. +// (initialized to default value by "main") +static int FLAGS_max_file_size = 0; + +// Approximate size of user data packed per block (before compression). +// (initialized to default value by "main") +static int FLAGS_block_size = 0; + // Number of bytes to use as a cache of uncompressed data. // Negative means use default settings. static int FLAGS_cache_size = -1; @@ -99,12 +108,16 @@ static int FLAGS_bloom_bits = -1; // benchmark will fail. static bool FLAGS_use_existing_db = false; +// If true, reuse existing log/MANIFEST files when re-opening a database. +static bool FLAGS_reuse_logs = false; + // Use the db with the following name. static const char* FLAGS_db = NULL; namespace leveldb { namespace { +leveldb::Env* g_env = NULL; // Helper for quickly generating random data. class RandomGenerator { @@ -138,6 +151,7 @@ class RandomGenerator { } }; +#if defined(__linux) static Slice TrimSpace(Slice s) { size_t start = 0; while (start < s.size() && isspace(s[start])) { @@ -149,6 +163,7 @@ static Slice TrimSpace(Slice s) { } return Slice(s.data() + start, limit - start); } +#endif static void AppendWithSpace(std::string* str, Slice msg) { if (msg.empty()) return; @@ -180,7 +195,7 @@ class Stats { done_ = 0; bytes_ = 0; seconds_ = 0; - start_ = Env::Default()->NowMicros(); + start_ = g_env->NowMicros(); finish_ = start_; message_.clear(); } @@ -198,7 +213,7 @@ class Stats { } void Stop() { - finish_ = Env::Default()->NowMicros(); + finish_ = g_env->NowMicros(); seconds_ = (finish_ - start_) * 1e-6; } @@ -208,7 +223,7 @@ class Stats { void FinishedSingleOp() { if (FLAGS_histogram) { - double now = Env::Default()->NowMicros(); + double now = g_env->NowMicros(); double micros = now - last_op_finish_; hist_.Add(micros); if (micros > 20000) { @@ -398,10 +413,10 @@ class Benchmark { reads_(FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads), heap_counter_(0) { std::vector files; - Env::Default()->GetChildren(FLAGS_db, &files); + g_env->GetChildren(FLAGS_db, &files); for (size_t i = 0; i < files.size(); i++) { if (Slice(files[i]).starts_with("heap-")) { - Env::Default()->DeleteFile(std::string(FLAGS_db) + "/" + files[i]); + g_env->DeleteFile(std::string(FLAGS_db) + "/" + files[i]); } } if (!FLAGS_use_existing_db) { @@ -442,7 +457,11 @@ class Benchmark { bool fresh_db = false; int num_threads = FLAGS_threads; - if (name == Slice("fillseq")) { + if (name == Slice("open")) { + method = &Benchmark::OpenBench; + num_ /= 10000; + if (num_ < 1) num_ = 1; + } else if (name == Slice("fillseq")) { fresh_db = true; method = &Benchmark::WriteSeq; } else if (name == Slice("fillbatch")) { @@ -579,7 +598,7 @@ class Benchmark { arg[i].shared = &shared; arg[i].thread = new ThreadState(i); arg[i].thread->shared = &shared; - Env::Default()->StartThread(ThreadBody, &arg[i]); + g_env->StartThread(ThreadBody, &arg[i]); } shared.mu.Lock(); @@ -690,11 +709,15 @@ class Benchmark { void Open() { assert(db_ == NULL); Options options; + options.env = g_env; options.create_if_missing = !FLAGS_use_existing_db; options.block_cache = cache_; options.write_buffer_size = FLAGS_write_buffer_size; + options.max_file_size = FLAGS_max_file_size; + options.block_size = FLAGS_block_size; options.max_open_files = FLAGS_open_files; options.filter_policy = filter_policy_; + options.reuse_logs = FLAGS_reuse_logs; Status s = DB::Open(options, FLAGS_db, &db_); if (!s.ok()) { fprintf(stderr, "open error: %s\n", s.ToString().c_str()); @@ -702,6 +725,14 @@ class Benchmark { } } + void OpenBench(ThreadState* thread) { + for (int i = 0; i < num_; i++) { + delete db_; + Open(); + thread->stats.FinishedSingleOp(); + } + } + void WriteSeq(ThreadState* thread) { DoWrite(thread, true); } @@ -906,7 +937,7 @@ class Benchmark { char fname[100]; snprintf(fname, sizeof(fname), "%s/heap-%04d", FLAGS_db, ++heap_counter_); WritableFile* file; - Status s = Env::Default()->NewWritableFile(fname, &file); + Status s = g_env->NewWritableFile(fname, &file); if (!s.ok()) { fprintf(stderr, "%s\n", s.ToString().c_str()); return; @@ -915,7 +946,7 @@ class Benchmark { delete file; if (!ok) { fprintf(stderr, "heap profiling not supported\n"); - Env::Default()->DeleteFile(fname); + g_env->DeleteFile(fname); } } }; @@ -924,6 +955,8 @@ class Benchmark { int main(int argc, char** argv) { FLAGS_write_buffer_size = leveldb::Options().write_buffer_size; + FLAGS_max_file_size = leveldb::Options().max_file_size; + FLAGS_block_size = leveldb::Options().block_size; FLAGS_open_files = leveldb::Options().max_open_files; std::string default_db_path; @@ -941,6 +974,9 @@ int main(int argc, char** argv) { } else if (sscanf(argv[i], "--use_existing_db=%d%c", &n, &junk) == 1 && (n == 0 || n == 1)) { FLAGS_use_existing_db = n; + } else if (sscanf(argv[i], "--reuse_logs=%d%c", &n, &junk) == 1 && + (n == 0 || n == 1)) { + FLAGS_reuse_logs = n; } else if (sscanf(argv[i], "--num=%d%c", &n, &junk) == 1) { FLAGS_num = n; } else if (sscanf(argv[i], "--reads=%d%c", &n, &junk) == 1) { @@ -951,6 +987,10 @@ int main(int argc, char** argv) { FLAGS_value_size = n; } else if (sscanf(argv[i], "--write_buffer_size=%d%c", &n, &junk) == 1) { FLAGS_write_buffer_size = n; + } else if (sscanf(argv[i], "--max_file_size=%d%c", &n, &junk) == 1) { + FLAGS_max_file_size = n; + } else if (sscanf(argv[i], "--block_size=%d%c", &n, &junk) == 1) { + FLAGS_block_size = n; } else if (sscanf(argv[i], "--cache_size=%d%c", &n, &junk) == 1) { FLAGS_cache_size = n; } else if (sscanf(argv[i], "--bloom_bits=%d%c", &n, &junk) == 1) { @@ -965,9 +1005,11 @@ int main(int argc, char** argv) { } } + leveldb::g_env = leveldb::Env::Default(); + // Choose a location for the test database if none given with --db= if (FLAGS_db == NULL) { - leveldb::Env::Default()->GetTestDirectory(&default_db_path); + leveldb::g_env->GetTestDirectory(&default_db_path); default_db_path += "/dbbench"; FLAGS_db = default_db_path.c_str(); } diff --git a/depend/zcash/src/leveldb/db/db_impl.cc b/depend/zcash/src/leveldb/db/db_impl.cc index 49b95953b..3bb58e560 100644 --- a/depend/zcash/src/leveldb/db/db_impl.cc +++ b/depend/zcash/src/leveldb/db/db_impl.cc @@ -96,6 +96,7 @@ Options SanitizeOptions(const std::string& dbname, result.filter_policy = (src.filter_policy != NULL) ? ipolicy : NULL; ClipToRange(&result.max_open_files, 64 + kNumNonTableCacheFiles, 50000); ClipToRange(&result.write_buffer_size, 64<<10, 1<<30); + ClipToRange(&result.max_file_size, 1<<20, 1<<30); ClipToRange(&result.block_size, 1<<10, 4<<20); if (result.info_log == NULL) { // Open a log file in the same directory as the db @@ -125,7 +126,7 @@ DBImpl::DBImpl(const Options& raw_options, const std::string& dbname) db_lock_(NULL), shutting_down_(NULL), bg_cv_(&mutex_), - mem_(new MemTable(internal_comparator_)), + mem_(NULL), imm_(NULL), logfile_(NULL), logfile_number_(0), @@ -134,7 +135,6 @@ DBImpl::DBImpl(const Options& raw_options, const std::string& dbname) tmp_batch_(new WriteBatch), bg_compaction_scheduled_(false), manual_compaction_(NULL) { - mem_->Ref(); has_imm_.Release_Store(NULL); // Reserve ten files or so for other uses and give the rest to TableCache. @@ -271,7 +271,7 @@ void DBImpl::DeleteObsoleteFiles() { } } -Status DBImpl::Recover(VersionEdit* edit) { +Status DBImpl::Recover(VersionEdit* edit, bool *save_manifest) { mutex_.AssertHeld(); // Ignore error from CreateDir since the creation of the DB is @@ -301,66 +301,69 @@ Status DBImpl::Recover(VersionEdit* edit) { } } - s = versions_->Recover(); - if (s.ok()) { - SequenceNumber max_sequence(0); - - // Recover from all newer log files than the ones named in the - // descriptor (new log files may have been added by the previous - // incarnation without registering them in the descriptor). - // - // Note that PrevLogNumber() is no longer used, but we pay - // attention to it in case we are recovering a database - // produced by an older version of leveldb. - const uint64_t min_log = versions_->LogNumber(); - const uint64_t prev_log = versions_->PrevLogNumber(); - std::vector filenames; - s = env_->GetChildren(dbname_, &filenames); + s = versions_->Recover(save_manifest); + if (!s.ok()) { + return s; + } + SequenceNumber max_sequence(0); + + // Recover from all newer log files than the ones named in the + // descriptor (new log files may have been added by the previous + // incarnation without registering them in the descriptor). + // + // Note that PrevLogNumber() is no longer used, but we pay + // attention to it in case we are recovering a database + // produced by an older version of leveldb. + const uint64_t min_log = versions_->LogNumber(); + const uint64_t prev_log = versions_->PrevLogNumber(); + std::vector filenames; + s = env_->GetChildren(dbname_, &filenames); + if (!s.ok()) { + return s; + } + std::set expected; + versions_->AddLiveFiles(&expected); + uint64_t number; + FileType type; + std::vector logs; + for (size_t i = 0; i < filenames.size(); i++) { + if (ParseFileName(filenames[i], &number, &type)) { + expected.erase(number); + if (type == kLogFile && ((number >= min_log) || (number == prev_log))) + logs.push_back(number); + } + } + if (!expected.empty()) { + char buf[50]; + snprintf(buf, sizeof(buf), "%d missing files; e.g.", + static_cast(expected.size())); + return Status::Corruption(buf, TableFileName(dbname_, *(expected.begin()))); + } + + // Recover in the order in which the logs were generated + std::sort(logs.begin(), logs.end()); + for (size_t i = 0; i < logs.size(); i++) { + s = RecoverLogFile(logs[i], (i == logs.size() - 1), save_manifest, edit, + &max_sequence); if (!s.ok()) { return s; } - std::set expected; - versions_->AddLiveFiles(&expected); - uint64_t number; - FileType type; - std::vector logs; - for (size_t i = 0; i < filenames.size(); i++) { - if (ParseFileName(filenames[i], &number, &type)) { - expected.erase(number); - if (type == kLogFile && ((number >= min_log) || (number == prev_log))) - logs.push_back(number); - } - } - if (!expected.empty()) { - char buf[50]; - snprintf(buf, sizeof(buf), "%d missing files; e.g.", - static_cast(expected.size())); - return Status::Corruption(buf, TableFileName(dbname_, *(expected.begin()))); - } - - // Recover in the order in which the logs were generated - std::sort(logs.begin(), logs.end()); - for (size_t i = 0; i < logs.size(); i++) { - s = RecoverLogFile(logs[i], edit, &max_sequence); - // The previous incarnation may not have written any MANIFEST - // records after allocating this log number. So we manually - // update the file number allocation counter in VersionSet. - versions_->MarkFileNumberUsed(logs[i]); - } + // The previous incarnation may not have written any MANIFEST + // records after allocating this log number. So we manually + // update the file number allocation counter in VersionSet. + versions_->MarkFileNumberUsed(logs[i]); + } - if (s.ok()) { - if (versions_->LastSequence() < max_sequence) { - versions_->SetLastSequence(max_sequence); - } - } + if (versions_->LastSequence() < max_sequence) { + versions_->SetLastSequence(max_sequence); } - return s; + return Status::OK(); } -Status DBImpl::RecoverLogFile(uint64_t log_number, - VersionEdit* edit, +Status DBImpl::RecoverLogFile(uint64_t log_number, bool last_log, + bool* save_manifest, VersionEdit* edit, SequenceNumber* max_sequence) { struct LogReporter : public log::Reader::Reporter { Env* env; @@ -405,12 +408,13 @@ Status DBImpl::RecoverLogFile(uint64_t log_number, std::string scratch; Slice record; WriteBatch batch; + int compactions = 0; MemTable* mem = NULL; while (reader.ReadRecord(&record, &scratch) && status.ok()) { if (record.size() < 12) { reporter.Corruption( - record.size(), Status::Corruption("log record too small")); + record.size(), Status::Corruption("log record too small", fname)); continue; } WriteBatchInternal::SetContents(&batch, record); @@ -432,25 +436,52 @@ Status DBImpl::RecoverLogFile(uint64_t log_number, } if (mem->ApproximateMemoryUsage() > options_.write_buffer_size) { + compactions++; + *save_manifest = true; status = WriteLevel0Table(mem, edit, NULL); + mem->Unref(); + mem = NULL; if (!status.ok()) { // Reflect errors immediately so that conditions like full // file-systems cause the DB::Open() to fail. break; } - mem->Unref(); - mem = NULL; } } - if (status.ok() && mem != NULL) { - status = WriteLevel0Table(mem, edit, NULL); - // Reflect errors immediately so that conditions like full - // file-systems cause the DB::Open() to fail. + delete file; + + // See if we should keep reusing the last log file. + if (status.ok() && options_.reuse_logs && last_log && compactions == 0) { + assert(logfile_ == NULL); + assert(log_ == NULL); + assert(mem_ == NULL); + uint64_t lfile_size; + if (env_->GetFileSize(fname, &lfile_size).ok() && + env_->NewAppendableFile(fname, &logfile_).ok()) { + Log(options_.info_log, "Reusing old log %s \n", fname.c_str()); + log_ = new log::Writer(logfile_, lfile_size); + logfile_number_ = log_number; + if (mem != NULL) { + mem_ = mem; + mem = NULL; + } else { + // mem can be NULL if lognum exists but was empty. + mem_ = new MemTable(internal_comparator_); + mem_->Ref(); + } + } + } + + if (mem != NULL) { + // mem did not get reused; compact it. + if (status.ok()) { + *save_manifest = true; + status = WriteLevel0Table(mem, edit, NULL); + } + mem->Unref(); } - if (mem != NULL) mem->Unref(); - delete file; return status; } @@ -821,8 +852,9 @@ Status DBImpl::FinishCompactionOutputFile(CompactionState* compact, delete iter; if (s.ok()) { Log(options_.info_log, - "Generated table #%llu: %lld keys, %lld bytes", + "Generated table #%llu@%d: %lld keys, %lld bytes", (unsigned long long) output_number, + compact->compaction->level(), (unsigned long long) current_entries, (unsigned long long) current_bytes); } @@ -1395,6 +1427,19 @@ bool DBImpl::GetProperty(const Slice& property, std::string* value) { } else if (in == "sstables") { *value = versions_->current()->DebugString(); return true; + } else if (in == "approximate-memory-usage") { + size_t total_usage = options_.block_cache->TotalCharge(); + if (mem_) { + total_usage += mem_->ApproximateMemoryUsage(); + } + if (imm_) { + total_usage += imm_->ApproximateMemoryUsage(); + } + char buf[50]; + snprintf(buf, sizeof(buf), "%llu", + static_cast(total_usage)); + value->append(buf); + return true; } return false; @@ -1449,8 +1494,11 @@ Status DB::Open(const Options& options, const std::string& dbname, DBImpl* impl = new DBImpl(options, dbname); impl->mutex_.Lock(); VersionEdit edit; - Status s = impl->Recover(&edit); // Handles create_if_missing, error_if_exists - if (s.ok()) { + // Recover handles create_if_missing, error_if_exists + bool save_manifest = false; + Status s = impl->Recover(&edit, &save_manifest); + if (s.ok() && impl->mem_ == NULL) { + // Create new log and a corresponding memtable. uint64_t new_log_number = impl->versions_->NewFileNumber(); WritableFile* lfile; s = options.env->NewWritableFile(LogFileName(dbname, new_log_number), @@ -1460,15 +1508,22 @@ Status DB::Open(const Options& options, const std::string& dbname, impl->logfile_ = lfile; impl->logfile_number_ = new_log_number; impl->log_ = new log::Writer(lfile); - s = impl->versions_->LogAndApply(&edit, &impl->mutex_); - } - if (s.ok()) { - impl->DeleteObsoleteFiles(); - impl->MaybeScheduleCompaction(); + impl->mem_ = new MemTable(impl->internal_comparator_); + impl->mem_->Ref(); } } + if (s.ok() && save_manifest) { + edit.SetPrevLogNumber(0); // No older logs needed after recovery. + edit.SetLogNumber(impl->logfile_number_); + s = impl->versions_->LogAndApply(&edit, &impl->mutex_); + } + if (s.ok()) { + impl->DeleteObsoleteFiles(); + impl->MaybeScheduleCompaction(); + } impl->mutex_.Unlock(); if (s.ok()) { + assert(impl->mem_ != NULL); *dbptr = impl; } else { delete impl; diff --git a/depend/zcash/src/leveldb/db/db_impl.h b/depend/zcash/src/leveldb/db/db_impl.h index cfc998164..8ff323e72 100644 --- a/depend/zcash/src/leveldb/db/db_impl.h +++ b/depend/zcash/src/leveldb/db/db_impl.h @@ -78,7 +78,8 @@ class DBImpl : public DB { // Recover the descriptor from persistent storage. May do a significant // amount of work to recover recently logged updates. Any changes to // be made to the descriptor are added to *edit. - Status Recover(VersionEdit* edit) EXCLUSIVE_LOCKS_REQUIRED(mutex_); + Status Recover(VersionEdit* edit, bool* save_manifest) + EXCLUSIVE_LOCKS_REQUIRED(mutex_); void MaybeIgnoreError(Status* s) const; @@ -90,9 +91,8 @@ class DBImpl : public DB { // Errors are recorded in bg_error_. void CompactMemTable() EXCLUSIVE_LOCKS_REQUIRED(mutex_); - Status RecoverLogFile(uint64_t log_number, - VersionEdit* edit, - SequenceNumber* max_sequence) + Status RecoverLogFile(uint64_t log_number, bool last_log, bool* save_manifest, + VersionEdit* edit, SequenceNumber* max_sequence) EXCLUSIVE_LOCKS_REQUIRED(mutex_); Status WriteLevel0Table(MemTable* mem, VersionEdit* edit, Version* base) diff --git a/depend/zcash/src/leveldb/db/db_test.cc b/depend/zcash/src/leveldb/db/db_test.cc index 0fed9137d..a0b08bc19 100644 --- a/depend/zcash/src/leveldb/db/db_test.cc +++ b/depend/zcash/src/leveldb/db/db_test.cc @@ -193,6 +193,7 @@ class DBTest { // Sequence of option configurations to try enum OptionConfig { kDefault, + kReuse, kFilter, kUncompressed, kEnd @@ -237,7 +238,11 @@ class DBTest { // Return the current option configuration. Options CurrentOptions() { Options options; + options.reuse_logs = false; switch (option_config_) { + case kReuse: + options.reuse_logs = true; + break; case kFilter: options.filter_policy = filter_policy_; break; @@ -558,6 +563,17 @@ TEST(DBTest, GetFromVersions) { } while (ChangeOptions()); } +TEST(DBTest, GetMemUsage) { + do { + ASSERT_OK(Put("foo", "v1")); + std::string val; + ASSERT_TRUE(db_->GetProperty("leveldb.approximate-memory-usage", &val)); + int mem_usage = atoi(val.c_str()); + ASSERT_GT(mem_usage, 0); + ASSERT_LT(mem_usage, 5*1024*1024); + } while (ChangeOptions()); +} + TEST(DBTest, GetSnapshot) { do { // Try with both a short key and a long key @@ -1080,6 +1096,14 @@ TEST(DBTest, ApproximateSizes) { // 0 because GetApproximateSizes() does not account for memtable space ASSERT_TRUE(Between(Size("", Key(50)), 0, 0)); + if (options.reuse_logs) { + // Recovery will reuse memtable, and GetApproximateSizes() does not + // account for memtable usage; + Reopen(&options); + ASSERT_TRUE(Between(Size("", Key(50)), 0, 0)); + continue; + } + // Check sizes across recovery by reopening a few times for (int run = 0; run < 3; run++) { Reopen(&options); @@ -1123,6 +1147,11 @@ TEST(DBTest, ApproximateSizes_MixOfSmallAndLarge) { ASSERT_OK(Put(Key(6), RandomString(&rnd, 300000))); ASSERT_OK(Put(Key(7), RandomString(&rnd, 10000))); + if (options.reuse_logs) { + // Need to force a memtable compaction since recovery does not do so. + ASSERT_OK(dbfull()->TEST_CompactMemTable()); + } + // Check sizes across recovery by reopening a few times for (int run = 0; run < 3; run++) { Reopen(&options); @@ -2084,7 +2113,8 @@ void BM_LogAndApply(int iters, int num_base_files) { InternalKeyComparator cmp(BytewiseComparator()); Options options; VersionSet vset(dbname, &options, NULL, &cmp); - ASSERT_OK(vset.Recover()); + bool save_manifest; + ASSERT_OK(vset.Recover(&save_manifest)); VersionEdit vbase; uint64_t fnum = 1; for (int i = 0; i < num_base_files; i++) { diff --git a/depend/zcash/src/leveldb/db/fault_injection_test.cc b/depend/zcash/src/leveldb/db/fault_injection_test.cc new file mode 100644 index 000000000..875dfe81e --- /dev/null +++ b/depend/zcash/src/leveldb/db/fault_injection_test.cc @@ -0,0 +1,554 @@ +// Copyright 2014 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +// This test uses a custom Env to keep track of the state of a filesystem as of +// the last "sync". It then checks for data loss errors by purposely dropping +// file data (or entire files) not protected by a "sync". + +#include "leveldb/db.h" + +#include +#include +#include "db/db_impl.h" +#include "db/filename.h" +#include "db/log_format.h" +#include "db/version_set.h" +#include "leveldb/cache.h" +#include "leveldb/env.h" +#include "leveldb/table.h" +#include "leveldb/write_batch.h" +#include "util/logging.h" +#include "util/mutexlock.h" +#include "util/testharness.h" +#include "util/testutil.h" + +namespace leveldb { + +static const int kValueSize = 1000; +static const int kMaxNumValues = 2000; +static const size_t kNumIterations = 3; + +class FaultInjectionTestEnv; + +namespace { + +// Assume a filename, and not a directory name like "/foo/bar/" +static std::string GetDirName(const std::string filename) { + size_t found = filename.find_last_of("/\\"); + if (found == std::string::npos) { + return ""; + } else { + return filename.substr(0, found); + } +} + +Status SyncDir(const std::string& dir) { + // As this is a test it isn't required to *actually* sync this directory. + return Status::OK(); +} + +// A basic file truncation function suitable for this test. +Status Truncate(const std::string& filename, uint64_t length) { + leveldb::Env* env = leveldb::Env::Default(); + + SequentialFile* orig_file; + Status s = env->NewSequentialFile(filename, &orig_file); + if (!s.ok()) + return s; + + char* scratch = new char[length]; + leveldb::Slice result; + s = orig_file->Read(length, &result, scratch); + delete orig_file; + if (s.ok()) { + std::string tmp_name = GetDirName(filename) + "/truncate.tmp"; + WritableFile* tmp_file; + s = env->NewWritableFile(tmp_name, &tmp_file); + if (s.ok()) { + s = tmp_file->Append(result); + delete tmp_file; + if (s.ok()) { + s = env->RenameFile(tmp_name, filename); + } else { + env->DeleteFile(tmp_name); + } + } + } + + delete[] scratch; + + return s; +} + +struct FileState { + std::string filename_; + ssize_t pos_; + ssize_t pos_at_last_sync_; + ssize_t pos_at_last_flush_; + + FileState(const std::string& filename) + : filename_(filename), + pos_(-1), + pos_at_last_sync_(-1), + pos_at_last_flush_(-1) { } + + FileState() : pos_(-1), pos_at_last_sync_(-1), pos_at_last_flush_(-1) {} + + bool IsFullySynced() const { return pos_ <= 0 || pos_ == pos_at_last_sync_; } + + Status DropUnsyncedData() const; +}; + +} // anonymous namespace + +// A wrapper around WritableFile which informs another Env whenever this file +// is written to or sync'ed. +class TestWritableFile : public WritableFile { + public: + TestWritableFile(const FileState& state, + WritableFile* f, + FaultInjectionTestEnv* env); + virtual ~TestWritableFile(); + virtual Status Append(const Slice& data); + virtual Status Close(); + virtual Status Flush(); + virtual Status Sync(); + + private: + FileState state_; + WritableFile* target_; + bool writable_file_opened_; + FaultInjectionTestEnv* env_; + + Status SyncParent(); +}; + +class FaultInjectionTestEnv : public EnvWrapper { + public: + FaultInjectionTestEnv() : EnvWrapper(Env::Default()), filesystem_active_(true) {} + virtual ~FaultInjectionTestEnv() { } + virtual Status NewWritableFile(const std::string& fname, + WritableFile** result); + virtual Status NewAppendableFile(const std::string& fname, + WritableFile** result); + virtual Status DeleteFile(const std::string& f); + virtual Status RenameFile(const std::string& s, const std::string& t); + + void WritableFileClosed(const FileState& state); + Status DropUnsyncedFileData(); + Status DeleteFilesCreatedAfterLastDirSync(); + void DirWasSynced(); + bool IsFileCreatedSinceLastDirSync(const std::string& filename); + void ResetState(); + void UntrackFile(const std::string& f); + // Setting the filesystem to inactive is the test equivalent to simulating a + // system reset. Setting to inactive will freeze our saved filesystem state so + // that it will stop being recorded. It can then be reset back to the state at + // the time of the reset. + bool IsFilesystemActive() const { return filesystem_active_; } + void SetFilesystemActive(bool active) { filesystem_active_ = active; } + + private: + port::Mutex mutex_; + std::map db_file_state_; + std::set new_files_since_last_dir_sync_; + bool filesystem_active_; // Record flushes, syncs, writes +}; + +TestWritableFile::TestWritableFile(const FileState& state, + WritableFile* f, + FaultInjectionTestEnv* env) + : state_(state), + target_(f), + writable_file_opened_(true), + env_(env) { + assert(f != NULL); +} + +TestWritableFile::~TestWritableFile() { + if (writable_file_opened_) { + Close(); + } + delete target_; +} + +Status TestWritableFile::Append(const Slice& data) { + Status s = target_->Append(data); + if (s.ok() && env_->IsFilesystemActive()) { + state_.pos_ += data.size(); + } + return s; +} + +Status TestWritableFile::Close() { + writable_file_opened_ = false; + Status s = target_->Close(); + if (s.ok()) { + env_->WritableFileClosed(state_); + } + return s; +} + +Status TestWritableFile::Flush() { + Status s = target_->Flush(); + if (s.ok() && env_->IsFilesystemActive()) { + state_.pos_at_last_flush_ = state_.pos_; + } + return s; +} + +Status TestWritableFile::SyncParent() { + Status s = SyncDir(GetDirName(state_.filename_)); + if (s.ok()) { + env_->DirWasSynced(); + } + return s; +} + +Status TestWritableFile::Sync() { + if (!env_->IsFilesystemActive()) { + return Status::OK(); + } + // Ensure new files referred to by the manifest are in the filesystem. + Status s = target_->Sync(); + if (s.ok()) { + state_.pos_at_last_sync_ = state_.pos_; + } + if (env_->IsFileCreatedSinceLastDirSync(state_.filename_)) { + Status ps = SyncParent(); + if (s.ok() && !ps.ok()) { + s = ps; + } + } + return s; +} + +Status FaultInjectionTestEnv::NewWritableFile(const std::string& fname, + WritableFile** result) { + WritableFile* actual_writable_file; + Status s = target()->NewWritableFile(fname, &actual_writable_file); + if (s.ok()) { + FileState state(fname); + state.pos_ = 0; + *result = new TestWritableFile(state, actual_writable_file, this); + // NewWritableFile doesn't append to files, so if the same file is + // opened again then it will be truncated - so forget our saved + // state. + UntrackFile(fname); + MutexLock l(&mutex_); + new_files_since_last_dir_sync_.insert(fname); + } + return s; +} + +Status FaultInjectionTestEnv::NewAppendableFile(const std::string& fname, + WritableFile** result) { + WritableFile* actual_writable_file; + Status s = target()->NewAppendableFile(fname, &actual_writable_file); + if (s.ok()) { + FileState state(fname); + state.pos_ = 0; + { + MutexLock l(&mutex_); + if (db_file_state_.count(fname) == 0) { + new_files_since_last_dir_sync_.insert(fname); + } else { + state = db_file_state_[fname]; + } + } + *result = new TestWritableFile(state, actual_writable_file, this); + } + return s; +} + +Status FaultInjectionTestEnv::DropUnsyncedFileData() { + Status s; + MutexLock l(&mutex_); + for (std::map::const_iterator it = + db_file_state_.begin(); + s.ok() && it != db_file_state_.end(); ++it) { + const FileState& state = it->second; + if (!state.IsFullySynced()) { + s = state.DropUnsyncedData(); + } + } + return s; +} + +void FaultInjectionTestEnv::DirWasSynced() { + MutexLock l(&mutex_); + new_files_since_last_dir_sync_.clear(); +} + +bool FaultInjectionTestEnv::IsFileCreatedSinceLastDirSync( + const std::string& filename) { + MutexLock l(&mutex_); + return new_files_since_last_dir_sync_.find(filename) != + new_files_since_last_dir_sync_.end(); +} + +void FaultInjectionTestEnv::UntrackFile(const std::string& f) { + MutexLock l(&mutex_); + db_file_state_.erase(f); + new_files_since_last_dir_sync_.erase(f); +} + +Status FaultInjectionTestEnv::DeleteFile(const std::string& f) { + Status s = EnvWrapper::DeleteFile(f); + ASSERT_OK(s); + if (s.ok()) { + UntrackFile(f); + } + return s; +} + +Status FaultInjectionTestEnv::RenameFile(const std::string& s, + const std::string& t) { + Status ret = EnvWrapper::RenameFile(s, t); + + if (ret.ok()) { + MutexLock l(&mutex_); + if (db_file_state_.find(s) != db_file_state_.end()) { + db_file_state_[t] = db_file_state_[s]; + db_file_state_.erase(s); + } + + if (new_files_since_last_dir_sync_.erase(s) != 0) { + assert(new_files_since_last_dir_sync_.find(t) == + new_files_since_last_dir_sync_.end()); + new_files_since_last_dir_sync_.insert(t); + } + } + + return ret; +} + +void FaultInjectionTestEnv::ResetState() { + // Since we are not destroying the database, the existing files + // should keep their recorded synced/flushed state. Therefore + // we do not reset db_file_state_ and new_files_since_last_dir_sync_. + MutexLock l(&mutex_); + SetFilesystemActive(true); +} + +Status FaultInjectionTestEnv::DeleteFilesCreatedAfterLastDirSync() { + // Because DeleteFile access this container make a copy to avoid deadlock + mutex_.Lock(); + std::set new_files(new_files_since_last_dir_sync_.begin(), + new_files_since_last_dir_sync_.end()); + mutex_.Unlock(); + Status s; + std::set::const_iterator it; + for (it = new_files.begin(); s.ok() && it != new_files.end(); ++it) { + s = DeleteFile(*it); + } + return s; +} + +void FaultInjectionTestEnv::WritableFileClosed(const FileState& state) { + MutexLock l(&mutex_); + db_file_state_[state.filename_] = state; +} + +Status FileState::DropUnsyncedData() const { + ssize_t sync_pos = pos_at_last_sync_ == -1 ? 0 : pos_at_last_sync_; + return Truncate(filename_, sync_pos); +} + +class FaultInjectionTest { + public: + enum ExpectedVerifResult { VAL_EXPECT_NO_ERROR, VAL_EXPECT_ERROR }; + enum ResetMethod { RESET_DROP_UNSYNCED_DATA, RESET_DELETE_UNSYNCED_FILES }; + + FaultInjectionTestEnv* env_; + std::string dbname_; + Cache* tiny_cache_; + Options options_; + DB* db_; + + FaultInjectionTest() + : env_(new FaultInjectionTestEnv), + tiny_cache_(NewLRUCache(100)), + db_(NULL) { + dbname_ = test::TmpDir() + "/fault_test"; + DestroyDB(dbname_, Options()); // Destroy any db from earlier run + options_.reuse_logs = true; + options_.env = env_; + options_.paranoid_checks = true; + options_.block_cache = tiny_cache_; + options_.create_if_missing = true; + } + + ~FaultInjectionTest() { + CloseDB(); + DestroyDB(dbname_, Options()); + delete tiny_cache_; + delete env_; + } + + void ReuseLogs(bool reuse) { + options_.reuse_logs = reuse; + } + + void Build(int start_idx, int num_vals) { + std::string key_space, value_space; + WriteBatch batch; + for (int i = start_idx; i < start_idx + num_vals; i++) { + Slice key = Key(i, &key_space); + batch.Clear(); + batch.Put(key, Value(i, &value_space)); + WriteOptions options; + ASSERT_OK(db_->Write(options, &batch)); + } + } + + Status ReadValue(int i, std::string* val) const { + std::string key_space, value_space; + Slice key = Key(i, &key_space); + Value(i, &value_space); + ReadOptions options; + return db_->Get(options, key, val); + } + + Status Verify(int start_idx, int num_vals, + ExpectedVerifResult expected) const { + std::string val; + std::string value_space; + Status s; + for (int i = start_idx; i < start_idx + num_vals && s.ok(); i++) { + Value(i, &value_space); + s = ReadValue(i, &val); + if (expected == VAL_EXPECT_NO_ERROR) { + if (s.ok()) { + ASSERT_EQ(value_space, val); + } + } else if (s.ok()) { + fprintf(stderr, "Expected an error at %d, but was OK\n", i); + s = Status::IOError(dbname_, "Expected value error:"); + } else { + s = Status::OK(); // An expected error + } + } + return s; + } + + // Return the ith key + Slice Key(int i, std::string* storage) const { + char buf[100]; + snprintf(buf, sizeof(buf), "%016d", i); + storage->assign(buf, strlen(buf)); + return Slice(*storage); + } + + // Return the value to associate with the specified key + Slice Value(int k, std::string* storage) const { + Random r(k); + return test::RandomString(&r, kValueSize, storage); + } + + Status OpenDB() { + delete db_; + db_ = NULL; + env_->ResetState(); + return DB::Open(options_, dbname_, &db_); + } + + void CloseDB() { + delete db_; + db_ = NULL; + } + + void DeleteAllData() { + Iterator* iter = db_->NewIterator(ReadOptions()); + WriteOptions options; + for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { + ASSERT_OK(db_->Delete(WriteOptions(), iter->key())); + } + + delete iter; + } + + void ResetDBState(ResetMethod reset_method) { + switch (reset_method) { + case RESET_DROP_UNSYNCED_DATA: + ASSERT_OK(env_->DropUnsyncedFileData()); + break; + case RESET_DELETE_UNSYNCED_FILES: + ASSERT_OK(env_->DeleteFilesCreatedAfterLastDirSync()); + break; + default: + assert(false); + } + } + + void PartialCompactTestPreFault(int num_pre_sync, int num_post_sync) { + DeleteAllData(); + Build(0, num_pre_sync); + db_->CompactRange(NULL, NULL); + Build(num_pre_sync, num_post_sync); + } + + void PartialCompactTestReopenWithFault(ResetMethod reset_method, + int num_pre_sync, + int num_post_sync) { + env_->SetFilesystemActive(false); + CloseDB(); + ResetDBState(reset_method); + ASSERT_OK(OpenDB()); + ASSERT_OK(Verify(0, num_pre_sync, FaultInjectionTest::VAL_EXPECT_NO_ERROR)); + ASSERT_OK(Verify(num_pre_sync, num_post_sync, FaultInjectionTest::VAL_EXPECT_ERROR)); + } + + void NoWriteTestPreFault() { + } + + void NoWriteTestReopenWithFault(ResetMethod reset_method) { + CloseDB(); + ResetDBState(reset_method); + ASSERT_OK(OpenDB()); + } + + void DoTest() { + Random rnd(0); + ASSERT_OK(OpenDB()); + for (size_t idx = 0; idx < kNumIterations; idx++) { + int num_pre_sync = rnd.Uniform(kMaxNumValues); + int num_post_sync = rnd.Uniform(kMaxNumValues); + + PartialCompactTestPreFault(num_pre_sync, num_post_sync); + PartialCompactTestReopenWithFault(RESET_DROP_UNSYNCED_DATA, + num_pre_sync, + num_post_sync); + + NoWriteTestPreFault(); + NoWriteTestReopenWithFault(RESET_DROP_UNSYNCED_DATA); + + PartialCompactTestPreFault(num_pre_sync, num_post_sync); + // No new files created so we expect all values since no files will be + // dropped. + PartialCompactTestReopenWithFault(RESET_DELETE_UNSYNCED_FILES, + num_pre_sync + num_post_sync, + 0); + + NoWriteTestPreFault(); + NoWriteTestReopenWithFault(RESET_DELETE_UNSYNCED_FILES); + } + } +}; + +TEST(FaultInjectionTest, FaultTestNoLogReuse) { + ReuseLogs(false); + DoTest(); +} + +TEST(FaultInjectionTest, FaultTestWithLogReuse) { + ReuseLogs(true); + DoTest(); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/depend/zcash/src/leveldb/db/leveldb_main.cc b/depend/zcash/src/leveldb/db/leveldbutil.cc similarity index 96% rename from depend/zcash/src/leveldb/db/leveldb_main.cc rename to depend/zcash/src/leveldb/db/leveldbutil.cc index 9f4b7dd70..d06d64d64 100644 --- a/depend/zcash/src/leveldb/db/leveldb_main.cc +++ b/depend/zcash/src/leveldb/db/leveldbutil.cc @@ -19,6 +19,7 @@ class StdoutPrinter : public WritableFile { virtual Status Close() { return Status::OK(); } virtual Status Flush() { return Status::OK(); } virtual Status Sync() { return Status::OK(); } + virtual std::string GetName() const { return "[stdout]"; } }; bool HandleDumpCommand(Env* env, char** files, int num) { diff --git a/depend/zcash/src/leveldb/db/log_format.h b/depend/zcash/src/leveldb/db/log_format.h index a8c06efe1..356e69fca 100644 --- a/depend/zcash/src/leveldb/db/log_format.h +++ b/depend/zcash/src/leveldb/db/log_format.h @@ -3,7 +3,7 @@ // found in the LICENSE file. See the AUTHORS file for names of contributors. // // Log format information shared by reader and writer. -// See ../doc/log_format.txt for more detail. +// See ../doc/log_format.md for more detail. #ifndef STORAGE_LEVELDB_DB_LOG_FORMAT_H_ #define STORAGE_LEVELDB_DB_LOG_FORMAT_H_ diff --git a/depend/zcash/src/leveldb/db/log_reader.cc b/depend/zcash/src/leveldb/db/log_reader.cc index e44b66c85..8b6ad136d 100644 --- a/depend/zcash/src/leveldb/db/log_reader.cc +++ b/depend/zcash/src/leveldb/db/log_reader.cc @@ -25,7 +25,8 @@ Reader::Reader(SequentialFile* file, Reporter* reporter, bool checksum, eof_(false), last_record_offset_(0), end_of_buffer_offset_(0), - initial_offset_(initial_offset) { + initial_offset_(initial_offset), + resyncing_(initial_offset > 0) { } Reader::~Reader() { @@ -72,8 +73,25 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch) { Slice fragment; while (true) { - uint64_t physical_record_offset = end_of_buffer_offset_ - buffer_.size(); const unsigned int record_type = ReadPhysicalRecord(&fragment); + + // ReadPhysicalRecord may have only had an empty trailer remaining in its + // internal buffer. Calculate the offset of the next physical record now + // that it has returned, properly accounting for its header size. + uint64_t physical_record_offset = + end_of_buffer_offset_ - buffer_.size() - kHeaderSize - fragment.size(); + + if (resyncing_) { + if (record_type == kMiddleType) { + continue; + } else if (record_type == kLastType) { + resyncing_ = false; + continue; + } else { + resyncing_ = false; + } + } + switch (record_type) { case kFullType: if (in_fragmented_record) { @@ -168,7 +186,7 @@ uint64_t Reader::LastRecordOffset() { } void Reader::ReportCorruption(uint64_t bytes, const char* reason) { - ReportDrop(bytes, Status::Corruption(reason)); + ReportDrop(bytes, Status::Corruption(reason, file_->GetName())); } void Reader::ReportDrop(uint64_t bytes, const Status& reason) { diff --git a/depend/zcash/src/leveldb/db/log_reader.h b/depend/zcash/src/leveldb/db/log_reader.h index 6aff79171..8389d61f8 100644 --- a/depend/zcash/src/leveldb/db/log_reader.h +++ b/depend/zcash/src/leveldb/db/log_reader.h @@ -73,6 +73,11 @@ class Reader { // Offset at which to start looking for the first record to return uint64_t const initial_offset_; + // True if we are resynchronizing after a seek (initial_offset_ > 0). In + // particular, a run of kMiddleType and kLastType records can be silently + // skipped in this mode + bool resyncing_; + // Extend record types with the following special values enum { kEof = kMaxRecordType + 1, diff --git a/depend/zcash/src/leveldb/db/log_test.cc b/depend/zcash/src/leveldb/db/log_test.cc index dcf056265..48a592865 100644 --- a/depend/zcash/src/leveldb/db/log_test.cc +++ b/depend/zcash/src/leveldb/db/log_test.cc @@ -79,7 +79,7 @@ class LogTest { virtual Status Skip(uint64_t n) { if (n > contents_.size()) { contents_.clear(); - return Status::NotFound("in-memory file skipepd past end"); + return Status::NotFound("in-memory file skipped past end"); } contents_.remove_prefix(n); @@ -104,23 +104,34 @@ class LogTest { StringSource source_; ReportCollector report_; bool reading_; - Writer writer_; - Reader reader_; + Writer* writer_; + Reader* reader_; // Record metadata for testing initial offset functionality static size_t initial_offset_record_sizes_[]; static uint64_t initial_offset_last_record_offsets_[]; + static int num_initial_offset_records_; public: LogTest() : reading_(false), - writer_(&dest_), - reader_(&source_, &report_, true/*checksum*/, - 0/*initial_offset*/) { + writer_(new Writer(&dest_)), + reader_(new Reader(&source_, &report_, true/*checksum*/, + 0/*initial_offset*/)) { + } + + ~LogTest() { + delete writer_; + delete reader_; + } + + void ReopenForAppend() { + delete writer_; + writer_ = new Writer(&dest_, dest_.contents_.size()); } void Write(const std::string& msg) { ASSERT_TRUE(!reading_) << "Write() after starting to read"; - writer_.AddRecord(Slice(msg)); + writer_->AddRecord(Slice(msg)); } size_t WrittenBytes() const { @@ -134,7 +145,7 @@ class LogTest { } std::string scratch; Slice record; - if (reader_.ReadRecord(&record, &scratch)) { + if (reader_->ReadRecord(&record, &scratch)) { return record.ToString(); } else { return "EOF"; @@ -182,13 +193,18 @@ class LogTest { } void WriteInitialOffsetLog() { - for (int i = 0; i < 4; i++) { + for (int i = 0; i < num_initial_offset_records_; i++) { std::string record(initial_offset_record_sizes_[i], static_cast('a' + i)); Write(record); } } + void StartReadingAt(uint64_t initial_offset) { + delete reader_; + reader_ = new Reader(&source_, &report_, true/*checksum*/, initial_offset); + } + void CheckOffsetPastEndReturnsNoRecords(uint64_t offset_past_end) { WriteInitialOffsetLog(); reading_ = true; @@ -208,32 +224,48 @@ class LogTest { source_.contents_ = Slice(dest_.contents_); Reader* offset_reader = new Reader(&source_, &report_, true/*checksum*/, initial_offset); - Slice record; - std::string scratch; - ASSERT_TRUE(offset_reader->ReadRecord(&record, &scratch)); - ASSERT_EQ(initial_offset_record_sizes_[expected_record_offset], - record.size()); - ASSERT_EQ(initial_offset_last_record_offsets_[expected_record_offset], - offset_reader->LastRecordOffset()); - ASSERT_EQ((char)('a' + expected_record_offset), record.data()[0]); + + // Read all records from expected_record_offset through the last one. + ASSERT_LT(expected_record_offset, num_initial_offset_records_); + for (; expected_record_offset < num_initial_offset_records_; + ++expected_record_offset) { + Slice record; + std::string scratch; + ASSERT_TRUE(offset_reader->ReadRecord(&record, &scratch)); + ASSERT_EQ(initial_offset_record_sizes_[expected_record_offset], + record.size()); + ASSERT_EQ(initial_offset_last_record_offsets_[expected_record_offset], + offset_reader->LastRecordOffset()); + ASSERT_EQ((char)('a' + expected_record_offset), record.data()[0]); + } delete offset_reader; } - }; size_t LogTest::initial_offset_record_sizes_[] = {10000, // Two sizable records in first block 10000, 2 * log::kBlockSize - 1000, // Span three blocks - 1}; + 1, + 13716, // Consume all but two bytes of block 3. + log::kBlockSize - kHeaderSize, // Consume the entirety of block 4. + }; uint64_t LogTest::initial_offset_last_record_offsets_[] = {0, kHeaderSize + 10000, 2 * (kHeaderSize + 10000), 2 * (kHeaderSize + 10000) + - (2 * log::kBlockSize - 1000) + 3 * kHeaderSize}; + (2 * log::kBlockSize - 1000) + 3 * kHeaderSize, + 2 * (kHeaderSize + 10000) + + (2 * log::kBlockSize - 1000) + 3 * kHeaderSize + + kHeaderSize + 1, + 3 * log::kBlockSize, + }; +// LogTest::initial_offset_last_record_offsets_ must be defined before this. +int LogTest::num_initial_offset_records_ = + sizeof(LogTest::initial_offset_last_record_offsets_)/sizeof(uint64_t); TEST(LogTest, Empty) { ASSERT_EQ("EOF", Read()); @@ -318,6 +350,15 @@ TEST(LogTest, AlignedEof) { ASSERT_EQ("EOF", Read()); } +TEST(LogTest, OpenForAppend) { + Write("hello"); + ReopenForAppend(); + Write("world"); + ASSERT_EQ("hello", Read()); + ASSERT_EQ("world", Read()); + ASSERT_EQ("EOF", Read()); +} + TEST(LogTest, RandomRead) { const int N = 500; Random write_rnd(301); @@ -445,6 +486,22 @@ TEST(LogTest, PartialLastIsIgnored) { ASSERT_EQ(0, DroppedBytes()); } +TEST(LogTest, SkipIntoMultiRecord) { + // Consider a fragmented record: + // first(R1), middle(R1), last(R1), first(R2) + // If initial_offset points to a record after first(R1) but before first(R2) + // incomplete fragment errors are not actual errors, and must be suppressed + // until a new first or full record is encountered. + Write(BigString("foo", 3*kBlockSize)); + Write("correct"); + StartReadingAt(kBlockSize); + + ASSERT_EQ("correct", Read()); + ASSERT_EQ("", ReportMessage()); + ASSERT_EQ(0, DroppedBytes()); + ASSERT_EQ("EOF", Read()); +} + TEST(LogTest, ErrorJoinsRecords) { // Consider two fragmented records: // first(R1) last(R1) first(R2) last(R2) @@ -514,6 +571,10 @@ TEST(LogTest, ReadFourthStart) { 3); } +TEST(LogTest, ReadInitialOffsetIntoBlockPadding) { + CheckInitialOffsetRecord(3 * log::kBlockSize - 3, 5); +} + TEST(LogTest, ReadEnd) { CheckOffsetPastEndReturnsNoRecords(0); } diff --git a/depend/zcash/src/leveldb/db/log_writer.cc b/depend/zcash/src/leveldb/db/log_writer.cc index 2da99ac08..74a03270d 100644 --- a/depend/zcash/src/leveldb/db/log_writer.cc +++ b/depend/zcash/src/leveldb/db/log_writer.cc @@ -12,15 +12,24 @@ namespace leveldb { namespace log { -Writer::Writer(WritableFile* dest) - : dest_(dest), - block_offset_(0) { +static void InitTypeCrc(uint32_t* type_crc) { for (int i = 0; i <= kMaxRecordType; i++) { char t = static_cast(i); - type_crc_[i] = crc32c::Value(&t, 1); + type_crc[i] = crc32c::Value(&t, 1); } } +Writer::Writer(WritableFile* dest) + : dest_(dest), + block_offset_(0) { + InitTypeCrc(type_crc_); +} + +Writer::Writer(WritableFile* dest, uint64_t dest_length) + : dest_(dest), block_offset_(dest_length % kBlockSize) { + InitTypeCrc(type_crc_); +} + Writer::~Writer() { } diff --git a/depend/zcash/src/leveldb/db/log_writer.h b/depend/zcash/src/leveldb/db/log_writer.h index a3a954d96..9e7cc4705 100644 --- a/depend/zcash/src/leveldb/db/log_writer.h +++ b/depend/zcash/src/leveldb/db/log_writer.h @@ -22,6 +22,12 @@ class Writer { // "*dest" must be initially empty. // "*dest" must remain live while this Writer is in use. explicit Writer(WritableFile* dest); + + // Create a writer that will append data to "*dest". + // "*dest" must have initial length "dest_length". + // "*dest" must remain live while this Writer is in use. + Writer(WritableFile* dest, uint64_t dest_length); + ~Writer(); Status AddRecord(const Slice& slice); diff --git a/depend/zcash/src/leveldb/db/memtable.cc b/depend/zcash/src/leveldb/db/memtable.cc index bfec0a7e7..287afdbdc 100644 --- a/depend/zcash/src/leveldb/db/memtable.cc +++ b/depend/zcash/src/leveldb/db/memtable.cc @@ -101,7 +101,7 @@ void MemTable::Add(SequenceNumber s, ValueType type, p += 8; p = EncodeVarint32(p, val_size); memcpy(p, value.data(), val_size); - assert((p + val_size) - buf == encoded_len); + assert(p + val_size == buf + encoded_len); table_.Insert(buf); } diff --git a/depend/zcash/src/leveldb/db/memtable.h b/depend/zcash/src/leveldb/db/memtable.h index 92e90bb09..9f41567cd 100644 --- a/depend/zcash/src/leveldb/db/memtable.h +++ b/depend/zcash/src/leveldb/db/memtable.h @@ -36,10 +36,7 @@ class MemTable { } // Returns an estimate of the number of bytes of data in use by this - // data structure. - // - // REQUIRES: external synchronization to prevent simultaneous - // operations on the same MemTable. + // data structure. It is safe to call when MemTable is being modified. size_t ApproximateMemoryUsage(); // Return an iterator that yields the contents of the memtable. diff --git a/depend/zcash/src/leveldb/db/recovery_test.cc b/depend/zcash/src/leveldb/db/recovery_test.cc new file mode 100644 index 000000000..9596f4288 --- /dev/null +++ b/depend/zcash/src/leveldb/db/recovery_test.cc @@ -0,0 +1,324 @@ +// Copyright (c) 2014 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/db_impl.h" +#include "db/filename.h" +#include "db/version_set.h" +#include "db/write_batch_internal.h" +#include "leveldb/db.h" +#include "leveldb/env.h" +#include "leveldb/write_batch.h" +#include "util/logging.h" +#include "util/testharness.h" +#include "util/testutil.h" + +namespace leveldb { + +class RecoveryTest { + public: + RecoveryTest() : env_(Env::Default()), db_(NULL) { + dbname_ = test::TmpDir() + "/recovery_test"; + DestroyDB(dbname_, Options()); + Open(); + } + + ~RecoveryTest() { + Close(); + DestroyDB(dbname_, Options()); + } + + DBImpl* dbfull() const { return reinterpret_cast(db_); } + Env* env() const { return env_; } + + bool CanAppend() { + WritableFile* tmp; + Status s = env_->NewAppendableFile(CurrentFileName(dbname_), &tmp); + delete tmp; + if (s.IsNotSupportedError()) { + return false; + } else { + return true; + } + } + + void Close() { + delete db_; + db_ = NULL; + } + + void Open(Options* options = NULL) { + Close(); + Options opts; + if (options != NULL) { + opts = *options; + } else { + opts.reuse_logs = true; // TODO(sanjay): test both ways + opts.create_if_missing = true; + } + if (opts.env == NULL) { + opts.env = env_; + } + ASSERT_OK(DB::Open(opts, dbname_, &db_)); + ASSERT_EQ(1, NumLogs()); + } + + Status Put(const std::string& k, const std::string& v) { + return db_->Put(WriteOptions(), k, v); + } + + std::string Get(const std::string& k, const Snapshot* snapshot = NULL) { + std::string result; + Status s = db_->Get(ReadOptions(), k, &result); + if (s.IsNotFound()) { + result = "NOT_FOUND"; + } else if (!s.ok()) { + result = s.ToString(); + } + return result; + } + + std::string ManifestFileName() { + std::string current; + ASSERT_OK(ReadFileToString(env_, CurrentFileName(dbname_), ¤t)); + size_t len = current.size(); + if (len > 0 && current[len-1] == '\n') { + current.resize(len - 1); + } + return dbname_ + "/" + current; + } + + std::string LogName(uint64_t number) { + return LogFileName(dbname_, number); + } + + size_t DeleteLogFiles() { + std::vector logs = GetFiles(kLogFile); + for (size_t i = 0; i < logs.size(); i++) { + ASSERT_OK(env_->DeleteFile(LogName(logs[i]))) << LogName(logs[i]); + } + return logs.size(); + } + + uint64_t FirstLogFile() { + return GetFiles(kLogFile)[0]; + } + + std::vector GetFiles(FileType t) { + std::vector filenames; + ASSERT_OK(env_->GetChildren(dbname_, &filenames)); + std::vector result; + for (size_t i = 0; i < filenames.size(); i++) { + uint64_t number; + FileType type; + if (ParseFileName(filenames[i], &number, &type) && type == t) { + result.push_back(number); + } + } + return result; + } + + int NumLogs() { + return GetFiles(kLogFile).size(); + } + + int NumTables() { + return GetFiles(kTableFile).size(); + } + + uint64_t FileSize(const std::string& fname) { + uint64_t result; + ASSERT_OK(env_->GetFileSize(fname, &result)) << fname; + return result; + } + + void CompactMemTable() { + dbfull()->TEST_CompactMemTable(); + } + + // Directly construct a log file that sets key to val. + void MakeLogFile(uint64_t lognum, SequenceNumber seq, Slice key, Slice val) { + std::string fname = LogFileName(dbname_, lognum); + WritableFile* file; + ASSERT_OK(env_->NewWritableFile(fname, &file)); + log::Writer writer(file); + WriteBatch batch; + batch.Put(key, val); + WriteBatchInternal::SetSequence(&batch, seq); + ASSERT_OK(writer.AddRecord(WriteBatchInternal::Contents(&batch))); + ASSERT_OK(file->Flush()); + delete file; + } + + private: + std::string dbname_; + Env* env_; + DB* db_; +}; + +TEST(RecoveryTest, ManifestReused) { + if (!CanAppend()) { + fprintf(stderr, "skipping test because env does not support appending\n"); + return; + } + ASSERT_OK(Put("foo", "bar")); + Close(); + std::string old_manifest = ManifestFileName(); + Open(); + ASSERT_EQ(old_manifest, ManifestFileName()); + ASSERT_EQ("bar", Get("foo")); + Open(); + ASSERT_EQ(old_manifest, ManifestFileName()); + ASSERT_EQ("bar", Get("foo")); +} + +TEST(RecoveryTest, LargeManifestCompacted) { + if (!CanAppend()) { + fprintf(stderr, "skipping test because env does not support appending\n"); + return; + } + ASSERT_OK(Put("foo", "bar")); + Close(); + std::string old_manifest = ManifestFileName(); + + // Pad with zeroes to make manifest file very big. + { + uint64_t len = FileSize(old_manifest); + WritableFile* file; + ASSERT_OK(env()->NewAppendableFile(old_manifest, &file)); + std::string zeroes(3*1048576 - static_cast(len), 0); + ASSERT_OK(file->Append(zeroes)); + ASSERT_OK(file->Flush()); + delete file; + } + + Open(); + std::string new_manifest = ManifestFileName(); + ASSERT_NE(old_manifest, new_manifest); + ASSERT_GT(10000, FileSize(new_manifest)); + ASSERT_EQ("bar", Get("foo")); + + Open(); + ASSERT_EQ(new_manifest, ManifestFileName()); + ASSERT_EQ("bar", Get("foo")); +} + +TEST(RecoveryTest, NoLogFiles) { + ASSERT_OK(Put("foo", "bar")); + ASSERT_EQ(1, DeleteLogFiles()); + Open(); + ASSERT_EQ("NOT_FOUND", Get("foo")); + Open(); + ASSERT_EQ("NOT_FOUND", Get("foo")); +} + +TEST(RecoveryTest, LogFileReuse) { + if (!CanAppend()) { + fprintf(stderr, "skipping test because env does not support appending\n"); + return; + } + for (int i = 0; i < 2; i++) { + ASSERT_OK(Put("foo", "bar")); + if (i == 0) { + // Compact to ensure current log is empty + CompactMemTable(); + } + Close(); + ASSERT_EQ(1, NumLogs()); + uint64_t number = FirstLogFile(); + if (i == 0) { + ASSERT_EQ(0, FileSize(LogName(number))); + } else { + ASSERT_LT(0, FileSize(LogName(number))); + } + Open(); + ASSERT_EQ(1, NumLogs()); + ASSERT_EQ(number, FirstLogFile()) << "did not reuse log file"; + ASSERT_EQ("bar", Get("foo")); + Open(); + ASSERT_EQ(1, NumLogs()); + ASSERT_EQ(number, FirstLogFile()) << "did not reuse log file"; + ASSERT_EQ("bar", Get("foo")); + } +} + +TEST(RecoveryTest, MultipleMemTables) { + // Make a large log. + const int kNum = 1000; + for (int i = 0; i < kNum; i++) { + char buf[100]; + snprintf(buf, sizeof(buf), "%050d", i); + ASSERT_OK(Put(buf, buf)); + } + ASSERT_EQ(0, NumTables()); + Close(); + ASSERT_EQ(0, NumTables()); + ASSERT_EQ(1, NumLogs()); + uint64_t old_log_file = FirstLogFile(); + + // Force creation of multiple memtables by reducing the write buffer size. + Options opt; + opt.reuse_logs = true; + opt.write_buffer_size = (kNum*100) / 2; + Open(&opt); + ASSERT_LE(2, NumTables()); + ASSERT_EQ(1, NumLogs()); + ASSERT_NE(old_log_file, FirstLogFile()) << "must not reuse log"; + for (int i = 0; i < kNum; i++) { + char buf[100]; + snprintf(buf, sizeof(buf), "%050d", i); + ASSERT_EQ(buf, Get(buf)); + } +} + +TEST(RecoveryTest, MultipleLogFiles) { + ASSERT_OK(Put("foo", "bar")); + Close(); + ASSERT_EQ(1, NumLogs()); + + // Make a bunch of uncompacted log files. + uint64_t old_log = FirstLogFile(); + MakeLogFile(old_log+1, 1000, "hello", "world"); + MakeLogFile(old_log+2, 1001, "hi", "there"); + MakeLogFile(old_log+3, 1002, "foo", "bar2"); + + // Recover and check that all log files were processed. + Open(); + ASSERT_LE(1, NumTables()); + ASSERT_EQ(1, NumLogs()); + uint64_t new_log = FirstLogFile(); + ASSERT_LE(old_log+3, new_log); + ASSERT_EQ("bar2", Get("foo")); + ASSERT_EQ("world", Get("hello")); + ASSERT_EQ("there", Get("hi")); + + // Test that previous recovery produced recoverable state. + Open(); + ASSERT_LE(1, NumTables()); + ASSERT_EQ(1, NumLogs()); + if (CanAppend()) { + ASSERT_EQ(new_log, FirstLogFile()); + } + ASSERT_EQ("bar2", Get("foo")); + ASSERT_EQ("world", Get("hello")); + ASSERT_EQ("there", Get("hi")); + + // Check that introducing an older log file does not cause it to be re-read. + Close(); + MakeLogFile(old_log+1, 2000, "hello", "stale write"); + Open(); + ASSERT_LE(1, NumTables()); + ASSERT_EQ(1, NumLogs()); + if (CanAppend()) { + ASSERT_EQ(new_log, FirstLogFile()); + } + ASSERT_EQ("bar2", Get("foo")); + ASSERT_EQ("world", Get("hello")); + ASSERT_EQ("there", Get("hi")); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/depend/zcash/src/leveldb/db/repair.cc b/depend/zcash/src/leveldb/db/repair.cc index 4cd4bb047..7281e3d34 100644 --- a/depend/zcash/src/leveldb/db/repair.cc +++ b/depend/zcash/src/leveldb/db/repair.cc @@ -203,7 +203,7 @@ class Repairer { while (reader.ReadRecord(&record, &scratch)) { if (record.size() < 12) { reporter.Corruption( - record.size(), Status::Corruption("log record too small")); + record.size(), Status::Corruption("log record too small", logname)); continue; } WriteBatchInternal::SetContents(&batch, record); diff --git a/depend/zcash/src/leveldb/db/skiplist.h b/depend/zcash/src/leveldb/db/skiplist.h index ed8b09220..8bd77764d 100644 --- a/depend/zcash/src/leveldb/db/skiplist.h +++ b/depend/zcash/src/leveldb/db/skiplist.h @@ -1,10 +1,10 @@ -#ifndef STORAGE_LEVELDB_DB_SKIPLIST_H_ -#define STORAGE_LEVELDB_DB_SKIPLIST_H_ - // Copyright (c) 2011 The LevelDB Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. -// + +#ifndef STORAGE_LEVELDB_DB_SKIPLIST_H_ +#define STORAGE_LEVELDB_DB_SKIPLIST_H_ + // Thread safety // ------------- // diff --git a/depend/zcash/src/leveldb/db/skiplist_test.cc b/depend/zcash/src/leveldb/db/skiplist_test.cc index c78f4b4fb..aee1461e1 100644 --- a/depend/zcash/src/leveldb/db/skiplist_test.cc +++ b/depend/zcash/src/leveldb/db/skiplist_test.cc @@ -250,7 +250,7 @@ class ConcurrentTest { // Note that generation 0 is never inserted, so it is ok if // <*,0,*> is missing. ASSERT_TRUE((gen(pos) == 0) || - (gen(pos) > initial_state.Get(key(pos))) + (gen(pos) > static_cast(initial_state.Get(key(pos)))) ) << "key: " << key(pos) << "; gen: " << gen(pos) << "; initgen: " diff --git a/depend/zcash/src/leveldb/db/snapshot.h b/depend/zcash/src/leveldb/db/snapshot.h index e7f8fd2c3..6ed413c42 100644 --- a/depend/zcash/src/leveldb/db/snapshot.h +++ b/depend/zcash/src/leveldb/db/snapshot.h @@ -5,6 +5,7 @@ #ifndef STORAGE_LEVELDB_DB_SNAPSHOT_H_ #define STORAGE_LEVELDB_DB_SNAPSHOT_H_ +#include "db/dbformat.h" #include "leveldb/db.h" namespace leveldb { diff --git a/depend/zcash/src/leveldb/db/version_set.cc b/depend/zcash/src/leveldb/db/version_set.cc index aa83df55e..2cb6d80ed 100644 --- a/depend/zcash/src/leveldb/db/version_set.cc +++ b/depend/zcash/src/leveldb/db/version_set.cc @@ -20,21 +20,29 @@ namespace leveldb { -static const int kTargetFileSize = 2 * 1048576; +static size_t TargetFileSize(const Options* options) { + return options->max_file_size; +} // Maximum bytes of overlaps in grandparent (i.e., level+2) before we // stop building a single file in a level->level+1 compaction. -static const int64_t kMaxGrandParentOverlapBytes = 10 * kTargetFileSize; +static int64_t MaxGrandParentOverlapBytes(const Options* options) { + return 10 * TargetFileSize(options); +} // Maximum number of bytes in all compacted files. We avoid expanding // the lower level file set of a compaction if it would make the // total compaction cover more than this many bytes. -static const int64_t kExpandedCompactionByteSizeLimit = 25 * kTargetFileSize; +static int64_t ExpandedCompactionByteSizeLimit(const Options* options) { + return 25 * TargetFileSize(options); +} -static double MaxBytesForLevel(int level) { +static double MaxBytesForLevel(const Options* options, int level) { // Note: the result for level zero is not really used since we set // the level-0 compaction threshold based on number of files. - double result = 10 * 1048576.0; // Result for both level-0 and level-1 + + // Result for both level-0 and level-1 + double result = 10. * 1048576.0; while (level > 1) { result *= 10; level--; @@ -42,8 +50,9 @@ static double MaxBytesForLevel(int level) { return result; } -static uint64_t MaxFileSizeForLevel(int level) { - return kTargetFileSize; // We could vary per level to reduce number of files? +static uint64_t MaxFileSizeForLevel(const Options* options, int level) { + // We could vary per level to reduce number of files? + return TargetFileSize(options); } static int64_t TotalFileSize(const std::vector& files) { @@ -508,7 +517,7 @@ int Version::PickLevelForMemTableOutput( // Check that file does not overlap too many grandparent bytes. GetOverlappingInputs(level + 2, &start, &limit, &overlaps); const int64_t sum = TotalFileSize(overlaps); - if (sum > kMaxGrandParentOverlapBytes) { + if (sum > MaxGrandParentOverlapBytes(vset_->options_)) { break; } } @@ -893,7 +902,7 @@ Status VersionSet::LogAndApply(VersionEdit* edit, port::Mutex* mu) { return s; } -Status VersionSet::Recover() { +Status VersionSet::Recover(bool *save_manifest) { struct LogReporter : public log::Reader::Reporter { Status* status; virtual void Corruption(size_t bytes, const Status& s) { @@ -1003,11 +1012,49 @@ Status VersionSet::Recover() { last_sequence_ = last_sequence; log_number_ = log_number; prev_log_number_ = prev_log_number; + + // See if we can reuse the existing MANIFEST file. + if (ReuseManifest(dscname, current)) { + // No need to save new manifest + } else { + *save_manifest = true; + } } return s; } +bool VersionSet::ReuseManifest(const std::string& dscname, + const std::string& dscbase) { + if (!options_->reuse_logs) { + return false; + } + FileType manifest_type; + uint64_t manifest_number; + uint64_t manifest_size; + if (!ParseFileName(dscbase, &manifest_number, &manifest_type) || + manifest_type != kDescriptorFile || + !env_->GetFileSize(dscname, &manifest_size).ok() || + // Make new compacted MANIFEST if old one is too big + manifest_size >= TargetFileSize(options_)) { + return false; + } + + assert(descriptor_file_ == NULL); + assert(descriptor_log_ == NULL); + Status r = env_->NewAppendableFile(dscname, &descriptor_file_); + if (!r.ok()) { + Log(options_->info_log, "Reuse MANIFEST: %s\n", r.ToString().c_str()); + assert(descriptor_file_ == NULL); + return false; + } + + Log(options_->info_log, "Reusing MANIFEST %s\n", dscname.c_str()); + descriptor_log_ = new log::Writer(descriptor_file_, manifest_size); + manifest_file_number_ = manifest_number; + return true; +} + void VersionSet::MarkFileNumberUsed(uint64_t number) { if (next_file_number_ <= number) { next_file_number_ = number + 1; @@ -1038,7 +1085,8 @@ void VersionSet::Finalize(Version* v) { } else { // Compute the ratio of current size to size limit. const uint64_t level_bytes = TotalFileSize(v->files_[level]); - score = static_cast(level_bytes) / MaxBytesForLevel(level); + score = + static_cast(level_bytes) / MaxBytesForLevel(options_, level); } if (score > best_score) { @@ -1252,7 +1300,7 @@ Compaction* VersionSet::PickCompaction() { level = current_->compaction_level_; assert(level >= 0); assert(level+1 < config::kNumLevels); - c = new Compaction(level); + c = new Compaction(options_, level); // Pick the first file that comes after compact_pointer_[level] for (size_t i = 0; i < current_->files_[level].size(); i++) { @@ -1269,7 +1317,7 @@ Compaction* VersionSet::PickCompaction() { } } else if (seek_compaction) { level = current_->file_to_compact_level_; - c = new Compaction(level); + c = new Compaction(options_, level); c->inputs_[0].push_back(current_->file_to_compact_); } else { return NULL; @@ -1314,7 +1362,8 @@ void VersionSet::SetupOtherInputs(Compaction* c) { const int64_t inputs1_size = TotalFileSize(c->inputs_[1]); const int64_t expanded0_size = TotalFileSize(expanded0); if (expanded0.size() > c->inputs_[0].size() && - inputs1_size + expanded0_size < kExpandedCompactionByteSizeLimit) { + inputs1_size + expanded0_size < + ExpandedCompactionByteSizeLimit(options_)) { InternalKey new_start, new_limit; GetRange(expanded0, &new_start, &new_limit); std::vector expanded1; @@ -1376,7 +1425,7 @@ Compaction* VersionSet::CompactRange( // and we must not pick one file and drop another older file if the // two files overlap. if (level > 0) { - const uint64_t limit = MaxFileSizeForLevel(level); + const uint64_t limit = MaxFileSizeForLevel(options_, level); uint64_t total = 0; for (size_t i = 0; i < inputs.size(); i++) { uint64_t s = inputs[i]->file_size; @@ -1388,7 +1437,7 @@ Compaction* VersionSet::CompactRange( } } - Compaction* c = new Compaction(level); + Compaction* c = new Compaction(options_, level); c->input_version_ = current_; c->input_version_->Ref(); c->inputs_[0] = inputs; @@ -1396,9 +1445,9 @@ Compaction* VersionSet::CompactRange( return c; } -Compaction::Compaction(int level) +Compaction::Compaction(const Options* options, int level) : level_(level), - max_output_file_size_(MaxFileSizeForLevel(level)), + max_output_file_size_(MaxFileSizeForLevel(options, level)), input_version_(NULL), grandparent_index_(0), seen_key_(false), @@ -1415,12 +1464,13 @@ Compaction::~Compaction() { } bool Compaction::IsTrivialMove() const { + const VersionSet* vset = input_version_->vset_; // Avoid a move if there is lots of overlapping grandparent data. // Otherwise, the move could create a parent file that will require // a very expensive merge later on. - return (num_input_files(0) == 1 && - num_input_files(1) == 0 && - TotalFileSize(grandparents_) <= kMaxGrandParentOverlapBytes); + return (num_input_files(0) == 1 && num_input_files(1) == 0 && + TotalFileSize(grandparents_) <= + MaxGrandParentOverlapBytes(vset->options_)); } void Compaction::AddInputDeletions(VersionEdit* edit) { @@ -1453,8 +1503,9 @@ bool Compaction::IsBaseLevelForKey(const Slice& user_key) { } bool Compaction::ShouldStopBefore(const Slice& internal_key) { + const VersionSet* vset = input_version_->vset_; // Scan to find earliest grandparent file that contains key. - const InternalKeyComparator* icmp = &input_version_->vset_->icmp_; + const InternalKeyComparator* icmp = &vset->icmp_; while (grandparent_index_ < grandparents_.size() && icmp->Compare(internal_key, grandparents_[grandparent_index_]->largest.Encode()) > 0) { @@ -1465,7 +1516,7 @@ bool Compaction::ShouldStopBefore(const Slice& internal_key) { } seen_key_ = true; - if (overlapped_bytes_ > kMaxGrandParentOverlapBytes) { + if (overlapped_bytes_ > MaxGrandParentOverlapBytes(vset->options_)) { // Too much overlap for current output; start new output overlapped_bytes_ = 0; return true; diff --git a/depend/zcash/src/leveldb/db/version_set.h b/depend/zcash/src/leveldb/db/version_set.h index 8dc14b8e0..7935a965a 100644 --- a/depend/zcash/src/leveldb/db/version_set.h +++ b/depend/zcash/src/leveldb/db/version_set.h @@ -179,7 +179,7 @@ class VersionSet { EXCLUSIVE_LOCKS_REQUIRED(mu); // Recover the last saved descriptor from persistent storage. - Status Recover(); + Status Recover(bool *save_manifest); // Return the current version. Version* current() const { return current_; } @@ -274,6 +274,8 @@ class VersionSet { friend class Compaction; friend class Version; + bool ReuseManifest(const std::string& dscname, const std::string& dscbase); + void Finalize(Version* v); void GetRange(const std::vector& inputs, @@ -364,7 +366,7 @@ class Compaction { friend class Version; friend class VersionSet; - explicit Compaction(int level); + Compaction(const Options* options, int level); int level_; uint64_t max_output_file_size_; @@ -374,7 +376,7 @@ class Compaction { // Each compaction reads inputs from "level_" and "level_+1" std::vector inputs_[2]; // The two sets of inputs - // State used to check for number of of overlapping grandparent files + // State used to check for number of overlapping grandparent files // (parent == level_ + 1, grandparent == level_ + 2) std::vector grandparents_; size_t grandparent_index_; // Index in grandparent_starts_ diff --git a/depend/zcash/src/leveldb/db/write_batch_internal.h b/depend/zcash/src/leveldb/db/write_batch_internal.h index 310a3c891..9448ef7b2 100644 --- a/depend/zcash/src/leveldb/db/write_batch_internal.h +++ b/depend/zcash/src/leveldb/db/write_batch_internal.h @@ -5,6 +5,7 @@ #ifndef STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ #define STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ +#include "db/dbformat.h" #include "leveldb/write_batch.h" namespace leveldb { diff --git a/depend/zcash/src/leveldb/doc/doc.css b/depend/zcash/src/leveldb/doc/doc.css deleted file mode 100644 index 700c564e4..000000000 --- a/depend/zcash/src/leveldb/doc/doc.css +++ /dev/null @@ -1,89 +0,0 @@ -body { - margin-left: 0.5in; - margin-right: 0.5in; - background: white; - color: black; -} - -h1 { - margin-left: -0.2in; - font-size: 14pt; -} -h2 { - margin-left: -0in; - font-size: 12pt; -} -h3 { - margin-left: -0in; -} -h4 { - margin-left: -0in; -} -hr { - margin-left: -0in; -} - -/* Definition lists: definition term bold */ -dt { - font-weight: bold; -} - -address { - text-align: center; -} -code,samp,var { - color: blue; -} -kbd { - color: #600000; -} -div.note p { - float: right; - width: 3in; - margin-right: 0%; - padding: 1px; - border: 2px solid #6060a0; - background-color: #fffff0; -} - -ul { - margin-top: -0em; - margin-bottom: -0em; -} - -ol { - margin-top: -0em; - margin-bottom: -0em; -} - -UL.nobullets { - list-style-type: none; - list-style-image: none; - margin-left: -1em; -} - -p { - margin: 1em 0 1em 0; - padding: 0 0 0 0; -} - -pre { - line-height: 1.3em; - padding: 0.4em 0 0.8em 0; - margin: 0 0 0 0; - border: 0 0 0 0; - color: blue; -} - -.datatable { - margin-left: auto; - margin-right: auto; - margin-top: 2em; - margin-bottom: 2em; - border: 1px solid; -} - -.datatable td,th { - padding: 0 0.5em 0 0.5em; - text-align: right; -} diff --git a/depend/zcash/src/leveldb/doc/impl.html b/depend/zcash/src/leveldb/doc/impl.html deleted file mode 100644 index 6a468be09..000000000 --- a/depend/zcash/src/leveldb/doc/impl.html +++ /dev/null @@ -1,213 +0,0 @@ - - - - -Leveldb file layout and compactions - - - - -

Files

- -The implementation of leveldb is similar in spirit to the -representation of a single - -Bigtable tablet (section 5.3). -However the organization of the files that make up the representation -is somewhat different and is explained below. - -

-Each database is represented by a set of files stored in a directory. -There are several different types of files as documented below: -

-

Log files

-

-A log file (*.log) stores a sequence of recent updates. Each update -is appended to the current log file. When the log file reaches a -pre-determined size (approximately 4MB by default), it is converted -to a sorted table (see below) and a new log file is created for future -updates. -

-A copy of the current log file is kept in an in-memory structure (the -memtable). This copy is consulted on every read so that read -operations reflect all logged updates. -

-

Sorted tables

-

-A sorted table (*.sst) stores a sequence of entries sorted by key. -Each entry is either a value for the key, or a deletion marker for the -key. (Deletion markers are kept around to hide obsolete values -present in older sorted tables). -

-The set of sorted tables are organized into a sequence of levels. The -sorted table generated from a log file is placed in a special young -level (also called level-0). When the number of young files exceeds a -certain threshold (currently four), all of the young files are merged -together with all of the overlapping level-1 files to produce a -sequence of new level-1 files (we create a new level-1 file for every -2MB of data.) -

-Files in the young level may contain overlapping keys. However files -in other levels have distinct non-overlapping key ranges. Consider -level number L where L >= 1. When the combined size of files in -level-L exceeds (10^L) MB (i.e., 10MB for level-1, 100MB for level-2, -...), one file in level-L, and all of the overlapping files in -level-(L+1) are merged to form a set of new files for level-(L+1). -These merges have the effect of gradually migrating new updates from -the young level to the largest level using only bulk reads and writes -(i.e., minimizing expensive seeks). - -

Manifest

-

-A MANIFEST file lists the set of sorted tables that make up each -level, the corresponding key ranges, and other important metadata. -A new MANIFEST file (with a new number embedded in the file name) -is created whenever the database is reopened. The MANIFEST file is -formatted as a log, and changes made to the serving state (as files -are added or removed) are appended to this log. -

-

Current

-

-CURRENT is a simple text file that contains the name of the latest -MANIFEST file. -

-

Info logs

-

-Informational messages are printed to files named LOG and LOG.old. -

-

Others

-

-Other files used for miscellaneous purposes may also be present -(LOCK, *.dbtmp). - -

Level 0

-When the log file grows above a certain size (1MB by default): -
    -
  • Create a brand new memtable and log file and direct future updates here -
  • In the background: -
      -
    • Write the contents of the previous memtable to an sstable -
    • Discard the memtable -
    • Delete the old log file and the old memtable -
    • Add the new sstable to the young (level-0) level. -
    -
- -

Compactions

- -

-When the size of level L exceeds its limit, we compact it in a -background thread. The compaction picks a file from level L and all -overlapping files from the next level L+1. Note that if a level-L -file overlaps only part of a level-(L+1) file, the entire file at -level-(L+1) is used as an input to the compaction and will be -discarded after the compaction. Aside: because level-0 is special -(files in it may overlap each other), we treat compactions from -level-0 to level-1 specially: a level-0 compaction may pick more than -one level-0 file in case some of these files overlap each other. - -

-A compaction merges the contents of the picked files to produce a -sequence of level-(L+1) files. We switch to producing a new -level-(L+1) file after the current output file has reached the target -file size (2MB). We also switch to a new output file when the key -range of the current output file has grown enough to overlap more than -ten level-(L+2) files. This last rule ensures that a later compaction -of a level-(L+1) file will not pick up too much data from level-(L+2). - -

-The old files are discarded and the new files are added to the serving -state. - -

-Compactions for a particular level rotate through the key space. In -more detail, for each level L, we remember the ending key of the last -compaction at level L. The next compaction for level L will pick the -first file that starts after this key (wrapping around to the -beginning of the key space if there is no such file). - -

-Compactions drop overwritten values. They also drop deletion markers -if there are no higher numbered levels that contain a file whose range -overlaps the current key. - -

Timing

- -Level-0 compactions will read up to four 1MB files from level-0, and -at worst all the level-1 files (10MB). I.e., we will read 14MB and -write 14MB. - -

-Other than the special level-0 compactions, we will pick one 2MB file -from level L. In the worst case, this will overlap ~ 12 files from -level L+1 (10 because level-(L+1) is ten times the size of level-L, -and another two at the boundaries since the file ranges at level-L -will usually not be aligned with the file ranges at level-L+1). The -compaction will therefore read 26MB and write 26MB. Assuming a disk -IO rate of 100MB/s (ballpark range for modern drives), the worst -compaction cost will be approximately 0.5 second. - -

-If we throttle the background writing to something small, say 10% of -the full 100MB/s speed, a compaction may take up to 5 seconds. If the -user is writing at 10MB/s, we might build up lots of level-0 files -(~50 to hold the 5*10MB). This may significantly increase the cost of -reads due to the overhead of merging more files together on every -read. - -

-Solution 1: To reduce this problem, we might want to increase the log -switching threshold when the number of level-0 files is large. Though -the downside is that the larger this threshold, the more memory we will -need to hold the corresponding memtable. - -

-Solution 2: We might want to decrease write rate artificially when the -number of level-0 files goes up. - -

-Solution 3: We work on reducing the cost of very wide merges. -Perhaps most of the level-0 files will have their blocks sitting -uncompressed in the cache and we will only need to worry about the -O(N) complexity in the merging iterator. - -

Number of files

- -Instead of always making 2MB files, we could make larger files for -larger levels to reduce the total file count, though at the expense of -more bursty compactions. Alternatively, we could shard the set of -files into multiple directories. - -

-An experiment on an ext3 filesystem on Feb 04, 2011 shows -the following timings to do 100K file opens in directories with -varying number of files: - - - - - -
Files in directoryMicroseconds to open a file
10009
1000010
10000016
-So maybe even the sharding is not necessary on modern filesystems? - -

Recovery

- -
    -
  • Read CURRENT to find name of the latest committed MANIFEST -
  • Read the named MANIFEST file -
  • Clean up stale files -
  • We could open all sstables here, but it is probably better to be lazy... -
  • Convert log chunk to a new level-0 sstable -
  • Start directing new writes to a new log file with recovered sequence# -
- -

Garbage collection of files

- -DeleteObsoleteFiles() is called at the end of every -compaction and at the end of recovery. It finds the names of all -files in the database. It deletes all log files that are not the -current log file. It deletes all table files that are not referenced -from some level and are not the output of an active compaction. - - - diff --git a/depend/zcash/src/leveldb/doc/impl.md b/depend/zcash/src/leveldb/doc/impl.md new file mode 100644 index 000000000..4b13f2a6b --- /dev/null +++ b/depend/zcash/src/leveldb/doc/impl.md @@ -0,0 +1,170 @@ +## Files + +The implementation of leveldb is similar in spirit to the representation of a +single [Bigtable tablet (section 5.3)](http://research.google.com/archive/bigtable.html). +However the organization of the files that make up the representation is +somewhat different and is explained below. + +Each database is represented by a set of files stored in a directory. There are +several different types of files as documented below: + +### Log files + +A log file (*.log) stores a sequence of recent updates. Each update is appended +to the current log file. When the log file reaches a pre-determined size +(approximately 4MB by default), it is converted to a sorted table (see below) +and a new log file is created for future updates. + +A copy of the current log file is kept in an in-memory structure (the +`memtable`). This copy is consulted on every read so that read operations +reflect all logged updates. + +## Sorted tables + +A sorted table (*.ldb) stores a sequence of entries sorted by key. Each entry is +either a value for the key, or a deletion marker for the key. (Deletion markers +are kept around to hide obsolete values present in older sorted tables). + +The set of sorted tables are organized into a sequence of levels. The sorted +table generated from a log file is placed in a special **young** level (also +called level-0). When the number of young files exceeds a certain threshold +(currently four), all of the young files are merged together with all of the +overlapping level-1 files to produce a sequence of new level-1 files (we create +a new level-1 file for every 2MB of data.) + +Files in the young level may contain overlapping keys. However files in other +levels have distinct non-overlapping key ranges. Consider level number L where +L >= 1. When the combined size of files in level-L exceeds (10^L) MB (i.e., 10MB +for level-1, 100MB for level-2, ...), one file in level-L, and all of the +overlapping files in level-(L+1) are merged to form a set of new files for +level-(L+1). These merges have the effect of gradually migrating new updates +from the young level to the largest level using only bulk reads and writes +(i.e., minimizing expensive seeks). + +### Manifest + +A MANIFEST file lists the set of sorted tables that make up each level, the +corresponding key ranges, and other important metadata. A new MANIFEST file +(with a new number embedded in the file name) is created whenever the database +is reopened. The MANIFEST file is formatted as a log, and changes made to the +serving state (as files are added or removed) are appended to this log. + +### Current + +CURRENT is a simple text file that contains the name of the latest MANIFEST +file. + +### Info logs + +Informational messages are printed to files named LOG and LOG.old. + +### Others + +Other files used for miscellaneous purposes may also be present (LOCK, *.dbtmp). + +## Level 0 + +When the log file grows above a certain size (1MB by default): +Create a brand new memtable and log file and direct future updates here +In the background: +Write the contents of the previous memtable to an sstable +Discard the memtable +Delete the old log file and the old memtable +Add the new sstable to the young (level-0) level. + +## Compactions + +When the size of level L exceeds its limit, we compact it in a background +thread. The compaction picks a file from level L and all overlapping files from +the next level L+1. Note that if a level-L file overlaps only part of a +level-(L+1) file, the entire file at level-(L+1) is used as an input to the +compaction and will be discarded after the compaction. Aside: because level-0 +is special (files in it may overlap each other), we treat compactions from +level-0 to level-1 specially: a level-0 compaction may pick more than one +level-0 file in case some of these files overlap each other. + +A compaction merges the contents of the picked files to produce a sequence of +level-(L+1) files. We switch to producing a new level-(L+1) file after the +current output file has reached the target file size (2MB). We also switch to a +new output file when the key range of the current output file has grown enough +to overlap more than ten level-(L+2) files. This last rule ensures that a later +compaction of a level-(L+1) file will not pick up too much data from +level-(L+2). + +The old files are discarded and the new files are added to the serving state. + +Compactions for a particular level rotate through the key space. In more detail, +for each level L, we remember the ending key of the last compaction at level L. +The next compaction for level L will pick the first file that starts after this +key (wrapping around to the beginning of the key space if there is no such +file). + +Compactions drop overwritten values. They also drop deletion markers if there +are no higher numbered levels that contain a file whose range overlaps the +current key. + +### Timing + +Level-0 compactions will read up to four 1MB files from level-0, and at worst +all the level-1 files (10MB). I.e., we will read 14MB and write 14MB. + +Other than the special level-0 compactions, we will pick one 2MB file from level +L. In the worst case, this will overlap ~ 12 files from level L+1 (10 because +level-(L+1) is ten times the size of level-L, and another two at the boundaries +since the file ranges at level-L will usually not be aligned with the file +ranges at level-L+1). The compaction will therefore read 26MB and write 26MB. +Assuming a disk IO rate of 100MB/s (ballpark range for modern drives), the worst +compaction cost will be approximately 0.5 second. + +If we throttle the background writing to something small, say 10% of the full +100MB/s speed, a compaction may take up to 5 seconds. If the user is writing at +10MB/s, we might build up lots of level-0 files (~50 to hold the 5*10MB). This +may significantly increase the cost of reads due to the overhead of merging more +files together on every read. + +Solution 1: To reduce this problem, we might want to increase the log switching +threshold when the number of level-0 files is large. Though the downside is that +the larger this threshold, the more memory we will need to hold the +corresponding memtable. + +Solution 2: We might want to decrease write rate artificially when the number of +level-0 files goes up. + +Solution 3: We work on reducing the cost of very wide merges. Perhaps most of +the level-0 files will have their blocks sitting uncompressed in the cache and +we will only need to worry about the O(N) complexity in the merging iterator. + +### Number of files + +Instead of always making 2MB files, we could make larger files for larger levels +to reduce the total file count, though at the expense of more bursty +compactions. Alternatively, we could shard the set of files into multiple +directories. + +An experiment on an ext3 filesystem on Feb 04, 2011 shows the following timings +to do 100K file opens in directories with varying number of files: + + +| Files in directory | Microseconds to open a file | +|-------------------:|----------------------------:| +| 1000 | 9 | +| 10000 | 10 | +| 100000 | 16 | + +So maybe even the sharding is not necessary on modern filesystems? + +## Recovery + +* Read CURRENT to find name of the latest committed MANIFEST +* Read the named MANIFEST file +* Clean up stale files +* We could open all sstables here, but it is probably better to be lazy... +* Convert log chunk to a new level-0 sstable +* Start directing new writes to a new log file with recovered sequence# + +## Garbage collection of files + +`DeleteObsoleteFiles()` is called at the end of every compaction and at the end +of recovery. It finds the names of all files in the database. It deletes all log +files that are not the current log file. It deletes all table files that are not +referenced from some level and are not the output of an active compaction. diff --git a/depend/zcash/src/leveldb/doc/index.html b/depend/zcash/src/leveldb/doc/index.html deleted file mode 100644 index 3ed0ed9d9..000000000 --- a/depend/zcash/src/leveldb/doc/index.html +++ /dev/null @@ -1,549 +0,0 @@ - - - - -Leveldb - - - -

Leveldb

-
Jeff Dean, Sanjay Ghemawat
-

-The leveldb library provides a persistent key value store. Keys and -values are arbitrary byte arrays. The keys are ordered within the key -value store according to a user-specified comparator function. - -

-

Opening A Database

-

-A leveldb database has a name which corresponds to a file system -directory. All of the contents of database are stored in this -directory. The following example shows how to open a database, -creating it if necessary: -

-

-  #include <assert>
-  #include "leveldb/db.h"
-
-  leveldb::DB* db;
-  leveldb::Options options;
-  options.create_if_missing = true;
-  leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);
-  assert(status.ok());
-  ...
-
-If you want to raise an error if the database already exists, add -the following line before the leveldb::DB::Open call: -
-  options.error_if_exists = true;
-
-

Status

-

-You may have noticed the leveldb::Status type above. Values of this -type are returned by most functions in leveldb that may encounter an -error. You can check if such a result is ok, and also print an -associated error message: -

-

-   leveldb::Status s = ...;
-   if (!s.ok()) cerr << s.ToString() << endl;
-
-

Closing A Database

-

-When you are done with a database, just delete the database object. -Example: -

-

-  ... open the db as described above ...
-  ... do something with db ...
-  delete db;
-
-

Reads And Writes

-

-The database provides Put, Delete, and Get methods to -modify/query the database. For example, the following code -moves the value stored under key1 to key2. -

-  std::string value;
-  leveldb::Status s = db->Get(leveldb::ReadOptions(), key1, &value);
-  if (s.ok()) s = db->Put(leveldb::WriteOptions(), key2, value);
-  if (s.ok()) s = db->Delete(leveldb::WriteOptions(), key1);
-
- -

Atomic Updates

-

-Note that if the process dies after the Put of key2 but before the -delete of key1, the same value may be left stored under multiple keys. -Such problems can be avoided by using the WriteBatch class to -atomically apply a set of updates: -

-

-  #include "leveldb/write_batch.h"
-  ...
-  std::string value;
-  leveldb::Status s = db->Get(leveldb::ReadOptions(), key1, &value);
-  if (s.ok()) {
-    leveldb::WriteBatch batch;
-    batch.Delete(key1);
-    batch.Put(key2, value);
-    s = db->Write(leveldb::WriteOptions(), &batch);
-  }
-
-The WriteBatch holds a sequence of edits to be made to the database, -and these edits within the batch are applied in order. Note that we -called Delete before Put so that if key1 is identical to key2, -we do not end up erroneously dropping the value entirely. -

-Apart from its atomicity benefits, WriteBatch may also be used to -speed up bulk updates by placing lots of individual mutations into the -same batch. - -

Synchronous Writes

-By default, each write to leveldb is asynchronous: it -returns after pushing the write from the process into the operating -system. The transfer from operating system memory to the underlying -persistent storage happens asynchronously. The sync flag -can be turned on for a particular write to make the write operation -not return until the data being written has been pushed all the way to -persistent storage. (On Posix systems, this is implemented by calling -either fsync(...) or fdatasync(...) or -msync(..., MS_SYNC) before the write operation returns.) -
-  leveldb::WriteOptions write_options;
-  write_options.sync = true;
-  db->Put(write_options, ...);
-
-Asynchronous writes are often more than a thousand times as fast as -synchronous writes. The downside of asynchronous writes is that a -crash of the machine may cause the last few updates to be lost. Note -that a crash of just the writing process (i.e., not a reboot) will not -cause any loss since even when sync is false, an update -is pushed from the process memory into the operating system before it -is considered done. - -

-Asynchronous writes can often be used safely. For example, when -loading a large amount of data into the database you can handle lost -updates by restarting the bulk load after a crash. A hybrid scheme is -also possible where every Nth write is synchronous, and in the event -of a crash, the bulk load is restarted just after the last synchronous -write finished by the previous run. (The synchronous write can update -a marker that describes where to restart on a crash.) - -

-WriteBatch provides an alternative to asynchronous writes. -Multiple updates may be placed in the same WriteBatch and -applied together using a synchronous write (i.e., -write_options.sync is set to true). The extra cost of -the synchronous write will be amortized across all of the writes in -the batch. - -

-

Concurrency

-

-A database may only be opened by one process at a time. -The leveldb implementation acquires a lock from the -operating system to prevent misuse. Within a single process, the -same leveldb::DB object may be safely shared by multiple -concurrent threads. I.e., different threads may write into or fetch -iterators or call Get on the same database without any -external synchronization (the leveldb implementation will -automatically do the required synchronization). However other objects -(like Iterator and WriteBatch) may require external synchronization. -If two threads share such an object, they must protect access to it -using their own locking protocol. More details are available in -the public header files. -

-

Iteration

-

-The following example demonstrates how to print all key,value pairs -in a database. -

-

-  leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions());
-  for (it->SeekToFirst(); it->Valid(); it->Next()) {
-    cout << it->key().ToString() << ": "  << it->value().ToString() << endl;
-  }
-  assert(it->status().ok());  // Check for any errors found during the scan
-  delete it;
-
-The following variation shows how to process just the keys in the -range [start,limit): -

-

-  for (it->Seek(start);
-       it->Valid() && it->key().ToString() < limit;
-       it->Next()) {
-    ...
-  }
-
-You can also process entries in reverse order. (Caveat: reverse -iteration may be somewhat slower than forward iteration.) -

-

-  for (it->SeekToLast(); it->Valid(); it->Prev()) {
-    ...
-  }
-
-

Snapshots

-

-Snapshots provide consistent read-only views over the entire state of -the key-value store. ReadOptions::snapshot may be non-NULL to indicate -that a read should operate on a particular version of the DB state. -If ReadOptions::snapshot is NULL, the read will operate on an -implicit snapshot of the current state. -

-Snapshots are created by the DB::GetSnapshot() method: -

-

-  leveldb::ReadOptions options;
-  options.snapshot = db->GetSnapshot();
-  ... apply some updates to db ...
-  leveldb::Iterator* iter = db->NewIterator(options);
-  ... read using iter to view the state when the snapshot was created ...
-  delete iter;
-  db->ReleaseSnapshot(options.snapshot);
-
-Note that when a snapshot is no longer needed, it should be released -using the DB::ReleaseSnapshot interface. This allows the -implementation to get rid of state that was being maintained just to -support reading as of that snapshot. -

Slice

-

-The return value of the it->key() and it->value() calls above -are instances of the leveldb::Slice type. Slice is a simple -structure that contains a length and a pointer to an external byte -array. Returning a Slice is a cheaper alternative to returning a -std::string since we do not need to copy potentially large keys and -values. In addition, leveldb methods do not return null-terminated -C-style strings since leveldb keys and values are allowed to -contain '\0' bytes. -

-C++ strings and null-terminated C-style strings can be easily converted -to a Slice: -

-

-   leveldb::Slice s1 = "hello";
-
-   std::string str("world");
-   leveldb::Slice s2 = str;
-
-A Slice can be easily converted back to a C++ string: -
-   std::string str = s1.ToString();
-   assert(str == std::string("hello"));
-
-Be careful when using Slices since it is up to the caller to ensure that -the external byte array into which the Slice points remains live while -the Slice is in use. For example, the following is buggy: -

-

-   leveldb::Slice slice;
-   if (...) {
-     std::string str = ...;
-     slice = str;
-   }
-   Use(slice);
-
-When the if statement goes out of scope, str will be destroyed and the -backing storage for slice will disappear. -

-

Comparators

-

-The preceding examples used the default ordering function for key, -which orders bytes lexicographically. You can however supply a custom -comparator when opening a database. For example, suppose each -database key consists of two numbers and we should sort by the first -number, breaking ties by the second number. First, define a proper -subclass of leveldb::Comparator that expresses these rules: -

-

-  class TwoPartComparator : public leveldb::Comparator {
-   public:
-    // Three-way comparison function:
-    //   if a < b: negative result
-    //   if a > b: positive result
-    //   else: zero result
-    int Compare(const leveldb::Slice& a, const leveldb::Slice& b) const {
-      int a1, a2, b1, b2;
-      ParseKey(a, &a1, &a2);
-      ParseKey(b, &b1, &b2);
-      if (a1 < b1) return -1;
-      if (a1 > b1) return +1;
-      if (a2 < b2) return -1;
-      if (a2 > b2) return +1;
-      return 0;
-    }
-
-    // Ignore the following methods for now:
-    const char* Name() const { return "TwoPartComparator"; }
-    void FindShortestSeparator(std::string*, const leveldb::Slice&) const { }
-    void FindShortSuccessor(std::string*) const { }
-  };
-
-Now create a database using this custom comparator: -

-

-  TwoPartComparator cmp;
-  leveldb::DB* db;
-  leveldb::Options options;
-  options.create_if_missing = true;
-  options.comparator = &cmp;
-  leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);
-  ...
-
-

Backwards compatibility

-

-The result of the comparator's Name method is attached to the -database when it is created, and is checked on every subsequent -database open. If the name changes, the leveldb::DB::Open call will -fail. Therefore, change the name if and only if the new key format -and comparison function are incompatible with existing databases, and -it is ok to discard the contents of all existing databases. -

-You can however still gradually evolve your key format over time with -a little bit of pre-planning. For example, you could store a version -number at the end of each key (one byte should suffice for most uses). -When you wish to switch to a new key format (e.g., adding an optional -third part to the keys processed by TwoPartComparator), -(a) keep the same comparator name (b) increment the version number -for new keys (c) change the comparator function so it uses the -version numbers found in the keys to decide how to interpret them. -

-

Performance

-

-Performance can be tuned by changing the default values of the -types defined in include/leveldb/options.h. - -

-

Block size

-

-leveldb groups adjacent keys together into the same block and such a -block is the unit of transfer to and from persistent storage. The -default block size is approximately 4096 uncompressed bytes. -Applications that mostly do bulk scans over the contents of the -database may wish to increase this size. Applications that do a lot -of point reads of small values may wish to switch to a smaller block -size if performance measurements indicate an improvement. There isn't -much benefit in using blocks smaller than one kilobyte, or larger than -a few megabytes. Also note that compression will be more effective -with larger block sizes. -

-

Compression

-

-Each block is individually compressed before being written to -persistent storage. Compression is on by default since the default -compression method is very fast, and is automatically disabled for -uncompressible data. In rare cases, applications may want to disable -compression entirely, but should only do so if benchmarks show a -performance improvement: -

-

-  leveldb::Options options;
-  options.compression = leveldb::kNoCompression;
-  ... leveldb::DB::Open(options, name, ...) ....
-
-

Cache

-

-The contents of the database are stored in a set of files in the -filesystem and each file stores a sequence of compressed blocks. If -options.cache is non-NULL, it is used to cache frequently used -uncompressed block contents. -

-

-  #include "leveldb/cache.h"
-
-  leveldb::Options options;
-  options.cache = leveldb::NewLRUCache(100 * 1048576);  // 100MB cache
-  leveldb::DB* db;
-  leveldb::DB::Open(options, name, &db);
-  ... use the db ...
-  delete db
-  delete options.cache;
-
-Note that the cache holds uncompressed data, and therefore it should -be sized according to application level data sizes, without any -reduction from compression. (Caching of compressed blocks is left to -the operating system buffer cache, or any custom Env -implementation provided by the client.) -

-When performing a bulk read, the application may wish to disable -caching so that the data processed by the bulk read does not end up -displacing most of the cached contents. A per-iterator option can be -used to achieve this: -

-

-  leveldb::ReadOptions options;
-  options.fill_cache = false;
-  leveldb::Iterator* it = db->NewIterator(options);
-  for (it->SeekToFirst(); it->Valid(); it->Next()) {
-    ...
-  }
-
-

Key Layout

-

-Note that the unit of disk transfer and caching is a block. Adjacent -keys (according to the database sort order) will usually be placed in -the same block. Therefore the application can improve its performance -by placing keys that are accessed together near each other and placing -infrequently used keys in a separate region of the key space. -

-For example, suppose we are implementing a simple file system on top -of leveldb. The types of entries we might wish to store are: -

-

-   filename -> permission-bits, length, list of file_block_ids
-   file_block_id -> data
-
-We might want to prefix filename keys with one letter (say '/') and the -file_block_id keys with a different letter (say '0') so that scans -over just the metadata do not force us to fetch and cache bulky file -contents. -

-

Filters

-

-Because of the way leveldb data is organized on disk, -a single Get() call may involve multiple reads from disk. -The optional FilterPolicy mechanism can be used to reduce -the number of disk reads substantially. -

-   leveldb::Options options;
-   options.filter_policy = NewBloomFilterPolicy(10);
-   leveldb::DB* db;
-   leveldb::DB::Open(options, "/tmp/testdb", &db);
-   ... use the database ...
-   delete db;
-   delete options.filter_policy;
-
-The preceding code associates a -Bloom filter -based filtering policy with the database. Bloom filter based -filtering relies on keeping some number of bits of data in memory per -key (in this case 10 bits per key since that is the argument we passed -to NewBloomFilterPolicy). This filter will reduce the number of unnecessary -disk reads needed for Get() calls by a factor of -approximately a 100. Increasing the bits per key will lead to a -larger reduction at the cost of more memory usage. We recommend that -applications whose working set does not fit in memory and that do a -lot of random reads set a filter policy. -

-If you are using a custom comparator, you should ensure that the filter -policy you are using is compatible with your comparator. For example, -consider a comparator that ignores trailing spaces when comparing keys. -NewBloomFilterPolicy must not be used with such a comparator. -Instead, the application should provide a custom filter policy that -also ignores trailing spaces. For example: -

-  class CustomFilterPolicy : public leveldb::FilterPolicy {
-   private:
-    FilterPolicy* builtin_policy_;
-   public:
-    CustomFilterPolicy() : builtin_policy_(NewBloomFilterPolicy(10)) { }
-    ~CustomFilterPolicy() { delete builtin_policy_; }
-
-    const char* Name() const { return "IgnoreTrailingSpacesFilter"; }
-
-    void CreateFilter(const Slice* keys, int n, std::string* dst) const {
-      // Use builtin bloom filter code after removing trailing spaces
-      std::vector<Slice> trimmed(n);
-      for (int i = 0; i < n; i++) {
-        trimmed[i] = RemoveTrailingSpaces(keys[i]);
-      }
-      return builtin_policy_->CreateFilter(&trimmed[i], n, dst);
-    }
-
-    bool KeyMayMatch(const Slice& key, const Slice& filter) const {
-      // Use builtin bloom filter code after removing trailing spaces
-      return builtin_policy_->KeyMayMatch(RemoveTrailingSpaces(key), filter);
-    }
-  };
-
-

-Advanced applications may provide a filter policy that does not use -a bloom filter but uses some other mechanism for summarizing a set -of keys. See leveldb/filter_policy.h for detail. -

-

Checksums

-

-leveldb associates checksums with all data it stores in the file system. -There are two separate controls provided over how aggressively these -checksums are verified: -

-

    -
  • ReadOptions::verify_checksums may be set to true to force - checksum verification of all data that is read from the file system on - behalf of a particular read. By default, no such verification is - done. -

    -

  • Options::paranoid_checks may be set to true before opening a - database to make the database implementation raise an error as soon as - it detects an internal corruption. Depending on which portion of the - database has been corrupted, the error may be raised when the database - is opened, or later by another database operation. By default, - paranoid checking is off so that the database can be used even if - parts of its persistent storage have been corrupted. -

    - If a database is corrupted (perhaps it cannot be opened when - paranoid checking is turned on), the leveldb::RepairDB function - may be used to recover as much of the data as possible -

    -

-

Approximate Sizes

-

-The GetApproximateSizes method can used to get the approximate -number of bytes of file system space used by one or more key ranges. -

-

-   leveldb::Range ranges[2];
-   ranges[0] = leveldb::Range("a", "c");
-   ranges[1] = leveldb::Range("x", "z");
-   uint64_t sizes[2];
-   leveldb::Status s = db->GetApproximateSizes(ranges, 2, sizes);
-
-The preceding call will set sizes[0] to the approximate number of -bytes of file system space used by the key range [a..c) and -sizes[1] to the approximate number of bytes used by the key range -[x..z). -

-

Environment

-

-All file operations (and other operating system calls) issued by the -leveldb implementation are routed through a leveldb::Env object. -Sophisticated clients may wish to provide their own Env -implementation to get better control. For example, an application may -introduce artificial delays in the file IO paths to limit the impact -of leveldb on other activities in the system. -

-

-  class SlowEnv : public leveldb::Env {
-    .. implementation of the Env interface ...
-  };
-
-  SlowEnv env;
-  leveldb::Options options;
-  options.env = &env;
-  Status s = leveldb::DB::Open(options, ...);
-
-

Porting

-

-leveldb may be ported to a new platform by providing platform -specific implementations of the types/methods/functions exported by -leveldb/port/port.h. See leveldb/port/port_example.h for more -details. -

-In addition, the new platform may need a new default leveldb::Env -implementation. See leveldb/util/env_posix.h for an example. - -

Other Information

- -

-Details about the leveldb implementation may be found in -the following documents: -

- - - diff --git a/depend/zcash/src/leveldb/doc/index.md b/depend/zcash/src/leveldb/doc/index.md new file mode 100644 index 000000000..be8569692 --- /dev/null +++ b/depend/zcash/src/leveldb/doc/index.md @@ -0,0 +1,523 @@ +leveldb +======= + +_Jeff Dean, Sanjay Ghemawat_ + +The leveldb library provides a persistent key value store. Keys and values are +arbitrary byte arrays. The keys are ordered within the key value store +according to a user-specified comparator function. + +## Opening A Database + +A leveldb database has a name which corresponds to a file system directory. All +of the contents of database are stored in this directory. The following example +shows how to open a database, creating it if necessary: + +```c++ +#include +#include "leveldb/db.h" + +leveldb::DB* db; +leveldb::Options options; +options.create_if_missing = true; +leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db); +assert(status.ok()); +... +``` + +If you want to raise an error if the database already exists, add the following +line before the `leveldb::DB::Open` call: + +```c++ +options.error_if_exists = true; +``` + +## Status + +You may have noticed the `leveldb::Status` type above. Values of this type are +returned by most functions in leveldb that may encounter an error. You can check +if such a result is ok, and also print an associated error message: + +```c++ +leveldb::Status s = ...; +if (!s.ok()) cerr << s.ToString() << endl; +``` + +## Closing A Database + +When you are done with a database, just delete the database object. Example: + +```c++ +... open the db as described above ... +... do something with db ... +delete db; +``` + +## Reads And Writes + +The database provides Put, Delete, and Get methods to modify/query the database. +For example, the following code moves the value stored under key1 to key2. + +```c++ +std::string value; +leveldb::Status s = db->Get(leveldb::ReadOptions(), key1, &value); +if (s.ok()) s = db->Put(leveldb::WriteOptions(), key2, value); +if (s.ok()) s = db->Delete(leveldb::WriteOptions(), key1); +``` + +## Atomic Updates + +Note that if the process dies after the Put of key2 but before the delete of +key1, the same value may be left stored under multiple keys. Such problems can +be avoided by using the `WriteBatch` class to atomically apply a set of updates: + +```c++ +#include "leveldb/write_batch.h" +... +std::string value; +leveldb::Status s = db->Get(leveldb::ReadOptions(), key1, &value); +if (s.ok()) { + leveldb::WriteBatch batch; + batch.Delete(key1); + batch.Put(key2, value); + s = db->Write(leveldb::WriteOptions(), &batch); +} +``` + +The `WriteBatch` holds a sequence of edits to be made to the database, and these +edits within the batch are applied in order. Note that we called Delete before +Put so that if key1 is identical to key2, we do not end up erroneously dropping +the value entirely. + +Apart from its atomicity benefits, `WriteBatch` may also be used to speed up +bulk updates by placing lots of individual mutations into the same batch. + +## Synchronous Writes + +By default, each write to leveldb is asynchronous: it returns after pushing the +write from the process into the operating system. The transfer from operating +system memory to the underlying persistent storage happens asynchronously. The +sync flag can be turned on for a particular write to make the write operation +not return until the data being written has been pushed all the way to +persistent storage. (On Posix systems, this is implemented by calling either +`fsync(...)` or `fdatasync(...)` or `msync(..., MS_SYNC)` before the write +operation returns.) + +```c++ +leveldb::WriteOptions write_options; +write_options.sync = true; +db->Put(write_options, ...); +``` + +Asynchronous writes are often more than a thousand times as fast as synchronous +writes. The downside of asynchronous writes is that a crash of the machine may +cause the last few updates to be lost. Note that a crash of just the writing +process (i.e., not a reboot) will not cause any loss since even when sync is +false, an update is pushed from the process memory into the operating system +before it is considered done. + +Asynchronous writes can often be used safely. For example, when loading a large +amount of data into the database you can handle lost updates by restarting the +bulk load after a crash. A hybrid scheme is also possible where every Nth write +is synchronous, and in the event of a crash, the bulk load is restarted just +after the last synchronous write finished by the previous run. (The synchronous +write can update a marker that describes where to restart on a crash.) + +`WriteBatch` provides an alternative to asynchronous writes. Multiple updates +may be placed in the same WriteBatch and applied together using a synchronous +write (i.e., `write_options.sync` is set to true). The extra cost of the +synchronous write will be amortized across all of the writes in the batch. + +## Concurrency + +A database may only be opened by one process at a time. The leveldb +implementation acquires a lock from the operating system to prevent misuse. +Within a single process, the same `leveldb::DB` object may be safely shared by +multiple concurrent threads. I.e., different threads may write into or fetch +iterators or call Get on the same database without any external synchronization +(the leveldb implementation will automatically do the required synchronization). +However other objects (like Iterator and `WriteBatch`) may require external +synchronization. If two threads share such an object, they must protect access +to it using their own locking protocol. More details are available in the public +header files. + +## Iteration + +The following example demonstrates how to print all key,value pairs in a +database. + +```c++ +leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions()); +for (it->SeekToFirst(); it->Valid(); it->Next()) { + cout << it->key().ToString() << ": " << it->value().ToString() << endl; +} +assert(it->status().ok()); // Check for any errors found during the scan +delete it; +``` + +The following variation shows how to process just the keys in the range +[start,limit): + +```c++ +for (it->Seek(start); + it->Valid() && it->key().ToString() < limit; + it->Next()) { + ... +} +``` + +You can also process entries in reverse order. (Caveat: reverse iteration may be +somewhat slower than forward iteration.) + +```c++ +for (it->SeekToLast(); it->Valid(); it->Prev()) { + ... +} +``` + +## Snapshots + +Snapshots provide consistent read-only views over the entire state of the +key-value store. `ReadOptions::snapshot` may be non-NULL to indicate that a +read should operate on a particular version of the DB state. If +`ReadOptions::snapshot` is NULL, the read will operate on an implicit snapshot +of the current state. + +Snapshots are created by the `DB::GetSnapshot()` method: + +```c++ +leveldb::ReadOptions options; +options.snapshot = db->GetSnapshot(); +... apply some updates to db ... +leveldb::Iterator* iter = db->NewIterator(options); +... read using iter to view the state when the snapshot was created ... +delete iter; +db->ReleaseSnapshot(options.snapshot); +``` + +Note that when a snapshot is no longer needed, it should be released using the +`DB::ReleaseSnapshot` interface. This allows the implementation to get rid of +state that was being maintained just to support reading as of that snapshot. + +## Slice + +The return value of the `it->key()` and `it->value()` calls above are instances +of the `leveldb::Slice` type. Slice is a simple structure that contains a length +and a pointer to an external byte array. Returning a Slice is a cheaper +alternative to returning a `std::string` since we do not need to copy +potentially large keys and values. In addition, leveldb methods do not return +null-terminated C-style strings since leveldb keys and values are allowed to +contain `'\0'` bytes. + +C++ strings and null-terminated C-style strings can be easily converted to a +Slice: + +```c++ +leveldb::Slice s1 = "hello"; + +std::string str("world"); +leveldb::Slice s2 = str; +``` + +A Slice can be easily converted back to a C++ string: + +```c++ +std::string str = s1.ToString(); +assert(str == std::string("hello")); +``` + +Be careful when using Slices since it is up to the caller to ensure that the +external byte array into which the Slice points remains live while the Slice is +in use. For example, the following is buggy: + +```c++ +leveldb::Slice slice; +if (...) { + std::string str = ...; + slice = str; +} +Use(slice); +``` + +When the if statement goes out of scope, str will be destroyed and the backing +storage for slice will disappear. + +## Comparators + +The preceding examples used the default ordering function for key, which orders +bytes lexicographically. You can however supply a custom comparator when opening +a database. For example, suppose each database key consists of two numbers and +we should sort by the first number, breaking ties by the second number. First, +define a proper subclass of `leveldb::Comparator` that expresses these rules: + +```c++ +class TwoPartComparator : public leveldb::Comparator { + public: + // Three-way comparison function: + // if a < b: negative result + // if a > b: positive result + // else: zero result + int Compare(const leveldb::Slice& a, const leveldb::Slice& b) const { + int a1, a2, b1, b2; + ParseKey(a, &a1, &a2); + ParseKey(b, &b1, &b2); + if (a1 < b1) return -1; + if (a1 > b1) return +1; + if (a2 < b2) return -1; + if (a2 > b2) return +1; + return 0; + } + + // Ignore the following methods for now: + const char* Name() const { return "TwoPartComparator"; } + void FindShortestSeparator(std::string*, const leveldb::Slice&) const {} + void FindShortSuccessor(std::string*) const {} +}; +``` + +Now create a database using this custom comparator: + +```c++ +TwoPartComparator cmp; +leveldb::DB* db; +leveldb::Options options; +options.create_if_missing = true; +options.comparator = &cmp; +leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db); +... +``` + +### Backwards compatibility + +The result of the comparator's Name method is attached to the database when it +is created, and is checked on every subsequent database open. If the name +changes, the `leveldb::DB::Open` call will fail. Therefore, change the name if +and only if the new key format and comparison function are incompatible with +existing databases, and it is ok to discard the contents of all existing +databases. + +You can however still gradually evolve your key format over time with a little +bit of pre-planning. For example, you could store a version number at the end of +each key (one byte should suffice for most uses). When you wish to switch to a +new key format (e.g., adding an optional third part to the keys processed by +`TwoPartComparator`), (a) keep the same comparator name (b) increment the +version number for new keys (c) change the comparator function so it uses the +version numbers found in the keys to decide how to interpret them. + +## Performance + +Performance can be tuned by changing the default values of the types defined in +`include/leveldb/options.h`. + +### Block size + +leveldb groups adjacent keys together into the same block and such a block is +the unit of transfer to and from persistent storage. The default block size is +approximately 4096 uncompressed bytes. Applications that mostly do bulk scans +over the contents of the database may wish to increase this size. Applications +that do a lot of point reads of small values may wish to switch to a smaller +block size if performance measurements indicate an improvement. There isn't much +benefit in using blocks smaller than one kilobyte, or larger than a few +megabytes. Also note that compression will be more effective with larger block +sizes. + +### Compression + +Each block is individually compressed before being written to persistent +storage. Compression is on by default since the default compression method is +very fast, and is automatically disabled for uncompressible data. In rare cases, +applications may want to disable compression entirely, but should only do so if +benchmarks show a performance improvement: + +```c++ +leveldb::Options options; +options.compression = leveldb::kNoCompression; +... leveldb::DB::Open(options, name, ...) .... +``` + +### Cache + +The contents of the database are stored in a set of files in the filesystem and +each file stores a sequence of compressed blocks. If options.cache is non-NULL, +it is used to cache frequently used uncompressed block contents. + +```c++ +#include "leveldb/cache.h" + +leveldb::Options options; +options.cache = leveldb::NewLRUCache(100 * 1048576); // 100MB cache +leveldb::DB* db; +leveldb::DB::Open(options, name, &db); +... use the db ... +delete db +delete options.cache; +``` + +Note that the cache holds uncompressed data, and therefore it should be sized +according to application level data sizes, without any reduction from +compression. (Caching of compressed blocks is left to the operating system +buffer cache, or any custom Env implementation provided by the client.) + +When performing a bulk read, the application may wish to disable caching so that +the data processed by the bulk read does not end up displacing most of the +cached contents. A per-iterator option can be used to achieve this: + +```c++ +leveldb::ReadOptions options; +options.fill_cache = false; +leveldb::Iterator* it = db->NewIterator(options); +for (it->SeekToFirst(); it->Valid(); it->Next()) { + ... +} +``` + +### Key Layout + +Note that the unit of disk transfer and caching is a block. Adjacent keys +(according to the database sort order) will usually be placed in the same block. +Therefore the application can improve its performance by placing keys that are +accessed together near each other and placing infrequently used keys in a +separate region of the key space. + +For example, suppose we are implementing a simple file system on top of leveldb. +The types of entries we might wish to store are: + + filename -> permission-bits, length, list of file_block_ids + file_block_id -> data + +We might want to prefix filename keys with one letter (say '/') and the +`file_block_id` keys with a different letter (say '0') so that scans over just +the metadata do not force us to fetch and cache bulky file contents. + +### Filters + +Because of the way leveldb data is organized on disk, a single `Get()` call may +involve multiple reads from disk. The optional FilterPolicy mechanism can be +used to reduce the number of disk reads substantially. + +```c++ +leveldb::Options options; +options.filter_policy = NewBloomFilterPolicy(10); +leveldb::DB* db; +leveldb::DB::Open(options, "/tmp/testdb", &db); +... use the database ... +delete db; +delete options.filter_policy; +``` + +The preceding code associates a Bloom filter based filtering policy with the +database. Bloom filter based filtering relies on keeping some number of bits of +data in memory per key (in this case 10 bits per key since that is the argument +we passed to `NewBloomFilterPolicy`). This filter will reduce the number of +unnecessary disk reads needed for Get() calls by a factor of approximately +a 100. Increasing the bits per key will lead to a larger reduction at the cost +of more memory usage. We recommend that applications whose working set does not +fit in memory and that do a lot of random reads set a filter policy. + +If you are using a custom comparator, you should ensure that the filter policy +you are using is compatible with your comparator. For example, consider a +comparator that ignores trailing spaces when comparing keys. +`NewBloomFilterPolicy` must not be used with such a comparator. Instead, the +application should provide a custom filter policy that also ignores trailing +spaces. For example: + +```c++ +class CustomFilterPolicy : public leveldb::FilterPolicy { + private: + FilterPolicy* builtin_policy_; + + public: + CustomFilterPolicy() : builtin_policy_(NewBloomFilterPolicy(10)) {} + ~CustomFilterPolicy() { delete builtin_policy_; } + + const char* Name() const { return "IgnoreTrailingSpacesFilter"; } + + void CreateFilter(const Slice* keys, int n, std::string* dst) const { + // Use builtin bloom filter code after removing trailing spaces + std::vector trimmed(n); + for (int i = 0; i < n; i++) { + trimmed[i] = RemoveTrailingSpaces(keys[i]); + } + return builtin_policy_->CreateFilter(&trimmed[i], n, dst); + } +}; +``` + +Advanced applications may provide a filter policy that does not use a bloom +filter but uses some other mechanism for summarizing a set of keys. See +`leveldb/filter_policy.h` for detail. + +## Checksums + +leveldb associates checksums with all data it stores in the file system. There +are two separate controls provided over how aggressively these checksums are +verified: + +`ReadOptions::verify_checksums` may be set to true to force checksum +verification of all data that is read from the file system on behalf of a +particular read. By default, no such verification is done. + +`Options::paranoid_checks` may be set to true before opening a database to make +the database implementation raise an error as soon as it detects an internal +corruption. Depending on which portion of the database has been corrupted, the +error may be raised when the database is opened, or later by another database +operation. By default, paranoid checking is off so that the database can be used +even if parts of its persistent storage have been corrupted. + +If a database is corrupted (perhaps it cannot be opened when paranoid checking +is turned on), the `leveldb::RepairDB` function may be used to recover as much +of the data as possible + +## Approximate Sizes + +The `GetApproximateSizes` method can used to get the approximate number of bytes +of file system space used by one or more key ranges. + +```c++ +leveldb::Range ranges[2]; +ranges[0] = leveldb::Range("a", "c"); +ranges[1] = leveldb::Range("x", "z"); +uint64_t sizes[2]; +leveldb::Status s = db->GetApproximateSizes(ranges, 2, sizes); +``` + +The preceding call will set `sizes[0]` to the approximate number of bytes of +file system space used by the key range `[a..c)` and `sizes[1]` to the +approximate number of bytes used by the key range `[x..z)`. + +## Environment + +All file operations (and other operating system calls) issued by the leveldb +implementation are routed through a `leveldb::Env` object. Sophisticated clients +may wish to provide their own Env implementation to get better control. +For example, an application may introduce artificial delays in the file IO +paths to limit the impact of leveldb on other activities in the system. + +```c++ +class SlowEnv : public leveldb::Env { + ... implementation of the Env interface ... +}; + +SlowEnv env; +leveldb::Options options; +options.env = &env; +Status s = leveldb::DB::Open(options, ...); +``` + +## Porting + +leveldb may be ported to a new platform by providing platform specific +implementations of the types/methods/functions exported by +`leveldb/port/port.h`. See `leveldb/port/port_example.h` for more details. + +In addition, the new platform may need a new default `leveldb::Env` +implementation. See `leveldb/util/env_posix.h` for an example. + +## Other Information + +Details about the leveldb implementation may be found in the following +documents: + +1. [Implementation notes](impl.md) +2. [Format of an immutable Table file](table_format.md) +3. [Format of a log file](log_format.md) diff --git a/depend/zcash/src/leveldb/doc/log_format.md b/depend/zcash/src/leveldb/doc/log_format.md new file mode 100644 index 000000000..f32cb5d7d --- /dev/null +++ b/depend/zcash/src/leveldb/doc/log_format.md @@ -0,0 +1,75 @@ +leveldb Log format +================== +The log file contents are a sequence of 32KB blocks. The only exception is that +the tail of the file may contain a partial block. + +Each block consists of a sequence of records: + + block := record* trailer? + record := + checksum: uint32 // crc32c of type and data[] ; little-endian + length: uint16 // little-endian + type: uint8 // One of FULL, FIRST, MIDDLE, LAST + data: uint8[length] + +A record never starts within the last six bytes of a block (since it won't fit). +Any leftover bytes here form the trailer, which must consist entirely of zero +bytes and must be skipped by readers. + +Aside: if exactly seven bytes are left in the current block, and a new non-zero +length record is added, the writer must emit a FIRST record (which contains zero +bytes of user data) to fill up the trailing seven bytes of the block and then +emit all of the user data in subsequent blocks. + +More types may be added in the future. Some Readers may skip record types they +do not understand, others may report that some data was skipped. + + FULL == 1 + FIRST == 2 + MIDDLE == 3 + LAST == 4 + +The FULL record contains the contents of an entire user record. + +FIRST, MIDDLE, LAST are types used for user records that have been split into +multiple fragments (typically because of block boundaries). FIRST is the type +of the first fragment of a user record, LAST is the type of the last fragment of +a user record, and MIDDLE is the type of all interior fragments of a user +record. + +Example: consider a sequence of user records: + + A: length 1000 + B: length 97270 + C: length 8000 + +**A** will be stored as a FULL record in the first block. + +**B** will be split into three fragments: first fragment occupies the rest of +the first block, second fragment occupies the entirety of the second block, and +the third fragment occupies a prefix of the third block. This will leave six +bytes free in the third block, which will be left empty as the trailer. + +**C** will be stored as a FULL record in the fourth block. + +---- + +## Some benefits over the recordio format: + +1. We do not need any heuristics for resyncing - just go to next block boundary + and scan. If there is a corruption, skip to the next block. As a + side-benefit, we do not get confused when part of the contents of one log + file are embedded as a record inside another log file. + +2. Splitting at approximate boundaries (e.g., for mapreduce) is simple: find the + next block boundary and skip records until we hit a FULL or FIRST record. + +3. We do not need extra buffering for large records. + +## Some downsides compared to recordio format: + +1. No packing of tiny records. This could be fixed by adding a new record type, + so it is a shortcoming of the current implementation, not necessarily the + format. + +2. No compression. Again, this could be fixed by adding new record types. diff --git a/depend/zcash/src/leveldb/doc/log_format.txt b/depend/zcash/src/leveldb/doc/log_format.txt deleted file mode 100644 index 4cca5ef6e..000000000 --- a/depend/zcash/src/leveldb/doc/log_format.txt +++ /dev/null @@ -1,75 +0,0 @@ -The log file contents are a sequence of 32KB blocks. The only -exception is that the tail of the file may contain a partial block. - -Each block consists of a sequence of records: - block := record* trailer? - record := - checksum: uint32 // crc32c of type and data[] ; little-endian - length: uint16 // little-endian - type: uint8 // One of FULL, FIRST, MIDDLE, LAST - data: uint8[length] - -A record never starts within the last six bytes of a block (since it -won't fit). Any leftover bytes here form the trailer, which must -consist entirely of zero bytes and must be skipped by readers. - -Aside: if exactly seven bytes are left in the current block, and a new -non-zero length record is added, the writer must emit a FIRST record -(which contains zero bytes of user data) to fill up the trailing seven -bytes of the block and then emit all of the user data in subsequent -blocks. - -More types may be added in the future. Some Readers may skip record -types they do not understand, others may report that some data was -skipped. - -FULL == 1 -FIRST == 2 -MIDDLE == 3 -LAST == 4 - -The FULL record contains the contents of an entire user record. - -FIRST, MIDDLE, LAST are types used for user records that have been -split into multiple fragments (typically because of block boundaries). -FIRST is the type of the first fragment of a user record, LAST is the -type of the last fragment of a user record, and MIDDLE is the type of -all interior fragments of a user record. - -Example: consider a sequence of user records: - A: length 1000 - B: length 97270 - C: length 8000 -A will be stored as a FULL record in the first block. - -B will be split into three fragments: first fragment occupies the rest -of the first block, second fragment occupies the entirety of the -second block, and the third fragment occupies a prefix of the third -block. This will leave six bytes free in the third block, which will -be left empty as the trailer. - -C will be stored as a FULL record in the fourth block. - -=================== - -Some benefits over the recordio format: - -(1) We do not need any heuristics for resyncing - just go to next -block boundary and scan. If there is a corruption, skip to the next -block. As a side-benefit, we do not get confused when part of the -contents of one log file are embedded as a record inside another log -file. - -(2) Splitting at approximate boundaries (e.g., for mapreduce) is -simple: find the next block boundary and skip records until we -hit a FULL or FIRST record. - -(3) We do not need extra buffering for large records. - -Some downsides compared to recordio format: - -(1) No packing of tiny records. This could be fixed by adding a new -record type, so it is a shortcoming of the current implementation, -not necessarily the format. - -(2) No compression. Again, this could be fixed by adding new record types. diff --git a/depend/zcash/src/leveldb/doc/table_format.md b/depend/zcash/src/leveldb/doc/table_format.md new file mode 100644 index 000000000..5fe7e7241 --- /dev/null +++ b/depend/zcash/src/leveldb/doc/table_format.md @@ -0,0 +1,107 @@ +leveldb File format +=================== + + + [data block 1] + [data block 2] + ... + [data block N] + [meta block 1] + ... + [meta block K] + [metaindex block] + [index block] + [Footer] (fixed size; starts at file_size - sizeof(Footer)) + + +The file contains internal pointers. Each such pointer is called +a BlockHandle and contains the following information: + + offset: varint64 + size: varint64 + +See [varints](https://developers.google.com/protocol-buffers/docs/encoding#varints) +for an explanation of varint64 format. + +1. The sequence of key/value pairs in the file are stored in sorted +order and partitioned into a sequence of data blocks. These blocks +come one after another at the beginning of the file. Each data block +is formatted according to the code in `block_builder.cc`, and then +optionally compressed. + +2. After the data blocks we store a bunch of meta blocks. The +supported meta block types are described below. More meta block types +may be added in the future. Each meta block is again formatted using +`block_builder.cc` and then optionally compressed. + +3. A "metaindex" block. It contains one entry for every other meta +block where the key is the name of the meta block and the value is a +BlockHandle pointing to that meta block. + +4. An "index" block. This block contains one entry per data block, +where the key is a string >= last key in that data block and before +the first key in the successive data block. The value is the +BlockHandle for the data block. + +5. At the very end of the file is a fixed length footer that contains +the BlockHandle of the metaindex and index blocks as well as a magic number. + + metaindex_handle: char[p]; // Block handle for metaindex + index_handle: char[q]; // Block handle for index + padding: char[40-p-q];// zeroed bytes to make fixed length + // (40==2*BlockHandle::kMaxEncodedLength) + magic: fixed64; // == 0xdb4775248b80fb57 (little-endian) + +## "filter" Meta Block + +If a `FilterPolicy` was specified when the database was opened, a +filter block is stored in each table. The "metaindex" block contains +an entry that maps from `filter.` to the BlockHandle for the filter +block where `` is the string returned by the filter policy's +`Name()` method. + +The filter block stores a sequence of filters, where filter i contains +the output of `FilterPolicy::CreateFilter()` on all keys that are stored +in a block whose file offset falls within the range + + [ i*base ... (i+1)*base-1 ] + +Currently, "base" is 2KB. So for example, if blocks X and Y start in +the range `[ 0KB .. 2KB-1 ]`, all of the keys in X and Y will be +converted to a filter by calling `FilterPolicy::CreateFilter()`, and the +resulting filter will be stored as the first filter in the filter +block. + +The filter block is formatted as follows: + + [filter 0] + [filter 1] + [filter 2] + ... + [filter N-1] + + [offset of filter 0] : 4 bytes + [offset of filter 1] : 4 bytes + [offset of filter 2] : 4 bytes + ... + [offset of filter N-1] : 4 bytes + + [offset of beginning of offset array] : 4 bytes + lg(base) : 1 byte + +The offset array at the end of the filter block allows efficient +mapping from a data block offset to the corresponding filter. + +## "stats" Meta Block + +This meta block contains a bunch of stats. The key is the name +of the statistic. The value contains the statistic. + +TODO(postrelease): record following stats. + + data size + index size + key size (uncompressed) + value size (uncompressed) + number of entries + number of data blocks diff --git a/depend/zcash/src/leveldb/doc/table_format.txt b/depend/zcash/src/leveldb/doc/table_format.txt deleted file mode 100644 index ca8f9b446..000000000 --- a/depend/zcash/src/leveldb/doc/table_format.txt +++ /dev/null @@ -1,104 +0,0 @@ -File format -=========== - - - [data block 1] - [data block 2] - ... - [data block N] - [meta block 1] - ... - [meta block K] - [metaindex block] - [index block] - [Footer] (fixed size; starts at file_size - sizeof(Footer)) - - -The file contains internal pointers. Each such pointer is called -a BlockHandle and contains the following information: - offset: varint64 - size: varint64 -See https://developers.google.com/protocol-buffers/docs/encoding#varints -for an explanation of varint64 format. - -(1) The sequence of key/value pairs in the file are stored in sorted -order and partitioned into a sequence of data blocks. These blocks -come one after another at the beginning of the file. Each data block -is formatted according to the code in block_builder.cc, and then -optionally compressed. - -(2) After the data blocks we store a bunch of meta blocks. The -supported meta block types are described below. More meta block types -may be added in the future. Each meta block is again formatted using -block_builder.cc and then optionally compressed. - -(3) A "metaindex" block. It contains one entry for every other meta -block where the key is the name of the meta block and the value is a -BlockHandle pointing to that meta block. - -(4) An "index" block. This block contains one entry per data block, -where the key is a string >= last key in that data block and before -the first key in the successive data block. The value is the -BlockHandle for the data block. - -(6) At the very end of the file is a fixed length footer that contains -the BlockHandle of the metaindex and index blocks as well as a magic number. - metaindex_handle: char[p]; // Block handle for metaindex - index_handle: char[q]; // Block handle for index - padding: char[40-p-q]; // zeroed bytes to make fixed length - // (40==2*BlockHandle::kMaxEncodedLength) - magic: fixed64; // == 0xdb4775248b80fb57 (little-endian) - -"filter" Meta Block -------------------- - -If a "FilterPolicy" was specified when the database was opened, a -filter block is stored in each table. The "metaindex" block contains -an entry that maps from "filter." to the BlockHandle for the filter -block where "" is the string returned by the filter policy's -"Name()" method. - -The filter block stores a sequence of filters, where filter i contains -the output of FilterPolicy::CreateFilter() on all keys that are stored -in a block whose file offset falls within the range - - [ i*base ... (i+1)*base-1 ] - -Currently, "base" is 2KB. So for example, if blocks X and Y start in -the range [ 0KB .. 2KB-1 ], all of the keys in X and Y will be -converted to a filter by calling FilterPolicy::CreateFilter(), and the -resulting filter will be stored as the first filter in the filter -block. - -The filter block is formatted as follows: - - [filter 0] - [filter 1] - [filter 2] - ... - [filter N-1] - - [offset of filter 0] : 4 bytes - [offset of filter 1] : 4 bytes - [offset of filter 2] : 4 bytes - ... - [offset of filter N-1] : 4 bytes - - [offset of beginning of offset array] : 4 bytes - lg(base) : 1 byte - -The offset array at the end of the filter block allows efficient -mapping from a data block offset to the corresponding filter. - -"stats" Meta Block ------------------- - -This meta block contains a bunch of stats. The key is the name -of the statistic. The value contains the statistic. -TODO(postrelease): record following stats. - data size - index size - key size (uncompressed) - value size (uncompressed) - number of entries - number of data blocks diff --git a/depend/zcash/src/leveldb/helpers/memenv/memenv.cc b/depend/zcash/src/leveldb/helpers/memenv/memenv.cc index 43ef2e072..68c0614a5 100644 --- a/depend/zcash/src/leveldb/helpers/memenv/memenv.cc +++ b/depend/zcash/src/leveldb/helpers/memenv/memenv.cc @@ -176,6 +176,7 @@ class SequentialFileImpl : public SequentialFile { return Status::OK(); } + virtual std::string GetName() const { return "[memenv]"; } private: FileState* file_; uint64_t pos_; @@ -196,6 +197,7 @@ class RandomAccessFileImpl : public RandomAccessFile { return file_->Read(offset, n, result, scratch); } + virtual std::string GetName() const { return "[memenv]"; } private: FileState* file_; }; @@ -218,6 +220,7 @@ class WritableFileImpl : public WritableFile { virtual Status Flush() { return Status::OK(); } virtual Status Sync() { return Status::OK(); } + virtual std::string GetName() const { return "[memenv]"; } private: FileState* file_; }; @@ -277,6 +280,19 @@ class InMemoryEnv : public EnvWrapper { return Status::OK(); } + virtual Status NewAppendableFile(const std::string& fname, + WritableFile** result) { + MutexLock lock(&mutex_); + FileState** sptr = &file_map_[fname]; + FileState* file = *sptr; + if (file == NULL) { + file = new FileState(); + file->Ref(); + } + *result = new WritableFileImpl(file); + return Status::OK(); + } + virtual bool FileExists(const std::string& fname) { MutexLock lock(&mutex_); return file_map_.find(fname) != file_map_.end(); diff --git a/depend/zcash/src/leveldb/helpers/memenv/memenv_test.cc b/depend/zcash/src/leveldb/helpers/memenv/memenv_test.cc index a44310fed..5cff77613 100644 --- a/depend/zcash/src/leveldb/helpers/memenv/memenv_test.cc +++ b/depend/zcash/src/leveldb/helpers/memenv/memenv_test.cc @@ -40,6 +40,8 @@ TEST(MemEnvTest, Basics) { // Create a file. ASSERT_OK(env_->NewWritableFile("/dir/f", &writable_file)); + ASSERT_OK(env_->GetFileSize("/dir/f", &file_size)); + ASSERT_EQ(0, file_size); delete writable_file; // Check that the file exists. @@ -55,9 +57,16 @@ TEST(MemEnvTest, Basics) { ASSERT_OK(writable_file->Append("abc")); delete writable_file; - // Check for expected size. + // Check that append works. + ASSERT_OK(env_->NewAppendableFile("/dir/f", &writable_file)); ASSERT_OK(env_->GetFileSize("/dir/f", &file_size)); ASSERT_EQ(3, file_size); + ASSERT_OK(writable_file->Append("hello")); + delete writable_file; + + // Check for expected size. + ASSERT_OK(env_->GetFileSize("/dir/f", &file_size)); + ASSERT_EQ(8, file_size); // Check that renaming works. ASSERT_TRUE(!env_->RenameFile("/dir/non_existent", "/dir/g").ok()); @@ -65,7 +74,7 @@ TEST(MemEnvTest, Basics) { ASSERT_TRUE(!env_->FileExists("/dir/f")); ASSERT_TRUE(env_->FileExists("/dir/g")); ASSERT_OK(env_->GetFileSize("/dir/g", &file_size)); - ASSERT_EQ(3, file_size); + ASSERT_EQ(8, file_size); // Check that opening non-existent file fails. SequentialFile* seq_file; diff --git a/depend/zcash/src/leveldb/include/leveldb/cache.h b/depend/zcash/src/leveldb/include/leveldb/cache.h index 1a201e5e0..6819d5bc4 100644 --- a/depend/zcash/src/leveldb/include/leveldb/cache.h +++ b/depend/zcash/src/leveldb/include/leveldb/cache.h @@ -81,6 +81,17 @@ class Cache { // its cache keys. virtual uint64_t NewId() = 0; + // Remove all cache entries that are not actively in use. Memory-constrained + // applications may wish to call this method to reduce memory usage. + // Default implementation of Prune() does nothing. Subclasses are strongly + // encouraged to override the default implementation. A future release of + // leveldb may change Prune() to a pure abstract method. + virtual void Prune() {} + + // Return an estimate of the combined charges of all elements stored in the + // cache. + virtual size_t TotalCharge() const = 0; + private: void LRU_Remove(Handle* e); void LRU_Append(Handle* e); diff --git a/depend/zcash/src/leveldb/include/leveldb/db.h b/depend/zcash/src/leveldb/include/leveldb/db.h index 4c169bf22..bfab10a0b 100644 --- a/depend/zcash/src/leveldb/include/leveldb/db.h +++ b/depend/zcash/src/leveldb/include/leveldb/db.h @@ -14,7 +14,7 @@ namespace leveldb { // Update Makefile if you change these static const int kMajorVersion = 1; -static const int kMinorVersion = 18; +static const int kMinorVersion = 20; struct Options; struct ReadOptions; @@ -115,6 +115,8 @@ class DB { // about the internal operation of the DB. // "leveldb.sstables" - returns a multi-line string that describes all // of the sstables that make up the db contents. + // "leveldb.approximate-memory-usage" - returns the approximate number of + // bytes of memory in use by the DB. virtual bool GetProperty(const Slice& property, std::string* value) = 0; // For each i in [0,n-1], store in "sizes[i]", the approximate diff --git a/depend/zcash/src/leveldb/include/leveldb/env.h b/depend/zcash/src/leveldb/include/leveldb/env.h index f709514da..275d441ea 100644 --- a/depend/zcash/src/leveldb/include/leveldb/env.h +++ b/depend/zcash/src/leveldb/include/leveldb/env.h @@ -69,6 +69,21 @@ class Env { virtual Status NewWritableFile(const std::string& fname, WritableFile** result) = 0; + // Create an object that either appends to an existing file, or + // writes to a new file (if the file does not exist to begin with). + // On success, stores a pointer to the new file in *result and + // returns OK. On failure stores NULL in *result and returns + // non-OK. + // + // The returned file will only be accessed by one thread at a time. + // + // May return an IsNotSupportedError error if this Env does + // not allow appending to an existing file. Users of Env (including + // the leveldb implementation) must be prepared to deal with + // an Env that does not support appending. + virtual Status NewAppendableFile(const std::string& fname, + WritableFile** result); + // Returns true iff the named file exists. virtual bool FileExists(const std::string& fname) = 0; @@ -176,6 +191,9 @@ class SequentialFile { // REQUIRES: External synchronization virtual Status Skip(uint64_t n) = 0; + // Get a name for the file, only for error reporting + virtual std::string GetName() const = 0; + private: // No copying allowed SequentialFile(const SequentialFile&); @@ -200,6 +218,9 @@ class RandomAccessFile { virtual Status Read(uint64_t offset, size_t n, Slice* result, char* scratch) const = 0; + // Get a name for the file, only for error reporting + virtual std::string GetName() const = 0; + private: // No copying allowed RandomAccessFile(const RandomAccessFile&); @@ -219,6 +240,9 @@ class WritableFile { virtual Status Flush() = 0; virtual Status Sync() = 0; + // Get a name for the file, only for error reporting + virtual std::string GetName() const = 0; + private: // No copying allowed WritableFile(const WritableFile&); @@ -289,6 +313,9 @@ class EnvWrapper : public Env { Status NewWritableFile(const std::string& f, WritableFile** r) { return target_->NewWritableFile(f, r); } + Status NewAppendableFile(const std::string& f, WritableFile** r) { + return target_->NewAppendableFile(f, r); + } bool FileExists(const std::string& f) { return target_->FileExists(f); } Status GetChildren(const std::string& dir, std::vector* r) { return target_->GetChildren(dir, r); diff --git a/depend/zcash/src/leveldb/include/leveldb/iterator.h b/depend/zcash/src/leveldb/include/leveldb/iterator.h index 76aced04b..da631ed9d 100644 --- a/depend/zcash/src/leveldb/include/leveldb/iterator.h +++ b/depend/zcash/src/leveldb/include/leveldb/iterator.h @@ -37,7 +37,7 @@ class Iterator { // Valid() after this call iff the source is not empty. virtual void SeekToLast() = 0; - // Position at the first key in the source that at or past target + // Position at the first key in the source that is at or past target. // The iterator is Valid() after this call iff the source contains // an entry that comes at or past target. virtual void Seek(const Slice& target) = 0; diff --git a/depend/zcash/src/leveldb/include/leveldb/options.h b/depend/zcash/src/leveldb/include/leveldb/options.h index 7c9b97345..976e38122 100644 --- a/depend/zcash/src/leveldb/include/leveldb/options.h +++ b/depend/zcash/src/leveldb/include/leveldb/options.h @@ -112,6 +112,18 @@ struct Options { // Default: 16 int block_restart_interval; + // Leveldb will write up to this amount of bytes to a file before + // switching to a new one. + // Most clients should leave this parameter alone. However if your + // filesystem is more efficient with larger files, you could + // consider increasing the value. The downside will be longer + // compactions and hence longer latency/performance hiccups. + // Another reason to increase this parameter might be when you are + // initially populating a large database. + // + // Default: 2MB + size_t max_file_size; + // Compress blocks using the specified compression algorithm. This // parameter can be changed dynamically. // @@ -128,6 +140,12 @@ struct Options { // efficiently detect that and will switch to uncompressed mode. CompressionType compression; + // EXPERIMENTAL: If true, append to existing MANIFEST and log files + // when a database is opened. This can significantly speed up open. + // + // Default: currently false, but may become true later. + bool reuse_logs; + // If non-NULL, use the specified filter policy to reduce disk reads. // Many applications will benefit from passing the result of // NewBloomFilterPolicy() here. diff --git a/depend/zcash/src/leveldb/include/leveldb/status.h b/depend/zcash/src/leveldb/include/leveldb/status.h index 11dbd4b47..d9575f975 100644 --- a/depend/zcash/src/leveldb/include/leveldb/status.h +++ b/depend/zcash/src/leveldb/include/leveldb/status.h @@ -60,6 +60,12 @@ class Status { // Returns true iff the status indicates an IOError. bool IsIOError() const { return code() == kIOError; } + // Returns true iff the status indicates a NotSupportedError. + bool IsNotSupportedError() const { return code() == kNotSupported; } + + // Returns true iff the status indicates an InvalidArgument. + bool IsInvalidArgument() const { return code() == kInvalidArgument; } + // Return a string representation of this status suitable for printing. // Returns the string "OK" for success. std::string ToString() const; diff --git a/depend/zcash/src/leveldb/port/atomic_pointer.h b/depend/zcash/src/leveldb/port/atomic_pointer.h index 9bf091f75..d79a02230 100644 --- a/depend/zcash/src/leveldb/port/atomic_pointer.h +++ b/depend/zcash/src/leveldb/port/atomic_pointer.h @@ -35,13 +35,41 @@ #define ARCH_CPU_X86_FAMILY 1 #elif defined(__ARMEL__) #define ARCH_CPU_ARM_FAMILY 1 +#elif defined(__aarch64__) +#define ARCH_CPU_ARM64_FAMILY 1 #elif defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__) #define ARCH_CPU_PPC_FAMILY 1 +#elif defined(__mips__) +#define ARCH_CPU_MIPS_FAMILY 1 #endif namespace leveldb { namespace port { +// AtomicPointer based on if available +#if defined(LEVELDB_ATOMIC_PRESENT) +class AtomicPointer { + private: + std::atomic rep_; + public: + AtomicPointer() { } + explicit AtomicPointer(void* v) : rep_(v) { } + inline void* Acquire_Load() const { + return rep_.load(std::memory_order_acquire); + } + inline void Release_Store(void* v) { + rep_.store(v, std::memory_order_release); + } + inline void* NoBarrier_Load() const { + return rep_.load(std::memory_order_relaxed); + } + inline void NoBarrier_Store(void* v) { + rep_.store(v, std::memory_order_relaxed); + } +}; + +#else + // Define MemoryBarrier() if available // Windows on x86 #if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY) @@ -92,6 +120,13 @@ inline void MemoryBarrier() { } #define LEVELDB_HAVE_MEMORY_BARRIER +// ARM64 +#elif defined(ARCH_CPU_ARM64_FAMILY) +inline void MemoryBarrier() { + asm volatile("dmb sy" : : : "memory"); +} +#define LEVELDB_HAVE_MEMORY_BARRIER + // PPC #elif defined(ARCH_CPU_PPC_FAMILY) && defined(__GNUC__) inline void MemoryBarrier() { @@ -101,6 +136,13 @@ inline void MemoryBarrier() { } #define LEVELDB_HAVE_MEMORY_BARRIER +// MIPS +#elif defined(ARCH_CPU_MIPS_FAMILY) && defined(__GNUC__) +inline void MemoryBarrier() { + __asm__ __volatile__("sync" : : : "memory"); +} +#define LEVELDB_HAVE_MEMORY_BARRIER + #endif // AtomicPointer built using platform-specific MemoryBarrier() @@ -124,28 +166,6 @@ class AtomicPointer { } }; -// AtomicPointer based on -#elif defined(LEVELDB_ATOMIC_PRESENT) -class AtomicPointer { - private: - std::atomic rep_; - public: - AtomicPointer() { } - explicit AtomicPointer(void* v) : rep_(v) { } - inline void* Acquire_Load() const { - return rep_.load(std::memory_order_acquire); - } - inline void Release_Store(void* v) { - rep_.store(v, std::memory_order_release); - } - inline void* NoBarrier_Load() const { - return rep_.load(std::memory_order_relaxed); - } - inline void NoBarrier_Store(void* v) { - rep_.store(v, std::memory_order_relaxed); - } -}; - // Atomic pointer based on sparc memory barriers #elif defined(__sparcv9) && defined(__GNUC__) class AtomicPointer { @@ -210,11 +230,13 @@ class AtomicPointer { #else #error Please implement AtomicPointer for this platform. +#endif #endif #undef LEVELDB_HAVE_MEMORY_BARRIER #undef ARCH_CPU_X86_FAMILY #undef ARCH_CPU_ARM_FAMILY +#undef ARCH_CPU_ARM64_FAMILY #undef ARCH_CPU_PPC_FAMILY } // namespace port diff --git a/depend/zcash/src/leveldb/port/port_example.h b/depend/zcash/src/leveldb/port/port_example.h index ab9e489b3..5b1d027de 100644 --- a/depend/zcash/src/leveldb/port/port_example.h +++ b/depend/zcash/src/leveldb/port/port_example.h @@ -129,6 +129,16 @@ extern bool Snappy_Uncompress(const char* input_data, size_t input_length, // The concatenation of all "data[0,n-1]" fragments is the heap profile. extern bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg); +// Determine whether a working accelerated crc32 implementation exists +// Returns true if AcceleratedCRC32C is safe to call +bool HasAcceleratedCRC32C(); + +// Extend the CRC to include the first n bytes of buf. +// +// Returns zero if the CRC cannot be extended using acceleration, else returns +// the newly extended CRC value (which may also be zero). +uint32_t AcceleratedCRC32C(uint32_t crc, const char* buf, size_t size); + } // namespace port } // namespace leveldb diff --git a/depend/zcash/src/leveldb/port/port_posix.cc b/depend/zcash/src/leveldb/port/port_posix.cc index 5ba127a5b..ec39e9219 100644 --- a/depend/zcash/src/leveldb/port/port_posix.cc +++ b/depend/zcash/src/leveldb/port/port_posix.cc @@ -7,7 +7,10 @@ #include #include #include -#include "util/logging.h" + +#if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__) +#include +#endif namespace leveldb { namespace port { @@ -50,5 +53,15 @@ void InitOnce(OnceType* once, void (*initializer)()) { PthreadCall("once", pthread_once(once, initializer)); } +bool HasAcceleratedCRC32C() { +#if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__) + unsigned int eax, ebx, ecx, edx; + __get_cpuid(1, &eax, &ebx, &ecx, &edx); + return (ecx & (1 << 20)) != 0; +#else + return false; +#endif +} + } // namespace port } // namespace leveldb diff --git a/depend/zcash/src/leveldb/port/port_posix.h b/depend/zcash/src/leveldb/port/port_posix.h index ccca9939d..d85fa5d63 100644 --- a/depend/zcash/src/leveldb/port/port_posix.h +++ b/depend/zcash/src/leveldb/port/port_posix.h @@ -152,6 +152,9 @@ inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { return false; } +bool HasAcceleratedCRC32C(); +uint32_t AcceleratedCRC32C(uint32_t crc, const char* buf, size_t size); + } // namespace port } // namespace leveldb diff --git a/depend/zcash/src/leveldb/port/port_posix_sse.cc b/depend/zcash/src/leveldb/port/port_posix_sse.cc new file mode 100644 index 000000000..2d49c21dd --- /dev/null +++ b/depend/zcash/src/leveldb/port/port_posix_sse.cc @@ -0,0 +1,110 @@ +// Copyright 2016 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// A portable implementation of crc32c, optimized to handle +// four bytes at a time. +// +// In a separate source file to allow this accelerated CRC32C function to be +// compiled with the appropriate compiler flags to enable x86 SSE 4.2 +// instructions. + +#include +#include +#include "port/port.h" + +#if defined(LEVELDB_PLATFORM_POSIX_SSE) + +#if defined(_MSC_VER) +#include +#elif defined(__GNUC__) && defined(__SSE4_2__) +#include +#endif + +#endif // defined(LEVELDB_PLATFORM_POSIX_SSE) + +namespace leveldb { +namespace port { + +#if defined(LEVELDB_PLATFORM_POSIX_SSE) + +// Used to fetch a naturally-aligned 32-bit word in little endian byte-order +static inline uint32_t LE_LOAD32(const uint8_t *p) { + // SSE is x86 only, so ensured that |p| is always little-endian. + uint32_t word; + memcpy(&word, p, sizeof(word)); + return word; +} + +#if defined(_M_X64) || defined(__x86_64__) // LE_LOAD64 is only used on x64. + +// Used to fetch a naturally-aligned 64-bit word in little endian byte-order +static inline uint64_t LE_LOAD64(const uint8_t *p) { + uint64_t dword; + memcpy(&dword, p, sizeof(dword)); + return dword; +} + +#endif // defined(_M_X64) || defined(__x86_64__) + +#endif // defined(LEVELDB_PLATFORM_POSIX_SSE) + +// For further improvements see Intel publication at: +// http://download.intel.com/design/intarch/papers/323405.pdf +uint32_t AcceleratedCRC32C(uint32_t crc, const char* buf, size_t size) { +#if !defined(LEVELDB_PLATFORM_POSIX_SSE) + return 0; +#else + + const uint8_t *p = reinterpret_cast(buf); + const uint8_t *e = p + size; + uint32_t l = crc ^ 0xffffffffu; + +#define STEP1 do { \ + l = _mm_crc32_u8(l, *p++); \ +} while (0) +#define STEP4 do { \ + l = _mm_crc32_u32(l, LE_LOAD32(p)); \ + p += 4; \ +} while (0) +#define STEP8 do { \ + l = _mm_crc32_u64(l, LE_LOAD64(p)); \ + p += 8; \ +} while (0) + + if (size > 16) { + // Process unaligned bytes + for (unsigned int i = reinterpret_cast(p) % 8; i; --i) { + STEP1; + } + + // _mm_crc32_u64 is only available on x64. +#if defined(_M_X64) || defined(__x86_64__) + // Process 8 bytes at a time + while ((e-p) >= 8) { + STEP8; + } + // Process 4 bytes at a time + if ((e-p) >= 4) { + STEP4; + } +#else // !(defined(_M_X64) || defined(__x86_64__)) + // Process 4 bytes at a time + while ((e-p) >= 4) { + STEP4; + } +#endif // defined(_M_X64) || defined(__x86_64__) + } + // Process the last few bytes + while (p != e) { + STEP1; + } +#undef STEP8 +#undef STEP4 +#undef STEP1 + return l ^ 0xffffffffu; +#endif // defined(LEVELDB_PLATFORM_POSIX_SSE) +} + +} // namespace port +} // namespace leveldb diff --git a/depend/zcash/src/leveldb/port/port_win.cc b/depend/zcash/src/leveldb/port/port_win.cc index 1b0f060a1..1be9e8d5b 100644 --- a/depend/zcash/src/leveldb/port/port_win.cc +++ b/depend/zcash/src/leveldb/port/port_win.cc @@ -32,6 +32,7 @@ #include #include +#include namespace leveldb { namespace port { @@ -143,5 +144,15 @@ void AtomicPointer::NoBarrier_Store(void* v) { rep_ = v; } +bool HasAcceleratedCRC32C() { +#if defined(__x86_64__) || defined(__i386__) + int cpu_info[4]; + __cpuid(cpu_info, 1); + return (cpu_info[2] & (1 << 20)) != 0; +#else + return false; +#endif +} + } } diff --git a/depend/zcash/src/leveldb/port/port_win.h b/depend/zcash/src/leveldb/port/port_win.h index 45bf2f0ea..ba7b17faf 100644 --- a/depend/zcash/src/leveldb/port/port_win.h +++ b/depend/zcash/src/leveldb/port/port_win.h @@ -32,13 +32,21 @@ #define STORAGE_LEVELDB_PORT_PORT_WIN_H_ #ifdef _MSC_VER +#if !(_MSC_VER >= 1900) #define snprintf _snprintf +#endif #define close _close #define fread_unlocked _fread_nolock +#ifdef _WIN64 +#define ssize_t int64_t +#else +#define ssize_t int32_t +#endif #endif #include #include +static_assert(sizeof(ssize_t) == sizeof(size_t), "ssize_t should be the same size as size_t"); #ifdef SNAPPY #include #endif @@ -168,6 +176,9 @@ inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { return false; } +bool HasAcceleratedCRC32C(); +uint32_t AcceleratedCRC32C(uint32_t crc, const char* buf, size_t size); + } } diff --git a/depend/zcash/src/leveldb/table/filter_block.cc b/depend/zcash/src/leveldb/table/filter_block.cc index 203e15c8b..1ed513417 100644 --- a/depend/zcash/src/leveldb/table/filter_block.cc +++ b/depend/zcash/src/leveldb/table/filter_block.cc @@ -9,7 +9,7 @@ namespace leveldb { -// See doc/table_format.txt for an explanation of the filter block format. +// See doc/table_format.md for an explanation of the filter block format. // Generate new filter every 2KB of data static const size_t kFilterBaseLg = 11; @@ -68,7 +68,7 @@ void FilterBlockBuilder::GenerateFilter() { // Generate filter for current set of keys and append to result_. filter_offsets_.push_back(result_.size()); - policy_->CreateFilter(&tmp_keys_[0], num_keys, &result_); + policy_->CreateFilter(&tmp_keys_[0], static_cast(num_keys), &result_); tmp_keys_.clear(); keys_.clear(); @@ -97,7 +97,7 @@ bool FilterBlockReader::KeyMayMatch(uint64_t block_offset, const Slice& key) { if (index < num_) { uint32_t start = DecodeFixed32(offset_ + index*4); uint32_t limit = DecodeFixed32(offset_ + index*4 + 4); - if (start <= limit && limit <= (offset_ - data_)) { + if (start <= limit && limit <= static_cast(offset_ - data_)) { Slice filter = Slice(data_ + start, limit - start); return policy_->KeyMayMatch(key, filter); } else if (start == limit) { diff --git a/depend/zcash/src/leveldb/table/format.cc b/depend/zcash/src/leveldb/table/format.cc index aa63144c9..285e1c0de 100644 --- a/depend/zcash/src/leveldb/table/format.cc +++ b/depend/zcash/src/leveldb/table/format.cc @@ -30,15 +30,14 @@ Status BlockHandle::DecodeFrom(Slice* input) { } void Footer::EncodeTo(std::string* dst) const { -#ifndef NDEBUG const size_t original_size = dst->size(); -#endif metaindex_handle_.EncodeTo(dst); index_handle_.EncodeTo(dst); dst->resize(2 * BlockHandle::kMaxEncodedLength); // Padding PutFixed32(dst, static_cast(kTableMagicNumber & 0xffffffffu)); PutFixed32(dst, static_cast(kTableMagicNumber >> 32)); assert(dst->size() == original_size + kEncodedLength); + (void)original_size; // Disable unused variable warning. } Status Footer::DecodeFrom(Slice* input) { @@ -83,7 +82,7 @@ Status ReadBlock(RandomAccessFile* file, } if (contents.size() != n + kBlockTrailerSize) { delete[] buf; - return Status::Corruption("truncated block read"); + return Status::Corruption("truncated block read", file->GetName()); } // Check the crc of the type and the block contents @@ -93,7 +92,7 @@ Status ReadBlock(RandomAccessFile* file, const uint32_t actual = crc32c::Value(data, n + 1); if (actual != crc) { delete[] buf; - s = Status::Corruption("block checksum mismatch"); + s = Status::Corruption("block checksum mismatch", file->GetName()); return s; } } @@ -120,13 +119,13 @@ Status ReadBlock(RandomAccessFile* file, size_t ulength = 0; if (!port::Snappy_GetUncompressedLength(data, n, &ulength)) { delete[] buf; - return Status::Corruption("corrupted compressed block contents"); + return Status::Corruption("corrupted compressed block contents", file->GetName()); } char* ubuf = new char[ulength]; if (!port::Snappy_Uncompress(data, n, ubuf)) { delete[] buf; delete[] ubuf; - return Status::Corruption("corrupted compressed block contents"); + return Status::Corruption("corrupted compressed block contents", file->GetName()); } delete[] buf; result->data = Slice(ubuf, ulength); @@ -136,7 +135,7 @@ Status ReadBlock(RandomAccessFile* file, } default: delete[] buf; - return Status::Corruption("bad block type"); + return Status::Corruption("bad block type", file->GetName()); } return Status::OK(); diff --git a/depend/zcash/src/leveldb/table/iterator_wrapper.h b/depend/zcash/src/leveldb/table/iterator_wrapper.h index 9e16b3dbe..f410c3fab 100644 --- a/depend/zcash/src/leveldb/table/iterator_wrapper.h +++ b/depend/zcash/src/leveldb/table/iterator_wrapper.h @@ -5,6 +5,9 @@ #ifndef STORAGE_LEVELDB_TABLE_ITERATOR_WRAPPER_H_ #define STORAGE_LEVELDB_TABLE_ITERATOR_WRAPPER_H_ +#include "leveldb/iterator.h" +#include "leveldb/slice.h" + namespace leveldb { // A internal wrapper class with an interface similar to Iterator that diff --git a/depend/zcash/src/leveldb/table/table.cc b/depend/zcash/src/leveldb/table/table.cc index dff8a8259..decf8082c 100644 --- a/depend/zcash/src/leveldb/table/table.cc +++ b/depend/zcash/src/leveldb/table/table.cc @@ -82,7 +82,7 @@ Status Table::Open(const Options& options, *table = new Table(rep); (*table)->ReadMeta(footer); } else { - if (index_block) delete index_block; + delete index_block; } return s; diff --git a/depend/zcash/src/leveldb/table/table_test.cc b/depend/zcash/src/leveldb/table/table_test.cc index c723bf84c..abf6e246f 100644 --- a/depend/zcash/src/leveldb/table/table_test.cc +++ b/depend/zcash/src/leveldb/table/table_test.cc @@ -853,12 +853,20 @@ TEST(TableTest, ApproximateOffsetOfCompressed) { options.compression = kSnappyCompression; c.Finish(options, &keys, &kvmap); - ASSERT_TRUE(Between(c.ApproximateOffsetOf("abc"), 0, 0)); - ASSERT_TRUE(Between(c.ApproximateOffsetOf("k01"), 0, 0)); - ASSERT_TRUE(Between(c.ApproximateOffsetOf("k02"), 0, 0)); - ASSERT_TRUE(Between(c.ApproximateOffsetOf("k03"), 2000, 3000)); - ASSERT_TRUE(Between(c.ApproximateOffsetOf("k04"), 2000, 3000)); - ASSERT_TRUE(Between(c.ApproximateOffsetOf("xyz"), 4000, 6000)); + // Expected upper and lower bounds of space used by compressible strings. + static const int kSlop = 1000; // Compressor effectiveness varies. + const int expected = 2500; // 10000 * compression ratio (0.25) + const int min_z = expected - kSlop; + const int max_z = expected + kSlop; + + ASSERT_TRUE(Between(c.ApproximateOffsetOf("abc"), 0, kSlop)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k01"), 0, kSlop)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k02"), 0, kSlop)); + // Have now emitted a large compressible string, so adjust expected offset. + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k03"), min_z, max_z)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k04"), min_z, max_z)); + // Have now emitted two large compressible strings, so adjust expected offset. + ASSERT_TRUE(Between(c.ApproximateOffsetOf("xyz"), 2 * min_z, 2 * max_z)); } } // namespace leveldb diff --git a/depend/zcash/src/leveldb/util/arena.cc b/depend/zcash/src/leveldb/util/arena.cc index 9367f7149..74078213e 100644 --- a/depend/zcash/src/leveldb/util/arena.cc +++ b/depend/zcash/src/leveldb/util/arena.cc @@ -9,8 +9,7 @@ namespace leveldb { static const int kBlockSize = 4096; -Arena::Arena() { - blocks_memory_ = 0; +Arena::Arena() : memory_usage_(0) { alloc_ptr_ = NULL; // First allocation will allocate a block alloc_bytes_remaining_ = 0; } @@ -60,8 +59,9 @@ char* Arena::AllocateAligned(size_t bytes) { char* Arena::AllocateNewBlock(size_t block_bytes) { char* result = new char[block_bytes]; - blocks_memory_ += block_bytes; blocks_.push_back(result); + memory_usage_.NoBarrier_Store( + reinterpret_cast(MemoryUsage() + block_bytes + sizeof(char*))); return result; } diff --git a/depend/zcash/src/leveldb/util/arena.h b/depend/zcash/src/leveldb/util/arena.h index 73bbf1cb9..48bab3374 100644 --- a/depend/zcash/src/leveldb/util/arena.h +++ b/depend/zcash/src/leveldb/util/arena.h @@ -9,6 +9,7 @@ #include #include #include +#include "port/port.h" namespace leveldb { @@ -24,10 +25,9 @@ class Arena { char* AllocateAligned(size_t bytes); // Returns an estimate of the total memory usage of data allocated - // by the arena (including space allocated but not yet used for user - // allocations). + // by the arena. size_t MemoryUsage() const { - return blocks_memory_ + blocks_.capacity() * sizeof(char*); + return reinterpret_cast(memory_usage_.NoBarrier_Load()); } private: @@ -41,8 +41,8 @@ class Arena { // Array of new[] allocated memory blocks std::vector blocks_; - // Bytes of memory in blocks allocated so far - size_t blocks_memory_; + // Total memory usage of the arena. + port::AtomicPointer memory_usage_; // No copying allowed Arena(const Arena&); diff --git a/depend/zcash/src/leveldb/util/bloom.cc b/depend/zcash/src/leveldb/util/bloom.cc index a27a2ace2..bf3e4ca6e 100644 --- a/depend/zcash/src/leveldb/util/bloom.cc +++ b/depend/zcash/src/leveldb/util/bloom.cc @@ -47,7 +47,7 @@ class BloomFilterPolicy : public FilterPolicy { dst->resize(init_size + bytes, 0); dst->push_back(static_cast(k_)); // Remember # of probes in filter char* array = &(*dst)[init_size]; - for (size_t i = 0; i < n; i++) { + for (int i = 0; i < n; i++) { // Use double-hashing to generate a sequence of hash values. // See analysis in [Kirsch,Mitzenmacher 2006]. uint32_t h = BloomHash(keys[i]); diff --git a/depend/zcash/src/leveldb/util/bloom_test.cc b/depend/zcash/src/leveldb/util/bloom_test.cc index 77fb1b315..1b87a2be3 100644 --- a/depend/zcash/src/leveldb/util/bloom_test.cc +++ b/depend/zcash/src/leveldb/util/bloom_test.cc @@ -46,7 +46,8 @@ class BloomTest { key_slices.push_back(Slice(keys_[i])); } filter_.clear(); - policy_->CreateFilter(&key_slices[0], key_slices.size(), &filter_); + policy_->CreateFilter(&key_slices[0], static_cast(key_slices.size()), + &filter_); keys_.clear(); if (kVerbose >= 2) DumpFilter(); } diff --git a/depend/zcash/src/leveldb/util/cache.cc b/depend/zcash/src/leveldb/util/cache.cc index 8b197bc02..ce4688617 100644 --- a/depend/zcash/src/leveldb/util/cache.cc +++ b/depend/zcash/src/leveldb/util/cache.cc @@ -19,6 +19,23 @@ Cache::~Cache() { namespace { // LRU cache implementation +// +// Cache entries have an "in_cache" boolean indicating whether the cache has a +// reference on the entry. The only ways that this can become false without the +// entry being passed to its "deleter" are via Erase(), via Insert() when +// an element with a duplicate key is inserted, or on destruction of the cache. +// +// The cache keeps two linked lists of items in the cache. All items in the +// cache are in one list or the other, and never both. Items still referenced +// by clients but erased from the cache are in neither list. The lists are: +// - in-use: contains the items currently referenced by clients, in no +// particular order. (This list is used for invariant checking. If we +// removed the check, elements that would otherwise be on this list could be +// left as disconnected singleton lists.) +// - LRU: contains the items not currently referenced by clients, in LRU order +// Elements are moved between these lists by the Ref() and Unref() methods, +// when they detect an element in the cache acquiring or losing its only +// external reference. // An entry is a variable length heap-allocated structure. Entries // are kept in a circular doubly linked list ordered by access time. @@ -30,7 +47,8 @@ struct LRUHandle { LRUHandle* prev; size_t charge; // TODO(opt): Only allow uint32_t? size_t key_length; - uint32_t refs; + bool in_cache; // Whether entry is in the cache. + uint32_t refs; // References, including cache reference, if present. uint32_t hash; // Hash of key(); used for fast sharding and comparisons char key_data[1]; // Beginning of key @@ -147,49 +165,77 @@ class LRUCache { Cache::Handle* Lookup(const Slice& key, uint32_t hash); void Release(Cache::Handle* handle); void Erase(const Slice& key, uint32_t hash); + void Prune(); + size_t TotalCharge() const { + MutexLock l(&mutex_); + return usage_; + } private: void LRU_Remove(LRUHandle* e); - void LRU_Append(LRUHandle* e); + void LRU_Append(LRUHandle*list, LRUHandle* e); + void Ref(LRUHandle* e); void Unref(LRUHandle* e); + bool FinishErase(LRUHandle* e); // Initialized before use. size_t capacity_; // mutex_ protects the following state. - port::Mutex mutex_; + mutable port::Mutex mutex_; size_t usage_; // Dummy head of LRU list. // lru.prev is newest entry, lru.next is oldest entry. + // Entries have refs==1 and in_cache==true. LRUHandle lru_; + // Dummy head of in-use list. + // Entries are in use by clients, and have refs >= 2 and in_cache==true. + LRUHandle in_use_; + HandleTable table_; }; LRUCache::LRUCache() : usage_(0) { - // Make empty circular linked list + // Make empty circular linked lists. lru_.next = &lru_; lru_.prev = &lru_; + in_use_.next = &in_use_; + in_use_.prev = &in_use_; } LRUCache::~LRUCache() { + assert(in_use_.next == &in_use_); // Error if caller has an unreleased handle for (LRUHandle* e = lru_.next; e != &lru_; ) { LRUHandle* next = e->next; - assert(e->refs == 1); // Error if caller has an unreleased handle + assert(e->in_cache); + e->in_cache = false; + assert(e->refs == 1); // Invariant of lru_ list. Unref(e); e = next; } } +void LRUCache::Ref(LRUHandle* e) { + if (e->refs == 1 && e->in_cache) { // If on lru_ list, move to in_use_ list. + LRU_Remove(e); + LRU_Append(&in_use_, e); + } + e->refs++; +} + void LRUCache::Unref(LRUHandle* e) { assert(e->refs > 0); e->refs--; - if (e->refs <= 0) { - usage_ -= e->charge; + if (e->refs == 0) { // Deallocate. + assert(!e->in_cache); (*e->deleter)(e->key(), e->value); free(e); + } else if (e->in_cache && e->refs == 1) { // No longer in use; move to lru_ list. + LRU_Remove(e); + LRU_Append(&lru_, e); } } @@ -198,10 +244,10 @@ void LRUCache::LRU_Remove(LRUHandle* e) { e->prev->next = e->next; } -void LRUCache::LRU_Append(LRUHandle* e) { - // Make "e" newest entry by inserting just before lru_ - e->next = &lru_; - e->prev = lru_.prev; +void LRUCache::LRU_Append(LRUHandle* list, LRUHandle* e) { + // Make "e" newest entry by inserting just before *list + e->next = list; + e->prev = list->prev; e->prev->next = e; e->next->prev = e; } @@ -210,9 +256,7 @@ Cache::Handle* LRUCache::Lookup(const Slice& key, uint32_t hash) { MutexLock l(&mutex_); LRUHandle* e = table_.Lookup(key, hash); if (e != NULL) { - e->refs++; - LRU_Remove(e); - LRU_Append(e); + Ref(e); } return reinterpret_cast(e); } @@ -234,34 +278,58 @@ Cache::Handle* LRUCache::Insert( e->charge = charge; e->key_length = key.size(); e->hash = hash; - e->refs = 2; // One from LRUCache, one for the returned handle + e->in_cache = false; + e->refs = 1; // for the returned handle. memcpy(e->key_data, key.data(), key.size()); - LRU_Append(e); - usage_ += charge; - LRUHandle* old = table_.Insert(e); - if (old != NULL) { - LRU_Remove(old); - Unref(old); - } + if (capacity_ > 0) { + e->refs++; // for the cache's reference. + e->in_cache = true; + LRU_Append(&in_use_, e); + usage_ += charge; + FinishErase(table_.Insert(e)); + } // else don't cache. (Tests use capacity_==0 to turn off caching.) while (usage_ > capacity_ && lru_.next != &lru_) { LRUHandle* old = lru_.next; - LRU_Remove(old); - table_.Remove(old->key(), old->hash); - Unref(old); + assert(old->refs == 1); + bool erased = FinishErase(table_.Remove(old->key(), old->hash)); + if (!erased) { // to avoid unused variable when compiled NDEBUG + assert(erased); + } } return reinterpret_cast(e); } -void LRUCache::Erase(const Slice& key, uint32_t hash) { - MutexLock l(&mutex_); - LRUHandle* e = table_.Remove(key, hash); +// If e != NULL, finish removing *e from the cache; it has already been removed +// from the hash table. Return whether e != NULL. Requires mutex_ held. +bool LRUCache::FinishErase(LRUHandle* e) { if (e != NULL) { + assert(e->in_cache); LRU_Remove(e); + e->in_cache = false; + usage_ -= e->charge; Unref(e); } + return e != NULL; +} + +void LRUCache::Erase(const Slice& key, uint32_t hash) { + MutexLock l(&mutex_); + FinishErase(table_.Remove(key, hash)); +} + +void LRUCache::Prune() { + MutexLock l(&mutex_); + while (lru_.next != &lru_) { + LRUHandle* e = lru_.next; + assert(e->refs == 1); + bool erased = FinishErase(table_.Remove(e->key(), e->hash)); + if (!erased) { // to avoid unused variable when compiled NDEBUG + assert(erased); + } + } } static const int kNumShardBits = 4; @@ -314,6 +382,18 @@ class ShardedLRUCache : public Cache { MutexLock l(&id_mutex_); return ++(last_id_); } + virtual void Prune() { + for (int s = 0; s < kNumShards; s++) { + shard_[s].Prune(); + } + } + virtual size_t TotalCharge() const { + size_t total = 0; + for (int s = 0; s < kNumShards; s++) { + total += shard_[s].TotalCharge(); + } + return total; + } }; } // end anonymous namespace diff --git a/depend/zcash/src/leveldb/util/cache_test.cc b/depend/zcash/src/leveldb/util/cache_test.cc index 43716715a..468f7a642 100644 --- a/depend/zcash/src/leveldb/util/cache_test.cc +++ b/depend/zcash/src/leveldb/util/cache_test.cc @@ -59,6 +59,11 @@ class CacheTest { &CacheTest::Deleter)); } + Cache::Handle* InsertAndReturnHandle(int key, int value, int charge = 1) { + return cache_->Insert(EncodeKey(key), EncodeValue(value), charge, + &CacheTest::Deleter); + } + void Erase(int key) { cache_->Erase(EncodeKey(key)); } @@ -135,8 +140,11 @@ TEST(CacheTest, EntriesArePinned) { TEST(CacheTest, EvictionPolicy) { Insert(100, 101); Insert(200, 201); + Insert(300, 301); + Cache::Handle* h = cache_->Lookup(EncodeKey(300)); - // Frequently used entry must be kept around + // Frequently used entry must be kept around, + // as must things that are still in use. for (int i = 0; i < kCacheSize + 100; i++) { Insert(1000+i, 2000+i); ASSERT_EQ(2000+i, Lookup(1000+i)); @@ -144,6 +152,25 @@ TEST(CacheTest, EvictionPolicy) { } ASSERT_EQ(101, Lookup(100)); ASSERT_EQ(-1, Lookup(200)); + ASSERT_EQ(301, Lookup(300)); + cache_->Release(h); +} + +TEST(CacheTest, UseExceedsCacheSize) { + // Overfill the cache, keeping handles on all inserted entries. + std::vector h; + for (int i = 0; i < kCacheSize + 100; i++) { + h.push_back(InsertAndReturnHandle(1000+i, 2000+i)); + } + + // Check that all the entries can be found in the cache. + for (int i = 0; i < h.size(); i++) { + ASSERT_EQ(2000+i, Lookup(1000+i)); + } + + for (int i = 0; i < h.size(); i++) { + cache_->Release(h[i]); + } } TEST(CacheTest, HeavyEntries) { @@ -179,6 +206,19 @@ TEST(CacheTest, NewId) { ASSERT_NE(a, b); } +TEST(CacheTest, Prune) { + Insert(1, 100); + Insert(2, 200); + + Cache::Handle* handle = cache_->Lookup(EncodeKey(1)); + ASSERT_TRUE(handle); + cache_->Prune(); + cache_->Release(handle); + + ASSERT_EQ(100, Lookup(1)); + ASSERT_EQ(-1, Lookup(2)); +} + } // namespace leveldb int main(int argc, char** argv) { diff --git a/depend/zcash/src/leveldb/util/crc32c.cc b/depend/zcash/src/leveldb/util/crc32c.cc index 6db9e7707..b3f40eeee 100644 --- a/depend/zcash/src/leveldb/util/crc32c.cc +++ b/depend/zcash/src/leveldb/util/crc32c.cc @@ -8,6 +8,8 @@ #include "util/crc32c.h" #include + +#include "port/port.h" #include "util/coding.h" namespace leveldb { @@ -283,7 +285,27 @@ static inline uint32_t LE_LOAD32(const uint8_t *p) { return DecodeFixed32(reinterpret_cast(p)); } +// Determine if the CPU running this program can accelerate the CRC32C +// calculation. +static bool CanAccelerateCRC32C() { + if (!port::HasAcceleratedCRC32C()) + return false; + + // Double-check that the accelerated implementation functions correctly. + // port::AcceleretedCRC32C returns zero when unable to accelerate. + static const char kTestCRCBuffer[] = "TestCRCBuffer"; + static const char kBufSize = sizeof(kTestCRCBuffer) - 1; + static const uint32_t kTestCRCValue = 0xdcbc59fa; + + return port::AcceleratedCRC32C(0, kTestCRCBuffer, kBufSize) == kTestCRCValue; +} + uint32_t Extend(uint32_t crc, const char* buf, size_t size) { + static bool accelerate = CanAccelerateCRC32C(); + if (accelerate) { + return port::AcceleratedCRC32C(crc, buf, size); + } + const uint8_t *p = reinterpret_cast(buf); const uint8_t *e = p + size; uint32_t l = crc ^ 0xffffffffu; diff --git a/depend/zcash/src/leveldb/util/env.cc b/depend/zcash/src/leveldb/util/env.cc index c2600e964..c58a0821e 100644 --- a/depend/zcash/src/leveldb/util/env.cc +++ b/depend/zcash/src/leveldb/util/env.cc @@ -9,6 +9,10 @@ namespace leveldb { Env::~Env() { } +Status Env::NewAppendableFile(const std::string& fname, WritableFile** result) { + return Status::NotSupported("NewAppendableFile", fname); +} + SequentialFile::~SequentialFile() { } diff --git a/depend/zcash/src/leveldb/util/env_posix.cc b/depend/zcash/src/leveldb/util/env_posix.cc index ba2667864..f77918313 100644 --- a/depend/zcash/src/leveldb/util/env_posix.cc +++ b/depend/zcash/src/leveldb/util/env_posix.cc @@ -11,12 +11,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include "leveldb/env.h" #include "leveldb/slice.h" @@ -24,15 +26,70 @@ #include "util/logging.h" #include "util/mutexlock.h" #include "util/posix_logger.h" +#include "util/env_posix_test_helper.h" namespace leveldb { namespace { +static int open_read_only_file_limit = -1; +static int mmap_limit = -1; + static Status IOError(const std::string& context, int err_number) { return Status::IOError(context, strerror(err_number)); } +// Helper class to limit resource usage to avoid exhaustion. +// Currently used to limit read-only file descriptors and mmap file usage +// so that we do not end up running out of file descriptors, virtual memory, +// or running into kernel performance problems for very large databases. +class Limiter { + public: + // Limit maximum number of resources to |n|. + Limiter(intptr_t n) { + SetAllowed(n); + } + + // If another resource is available, acquire it and return true. + // Else return false. + bool Acquire() { + if (GetAllowed() <= 0) { + return false; + } + MutexLock l(&mu_); + intptr_t x = GetAllowed(); + if (x <= 0) { + return false; + } else { + SetAllowed(x - 1); + return true; + } + } + + // Release a resource acquired by a previous call to Acquire() that returned + // true. + void Release() { + MutexLock l(&mu_); + SetAllowed(GetAllowed() + 1); + } + + private: + port::Mutex mu_; + port::AtomicPointer allowed_; + + intptr_t GetAllowed() const { + return reinterpret_cast(allowed_.Acquire_Load()); + } + + // REQUIRES: mu_ must be held + void SetAllowed(intptr_t v) { + allowed_.Release_Store(reinterpret_cast(v)); + } + + Limiter(const Limiter&); + void operator=(const Limiter&); +}; + class PosixSequentialFile: public SequentialFile { private: std::string filename_; @@ -64,79 +121,61 @@ class PosixSequentialFile: public SequentialFile { } return Status::OK(); } + + virtual std::string GetName() const { return filename_; } }; // pread() based random-access class PosixRandomAccessFile: public RandomAccessFile { private: std::string filename_; + bool temporary_fd_; // If true, fd_ is -1 and we open on every read. int fd_; + Limiter* limiter_; public: - PosixRandomAccessFile(const std::string& fname, int fd) - : filename_(fname), fd_(fd) { } - virtual ~PosixRandomAccessFile() { close(fd_); } + PosixRandomAccessFile(const std::string& fname, int fd, Limiter* limiter) + : filename_(fname), fd_(fd), limiter_(limiter) { + temporary_fd_ = !limiter->Acquire(); + if (temporary_fd_) { + // Open file on every access. + close(fd_); + fd_ = -1; + } + } + + virtual ~PosixRandomAccessFile() { + if (!temporary_fd_) { + close(fd_); + limiter_->Release(); + } + } virtual Status Read(uint64_t offset, size_t n, Slice* result, char* scratch) const { + int fd = fd_; + if (temporary_fd_) { + fd = open(filename_.c_str(), O_RDONLY); + if (fd < 0) { + return IOError(filename_, errno); + } + } + Status s; - ssize_t r = pread(fd_, scratch, n, static_cast(offset)); + ssize_t r = pread(fd, scratch, n, static_cast(offset)); *result = Slice(scratch, (r < 0) ? 0 : r); if (r < 0) { // An error: return a non-ok status s = IOError(filename_, errno); } - return s; - } -}; - -// Helper class to limit mmap file usage so that we do not end up -// running out virtual memory or running into kernel performance -// problems for very large databases. -class MmapLimiter { - public: - // Up to 1000 mmaps for 64-bit binaries; none for smaller pointer sizes. - MmapLimiter() { - SetAllowed(sizeof(void*) >= 8 ? 1000 : 0); - } - - // If another mmap slot is available, acquire it and return true. - // Else return false. - bool Acquire() { - if (GetAllowed() <= 0) { - return false; - } - MutexLock l(&mu_); - intptr_t x = GetAllowed(); - if (x <= 0) { - return false; - } else { - SetAllowed(x - 1); - return true; + if (temporary_fd_) { + // Close the temporary file descriptor opened earlier. + close(fd); } + return s; } - // Release a slot acquired by a previous call to Acquire() that returned true. - void Release() { - MutexLock l(&mu_); - SetAllowed(GetAllowed() + 1); - } - - private: - port::Mutex mu_; - port::AtomicPointer allowed_; - - intptr_t GetAllowed() const { - return reinterpret_cast(allowed_.Acquire_Load()); - } - - // REQUIRES: mu_ must be held - void SetAllowed(intptr_t v) { - allowed_.Release_Store(reinterpret_cast(v)); - } - - MmapLimiter(const MmapLimiter&); - void operator=(const MmapLimiter&); + virtual std::string GetName() const { return filename_; } }; // mmap() based random-access @@ -145,12 +184,12 @@ class PosixMmapReadableFile: public RandomAccessFile { std::string filename_; void* mmapped_region_; size_t length_; - MmapLimiter* limiter_; + Limiter* limiter_; public: // base[0,length-1] contains the mmapped contents of the file. PosixMmapReadableFile(const std::string& fname, void* base, size_t length, - MmapLimiter* limiter) + Limiter* limiter) : filename_(fname), mmapped_region_(base), length_(length), limiter_(limiter) { } @@ -171,6 +210,8 @@ class PosixMmapReadableFile: public RandomAccessFile { } return s; } + + virtual std::string GetName() const { return filename_; } }; class PosixWritableFile : public WritableFile { @@ -231,7 +272,7 @@ class PosixWritableFile : public WritableFile { if (fd < 0) { s = IOError(dir, errno); } else { - if (fsync(fd) < 0) { + if (fsync(fd) < 0 && errno != EINVAL) { s = IOError(dir, errno); } close(fd); @@ -252,6 +293,8 @@ class PosixWritableFile : public WritableFile { } return s; } + + virtual std::string GetName() const { return filename_; } }; static int LockOrUnlock(int fd, bool lock) { @@ -333,7 +376,7 @@ class PosixEnv : public Env { mmap_limit_.Release(); } } else { - *result = new PosixRandomAccessFile(fname, fd); + *result = new PosixRandomAccessFile(fname, fd, &fd_limit_); } return s; } @@ -351,6 +394,19 @@ class PosixEnv : public Env { return s; } + virtual Status NewAppendableFile(const std::string& fname, + WritableFile** result) { + Status s; + FILE* f = fopen(fname.c_str(), "a"); + if (f == NULL) { + *result = NULL; + s = IOError(fname, errno); + } else { + *result = new PosixWritableFile(fname, f); + } + return s; + } + virtual bool FileExists(const std::string& fname) { return access(fname.c_str(), F_OK) == 0; } @@ -520,10 +576,42 @@ class PosixEnv : public Env { BGQueue queue_; PosixLockTable locks_; - MmapLimiter mmap_limit_; + Limiter mmap_limit_; + Limiter fd_limit_; }; -PosixEnv::PosixEnv() : started_bgthread_(false) { +// Return the maximum number of concurrent mmaps. +static int MaxMmaps() { + if (mmap_limit >= 0) { + return mmap_limit; + } + // Up to 4096 mmaps for 64-bit binaries; none for smaller pointer sizes. + mmap_limit = sizeof(void*) >= 8 ? 4096 : 0; + return mmap_limit; +} + +// Return the maximum number of read-only files to keep open. +static intptr_t MaxOpenFiles() { + if (open_read_only_file_limit >= 0) { + return open_read_only_file_limit; + } + struct rlimit rlim; + if (getrlimit(RLIMIT_NOFILE, &rlim)) { + // getrlimit failed, fallback to hard-coded default. + open_read_only_file_limit = 50; + } else if (rlim.rlim_cur == RLIM_INFINITY) { + open_read_only_file_limit = std::numeric_limits::max(); + } else { + // Allow use of 20% of available file descriptors for read-only files. + open_read_only_file_limit = rlim.rlim_cur / 5; + } + return open_read_only_file_limit; +} + +PosixEnv::PosixEnv() + : started_bgthread_(false), + mmap_limit_(MaxMmaps()), + fd_limit_(MaxOpenFiles()) { PthreadCall("mutex_init", pthread_mutex_init(&mu_, NULL)); PthreadCall("cvar_init", pthread_cond_init(&bgsignal_, NULL)); } @@ -598,6 +686,16 @@ static pthread_once_t once = PTHREAD_ONCE_INIT; static Env* default_env; static void InitDefaultEnv() { default_env = new PosixEnv; } +void EnvPosixTestHelper::SetReadOnlyFDLimit(int limit) { + assert(default_env == NULL); + open_read_only_file_limit = limit; +} + +void EnvPosixTestHelper::SetReadOnlyMMapLimit(int limit) { + assert(default_env == NULL); + mmap_limit = limit; +} + Env* Env::Default() { pthread_once(&once, InitDefaultEnv); return default_env; diff --git a/depend/zcash/src/leveldb/util/env_posix_test.cc b/depend/zcash/src/leveldb/util/env_posix_test.cc new file mode 100644 index 000000000..295f8ae44 --- /dev/null +++ b/depend/zcash/src/leveldb/util/env_posix_test.cc @@ -0,0 +1,66 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/env.h" + +#include "port/port.h" +#include "util/testharness.h" +#include "util/env_posix_test_helper.h" + +namespace leveldb { + +static const int kDelayMicros = 100000; +static const int kReadOnlyFileLimit = 4; +static const int kMMapLimit = 4; + +class EnvPosixTest { + public: + Env* env_; + EnvPosixTest() : env_(Env::Default()) { } + + static void SetFileLimits(int read_only_file_limit, int mmap_limit) { + EnvPosixTestHelper::SetReadOnlyFDLimit(read_only_file_limit); + EnvPosixTestHelper::SetReadOnlyMMapLimit(mmap_limit); + } +}; + +TEST(EnvPosixTest, TestOpenOnRead) { + // Write some test data to a single file that will be opened |n| times. + std::string test_dir; + ASSERT_OK(env_->GetTestDirectory(&test_dir)); + std::string test_file = test_dir + "/open_on_read.txt"; + + FILE* f = fopen(test_file.c_str(), "w"); + ASSERT_TRUE(f != NULL); + const char kFileData[] = "abcdefghijklmnopqrstuvwxyz"; + fputs(kFileData, f); + fclose(f); + + // Open test file some number above the sum of the two limits to force + // open-on-read behavior of POSIX Env leveldb::RandomAccessFile. + const int kNumFiles = kReadOnlyFileLimit + kMMapLimit + 5; + leveldb::RandomAccessFile* files[kNumFiles] = {0}; + for (int i = 0; i < kNumFiles; i++) { + ASSERT_OK(env_->NewRandomAccessFile(test_file, &files[i])); + } + char scratch; + Slice read_result; + for (int i = 0; i < kNumFiles; i++) { + ASSERT_OK(files[i]->Read(i, 1, &read_result, &scratch)); + ASSERT_EQ(kFileData[i], read_result[0]); + } + for (int i = 0; i < kNumFiles; i++) { + delete files[i]; + } + ASSERT_OK(env_->DeleteFile(test_file)); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + // All tests currently run with the same read-only file limits. + leveldb::EnvPosixTest::SetFileLimits(leveldb::kReadOnlyFileLimit, + leveldb::kMMapLimit); + return leveldb::test::RunAllTests(); +} diff --git a/depend/zcash/src/leveldb/util/env_posix_test_helper.h b/depend/zcash/src/leveldb/util/env_posix_test_helper.h new file mode 100644 index 000000000..038696059 --- /dev/null +++ b/depend/zcash/src/leveldb/util/env_posix_test_helper.h @@ -0,0 +1,28 @@ +// Copyright 2017 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_UTIL_ENV_POSIX_TEST_HELPER_H_ +#define STORAGE_LEVELDB_UTIL_ENV_POSIX_TEST_HELPER_H_ + +namespace leveldb { + +class EnvPosixTest; + +// A helper for the POSIX Env to facilitate testing. +class EnvPosixTestHelper { + private: + friend class EnvPosixTest; + + // Set the maximum number of read-only files that will be opened. + // Must be called before creating an Env. + static void SetReadOnlyFDLimit(int limit); + + // Set the maximum number of read-only files that will be mapped via mmap. + // Must be called before creating an Env. + static void SetReadOnlyMMapLimit(int limit); +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_UTIL_ENV_POSIX_TEST_HELPER_H_ diff --git a/depend/zcash/src/leveldb/util/env_test.cc b/depend/zcash/src/leveldb/util/env_test.cc index b72cb4438..839ae56a1 100644 --- a/depend/zcash/src/leveldb/util/env_test.cc +++ b/depend/zcash/src/leveldb/util/env_test.cc @@ -10,29 +10,31 @@ namespace leveldb { static const int kDelayMicros = 100000; +static const int kReadOnlyFileLimit = 4; +static const int kMMapLimit = 4; -class EnvPosixTest { +class EnvTest { private: port::Mutex mu_; std::string events_; public: Env* env_; - EnvPosixTest() : env_(Env::Default()) { } + EnvTest() : env_(Env::Default()) { } }; static void SetBool(void* ptr) { reinterpret_cast(ptr)->NoBarrier_Store(ptr); } -TEST(EnvPosixTest, RunImmediately) { +TEST(EnvTest, RunImmediately) { port::AtomicPointer called (NULL); env_->Schedule(&SetBool, &called); - Env::Default()->SleepForMicroseconds(kDelayMicros); + env_->SleepForMicroseconds(kDelayMicros); ASSERT_TRUE(called.NoBarrier_Load() != NULL); } -TEST(EnvPosixTest, RunMany) { +TEST(EnvTest, RunMany) { port::AtomicPointer last_id (NULL); struct CB { @@ -59,7 +61,7 @@ TEST(EnvPosixTest, RunMany) { env_->Schedule(&CB::Run, &cb3); env_->Schedule(&CB::Run, &cb4); - Env::Default()->SleepForMicroseconds(kDelayMicros); + env_->SleepForMicroseconds(kDelayMicros); void* cur = last_id.Acquire_Load(); ASSERT_EQ(4, reinterpret_cast(cur)); } @@ -78,7 +80,7 @@ static void ThreadBody(void* arg) { s->mu.Unlock(); } -TEST(EnvPosixTest, StartThread) { +TEST(EnvTest, StartThread) { State state; state.val = 0; state.num_running = 3; @@ -92,7 +94,7 @@ TEST(EnvPosixTest, StartThread) { if (num == 0) { break; } - Env::Default()->SleepForMicroseconds(kDelayMicros); + env_->SleepForMicroseconds(kDelayMicros); } ASSERT_EQ(state.val, 3); } diff --git a/depend/zcash/src/leveldb/util/env_win.cc b/depend/zcash/src/leveldb/util/env_win.cc index e11a96b79..830332abe 100644 --- a/depend/zcash/src/leveldb/util/env_win.cc +++ b/depend/zcash/src/leveldb/util/env_win.cc @@ -1,7 +1,7 @@ // This file contains source that originates from: // http://code.google.com/p/leveldbwin/source/browse/trunk/win32_impl_src/env_win32.h // http://code.google.com/p/leveldbwin/source/browse/trunk/win32_impl_src/port_win32.cc -// Those files dont' have any explict license headers but the +// Those files don't have any explicit license headers but the // project (http://code.google.com/p/leveldbwin/) lists the 'New BSD License' // as the license. #if defined(LEVELDB_PLATFORM_WINDOWS) @@ -78,6 +78,7 @@ class Win32SequentialFile : public SequentialFile virtual Status Read(size_t n, Slice* result, char* scratch); virtual Status Skip(uint64_t n); BOOL isEnable(); + virtual std::string GetName() const { return _filename; } private: BOOL _Init(); void _CleanUp(); @@ -94,6 +95,7 @@ class Win32RandomAccessFile : public RandomAccessFile virtual ~Win32RandomAccessFile(); virtual Status Read(uint64_t offset, size_t n, Slice* result,char* scratch) const; BOOL isEnable(); + virtual std::string GetName() const { return _filename; } private: BOOL _Init(LPCWSTR path); void _CleanUp(); @@ -106,7 +108,7 @@ class Win32RandomAccessFile : public RandomAccessFile class Win32WritableFile : public WritableFile { public: - Win32WritableFile(const std::string& fname); + Win32WritableFile(const std::string& fname, bool append); ~Win32WritableFile(); virtual Status Append(const Slice& data); @@ -114,6 +116,7 @@ class Win32WritableFile : public WritableFile virtual Status Flush(); virtual Status Sync(); BOOL isEnable(); + virtual std::string GetName() const { return filename_; } private: std::string filename_; ::HANDLE _hFile; @@ -158,6 +161,8 @@ class Win32Env : public Env RandomAccessFile** result); virtual Status NewWritableFile(const std::string& fname, WritableFile** result); + virtual Status NewAppendableFile(const std::string& fname, + WritableFile** result); virtual bool FileExists(const std::string& fname); @@ -198,24 +203,16 @@ class Win32Env : public Env void ToWidePath(const std::string& value, std::wstring& target) { wchar_t buffer[MAX_PATH]; - MultiByteToWideChar(CP_ACP, 0, value.c_str(), -1, buffer, MAX_PATH); + MultiByteToWideChar(CP_UTF8, 0, value.c_str(), -1, buffer, MAX_PATH); target = buffer; } void ToNarrowPath(const std::wstring& value, std::string& target) { char buffer[MAX_PATH]; - WideCharToMultiByte(CP_ACP, 0, value.c_str(), -1, buffer, MAX_PATH, NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, value.c_str(), -1, buffer, MAX_PATH, NULL, NULL); target = buffer; } -std::string GetCurrentDir() -{ - CHAR path[MAX_PATH]; - ::GetModuleFileNameA(::GetModuleHandleA(NULL),path,MAX_PATH); - *strrchr(path,'\\') = 0; - return std::string(path); -} - std::wstring GetCurrentDirW() { WCHAR path[MAX_PATH]; @@ -224,6 +221,13 @@ std::wstring GetCurrentDirW() return std::wstring(path); } +std::string GetCurrentDir() +{ + std::string path; + ToNarrowPath(GetCurrentDirW(), path); + return path; +} + std::string& ModifyPath(std::string& path) { if(path[0] == '/' || path[0] == '\\'){ @@ -353,11 +357,13 @@ BOOL Win32SequentialFile::_Init() ToWidePath(_filename, path); _hFile = CreateFileW(path.c_str(), GENERIC_READ, - FILE_SHARE_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + if (_hFile == INVALID_HANDLE_VALUE) + _hFile = NULL; return _hFile ? TRUE : FALSE; } @@ -401,7 +407,7 @@ BOOL Win32RandomAccessFile::_Init( LPCWSTR path ) { BOOL bRet = FALSE; if(!_hFile) - _hFile = ::CreateFileW(path,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING, + _hFile = ::CreateFileW(path,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,NULL); if(!_hFile || _hFile == INVALID_HANDLE_VALUE ) _hFile = NULL; @@ -423,17 +429,23 @@ void Win32RandomAccessFile::_CleanUp() } } -Win32WritableFile::Win32WritableFile(const std::string& fname) +Win32WritableFile::Win32WritableFile(const std::string& fname, bool append) : filename_(fname) { std::wstring path; ToWidePath(fname, path); - DWORD Flag = PathFileExistsW(path.c_str()) ? OPEN_EXISTING : CREATE_ALWAYS; + // NewAppendableFile: append to an existing file, or create a new one + // if none exists - this is OPEN_ALWAYS behavior, with + // FILE_APPEND_DATA to avoid having to manually position the file + // pointer at the end of the file. + // NewWritableFile: create a new file, delete if it exists - this is + // CREATE_ALWAYS behavior. This file is used for writing only so + // use GENERIC_WRITE. _hFile = CreateFileW(path.c_str(), - GENERIC_READ | GENERIC_WRITE, + append ? FILE_APPEND_DATA : GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_DELETE|FILE_SHARE_WRITE, NULL, - Flag, + append ? OPEN_ALWAYS : CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); // CreateFileW returns INVALID_HANDLE_VALUE in case of error, always check isEnable() before use @@ -661,7 +673,7 @@ Status Win32Env::GetFileSize( const std::string& fname, uint64_t* file_size ) ToWidePath(ModifyPath(path), wpath); HANDLE file = ::CreateFileW(wpath.c_str(), - GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); + GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); LARGE_INTEGER li; if(::GetFileSizeEx(file,&li)){ *file_size = (uint64_t)li.QuadPart; @@ -751,14 +763,16 @@ uint64_t Win32Env::NowMicros() static Status CreateDirInner( const std::string& dirname ) { Status sRet; - DWORD attr = ::GetFileAttributes(dirname.c_str()); + std::wstring dirnameW; + ToWidePath(dirname, dirnameW); + DWORD attr = ::GetFileAttributesW(dirnameW.c_str()); if (attr == INVALID_FILE_ATTRIBUTES) { // doesn't exist: std::size_t slash = dirname.find_last_of("\\"); if (slash != std::string::npos){ sRet = CreateDirInner(dirname.substr(0, slash)); if (!sRet.ok()) return sRet; } - BOOL result = ::CreateDirectory(dirname.c_str(), NULL); + BOOL result = ::CreateDirectoryW(dirnameW.c_str(), NULL); if (result == FALSE) { sRet = Status::IOError(dirname, "Could not create directory."); return sRet; @@ -823,7 +837,9 @@ Status Win32Env::NewLogger( const std::string& fname, Logger** result ) { Status sRet; std::string path = fname; - Win32WritableFile* pMapFile = new Win32WritableFile(ModifyPath(path)); + // Logs are opened with write semantics, not with append semantics + // (see PosixEnv::NewLogger) + Win32WritableFile* pMapFile = new Win32WritableFile(ModifyPath(path), false); if(!pMapFile->isEnable()){ delete pMapFile; *result = NULL; @@ -837,7 +853,20 @@ Status Win32Env::NewWritableFile( const std::string& fname, WritableFile** resul { Status sRet; std::string path = fname; - Win32WritableFile* pFile = new Win32WritableFile(ModifyPath(path)); + Win32WritableFile* pFile = new Win32WritableFile(ModifyPath(path), false); + if(!pFile->isEnable()){ + *result = NULL; + sRet = Status::IOError(fname,Win32::GetLastErrSz()); + }else + *result = pFile; + return sRet; +} + +Status Win32Env::NewAppendableFile( const std::string& fname, WritableFile** result ) +{ + Status sRet; + std::string path = fname; + Win32WritableFile* pFile = new Win32WritableFile(ModifyPath(path), true); if(!pFile->isEnable()){ *result = NULL; sRet = Status::IOError(fname,Win32::GetLastErrSz()); diff --git a/depend/zcash/src/leveldb/util/logging.cc b/depend/zcash/src/leveldb/util/logging.cc index ca6b32440..db6160c8f 100644 --- a/depend/zcash/src/leveldb/util/logging.cc +++ b/depend/zcash/src/leveldb/util/logging.cc @@ -49,7 +49,7 @@ bool ConsumeDecimalNumber(Slice* in, uint64_t* val) { uint64_t v = 0; int digits = 0; while (!in->empty()) { - char c = (*in)[0]; + unsigned char c = (*in)[0]; if (c >= '0' && c <= '9') { ++digits; const int delta = (c - '0'); diff --git a/depend/zcash/src/leveldb/util/options.cc b/depend/zcash/src/leveldb/util/options.cc index 76af5b930..b5e622761 100644 --- a/depend/zcash/src/leveldb/util/options.cc +++ b/depend/zcash/src/leveldb/util/options.cc @@ -21,9 +21,10 @@ Options::Options() block_cache(NULL), block_size(4096), block_restart_interval(16), + max_file_size(2<<20), compression(kSnappyCompression), + reuse_logs(false), filter_policy(NULL) { } - } // namespace leveldb diff --git a/depend/zcash/src/leveldb/util/testutil.h b/depend/zcash/src/leveldb/util/testutil.h index adad3fc1e..d7e458370 100644 --- a/depend/zcash/src/leveldb/util/testutil.h +++ b/depend/zcash/src/leveldb/util/testutil.h @@ -45,6 +45,16 @@ class ErrorEnv : public EnvWrapper { } return target()->NewWritableFile(fname, result); } + + virtual Status NewAppendableFile(const std::string& fname, + WritableFile** result) { + if (writable_file_error_) { + ++num_writable_file_errors_; + *result = NULL; + return Status::IOError(fname, "fake error"); + } + return target()->NewAppendableFile(fname, result); + } }; } // namespace test diff --git a/depend/zcash/src/logging.cpp b/depend/zcash/src/logging.cpp new file mode 100644 index 000000000..2b75d642c --- /dev/null +++ b/depend/zcash/src/logging.cpp @@ -0,0 +1,163 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2018 The Bitcoin Core developers +// Copyright (c) 2018-2020 The Zcash developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "logging.h" + +#include "serialize.h" +#include "util.h" + +#include + +#include +#include +#include +#include + +using namespace std; + +const char * const DEFAULT_DEBUGLOGFILE = "debug.log"; + +bool fPrintToConsole = false; +bool fPrintToDebugLog = true; + +bool fLogTimestamps = DEFAULT_LOGTIMESTAMPS; +bool fLogTimeMicros = DEFAULT_LOGTIMEMICROS; +bool fLogIPs = DEFAULT_LOGIPS; +std::atomic fReopenDebugLog(false); + +/** + * LogPrintf() has been broken a couple of times now + * by well-meaning people adding mutexes in the most straightforward way. + * It breaks because it may be called by global destructors during shutdown. + * Since the order of destruction of static/global objects is undefined, + * defining a mutex as a global object doesn't work (the mutex gets + * destroyed, and then some later destructor calls OutputDebugStringF, + * maybe indirectly, and you get a core dump at shutdown trying to lock + * the mutex). + */ + +static boost::once_flag debugPrintInitFlag = BOOST_ONCE_INIT; + +/** + * We use boost::call_once() to make sure mutexDebugLog and + * vMsgsBeforeOpenLog are initialized in a thread-safe manner. + * + * NOTE: fileout, mutexDebugLog and sometimes vMsgsBeforeOpenLog + * are leaked on exit. This is ugly, but will be cleaned up by + * the OS/libc. When the shutdown sequence is fully audited and + * tested, explicit destruction of these objects can be implemented. + */ +static FILE* fileout = NULL; +static boost::mutex* mutexDebugLog = NULL; +static list *vMsgsBeforeOpenLog; + +[[noreturn]] void new_handler_terminate() +{ + // Rather than throwing std::bad-alloc if allocation fails, terminate + // immediately to (try to) avoid chain corruption. + // Since LogPrintf may itself allocate memory, set the handler directly + // to terminate first. + std::set_new_handler(std::terminate); + fputs("Error: Out of memory. Terminating.\n", stderr); + LogPrintf("Error: Out of memory. Terminating.\n"); + + // The log was successful, terminate now. + std::terminate(); +}; + +static int FileWriteStr(const std::string &str, FILE *fp) +{ + return fwrite(str.data(), 1, str.size(), fp); +} + +static void DebugPrintInit() +{ + assert(mutexDebugLog == NULL); + mutexDebugLog = new boost::mutex(); + vMsgsBeforeOpenLog = new list; +} + +boost::filesystem::path GetDebugLogPath() +{ + boost::filesystem::path logfile(GetArg("-debuglogfile", DEFAULT_DEBUGLOGFILE)); + if (logfile.is_absolute()) { + return logfile; + } else { + return GetDataDir() / logfile; + } +} + +std::string LogConfigFilter() +{ + // With no -debug flags, show errors and LogPrintf lines. + std::string filter = "error,main=info"; + + auto& categories = mapMultiArgs["-debug"]; + std::set setCategories(categories.begin(), categories.end()); + if (setCategories.count(string("")) != 0 || setCategories.count(string("1")) != 0) { + // Turn on the firehose! + filter = "debug"; + } else { + for (auto category : setCategories) { + filter += "," + category + "=debug"; + } + } + + return filter; +} + +bool LogAcceptCategory(const char* category) +{ + if (category != NULL) + { + if (!fDebug) + return false; + + // Give each thread quick access to -debug settings. + // This helps prevent issues debugging global destructors, + // where mapMultiArgs might be deleted before another + // global destructor calls LogPrint() + static boost::thread_specific_ptr > ptrCategory; + if (ptrCategory.get() == NULL) + { + const vector& categories = mapMultiArgs["-debug"]; + ptrCategory.reset(new set(categories.begin(), categories.end())); + // thread_specific_ptr automatically deletes the set when the thread ends. + } + const set& setCategories = *ptrCategory.get(); + + // if not debugging everything and not debugging specific category, LogPrint does nothing. + if (setCategories.count(string("")) == 0 && + setCategories.count(string("1")) == 0 && + setCategories.count(string(category)) == 0) + return false; + } + return true; +} + +void ShrinkDebugFile() +{ + // Scroll debug.log if it's getting too big + boost::filesystem::path pathLog = GetDebugLogPath(); + FILE* file = fopen(pathLog.string().c_str(), "r"); + if (file && boost::filesystem::file_size(pathLog) > 10 * 1000000) + { + // Restart the file with some of the end + std::vector vch(200000,0); + fseek(file, -((long)vch.size()), SEEK_END); + int nBytes = fread(begin_ptr(vch), 1, vch.size(), file); + fclose(file); + + file = fopen(pathLog.string().c_str(), "w"); + if (file) + { + fwrite(begin_ptr(vch), 1, nBytes, file); + fclose(file); + } + } + else if (file != NULL) + fclose(file); +} diff --git a/depend/zcash/src/logging.h b/depend/zcash/src/logging.h new file mode 100644 index 000000000..bd40efcff --- /dev/null +++ b/depend/zcash/src/logging.h @@ -0,0 +1,60 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2018 The Bitcoin Core developers +// Copyright (c) 2018-2020 The Zcash developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef ZCASH_LOGGING_H +#define ZCASH_LOGGING_H + +#include "tinyformat.h" + +#include +#include + +#include + +#include + +static const bool DEFAULT_LOGTIMEMICROS = false; +static const bool DEFAULT_LOGIPS = false; +static const bool DEFAULT_LOGTIMESTAMPS = true; +extern const char * const DEFAULT_DEBUGLOGFILE; + +extern bool fPrintToConsole; +extern bool fPrintToDebugLog; + +extern bool fLogTimestamps; +extern bool fLogIPs; +extern std::atomic fReopenDebugLog; + +/** Returns the filtering directive set by the -debug flags. */ +std::string LogConfigFilter(); + +/** Return true if log accepts specified category */ +bool LogAcceptCategory(const char* category); + +/** Print to debug.log with level INFO and category "main". */ +#define LogPrintf(...) LogPrintInner("info", "main", __VA_ARGS__) + +/** Print to debug.log with level DEBUG. */ +#define LogPrint(category, ...) LogPrintInner("debug", category, __VA_ARGS__) + +#define LogPrintInner(level, category, ...) do { \ + std::string T_MSG = tfm::format(__VA_ARGS__); \ + if (!T_MSG.empty() && T_MSG[T_MSG.size()-1] == '\n') { \ + T_MSG.erase(T_MSG.size()-1); \ + } \ + TracingLog(level, category, T_MSG.c_str()); \ +} while(0) + +#define LogError(category, ...) ([&]() { \ + std::string T_MSG = tfm::format(__VA_ARGS__); \ + TracingError(category, T_MSG.c_str()); \ + return false; \ +}()) + +boost::filesystem::path GetDebugLogPath(); +void ShrinkDebugFile(); + +#endif // ZCASH_LOGGING_H diff --git a/depend/zcash/src/main.cpp b/depend/zcash/src/main.cpp index 42ec6c108..2742b141f 100644 --- a/depend/zcash/src/main.cpp +++ b/depend/zcash/src/main.cpp @@ -81,6 +81,7 @@ bool fPruneMode = false; bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG; bool fCheckBlockIndex = false; bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED; +bool fIBDSkipTxVerification = DEFAULT_IBD_SKIP_TX_VERIFICATION; bool fCoinbaseEnforcedShieldingEnabled = true; size_t nCoinCacheUsage = 5000 * 300; uint64_t nPruneTarget = 0; @@ -120,7 +121,7 @@ namespace { /** Abort with a message */ bool AbortNode(const std::string& strMessage, const std::string& userMessage="") { - SetMiscWarning(strMessage); + SetMiscWarning(strMessage, GetTime()); LogPrintf("*** %s\n", strMessage); uiInterface.ThreadSafeMessageBox( userMessage.empty() ? _("Error: A fatal internal error occurred, see debug.log for details") : userMessage, @@ -762,7 +763,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in /** * Check a transaction contextually against a set of consensus rules valid at a given block height. - * + * * Notes: * 1. AcceptToMemoryPool calls CheckTransaction and this function. * 2. ProcessNewBlock calls AcceptBlock, which calls CheckBlock (which calls CheckTransaction) @@ -793,97 +794,100 @@ bool ContextualCheckTransaction( bool overwinterActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_OVERWINTER); bool saplingActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_SAPLING); - bool isSprout = !overwinterActive; + bool beforeOverwinter = !overwinterActive; bool heartwoodActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_HEARTWOOD); bool canopyActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_CANOPY); - // If Sprout rules apply, reject transactions which are intended for Overwinter and beyond - if (isSprout && tx.fOverwintered) { - return state.DoS( - dosLevelPotentiallyRelaxing, - error("ContextualCheckTransaction(): overwinter is not active yet"), - REJECT_INVALID, "tx-overwinter-not-active"); + assert(!saplingActive || overwinterActive); // Sapling cannot be active unless Overwinter is + assert(!heartwoodActive || saplingActive); // Heartwood cannot be active unless Sapling is + assert(!canopyActive || heartwoodActive); // Canopy cannot be active unless Heartwood is + + // Rules that apply only to Sprout + if (beforeOverwinter) { + // Reject transactions which are intended for Overwinter and beyond + if (tx.fOverwintered) { + return state.DoS( + dosLevelPotentiallyRelaxing, + error("ContextualCheckTransaction(): overwinter is not active yet"), + REJECT_INVALID, "tx-overwinter-not-active"); + } } - if (saplingActive) { - // Reject transactions with valid version but missing overwintered flag - if (tx.nVersion >= SAPLING_MIN_TX_VERSION && !tx.fOverwintered) { + // Rules that apply to Overwinter and later: + if (overwinterActive) { + // Reject transactions intended for Sprout + if (!tx.fOverwintered) { return state.DoS( dosLevelConstricting, - error("ContextualCheckTransaction(): overwintered flag must be set"), + error("ContextualCheckTransaction(): fOverwintered flag must be set when Overwinter is active"), REJECT_INVALID, "tx-overwintered-flag-not-set"); } + // The condition `if (tx.nVersion < OVERWINTER_MIN_TX_VERSION)` + // that would otherwise fire here is already performed in the + // noncontextual checks in CheckTransactionWithoutProofVerification + + // Check that all transactions are unexpired + if (IsExpiredTx(tx, nHeight)) { + // Don't increase banscore if the transaction only just expired + int expiredDosLevel = IsExpiredTx(tx, nHeight - 1) ? dosLevelConstricting : 0; + return state.DoS( + expiredDosLevel, + error("ContextualCheckTransaction(): transaction is expired. Resending when caught up with the blockchain, or manually setting the zcashd txexpirydelta parameter may help."), + REJECT_INVALID, "tx-overwinter-expired"); + } + + // Rules that became inactive after Sapling activation. + if (!saplingActive) { + // Reject transactions with invalid version + if (tx.nVersion > OVERWINTER_MAX_TX_VERSION ) { + return state.DoS( + dosLevelPotentiallyRelaxing, + error("ContextualCheckTransaction(): overwinter version too high"), + REJECT_INVALID, "bad-tx-overwinter-version-too-high"); + } + + // Reject transactions with non-Overwinter version group ID + if (tx.nVersionGroupId != OVERWINTER_VERSION_GROUP_ID) { + return state.DoS( + dosLevelPotentiallyRelaxing, + error("ContextualCheckTransaction(): invalid Overwinter tx version"), + REJECT_INVALID, "bad-overwinter-tx-version-group-id"); + } + } + } + + // Rules that apply to Sapling and later: + if (saplingActive) { // Reject transactions with non-Sapling version group ID - if (tx.fOverwintered && tx.nVersionGroupId != SAPLING_VERSION_GROUP_ID) { + if (tx.nVersionGroupId != SAPLING_VERSION_GROUP_ID) { return state.DoS( dosLevelPotentiallyRelaxing, - error("CheckTransaction(): invalid Sapling tx version"), + error("ContextualCheckTransaction(): invalid Sapling tx version"), REJECT_INVALID, "bad-sapling-tx-version-group-id"); } // Reject transactions with invalid version - if (tx.fOverwintered && tx.nVersion < SAPLING_MIN_TX_VERSION ) { + if (tx.nVersion < SAPLING_MIN_TX_VERSION) { return state.DoS( dosLevelConstricting, - error("CheckTransaction(): Sapling version too low"), + error("ContextualCheckTransaction(): Sapling version too low"), REJECT_INVALID, "bad-tx-sapling-version-too-low"); } // Reject transactions with invalid version - if (tx.fOverwintered && tx.nVersion > SAPLING_MAX_TX_VERSION ) { + if (tx.nVersion > SAPLING_MAX_TX_VERSION) { return state.DoS( dosLevelPotentiallyRelaxing, - error("CheckTransaction(): Sapling version too high"), + error("ContextualCheckTransaction(): Sapling version too high"), REJECT_INVALID, "bad-tx-sapling-version-too-high"); } - } else if (overwinterActive) { - // Reject transactions with valid version but missing overwinter flag - if (tx.nVersion >= OVERWINTER_MIN_TX_VERSION && !tx.fOverwintered) { - return state.DoS( - dosLevelConstricting, - error("ContextualCheckTransaction(): overwinter flag must be set"), - REJECT_INVALID, "tx-overwinter-flag-not-set"); - } - - // Reject transactions with non-Overwinter version group ID - if (tx.fOverwintered && tx.nVersionGroupId != OVERWINTER_VERSION_GROUP_ID) { - return state.DoS( - dosLevelPotentiallyRelaxing, - error("CheckTransaction(): invalid Overwinter tx version"), - REJECT_INVALID, "bad-overwinter-tx-version-group-id"); - } - - // Reject transactions with invalid version - if (tx.fOverwintered && tx.nVersion > OVERWINTER_MAX_TX_VERSION ) { - return state.DoS( - dosLevelPotentiallyRelaxing, - error("CheckTransaction(): overwinter version too high"), - REJECT_INVALID, "bad-tx-overwinter-version-too-high"); - } - } - - // Rules that apply to Overwinter or later: - if (overwinterActive) { - // Reject transactions intended for Sprout - if (!tx.fOverwintered) { - return state.DoS( - dosLevelConstricting, - error("ContextualCheckTransaction: overwinter is active"), - REJECT_INVALID, "tx-overwinter-active"); - } - - // Check that all transactions are unexpired - if (IsExpiredTx(tx, nHeight)) { - // Don't increase banscore if the transaction only just expired - int expiredDosLevel = IsExpiredTx(tx, nHeight - 1) ? dosLevelConstricting : 0; - return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction is expired"), REJECT_INVALID, "tx-overwinter-expired"); - } - } + } else { + // Rules that apply generally before Sapling. These were + // previously noncontextual checks that became contextual + // after Sapling activation. - // Rules that apply before Sapling: - if (!saplingActive) { - // Size limits + // Reject transactions that exceed pre-sapling size limits BOOST_STATIC_ASSERT(MAX_BLOCK_SIZE > MAX_TX_SIZE_BEFORE_SAPLING); // sanity if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_TX_SIZE_BEFORE_SAPLING) return state.DoS( @@ -892,31 +896,16 @@ bool ContextualCheckTransaction( REJECT_INVALID, "bad-txns-oversize"); } - // Rules that apply before Heartwood: - if (!heartwoodActive) { - if (tx.IsCoinBase()) { - // A coinbase transaction cannot have output descriptions - if (tx.vShieldedOutput.size() > 0) - return state.DoS( - dosLevelPotentiallyRelaxing, - error("CheckTransaction(): coinbase has output descriptions"), - REJECT_INVALID, "bad-cb-has-output-description"); - } - } - // From Canopy onward, coinbase transaction must include outputs corresponding to the // ZIP 207 consensus funding streams active at the current block height. To avoid // double-decrypting, we detect any shielded funding streams during the Heartwood // consensus check. If Canopy is not yet active, fundingStreamElements will be empty. - std::set fundingStreamElements; - if (canopyActive) { - fundingStreamElements = Consensus::GetActiveFundingStreamElements( - nHeight, - GetBlockSubsidy(nHeight, chainparams.GetConsensus()), - chainparams.GetConsensus()); - } + std::set fundingStreamElements = Consensus::GetActiveFundingStreamElements( + nHeight, + GetBlockSubsidy(nHeight, chainparams.GetConsensus()), + chainparams.GetConsensus()); - // Rules that apply to Heartwood or later: + // Rules that apply to Heartwood and later: if (heartwoodActive) { if (tx.IsCoinBase()) { // All Sapling outputs in coinbase transactions MUST have valid note commitments @@ -929,9 +918,8 @@ bool ContextualCheckTransaction( if (!outPlaintext) { return state.DoS( DOS_LEVEL_BLOCK, - error("CheckTransaction(): coinbase output description has invalid outCiphertext"), - REJECT_INVALID, - "bad-cb-output-desc-invalid-outct"); + error("ContextualCheckTransaction(): coinbase output description has invalid outCiphertext"), + REJECT_INVALID, "bad-cb-output-desc-invalid-outct"); } // SaplingNotePlaintext::decrypt() checks note commitment validity. @@ -947,9 +935,8 @@ bool ContextualCheckTransaction( if (!encPlaintext) { return state.DoS( DOS_LEVEL_BLOCK, - error("CheckTransaction(): coinbase output description has invalid encCiphertext"), - REJECT_INVALID, - "bad-cb-output-desc-invalid-encct"); + error("ContextualCheckTransaction(): coinbase output description has invalid encCiphertext"), + REJECT_INVALID, "bad-cb-output-desc-invalid-encct"); } // ZIP 207: detect shielded funding stream elements @@ -964,26 +951,41 @@ bool ContextualCheckTransaction( } } - // ZIP 212: Check that the note plaintexts use the v2 note plaintext - // version. - // This check compels miners to switch to the new plaintext version - // and overrides the grace period in plaintext_version_is_valid() + // ZIP 212: after ZIP 212 any Sapling output of a coinbase tx that is + // decrypted to a note plaintext, MUST have note plaintext lead byte equal + // to 0x02. This applies even during the grace period, and also applies to + // funding stream outputs sent to shielded payment addresses, if any. + // https://zips.z.cash/zip-0212#consensus-rule-change-for-coinbase-transactions if (canopyActive != (encPlaintext->get_leadbyte() == 0x02)) { return state.DoS( DOS_LEVEL_BLOCK, - error("CheckTransaction(): coinbase output description has invalid note plaintext version"), + error("ContextualCheckTransaction(): coinbase output description has invalid note plaintext version"), REJECT_INVALID, "bad-cb-output-desc-invalid-note-plaintext-version"); } } } + } else { + // Rules that apply generally before Heartwood. These were + // previously noncontextual checks that became contextual + // after Heartwood activation. + + if (tx.IsCoinBase()) { + // A coinbase transaction cannot have output descriptions + if (tx.vShieldedOutput.size() > 0) + return state.DoS( + dosLevelPotentiallyRelaxing, + error("ContextualCheckTransaction(): coinbase has output descriptions"), + REJECT_INVALID, "bad-cb-has-output-description"); + } } // Rules that apply to Canopy or later: if (canopyActive) { for (const JSDescription& joinsplit : tx.vJoinSplit) { if (joinsplit.vpub_old > 0) { - return state.DoS(DOS_LEVEL_BLOCK, error("ContextualCheckTransaction(): joinsplit.vpub_old nonzero"), REJECT_INVALID, "bad-txns-vpub_old-nonzero"); + return state.DoS(DOS_LEVEL_BLOCK, error("ContextualCheckTransaction(): joinsplit.vpub_old nonzero"), + REJECT_INVALID, "bad-txns-vpub_old-nonzero"); } } @@ -1000,11 +1002,14 @@ bool ContextualCheckTransaction( } if (!fundingStreamElements.empty()) { - std::cout << "\nFunding stream missing at height " << nHeight; - return state.DoS(100, error("%s: funding stream missing", __func__), + return state.DoS(100, error("ContextualCheckTransaction(): funding stream missing at height %d", nHeight), REJECT_INVALID, "cb-funding-stream-missing"); } } + } else { + // Rules that apply generally before Canopy. These were + // previously noncontextual checks that became contextual + // after Canopy activation. } auto consensusBranchId = CurrentEpochBranchId(nHeight, chainparams.GetConsensus()); @@ -1024,8 +1029,8 @@ bool ContextualCheckTransaction( } catch (std::logic_error ex) { // A logic error should never occur because we pass NOT_AN_INPUT and // SIGHASH_ALL to SignatureHash(). - return state.DoS(100, error("CheckTransaction(): error computing signature hash"), - REJECT_INVALID, "error-computing-signature-hash"); + return state.DoS(100, error("ContextualCheckTransaction(): error computing signature hash"), + REJECT_INVALID, "error-computing-signature-hash"); } } @@ -1049,18 +1054,18 @@ bool ContextualCheckTransaction( // We rely on libsodium to check that the signature is canonical. // https://github.com/jedisct1/libsodium/commit/62911edb7ff2275cccd74bf1c8aefcc4d76924e0 - if (ed25519_verifier(&tx.joinSplitSig[0], + if (ed25519_verifier(tx.joinSplitSig.bytes, dataToBeSigned.begin(), 32, - tx.joinSplitPubKey.begin() + tx.joinSplitPubKey.bytes ) != 0) { // Check whether the failure was caused by an outdated consensus // branch ID; if so, inform the node that they need to upgrade. We // only check the previous epoch's branch ID, on the assumption that // users creating transactions will notice their transactions // failing before a second network upgrade occurs. - if (ed25519_verifier(&tx.joinSplitSig[0], + if (ed25519_verifier(tx.joinSplitSig.bytes, prevDataToBeSigned.begin(), 32, - tx.joinSplitPubKey.begin() + tx.joinSplitPubKey.bytes ) == 0) { return state.DoS( dosLevelPotentiallyRelaxing, false, REJECT_INVALID, strprintf( @@ -1070,7 +1075,7 @@ bool ContextualCheckTransaction( } return state.DoS( dosLevelPotentiallyRelaxing, - error("CheckTransaction(): invalid joinsplit signature"), + error("ContextualCheckTransaction(): invalid joinsplit signature"), REJECT_INVALID, "bad-txns-invalid-joinsplit-signature"); } } @@ -1156,6 +1161,10 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, REJECT_INVALID, "bad-txns-joinsplit-verification-failed"); } } + + // Sapling zk-SNARK proofs are checked in librustzcash_sapling_check_{spend,output}, + // called from ContextualCheckTransaction. + return true; } } @@ -1660,7 +1669,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa { // We lock to prevent other threads from accessing the mempool between adding and evicting LOCK(pool.cs); - + // Store transaction in memory pool.addUnchecked(hash, entry, !IsInitialBlockDownload(Params())); @@ -2080,12 +2089,12 @@ void static InvalidChainFound(CBlockIndex* pindexNew, const CChainParams& chainP LogPrintf("%s: invalid block=%s height=%d log2_work=%.8g date=%s\n", __func__, pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, - log(pindexNew->nChainWork.getdouble())/log(2.0), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", + log2(pindexNew->nChainWork.getdouble()), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexNew->GetBlockTime())); CBlockIndex *tip = chainActive.Tip(); assert (tip); LogPrintf("%s: current best=%s height=%d log2_work=%.8g date=%s\n", __func__, - tip->GetBlockHash().ToString(), chainActive.Height(), log(tip->nChainWork.getdouble())/log(2.0), + tip->GetBlockHash().ToString(), chainActive.Height(), log2(tip->nChainWork.getdouble()), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", tip->GetBlockTime())); CheckForkWarningConditions(chainParams); } @@ -2628,7 +2637,7 @@ void PartitionCheck(bool (*initialDownloadCheck)(const CChainParams&), LOCK(cs); - Consensus::Params consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); int BLOCKS_EXPECTED; // TODO: This can be simplified when the Blossom activation height is set @@ -2670,18 +2679,18 @@ void PartitionCheck(bool (*initialDownloadCheck)(const CChainParams&), if (p <= alertThreshold && nBlocks < BLOCKS_EXPECTED) { // Many fewer blocks than expected: alert! - strWarning = strprintf(_("WARNING: check your network connection, %d blocks received in the last %d hours (%d expected)"), + strWarning = strprintf(_("WARNING: Check your network connection, %d blocks received in the last %d hours (%d expected)"), nBlocks, SPAN_HOURS, BLOCKS_EXPECTED); } else if (p <= alertThreshold && nBlocks > BLOCKS_EXPECTED) { // Many more blocks than expected: alert! - strWarning = strprintf(_("WARNING: abnormally high number of blocks generated, %d blocks received in the last %d hours (%d expected)"), + strWarning = strprintf(_("WARNING: Abnormally high number of blocks generated, %d blocks received in the last %d hours (%d expected)"), nBlocks, SPAN_HOURS, BLOCKS_EXPECTED); } if (!strWarning.empty()) { - SetMiscWarning(strWarning); + SetMiscWarning(strWarning, GetTime()); CAlert::Notify(strWarning, true); lastAlertTime = now; } @@ -2693,25 +2702,42 @@ static int64_t nTimeIndex = 0; static int64_t nTimeCallbacks = 0; static int64_t nTimeTotal = 0; +/** + * Determine whether to do transaction checks when verifying blocks. + * Returns `false` (allowing transaction checks to be skipped) only if all + * of the following are true: + * - we're currently in initial block download + * - the `-ibdskiptxverification` flag is set + * - the block under inspection is an ancestor of the latest checkpoint. + */ +static bool ShouldCheckTransactions(const CChainParams& chainparams, const CBlockIndex* pindex) { + return !(IsInitialBlockDownload(chainparams) + && fIBDSkipTxVerification + && fCheckpointsEnabled + && Checkpoints::IsAncestorOfLastCheckpoint(chainparams.Checkpoints(), pindex)); +} + bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, const CChainParams& chainparams, bool fJustCheck) { AssertLockHeld(cs_main); bool fExpensiveChecks = true; - if (fCheckpointsEnabled) { - CBlockIndex *pindexLastCheckpoint = Checkpoints::GetLastCheckpoint(chainparams.Checkpoints()); - if (pindexLastCheckpoint && pindexLastCheckpoint->GetAncestor(pindex->nHeight) == pindex) { - // This block is an ancestor of a checkpoint: disable script checks - fExpensiveChecks = false; - } + + // If this block is an ancestor of a checkpoint, disable expensive checks + if (fCheckpointsEnabled && Checkpoints::IsAncestorOfLastCheckpoint(chainparams.Checkpoints(), pindex)) { + fExpensiveChecks = false; } - auto verifier = ProofVerifier::Strict(); - auto disabledVerifier = ProofVerifier::Disabled(); + // proof verification is expensive, disable if possible + auto verifier = fExpensiveChecks ? ProofVerifier::Strict() : ProofVerifier::Disabled(); + + // If in initial block download, and this block is an ancestor of a checkpoint, + // and -ibdskiptxverification is set, disable all transaction checks. + bool fCheckTransactions = ShouldCheckTransactions(chainparams, pindex); // Check it again to verify JoinSplit proofs, and in case a previous version let a bad block in - if (!CheckBlock(block, state, chainparams, fExpensiveChecks ? verifier : disabledVerifier, !fJustCheck, !fJustCheck)) + if (!CheckBlock(block, state, chainparams, verifier, !fJustCheck, !fJustCheck, fCheckTransactions)) return false; // verify that the view's current state corresponds to the previous block @@ -3233,11 +3259,24 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) { nTimeBestReceived = GetTime(); mempool.AddTransactionsUpdated(1); - LogPrintf("%s: new best=%s height=%d bits=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__, - chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), chainActive.Tip()->nBits, - log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx, - DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()), - Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize()); + auto hash = tfm::format("%s", chainActive.Tip()->GetBlockHash().ToString()); + auto height = tfm::format("%d", chainActive.Height()); + auto bits = tfm::format("%d", chainActive.Tip()->nBits); + auto log2_work = tfm::format("%.8g", log2(chainActive.Tip()->nChainWork.getdouble())); + auto tx = tfm::format("%lu", (unsigned long)chainActive.Tip()->nChainTx); + auto date = DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()); + auto progress = tfm::format("%f", Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip())); + auto cache = tfm::format("%.1fMiB(%utx)", pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize()); + + TracingInfo("main", "UpdateTip: new best", + "hash", hash.c_str(), + "height", height.c_str(), + "bits", bits.c_str(), + "log2_work", log2_work.c_str(), + "tx", tx.c_str(), + "date", date.c_str(), + "progress", progress.c_str(), + "cache", cache.c_str()); cvBlockChange.notify_all(); } @@ -3612,6 +3651,8 @@ bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, // When we reach this point, we switched to a new tip (stored in pindexNewTip). // Notifications/callbacks that can run without cs_main + // Always notify the UI if a new block tip was connected + uiInterface.NotifyBlockTip(fInitialDownload, pindexNewTip); if (!fInitialDownload) { uint256 hashNewTip = pindexNewTip->GetBlockHash(); // Relay inventory, but don't relay old inventory during initial block download. @@ -3626,7 +3667,6 @@ bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, } // Notify external listeners about the new tip. GetMainSignals().UpdatedBlockTip(pindexNewTip); - uiInterface.NotifyBlockTip(hashNewTip); } } while(pindexMostWork != chainActive.Tip()); CheckBlockIndex(chainparams.GetConsensus()); @@ -3996,10 +4036,13 @@ bool CheckBlockHeader( return true; } -bool CheckBlock(const CBlock& block, CValidationState& state, +bool CheckBlock(const CBlock& block, + CValidationState& state, const CChainParams& chainparams, ProofVerifier& verifier, - bool fCheckPOW, bool fCheckMerkleRoot) + bool fCheckPOW, + bool fCheckMerkleRoot, + bool fCheckTransactions) { // These are checks that are independent of context. @@ -4042,6 +4085,9 @@ bool CheckBlock(const CBlock& block, CValidationState& state, return state.DoS(100, error("CheckBlock(): more than one coinbase"), REJECT_INVALID, "bad-cb-multiple"); + // skip all transaction checks if this flag is not set + if (!fCheckTransactions) return true; + // Check transactions BOOST_FOREACH(const CTransaction& tx, block.vtx) if (!CheckTransaction(tx, state, verifier)) @@ -4127,26 +4173,29 @@ bool ContextualCheckBlockHeader( bool ContextualCheckBlock( const CBlock& block, CValidationState& state, - const CChainParams& chainparams, CBlockIndex * const pindexPrev) + const CChainParams& chainparams, CBlockIndex * const pindexPrev, + bool fCheckTransactions) { const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1; const Consensus::Params& consensusParams = chainparams.GetConsensus(); - // Check that all transactions are finalized - BOOST_FOREACH(const CTransaction& tx, block.vtx) { + if (fCheckTransactions) { + // Check that all transactions are finalized + BOOST_FOREACH(const CTransaction& tx, block.vtx) { - // Check transaction contextually against consensus rules at block height - if (!ContextualCheckTransaction(tx, state, chainparams, nHeight, true)) { - return false; // Failure reason has been set in validation state object - } + // Check transaction contextually against consensus rules at block height + if (!ContextualCheckTransaction(tx, state, chainparams, nHeight, true)) { + return false; // Failure reason has been set in validation state object + } - int nLockTimeFlags = 0; - int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) - ? pindexPrev->GetMedianTimePast() - : block.GetBlockTime(); - if (!IsFinalTx(tx, nHeight, nLockTimeCutoff)) { - return state.DoS(10, error("%s: contains a non-final transaction", __func__), - REJECT_INVALID, "bad-txns-nonfinal"); + int nLockTimeFlags = 0; + int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) + ? pindexPrev->GetMedianTimePast() + : block.GetBlockTime(); + if (!IsFinalTx(tx, nHeight, nLockTimeCutoff)) { + return state.DoS(10, error("%s: contains a non-final transaction", __func__), + REJECT_INVALID, "bad-txns-nonfinal"); + } } } @@ -4166,6 +4215,10 @@ bool ContextualCheckBlock( if (consensusParams.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_CANOPY)) { // Funding streams are checked inside ContextualCheckTransaction. + // This empty conditional branch exists to enforce this ZIP 207 consensus rule: + // + // Once the Canopy network upgrade activates, the existing consensus rule for + // payment of the Founders' Reward is no longer active. } else if ((nHeight > 0) && (nHeight <= consensusParams.GetLastFoundersRewardBlockHeight(nHeight))) { // Coinbase transaction must include an output sending 20% of // the block subsidy to a Founders' Reward script, until the last Founders' @@ -4237,10 +4290,11 @@ static bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state /** * Store block on disk. - * JoinSplit proofs are never verified, because: - * - AcceptBlock doesn't perform script checks either. - * - The only caller of AcceptBlock verifies JoinSplit proofs elsewhere. - * If dbp is non-NULL, the file is known to already reside on disk + * If dbp is non-NULL, the file is known to already reside on disk. + * + * JoinSplit proofs are not verified here; the only caller of AcceptBlock + * (ProcessNewBlock) later invokes ActivateBestChain, which ultimately calls + * ConnectBlock in a manner that can verify the proofs */ static bool AcceptBlock(const CBlock& block, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested, CDiskBlockPos* dbp) { @@ -4272,9 +4326,11 @@ static bool AcceptBlock(const CBlock& block, CValidationState& state, const CCha if (fTooFarAhead) return true; // Block height is too high } - // See method docstring for why this is always disabled + // See method docstring for why this is always disabled. auto verifier = ProofVerifier::Disabled(); - if ((!CheckBlock(block, state, chainparams, verifier)) || !ContextualCheckBlock(block, state, chainparams, pindex->pprev)) { + bool fCheckTransactions = ShouldCheckTransactions(chainparams, pindex); + if ((!CheckBlock(block, state, chainparams, verifier, true, true, fCheckTransactions)) || + !ContextualCheckBlock(block, state, chainparams, pindex->pprev, fCheckTransactions)) { if (state.IsInvalid() && !state.CorruptionPossible()) { pindex->nStatus |= BLOCK_FAILED_VALID; setDirtyBlockIndex.insert(pindex); @@ -4322,17 +4378,12 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned bool ProcessNewBlock(CValidationState& state, const CChainParams& chainparams, const CNode* pfrom, const CBlock* pblock, bool fForceProcessing, CDiskBlockPos* dbp) { - // Preliminary checks - auto verifier = ProofVerifier::Disabled(); - bool checked = CheckBlock(*pblock, state, chainparams, verifier); + auto span = TracingSpan("info", "main", "ProcessNewBlock"); + auto spanGuard = span.Enter(); { LOCK(cs_main); - bool fRequested = MarkBlockAsReceived(pblock->GetHash()); - fRequested |= fForceProcessing; - if (!checked) { - return error("%s: CheckBlock FAILED", __func__); - } + bool fRequested = MarkBlockAsReceived(pblock->GetHash()) | fForceProcessing; // Store to disk CBlockIndex *pindex = NULL; @@ -4351,7 +4402,11 @@ bool ProcessNewBlock(CValidationState& state, const CChainParams& chainparams, c return true; } -bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot) +/** + * This is only invoked by the miner. + * The block's proof-of-work is assumed invalid and not checked. + */ +bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckMerkleRoot) { AssertLockHeld(cs_main); assert(pindexPrev == chainActive.Tip()); @@ -4366,9 +4421,10 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, // NOTE: CheckBlockHeader is called by CheckBlock if (!ContextualCheckBlockHeader(block, state, chainparams, pindexPrev)) return false; - if (!CheckBlock(block, state, chainparams, verifier, fCheckPOW, fCheckMerkleRoot)) + // The following may be duplicative of the `CheckBlock` call within `ConnectBlock` + if (!CheckBlock(block, state, chainparams, verifier, false, fCheckMerkleRoot, true)) return false; - if (!ContextualCheckBlock(block, state, chainparams, pindexPrev)) + if (!ContextualCheckBlock(block, state, chainparams, pindexPrev, true)) return false; if (!ConnectBlock(block, state, &indexDummy, viewNew, chainparams, true)) return false; @@ -4760,21 +4816,28 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, CBlockIndex* pindexFailure = NULL; int nGoodTransactions = 0; CValidationState state; - // No need to verify JoinSplits twice - auto verifier = ProofVerifier::Disabled(); + + // Flags used to permit skipping checks for efficiency + auto verifier = ProofVerifier::Disabled(); // No need to verify JoinSplits twice + bool fCheckTransactions = true; + for (CBlockIndex* pindex = chainActive.Tip(); pindex && pindex->pprev; pindex = pindex->pprev) { boost::this_thread::interruption_point(); uiInterface.ShowProgress(_("Verifying blocks..."), std::max(1, std::min(99, (int)(((double)(chainActive.Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100))))); if (pindex->nHeight < chainActive.Height()-nCheckDepth) break; + CBlock block; // check level 0: read from disk if (!ReadBlockFromDisk(block, pindex, chainparams.GetConsensus())) return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString()); + // check level 1: verify block validity - if (nCheckLevel >= 1 && !CheckBlock(block, state, chainparams, verifier)) + fCheckTransactions = ShouldCheckTransactions(chainparams, pindex); + if (nCheckLevel >= 1 && !CheckBlock(block, state, chainparams, verifier, true, true, fCheckTransactions)) return error("VerifyDB(): *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); + // check level 2: verify undo validity if (nCheckLevel >= 2 && pindex) { CBlockUndo undo; @@ -4784,6 +4847,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, return error("VerifyDB(): *** found bad undo data at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); } } + // check level 3: check for inconsistencies during memory-only disconnect of tip blocks if (nCheckLevel >= 3 && pindex == pindexState && (coins.DynamicMemoryUsage() + pcoinsTip->DynamicMemoryUsage()) <= nCoinCacheUsage) { // insightexplorer: do not update indices (false) @@ -4799,6 +4863,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, nGoodTransactions += block.vtx.size(); } } + if (ShutdownRequested()) return true; } @@ -4839,7 +4904,7 @@ bool RewindBlockIndex(const CChainParams& chainparams, bool& clearWitnessCaches) // - BLOCK_ACTIVATES_UPGRADE is set only on blocks that activate upgrades. // - nCachedBranchId for each block matches what we expect. auto sufficientlyValidated = [&chainparams](const CBlockIndex* pindex) { - auto consensus = chainparams.GetConsensus(); + const Consensus::Params& consensus = chainparams.GetConsensus(); bool fFlagSet = pindex->nStatus & BLOCK_ACTIVATES_UPGRADE; bool fFlagExpected = IsActivationHeightForAnyUpgrade(pindex->nHeight, consensus); return fFlagSet == fFlagExpected && @@ -5025,7 +5090,7 @@ bool LoadBlockIndex() return true; } -bool InitBlockIndex(const CChainParams& chainparams) +bool InitBlockIndex(const CChainParams& chainparams) { LOCK(cs_main); @@ -6890,7 +6955,7 @@ CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Para mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID; mtx.nVersion = OVERWINTER_TX_VERSION; } - + bool blossomActive = consensusParams.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_BLOSSOM); unsigned int defaultExpiryDelta = blossomActive ? DEFAULT_POST_BLOSSOM_TX_EXPIRY_DELTA : DEFAULT_PRE_BLOSSOM_TX_EXPIRY_DELTA; mtx.nExpiryHeight = nHeight + (expiryDeltaArg ? expiryDeltaArg.value() : defaultExpiryDelta); diff --git a/depend/zcash/src/main.h b/depend/zcash/src/main.h index ba44a49bf..d2749ca54 100644 --- a/depend/zcash/src/main.h +++ b/depend/zcash/src/main.h @@ -101,6 +101,10 @@ static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024; static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60; /** Time to wait (in seconds) between flushing chainstate to disk. */ static const unsigned int DATABASE_FLUSH_INTERVAL = 24 * 60 * 60; +/** Time to wait (in seconds) between writing wallet witness data to disk. */ +static const unsigned int WITNESS_WRITE_INTERVAL = 10 * 60; +/** Number of updates between writing wallet witness data to disk. */ +static const unsigned int WITNESS_WRITE_UPDATES = 10000; /** Maximum length of reject messages. */ static const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111; static const unsigned int DEFAULT_LIMITFREERELAY = 15; @@ -110,6 +114,7 @@ static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60; /** Default for -permitbaremultisig */ static const bool DEFAULT_PERMIT_BAREMULTISIG = true; static const bool DEFAULT_CHECKPOINTS_ENABLED = true; +static const bool DEFAULT_IBD_SKIP_TX_VERIFICATION = false; static const bool DEFAULT_TXINDEX = false; static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100; @@ -161,6 +166,7 @@ extern bool fTimestampIndex; extern bool fIsBareMultisigStd; extern bool fCheckBlockIndex; extern bool fCheckpointsEnabled; +extern bool fIBDSkipTxVerification; // TODO: remove this flag by structuring our code such that // it is unneeded for testing extern bool fCoinbaseEnforcedShieldingEnabled; @@ -207,11 +213,11 @@ void RegisterNodeSignals(CNodeSignals& nodeSignals); /** Unregister a network node */ void UnregisterNodeSignals(CNodeSignals& nodeSignals); -/** +/** * Process an incoming block. This only returns after the best known valid * block is made active. Note that it does not, however, guarantee that the * specific block passed to it has been checked for validity! - * + * * @param[out] state This may be set to an Error state if any error occurred processing it, including during validation/connection/etc of otherwise unrelated blocks during reorganisation; or it may be set to an Invalid state if pblock is itself invalid (but this is not guaranteed even when the block is checked). If you want to *possibly* get feedback on whether pblock is valid, you must also install a CValidationInterface (see validationinterface.h) - this will have its BlockChecked method called whenever *any* block completes validation. * @param[in] pfrom The node which we are receiving the block from; it is added to mapBlockSource and may be penalised if the block is invalid. * @param[in] pblock The block we want to process. @@ -251,8 +257,8 @@ void ThreadScriptCheck(); void PartitionCheck(bool (*initialDownloadCheck)(const CChainParams&), CCriticalSection& cs, const CBlockIndex *const &bestHeader); /** Check whether we are doing an initial block download (synchronizing from disk or network) */ bool IsInitialBlockDownload(const CChainParams& chainParams); -/** Format a string that describes several potential problems detected by the core */ -std::string GetWarnings(const std::string& strFor); +/** Pair of timestamp and formatted string that describes several potential problems detected by the core */ +std::pair GetWarnings(const std::string& strFor); /** Retrieve a transaction (from memory pool, or from disk, if possible) */ bool GetTransaction(const uint256 &hash, CTransaction &tx, const Consensus::Params& params, uint256 &hashBlock, bool fAllowSlow = false); /** Find the best known block, and make it the tip of the block chain */ @@ -308,7 +314,7 @@ struct CNodeStateStats { CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree); -/** +/** * Count ECDSA signature operations the old-fashioned (pre-0.6) way * @return number of sigops this transaction's outputs will produce when spent * @see CTransaction::FetchInputs @@ -317,7 +323,7 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx); /** * Count ECDSA signature operations in pay-to-script-hash inputs. - * + * * @param[in] mapInputs Map of previous transactions that have outputs we're spending * @return maximum number of sigops required to validate this transaction's inputs * @see CTransaction::FetchInputs @@ -387,9 +393,9 @@ bool IsExpiringSoonTx(const CTransaction &tx, int nNextBlockHeight); */ bool CheckFinalTx(const CTransaction &tx, int flags = -1); -/** +/** * Closure representing one script verification - * Note that this stores references to the spending transaction + * Note that this stores references to the spending transaction */ class CScriptCheck { @@ -444,13 +450,17 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus /** Functions for validating blocks and updating the block tree */ /** Context-independent validity checks */ + bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, const CChainParams& chainparams, bool fCheckPOW = true); + bool CheckBlock(const CBlock& block, CValidationState& state, const CChainParams& chainparams, ProofVerifier& verifier, - bool fCheckPOW = true, bool fCheckMerkleRoot = true); + bool fCheckPOW, + bool fCheckMerkleRoot, + bool fCheckTransactions); /** Context-dependent validity checks. * By "context", we mean only the previous block headers, but not the UTXO @@ -458,7 +468,9 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, const CChainParams& chainparams, CBlockIndex *pindexPrev); bool ContextualCheckBlock(const CBlock& block, CValidationState& state, - const CChainParams& chainparams, CBlockIndex *pindexPrev); + const CChainParams& chainparams, + CBlockIndex *pindexPrev, + bool fCheckTransactions); /** Apply the effects of this block (with given index) on the UTXO set represented by coins. * Validity checks that depend on the UTXO set are also done; ConnectBlock() @@ -466,11 +478,11 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, const CChainParams& chainparams, bool fJustCheck = false); -/** +/** * Check a block is completely valid from start to finish (only works on top - * of our current best block, with cs_main held) + * of our current best block, with cs_main held) */ -bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW = true, bool fCheckMerkleRoot = true); +bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckMerkleRoot); /** @@ -518,7 +530,7 @@ int GetSpendHeight(const CCoinsViewCache& inputs); uint64_t CalculateCurrentUsage(); -/** +/** * Return a CMutableTransaction with contextual default values based on set of consensus rules at nHeight. The expiryDelta will * either be based on the command-line argument '-txexpirydelta' or derived from consensusParams. */ diff --git a/depend/zcash/src/mempool_limit.cpp b/depend/zcash/src/mempool_limit.cpp index 44d61a2fa..5fcd4d1db 100644 --- a/depend/zcash/src/mempool_limit.cpp +++ b/depend/zcash/src/mempool_limit.cpp @@ -2,12 +2,13 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or https://www.opensource.org/licenses/mit-license.php -#include "core_memusage.h" #include "mempool_limit.h" + +#include "core_memusage.h" +#include "logging.h" #include "random.h" #include "serialize.h" #include "timedata.h" -#include "util.h" #include "utiltime.h" #include "version.h" diff --git a/depend/zcash/src/metrics.cpp b/depend/zcash/src/metrics.cpp index 19807ea81..c921da15e 100644 --- a/depend/zcash/src/metrics.cpp +++ b/depend/zcash/src/metrics.cpp @@ -17,6 +17,8 @@ #include #include #include + +#include #include #ifdef WIN32 #include @@ -206,12 +208,12 @@ void ConnectMetricsScreen() uiInterface.InitMessage.connect(metrics_InitMessage); } -std::string DisplayDuration(int64_t time, DurationFormat format) +std::string DisplayDuration(int64_t duration, DurationFormat format) { - int days = time / (24 * 60 * 60); - int hours = (time - (days * 24 * 60 * 60)) / (60 * 60); - int minutes = (time - (((days * 24) + hours) * 60 * 60)) / 60; - int seconds = time - (((((days * 24) + hours) * 60) + minutes) * 60); + int64_t days = duration / (24 * 60 * 60); + int64_t hours = (duration - (days * 24 * 60 * 60)) / (60 * 60); + int64_t minutes = (duration - (((days * 24) + hours) * 60 * 60)) / 60; + int64_t seconds = duration - (((((days * 24) + hours) * 60) + minutes) * 60); std::string strDuration; if (format == DurationFormat::REDUCED) { @@ -242,20 +244,38 @@ std::string DisplaySize(size_t value) { double coef = 1.0; if (value < 1024.0 * coef) - return strprintf(_("%d Bytes"), value); + return strprintf(_("%d Bytes"), value); coef *= 1024.0; if (value < 1024.0 * coef) - return strprintf(_("%.2f KiB"), value / coef); + return strprintf(_("%.2f KiB"), value / coef); coef *= 1024.0; if (value < 1024.0 * coef) - return strprintf(_("%.2f MiB"), value / coef); + return strprintf(_("%.2f MiB"), value / coef); coef *= 1024.0; if (value < 1024.0 * coef) - return strprintf(_("%.2f GiB"), value / coef); + return strprintf(_("%.2f GiB"), value / coef); coef *= 1024.0; return strprintf(_("%.2f TiB"), value / coef); } +std::string DisplayHashRate(double value) +{ + double coef = 1.0; + if (value < 1000.0 * coef) + return strprintf(_("%.3f Sol/s"), value); + coef *= 1000.0; + if (value < 1000.0 * coef) + return strprintf(_("%.3f kSol/s"), value / coef); + coef *= 1000.0; + if (value < 1000.0 * coef) + return strprintf(_("%.3f MSol/s"), value / coef); + coef *= 1000.0; + if (value < 1000.0 * coef) + return strprintf(_("%.3f GSol/s"), value / coef); + coef *= 1000.0; + return strprintf(_("%.3f TSol/s"), value / coef); +} + std::optional SecondsLeftToNextEpoch(const Consensus::Params& params, int currentHeight) { auto nextHeight = NextActivationHeight(currentHeight, params); @@ -266,48 +286,71 @@ std::optional SecondsLeftToNextEpoch(const Consensus::Params& params, i } } -int printStats(bool isScreen, bool mining) -{ - // Number of lines that are always displayed - int lines = 5; +struct MetricsStats { + int height; + int64_t currentHeadersHeight; + int64_t currentHeadersTime; + size_t connections; + int64_t netsolps; +}; +MetricsStats loadStats() +{ int height; int64_t currentHeadersHeight; int64_t currentHeadersTime; size_t connections; int64_t netsolps; - double netsolpsLog = 1.0; - const Consensus::Params& params = Params().GetConsensus(); + { - LOCK2(cs_main, cs_vNodes); + LOCK(cs_main); height = chainActive.Height(); currentHeadersHeight = pindexBestHeader ? pindexBestHeader->nHeight: -1; currentHeadersTime = pindexBestHeader ? pindexBestHeader->nTime : 0; - connections = vNodes.size(); netsolps = GetNetworkHashPS(120, -1); - netsolpsLog = std::log2(netsolps); } + { + LOCK(cs_vNodes); + connections = vNodes.size(); + } + + return MetricsStats { + height, + currentHeadersHeight, + currentHeadersTime, + connections, + netsolps + }; +} + +int printStats(MetricsStats stats, bool isScreen, bool mining) +{ + // Number of lines that are always displayed + int lines = 5; + + const Consensus::Params& params = Params().GetConsensus(); auto localsolps = GetLocalSolPS(); - double localsolpsLog = 0.0; - if (localsolps > 0) - localsolpsLog = std::log2(localsolps); if (IsInitialBlockDownload(Params())) { if (fReindex) { int downloadPercent = nSizeReindexed * 100 / nFullSizeToReindex; - std::cout << " " << _("Reindexing blocks") << " | " << DisplaySize(nSizeReindexed) << " / " << DisplaySize(nFullSizeToReindex) << " (" << downloadPercent << "%, " << height << " " << _("blocks") << ")" << std::endl; + std::cout << " " << _("Reindexing blocks") << " | " + << DisplaySize(nSizeReindexed) << " / " << DisplaySize(nFullSizeToReindex) + << " (" << downloadPercent << "%, " << stats.height << " " << _("blocks") << ")" << std::endl; } else { - int nHeaders = currentHeadersHeight; + int nHeaders = stats.currentHeadersHeight; if (nHeaders < 0) nHeaders = 0; - int netheight = currentHeadersHeight == -1 || currentHeadersTime == 0 ? - 0 : EstimateNetHeight(params, currentHeadersHeight, currentHeadersTime); + int netheight = stats.currentHeadersHeight == -1 || stats.currentHeadersTime == 0 ? + 0 : EstimateNetHeight(params, stats.currentHeadersHeight, stats.currentHeadersTime); if (netheight < nHeaders) netheight = nHeaders; if (netheight <= 0) netheight = 1; - int downloadPercent = height * 100 / netheight; - std::cout << " " << _("Downloading blocks") << " | " << height << " (" << nHeaders << " " << _("headers") << ") / ~" << netheight << " (" << downloadPercent << "%)" << std::endl; + int downloadPercent = stats.height * 100 / netheight; + std::cout << " " << _("Downloading blocks") << " | " + << stats.height << " (" << nHeaders << " " << _("headers") << ") / ~" << netheight + << " (" << downloadPercent << "%)" << std::endl; if (isScreen) { // Draw 50-character progress bar, which will fit into a 79-character line. @@ -331,14 +374,14 @@ int printStats(bool isScreen, bool mining) } } } else { - std::cout << " " << _("Block height") << " | " << height << std::endl; + std::cout << " " << _("Block height") << " | " << stats.height << std::endl; } - auto secondsLeft = SecondsLeftToNextEpoch(params, height); + auto secondsLeft = SecondsLeftToNextEpoch(params, stats.height); std::string strUpgradeTime; if (secondsLeft) { - auto nextHeight = NextActivationHeight(height, params).value(); - auto nextBranch = NextEpoch(height, params).value(); + auto nextHeight = NextActivationHeight(stats.height, params).value(); + auto nextBranch = NextEpoch(stats.height, params).value(); strUpgradeTime = strprintf(_("%s at block height %d, in around %s"), NetworkUpgradeInfo[nextBranch].strName, nextHeight, DisplayDuration(secondsLeft.value(), DurationFormat::REDUCED)); } @@ -346,10 +389,10 @@ int printStats(bool isScreen, bool mining) strUpgradeTime = "Unknown"; } std::cout << " " << _("Next upgrade") << " | " << strUpgradeTime << std::endl; - std::cout << " " << _("Connections") << " | " << connections << std::endl; - std::cout << " " << _("Network solution rate") << " | " << strprintf("~ 2^%.4f Sol/s", netsolpsLog) << std::endl; + std::cout << " " << _("Connections") << " | " << stats.connections << std::endl; + std::cout << " " << _("Network solution rate") << " | " << DisplayHashRate(stats.netsolps) << std::endl; if (mining && miningTimer.running()) { - std::cout << " " << _("Local solution rate") << " | " << strprintf("~ 2^%.4f Sol/s", localsolpsLog) << std::endl; + std::cout << " " << _("Local solution rate") << " | " << DisplayHashRate(localsolps) << std::endl; lines++; } std::cout << std::endl; @@ -428,7 +471,7 @@ int printMetrics(size_t cols, bool mining) { LOCK2(cs_main, cs_metrics); boost::strict_lock_ptr> u = trackedBlocks.synchronize(); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); auto tipHeight = chainActive.Height(); // Update orphans and calculate subsidies @@ -598,6 +641,12 @@ void ThreadShowMetricsScreen() #endif } + // Lock and fetch stats before erasing the screen, in case we block. + std::optional metricsStats; + if (loaded) { + metricsStats = loadStats(); + } + if (isScreen) { // Erase below current position std::cout << "\e[J"; @@ -611,7 +660,7 @@ void ThreadShowMetricsScreen() #endif if (loaded) { - lines += printStats(isScreen, mining); + lines += printStats(metricsStats.value(), isScreen, mining); lines += printMiningStatus(mining); } lines += printMetrics(cols, mining); diff --git a/depend/zcash/src/metrics.h b/depend/zcash/src/metrics.h index 959601632..b6ea2233b 100644 --- a/depend/zcash/src/metrics.h +++ b/depend/zcash/src/metrics.h @@ -75,6 +75,8 @@ double GetLocalSolPS(); int EstimateNetHeight(const Consensus::Params& params, int currentBlockHeight, int64_t currentBlockTime); std::optional SecondsLeftToNextEpoch(const Consensus::Params& params, int currentHeight); std::string DisplayDuration(int64_t time, DurationFormat format); +std::string DisplaySize(size_t value); +std::string DisplayHashRate(double value); void TriggerRefresh(); diff --git a/depend/zcash/src/miner.cpp b/depend/zcash/src/miner.cpp index f83142641..13a85ac51 100644 --- a/depend/zcash/src/miner.cpp +++ b/depend/zcash/src/miner.cpp @@ -619,7 +619,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const MinerAddre pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); CValidationState state; - if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) + if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false)) throw std::runtime_error(std::string("CreateNewBlock(): TestBlockValidity failed: ") + state.GetRejectReason()); } @@ -733,7 +733,7 @@ void static BitcoinMiner(const CChainParams& chainparams) std::mutex m_cs; bool cancelSolver = false; boost::signals2::connection c = uiInterface.NotifyBlockTip.connect( - [&m_cs, &cancelSolver](const uint256& hashNewTip) mutable { + [&m_cs, &cancelSolver](bool, const CBlockIndex *) mutable { std::lock_guard lock{m_cs}; cancelSolver = true; } @@ -857,7 +857,7 @@ void static BitcoinMiner(const CChainParams& chainparams) if (solver == "tromp") { // Create solver and initialize it. equi eq(1); - eq.setstate(curr_state.state); + eq.setstate(curr_state.inner.get()); // Initialization done, start algo driver. eq.digit0(0); diff --git a/depend/zcash/src/net.cpp b/depend/zcash/src/net.cpp index 5b8cf713b..20155ed99 100644 --- a/depend/zcash/src/net.cpp +++ b/depend/zcash/src/net.cpp @@ -994,6 +994,8 @@ void ThreadSocketHandler() if (pnode->fDisconnect || (pnode->GetRefCount() <= 0 && pnode->vRecvMsg.empty() && pnode->nSendSize == 0 && pnode->ssSend.empty())) { + auto spanGuard = pnode->span.Enter(); + // remove from vNodes vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end()); @@ -1152,6 +1154,8 @@ void ThreadSocketHandler() { boost::this_thread::interruption_point(); + auto spanGuard = pnode->span.Enter(); + // // Receive // @@ -1557,6 +1561,8 @@ void ThreadMessageHandler() if (pnode->fDisconnect) continue; + auto spanGuard = pnode->span.Enter(); + // Receive messages { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); @@ -1890,6 +1896,7 @@ void RelayTransaction(const CTransaction& tx, const CDataStream& ss) if(!pnode->fRelayTxes) continue; LOCK(pnode->cs_filter); + auto spanGuard = pnode->span.Enter(); if (pnode->pfilter) { if (pnode->pfilter->IsRelevantAndUpdate(tx)) @@ -2102,6 +2109,13 @@ CNode::CNode(SOCKET hSocketIn, const CAddress& addrIn, const std::string& addrNa fPingQueued = false; nMinPingUsecTime = std::numeric_limits::max(); + if (fLogIPs) { + span = TracingSpanFields("info", "net", "CNode", "addr", addrName.c_str()); + } else { + span = TracingSpan("info", "net", "CNode"); + } + auto spanGuard = span.Enter(); + { LOCK(cs_nLastNodeId); id = nLastNodeId++; diff --git a/depend/zcash/src/net.h b/depend/zcash/src/net.h index 7fd4320b7..b8392e083 100644 --- a/depend/zcash/src/net.h +++ b/depend/zcash/src/net.h @@ -30,6 +30,8 @@ #include #include +#include + class CAddrMan; class CBlockIndex; class CScheduler; @@ -297,6 +299,8 @@ class CNode CBloomFilter* pfilter; int nRefCount; NodeId id; + + tracing::Span span; protected: // Denial-of-service detection/prevention diff --git a/depend/zcash/src/pow.cpp b/depend/zcash/src/pow.cpp index b9d7020c0..c81f2a873 100644 --- a/depend/zcash/src/pow.cpp +++ b/depend/zcash/src/pow.cpp @@ -138,9 +138,9 @@ arith_uint256 GetBlockProof(const CBlockIndex& block) if (fNegative || fOverflow || bnTarget == 0) return 0; // We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256 - // as it's too large for a arith_uint256. However, as 2**256 is at least as large + // as it's too large for an arith_uint256. However, as 2**256 is at least as large // as bnTarget+1, it is equal to ((2**256 - bnTarget - 1) / (bnTarget+1)) + 1, - // or ~bnTarget / (nTarget+1) + 1. + // or ~bnTarget / (bnTarget+1) + 1. return (~bnTarget / (bnTarget + 1)) + 1; } diff --git a/depend/zcash/src/pow/tromp/equi.h b/depend/zcash/src/pow/tromp/equi.h index e2bd99089..a5460d26d 100644 --- a/depend/zcash/src/pow/tromp/equi.h +++ b/depend/zcash/src/pow/tromp/equi.h @@ -41,12 +41,12 @@ enum verify_code { POW_OK, POW_DUPLICATE, POW_OUT_OF_ORDER, POW_NONZERO_XOR }; const char *errstr[] = { "OK", "duplicate index", "indices out of order", "nonzero xor" }; void genhash(const BLAKE2bState *ctx, u32 idx, uchar *hash) { - auto state = rust_blake2b_clone(ctx); + auto state = blake2b_clone(ctx); u32 leb = htole32(idx / HASHESPERBLAKE); - rust_blake2b_update(state, (uchar *)&leb, sizeof(u32)); + blake2b_update(state, (uchar *)&leb, sizeof(u32)); uchar blakehash[HASHOUT]; - rust_blake2b_finalize(state, blakehash, HASHOUT); - rust_blake2b_free(state); + blake2b_finalize(state, blakehash, HASHOUT); + blake2b_free(state); memcpy(hash, blakehash + (idx % HASHESPERBLAKE) * WN/8, WN/8); } diff --git a/depend/zcash/src/pow/tromp/equi_miner.h b/depend/zcash/src/pow/tromp/equi_miner.h index e7b435bdf..0698656c5 100644 --- a/depend/zcash/src/pow/tromp/equi_miner.h +++ b/depend/zcash/src/pow/tromp/equi_miner.h @@ -227,12 +227,10 @@ struct equi { hta.dealloctrees(); free(nslots); free(sols); - if (blake_ctx != nullptr) { - rust_blake2b_free(blake_ctx); - } + blake2b_free(blake_ctx); } void setstate(const BLAKE2bState *ctx) { - blake_ctx = rust_blake2b_clone(ctx); + blake_ctx = blake2b_clone(ctx); memset(nslots, 0, NBUCKETS * sizeof(au32)); // only nslots[0] needs zeroing nsols = 0; } @@ -438,11 +436,11 @@ struct equi { htlayout htl(this, 0); const u32 hashbytes = hashsize(0); for (u32 block = id; block < NBLOCKS; block += nthreads) { - state = rust_blake2b_clone(blake_ctx); + state = blake2b_clone(blake_ctx); u32 leb = htole32(block); - rust_blake2b_update(state, (uchar *)&leb, sizeof(u32)); - rust_blake2b_finalize(state, hash, HASHOUT); - rust_blake2b_free(state); + blake2b_update(state, (uchar *)&leb, sizeof(u32)); + blake2b_finalize(state, hash, HASHOUT); + blake2b_free(state); for (u32 i = 0; i*>(&vShieldedSpend) = tx.vShieldedSpend; *const_cast*>(&vShieldedOutput) = tx.vShieldedOutput; *const_cast*>(&vJoinSplit) = tx.vJoinSplit; - *const_cast(&joinSplitPubKey) = tx.joinSplitPubKey; - *const_cast(&joinSplitSig) = tx.joinSplitSig; + *const_cast(&joinSplitPubKey) = tx.joinSplitPubKey; + *const_cast(&joinSplitSig) = tx.joinSplitSig; *const_cast(&bindingSig) = tx.bindingSig; *const_cast(&hash) = tx.hash; return *this; diff --git a/depend/zcash/src/primitives/transaction.h b/depend/zcash/src/primitives/transaction.h index b16a69a5b..7498ea4ff 100644 --- a/depend/zcash/src/primitives/transaction.h +++ b/depend/zcash/src/primitives/transaction.h @@ -20,6 +20,8 @@ #include "zcash/Zcash.h" #include "zcash/Proof.hpp" +#include + // Overwinter transaction version static const int32_t OVERWINTER_TX_VERSION = 3; static_assert(OVERWINTER_TX_VERSION >= OVERWINTER_MIN_TX_VERSION, @@ -522,8 +524,8 @@ class CTransaction const std::vector vShieldedSpend; const std::vector vShieldedOutput; const std::vector vJoinSplit; - const uint256 joinSplitPubKey; - const joinsplit_sig_t joinSplitSig = {{0}}; + const Ed25519VerificationKey joinSplitPubKey; + const Ed25519Signature joinSplitSig; const binding_sig_t bindingSig = {{0}}; /** Construct a CTransaction that qualifies as IsNull() */ @@ -580,8 +582,8 @@ class CTransaction auto os = WithVersion(&s, static_cast(header)); ::SerReadWrite(os, *const_cast*>(&vJoinSplit), ser_action); if (vJoinSplit.size() > 0) { - READWRITE(*const_cast(&joinSplitPubKey)); - READWRITE(*const_cast(&joinSplitSig)); + READWRITE(*const_cast(&joinSplitPubKey)); + READWRITE(*const_cast(&joinSplitSig)); } } if (isSaplingV4 && !(vShieldedSpend.empty() && vShieldedOutput.empty())) { @@ -669,8 +671,8 @@ struct CMutableTransaction std::vector vShieldedSpend; std::vector vShieldedOutput; std::vector vJoinSplit; - uint256 joinSplitPubKey; - CTransaction::joinsplit_sig_t joinSplitSig = {{0}}; + Ed25519VerificationKey joinSplitPubKey; + Ed25519Signature joinSplitSig; CTransaction::binding_sig_t bindingSig = {{0}}; CMutableTransaction(); diff --git a/depend/zcash/src/proof_verifier.cpp b/depend/zcash/src/proof_verifier.cpp index 372e10c9b..92a620cba 100644 --- a/depend/zcash/src/proof_verifier.cpp +++ b/depend/zcash/src/proof_verifier.cpp @@ -13,13 +13,13 @@ class SproutProofVerifier { ProofVerifier& verifier; - const uint256& joinSplitPubKey; + const Ed25519VerificationKey& joinSplitPubKey; const JSDescription& jsdesc; public: SproutProofVerifier( ProofVerifier& verifier, - const uint256& joinSplitPubKey, + const Ed25519VerificationKey& joinSplitPubKey, const JSDescription& jsdesc ) : jsdesc(jsdesc), verifier(verifier), joinSplitPubKey(joinSplitPubKey) {} @@ -60,7 +60,7 @@ ProofVerifier ProofVerifier::Disabled() { bool ProofVerifier::VerifySprout( const JSDescription& jsdesc, - const uint256& joinSplitPubKey + const Ed25519VerificationKey& joinSplitPubKey ) { if (!perform_verification) { return true; diff --git a/depend/zcash/src/proof_verifier.h b/depend/zcash/src/proof_verifier.h index 2e22d390c..ef48200ae 100644 --- a/depend/zcash/src/proof_verifier.h +++ b/depend/zcash/src/proof_verifier.h @@ -8,6 +8,8 @@ #include #include +#include + class ProofVerifier { private: bool perform_verification; @@ -33,7 +35,7 @@ class ProofVerifier { // Verifies that the JoinSplit proof is correct. bool VerifySprout( const JSDescription& jsdesc, - const uint256& joinSplitPubKey + const Ed25519VerificationKey& joinSplitPubKey ); }; diff --git a/depend/zcash/src/random.h b/depend/zcash/src/random.h index a0802d6fa..429007519 100644 --- a/depend/zcash/src/random.h +++ b/depend/zcash/src/random.h @@ -9,6 +9,7 @@ #include "uint256.h" #include +#include #include /** @@ -19,6 +20,34 @@ uint64_t GetRand(uint64_t nMax); int GetRandInt(int nMax); uint256 GetRandHash(); +/** + * Implementation of a C++ Uniform Random Number Generator, backed by GetRandBytes. + */ +class ZcashRandomEngine +{ +public: + typedef uint64_t result_type; + + explicit ZcashRandomEngine() {} + + static constexpr result_type min() { + return std::numeric_limits::min(); + } + static constexpr result_type max() { + return std::numeric_limits::max(); + } + + result_type operator()() { + result_type nRand = 0; + GetRandBytes((unsigned char*)&nRand, sizeof(nRand)); + return nRand; + } + + double entropy() const noexcept { + return 0; + } +}; + /** * Identity function for MappedShuffle, so that elements retain their original order. */ diff --git a/depend/zcash/src/rpc/blockchain.cpp b/depend/zcash/src/rpc/blockchain.cpp index 696f0ae45..790374bb8 100644 --- a/depend/zcash/src/rpc/blockchain.cpp +++ b/depend/zcash/src/rpc/blockchain.cpp @@ -194,7 +194,6 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) if (IsValidDestination(dest)) { delta.pushKV("address", keyIO.EncodeDestination(dest)); } - delta.pushKV("address", keyIO.EncodeDestination(dest)); delta.pushKV("satoshis", out.nValue); delta.pushKV("index", (int)k); @@ -996,6 +995,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp) "{\n" " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n" " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" + " \"initial_block_download_complete\": xx, (boolean) true if the initial download of the blockchain is complete\n" " \"headers\": xxxxxx, (numeric) the current number of headers we have validated\n" " \"bestblockhash\": \"...\", (string) the hash of the currently best block\n" " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" @@ -1040,6 +1040,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp) UniValue obj(UniValue::VOBJ); obj.pushKV("chain", Params().NetworkIDString()); obj.pushKV("blocks", (int)chainActive.Height()); + obj.pushKV("initial_block_download_complete", !IsInitialBlockDownload(Params())); obj.pushKV("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1); obj.pushKV("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()); obj.pushKV("difficulty", (double)GetNetworkDifficulty()); @@ -1049,9 +1050,9 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp) obj.pushKV("size_on_disk", CalculateCurrentUsage()); if (IsInitialBlockDownload(Params())) - obj.push_back(Pair("estimatedheight", EstimateNetHeight(Params().GetConsensus(), (int)chainActive.Height(), chainActive.Tip()->GetMedianTimePast()))); + obj.pushKV("estimatedheight", EstimateNetHeight(Params().GetConsensus(), (int)chainActive.Height(), chainActive.Tip()->GetMedianTimePast())); else - obj.push_back(Pair("estimatedheight", (int)chainActive.Height())); + obj.pushKV("estimatedheight", (int)chainActive.Height()); SproutMerkleTree tree; pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), tree); diff --git a/depend/zcash/src/rpc/mining.cpp b/depend/zcash/src/rpc/mining.cpp index ccb6d0dfa..9ffbdc766 100644 --- a/depend/zcash/src/rpc/mining.cpp +++ b/depend/zcash/src/rpc/mining.cpp @@ -13,6 +13,7 @@ #include "crypto/equihash.h" #endif #include "init.h" +#include "key_io.h" #include "main.h" #include "metrics.h" #include "miner.h" @@ -340,7 +341,9 @@ UniValue getmininginfo(const UniValue& params, bool fHelp) obj.pushKV("currentblocksize", (uint64_t)nLastBlockSize); obj.pushKV("currentblocktx", (uint64_t)nLastBlockTx); obj.pushKV("difficulty", (double)GetNetworkDifficulty()); - obj.pushKV("errors", GetWarnings("statusbar")); + auto warnings = GetWarnings("statusbar"); + obj.pushKV("errors", warnings.first); + obj.pushKV("errorstimestamp", warnings.second); obj.pushKV("genproclimit", (int)GetArg("-genproclimit", DEFAULT_GENERATE_THREADS)); obj.pushKV("localsolps" , getlocalsolps(params, false)); obj.pushKV("networksolps", getnetworksolps(params, false)); @@ -528,7 +531,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) return "inconclusive-not-best-prevblk"; CValidationState state; - TestBlockValidity(state, Params(), block, pindexPrev, false, true); + TestBlockValidity(state, Params(), block, pindexPrev, true); return BIP22ValidationResult(state); } } @@ -881,15 +884,17 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp) " \"founders\" : x.xxx, (numeric) The founders' reward amount in " + CURRENCY_UNIT + ".\n" " \"fundingstreams\" : [ (array) An array of funding stream descriptions (present only when Canopy has activated).\n" " {\n" - " \"recipient\" : \"...\", (string) A description of the funding stream recipient.\n" - " \"specification\" : \"url\", (string) A URL for the specification of this funding stream.\n" - " \"value\" : x.xxx (numeric) The funding stream amount in " + CURRENCY_UNIT + ".\n" + " \"recipient\" : \"...\", (string) A description of the funding stream recipient.\n" + " \"specification\" : \"url\", (string) A URL for the specification of this funding stream.\n" + " \"value\" : x.xxx (numeric) The funding stream amount in " + CURRENCY_UNIT + ".\n" + " \"valueZat\" : xxxx (numeric) The funding stream amount in " + MINOR_CURRENCY_UNIT + ".\n" + " \"address\" : (string) The transparent or Sapling address of the funding stream recipient.\n" " }, ...\n" " ]\n" "}\n" "\nExamples:\n" + HelpExampleCli("getblocksubsidy", "1000") - + HelpExampleRpc("getblockubsidy", "1000") + + HelpExampleRpc("getblocksubsidy", "1000") ); LOCK(cs_main); @@ -897,7 +902,7 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp) if (nHeight < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - auto consensus = Params().GetConsensus(); + const Consensus::Params& consensus = Params().GetConsensus(); CAmount nBlockSubsidy = GetBlockSubsidy(nHeight, consensus); CAmount nMinerReward = nBlockSubsidy; CAmount nFoundersReward = 0; @@ -905,9 +910,11 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); if (canopyActive) { + KeyIO keyIO(Params()); UniValue fundingstreams(UniValue::VARR); auto fsinfos = Consensus::GetActiveFundingStreams(nHeight, consensus); - for (auto fsinfo : fsinfos) { + for (int idx = 0; idx < fsinfos.size(); idx++) { + const auto& fsinfo = fsinfos[idx]; CAmount nStreamAmount = fsinfo.Value(nBlockSubsidy); nMinerReward -= nStreamAmount; @@ -915,6 +922,29 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp) fsobj.pushKV("recipient", fsinfo.recipient); fsobj.pushKV("specification", fsinfo.specification); fsobj.pushKV("value", ValueFromAmount(nStreamAmount)); + fsobj.pushKV("valueZat", nStreamAmount); + + auto fs = consensus.vFundingStreams[idx]; + auto address = fs.value().RecipientAddress(consensus, nHeight); + + CScript* outpoint = std::get_if(&address); + std::string addressStr; + + if (outpoint != nullptr) { + // For transparent funding stream addresses + UniValue pubkey(UniValue::VOBJ); + ScriptPubKeyToUniv(*outpoint, pubkey, true); + addressStr = find_value(pubkey, "addresses").get_array()[0].get_str(); + + } else { + libzcash::SaplingPaymentAddress* zaddr = std::get_if(&address); + if (zaddr != nullptr) { + // For shielded funding stream addresses + addressStr = keyIO.EncodePaymentAddress(*zaddr); + } + } + + fsobj.pushKV("address", addressStr); fundingstreams.push_back(fsobj); } result.pushKV("fundingstreams", fundingstreams); diff --git a/depend/zcash/src/rpc/misc.cpp b/depend/zcash/src/rpc/misc.cpp index fc1d36bc8..d79a718c7 100644 --- a/depend/zcash/src/rpc/misc.cpp +++ b/depend/zcash/src/rpc/misc.cpp @@ -106,7 +106,9 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.pushKV("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())); #endif obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())); - obj.pushKV("errors", GetWarnings("statusbar")); + auto warnings = GetWarnings("statusbar"); + obj.pushKV("errors", warnings.first); + obj.pushKV("errorstimestamp", warnings.second); return obj; } @@ -667,8 +669,8 @@ UniValue getaddressmempool(const UniValue& params, bool fHelp) UniValue getaddressutxos(const UniValue& params, bool fHelp) { std::string disabledMsg = ""; - if (!fExperimentalInsightExplorer) { - disabledMsg = experimentalDisabledHelpMsg("getaddressutxos", {"insightexplorer"}); + if (!(fExperimentalInsightExplorer || fExperimentalLightWalletd)) { + disabledMsg = experimentalDisabledHelpMsg("getaddressutxos", {"insightexplorer", "lightwalletd"}); } if (fHelp || params.size() != 1) throw runtime_error( @@ -718,7 +720,7 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp) + HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"tmYXBYJj1K7vhejSec5osXK2QsGa5MTisUQ\"], \"chainInfo\": true}") ); - if (!fExperimentalInsightExplorer) { + if (!(fExperimentalInsightExplorer || fExperimentalLightWalletd)) { throw JSONRPCError(RPC_MISC_ERROR, "Error: getaddressutxos is disabled. " "Run './zcash-cli help getaddressutxos' for instructions on how to enable this feature."); } diff --git a/depend/zcash/src/rpc/net.cpp b/depend/zcash/src/rpc/net.cpp index 9f8b4cf72..7fa19567c 100644 --- a/depend/zcash/src/rpc/net.cpp +++ b/depend/zcash/src/rpc/net.cpp @@ -84,7 +84,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp) "[\n" " {\n" " \"id\": n, (numeric) Peer index\n" - " \"addr\":\"host:port\", (string) The ip address and port of the peer\n" + " \"addr\":\"host:port\", (string) The IP address and port of the peer\n" " \"addrlocal\":\"ip:port\", (string) local address\n" " \"services\":\"xxxxxxxxxxxxxxxx\", (string) The services offered\n" " \"lastsend\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last send\n" @@ -173,7 +173,7 @@ UniValue addnode(const UniValue& params, bool fHelp) (strCommand != "onetry" && strCommand != "add" && strCommand != "remove")) throw runtime_error( "addnode \"node\" \"add|remove|onetry\"\n" - "\nAttempts add or remove a node from the addnode list.\n" + "\nAttempts to add or remove a node from the addnode list.\n" "Or try a connection to a node once.\n" "\nArguments:\n" "1. \"node\" (string, required) The node (see getpeerinfo for nodes)\n" @@ -251,7 +251,7 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp) "\nResult:\n" "[\n" " {\n" - " \"addednode\" : \"192.168.0.201\", (string) The node ip address\n" + " \"addednode\" : \"192.168.0.201\", (string) The node IP address\n" " \"connected\" : true|false, (boolean) If connected\n" " \"addresses\" : [\n" " {\n" @@ -488,7 +488,9 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp) } } obj.pushKV("localaddresses", localAddresses); - obj.pushKV("warnings", GetWarnings("statusbar")); + auto warnings = GetWarnings("statusbar"); + obj.pushKV("warnings", warnings.first); + obj.pushKV("warningstimestamp", warnings.second); return obj; } @@ -501,12 +503,12 @@ UniValue setban(const UniValue& params, bool fHelp) (strCommand != "add" && strCommand != "remove")) throw runtime_error( "setban \"ip(/netmask)\" \"add|remove\" (bantime) (absolute)\n" - "\nAttempts add or remove a IP/Subnet from the banned list.\n" + "\nAttempts to add or remove an IP/Subnet from the banned list.\n" "\nArguments:\n" - "1. \"ip(/netmask)\" (string, required) The IP/Subnet (see getpeerinfo for nodes ip) with a optional netmask (default is /32 = single ip)\n" - "2. \"command\" (string, required) 'add' to add a IP/Subnet to the list, 'remove' to remove a IP/Subnet from the list\n" - "3. \"bantime\" (numeric, optional) time in seconds how long (or until when if [absolute] is set) the ip is banned (0 or empty means using the default time of 24h which can also be overwritten by the -bantime startup argument)\n" - "4. \"absolute\" (boolean, optional) If set, the bantime must be a absolute timestamp in seconds since epoch (Jan 1 1970 GMT)\n" + "1. \"ip(/netmask)\" (string, required) The IP/Subnet (see getpeerinfo for nodes IP) with an optional netmask (default is /32 = single IP)\n" + "2. \"command\" (string, required) 'add' to add an IP/Subnet to the list, 'remove' to remove an IP/Subnet from the list\n" + "3. \"bantime\" (numeric, optional) time in seconds how long (or until when if [absolute] is set) the IP is banned (0 or empty means using the default time of 24h which can also be overwritten by the -bantime startup argument)\n" + "4. \"absolute\" (boolean, optional) If set, the bantime must be an absolute timestamp in seconds since epoch (Jan 1 1970 GMT)\n" "\nExamples:\n" + HelpExampleCli("setban", "\"192.168.0.6\" \"add\" 86400") + HelpExampleCli("setban", "\"192.168.0.0/24\" \"add\"") diff --git a/depend/zcash/src/rpc/rawtransaction.cpp b/depend/zcash/src/rpc/rawtransaction.cpp index 88fefea7e..c7957ea84 100644 --- a/depend/zcash/src/rpc/rawtransaction.cpp +++ b/depend/zcash/src/rpc/rawtransaction.cpp @@ -154,6 +154,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) { const uint256 txid = tx.GetHash(); entry.pushKV("txid", txid.GetHex()); + entry.pushKV("size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION)); entry.pushKV("overwintered", tx.fOverwintered); entry.pushKV("version", tx.nVersion); if (tx.fOverwintered) { @@ -236,8 +237,16 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) } if (tx.nVersion >= 2 && tx.vJoinSplit.size() > 0) { - entry.pushKV("joinSplitPubKey", tx.joinSplitPubKey.GetHex()); - entry.pushKV("joinSplitSig", HexStr(tx.joinSplitSig.begin(), tx.joinSplitSig.end())); + // Copy joinSplitPubKey into a uint256 so that + // it is byte-flipped in the RPC output. + uint256 joinSplitPubKey; + std::copy( + tx.joinSplitPubKey.bytes, + tx.joinSplitPubKey.bytes + ED25519_VERIFICATION_KEY_LEN, + joinSplitPubKey.begin()); + entry.pushKV("joinSplitPubKey", joinSplitPubKey.GetHex()); + entry.pushKV("joinSplitSig", + HexStr(tx.joinSplitSig.bytes, tx.joinSplitSig.bytes + ED25519_SIGNATURE_LEN)); } if (!hashBlock.IsNull()) { @@ -281,6 +290,7 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp) "{\n" " \"hex\" : \"data\", (string) The serialized, hex-encoded data for 'txid'\n" " \"txid\" : \"id\", (string) The transaction id (same as provided)\n" + " \"size\" : n, (numeric) The transaction size\n" " \"version\" : n, (numeric) The version\n" " \"locktime\" : ttt, (numeric) The lock time\n" " \"expiryheight\" : ttt, (numeric, optional) The block height after which the transaction expires\n" @@ -625,6 +635,7 @@ UniValue decoderawtransaction(const UniValue& params, bool fHelp) "\nResult:\n" "{\n" " \"txid\" : \"id\", (string) The transaction id\n" + " \"size\" : n, (numeric) The transaction size\n" " \"overwintered\" : bool (boolean) The Overwintered flag\n" " \"version\" : n, (numeric) The version\n" " \"versiongroupid\": \"hex\" (string, optional) The version group id (Overwintered txs)\n" diff --git a/depend/zcash/src/rpc/server.cpp b/depend/zcash/src/rpc/server.cpp index bd4273bd4..fc9c6da17 100644 --- a/depend/zcash/src/rpc/server.cpp +++ b/depend/zcash/src/rpc/server.cpp @@ -18,7 +18,7 @@ #include -#include +#include #include #include #include @@ -28,8 +28,11 @@ #include #include // for to_upper() +#include + using namespace RPCServer; using namespace std; +using namespace boost::placeholders; static bool fRPCRunning = false; static bool fRPCInWarmup = true; @@ -239,6 +242,42 @@ UniValue help(const UniValue& params, bool fHelp) } +UniValue setlogfilter(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() > 1) { + throw runtime_error( + "setlogfilter \"directives\"\n" + "\nSets the filter to be used for selecting events to log.\n" + "\nA filter is a comma-separated list of directives.\n" + "The syntax for each directive is:\n" + "\n target[span{field=value}]=level\n" + "\nThe default filter, derived from the -debug=target flags, is:\n" + + strprintf("\n %s", LogConfigFilter()) + "\n" + "\nPassing a valid filter here will replace the existing filter.\n" + "Passing an empty string will reset the filter to the default.\n" + "\nArguments:\n" + "1. newFilterDirectives (string, required) The new log filter.\n" + "\nExamples:\n" + + HelpExampleCli("setlogfilter", "\"main=info,rpc=info\"") + + HelpExampleRpc("setlogfilter", "\"main=info,rpc=info\"") + ); + } + + auto newFilter = params[0].getValStr(); + if (newFilter.empty()) { + newFilter = LogConfigFilter(); + } + + if (pTracingHandle) { + if (!tracing_reload(pTracingHandle, newFilter.c_str())) { + throw JSONRPCError(RPC_INTERNAL_ERROR, "Filter reload failed; check logs"); + } + } + + return NullUniValue; +} + + UniValue stop(const UniValue& params, bool fHelp) { // Accept the deprecated and ignored 'detach' boolean argument @@ -260,6 +299,7 @@ static const CRPCCommand vRPCCommands[] = // --------------------- ------------------------ ----------------------- ---------- /* Overall control/query calls */ { "control", "help", &help, true }, + { "control", "setlogfilter", &setlogfilter, true }, { "control", "stop", &stop, true }, }; diff --git a/depend/zcash/src/rust/include/librustzcash.h b/depend/zcash/src/rust/include/librustzcash.h index c6c3b1e6c..8fde5eade 100644 --- a/depend/zcash/src/rust/include/librustzcash.h +++ b/depend/zcash/src/rust/include/librustzcash.h @@ -1,6 +1,9 @@ #ifndef LIBRUSTZCASH_INCLUDE_H_ #define LIBRUSTZCASH_INCLUDE_H_ +#include "rust/types.h" + +#include #include #ifndef __cplusplus @@ -8,7 +11,16 @@ #include #endif -#define ENTRY_SERIALIZED_LENGTH 180 +#define NODE_SERIALIZED_LENGTH 171 +#define ENTRY_SERIALIZED_LENGTH (NODE_SERIALIZED_LENGTH + 9) + +typedef struct HistoryNode { + unsigned char bytes[NODE_SERIALIZED_LENGTH]; +} HistoryNode; +static_assert( + sizeof(HistoryNode) == NODE_SERIALIZED_LENGTH, + "HistoryNode struct is not the same size as the underlying byte array"); +static_assert(alignof(HistoryNode) == 1, "HistoryNode struct alignment is not 1"); typedef struct HistoryEntry { unsigned char bytes[ENTRY_SERIALIZED_LENGTH]; @@ -20,11 +32,6 @@ static_assert(alignof(HistoryEntry) == 1, "HistoryEntry struct alignment is not #ifdef __cplusplus extern "C" { -#endif -#ifdef WIN32 - typedef uint16_t codeunit; -#else - typedef uint8_t codeunit; #endif void librustzcash_to_scalar(const unsigned char *input, unsigned char *result); @@ -44,13 +51,10 @@ extern "C" { void librustzcash_init_zksnark_params( const codeunit* spend_path, size_t spend_path_len, - const char* spend_hash, const codeunit* output_path, size_t output_path_len, - const char* output_hash, const codeunit* sprout_path, - size_t sprout_path_len, - const char* sprout_hash + size_t sprout_path_len ); /// Validates the provided Equihash solution against @@ -200,7 +204,7 @@ extern "C" { const unsigned char *diversifier, const unsigned char *pk_d, const uint64_t value, - const unsigned char *r, + const unsigned char *rcm, const unsigned char *ak, const unsigned char *nk, const uint64_t position, @@ -213,11 +217,11 @@ extern "C" { /// The `pk_d` and `r` parameters must be of length 32. /// The result is also of length 32 and placed in `result`. /// Returns false if the diversifier or pk_d is not valid - bool librustzcash_sapling_compute_cm( + bool librustzcash_sapling_compute_cmu( const unsigned char *diversifier, const unsigned char *pk_d, const uint64_t value, - const unsigned char *r, + const unsigned char *rcm, unsigned char *result ); @@ -331,9 +335,9 @@ extern "C" { const uint32_t *ni_ptr, const HistoryEntry *n_ptr, size_t p_len, - const unsigned char *nn_ptr, + const HistoryNode *nn_ptr, unsigned char *rt_ret, - unsigned char *buf_ret + HistoryNode *buf_ret ); uint32_t librustzcash_mmr_delete( @@ -348,11 +352,14 @@ extern "C" { uint32_t librustzcash_mmr_hash_node( uint32_t cbranch, - const unsigned char *n_ptr, + const HistoryNode *n_ptr, unsigned char *h_ret ); - /// Fills the provided buffer with random bytes. + /// Fills the provided buffer with random bytes. This is intended to + /// be a cryptographically secure RNG; it uses Rust's `OsRng`, which + /// is implemented in terms of the `getrandom` crate. The first call + /// to this function may block until sufficient randomness is available. void librustzcash_getrandom( unsigned char *buf, size_t buf_len diff --git a/depend/zcash/src/rust/include/rust/blake2b.h b/depend/zcash/src/rust/include/rust/blake2b.h index e5c17ec7b..39bc34cf9 100644 --- a/depend/zcash/src/rust/include/rust/blake2b.h +++ b/depend/zcash/src/rust/include/rust/blake2b.h @@ -2,11 +2,10 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or https://www.opensource.org/licenses/mit-license.php . -#ifndef RUST_BLAKE2B_H_ -#define RUST_BLAKE2B_H_ +#ifndef BLAKE2B_INCLUDE_H_ +#define BLAKE2B_INCLUDE_H_ #include -#include #ifdef __cplusplus extern "C" { @@ -20,32 +19,35 @@ typedef struct BLAKE2bState BLAKE2bState; /// /// `personalization` MUST be a pointer to a 16-byte array. /// -/// Please free this with `rust_blake2b_free` when you are done. -BLAKE2bState* rust_blake2b_init( - size_t length, +/// Please free this with `blake2b_free` when you are done. +BLAKE2bState* blake2b_init( + size_t output_len, const unsigned char* personalization); /// Clones the given BLAKE2b state. /// -/// Both states need to be separately freed with `rust_blake2b_free` when you -/// are done. -BLAKE2bState* rust_blake2b_clone(const BLAKE2bState* state); +/// Both states need to be separately freed with `blake2b_free` when you are +/// done. +BLAKE2bState* blake2b_clone(const BLAKE2bState* state); -/// Frees a BLAKE2b state returned by `rust_blake2b_init`. -void rust_blake2b_free(BLAKE2bState* state); +/// Frees a BLAKE2b state returned by `blake2b_init`. +void blake2b_free(BLAKE2bState* state); /// Adds input to the hash. You can call this any number of times. -void rust_blake2b_update( +void blake2b_update( BLAKE2bState* state, const unsigned char* input, size_t input_len); /// Finalizes the `state` and stores the result in `output`. /// +/// `output_len` MUST be less than or equal to the value that was passed as the +/// first parameter to `blake2b_init`. +/// /// This method is idempotent, and calling it multiple times will give the same -/// result. It's also possible to call `rust_blake2b_update` with more input in +/// result. It's also possible to call `blake2b_update` with more input in /// between. -void rust_blake2b_finalize( +void blake2b_finalize( BLAKE2bState* state, unsigned char* output, size_t output_len); @@ -54,4 +56,4 @@ void rust_blake2b_finalize( } #endif -#endif // RUST_BLAKE2B_H_ +#endif // BLAKE2B_INCLUDE_H_ diff --git a/depend/zcash/src/rust/include/rust/ed25519.h b/depend/zcash/src/rust/include/rust/ed25519.h new file mode 100644 index 000000000..2d4ba1d2a --- /dev/null +++ b/depend/zcash/src/rust/include/rust/ed25519.h @@ -0,0 +1,59 @@ +// Copyright (c) 2020 The Zcash developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or https://www.opensource.org/licenses/mit-license.php . + +#ifndef ED25519_INCLUDE_H_ +#define ED25519_INCLUDE_H_ + +#include "ed25519/types.h" + +#include + +#ifndef __cplusplus +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/// Generates a new Ed25519 keypair. +void ed25519_generate_keypair( + Ed25519SigningKey* sk, + Ed25519VerificationKey* vk); + +/// Creates a signature on msg using the given signing key. +bool ed25519_sign( + const Ed25519SigningKey* sk, + const unsigned char* msg, + size_t msglen, + Ed25519Signature* signature); + +/// Verifies a purported `signature` on the given `msg`. +/// +/// # Zcash-specific consensus properties +/// +/// Ed25519 checks are described in §5.4.5 of the Zcash protocol specification +/// and in ZIP 215. The verification criteria for an (encoded) `signature` +/// (`R_bytes`, `s_bytes`) with (encoded) verification key `A_bytes` are: +/// +/// - `A_bytes` and `R_bytes` MUST be encodings of points `A` and `R` +/// respectively on the twisted Edwards form of Curve25519, and non-canonical +/// encodings MUST be accepted; +/// - `s_bytes` MUST represent an integer `s` less than `l`, the order of the +/// prime-order subgroup of Curve25519; +/// - the verification equation `[8][s]B = [8]R + [8][k]A` MUST be satisfied; +/// - the alternate verification equation `[s]B = R + [k]A`, allowed by RFC 8032, +/// MUST NOT be used. +bool ed25519_verify( + const Ed25519VerificationKey* vk, + const Ed25519Signature* signature, + const unsigned char* msg, + size_t msglen); + +#ifdef __cplusplus +} +#endif + +#endif // ED25519_INCLUDE_H_ diff --git a/depend/zcash/src/rust/include/rust/ed25519/types.h b/depend/zcash/src/rust/include/rust/ed25519/types.h new file mode 100644 index 000000000..56f00f88d --- /dev/null +++ b/depend/zcash/src/rust/include/rust/ed25519/types.h @@ -0,0 +1,56 @@ +// Copyright (c) 2020 The Zcash developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or https://www.opensource.org/licenses/mit-license.php . + +#ifndef RUST_ED25519_TYPES_H_ +#define RUST_ED25519_TYPES_H_ + +#ifndef __cplusplus +#include +#include +#endif + +#define ED25519_SIGNING_KEY_LEN 32U +#define ED25519_VERIFICATION_KEY_LEN 32U +#define ED25519_SIGNATURE_LEN 64U + +/// An Ed25519 signing key. +/// +/// This is also called a secret key by other implementations. +typedef struct Ed25519SigningKey { + unsigned char bytes[ED25519_SIGNING_KEY_LEN]; +} Ed25519SigningKey; +static_assert( + sizeof(Ed25519SigningKey) == ED25519_SIGNING_KEY_LEN, + "Ed25519SigningKey struct is not the same size as the underlying byte array"); +static_assert( + alignof(Ed25519SigningKey) == 1, + "Ed25519SigningKey struct alignment is not 1"); + +/// An encoded Ed25519 verification key. +/// +/// This is also called a public key by other implementations. +/// +/// This type does not guarantee validity of the verification key. +typedef struct Ed25519VerificationKey { + unsigned char bytes[ED25519_VERIFICATION_KEY_LEN]; +} Ed25519VerificationKey; +static_assert( + sizeof(Ed25519VerificationKey) == ED25519_VERIFICATION_KEY_LEN, + "Ed25519VerificationKey struct is not the same size as the underlying byte array"); +static_assert( + alignof(Ed25519VerificationKey) == 1, + "Ed25519VerificationKey struct alignment is not 1"); + +/// An Ed25519 signature. +typedef struct Ed25519Signature { + unsigned char bytes[ED25519_SIGNATURE_LEN]; +} Ed25519Signature; +static_assert( + sizeof(Ed25519Signature) == ED25519_SIGNATURE_LEN, + "Ed25519Signature struct is not the same size as the underlying byte array"); +static_assert( + alignof(Ed25519Signature) == 1, + "Ed25519Signature struct alignment is not 1"); + +#endif // RUST_ED25519_TYPES_H_ diff --git a/depend/zcash/src/rust/include/rust/types.h b/depend/zcash/src/rust/include/rust/types.h new file mode 100644 index 000000000..63c5a1d52 --- /dev/null +++ b/depend/zcash/src/rust/include/rust/types.h @@ -0,0 +1,16 @@ +// Copyright (c) 2020 The Zcash developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or https://www.opensource.org/licenses/mit-license.php . + +#ifndef RUST_TYPES_H_ +#define RUST_TYPES_H_ + +#include + +#ifdef WIN32 +typedef uint16_t codeunit; +#else +typedef uint8_t codeunit; +#endif + +#endif // RUST_TYPES_H_ diff --git a/depend/zcash/src/rust/include/tracing.h b/depend/zcash/src/rust/include/tracing.h new file mode 100644 index 000000000..744e80712 --- /dev/null +++ b/depend/zcash/src/rust/include/tracing.h @@ -0,0 +1,341 @@ +// Copyright (c) 2020 Jack Grigg +// Distributed under the MIT software license, see the accompanying +// file COPYING or https://www.opensource.org/licenses/mit-license.php . + +#ifndef TRACING_INCLUDE_H_ +#define TRACING_INCLUDE_H_ + +#include "rust/types.h" +#include "tracing/map.h" + +#include +#include + +#ifdef __cplusplus +#include + +extern "C" { +#endif + +struct TracingHandle; +typedef struct TracingHandle TracingHandle; + +/// Initializes the tracing crate, returning a handle for the logging +/// component. The handle must be freed to close the logging component. +/// +/// If log_path is NULL, logging is sent to standard output. +TracingHandle* tracing_init( + const codeunit* log_path, + size_t log_path_len, + const char* initial_filter, + bool log_timestamps); + +/// Frees a tracing handle returned from `tracing_init`; +void tracing_free(TracingHandle* handle); + +/// Reloads the tracing filter. +/// +/// Returns `true` if the reload succeeded. +bool tracing_reload(TracingHandle* handle, const char* new_filter); + +struct TracingCallsite; +typedef struct TracingCallsite TracingCallsite; + +/// Creates a tracing callsite. +/// +/// You should usually call the `TracingLog` macro (or one of the helper +/// macros such as `TracingInfo`) instead of calling this directly. +/// +/// This MUST ONLY be called to assign a `static TracingCallsite*`, and all +/// string arguments MUST be static `const char*` constants, and MUST be valid +/// UTF-8. +TracingCallsite* tracing_callsite( + const char* name, + const char* target, + const char* level, + const char* file, + uint32_t line, + const char* const* fields, + size_t fields_len, + bool is_span); + +struct TracingSpanHandle; +typedef struct TracingSpanHandle TracingSpanHandle; + +struct TracingSpanGuard; +typedef struct TracingSpanGuard TracingSpanGuard; + +/// Creates a span for a callsite. +/// +/// The span must be freed when it goes out of scope. +TracingSpanHandle* tracing_span_create( + const TracingCallsite* callsite, + const char* const* field_values, + size_t fields_len); + +/// Clones the given span. +/// +/// Both spans need to be separately freed when they go out of scope. +TracingSpanHandle* tracing_span_clone(const TracingSpanHandle* span); + +/// Frees a span. +void tracing_span_free(TracingSpanHandle* span); + +/// Enters the given span, returning a guard. +/// +/// `tracing_span_exit` must be called to drop this guard before the span +/// goes out of scope. +TracingSpanGuard* tracing_span_enter(const TracingSpanHandle* span); + +/// Exits a span by dropping the given guard. +void tracing_span_exit(TracingSpanGuard* guard); + +/// Logs a message for a callsite. +/// +/// You should usually call the `TracingLog` macro (or one of the helper +/// macros such as `TracingInfo`) instead of calling this directly. +void tracing_log( + const TracingCallsite* callsite, + const char* const* field_values, + size_t fields_len); + +#ifdef __cplusplus +} +#endif + +// +// Helper macros +// + +#define MAP_PAIR_LIST0(f, x, y, peek, ...) f(x, y) MAP_LIST_NEXT(peek, MAP_PAIR_LIST1)(f, peek, __VA_ARGS__) +#define MAP_PAIR_LIST1(f, x, y, peek, ...) f(x, y) MAP_LIST_NEXT(peek, MAP_PAIR_LIST0)(f, peek, __VA_ARGS__) + +/// Applies the function macro `f` to each pair of the remaining parameters and +/// inserts commas between the results. +#define MAP_PAIR_LIST(f, ...) EVAL(MAP_PAIR_LIST1(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#define T_FIELD_NAME(x, y) x +#define T_FIELD_VALUE(x, y) y + +#define T_FIELD_NAMES(...) MAP_PAIR_LIST(T_FIELD_NAME, __VA_ARGS__) +#define T_FIELD_VALUES(...) MAP_PAIR_LIST(T_FIELD_VALUE, __VA_ARGS__) + +#define T_DOUBLEESCAPE(a) #a +#define T_ESCAPEQUOTE(a) T_DOUBLEESCAPE(a) + +// Computes the length of the given array. This is COUNT_OF from Chromium. +#define T_ARRLEN(x) ((sizeof(x) / sizeof(0 [x])) / ((size_t)(!(sizeof(x) % sizeof(0 [x]))))) + +#ifdef __cplusplus +// Constructs a tracing callsite. +// +// The 'static constexpr' hack ensures that name, target, level, and fields are +// compile-time constants with static storage duration. The output of this macro +// MUST be stored as a static TracingCallsite*. +#define T_CALLSITE(name, target, level, fields, is_span) ([&] { \ + static constexpr const char* _t_name = name; \ + static constexpr const char* _t_target = target; \ + static constexpr const char* _t_level = level; \ + static constexpr const char* const* _t_fields = fields; \ + return tracing_callsite( \ + _t_name, \ + _t_target, \ + _t_level, \ + __FILE__, \ + __LINE__, \ + _t_fields, \ + T_ARRLEN(fields), \ + is_span); \ +}()) +#else +// Constructs a tracing callsite. +// +// name, target, level, and fields MUST be static constants, and the output of +// this macro MUST be stored as a static TracingCallsite*. +#define T_CALLSITE(name, target, level, fields, is_span) \ + tracing_callsite( \ + name, \ + target, \ + level, \ + __FILE__, \ + __LINE__, \ + fields, \ + T_ARRLEN(fields), \ + is_span) +#endif + +// +// Spans +// + +#ifdef __cplusplus +namespace tracing +{ +class Span; + +/// A guard representing a span which has been entered and is currently +/// executing. +/// +/// When the guard is dropped, the span will be exited. +/// +/// This is returned by the `Span::Enter` function. +class Entered +{ +private: + friend class Span; + std::unique_ptr inner; + + Entered(const TracingSpanHandle* span) : inner(tracing_span_enter(span), tracing_span_exit) {} +}; + +/// A handle representing a span, with the capability to enter the span if it +/// exists. +/// +/// If the span was rejected by the current `Subscriber`'s filter, entering the +/// span will silently do nothing. Thus, the handle can be used in the same +/// manner regardless of whether or not the trace is currently being collected. +class Span +{ +private: + std::unique_ptr inner; + +public: + /// Constructs a span that does nothing. + /// + /// This constructor is present to enable spans to be stored in classes, + /// while also containing fields that are initialized within the class + /// constructor: + /// + /// class Foo { + /// std::string name; + /// tracing::Span span; + /// + /// Foo(std::string tag) + /// { + /// name = "Foo-" + tag; + /// span = TracingSpan("info", "main", "Foo", "name", name); + /// } + /// } + Span() : inner(nullptr, tracing_span_free) {} + + /// Use the `TracingSpan` macro instead of calling this constructor directly. + Span(const TracingCallsite* callsite, const char* const* field_values, size_t fields_len) : inner(tracing_span_create(callsite, field_values, fields_len), tracing_span_free) {} + + Span(Span&& span) : inner(std::move(span.inner)) {} + Span(const Span& span) : inner(tracing_span_clone(span.inner.get()), tracing_span_free) {} + Span& operator=(Span&& span) + { + if (this != &span) { + inner = std::move(span.inner); + } + return *this; + } + Span& operator=(const Span& span) + { + if (this != &span) { + inner.reset(tracing_span_clone(span.inner.get())); + } + return *this; + } + + /// Enters this span, returning a guard that will exit the span when dropped. + /// + /// If this span is enabled by the current subscriber, then this function + /// will call `Subscriber::enter` with the span's `Id`, and dropping the + /// guard will call `Subscriber::exit`. If the span is disabled, this does + /// nothing. + Entered Enter() + { + return Entered(inner.get()); + } +}; +} // namespace tracing + +/// Expands to a `tracing::Span` object which is used to record a span. +/// The `Span::Enter` method on that object records that the span has been +/// entered, and returns a RAII guard object, which will exit the span when +/// dropped. +/// +/// level, target, and name MUST be static constants, and MUST be valid UTF-8 +/// strings. +#define TracingSpan(level, target, name) ([&] { \ + static constexpr const char* const FIELDS[] = {}; \ + const char* T_VALUES[] = {}; \ + static TracingCallsite* CALLSITE = \ + T_CALLSITE(name, target, level, FIELDS, true); \ + return tracing::Span( \ + CALLSITE, T_VALUES, T_ARRLEN(T_VALUES)); \ +}()) + +/// Expands to a `tracing::Span` object which is used to record a span. +/// The `Span::Enter` method on that object records that the span has been +/// entered, and returns a RAII guard object, which will exit the span when +/// dropped. +/// +/// Arguments: (level, target, name, key, value[, key2, value2, ...]) +/// +/// level, target, name, and all keys MUST be static constants, and MUST be +/// valid UTF-8 strings. +#define TracingSpanFields(level, target, name, ...) ([&] { \ + static constexpr const char* const FIELDS[] = \ + {T_FIELD_NAMES(__VA_ARGS__)}; \ + const char* T_VALUES[] = \ + {T_FIELD_VALUES(__VA_ARGS__)}; \ + static TracingCallsite* CALLSITE = \ + T_CALLSITE(name, target, level, FIELDS, true); \ + return tracing::Span( \ + CALLSITE, T_VALUES, T_ARRLEN(T_VALUES)); \ +}()) +#endif + +// +// Events +// + +/// Constructs a new event. +/// +/// level and target MUST be static constants, and MUST be valid UTF-8 strings. +#define TracingLog(level, target, ...) \ + do { \ + static constexpr const char* const FIELDS[] = \ + {T_FIELD_NAMES("message", __VA_ARGS__)}; \ + const char* T_VALUES[] = \ + {T_FIELD_VALUES("message", __VA_ARGS__)}; \ + static TracingCallsite* CALLSITE = T_CALLSITE( \ + "event " __FILE__ ":" T_ESCAPEQUOTE(__LINE__), \ + target, level, FIELDS, false); \ + tracing_log(CALLSITE, T_VALUES, T_ARRLEN(T_VALUES)); \ + } while (0) + +/// Constructs an event at the error level. +/// +/// Arguments: (target, message) +/// +/// target MUST be a static constant, and MUST be valid UTF-8 string. +#define TracingError(...) TracingLog("error", __VA_ARGS__) +/// Constructs an event at the warn level. +/// +/// Arguments: (target, message) +/// +/// target MUST be a static constant, and MUST be valid UTF-8 string. +#define TracingWarn(...) TracingLog("warn", __VA_ARGS__) +/// Constructs an event at the info level. +/// +/// Arguments: (target, message) +/// +/// target MUST be a static constant, and MUST be valid UTF-8 string. +#define TracingInfo(...) TracingLog("info", __VA_ARGS__) +/// Constructs an event at the debug level. +/// +/// Arguments: (target, message) +/// +/// target MUST be a static constant, and MUST be valid UTF-8 string. +#define TracingDebug(...) TracingLog("debug", __VA_ARGS__) +/// Constructs an event at the trace level. +/// +/// Arguments: (target, message) +/// +/// target MUST be a static constant, and MUST be valid UTF-8 string. +#define TracingTrace(...) TracingLog("trace", __VA_ARGS__) + +#endif // TRACING_INCLUDE_H_ diff --git a/depend/zcash/src/rust/include/tracing/map.h b/depend/zcash/src/rust/include/tracing/map.h new file mode 100644 index 000000000..acd5018e3 --- /dev/null +++ b/depend/zcash/src/rust/include/tracing/map.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2012 William Swanson + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the names of the authors or + * their institutions shall not be used in advertising or otherwise to + * promote the sale, use or other dealings in this Software without + * prior written authorization from the authors. + */ + +#ifndef MAP_H_INCLUDED +#define MAP_H_INCLUDED + +#define EVAL0(...) __VA_ARGS__ +#define EVAL1(...) EVAL0(EVAL0(EVAL0(__VA_ARGS__))) +#define EVAL2(...) EVAL1(EVAL1(EVAL1(__VA_ARGS__))) +#define EVAL3(...) EVAL2(EVAL2(EVAL2(__VA_ARGS__))) +#define EVAL4(...) EVAL3(EVAL3(EVAL3(__VA_ARGS__))) +#define EVAL(...) EVAL4(EVAL4(EVAL4(__VA_ARGS__))) + +#define MAP_END(...) +#define MAP_OUT +#define MAP_COMMA , + +#define MAP_GET_END2() 0, MAP_END +#define MAP_GET_END1(...) MAP_GET_END2 +#define MAP_GET_END(...) MAP_GET_END1 +#define MAP_NEXT0(test, next, ...) next MAP_OUT +#define MAP_NEXT1(test, next) MAP_NEXT0(test, next, 0) +#define MAP_NEXT(test, next) MAP_NEXT1(MAP_GET_END test, next) + +#define MAP0(f, x, peek, ...) f(x) MAP_NEXT(peek, MAP1)(f, peek, __VA_ARGS__) +#define MAP1(f, x, peek, ...) f(x) MAP_NEXT(peek, MAP0)(f, peek, __VA_ARGS__) + +#define MAP_LIST_NEXT1(test, next) MAP_NEXT0(test, MAP_COMMA next, 0) +#define MAP_LIST_NEXT(test, next) MAP_LIST_NEXT1(MAP_GET_END test, next) + +#define MAP_LIST0(f, x, peek, ...) f(x) MAP_LIST_NEXT(peek, MAP_LIST1)(f, peek, __VA_ARGS__) +#define MAP_LIST1(f, x, peek, ...) f(x) MAP_LIST_NEXT(peek, MAP_LIST0)(f, peek, __VA_ARGS__) + +/** + * Applies the function macro `f` to each of the remaining parameters. + */ +#define MAP(f, ...) EVAL(MAP1(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +/** + * Applies the function macro `f` to each of the remaining parameters and + * inserts commas between the results. + */ +#define MAP_LIST(f, ...) EVAL(MAP_LIST1(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#endif diff --git a/depend/zcash/src/rust/src/blake2b.rs b/depend/zcash/src/rust/src/blake2b.rs index 3d02293bb..b389631be 100644 --- a/depend/zcash/src/rust/src/blake2b.rs +++ b/depend/zcash/src/rust/src/blake2b.rs @@ -4,37 +4,40 @@ use blake2b_simd::{State, PERSONALBYTES}; use libc::{c_uchar, size_t}; +use std::ptr; use std::slice; #[no_mangle] -pub extern "C" fn rust_blake2b_init( - length: size_t, +pub extern "C" fn blake2b_init( + output_len: size_t, personalization: *const [c_uchar; PERSONALBYTES], ) -> *mut State { let personalization = unsafe { personalization.as_ref().unwrap() }; Box::into_raw(Box::new( blake2b_simd::Params::new() - .hash_length(length) + .hash_length(output_len) .personal(personalization) .to_state(), )) } #[no_mangle] -pub extern "C" fn rust_blake2b_clone(state: *const State) -> *mut State { - let state = unsafe { state.as_ref().unwrap() }; - - Box::into_raw(Box::new(state.clone())) +pub extern "C" fn blake2b_clone(state: *const State) -> *mut State { + unsafe { state.as_ref() } + .map(|state| Box::into_raw(Box::new(state.clone()))) + .unwrap_or(ptr::null_mut()) } #[no_mangle] -pub extern "C" fn rust_blake2b_free(state: *mut State) { - drop(unsafe { Box::from_raw(state) }); +pub extern "C" fn blake2b_free(state: *mut State) { + if !state.is_null() { + drop(unsafe { Box::from_raw(state) }); + } } #[no_mangle] -pub extern "C" fn rust_blake2b_update(state: *mut State, input: *const c_uchar, input_len: size_t) { +pub extern "C" fn blake2b_update(state: *mut State, input: *const c_uchar, input_len: size_t) { let state = unsafe { state.as_mut().unwrap() }; let input = unsafe { slice::from_raw_parts(input, input_len) }; @@ -42,13 +45,12 @@ pub extern "C" fn rust_blake2b_update(state: *mut State, input: *const c_uchar, } #[no_mangle] -pub extern "C" fn rust_blake2b_finalize( - state: *mut State, - output: *mut c_uchar, - output_len: size_t, -) { +pub extern "C" fn blake2b_finalize(state: *mut State, output: *mut c_uchar, output_len: size_t) { let state = unsafe { state.as_mut().unwrap() }; let output = unsafe { slice::from_raw_parts_mut(output, output_len) }; - output.copy_from_slice(state.finalize().as_bytes()); + // Allow consuming only part of the output. + let hash = state.finalize(); + assert!(output_len <= hash.as_bytes().len()); + output.copy_from_slice(&hash.as_bytes()[..output_len]); } diff --git a/depend/zcash/src/rust/src/ed25519.rs b/depend/zcash/src/rust/src/ed25519.rs new file mode 100644 index 000000000..3a40cff31 --- /dev/null +++ b/depend/zcash/src/rust/src/ed25519.rs @@ -0,0 +1,67 @@ +// Copyright (c) 2020 The Zcash developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or https://www.opensource.org/licenses/mit-license.php . + +use ed25519_zebra::{Signature, SigningKey, VerificationKey}; +use libc::{c_uchar, size_t}; +use rand_core::OsRng; +use std::convert::TryFrom; +use std::slice; + +#[no_mangle] +pub extern "C" fn ed25519_generate_keypair(sk: *mut [u8; 32], vk: *mut [u8; 32]) { + let sk = unsafe { sk.as_mut() }.unwrap(); + let vk = unsafe { vk.as_mut() }.unwrap(); + + let signing_key = SigningKey::new(OsRng); + + *sk = signing_key.into(); + *vk = VerificationKey::from(&signing_key).into(); +} + +#[no_mangle] +pub extern "C" fn ed25519_sign( + sk: *const [u8; 32], + msg: *const c_uchar, + msg_len: size_t, + signature: *mut [u8; 64], +) -> bool { + let sk = SigningKey::from(*unsafe { sk.as_ref() }.unwrap()); + + let msg = unsafe { slice::from_raw_parts(msg, msg_len) }; + + let signature = unsafe { + match signature.as_mut() { + Some(sig) => sig, + None => return false, + } + }; + + *signature = sk.sign(msg).into(); + + true +} + +#[no_mangle] +pub extern "C" fn ed25519_verify( + vk: *const [u8; 32], + signature: *const [u8; 64], + msg: *const c_uchar, + msg_len: size_t, +) -> bool { + let vk = match VerificationKey::try_from(*unsafe { vk.as_ref() }.unwrap()) { + Ok(vk) => vk, + Err(_) => return false, + }; + + let signature = Signature::from(*unsafe { + match signature.as_ref() { + Some(sig) => sig, + None => return false, + } + }); + + let msg = unsafe { slice::from_raw_parts(msg, msg_len) }; + + vk.verify(&signature, msg).is_ok() +} diff --git a/depend/zcash/src/rust/src/rustzcash.rs b/depend/zcash/src/rust/src/rustzcash.rs index e2b5863a6..677db80f6 100644 --- a/depend/zcash/src/rust/src/rustzcash.rs +++ b/depend/zcash/src/rust/src/rustzcash.rs @@ -21,16 +21,15 @@ use bellman::groth16::{Parameters, PreparedVerifyingKey, Proof}; use blake2s_simd::Params as Blake2sParams; -use ff::{PrimeField, PrimeFieldRepr}; -use lazy_static; -use libc::{c_char, c_uchar, size_t}; -use pairing::bls12_381::{Bls12, Fr, FrRepr}; +use bls12_381::Bls12; +use group::{cofactor::CofactorGroup, GroupEncoding}; +use libc::{c_uchar, size_t}; use rand_core::{OsRng, RngCore}; -use std::ffi::CStr; use std::fs::File; use std::io::BufReader; use std::path::{Path, PathBuf}; use std::slice; +use subtle::CtOption; #[cfg(not(target_os = "windows"))] use std::ffi::OsStr; @@ -44,19 +43,14 @@ use std::os::windows::ffi::OsStringExt; use zcash_primitives::{ block::equihash, - constants::CRH_IVK_PERSONALIZATION, - jubjub::{ - edwards, - fs::{Fs, FsRepr}, - FixedGenerators, JubjubEngine, JubjubParams, PrimeOrder, ToUniform, Unknown, - }, + constants::{CRH_IVK_PERSONALIZATION, PROOF_GENERATION_KEY_GENERATOR, SPENDING_KEY_GENERATOR}, merkle_tree::MerklePath, note_encryption::sapling_ka_agree, - primitives::{Diversifier, Note, PaymentAddress, ProofGenerationKey, ViewingKey}, + primitives::{Diversifier, Note, PaymentAddress, ProofGenerationKey, Rseed, ViewingKey}, redjubjub::{self, Signature}, sapling::{merkle_hash, spend_sig}, transaction::components::Amount, - zip32, JUBJUB, + zip32, }; use zcash_proofs::{ circuit::sapling::TREE_DEPTH as SAPLING_TREE_DEPTH, @@ -68,6 +62,8 @@ use zcash_proofs::{ use zcash_history::{Entry as MMREntry, NodeData as MMRNodeData, Tree as MMRTree}; mod blake2b; +mod ed25519; +mod tracing_ffi; #[cfg(test)] mod tests; @@ -80,142 +76,77 @@ static mut SAPLING_SPEND_PARAMS: Option> = None; static mut SAPLING_OUTPUT_PARAMS: Option> = None; static mut SPROUT_GROTH16_PARAMS_PATH: Option = None; -/// Reads an FrRepr from a [u8; 32]. -fn read_fr(from: &[u8; 32]) -> FrRepr { - let mut f = FrRepr::default(); - f.read_le(&from[..]).expect("length is 32 bytes"); - f -} - -/// Reads an FsRepr from a [u8; 32]. -fn read_fs(from: &[u8; 32]) -> FsRepr { - let mut f = <::Fs as PrimeField>::Repr::default(); - f.read_le(&from[..]).expect("length is 32 bytes"); - f +/// Converts CtOption into Option +fn de_ct(ct: CtOption) -> Option { + if ct.is_some().into() { + Some(ct.unwrap()) + } else { + None + } } /// Reads an FsRepr from a [u8; 32] /// and multiplies it by the given base. -fn fixed_scalar_mult(from: &[u8; 32], p_g: FixedGenerators) -> edwards::Point { - let f = read_fs(from); +fn fixed_scalar_mult(from: &[u8; 32], p_g: &jubjub::SubgroupPoint) -> jubjub::SubgroupPoint { + // We only call this with `from` being a valid jubjub::Scalar. + let f = jubjub::Scalar::from_bytes(from).unwrap(); - JUBJUB.generator(p_g).mul(f, &JUBJUB) + p_g * f } /// Loads the zk-SNARK parameters into memory and saves paths as necessary. /// Only called once. -#[cfg(not(target_os = "windows"))] #[no_mangle] pub extern "C" fn librustzcash_init_zksnark_params( - spend_path: *const u8, + #[cfg(not(target_os = "windows"))] spend_path: *const u8, + #[cfg(target_os = "windows")] spend_path: *const u16, spend_path_len: usize, - spend_hash: *const c_char, - output_path: *const u8, + #[cfg(not(target_os = "windows"))] output_path: *const u8, + #[cfg(target_os = "windows")] output_path: *const u16, output_path_len: usize, - output_hash: *const c_char, - sprout_path: *const u8, + #[cfg(not(target_os = "windows"))] sprout_path: *const u8, + #[cfg(target_os = "windows")] sprout_path: *const u16, sprout_path_len: usize, - sprout_hash: *const c_char, ) { - let spend_path = Path::new(OsStr::from_bytes(unsafe { - slice::from_raw_parts(spend_path, spend_path_len) - })); - let output_path = Path::new(OsStr::from_bytes(unsafe { - slice::from_raw_parts(output_path, output_path_len) - })); - let sprout_path = if sprout_path.is_null() { - None - } else { - Some(Path::new(OsStr::from_bytes(unsafe { - slice::from_raw_parts(sprout_path, sprout_path_len) - }))) + #[cfg(not(target_os = "windows"))] + let (spend_path, output_path, sprout_path) = { + ( + OsStr::from_bytes(unsafe { slice::from_raw_parts(spend_path, spend_path_len) }), + OsStr::from_bytes(unsafe { slice::from_raw_parts(output_path, output_path_len) }), + if sprout_path.is_null() { + None + } else { + Some(OsStr::from_bytes(unsafe { + slice::from_raw_parts(sprout_path, sprout_path_len) + })) + }, + ) }; - init_zksnark_params( - spend_path, - spend_hash, - output_path, - output_hash, - sprout_path, - sprout_hash, - ) -} - -/// Loads the zk-SNARK parameters into memory and saves paths as necessary. -/// Only called once. -#[cfg(target_os = "windows")] -#[no_mangle] -pub extern "C" fn librustzcash_init_zksnark_params( - spend_path: *const u16, - spend_path_len: usize, - spend_hash: *const c_char, - output_path: *const u16, - output_path_len: usize, - output_hash: *const c_char, - sprout_path: *const u16, - sprout_path_len: usize, - sprout_hash: *const c_char, -) { - let spend_path = - OsString::from_wide(unsafe { slice::from_raw_parts(spend_path, spend_path_len) }); - let output_path = - OsString::from_wide(unsafe { slice::from_raw_parts(output_path, output_path_len) }); - let sprout_path = if sprout_path.is_null() { - None - } else { - Some(OsString::from_wide(unsafe { - slice::from_raw_parts(sprout_path, sprout_path_len) - })) + #[cfg(target_os = "windows")] + let (spend_path, output_path, sprout_path) = { + ( + OsString::from_wide(unsafe { slice::from_raw_parts(spend_path, spend_path_len) }), + OsString::from_wide(unsafe { slice::from_raw_parts(output_path, output_path_len) }), + if sprout_path.is_null() { + None + } else { + Some(OsString::from_wide(unsafe { + slice::from_raw_parts(sprout_path, sprout_path_len) + })) + }, + ) }; - init_zksnark_params( + let (spend_path, output_path, sprout_path) = ( Path::new(&spend_path), - spend_hash, Path::new(&output_path), - output_hash, sprout_path.as_ref().map(|p| Path::new(p)), - sprout_hash, - ) -} - -fn init_zksnark_params( - spend_path: &Path, - spend_hash: *const c_char, - output_path: &Path, - output_hash: *const c_char, - sprout_path: Option<&Path>, - sprout_hash: *const c_char, -) { - // Initialize jubjub parameters here - lazy_static::initialize(&JUBJUB); - - let spend_hash = unsafe { CStr::from_ptr(spend_hash) } - .to_str() - .expect("hash should be a valid string"); - - let output_hash = unsafe { CStr::from_ptr(output_hash) } - .to_str() - .expect("hash should be a valid string"); - - let sprout_hash = if sprout_path.is_none() { - None - } else { - Some( - unsafe { CStr::from_ptr(sprout_hash) } - .to_str() - .expect("hash should be a valid string"), - ) - }; + ); // Load params - let (spend_params, spend_vk, output_params, output_vk, sprout_vk) = load_parameters( - spend_path, - spend_hash, - output_path, - output_hash, - sprout_path, - sprout_hash, - ); + let (spend_params, spend_vk, output_params, output_vk, sprout_vk) = + load_parameters(spend_path, output_path, sprout_path); // Caller is responsible for calling this function once, so // these global mutations are safe. @@ -235,12 +166,12 @@ fn init_zksnark_params( /// `result` must be a valid pointer to 32 bytes which will be written. #[no_mangle] pub extern "C" fn librustzcash_tree_uncommitted(result: *mut [c_uchar; 32]) { - let tmp = Note::::uncommitted().into_repr(); + let tmp = Note::uncommitted().to_bytes(); // Should be okay, caller is responsible for ensuring the pointer // is a valid pointer to 32 bytes that can be mutated. let result = unsafe { &mut *result }; - tmp.write_le(&mut result[..]).expect("length is 32 bytes"); + *result = tmp; } /// Computes a merkle tree hash for a given depth. The `depth` parameter should @@ -258,21 +189,13 @@ pub extern "C" fn librustzcash_merkle_hash( result: *mut [c_uchar; 32], ) { // Should be okay, because caller is responsible for ensuring - // the pointer is a valid pointer to 32 bytes, and that is the - // size of the representation - let a_repr = read_fr(unsafe { &*a }); - - // Should be okay, because caller is responsible for ensuring - // the pointer is a valid pointer to 32 bytes, and that is the - // size of the representation - let b_repr = read_fr(unsafe { &*b }); - - let tmp = merkle_hash(depth, &a_repr, &b_repr); + // the pointers are valid pointers to 32 bytes. + let tmp = merkle_hash(depth, unsafe { &*a }, unsafe { &*b }); // Should be okay, caller is responsible for ensuring the pointer // is a valid pointer to 32 bytes that can be mutated. let result = unsafe { &mut *result }; - tmp.write_le(&mut result[..]).expect("length is 32 bytes"); + *result = tmp; } #[no_mangle] // ToScalar @@ -280,33 +203,31 @@ pub extern "C" fn librustzcash_to_scalar(input: *const [c_uchar; 64], result: *m // Should be okay, because caller is responsible for ensuring // the pointer is a valid pointer to 32 bytes, and that is the // size of the representation - let scalar = ::Fs::to_uniform(unsafe { &(&*input)[..] }).into_repr(); + let scalar = jubjub::Scalar::from_bytes_wide(unsafe { &*input }); let result = unsafe { &mut *result }; - scalar - .write_le(&mut result[..]) - .expect("length is 32 bytes"); + *result = scalar.to_bytes(); } #[no_mangle] pub extern "C" fn librustzcash_ask_to_ak(ask: *const [c_uchar; 32], result: *mut [c_uchar; 32]) { let ask = unsafe { &*ask }; - let ak = fixed_scalar_mult(ask, FixedGenerators::SpendingKeyGenerator); + let ak = fixed_scalar_mult(ask, &SPENDING_KEY_GENERATOR); let result = unsafe { &mut *result }; - ak.write(&mut result[..]).expect("length is 32 bytes"); + *result = ak.to_bytes(); } #[no_mangle] pub extern "C" fn librustzcash_nsk_to_nk(nsk: *const [c_uchar; 32], result: *mut [c_uchar; 32]) { let nsk = unsafe { &*nsk }; - let nk = fixed_scalar_mult(nsk, FixedGenerators::ProofGenerationKey); + let nk = fixed_scalar_mult(nsk, &PROOF_GENERATION_KEY_GENERATOR); let result = unsafe { &mut *result }; - nk.write(&mut result[..]).expect("length is 32 bytes"); + *result = nk.to_bytes(); } #[no_mangle] @@ -337,7 +258,7 @@ pub extern "C" fn librustzcash_crh_ivk( #[no_mangle] pub extern "C" fn librustzcash_check_diversifier(diversifier: *const [c_uchar; 11]) -> bool { let diversifier = Diversifier(unsafe { *diversifier }); - diversifier.g_d::(&JUBJUB).is_some() + diversifier.g_d().is_some() } #[no_mangle] @@ -346,14 +267,14 @@ pub extern "C" fn librustzcash_ivk_to_pkd( diversifier: *const [c_uchar; 11], result: *mut [c_uchar; 32], ) -> bool { - let ivk = read_fs(unsafe { &*ivk }); + let ivk = de_ct(jubjub::Scalar::from_bytes(unsafe { &*ivk })); let diversifier = Diversifier(unsafe { *diversifier }); - if let Some(g_d) = diversifier.g_d::(&JUBJUB) { - let pk_d = g_d.mul(ivk, &JUBJUB); + if let (Some(ivk), Some(g_d)) = (ivk, diversifier.g_d()) { + let pk_d = g_d * ivk; let result = unsafe { &mut *result }; - pk_d.write(&mut result[..]).expect("length is 32 bytes"); + *result = pk_d.to_bytes(); true } else { @@ -373,11 +294,8 @@ fn test_gen_r() { assert_ne!(r1, r2); // Verify r values are valid in the field - let mut repr = FsRepr::default(); - repr.read_le(&r1[..]).expect("length is not 32 bytes"); - let _ = Fs::from_repr(repr).unwrap(); - repr.read_le(&r2[..]).expect("length is not 32 bytes"); - let _ = Fs::from_repr(repr).unwrap(); + let _ = jubjub::Scalar::from_bytes(&r1).unwrap(); + let _ = jubjub::Scalar::from_bytes(&r2).unwrap(); } /// Generate uniformly random scalar in Jubjub. The result is of length 32. @@ -389,11 +307,9 @@ pub extern "C" fn librustzcash_sapling_generate_r(result: *mut [c_uchar; 32]) { rng.fill_bytes(&mut buffer); // reduce to uniform value - let r = ::Fs::to_uniform(&buffer[..]); + let r = jubjub::Scalar::from_bytes_wide(&buffer); let result = unsafe { &mut *result }; - r.into_repr() - .write_le(&mut result[..]) - .expect("result must be 32 bytes"); + *result = r.to_bytes(); } // Private utility function to get Note from C parameters @@ -401,24 +317,25 @@ fn priv_get_note( diversifier: *const [c_uchar; 11], pk_d: *const [c_uchar; 32], value: u64, - r: *const [c_uchar; 32], -) -> Result, ()> { + rcm: *const [c_uchar; 32], +) -> Result { let diversifier = Diversifier(unsafe { *diversifier }); - let g_d = diversifier.g_d::(&JUBJUB).ok_or(())?; + let g_d = diversifier.g_d().ok_or(())?; - let pk_d = edwards::Point::::read(&(unsafe { &*pk_d })[..], &JUBJUB) - .map_err(|_| ())?; + let pk_d = de_ct(jubjub::ExtendedPoint::from_bytes(unsafe { &*pk_d })).ok_or(())?; - let pk_d = pk_d.as_prime_order(&JUBJUB).ok_or(())?; + let pk_d = de_ct(pk_d.into_subgroup()).ok_or(())?; // Deserialize randomness - let r = Fs::from_repr(read_fs(unsafe { &*r })).map_err(|_| ())?; + // If this is after ZIP 212, the caller has calculated rcm, and we don't need to call + // Note::derive_esk, so we just pretend the note was using this rcm all along. + let rseed = Rseed::BeforeZip212(de_ct(jubjub::Scalar::from_bytes(unsafe { &*rcm })).ok_or(())?); let note = Note { value, g_d, pk_d, - r, + rseed, }; Ok(note) @@ -435,39 +352,39 @@ pub extern "C" fn librustzcash_sapling_compute_nf( diversifier: *const [c_uchar; 11], pk_d: *const [c_uchar; 32], value: u64, - r: *const [c_uchar; 32], + rcm: *const [c_uchar; 32], ak: *const [c_uchar; 32], nk: *const [c_uchar; 32], position: u64, result: *mut [c_uchar; 32], ) -> bool { - let note = match priv_get_note(diversifier, pk_d, value, r) { + let note = match priv_get_note(diversifier, pk_d, value, rcm) { Ok(p) => p, Err(_) => return false, }; - let ak = match edwards::Point::::read(&(unsafe { &*ak })[..], &JUBJUB) { - Ok(p) => p, - Err(_) => return false, + let ak = match de_ct(jubjub::ExtendedPoint::from_bytes(unsafe { &*ak })) { + Some(p) => p, + None => return false, }; - let ak = match ak.as_prime_order(&JUBJUB) { + let ak = match de_ct(ak.into_subgroup()) { Some(ak) => ak, None => return false, }; - let nk = match edwards::Point::::read(&(unsafe { &*nk })[..], &JUBJUB) { - Ok(p) => p, - Err(_) => return false, + let nk = match de_ct(jubjub::ExtendedPoint::from_bytes(unsafe { &*nk })) { + Some(p) => p, + None => return false, }; - let nk = match nk.as_prime_order(&JUBJUB) { + let nk = match de_ct(nk.into_subgroup()) { Some(nk) => nk, None => return false, }; let vk = ViewingKey { ak, nk }; - let nf = note.nf(&vk, position, &JUBJUB); + let nf = note.nf(&vk, position); let result = unsafe { &mut *result }; result.copy_from_slice(&nf); @@ -481,23 +398,20 @@ pub extern "C" fn librustzcash_sapling_compute_nf( /// The result is also of length 32 and placed in `result`. /// Returns false if `diversifier` or `pk_d` is not valid. #[no_mangle] -pub extern "C" fn librustzcash_sapling_compute_cm( +pub extern "C" fn librustzcash_sapling_compute_cmu( diversifier: *const [c_uchar; 11], pk_d: *const [c_uchar; 32], value: u64, - r: *const [c_uchar; 32], + rcm: *const [c_uchar; 32], result: *mut [c_uchar; 32], ) -> bool { - let note = match priv_get_note(diversifier, pk_d, value, r) { + let note = match priv_get_note(diversifier, pk_d, value, rcm) { Ok(p) => p, Err(_) => return false, }; let result = unsafe { &mut *result }; - note.cm(&JUBJUB) - .into_repr() - .write_le(&mut result[..]) - .expect("length is 32 bytes"); + *result = note.cmu().to_bytes(); true } @@ -513,15 +427,15 @@ pub extern "C" fn librustzcash_sapling_ka_agree( result: *mut [c_uchar; 32], ) -> bool { // Deserialize p - let p = match edwards::Point::::read(&(unsafe { &*p })[..], &JUBJUB) { - Ok(p) => p, - Err(_) => return false, + let p = match de_ct(jubjub::ExtendedPoint::from_bytes(unsafe { &*p })) { + Some(p) => p, + None => return false, }; // Deserialize sk - let sk = match Fs::from_repr(read_fs(unsafe { &*sk })) { - Ok(p) => p, - Err(_) => return false, + let sk = match de_ct(jubjub::Scalar::from_bytes(unsafe { &*sk })) { + Some(p) => p, + None => return false, }; // Compute key agreement @@ -529,7 +443,7 @@ pub extern "C" fn librustzcash_sapling_ka_agree( // Produce result let result = unsafe { &mut *result }; - ka.write(&mut result[..]).expect("length is not 32 bytes"); + *result = ka.to_bytes(); true } @@ -546,21 +460,21 @@ pub extern "C" fn librustzcash_sapling_ka_derivepublic( let diversifier = Diversifier(unsafe { *diversifier }); // Compute g_d from the diversifier - let g_d = match diversifier.g_d::(&JUBJUB) { + let g_d = match diversifier.g_d() { Some(g) => g, None => return false, }; // Deserialize esk - let esk = match Fs::from_repr(read_fs(unsafe { &*esk })) { - Ok(p) => p, - Err(_) => return false, + let esk = match de_ct(jubjub::Scalar::from_bytes(unsafe { &*esk })) { + Some(p) => p, + None => return false, }; - let p = g_d.mul(esk, &JUBJUB); + let p = g_d * esk; let result = unsafe { &mut *result }; - p.write(&mut result[..]).expect("length is not 32 bytes"); + *result = p.to_bytes(); true } @@ -584,7 +498,7 @@ pub extern "C" fn librustzcash_eh_isvalid( let rs_input = unsafe { slice::from_raw_parts(input, input_len) }; let rs_nonce = unsafe { slice::from_raw_parts(nonce, nonce_len) }; let rs_soln = unsafe { slice::from_raw_parts(soln, soln_len) }; - equihash::is_valid_solution(n, k, rs_input, rs_nonce, rs_soln) + equihash::is_valid_solution(n, k, rs_input, rs_nonce, rs_soln).is_ok() } /// Creates a Sapling verification context. Please free this when you're done. @@ -620,20 +534,20 @@ pub extern "C" fn librustzcash_sapling_check_spend( sighash_value: *const [c_uchar; 32], ) -> bool { // Deserialize the value commitment - let cv = match edwards::Point::::read(&(unsafe { &*cv })[..], &JUBJUB) { - Ok(p) => p, - Err(_) => return false, + let cv = match de_ct(jubjub::ExtendedPoint::from_bytes(unsafe { &*cv })) { + Some(p) => p, + None => return false, }; // Deserialize the anchor, which should be an element // of Fr. - let anchor = match Fr::from_repr(read_fr(unsafe { &*anchor })) { - Ok(a) => a, - Err(_) => return false, + let anchor = match de_ct(bls12_381::Scalar::from_bytes(unsafe { &*anchor })) { + Some(a) => a, + None => return false, }; // Deserialize rk - let rk = match redjubjub::PublicKey::::read(&(unsafe { &*rk })[..], &JUBJUB) { + let rk = match redjubjub::PublicKey::read(&(unsafe { &*rk })[..]) { Ok(p) => p, Err(_) => return false, }; @@ -645,7 +559,7 @@ pub extern "C" fn librustzcash_sapling_check_spend( }; // Deserialize the proof - let zkproof = match Proof::::read(&(unsafe { &*zkproof })[..]) { + let zkproof = match Proof::read(&(unsafe { &*zkproof })[..]) { Ok(p) => p, Err(_) => return false, }; @@ -659,7 +573,6 @@ pub extern "C" fn librustzcash_sapling_check_spend( spend_auth_sig, zkproof, unsafe { SAPLING_SPEND_VK.as_ref() }.unwrap(), - &JUBJUB, ) } @@ -674,26 +587,26 @@ pub extern "C" fn librustzcash_sapling_check_output( zkproof: *const [c_uchar; GROTH_PROOF_SIZE], ) -> bool { // Deserialize the value commitment - let cv = match edwards::Point::::read(&(unsafe { &*cv })[..], &JUBJUB) { - Ok(p) => p, - Err(_) => return false, + let cv = match de_ct(jubjub::ExtendedPoint::from_bytes(unsafe { &*cv })) { + Some(p) => p, + None => return false, }; // Deserialize the commitment, which should be an element // of Fr. - let cm = match Fr::from_repr(read_fr(unsafe { &*cm })) { - Ok(a) => a, - Err(_) => return false, + let cm = match de_ct(bls12_381::Scalar::from_bytes(unsafe { &*cm })) { + Some(a) => a, + None => return false, }; // Deserialize the ephemeral key - let epk = match edwards::Point::::read(&(unsafe { &*epk })[..], &JUBJUB) { - Ok(p) => p, - Err(_) => return false, + let epk = match de_ct(jubjub::ExtendedPoint::from_bytes(unsafe { &*epk })) { + Some(p) => p, + None => return false, }; // Deserialize the proof - let zkproof = match Proof::::read(&(unsafe { &*zkproof })[..]) { + let zkproof = match Proof::read(&(unsafe { &*zkproof })[..]) { Ok(p) => p, Err(_) => return false, }; @@ -704,7 +617,6 @@ pub extern "C" fn librustzcash_sapling_check_output( epk, zkproof, unsafe { SAPLING_OUTPUT_VK.as_ref() }.unwrap(), - &JUBJUB, ) } @@ -728,12 +640,7 @@ pub extern "C" fn librustzcash_sapling_final_check( Err(_) => return false, }; - unsafe { &*ctx }.final_check( - value_balance, - unsafe { &*sighash_value }, - binding_sig, - &JUBJUB, - ) + unsafe { &*ctx }.final_check(value_balance, unsafe { &*sighash_value }, binding_sig) } /// Sprout JoinSplit proof generation. @@ -783,7 +690,7 @@ pub extern "C" fn librustzcash_sprout_prove( let mut sprout_fs = BufReader::with_capacity(1024 * 1024, sprout_fs); - let params = Parameters::::read(&mut sprout_fs, false) + let params = Parameters::read(&mut sprout_fs, false) .expect("couldn't deserialize Sprout JoinSplit parameters file"); drop(sprout_fs); @@ -862,22 +769,21 @@ pub extern "C" fn librustzcash_sapling_output_proof( zkproof: *mut [c_uchar; GROTH_PROOF_SIZE], ) -> bool { // Grab `esk`, which the caller should have constructed for the DH key exchange. - let esk = match Fs::from_repr(read_fs(unsafe { &*esk })) { - Ok(p) => p, - Err(_) => return false, + let esk = match de_ct(jubjub::Scalar::from_bytes(unsafe { &*esk })) { + Some(p) => p, + None => return false, }; // Grab the payment address from the caller - let payment_address = - match PaymentAddress::::from_bytes(unsafe { &*payment_address }, &JUBJUB) { - Some(pa) => pa, - None => return false, - }; + let payment_address = match PaymentAddress::from_bytes(unsafe { &*payment_address }) { + Some(pa) => pa, + None => return false, + }; // The caller provides the commitment randomness for the output note - let rcm = match Fs::from_repr(read_fs(unsafe { &*rcm })) { - Ok(p) => p, - Err(_) => return false, + let rcm = match de_ct(jubjub::Scalar::from_bytes(unsafe { &*rcm })) { + Some(p) => p, + None => return false, }; // Create proof @@ -887,7 +793,6 @@ pub extern "C" fn librustzcash_sapling_output_proof( rcm, value, unsafe { SAPLING_OUTPUT_PARAMS.as_ref() }.unwrap(), - &JUBJUB, ); // Write the proof out to the caller @@ -896,9 +801,7 @@ pub extern "C" fn librustzcash_sapling_output_proof( .expect("should be able to serialize a proof"); // Write the value commitment to the caller - value_commitment - .write(&mut (unsafe { &mut *cv })[..]) - .expect("should be able to serialize rcv"); + *unsafe { &mut *cv } = value_commitment.to_bytes(); true } @@ -916,13 +819,13 @@ pub extern "C" fn librustzcash_sapling_spend_sig( result: *mut [c_uchar; 64], ) -> bool { // The caller provides the re-randomization of `ak`. - let ar = match Fs::from_repr(read_fs(unsafe { &*ar })) { - Ok(p) => p, - Err(_) => return false, + let ar = match de_ct(jubjub::Scalar::from_bytes(unsafe { &*ar })) { + Some(p) => p, + None => return false, }; // The caller provides `ask`, the spend authorizing key. - let ask = match redjubjub::PrivateKey::::read(&(unsafe { &*ask })[..]) { + let ask = match redjubjub::PrivateKey::read(&(unsafe { &*ask })[..]) { Ok(p) => p, Err(_) => return false, }; @@ -931,7 +834,7 @@ pub extern "C" fn librustzcash_sapling_spend_sig( let mut rng = OsRng; // Do the signing - let sig = spend_sig(ask, ar, unsafe { &*sighash }, &mut rng, &JUBJUB); + let sig = spend_sig(ask, ar, unsafe { &*sighash }, &mut rng); // Write out the signature sig.write(&mut (unsafe { &mut *result })[..]) @@ -957,7 +860,7 @@ pub extern "C" fn librustzcash_sapling_binding_sig( }; // Sign - let sig = match unsafe { &*ctx }.binding_sig(value_balance, unsafe { &*sighash }, &JUBJUB) { + let sig = match unsafe { &*ctx }.binding_sig(value_balance, unsafe { &*sighash }) { Ok(s) => s, Err(_) => return false, }; @@ -988,21 +891,21 @@ pub extern "C" fn librustzcash_sapling_spend_proof( zkproof: *mut [c_uchar; GROTH_PROOF_SIZE], ) -> bool { // Grab `ak` from the caller, which should be a point. - let ak = match edwards::Point::::read(&(unsafe { &*ak })[..], &JUBJUB) { - Ok(p) => p, - Err(_) => return false, + let ak = match de_ct(jubjub::ExtendedPoint::from_bytes(unsafe { &*ak })) { + Some(p) => p, + None => return false, }; // `ak` should be prime order. - let ak = match ak.as_prime_order(&JUBJUB) { + let ak = match de_ct(ak.into_subgroup()) { Some(p) => p, None => return false, }; // Grab `nsk` from the caller - let nsk = match Fs::from_repr(read_fs(unsafe { &*nsk })) { - Ok(p) => p, - Err(_) => return false, + let nsk = match de_ct(jubjub::Scalar::from_bytes(unsafe { &*nsk })) { + Some(p) => p, + None => return false, }; // Construct the proof generation key @@ -1015,21 +918,23 @@ pub extern "C" fn librustzcash_sapling_spend_proof( let diversifier = Diversifier(unsafe { *diversifier }); // The caller chooses the note randomness - let rcm = match Fs::from_repr(read_fs(unsafe { &*rcm })) { - Ok(p) => p, - Err(_) => return false, + // If this is after ZIP 212, the caller has calculated rcm, and we don't need to call + // Note::derive_esk, so we just pretend the note was using this rcm all along. + let rseed = match de_ct(jubjub::Scalar::from_bytes(unsafe { &*rcm })) { + Some(p) => Rseed::BeforeZip212(p), + None => return false, }; // The caller also chooses the re-randomization of ak - let ar = match Fs::from_repr(read_fs(unsafe { &*ar })) { - Ok(p) => p, - Err(_) => return false, + let ar = match de_ct(jubjub::Scalar::from_bytes(unsafe { &*ar })) { + Some(p) => p, + None => return false, }; // We need to compute the anchor of the Spend. - let anchor = match Fr::from_repr(read_fr(unsafe { &*anchor })) { - Ok(p) => p, - Err(_) => return false, + let anchor = match de_ct(bls12_381::Scalar::from_bytes(unsafe { &*anchor })) { + Some(p) => p, + None => return false, }; // Parse the Merkle path from the caller @@ -1043,21 +948,18 @@ pub extern "C" fn librustzcash_sapling_spend_proof( .spend_proof( proof_generation_key, diversifier, - rcm, + rseed, ar, value, anchor, merkle_path, unsafe { SAPLING_SPEND_PARAMS.as_ref() }.unwrap(), unsafe { SAPLING_SPEND_VK.as_ref() }.unwrap(), - &JUBJUB, ) .expect("proving should not fail"); // Write value commitment to caller - value_commitment - .write(&mut unsafe { &mut *cv }[..]) - .expect("should be able to serialize cv"); + *unsafe { &mut *cv } = value_commitment.to_bytes(); // Write proof out to caller proof diff --git a/depend/zcash/src/rust/src/tests/key_agreement.rs b/depend/zcash/src/rust/src/tests/key_agreement.rs index c4f56a139..1f7b5a503 100644 --- a/depend/zcash/src/rust/src/tests/key_agreement.rs +++ b/depend/zcash/src/rust/src/tests/key_agreement.rs @@ -1,7 +1,5 @@ -use ff::{PrimeField, PrimeFieldRepr}; -use pairing::bls12_381::Bls12; +use group::{Group, GroupEncoding}; use rand_core::{OsRng, RngCore}; -use zcash_primitives::jubjub::{edwards, JubjubBls12}; use zcash_primitives::primitives::{Diversifier, ViewingKey}; use crate::{ @@ -11,20 +9,19 @@ use crate::{ #[test] fn test_key_agreement() { - let params = JubjubBls12::new(); let mut rng = OsRng; // Create random viewing key - let vk = ViewingKey:: { - ak: edwards::Point::rand(&mut rng, ¶ms).mul_by_cofactor(¶ms), - nk: edwards::Point::rand(&mut rng, ¶ms).mul_by_cofactor(¶ms), + let vk = ViewingKey { + ak: jubjub::SubgroupPoint::random(&mut rng), + nk: jubjub::SubgroupPoint::random(&mut rng), }; // Create a random address with the viewing key let addr = loop { let mut d = [0; 11]; rng.fill_bytes(&mut d); - match vk.to_payment_address(Diversifier(d), ¶ms) { + match vk.to_payment_address(Diversifier(d)) { Some(a) => break a, None => {} } @@ -32,8 +29,7 @@ fn test_key_agreement() { // Grab ivk from our viewing key in serialized form let ivk = vk.ivk(); - let mut ivk_serialized = [0u8; 32]; - ivk.into_repr().write_le(&mut ivk_serialized[..]).unwrap(); + let ivk_serialized = ivk.to_bytes(); // Create random esk let mut esk = [0u8; 32]; @@ -45,8 +41,7 @@ fn test_key_agreement() { let mut shared_secret_sender = [0u8; 32]; // Serialize pk_d for the call to librustzcash_sapling_ka_agree - let mut addr_pk_d = [0u8; 32]; - addr.pk_d().write(&mut addr_pk_d[..]).unwrap(); + let addr_pk_d = addr.pk_d().to_bytes(); assert!(librustzcash_sapling_ka_agree( &addr_pk_d, diff --git a/depend/zcash/src/rust/src/tests/key_components.rs b/depend/zcash/src/rust/src/tests/key_components.rs index 5975e5eb1..7a2147340 100644 --- a/depend/zcash/src/rust/src/tests/key_components.rs +++ b/depend/zcash/src/rust/src/tests/key_components.rs @@ -1,12 +1,9 @@ -use ff::{PrimeField, PrimeFieldRepr}; -use pairing::bls12_381::Bls12; +use group::GroupEncoding; use zcash_primitives::{ - jubjub::{fs::FsRepr, FixedGenerators, JubjubEngine, JubjubParams}, - primitives::{Diversifier, ProofGenerationKey}, + constants::SPENDING_KEY_GENERATOR, + primitives::{Diversifier, ProofGenerationKey, Rseed}, }; -use super::JUBJUB; - use crate::{ librustzcash_ask_to_ak, librustzcash_check_diversifier, librustzcash_crh_ivk, librustzcash_ivk_to_pkd, librustzcash_nsk_to_nk, @@ -657,20 +654,11 @@ fn key_components() { ]; for tv in test_vectors { - let mut ask_repr = FsRepr::default(); - let mut nsk_repr = FsRepr::default(); - ask_repr.read_le(&tv.ask[..]).unwrap(); - nsk_repr.read_le(&tv.nsk[..]).unwrap(); - let nsk = ::Fs::from_repr(nsk_repr).unwrap(); + let ask = jubjub::Scalar::from_bytes(&tv.ask).unwrap(); + let nsk = jubjub::Scalar::from_bytes(&tv.nsk).unwrap(); - let ak = JUBJUB - .generator(FixedGenerators::SpendingKeyGenerator) - .mul(ask_repr.clone(), &JUBJUB); - { - let mut vec = Vec::new(); - ak.write(&mut vec).unwrap(); - assert_eq!(&vec, &tv.ak); - } + let ak = SPENDING_KEY_GENERATOR * ask; + assert_eq!(&ak.to_bytes(), &tv.ak); { let mut ak = [0u8; 32]; librustzcash_ask_to_ak(&tv.ask, &mut ak); @@ -678,23 +666,15 @@ fn key_components() { } let pgk = ProofGenerationKey { ak, nsk }; - let fvk = pgk.to_viewing_key(&JUBJUB); - { - let mut vec = Vec::new(); - fvk.nk.write(&mut vec).unwrap(); - assert_eq!(&vec, &tv.nk); - } + let fvk = pgk.to_viewing_key(); + assert_eq!(&fvk.nk.to_bytes(), &tv.nk); { let mut nk = [0u8; 32]; librustzcash_nsk_to_nk(&tv.nsk, &mut nk); assert_eq!(&nk, &tv.nk); } - { - let mut vec = Vec::new(); - fvk.ivk().into_repr().write_le(&mut vec).unwrap(); - assert_eq!(&vec, &tv.ivk); - } + assert_eq!(&fvk.ivk().to_bytes(), &tv.ivk); { let mut ivk = [0u8; 32]; librustzcash_crh_ivk(&tv.ak, &tv.nk, &mut ivk); @@ -704,28 +684,20 @@ fn key_components() { let diversifier = Diversifier(tv.default_d); assert!(librustzcash_check_diversifier(&tv.default_d)); - let addr = fvk.to_payment_address(diversifier, &JUBJUB).unwrap(); - { - let mut vec = Vec::new(); - addr.pk_d().write(&mut vec).unwrap(); - assert_eq!(&vec, &tv.default_pk_d); - } + let addr = fvk.to_payment_address(diversifier).unwrap(); + assert_eq!(&addr.pk_d().to_bytes(), &tv.default_pk_d); { let mut default_pk_d = [0u8; 32]; librustzcash_ivk_to_pkd(&tv.ivk, &tv.default_d, &mut default_pk_d); assert_eq!(&default_pk_d, &tv.default_pk_d); } - let mut note_r_repr = FsRepr::default(); - note_r_repr.read_le(&tv.note_r[..]).unwrap(); - let note_r = ::Fs::from_repr(note_r_repr).unwrap(); - let note = addr.create_note(tv.note_v, note_r, &JUBJUB).unwrap(); - { - let mut vec = Vec::new(); - note.cm(&JUBJUB).into_repr().write_le(&mut vec).unwrap(); - assert_eq!(&vec, &tv.note_cm); - } + let note_r = jubjub::Scalar::from_bytes(&tv.note_r).unwrap(); + let note = addr + .create_note(tv.note_v, Rseed::BeforeZip212(note_r)) + .unwrap(); + assert_eq!(¬e.cmu().to_bytes(), &tv.note_cm); - assert_eq!(note.nf(&fvk, tv.note_pos, &JUBJUB), tv.note_nf); + assert_eq!(note.nf(&fvk, tv.note_pos), tv.note_nf); } } diff --git a/depend/zcash/src/rust/src/tests/mod.rs b/depend/zcash/src/rust/src/tests/mod.rs index bbaee0abb..cca0983dc 100644 --- a/depend/zcash/src/rust/src/tests/mod.rs +++ b/depend/zcash/src/rust/src/tests/mod.rs @@ -1,6 +1,9 @@ -use zcash_primitives::jubjub::{FixedGenerators, JubjubParams}; - -use super::JUBJUB; +use group::GroupEncoding; +use zcash_primitives::constants::{ + NOTE_COMMITMENT_RANDOMNESS_GENERATOR, NULLIFIER_POSITION_GENERATOR, + PROOF_GENERATION_KEY_GENERATOR, SPENDING_KEY_GENERATOR, VALUE_COMMITMENT_RANDOMNESS_GENERATOR, + VALUE_COMMITMENT_VALUE_GENERATOR, +}; mod key_agreement; mod key_components; @@ -53,45 +56,25 @@ fn sapling_generators() { ], }; - { - let mut vec = Vec::new(); - let p = JUBJUB.generator(FixedGenerators::SpendingKeyGenerator); - p.write(&mut vec).unwrap(); - assert_eq!(&vec, &sapling_generators.skb); - } - - { - let mut vec = Vec::new(); - let p = JUBJUB.generator(FixedGenerators::ProofGenerationKey); - p.write(&mut vec).unwrap(); - assert_eq!(&vec, &sapling_generators.pkb); - } - - { - let mut vec = Vec::new(); - let p = JUBJUB.generator(FixedGenerators::NullifierPosition); - p.write(&mut vec).unwrap(); - assert_eq!(&vec, &sapling_generators.npb); - } - - { - let mut vec = Vec::new(); - let p = JUBJUB.generator(FixedGenerators::NoteCommitmentRandomness); - p.write(&mut vec).unwrap(); - assert_eq!(&vec, &sapling_generators.wprb); - } - - { - let mut vec = Vec::new(); - let p = JUBJUB.generator(FixedGenerators::ValueCommitmentValue); - p.write(&mut vec).unwrap(); - assert_eq!(&vec, &sapling_generators.vcvb); - } - - { - let mut vec = Vec::new(); - let p = JUBJUB.generator(FixedGenerators::ValueCommitmentRandomness); - p.write(&mut vec).unwrap(); - assert_eq!(&vec, &sapling_generators.vcrb); - } + assert_eq!(&SPENDING_KEY_GENERATOR.to_bytes(), &sapling_generators.skb); + assert_eq!( + &PROOF_GENERATION_KEY_GENERATOR.to_bytes(), + &sapling_generators.pkb + ); + assert_eq!( + &NULLIFIER_POSITION_GENERATOR.to_bytes(), + &sapling_generators.npb + ); + assert_eq!( + &NOTE_COMMITMENT_RANDOMNESS_GENERATOR.to_bytes(), + &sapling_generators.wprb + ); + assert_eq!( + &VALUE_COMMITMENT_VALUE_GENERATOR.to_bytes(), + &sapling_generators.vcvb + ); + assert_eq!( + &VALUE_COMMITMENT_RANDOMNESS_GENERATOR.to_bytes(), + &sapling_generators.vcrb + ); } diff --git a/depend/zcash/src/rust/src/tests/notes.rs b/depend/zcash/src/rust/src/tests/notes.rs index 6b48b5ff8..55da486c0 100644 --- a/depend/zcash/src/rust/src/tests/notes.rs +++ b/depend/zcash/src/rust/src/tests/notes.rs @@ -1,4 +1,4 @@ -use crate::librustzcash_sapling_compute_cm; +use crate::librustzcash_sapling_compute_cmu; use crate::librustzcash_sapling_compute_nf; #[test] @@ -648,7 +648,7 @@ fn notes() { for tv in test_vectors { // Compute commitment and compare with test vector let mut result = [0u8; 32]; - assert!(librustzcash_sapling_compute_cm( + assert!(librustzcash_sapling_compute_cmu( &tv.default_d, &tv.default_pk_d, tv.note_v, diff --git a/depend/zcash/src/rust/src/tests/signatures.rs b/depend/zcash/src/rust/src/tests/signatures.rs index 68ac7997c..6002cbfd6 100644 --- a/depend/zcash/src/rust/src/tests/signatures.rs +++ b/depend/zcash/src/rust/src/tests/signatures.rs @@ -1,9 +1,7 @@ -use ff::{PrimeField, PrimeFieldRepr}; -use pairing::bls12_381::Bls12; -use zcash_primitives::jubjub::{FixedGenerators, JubjubEngine}; -use zcash_primitives::redjubjub::{PrivateKey, PublicKey, Signature}; - -use super::JUBJUB; +use zcash_primitives::{ + constants::SPENDING_KEY_GENERATOR, + redjubjub::{PrivateKey, PublicKey, Signature}, +}; #[test] fn redjubjub_signatures() { @@ -483,15 +481,13 @@ fn redjubjub_signatures() { ]; for tv in test_vectors { - let sk = PrivateKey::::read(&tv.sk[..]).unwrap(); - let vk = PublicKey::::read(&tv.vk[..], &JUBJUB).unwrap(); - let rvk = PublicKey::::read(&tv.rvk[..], &JUBJUB).unwrap(); + let sk = PrivateKey::read(&tv.sk[..]).unwrap(); + let vk = PublicKey::read(&tv.vk[..]).unwrap(); + let rvk = PublicKey::read(&tv.rvk[..]).unwrap(); let sig = Signature::read(&tv.sig[..]).unwrap(); let rsig = Signature::read(&tv.rsig[..]).unwrap(); - let mut alpha_repr = <::Fs as PrimeField>::Repr::default(); - alpha_repr.read_le(&tv.alpha[..]).unwrap(); - let alpha = ::Fs::from_repr(alpha_repr).unwrap(); + let alpha = jubjub::Scalar::from_bytes(&tv.alpha).unwrap(); { let mut vec = Vec::new(); @@ -500,15 +496,15 @@ fn redjubjub_signatures() { } { let mut vec = Vec::new(); - vk.randomize(alpha, FixedGenerators::SpendingKeyGenerator, &JUBJUB) + vk.randomize(alpha, SPENDING_KEY_GENERATOR) .write(&mut vec) .unwrap(); assert_eq!(&vec, &tv.rvk); } - assert!(vk.verify(&tv.m, &sig, FixedGenerators::SpendingKeyGenerator, &JUBJUB)); - assert!(rvk.verify(&tv.m, &rsig, FixedGenerators::SpendingKeyGenerator, &JUBJUB)); - assert!(!vk.verify(&tv.m, &rsig, FixedGenerators::SpendingKeyGenerator, &JUBJUB)); - assert!(!rvk.verify(&tv.m, &sig, FixedGenerators::SpendingKeyGenerator, &JUBJUB)); + assert!(vk.verify(&tv.m, &sig, SPENDING_KEY_GENERATOR)); + assert!(rvk.verify(&tv.m, &rsig, SPENDING_KEY_GENERATOR)); + assert!(!vk.verify(&tv.m, &rsig, SPENDING_KEY_GENERATOR)); + assert!(!rvk.verify(&tv.m, &sig, SPENDING_KEY_GENERATOR)); } } diff --git a/depend/zcash/src/rust/src/tracing_ffi.rs b/depend/zcash/src/rust/src/tracing_ffi.rs new file mode 100644 index 000000000..f3db6c30d --- /dev/null +++ b/depend/zcash/src/rust/src/tracing_ffi.rs @@ -0,0 +1,644 @@ +use libc::c_char; +use std::ffi::CStr; +use std::path::Path; +use std::slice; +use std::str; +use std::sync::atomic::{AtomicUsize, Ordering}; +use tracing::{ + callsite::{Callsite, Identifier}, + field::{FieldSet, Value}, + level_enabled, + metadata::Kind, + span::Entered, + subscriber::{Interest, Subscriber}, + Event, Metadata, Span, +}; +use tracing_appender::non_blocking::WorkerGuard; +use tracing_core::Once; +use tracing_subscriber::{ + filter::EnvFilter, + layer::{Layer, SubscriberExt}, + reload::{self, Handle}, + util::SubscriberInitExt, +}; + +#[cfg(not(target_os = "windows"))] +use std::ffi::OsStr; +#[cfg(not(target_os = "windows"))] +use std::os::unix::ffi::OsStrExt; + +#[cfg(target_os = "windows")] +use std::ffi::OsString; +#[cfg(target_os = "windows")] +use std::os::windows::ffi::OsStringExt; + +trait ReloadHandle { + fn reload(&self, new_filter: EnvFilter) -> Result<(), reload::Error>; +} + +impl ReloadHandle for Handle +where + L: From + Layer + 'static, + S: Subscriber, +{ + fn reload(&self, new_filter: EnvFilter) -> Result<(), reload::Error> { + self.reload(new_filter) + } +} + +pub struct TracingHandle { + _file_guard: Option, + reload_handle: Box, +} + +#[no_mangle] +pub extern "C" fn tracing_init( + #[cfg(not(target_os = "windows"))] log_path: *const u8, + #[cfg(target_os = "windows")] log_path: *const u16, + log_path_len: usize, + initial_filter: *const c_char, + log_timestamps: bool, +) -> *mut TracingHandle { + let initial_filter = unsafe { CStr::from_ptr(initial_filter) } + .to_str() + .expect("initial filter should be a valid string"); + + let log_path = if log_path.is_null() { + None + } else { + Some(unsafe { slice::from_raw_parts(log_path, log_path_len) }) + }; + + #[cfg(not(target_os = "windows"))] + let log_path = log_path.map(OsStr::from_bytes); + + #[cfg(target_os = "windows")] + let log_path = log_path.map(OsString::from_wide); + + tracing_init_inner( + log_path.as_ref().map(Path::new), + initial_filter, + log_timestamps, + ) +} + +fn tracing_init_inner( + log_path: Option<&Path>, + initial_filter: &str, + log_timestamps: bool, +) -> *mut TracingHandle { + let (file_logger, file_guard) = if let Some(log_path) = log_path { + let file_appender = tracing_appender::rolling::never( + log_path.parent().unwrap(), + log_path.file_name().unwrap(), + ); + let (non_blocking, file_guard) = tracing_appender::non_blocking(file_appender); + + ( + Some( + tracing_subscriber::fmt::layer() + .with_ansi(false) + .with_writer(non_blocking), + ), + Some(file_guard), + ) + } else { + (None, None) + }; + let stdout_logger = tracing_subscriber::fmt::layer().with_ansi(true); + let filter = EnvFilter::from(initial_filter); + + let reload_handle = match (file_logger, log_timestamps) { + (None, true) => { + let (filter, reload_handle) = reload::Layer::new(filter); + + tracing_subscriber::registry() + .with(stdout_logger) + .with(filter) + .init(); + + Box::new(reload_handle) as Box + } + (None, false) => { + let (filter, reload_handle) = reload::Layer::new(filter); + + tracing_subscriber::registry() + .with(stdout_logger.without_time()) + .with(filter) + .init(); + + Box::new(reload_handle) as Box + } + (Some(file_logger), true) => { + let (filter, reload_handle) = reload::Layer::new(filter); + + tracing_subscriber::registry() + .with(file_logger) + .with(filter) + .init(); + + Box::new(reload_handle) as Box + } + (Some(file_logger), false) => { + let (filter, reload_handle) = reload::Layer::new(filter); + + tracing_subscriber::registry() + .with(file_logger.without_time()) + .with(filter) + .init(); + + Box::new(reload_handle) as Box + } + }; + + Box::into_raw(Box::new(TracingHandle { + _file_guard: file_guard, + reload_handle, + })) +} + +#[no_mangle] +pub extern "C" fn tracing_free(handle: *mut TracingHandle) { + drop(unsafe { Box::from_raw(handle) }); +} + +#[no_mangle] +pub extern "C" fn tracing_reload(handle: *mut TracingHandle, new_filter: *const c_char) -> bool { + let handle = unsafe { &mut *handle }; + + match unsafe { CStr::from_ptr(new_filter) } + .to_str() + .map(EnvFilter::new) + { + Err(e) => { + tracing::error!("New filter is not valid UTF-8: {}", e); + false + } + Ok(new_filter) => { + if let Err(e) = handle.reload_handle.reload(new_filter) { + tracing::error!("Filter reload failed: {}", e); + false + } else { + true + } + } + } +} + +pub struct FfiCallsite { + interest: AtomicUsize, + meta: Option>, + registration: Once, + fields: Vec<&'static str>, +} + +impl FfiCallsite { + fn new(fields: Vec<&'static str>) -> Self { + FfiCallsite { + interest: AtomicUsize::new(0), + meta: None, + registration: Once::new(), + fields, + } + } + + #[inline(always)] + fn is_enabled(&self) -> bool { + let interest = self.interest(); + if interest.is_always() { + return true; + } + if interest.is_never() { + return false; + } + + tracing::dispatcher::get_default(|current| current.enabled(self.metadata())) + } + + #[inline(always)] + pub fn register(&'static self) { + self.registration + .call_once(|| tracing::callsite::register(self)); + } + + #[inline(always)] + fn interest(&self) -> Interest { + match self.interest.load(Ordering::Relaxed) { + 0 => Interest::never(), + 2 => Interest::always(), + _ => Interest::sometimes(), + } + } +} + +impl Callsite for FfiCallsite { + fn set_interest(&self, interest: Interest) { + let interest = match () { + _ if interest.is_never() => 0, + _ if interest.is_always() => 2, + _ => 1, + }; + self.interest.store(interest, Ordering::SeqCst); + } + + #[inline(always)] + fn metadata(&self) -> &Metadata<'static> { + self.meta.as_ref().unwrap() + } +} + +#[no_mangle] +pub extern "C" fn tracing_callsite( + name: *const c_char, + target: *const c_char, + level: *const c_char, + file: *const c_char, + line: u32, + fields: *const *const c_char, + fields_len: usize, + is_span: bool, +) -> *mut FfiCallsite { + let name = unsafe { CStr::from_ptr(name) }.to_str().unwrap(); + let target = unsafe { CStr::from_ptr(target) }.to_str().unwrap(); + let level = unsafe { CStr::from_ptr(level) }.to_str().unwrap(); + let file = unsafe { CStr::from_ptr(file) }.to_str().unwrap(); + + let fields = unsafe { slice::from_raw_parts(fields, fields_len) }; + let fields = fields + .iter() + .map(|&p| unsafe { CStr::from_ptr(p) }) + .map(|cs| cs.to_str()) + .collect::, _>>() + .unwrap(); + + let level = level.parse().unwrap(); + + // We immediately convert the new callsite into a pointer to erase lifetime + // information. The caller MUST ensure that the callsite is stored statically. + let site = Box::into_raw(Box::new(FfiCallsite::new(fields))); + let site_ref = unsafe { &*site }; + + let meta: Metadata<'static> = Metadata::new( + name, + target, + level, + Some(file), + Some(line), + None, + FieldSet::new(&site_ref.fields, Identifier(site_ref)), + if is_span { Kind::SPAN } else { Kind::EVENT }, + ); + unsafe { &mut *site }.meta = Some(meta); + + site_ref.register(); + site +} + +macro_rules! repeat { + (0, $val:expr) => { + [] + }; + (1, $val:expr) => { + [$val] + }; + (2, $val:expr) => { + [$val, $val] + }; + (3, $val:expr) => { + [$val, $val, $val] + }; + (4, $val:expr) => { + [$val, $val, $val, $val] + }; + (5, $val:expr) => { + [$val, $val, $val, $val, $val] + }; + (6, $val:expr) => { + [$val, $val, $val, $val, $val, $val] + }; + (7, $val:expr) => { + [$val, $val, $val, $val, $val, $val, $val] + }; + (8, $val:expr) => { + [$val, $val, $val, $val, $val, $val, $val, $val] + }; + (9, $val:expr) => { + [$val, $val, $val, $val, $val, $val, $val, $val, $val] + }; + (10, $val:expr) => { + [$val, $val, $val, $val, $val, $val, $val, $val, $val, $val] + }; + (11, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + ] + }; + (12, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + ] + }; + (13, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + ] + }; + (14, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + ] + }; + (15, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, + ] + }; + (16, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, + ] + }; + (17, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, + ] + }; + (18, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, + ] + }; + (19, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, + ] + }; + (20, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, + ] + }; + (21, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, $val, + ] + }; + (22, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, $val, $val, + ] + }; + (23, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, $val, $val, $val, + ] + }; + (24, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + ] + }; + (25, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + ] + }; + (26, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + ] + }; + (27, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + ] + }; + (28, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + ] + }; + (29, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, + ] + }; + (30, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, + ] + }; + (31, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, + ] + }; + (32, $val:expr) => { + [ + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, $val, + $val, $val, $val, $val, + ] + }; +} + +#[no_mangle] +pub extern "C" fn tracing_span_create( + callsite: *const FfiCallsite, + field_values: *const *const c_char, + fields_len: usize, +) -> *mut Span { + let callsite = unsafe { &*callsite }; + let field_values = unsafe { slice::from_raw_parts(field_values, fields_len) }; + + let meta = callsite.metadata(); + assert!(meta.is_span()); + + let span = if level_enabled!(*meta.level()) && callsite.is_enabled() { + let mut fi = meta.fields().iter(); + let mut vi = field_values + .iter() + .map(|&p| unsafe { CStr::from_ptr(p) }) + .map(|cs| cs.to_string_lossy()); + + use tracing::field::display; + macro_rules! new_span { + ($n:tt) => { + Span::new( + meta, + &meta.fields().value_set(&repeat!( + $n, + ( + &fi.next().unwrap(), + Some(&display(vi.next().unwrap().as_ref()) as &dyn Value) + ) + )), + ) + }; + } + + // https://github.com/tokio-rs/tracing/issues/782 might help improve things here. + match field_values.len() { + 0 => new_span!(0), + 1 => new_span!(1), + 2 => new_span!(2), + 3 => new_span!(3), + 4 => new_span!(4), + 5 => new_span!(5), + 6 => new_span!(6), + 7 => new_span!(7), + 8 => new_span!(8), + 9 => new_span!(9), + 10 => new_span!(10), + 11 => new_span!(11), + 12 => new_span!(12), + 13 => new_span!(13), + 14 => new_span!(14), + 15 => new_span!(15), + 16 => new_span!(16), + 17 => new_span!(17), + 18 => new_span!(18), + 19 => new_span!(19), + 20 => new_span!(20), + 21 => new_span!(21), + 22 => new_span!(22), + 23 => new_span!(23), + 24 => new_span!(24), + 25 => new_span!(25), + 26 => new_span!(26), + 27 => new_span!(27), + 28 => new_span!(28), + 29 => new_span!(29), + 30 => new_span!(30), + 31 => new_span!(31), + 32 => new_span!(32), + _ => unimplemented!(), + } + } else { + Span::none() + }; + + Box::into_raw(Box::new(span)) +} + +#[no_mangle] +pub extern "C" fn tracing_span_clone(span: *const Span) -> *mut Span { + unsafe { span.as_ref() } + .map(|span| Box::into_raw(Box::new(span.clone()))) + .unwrap_or(std::ptr::null_mut()) +} + +#[no_mangle] +pub extern "C" fn tracing_span_free(span: *mut Span) { + if !span.is_null() { + drop(unsafe { Box::from_raw(span) }); + } +} + +#[no_mangle] +pub extern "C" fn tracing_span_enter(span: *const Span) -> *mut Entered<'static> { + unsafe { span.as_ref() } + .map(|span| Box::into_raw(Box::new(span.enter()))) + .unwrap_or(std::ptr::null_mut()) +} + +#[no_mangle] +pub extern "C" fn tracing_span_exit(guard: *mut Entered) { + if !guard.is_null() { + drop(unsafe { Box::from_raw(guard) }); + } +} + +#[no_mangle] +pub extern "C" fn tracing_log( + callsite: *const FfiCallsite, + field_values: *const *const c_char, + fields_len: usize, +) { + let callsite = unsafe { &*callsite }; + let field_values = unsafe { slice::from_raw_parts(field_values, fields_len) }; + + let meta = callsite.metadata(); + assert!(meta.is_event()); + + if level_enabled!(*meta.level()) && callsite.is_enabled() { + let mut fi = meta.fields().iter(); + let mut vi = field_values + .iter() + .map(|&p| unsafe { CStr::from_ptr(p) }) + .map(|cs| cs.to_string_lossy()); + + use tracing::field::display; + macro_rules! dispatch { + ($n:tt) => { + Event::dispatch( + meta, + &meta.fields().value_set(&repeat!( + $n, + ( + &fi.next().unwrap(), + Some(&display(vi.next().unwrap().as_ref()) as &dyn Value) + ) + )), + ) + }; + } + + // https://github.com/tokio-rs/tracing/issues/782 might help improve things here. + match field_values.len() { + 1 => dispatch!(1), + 2 => dispatch!(2), + 3 => dispatch!(3), + 4 => dispatch!(4), + 5 => dispatch!(5), + 6 => dispatch!(6), + 7 => dispatch!(7), + 8 => dispatch!(8), + 9 => dispatch!(9), + 10 => dispatch!(10), + 11 => dispatch!(11), + 12 => dispatch!(12), + 13 => dispatch!(13), + 14 => dispatch!(14), + 15 => dispatch!(15), + 16 => dispatch!(16), + 17 => dispatch!(17), + 18 => dispatch!(18), + 19 => dispatch!(19), + 20 => dispatch!(20), + 21 => dispatch!(21), + 22 => dispatch!(22), + 23 => dispatch!(23), + 24 => dispatch!(24), + 25 => dispatch!(25), + 26 => dispatch!(26), + 27 => dispatch!(27), + 28 => dispatch!(28), + 29 => dispatch!(29), + 30 => dispatch!(30), + 31 => dispatch!(31), + 32 => dispatch!(32), + _ => unimplemented!(), + } + } +} diff --git a/depend/zcash/src/scheduler.cpp b/depend/zcash/src/scheduler.cpp index 44bc57ca3..fc0696647 100644 --- a/depend/zcash/src/scheduler.cpp +++ b/depend/zcash/src/scheduler.cpp @@ -7,9 +7,10 @@ #include "reverselock.h" #include -#include #include +#include + CScheduler::CScheduler() : nThreadsServicingQueue(0), stopRequested(false), stopWhenEmpty(false) { } diff --git a/depend/zcash/src/script/script.h b/depend/zcash/src/script/script.h index e9592ed5f..e67119197 100644 --- a/depend/zcash/src/script/script.h +++ b/depend/zcash/src/script/script.h @@ -228,12 +228,12 @@ class CScriptNum m_value = set_vch(vch); } - inline bool operator==(const int64_t& rhs) const { return m_value == rhs; } - inline bool operator!=(const int64_t& rhs) const { return m_value != rhs; } - inline bool operator<=(const int64_t& rhs) const { return m_value <= rhs; } - inline bool operator< (const int64_t& rhs) const { return m_value < rhs; } - inline bool operator>=(const int64_t& rhs) const { return m_value >= rhs; } - inline bool operator> (const int64_t& rhs) const { return m_value > rhs; } + inline bool operator==(const int64_t& rhs) const { return m_value == rhs; } + inline bool operator!=(const int64_t& rhs) const { return m_value != rhs; } + inline bool operator<=(const int64_t& rhs) const { return m_value <= rhs; } + inline bool operator< (const int64_t& rhs) const { return m_value < rhs; } + inline bool operator>=(const int64_t& rhs) const { return m_value >= rhs; } + inline bool operator> (const int64_t& rhs) const { return m_value > rhs; } inline bool operator==(const CScriptNum& rhs) const { return operator==(rhs.m_value); } inline bool operator!=(const CScriptNum& rhs) const { return operator!=(rhs.m_value); } @@ -242,8 +242,20 @@ class CScriptNum inline bool operator>=(const CScriptNum& rhs) const { return operator>=(rhs.m_value); } inline bool operator> (const CScriptNum& rhs) const { return operator> (rhs.m_value); } - inline CScriptNum operator+( const int64_t& rhs) const { return CScriptNum(m_value + rhs);} - inline CScriptNum operator-( const int64_t& rhs) const { return CScriptNum(m_value - rhs);} + inline CScriptNum operator+( const int64_t& rhs) const + { + assert(rhs == 0 || (rhs > 0 && m_value <= std::numeric_limits::max() - rhs) || + (rhs < 0 && m_value >= std::numeric_limits::min() - rhs)); + return CScriptNum(m_value + rhs); + } + + inline CScriptNum operator-( const int64_t& rhs) const + { + assert(rhs == 0 || (rhs > 0 && m_value >= std::numeric_limits::min() + rhs) || + (rhs < 0 && m_value <= std::numeric_limits::max() + rhs)); + return CScriptNum(m_value - rhs); + } + inline CScriptNum operator+( const CScriptNum& rhs) const { return operator+(rhs.m_value); } inline CScriptNum operator-( const CScriptNum& rhs) const { return operator-(rhs.m_value); } @@ -256,7 +268,7 @@ class CScriptNum return CScriptNum(-m_value); } - inline CScriptNum& operator=( const int64_t& rhs) + inline CScriptNum& operator=( const int64_t& rhs) { m_value = rhs; return *this; diff --git a/depend/zcash/src/script/zcash_script.cpp b/depend/zcash/src/script/zcash_script.cpp index 799ca5bdd..4bf6e3958 100644 --- a/depend/zcash/src/script/zcash_script.cpp +++ b/depend/zcash/src/script/zcash_script.cpp @@ -11,18 +11,18 @@ #include "script/interpreter.h" #include "version.h" -namespace { - +namespace +{ /** A class that deserializes a single CTransaction one time. */ class TxInputStream { public: - TxInputStream(int nTypeIn, int nVersionIn, const unsigned char *txTo, size_t txToLen) : - m_type(nTypeIn), - m_version(nVersionIn), - m_data(txTo), - m_remaining(txToLen) - {} + TxInputStream(int nTypeIn, int nVersionIn, const unsigned char* txTo, size_t txToLen) : m_type(nTypeIn), + m_version(nVersionIn), + m_data(txTo), + m_remaining(txToLen) + { + } void read(char* pch, size_t nSize) { @@ -40,7 +40,7 @@ class TxInputStream m_data += nSize; } - template + template TxInputStream& operator>>(T& obj) { ::Unserialize(*this, obj); @@ -49,6 +49,7 @@ class TxInputStream int GetVersion() const { return m_version; } int GetType() const { return m_type; } + private: const int m_type; const int m_version; @@ -63,19 +64,84 @@ inline int set_error(zcash_script_error* ret, zcash_script_error serror) return 0; } -struct ECCryptoClosure -{ +struct ECCryptoClosure { ECCVerifyHandle handle; }; ECCryptoClosure instance_of_eccryptoclosure; +} // namespace + +struct PrecomputedTransaction { + const CTransaction tx; + const PrecomputedTransactionData txdata; + + PrecomputedTransaction(CTransaction txIn) : tx(txIn), txdata(txIn) {} +}; + +void* zcash_script_new_precomputed_tx( + const unsigned char* txTo, + unsigned int txToLen, + zcash_script_error* err) +{ + try { + TxInputStream stream(SER_NETWORK, PROTOCOL_VERSION, txTo, txToLen); + CTransaction tx; + stream >> tx; + if (GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) != txToLen) { + set_error(err, zcash_script_ERR_TX_SIZE_MISMATCH); + return nullptr; + } + + // Regardless of the verification result, the tx did not error. + set_error(err, zcash_script_ERR_OK); + auto preTx = new PrecomputedTransaction(tx); + return preTx; + } catch (const std::exception&) { + set_error(err, zcash_script_ERR_TX_DESERIALIZE); // Error deserializing + return nullptr; + } +} + +void zcash_script_free_precomputed_tx(void* pre_preTx) +{ + PrecomputedTransaction* preTx = static_cast(pre_preTx); + delete preTx; + preTx = nullptr; +} + +int zcash_script_verify_precomputed( + const void* pre_preTx, + unsigned int nIn, + const unsigned char* scriptPubKey, + unsigned int scriptPubKeyLen, + int64_t amount, + unsigned int flags, + uint32_t consensusBranchId, + zcash_script_error* err) +{ + const PrecomputedTransaction* preTx = static_cast(pre_preTx); + if (nIn >= preTx->tx.vin.size()) + return set_error(err, zcash_script_ERR_TX_INDEX); + + // Regardless of the verification result, the tx did not error. + set_error(err, zcash_script_ERR_OK); + return VerifyScript( + preTx->tx.vin[nIn].scriptSig, + CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), + flags, + TransactionSignatureChecker(&preTx->tx, nIn, amount, preTx->txdata), + consensusBranchId, + NULL); } int zcash_script_verify( - const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, + const unsigned char* scriptPubKey, + unsigned int scriptPubKeyLen, int64_t amount, - const unsigned char *txTo, unsigned int txToLen, - unsigned int nIn, unsigned int flags, + const unsigned char* txTo, + unsigned int txToLen, + unsigned int nIn, + unsigned int flags, uint32_t consensusBranchId, zcash_script_error* err) { @@ -88,7 +154,7 @@ int zcash_script_verify( if (GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) != txToLen) return set_error(err, zcash_script_ERR_TX_SIZE_MISMATCH); - // Regardless of the verification result, the tx did not error. + // Regardless of the verification result, the tx did not error. set_error(err, zcash_script_ERR_OK); PrecomputedTransactionData txdata(tx); return VerifyScript( diff --git a/depend/zcash/src/script/zcash_script.h b/depend/zcash/src/script/zcash_script.h index 31b12290a..e728bf79c 100644 --- a/depend/zcash/src/script/zcash_script.h +++ b/depend/zcash/src/script/zcash_script.h @@ -33,7 +33,7 @@ extern "C" { #endif -#define ZCASH_SCRIPT_API_VER 0 +#define ZCASH_SCRIPT_API_VER 1 typedef enum zcash_script_error_t { @@ -51,6 +51,37 @@ enum zcash_script_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9), // enable CHECKLOCKTIMEVERIFY (BIP65) }; +/// Deserializes the given transaction and precomputes values to improve +/// script verification performance. +/// +/// Returns a pointer to the precomputed transaction. Free this with +/// zcash_script_free_precomputed_tx once you are done. +/// +/// If not NULL, err will contain an error/success code for the operation. +void* zcash_script_new_precomputed_tx( + const unsigned char* txTo, + unsigned int txToLen, + zcash_script_error* err); + +/// Frees a precomputed transaction previously created with +/// zcash_script_new_precomputed_tx. +void zcash_script_free_precomputed_tx(void* preTx); + +/// Returns 1 if the input nIn of the precomputed transaction pointed to by +/// preTx correctly spends the scriptPubKey pointed to by scriptPubKey under +/// the additional constraints specified by flags. +/// +/// If not NULL, err will contain an error/success code for the operation. +EXPORT_SYMBOL int zcash_script_verify_precomputed( + const void* preTx, + unsigned int nIn, + const unsigned char* scriptPubKey, + unsigned int scriptPubKeyLen, + int64_t amount, + unsigned int flags, + uint32_t consensusBranchId, + zcash_script_error* err); + /// Returns 1 if the input nIn of the serialized transaction pointed to by /// txTo correctly spends the scriptPubKey pointed to by scriptPubKey under /// the additional constraints specified by flags. diff --git a/depend/zcash/src/secp256k1/configure.ac b/depend/zcash/src/secp256k1/configure.ac index e5fcbcb4e..9eeab51f0 100644 --- a/depend/zcash/src/secp256k1/configure.ac +++ b/depend/zcash/src/secp256k1/configure.ac @@ -25,9 +25,9 @@ fi AM_PROG_CC_C_O -AC_PROG_CC_C89 -if test x"$ac_cv_prog_cc_c89" = x"no"; then - AC_MSG_ERROR([c89 compiler support required]) +AC_PROG_CC_C99 +if test x"$ac_cv_prog_cc_c99" = x"no"; then + AC_MSG_ERROR([c99 compiler support required]) fi AM_PROG_AS @@ -65,7 +65,7 @@ esac CFLAGS="$CFLAGS -W" -warn_CFLAGS="-std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings" +warn_CFLAGS="-std=c99 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings" saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $warn_CFLAGS" AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}]) diff --git a/depend/zcash/src/secp256k1/src/scalar_4x64_impl.h b/depend/zcash/src/secp256k1/src/scalar_4x64_impl.h index 5c72512e7..a9f2f64c2 100644 --- a/depend/zcash/src/secp256k1/src/scalar_4x64_impl.h +++ b/depend/zcash/src/secp256k1/src/scalar_4x64_impl.h @@ -127,10 +127,38 @@ static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *b } static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a) { - bin[0] = a->d[3] >> 56; bin[1] = a->d[3] >> 48; bin[2] = a->d[3] >> 40; bin[3] = a->d[3] >> 32; bin[4] = a->d[3] >> 24; bin[5] = a->d[3] >> 16; bin[6] = a->d[3] >> 8; bin[7] = a->d[3]; - bin[8] = a->d[2] >> 56; bin[9] = a->d[2] >> 48; bin[10] = a->d[2] >> 40; bin[11] = a->d[2] >> 32; bin[12] = a->d[2] >> 24; bin[13] = a->d[2] >> 16; bin[14] = a->d[2] >> 8; bin[15] = a->d[2]; - bin[16] = a->d[1] >> 56; bin[17] = a->d[1] >> 48; bin[18] = a->d[1] >> 40; bin[19] = a->d[1] >> 32; bin[20] = a->d[1] >> 24; bin[21] = a->d[1] >> 16; bin[22] = a->d[1] >> 8; bin[23] = a->d[1]; - bin[24] = a->d[0] >> 56; bin[25] = a->d[0] >> 48; bin[26] = a->d[0] >> 40; bin[27] = a->d[0] >> 32; bin[28] = a->d[0] >> 24; bin[29] = a->d[0] >> 16; bin[30] = a->d[0] >> 8; bin[31] = a->d[0]; + bin[0] = (unsigned char) (a->d[3] >> 56); + bin[1] = (unsigned char) (a->d[3] >> 48); + bin[2] = (unsigned char) (a->d[3] >> 40); + bin[3] = (unsigned char) (a->d[3] >> 32); + bin[4] = (unsigned char) (a->d[3] >> 24); + bin[5] = (unsigned char) (a->d[3] >> 16); + bin[6] = (unsigned char) (a->d[3] >> 8); + bin[7] = (unsigned char) (a->d[3]); + bin[8] = (unsigned char) (a->d[2] >> 56); + bin[9] = (unsigned char) (a->d[2] >> 48); + bin[10] = (unsigned char) (a->d[2] >> 40); + bin[11] = (unsigned char) (a->d[2] >> 32); + bin[12] = (unsigned char) (a->d[2] >> 24); + bin[13] = (unsigned char) (a->d[2] >> 16); + bin[14] = (unsigned char) (a->d[2] >> 8); + bin[15] = (unsigned char) (a->d[2]); + bin[16] = (unsigned char) (a->d[1] >> 56); + bin[17] = (unsigned char) (a->d[1] >> 48); + bin[18] = (unsigned char) (a->d[1] >> 40); + bin[19] = (unsigned char) (a->d[1] >> 32); + bin[20] = (unsigned char) (a->d[1] >> 24); + bin[21] = (unsigned char) (a->d[1] >> 16); + bin[22] = (unsigned char) (a->d[1] >> 8); + bin[23] = (unsigned char) (a->d[1]); + bin[24] = (unsigned char) (a->d[0] >> 56); + bin[25] = (unsigned char) (a->d[0] >> 48); + bin[26] = (unsigned char) (a->d[0] >> 40); + bin[27] = (unsigned char) (a->d[0] >> 32); + bin[28] = (unsigned char) (a->d[0] >> 24); + bin[29] = (unsigned char) (a->d[0] >> 16); + bin[30] = (unsigned char) (a->d[0] >> 8); + bin[31] = (unsigned char) (a->d[0]); } SECP256K1_INLINE static int secp256k1_scalar_is_zero(const secp256k1_scalar *a) { diff --git a/depend/zcash/src/sendalert.cpp b/depend/zcash/src/sendalert.cpp index b6515d6b3..98aee058a 100644 --- a/depend/zcash/src/sendalert.cpp +++ b/depend/zcash/src/sendalert.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2018 The Zcash developers +// Copyright (c) 2016-2020 The Zcash developers // Original code from: https://gist.github.com/laanwj/0e689cfa37b52bcbbb44 /* @@ -72,15 +72,17 @@ void ThreadSendAlert() CAlert alert; alert.nRelayUntil = GetTime() + 15 * 60; alert.nExpiration = GetTime() + 10 * 365 * 24 * 60 * 60; - alert.nID = 1006; // use https://github.com/zcash/zcash/wiki/specification#assigned-numbers to keep track of alert IDs - alert.nCancel = 1005; // cancels previous messages up to this ID number + alert.nID = 1007; // use https://github.com/zcash/zcash/wiki/specification#assigned-numbers to keep track of alert IDs + alert.nCancel = 1006; // cancels previous messages up to this ID number // These versions are protocol versions // 170002 : 1.0.0 // 170006 : 1.1.2 // 170007 : 2.0.0 + // 170010 : 2.1.2 + // 170011 : 3.0.0 alert.nMinVer = 170002; - alert.nMaxVer = 170006; + alert.nMaxVer = 170010; // // main.cpp: @@ -90,7 +92,7 @@ void ThreadSendAlert() // 4000 or higher will put the RPC into safe mode alert.nPriority = 4000; alert.strComment = ""; - alert.strStatusBar = "Your client is out of date and incompatible with the Sapling network upgrade. Please update to a recent version of Zcash (2.0.1 or later)."; + alert.strStatusBar = "Your client is out of date and incompatible with the Heartwood network upgrade. Please update to a recent version of Zcash (3.0.0 or later)."; alert.strRPCError = alert.strStatusBar; // Set specific client version/versions here. If setSubVer is empty, no filtering on subver is done: diff --git a/depend/zcash/src/serialize.h b/depend/zcash/src/serialize.h index db8b16134..b7eb33b09 100644 --- a/depend/zcash/src/serialize.h +++ b/depend/zcash/src/serialize.h @@ -24,6 +24,8 @@ #include #include +#include + #include "prevector.h" static const unsigned int MAX_SIZE = 0x02000000; @@ -580,6 +582,24 @@ template void Unserialize(Stream& os, std::shared_p template void Serialize(Stream& os, const std::unique_ptr& p); template void Unserialize(Stream& os, std::unique_ptr& p); +/** + * Ed25519SigningKey + */ +template void Serialize(Stream& os, const Ed25519SigningKey& item); +template void Unserialize(Stream& is, Ed25519SigningKey& item); + +/** + * Ed25519VerificationKey + */ +template void Serialize(Stream& os, const Ed25519VerificationKey& item); +template void Unserialize(Stream& is, Ed25519VerificationKey& item); + +/** + * Ed25519Signature + */ +template void Serialize(Stream& os, const Ed25519Signature& item); +template void Unserialize(Stream& is, Ed25519Signature& item); + /** @@ -950,6 +970,57 @@ void Unserialize(Stream& is, std::shared_ptr& p) +/** + * Ed25519SigningKey + */ +template +void Serialize(Stream& os, const Ed25519SigningKey& sk) +{ + os.write((char*)sk.bytes, ED25519_SIGNING_KEY_LEN); +} + +template +void Unserialize(Stream& is, Ed25519SigningKey& sk) +{ + is.read((char*)sk.bytes, ED25519_SIGNING_KEY_LEN); +} + + + +/** + * Ed25519VerificationKey + */ +template +void Serialize(Stream& os, const Ed25519VerificationKey& vk) +{ + os.write((char*)vk.bytes, ED25519_VERIFICATION_KEY_LEN); +} + +template +void Unserialize(Stream& is, Ed25519VerificationKey& vk) +{ + is.read((char*)vk.bytes, ED25519_VERIFICATION_KEY_LEN); +} + + + +/** + * Ed25519Signature + */ +template +void Serialize(Stream& os, const Ed25519Signature& sig) +{ + os.write((char*)sig.bytes, ED25519_SIGNATURE_LEN); +} + +template +void Unserialize(Stream& is, Ed25519Signature& sig) +{ + is.read((char*)sig.bytes, ED25519_SIGNATURE_LEN); +} + + + /** * Support for ADD_SERIALIZE_METHODS and READWRITE macro */ diff --git a/depend/zcash/src/streams.h b/depend/zcash/src/streams.h index 5dbcfaf21..8680cde5b 100644 --- a/depend/zcash/src/streams.h +++ b/depend/zcash/src/streams.h @@ -524,16 +524,17 @@ class CBufferedFile protected: // read data from the source to fill the buffer bool Fill() { + assert(nReadPos == nSrcPos); unsigned int pos = nSrcPos % vchBuf.size(); unsigned int readNow = vchBuf.size() - pos; - unsigned int nAvail = vchBuf.size() - (nSrcPos - nReadPos) - nRewind; + unsigned int nAvail = vchBuf.size() - nRewind; if (nAvail < readNow) readNow = nAvail; if (readNow == 0) return false; size_t nBytes = fread((void*)&vchBuf[pos], 1, readNow, src); if (nBytes == 0) { - throw std::ios_base::failure(feof(src) ? "CBufferedFile::Fill: end of file" : "CBufferedFile::Fill: fread failed"); + throw std::ios_base::failure(eof() ? "CBufferedFile::Fill: end of file" : "CBufferedFile::Fill: fread failed"); } nSrcPos += nBytes; return true; @@ -566,7 +567,7 @@ class CBufferedFile // check whether we're at the end of the source file bool eof() const { - return nReadPos == nSrcPos && feof(src); + return src == NULL || (nReadPos == nSrcPos && feof(src)); } // read a number of bytes diff --git a/depend/zcash/src/support/allocators/secure.h b/depend/zcash/src/support/allocators/secure.h index 08e755b48..eb4d3c560 100644 --- a/depend/zcash/src/support/allocators/secure.h +++ b/depend/zcash/src/support/allocators/secure.h @@ -40,14 +40,17 @@ struct secure_allocator : public std::allocator { T* allocate(std::size_t n, const void* hint = 0) { - return static_cast(LockedPoolManager::Instance().alloc(sizeof(T) * n)); + T* allocation = static_cast(LockedPoolManager::Instance().alloc(sizeof(T) * n)); + if (!allocation) { + throw std::bad_alloc(); + } + return allocation; } - void deallocate(T* p, std::size_t n) + void deallocate(T* p, std::size_t n) noexcept { - if (p != NULL) { - memory_cleanse(p, sizeof(T) * n); - } + assert(p != nullptr); + memory_cleanse(p, sizeof(T) * n); LockedPoolManager::Instance().free(p); } }; diff --git a/depend/zcash/src/support/lockedpool.cpp b/depend/zcash/src/support/lockedpool.cpp index 63050f006..970bc94c2 100644 --- a/depend/zcash/src/support/lockedpool.cpp +++ b/depend/zcash/src/support/lockedpool.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php . #include "support/lockedpool.h" #include "support/cleanse.h" @@ -26,8 +26,14 @@ #include // for sysconf #endif -LockedPoolManager* LockedPoolManager::_instance = NULL; -std::once_flag LockedPoolManager::init_flag; +#include +#include +#ifdef ARENA_DEBUG +#include +#include +#endif + +LockedPoolManager* LockedPoolManager::_instance = nullptr; /*******************************************************************************/ // Utilities @@ -45,7 +51,9 @@ Arena::Arena(void *base_in, size_t size_in, size_t alignment_in): base(static_cast(base_in)), end(static_cast(base_in) + size_in), alignment(alignment_in) { // Start with one free chunk that covers the entire arena - chunks.emplace(base, Chunk(size_in, false)); + auto it = size_to_free_chunk.emplace(size_in, base); + chunks_free.emplace(base, it); + chunks_free_end.emplace(base + size_in, it); } Arena::~Arena() @@ -57,91 +65,99 @@ void* Arena::alloc(size_t size) // Round to next multiple of alignment size = align_up(size, alignment); - // Don't handle zero-sized chunks, or those bigger than MAX_SIZE - if (size == 0 || size >= Chunk::MAX_SIZE) { + // Don't handle zero-sized chunks + if (size == 0) return nullptr; - } - for (auto& chunk: chunks) { - if (!chunk.second.isInUse() && size <= chunk.second.getSize()) { - char* base = chunk.first; - size_t leftover = chunk.second.getSize() - size; - if (leftover > 0) { // Split chunk - chunks.emplace(base + size, Chunk(leftover, false)); - chunk.second.setSize(size); - } - chunk.second.setInUse(true); - return reinterpret_cast(base); - } + // Pick a large enough free-chunk. Returns an iterator pointing to the first element that is not less than key. + // This allocation strategy is best-fit. According to "Dynamic Storage Allocation: A Survey and Critical Review", + // Wilson et. al. 1995, https://www.scs.stanford.edu/14wi-cs140/sched/readings/wilson.pdf , best-fit and first-fit + // policies seem to work well in practice. + auto size_ptr_it = size_to_free_chunk.lower_bound(size); + if (size_ptr_it == size_to_free_chunk.end()) + return nullptr; + + // Create the used-chunk, taking its space from the end of the free-chunk + const size_t size_remaining = size_ptr_it->first - size; + auto alloced = chunks_used.emplace(size_ptr_it->second + size_remaining, size).first; + chunks_free_end.erase(size_ptr_it->second + size_ptr_it->first); + if (size_ptr_it->first == size) { + // whole chunk is used up + chunks_free.erase(size_ptr_it->second); + } else { + // still some memory left in the chunk + auto it_remaining = size_to_free_chunk.emplace(size_remaining, size_ptr_it->second); + chunks_free[size_ptr_it->second] = it_remaining; + chunks_free_end.emplace(size_ptr_it->second + size_remaining, it_remaining); } - return nullptr; + size_to_free_chunk.erase(size_ptr_it); + + return reinterpret_cast(alloced->first); } -void Arena::free(void *ptr) +void Arena::free(void *ptr) noexcept { - // Freeing the NULL pointer is OK. + // Freeing the nullptr pointer is OK. if (ptr == nullptr) { return; } - auto i = chunks.find(static_cast(ptr)); - if (i == chunks.end() || !i->second.isInUse()) { - throw std::runtime_error("Arena: invalid or double free"); - } - i->second.setInUse(false); - - if (i != chunks.begin()) { // Absorb into previous chunk if exists and free - auto prev = i; - --prev; - if (!prev->second.isInUse()) { - // Absorb current chunk size into previous chunk. - prev->second.setSize(prev->second.getSize() + i->second.getSize()); - // Erase current chunk. Erasing does not invalidate current - // iterators for a map, except for that pointing to the object - // itself, which will be overwritten in the next statement. - chunks.erase(i); - // From here on, the previous chunk is our current chunk. - i = prev; - } + // Remove chunk from used map + auto i = chunks_used.find(static_cast(ptr)); + if (i == chunks_used.end()) { + assert(!"Arena: invalid or double free"); } - auto next = i; - ++next; - if (next != chunks.end()) { // Absorb next chunk if exists and free - if (!next->second.isInUse()) { - // Absurb next chunk size into current chunk - i->second.setSize(i->second.getSize() + next->second.getSize()); - // Erase next chunk. - chunks.erase(next); - } + std::pair freed = *i; + chunks_used.erase(i); + + // coalesce freed with previous chunk + auto prev = chunks_free_end.find(freed.first); + if (prev != chunks_free_end.end()) { + freed.first -= prev->second->first; + freed.second += prev->second->first; + size_to_free_chunk.erase(prev->second); + chunks_free_end.erase(prev); + } + + // coalesce freed with chunk after freed + auto next = chunks_free.find(freed.first + freed.second); + if (next != chunks_free.end()) { + freed.second += next->second->first; + size_to_free_chunk.erase(next->second); + chunks_free.erase(next); } + + // Add/set space with coalesced free chunk + auto it = size_to_free_chunk.emplace(freed.second, freed.first); + chunks_free[freed.first] = it; + chunks_free_end[freed.first + freed.second] = it; } Arena::Stats Arena::stats() const { - Arena::Stats r; - r.used = r.free = r.total = r.chunks_used = r.chunks_free = 0; - for (const auto& chunk: chunks) { - if (chunk.second.isInUse()) { - r.used += chunk.second.getSize(); - r.chunks_used += 1; - } else { - r.free += chunk.second.getSize(); - r.chunks_free += 1; - } - r.total += chunk.second.getSize(); - } + Arena::Stats r{ 0, 0, 0, chunks_used.size(), chunks_free.size() }; + for (const auto& chunk: chunks_used) + r.used += chunk.second; + for (const auto& chunk: chunks_free) + r.free += chunk.second->first; + r.total = r.used + r.free; return r; } #ifdef ARENA_DEBUG +static void printchunk(void* base, size_t sz, bool used) { + std::cout << + "0x" << std::hex << std::setw(16) << std::setfill('0') << base << + " 0x" << std::hex << std::setw(16) << std::setfill('0') << sz << + " 0x" << used << std::endl; +} void Arena::walk() const { - for (const auto& chunk: chunks) { - std::cout << - "0x" << std::hex << std::setw(16) << std::setfill('0') << chunk.first << - " 0x" << std::hex << std::setw(16) << std::setfill('0') << chunk.second.getSize() << - " 0x" << chunk.second.isInUse() << std::endl; - } + for (const auto& chunk: chunks_used) + printchunk(chunk.first, chunk.second, true); + std::cout << std::endl; + for (const auto& chunk: chunks_free) + printchunk(chunk.first, chunk.second->first, false); std::cout << std::endl; } #endif @@ -224,13 +240,28 @@ PosixLockedPageAllocator::PosixLockedPageAllocator() page_size = sysconf(_SC_PAGESIZE); #endif } + +// Some systems (at least OS X) do not define MAP_ANONYMOUS yet and define +// MAP_ANON which is deprecated +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + void *PosixLockedPageAllocator::AllocateLocked(size_t len, bool *lockingSuccess) { void *addr; len = align_up(len, page_size); addr = mmap(nullptr, len, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + if (addr == MAP_FAILED) { + return nullptr; + } if (addr) { *lockingSuccess = mlock(addr, len) == 0; +#if defined(MADV_DONTDUMP) // Linux + madvise(addr, len, MADV_DONTDUMP); +#elif defined(MADV_NOCORE) // FreeBSD + madvise(addr, len, MADV_NOCORE); +#endif } return addr; } @@ -269,6 +300,11 @@ LockedPool::~LockedPool() void* LockedPool::alloc(size_t size) { std::lock_guard lock(mutex); + + // Don't handle impossible sizes + if (size == 0 || size > ARENA_SIZE) + return nullptr; + // Try allocating from each current arena for (auto &arena: arenas) { void *addr = arena.alloc(size); @@ -283,8 +319,13 @@ void* LockedPool::alloc(size_t size) return nullptr; } -void LockedPool::free(void *ptr) +void LockedPool::free(void *ptr) noexcept { + // Freeing the nullptr pointer is OK. + if (ptr == nullptr) { + return; + } + std::lock_guard lock(mutex); // TODO we can do better than this linear search by keeping a map of arena // extents to arena, and looking up the address. @@ -294,15 +335,13 @@ void LockedPool::free(void *ptr) return; } } - throw std::runtime_error("LockedPool: invalid address not pointing to any arena"); + assert(!"LockedPool: invalid address not pointing to any arena"); } LockedPool::Stats LockedPool::stats() const { std::lock_guard lock(mutex); - LockedPool::Stats r; - r.used = r.free = r.total = r.chunks_used = r.chunks_free = 0; - r.locked = cumulative_bytes_locked; + LockedPool::Stats r{0, 0, 0, cumulative_bytes_locked, 0, 0}; for (const auto &arena: arenas) { Arena::Stats i = arena.stats(); r.used += i.used; diff --git a/depend/zcash/src/support/lockedpool.h b/depend/zcash/src/support/lockedpool.h index 526c17a73..c73c6e9b6 100644 --- a/depend/zcash/src/support/lockedpool.h +++ b/depend/zcash/src/support/lockedpool.h @@ -1,6 +1,6 @@ // Copyright (c) 2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php . #ifndef BITCOIN_SUPPORT_LOCKEDPOOL_H #define BITCOIN_SUPPORT_LOCKEDPOOL_H @@ -10,6 +10,7 @@ #include #include #include +#include /** * OS-dependent allocation and deallocation of locked/pinned memory pages. @@ -21,7 +22,7 @@ class LockedPageAllocator virtual ~LockedPageAllocator() {} /** Allocate and lock memory pages. * If len is not a multiple of the system page size, it is rounded up. - * Returns 0 in case of allocation failure. + * Returns nullptr in case of allocation failure. * * If locking the memory pages could not be accomplished it will still * return the memory, however the lockingSuccess flag will be false. @@ -50,27 +51,9 @@ class Arena Arena(void *base, size_t size, size_t alignment); virtual ~Arena(); - /** A chunk of memory. - */ - struct Chunk - { - /** Most significant bit of size_t. This is used to mark - * in-usedness of chunk. - */ - const static size_t SIZE_MSB = 1LLU << ((sizeof(size_t)*8)-1); - /** Maximum size of a chunk */ - const static size_t MAX_SIZE = SIZE_MSB - 1; - - Chunk(size_t size_in, bool used_in): - size(size_in | (used_in ? SIZE_MSB : 0)) {} - - bool isInUse() const { return size & SIZE_MSB; } - void setInUse(bool used_in) { size = (size & ~SIZE_MSB) | (used_in ? SIZE_MSB : 0); } - size_t getSize() const { return size & ~SIZE_MSB; } - void setSize(size_t size_in) { size = (size & SIZE_MSB) | size_in; } - private: - size_t size; - }; + Arena(const Arena& other) = delete; // non construction-copyable + Arena& operator=(const Arena&) = delete; // non copyable + /** Memory statistics. */ struct Stats { @@ -89,9 +72,8 @@ class Arena /** Free a previously allocated chunk of memory. * Freeing the zero pointer has no effect. - * Raises std::runtime_error in case of error. */ - void free(void *ptr); + void free(void *ptr) noexcept; /** Get arena usage statistics */ Stats stats() const; @@ -106,13 +88,19 @@ class Arena */ bool addressInArena(void *ptr) const { return ptr >= base && ptr < end; } private: - Arena(const Arena& other) = delete; // non construction-copyable - Arena& operator=(const Arena&) = delete; // non copyable + typedef std::multimap SizeToChunkSortedMap; + /** Map to enable O(log(n)) best-fit allocation, as it's sorted by size */ + SizeToChunkSortedMap size_to_free_chunk; + + typedef std::unordered_map ChunkToSizeMap; + /** Map from begin of free chunk to its node in size_to_free_chunk */ + ChunkToSizeMap chunks_free; + /** Map from end of free chunk to its node in size_to_free_chunk */ + ChunkToSizeMap chunks_free_end; + + /** Map from begin of used chunk to its size */ + std::unordered_map chunks_used; - /** Map of chunk address to chunk information. This class makes use of the - * sorted order to merge previous and next chunks during deallocation. - */ - std::map chunks; /** Base address of arena */ char* base; /** End address of arena */ @@ -129,7 +117,7 @@ class Arena * An arena manages a contiguous region of memory. The pool starts out with one arena * but can grow to multiple arenas if the need arises. * - * Unlike a normal C heap, the administrative structures are seperate from the managed + * Unlike a normal C heap, the administrative structures are separate from the managed * memory. This has been done as the sizes and bases of objects are not in themselves sensitive * information, as to conserve precious locked memory. In some operating systems * the amount of memory that can be locked is small. @@ -170,9 +158,12 @@ class LockedPool * If this callback is provided and returns false, the allocation fails (hard fail), if * it returns true the allocation proceeds, but it could warn. */ - LockedPool(std::unique_ptr allocator, LockingFailed_Callback lf_cb_in = 0); + explicit LockedPool(std::unique_ptr allocator, LockingFailed_Callback lf_cb_in = nullptr); ~LockedPool(); + LockedPool(const LockedPool& other) = delete; // non construction-copyable + LockedPool& operator=(const LockedPool&) = delete; // non copyable + /** Allocate size bytes from this arena. * Returns pointer on success, or 0 if memory is full or * the application tried to allocate 0 bytes. @@ -181,16 +172,12 @@ class LockedPool /** Free a previously allocated chunk of memory. * Freeing the zero pointer has no effect. - * Raises std::runtime_error in case of error. */ - void free(void *ptr); + void free(void *ptr) noexcept; /** Get pool usage statistics */ Stats stats() const; private: - LockedPool(const LockedPool& other) = delete; // non construction-copyable - LockedPool& operator=(const LockedPool&) = delete; // non copyable - std::unique_ptr allocator; /** Create an arena from locked pages */ @@ -232,12 +219,13 @@ class LockedPoolManager : public LockedPool /** Return the current instance, or create it once */ static LockedPoolManager& Instance() { - std::call_once(LockedPoolManager::init_flag, LockedPoolManager::CreateInstance); + static std::once_flag init_flag; + std::call_once(init_flag, LockedPoolManager::CreateInstance); return *LockedPoolManager::_instance; } private: - LockedPoolManager(std::unique_ptr allocator); + explicit LockedPoolManager(std::unique_ptr allocator); /** Create a new LockedPoolManager specialized to the OS */ static void CreateInstance(); @@ -245,7 +233,6 @@ class LockedPoolManager : public LockedPool static bool LockingFailed(); static LockedPoolManager* _instance; - static std::once_flag init_flag; }; #endif // BITCOIN_SUPPORT_LOCKEDPOOL_H diff --git a/depend/zcash/src/test/alert_tests.cpp b/depend/zcash/src/test/alert_tests.cpp index c4ba04c37..f215eccd0 100644 --- a/depend/zcash/src/test/alert_tests.cpp +++ b/depend/zcash/src/test/alert_tests.cpp @@ -10,7 +10,7 @@ #include "chain.h" #include "chainparams.h" #include "clientversion.h" -#include "data/alertTests.raw.h" +#include "test/data/alertTests.raw.h" #include "main.h" #include "rpc/protocol.h" @@ -395,17 +395,17 @@ BOOST_AUTO_TEST_CASE(AlertDisablesRPC) const std::vector& alertKey = Params(CBaseChainParams::MAIN).AlertKey(); // Command should work before alerts - BOOST_CHECK_EQUAL(GetWarnings("rpc"), ""); + BOOST_CHECK_EQUAL(GetWarnings("rpc").first, ""); // First alert should disable RPC alerts[7].ProcessAlert(alertKey, false); BOOST_CHECK_EQUAL(alerts[7].strRPCError, "RPC disabled"); - BOOST_CHECK_EQUAL(GetWarnings("rpc"), "RPC disabled"); + BOOST_CHECK_EQUAL(GetWarnings("rpc").first, "RPC disabled"); // Second alert should re-enable RPC alerts[8].ProcessAlert(alertKey, false); BOOST_CHECK_EQUAL(alerts[8].strRPCError, ""); - BOOST_CHECK_EQUAL(GetWarnings("rpc"), ""); + BOOST_CHECK_EQUAL(GetWarnings("rpc").first, ""); SetMockTime(0); mapAlerts.clear(); @@ -436,26 +436,30 @@ void PartitionAlertTestImpl(const Consensus::Params& params, int startTime, int // Test 1: chain with blocks every nPowTargetSpacing seconds, // as normal, no worries: - SetMiscWarning(""); + SetMiscWarning("", 0); PartitionCheck(falseFunc, csDummy, &indexDummy[799]); - BOOST_CHECK_EQUAL("", GetMiscWarning()); + BOOST_CHECK_EQUAL("", GetMiscWarning().first); // Test 2: go 3.5 hours without a block, expect a warning: now += 3*60*60+30*60; SetMockTime(now); - SetMiscWarning(""); + SetMiscWarning("", 0); PartitionCheck(falseFunc, csDummy, &indexDummy[799]); - std::string expectedSlowErr = strprintf("WARNING: check your network connection, %d blocks received in the last 4 hours (%d expected)", expectedSlow, expectedTotal); - BOOST_CHECK_EQUAL(expectedSlowErr, GetMiscWarning()); - BOOST_TEST_MESSAGE(std::string("Got alert text: ")+GetMiscWarning()); + std::string expectedSlowErr = strprintf("WARNING: Check your network connection, %d blocks received in the last 4 hours (%d expected)", expectedSlow, expectedTotal); + auto warning = GetMiscWarning(); + // advance 5 seconds so alert time will be in the past + SetMockTime(now + 5); + BOOST_CHECK_EQUAL(GetTime() - 5, warning.second); + BOOST_CHECK_EQUAL(expectedSlowErr, warning.first); + BOOST_TEST_MESSAGE(DateTimeStrFormat("%Y-%m-%d %H:%M:%S", warning.second) + " - Got alert text: " + warning.first); // Test 3: test the "partition alerts only go off once per day" // code: now += 60*10; SetMockTime(now); - SetMiscWarning(""); + SetMiscWarning("", 0); PartitionCheck(falseFunc, csDummy, &indexDummy[799]); - BOOST_CHECK_EQUAL("", GetMiscWarning()); + BOOST_CHECK_EQUAL("", GetMiscWarning().first); // Test 4: get 2.5 times as many blocks as expected: start = now + 60*60*24; // Pretend it is a day later @@ -466,12 +470,16 @@ void PartitionAlertTestImpl(const Consensus::Params& params, int startTime, int now = indexDummy[799].nTime + params.PoWTargetSpacing(0) * 2/5; SetMockTime(now); - SetMiscWarning(""); + SetMiscWarning("", 0); PartitionCheck(falseFunc, csDummy, &indexDummy[799]); - std::string expectedFastErr = strprintf("WARNING: abnormally high number of blocks generated, %d blocks received in the last 4 hours (%d expected)", expectedFast, expectedTotal); - BOOST_CHECK_EQUAL(expectedFastErr, GetMiscWarning()); - BOOST_TEST_MESSAGE(std::string("Got alert text: ")+GetMiscWarning()); - SetMiscWarning(""); + std::string expectedFastErr = strprintf("WARNING: Abnormally high number of blocks generated, %d blocks received in the last 4 hours (%d expected)", expectedFast, expectedTotal); + warning = GetMiscWarning(); + // advance 5 seconds so alert time will be in the past + SetMockTime(now + 5); + BOOST_CHECK_EQUAL(GetTime() - 5, warning.second); + BOOST_CHECK_EQUAL(expectedFastErr, warning.first); + BOOST_TEST_MESSAGE(DateTimeStrFormat("%Y-%m-%d %H:%M:%S", warning.second) + " - Got alert text: " + warning.first); + SetMiscWarning("", 0); SetMockTime(0); } diff --git a/depend/zcash/src/test/allocator_tests.cpp b/depend/zcash/src/test/allocator_tests.cpp index 5599f4015..0099b32d1 100644 --- a/depend/zcash/src/test/allocator_tests.cpp +++ b/depend/zcash/src/test/allocator_tests.cpp @@ -31,15 +31,8 @@ BOOST_AUTO_TEST_CASE(arena_tests) #endif BOOST_CHECK(b.stats().used == 0); BOOST_CHECK(b.stats().free == synth_size); - try { // Test exception on double-free - b.free(chunk); - BOOST_CHECK(0); - } catch(std::runtime_error &) - { - } void *a0 = b.alloc(128); - BOOST_CHECK(a0 == synth_base); // first allocation must start at beginning void *a1 = b.alloc(256); void *a2 = b.alloc(512); BOOST_CHECK(b.stats().used == 896); @@ -63,8 +56,10 @@ BOOST_AUTO_TEST_CASE(arena_tests) BOOST_CHECK(b.stats().used == 128); b.free(a3); BOOST_CHECK(b.stats().used == 0); + BOOST_CHECK_EQUAL(b.stats().chunks_used, 0); BOOST_CHECK(b.stats().total == synth_size); BOOST_CHECK(b.stats().free == synth_size); + BOOST_CHECK_EQUAL(b.stats().chunks_free, 1); std::vector addr; BOOST_CHECK(b.alloc(0) == nullptr); // allocating 0 always returns nullptr @@ -74,7 +69,6 @@ BOOST_AUTO_TEST_CASE(arena_tests) // Sweeping allocate all memory for (int x=0; x<1024; ++x) addr.push_back(b.alloc(1024)); - BOOST_CHECK(addr[0] == synth_base); // first allocation must start at beginning BOOST_CHECK(b.stats().free == 0); BOOST_CHECK(b.alloc(1024) == nullptr); // memory is full, this must return nullptr BOOST_CHECK(b.alloc(0) == nullptr); @@ -116,7 +110,7 @@ BOOST_AUTO_TEST_CASE(arena_tests) bool lsb = s & 1; s >>= 1; if (lsb) - s ^= 0xf00f00f0; // LFSR period 0xf7ffffe0 + s ^= 0xf00f00f0; // LFSR period 0xf7ffffe1 } for (void *ptr: addr) b.free(ptr); @@ -124,6 +118,9 @@ BOOST_AUTO_TEST_CASE(arena_tests) BOOST_CHECK(b.stats().total == synth_size); BOOST_CHECK(b.stats().free == synth_size); + + // Check that Arena::free may be called on nullptr. + b.free(nullptr); } /** Mock LockedPageAllocator for testing */ @@ -166,6 +163,16 @@ BOOST_AUTO_TEST_CASE(lockedpool_tests_mock) BOOST_CHECK(pool.stats().total == 0); BOOST_CHECK(pool.stats().locked == 0); + // Ensure unreasonable requests are refused without allocating anything + void *invalid_toosmall = pool.alloc(0); + BOOST_CHECK(invalid_toosmall == nullptr); + BOOST_CHECK(pool.stats().used == 0); + BOOST_CHECK(pool.stats().free == 0); + void *invalid_toobig = pool.alloc(LockedPool::ARENA_SIZE+1); + BOOST_CHECK(invalid_toobig == nullptr); + BOOST_CHECK(pool.stats().used == 0); + BOOST_CHECK(pool.stats().free == 0); + void *a0 = pool.alloc(LockedPool::ARENA_SIZE / 2); BOOST_CHECK(a0); BOOST_CHECK(pool.stats().locked == LockedPool::ARENA_SIZE); @@ -209,16 +216,13 @@ BOOST_AUTO_TEST_CASE(lockedpool_tests_live) BOOST_CHECK(*((uint32_t*)a0) == 0x1234); pool.free(a0); - try { // Test exception on double-free - pool.free(a0); - BOOST_CHECK(0); - } catch(std::runtime_error &) - { - } // If more than one new arena was allocated for the above tests, something is wrong BOOST_CHECK(pool.stats().total <= (initial.total + LockedPool::ARENA_SIZE)); // Usage must be back to where it started BOOST_CHECK(pool.stats().used == initial.used); + + // Check that LockedPool::free may be called on nullptr. + pool.free(nullptr); } BOOST_AUTO_TEST_SUITE_END() diff --git a/depend/zcash/src/test/arith_uint256_tests.cpp b/depend/zcash/src/test/arith_uint256_tests.cpp index ba0b6141c..a1b7e2625 100644 --- a/depend/zcash/src/test/arith_uint256_tests.cpp +++ b/depend/zcash/src/test/arith_uint256_tests.cpp @@ -219,7 +219,7 @@ BOOST_AUTO_TEST_CASE( unaryOperators ) // ! ~ - // Check if doing _A_ _OP_ _B_ results in the same as applying _OP_ onto each -// element of Aarray and Barray, and then converting the result into a arith_uint256. +// element of Aarray and Barray, and then converting the result into an arith_uint256. #define CHECKBITWISEOPERATOR(_A_,_B_,_OP_) \ for (unsigned int i = 0; i < 32; ++i) { TmpArray[i] = _A_##Array[i] _OP_ _B_##Array[i]; } \ BOOST_CHECK(arith_uint256V(std::vector(TmpArray,TmpArray+32)) == (_A_##L _OP_ _B_##L)); diff --git a/depend/zcash/src/test/base58_tests.cpp b/depend/zcash/src/test/base58_tests.cpp index 8345c35e5..e11c8554d 100644 --- a/depend/zcash/src/test/base58_tests.cpp +++ b/depend/zcash/src/test/base58_tests.cpp @@ -4,14 +4,15 @@ #include "base58.h" -#include "data/base58_encode_decode.json.h" -#include "data/base58_keys_invalid.json.h" -#include "data/base58_keys_valid.json.h" +#include "test/data/base58_encode_decode.json.h" +#include "test/data/base58_keys_invalid.json.h" +#include "test/data/base58_keys_valid.json.h" #include "key.h" #include "key_io.h" #include "script/script.h" #include "test/test_bitcoin.h" +#include "test/test_util.h" #include "uint256.h" #include "util.h" #include "utilstrencodings.h" @@ -22,8 +23,6 @@ #include -extern UniValue read_json(const std::string& jsondata); - BOOST_FIXTURE_TEST_SUITE(base58_tests, BasicTestingSetup) // Goal: test low-level base58 encoding functionality diff --git a/depend/zcash/src/test/bignum.h b/depend/zcash/src/test/bignum.h deleted file mode 100644 index 13e70133a..000000000 --- a/depend/zcash/src/test/bignum.h +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2013 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or https://www.opensource.org/licenses/mit-license.php . - -#ifndef BITCOIN_TEST_BIGNUM_H -#define BITCOIN_TEST_BIGNUM_H - -#include -#include -#include -#include -#include -#include -#include - -#include - -class bignum_error : public std::runtime_error -{ -public: - explicit bignum_error(const std::string& str) : std::runtime_error(str) {} -}; - - -/** C++ wrapper for BIGNUM (OpenSSL bignum) */ -class CBigNum -{ - BIGNUM* bn; -public: - CBigNum() - { - bn = BN_new(); - assert(bn); - } - - CBigNum(const CBigNum& b) - { - bn = BN_new(); - assert(bn); - if (!BN_copy(bn, b.bn)) - { - BN_clear_free(bn); - throw bignum_error("CBigNum::CBigNum(const CBigNum&): BN_copy failed"); - } - } - - CBigNum& operator=(const CBigNum& b) - { - if (!BN_copy(bn, b.bn)) - throw bignum_error("CBigNum::operator=: BN_copy failed"); - return (*this); - } - - ~CBigNum() - { - BN_clear_free(bn); - } - - CBigNum(long long n) { bn = BN_new(); assert(bn); setint64(n); } - - explicit CBigNum(const std::vector& vch) - { - bn = BN_new(); - assert(bn); - setvch(vch); - } - - int getint() const - { - BN_ULONG n = BN_get_word(bn); - if (!BN_is_negative(bn)) - return (n > (BN_ULONG)std::numeric_limits::max() ? std::numeric_limits::max() : n); - else - return (n > (BN_ULONG)std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); - } - - void setint64(int64_t sn) - { - unsigned char pch[sizeof(sn) + 6]; - unsigned char* p = pch + 4; - bool fNegative; - uint64_t n; - - if (sn < (int64_t)0) - { - // Since the minimum signed integer cannot be represented as positive so long as its type is signed, - // and it's not well-defined what happens if you make it unsigned before negating it, - // we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate - n = -(sn + 1); - ++n; - fNegative = true; - } else { - n = sn; - fNegative = false; - } - - bool fLeadingZeroes = true; - for (int i = 0; i < 8; i++) - { - unsigned char c = (n >> 56) & 0xff; - n <<= 8; - if (fLeadingZeroes) - { - if (c == 0) - continue; - if (c & 0x80) - *p++ = (fNegative ? 0x80 : 0); - else if (fNegative) - c |= 0x80; - fLeadingZeroes = false; - } - *p++ = c; - } - unsigned int nSize = p - (pch + 4); - pch[0] = (nSize >> 24) & 0xff; - pch[1] = (nSize >> 16) & 0xff; - pch[2] = (nSize >> 8) & 0xff; - pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, bn); - } - - void setvch(const std::vector& vch) - { - std::vector vch2(vch.size() + 4); - unsigned int nSize = vch.size(); - // BIGNUM's byte stream format expects 4 bytes of - // big endian size data info at the front - vch2[0] = (nSize >> 24) & 0xff; - vch2[1] = (nSize >> 16) & 0xff; - vch2[2] = (nSize >> 8) & 0xff; - vch2[3] = (nSize >> 0) & 0xff; - // swap data to big endian - reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4); - BN_mpi2bn(&vch2[0], vch2.size(), bn); - } - - std::vector getvch() const - { - unsigned int nSize = BN_bn2mpi(bn, NULL); - if (nSize <= 4) - return std::vector(); - std::vector vch(nSize); - BN_bn2mpi(bn, &vch[0]); - vch.erase(vch.begin(), vch.begin() + 4); - reverse(vch.begin(), vch.end()); - return vch; - } - - friend inline const CBigNum operator+(const CBigNum& a, const CBigNum& b); - friend inline const CBigNum operator-(const CBigNum& a, const CBigNum& b); - friend inline const CBigNum operator-(const CBigNum& a); - friend inline bool operator==(const CBigNum& a, const CBigNum& b); - friend inline bool operator!=(const CBigNum& a, const CBigNum& b); - friend inline bool operator<=(const CBigNum& a, const CBigNum& b); - friend inline bool operator>=(const CBigNum& a, const CBigNum& b); - friend inline bool operator<(const CBigNum& a, const CBigNum& b); - friend inline bool operator>(const CBigNum& a, const CBigNum& b); -}; - - - -inline const CBigNum operator+(const CBigNum& a, const CBigNum& b) -{ - CBigNum r; - if (!BN_add(r.bn, a.bn, b.bn)) - throw bignum_error("CBigNum::operator+: BN_add failed"); - return r; -} - -inline const CBigNum operator-(const CBigNum& a, const CBigNum& b) -{ - CBigNum r; - if (!BN_sub(r.bn, a.bn, b.bn)) - throw bignum_error("CBigNum::operator-: BN_sub failed"); - return r; -} - -inline const CBigNum operator-(const CBigNum& a) -{ - CBigNum r(a); - BN_set_negative(r.bn, !BN_is_negative(r.bn)); - return r; -} - -inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.bn, b.bn) == 0); } -inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.bn, b.bn) != 0); } -inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.bn, b.bn) <= 0); } -inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.bn, b.bn) >= 0); } -inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.bn, b.bn) < 0); } -inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.bn, b.bn) > 0); } - -#endif // BITCOIN_TEST_BIGNUM_H diff --git a/depend/zcash/src/test/checkblock_tests.cpp b/depend/zcash/src/test/checkblock_tests.cpp index 4df9ca027..494ce4255 100644 --- a/depend/zcash/src/test/checkblock_tests.cpp +++ b/depend/zcash/src/test/checkblock_tests.cpp @@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(May15) // After May 15'th, big blocks are OK: forkingBlock.nTime = tMay15; // Invalidates PoW auto verifier = ProofVerifier::Strict(); - BOOST_CHECK(CheckBlock(forkingBlock, state, Params(), verifier, false, false)); + BOOST_CHECK(CheckBlock(forkingBlock, state, Params(), verifier, false, false, true)); } SetMockTime(0); diff --git a/depend/zcash/src/test/crypto_tests.cpp b/depend/zcash/src/test/crypto_tests.cpp index 7b8906d3a..c89bd90bb 100644 --- a/depend/zcash/src/test/crypto_tests.cpp +++ b/depend/zcash/src/test/crypto_tests.cpp @@ -17,8 +17,6 @@ #include #include -#include -#include BOOST_FIXTURE_TEST_SUITE(crypto_tests, BasicTestingSetup) diff --git a/depend/zcash/src/test/rpc_tests.cpp b/depend/zcash/src/test/rpc_tests.cpp index 716b86362..1643b41db 100644 --- a/depend/zcash/src/test/rpc_tests.cpp +++ b/depend/zcash/src/test/rpc_tests.cpp @@ -12,64 +12,14 @@ #include "utilstrencodings.h" #include "test/test_bitcoin.h" +#include "test/test_util.h" -#include #include #include using namespace std; -UniValue -createArgs(int nRequired, const char* address1=NULL, const char* address2=NULL) -{ - UniValue result(UniValue::VARR); - result.push_back(nRequired); - UniValue addresses(UniValue::VARR); - if (address1) addresses.push_back(address1); - if (address2) addresses.push_back(address2); - result.push_back(addresses); - return result; -} - -UniValue CallRPC(string args) -{ - vector vArgs; - boost::split(vArgs, args, boost::is_any_of(" \t")); - string strMethod = vArgs[0]; - vArgs.erase(vArgs.begin()); - // Handle empty strings the same way as CLI - for (auto i = 0; i < vArgs.size(); i++) { - if (vArgs[i] == "\"\"") { - vArgs[i] = ""; - } - } - UniValue params = RPCConvertValues(strMethod, vArgs); - BOOST_CHECK(tableRPC[strMethod]); - rpcfn_type method = tableRPC[strMethod]->actor; - try { - UniValue result = (*method)(params, false); - return result; - } - catch (const UniValue& objError) { - throw runtime_error(find_value(objError, "message").get_str()); - } -} - - -void CheckRPCThrows(std::string rpcString, std::string expectedErrorMessage) { - try { - CallRPC(rpcString); - // Note: CallRPC catches (const UniValue& objError) and rethrows a runtime_error - BOOST_FAIL("Should have caused an error"); - } catch (const std::runtime_error& e) { - BOOST_CHECK_EQUAL(expectedErrorMessage, e.what()); - } catch(const std::exception& e) { - BOOST_FAIL(std::string("Unexpected exception: ") + typeid(e).name() + ", message=\"" + e.what() + "\""); - } -} - - BOOST_FIXTURE_TEST_SUITE(rpc_tests, TestingSetup) BOOST_AUTO_TEST_CASE(rpc_rawparams) @@ -96,6 +46,7 @@ BOOST_AUTO_TEST_CASE(rpc_rawparams) BOOST_CHECK_THROW(CallRPC("decoderawtransaction DEADBEEF"), runtime_error); string rawtx = "0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000"; BOOST_CHECK_NO_THROW(r = CallRPC(string("decoderawtransaction ")+rawtx)); + BOOST_CHECK_EQUAL(find_value(r.get_obj(), "size").get_int(), 193); BOOST_CHECK_EQUAL(find_value(r.get_obj(), "version").get_int(), 1); BOOST_CHECK_EQUAL(find_value(r.get_obj(), "locktime").get_int(), 0); BOOST_CHECK_THROW(r = CallRPC(string("decoderawtransaction ")+rawtx+" extra"), runtime_error); diff --git a/depend/zcash/src/test/sanity_tests.cpp b/depend/zcash/src/test/sanity_tests.cpp index c29b173fa..41813fdd2 100644 --- a/depend/zcash/src/test/sanity_tests.cpp +++ b/depend/zcash/src/test/sanity_tests.cpp @@ -14,7 +14,7 @@ BOOST_AUTO_TEST_CASE(basic_sanity) { BOOST_CHECK_MESSAGE(glibc_sanity_test() == true, "libc sanity test"); BOOST_CHECK_MESSAGE(glibcxx_sanity_test() == true, "stdlib sanity test"); - BOOST_CHECK_MESSAGE(ECC_InitSanityCheck() == true, "openssl ECC test"); + BOOST_CHECK_MESSAGE(ECC_InitSanityCheck() == true, "ECC sanity test"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/depend/zcash/src/test/scheduler_tests.cpp b/depend/zcash/src/test/scheduler_tests.cpp index f22d3391f..811003440 100644 --- a/depend/zcash/src/test/scheduler_tests.cpp +++ b/depend/zcash/src/test/scheduler_tests.cpp @@ -7,7 +7,7 @@ #include "test/test_bitcoin.h" -#include +#include #include #include #include diff --git a/depend/zcash/src/test/script_P2PKH_tests.cpp b/depend/zcash/src/test/script_P2PKH_tests.cpp index 99d826345..9418b0d02 100644 --- a/depend/zcash/src/test/script_P2PKH_tests.cpp +++ b/depend/zcash/src/test/script_P2PKH_tests.cpp @@ -47,12 +47,12 @@ BOOST_AUTO_TEST_CASE(IsPayToPublicKeyHash) static const unsigned char missing2[] = { OP_DUP, OP_HASH160, 20, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; - BOOST_CHECK(!CScript(missing2, missing2+sizeof(missing)).IsPayToPublicKeyHash()); + BOOST_CHECK(!CScript(missing2, missing2+sizeof(missing2)).IsPayToPublicKeyHash()); static const unsigned char tooshort[] = { OP_DUP, OP_HASH160, 2, 0,0, OP_EQUALVERIFY, OP_CHECKSIG }; - BOOST_CHECK(!CScript(tooshort, tooshort+sizeof(direct)).IsPayToPublicKeyHash()); + BOOST_CHECK(!CScript(tooshort, tooshort+sizeof(tooshort)).IsPayToPublicKeyHash()); } diff --git a/depend/zcash/src/test/script_tests.cpp b/depend/zcash/src/test/script_tests.cpp index ea2ddf842..ef8453fbb 100644 --- a/depend/zcash/src/test/script_tests.cpp +++ b/depend/zcash/src/test/script_tests.cpp @@ -2,8 +2,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or https://www.opensource.org/licenses/mit-license.php . -#include "data/script_invalid.json.h" -#include "data/script_valid.json.h" +#include "test/data/script_invalid.json.h" +#include "test/data/script_valid.json.h" #include "consensus/upgrades.h" #include "core_io.h" @@ -15,8 +15,9 @@ #include "script/sign.h" #include "util.h" #include "test/test_bitcoin.h" +#include "test/test_util.h" -#if defined(HAVE_CONSENSUS_LIB) +#if defined(HAVE_SCRIPT_LIB) #include "script/zcash_script.h" #endif @@ -38,22 +39,6 @@ using namespace std; static const unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC; -unsigned int ParseScriptFlags(string strFlags); -string FormatScriptFlags(unsigned int flags); - -UniValue -read_json(const std::string& jsondata) -{ - UniValue v; - - if (!v.read(jsondata) || !v.isArray()) - { - BOOST_ERROR("Parse error."); - return UniValue(UniValue::VARR); - } - return v.get_array(); -} - BOOST_FIXTURE_TEST_SUITE(script_tests, BasicTestingSetup) CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey) @@ -97,7 +82,7 @@ void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, int flags, ui CMutableTransaction tx2 = tx; BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, flags, MutableTransactionSignatureChecker(&tx, 0, txCredit.vout[0].nValue), consensusBranchId, &err) == expect, message); BOOST_CHECK_MESSAGE(expect == (err == SCRIPT_ERR_OK), std::string(ScriptErrorString(err)) + ": " + message); -#if defined(HAVE_CONSENSUS_LIB) +#if defined(HAVE_SCRIPT_LIB) CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << tx2; BOOST_CHECK_MESSAGE(zcash_script_verify( diff --git a/depend/zcash/src/test/scriptnum10.h b/depend/zcash/src/test/scriptnum10.h new file mode 100644 index 000000000..d81e599bd --- /dev/null +++ b/depend/zcash/src/test/scriptnum10.h @@ -0,0 +1,209 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_TEST_SCRIPTNUM10_H +#define BITCOIN_TEST_SCRIPTNUM10_H + +#include +#include +#include +#include +#include +#include +#include "assert.h" + +class scriptnum10_error : public std::runtime_error +{ +public: + explicit scriptnum10_error(const std::string& str) : std::runtime_error(str) {} +}; + +class CScriptNum10 +{ +/** + * The ScriptNum implementation from Bitcoin Core 0.10.0, for cross-comparison. + */ +public: + + explicit CScriptNum10(const int64_t& n) + { + m_value = n; + } + + static const size_t nDefaultMaxNumSize = 4; + + explicit CScriptNum10(const std::vector& vch, bool fRequireMinimal, + const size_t nMaxNumSize = nDefaultMaxNumSize) + { + if (vch.size() > nMaxNumSize) { + throw scriptnum10_error("script number overflow"); + } + if (fRequireMinimal && vch.size() > 0) { + // Check that the number is encoded with the minimum possible + // number of bytes. + // + // If the most-significant-byte - excluding the sign bit - is zero + // then we're not minimal. Note how this test also rejects the + // negative-zero encoding, 0x80. + if ((vch.back() & 0x7f) == 0) { + // One exception: if there's more than one byte and the most + // significant bit of the second-most-significant-byte is set + // it would conflict with the sign bit. An example of this case + // is +-255, which encode to 0xff00 and 0xff80 respectively. + // (big-endian). + if (vch.size() <= 1 || (vch[vch.size() - 2] & 0x80) == 0) { + throw scriptnum10_error("non-minimally encoded script number"); + } + } + } + m_value = set_vch(vch); + } + + inline bool operator==(const int64_t& rhs) const { return m_value == rhs; } + inline bool operator!=(const int64_t& rhs) const { return m_value != rhs; } + inline bool operator<=(const int64_t& rhs) const { return m_value <= rhs; } + inline bool operator< (const int64_t& rhs) const { return m_value < rhs; } + inline bool operator>=(const int64_t& rhs) const { return m_value >= rhs; } + inline bool operator> (const int64_t& rhs) const { return m_value > rhs; } + + inline bool operator==(const CScriptNum10& rhs) const { return operator==(rhs.m_value); } + inline bool operator!=(const CScriptNum10& rhs) const { return operator!=(rhs.m_value); } + inline bool operator<=(const CScriptNum10& rhs) const { return operator<=(rhs.m_value); } + inline bool operator< (const CScriptNum10& rhs) const { return operator< (rhs.m_value); } + inline bool operator>=(const CScriptNum10& rhs) const { return operator>=(rhs.m_value); } + inline bool operator> (const CScriptNum10& rhs) const { return operator> (rhs.m_value); } + + inline CScriptNum10 operator+( const int64_t& rhs) const + { + assert(rhs == 0 || (rhs > 0 && m_value <= std::numeric_limits::max() - rhs) || + (rhs < 0 && m_value >= std::numeric_limits::min() - rhs)); + return CScriptNum10(m_value + rhs); + } + + inline CScriptNum10 operator-( const int64_t& rhs) const + { + assert(rhs == 0 || (rhs > 0 && m_value >= std::numeric_limits::min() + rhs) || + (rhs < 0 && m_value <= std::numeric_limits::max() + rhs)); + return CScriptNum10(m_value - rhs); + } + + inline CScriptNum10 operator+( const CScriptNum10& rhs) const { return operator+(rhs.m_value); } + inline CScriptNum10 operator-( const CScriptNum10& rhs) const { return operator-(rhs.m_value); } + + inline CScriptNum10& operator+=( const CScriptNum10& rhs) { return operator+=(rhs.m_value); } + inline CScriptNum10& operator-=( const CScriptNum10& rhs) { return operator-=(rhs.m_value); } + + inline CScriptNum10 operator-() const + { + assert(m_value != std::numeric_limits::min()); + return CScriptNum10(-m_value); + } + + inline CScriptNum10& operator=( const int64_t& rhs) + { + m_value = rhs; + return *this; + } + + inline CScriptNum10& operator+=( const int64_t& rhs) + { + assert(rhs == 0 || (rhs > 0 && m_value <= std::numeric_limits::max() - rhs) || + (rhs < 0 && m_value >= std::numeric_limits::min() - rhs)); + m_value += rhs; + return *this; + } + + inline CScriptNum10& operator-=( const int64_t& rhs) + { + assert(rhs == 0 || (rhs > 0 && m_value >= std::numeric_limits::min() + rhs) || + (rhs < 0 && m_value <= std::numeric_limits::max() + rhs)); + m_value -= rhs; + return *this; + } + + int getint() const + { + if (m_value > std::numeric_limits::max()) + return std::numeric_limits::max(); + else if (m_value < std::numeric_limits::min()) + return std::numeric_limits::min(); + return m_value; + } + + std::vector getvch() const + { + return serialize(m_value); + } + + static std::vector serialize(const int64_t& value) + { + if(value == 0) + return std::vector(); + + // This could result in undefined behaviour in Bitcoin 0.10.0 and + // Zcash prior to https://github.com/zcash/zcash/pull/4454 . + // Since we only use this implementation for tests, we just assert + // that the tests are not triggering this case (which is tested + // separately for the real implementation). + assert(value != INT64_MIN); + + std::vector result; + const bool neg = value < 0; + uint64_t absvalue = neg ? -value : value; + + while(absvalue) + { + result.push_back(absvalue & 0xff); + absvalue >>= 8; + } + +// - If the most significant byte is >= 0x80 and the value is positive, push a +// new zero-byte to make the significant byte < 0x80 again. + +// - If the most significant byte is >= 0x80 and the value is negative, push a +// new 0x80 byte that will be popped off when converting to an integral. + +// - If the most significant byte is < 0x80 and the value is negative, add +// 0x80 to it, since it will be subtracted and interpreted as a negative when +// converting to an integral. + + if (result.back() & 0x80) + result.push_back(neg ? 0x80 : 0); + else if (neg) + result.back() |= 0x80; + + return result; + } + +private: + static int64_t set_vch(const std::vector& vch) + { + if (vch.empty()) + return 0; + + // This could result in undefined behaviour in Bitcoin 0.10.0 and + // Zcash prior to https://github.com/zcash/zcash/pull/4454 . + // Since we only use this implementation for tests, we just assert + // that the tests are not triggering this case (which is tested + // separately for the real implementation). + assert(vch.size() <= 8); + + int64_t result = 0; + for (size_t i = 0; i != vch.size(); ++i) + result |= static_cast(vch[i]) << 8*i; + + // If the input vector's most significant byte is 0x80, remove it from + // the result's msb and return a negative. + if (vch.back() & 0x80) + return -((int64_t)(result & ~(0x80ULL << (8 * (vch.size() - 1))))); + + return result; + } + + int64_t m_value; +}; + + +#endif // BITCOIN_TEST_BIGNUM_H diff --git a/depend/zcash/src/test/scriptnum_tests.cpp b/depend/zcash/src/test/scriptnum_tests.cpp index def72e784..42ab48516 100644 --- a/depend/zcash/src/test/scriptnum_tests.cpp +++ b/depend/zcash/src/test/scriptnum_tests.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or https://www.opensource.org/licenses/mit-license.php . -#include "bignum.h" +#include "scriptnum10.h" #include "script/script.h" #include "test/test_bitcoin.h" @@ -13,55 +13,70 @@ BOOST_FIXTURE_TEST_SUITE(scriptnum_tests, BasicTestingSetup) static const int64_t values[] = \ -{ 0, 1, CHAR_MIN, CHAR_MAX, UCHAR_MAX, SHRT_MIN, USHRT_MAX, INT_MIN, INT_MAX, UINT_MAX, LONG_MIN, LONG_MAX }; +{ 0, 1, CHAR_MIN, CHAR_MAX, UCHAR_MAX, SHRT_MIN, USHRT_MAX, INT_MIN, INT_MAX, UINT_MAX, INT64_MIN, INT64_MAX }; static const int64_t offsets[] = { 1, 0x79, 0x80, 0x81, 0xFF, 0x7FFF, 0x8000, 0xFFFF, 0x10000}; -static bool verify(const CBigNum& bignum, const CScriptNum& scriptnum) + +static bool addition_in_range(int64_t a, int64_t b) { + // intentionally excludes cases where the result would be INT64_MIN + return b > 0 ? (a <= INT64_MAX - b) : (a > INT64_MIN - b); +} + +static bool subtraction_in_range(int64_t a, int64_t b) { + // intentionally excludes cases where the result would be INT64_MIN + return b >= 0 ? (a > INT64_MIN + b) : (a <= INT64_MAX + b); +} + +static bool value_in_range(int64_t a) { + return a != INT64_MIN; +} + +static bool verify(const CScriptNum10& bignum, const CScriptNum& scriptnum) { return bignum.getvch() == scriptnum.getvch() && bignum.getint() == scriptnum.getint(); } -static void CheckCreateVch(const int64_t& num) +static void CheckCreateVch(int64_t num) { - CBigNum bignum(num); + CScriptNum10 bignum(num); CScriptNum scriptnum(num); BOOST_CHECK(verify(bignum, scriptnum)); - CBigNum bignum2(bignum.getvch()); - CScriptNum scriptnum2(scriptnum.getvch(), false); + CScriptNum10 bignum2(bignum.getvch(), false); + std::vector scriptnum_vch = scriptnum.getvch(); + // The 9-byte case is exercised by the 'intmin' test. + BOOST_CHECK(scriptnum_vch.size() <= 8); + CScriptNum scriptnum2(scriptnum_vch, false); BOOST_CHECK(verify(bignum2, scriptnum2)); - CBigNum bignum3(scriptnum2.getvch()); + CScriptNum10 bignum3(scriptnum2.getvch(), false); CScriptNum scriptnum3(bignum2.getvch(), false); BOOST_CHECK(verify(bignum3, scriptnum3)); } -static void CheckCreateInt(const int64_t& num) +static void CheckCreateInt(int64_t num) { - CBigNum bignum(num); + CScriptNum10 bignum(num); CScriptNum scriptnum(num); BOOST_CHECK(verify(bignum, scriptnum)); - BOOST_CHECK(verify(bignum.getint(), CScriptNum(scriptnum.getint()))); - BOOST_CHECK(verify(scriptnum.getint(), CScriptNum(bignum.getint()))); - BOOST_CHECK(verify(CBigNum(scriptnum.getint()).getint(), CScriptNum(CScriptNum(bignum.getint()).getint()))); + BOOST_CHECK(verify(CScriptNum10(bignum.getint()), CScriptNum(scriptnum.getint()))); + BOOST_CHECK(verify(CScriptNum10(scriptnum.getint()), CScriptNum(bignum.getint()))); + BOOST_CHECK(verify(CScriptNum10(CScriptNum10(scriptnum.getint()).getint()), CScriptNum(CScriptNum(bignum.getint()).getint()))); } -static void CheckAdd(const int64_t& num1, const int64_t& num2) +static void CheckAdd(int64_t num1, int64_t num2) { - const CBigNum bignum1(num1); - const CBigNum bignum2(num2); + const CScriptNum10 bignum1(num1); + const CScriptNum10 bignum2(num2); const CScriptNum scriptnum1(num1); const CScriptNum scriptnum2(num2); - CBigNum bignum3(num1); - CBigNum bignum4(num1); + CScriptNum10 bignum3(num1); + CScriptNum10 bignum4(num1); CScriptNum scriptnum3(num1); CScriptNum scriptnum4(num1); - // int64_t overflow is undefined. - bool invalid = (((num2 > 0) && (num1 > (std::numeric_limits::max() - num2))) || - ((num2 < 0) && (num1 < (std::numeric_limits::min() - num2)))); - if (!invalid) + if (addition_in_range(num1, num2)) { BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + scriptnum2)); BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + num2)); @@ -69,91 +84,84 @@ static void CheckAdd(const int64_t& num1, const int64_t& num2) } } -static void CheckNegate(const int64_t& num) +static void CheckNegate(int64_t num) { - const CBigNum bignum(num); + const CScriptNum10 bignum(num); const CScriptNum scriptnum(num); - // -INT64_MIN is undefined - if (num != std::numeric_limits::min()) - BOOST_CHECK(verify(-bignum, -scriptnum)); + BOOST_CHECK(verify(-bignum, -scriptnum)); } -static void CheckSubtract(const int64_t& num1, const int64_t& num2) +static void CheckSubtract(int64_t num1, int64_t num2) { - const CBigNum bignum1(num1); - const CBigNum bignum2(num2); + const CScriptNum10 bignum1(num1); + const CScriptNum10 bignum2(num2); const CScriptNum scriptnum1(num1); const CScriptNum scriptnum2(num2); bool invalid = false; - // int64_t overflow is undefined. - invalid = ((num2 > 0 && num1 < std::numeric_limits::min() + num2) || - (num2 < 0 && num1 > std::numeric_limits::max() + num2)); - if (!invalid) + if (subtraction_in_range(num1, num2)) { BOOST_CHECK(verify(bignum1 - bignum2, scriptnum1 - scriptnum2)); BOOST_CHECK(verify(bignum1 - bignum2, scriptnum1 - num2)); } - invalid = ((num1 > 0 && num2 < std::numeric_limits::min() + num1) || - (num1 < 0 && num2 > std::numeric_limits::max() + num1)); - if (!invalid) + if (subtraction_in_range(num2, num1)) { BOOST_CHECK(verify(bignum2 - bignum1, scriptnum2 - scriptnum1)); BOOST_CHECK(verify(bignum2 - bignum1, scriptnum2 - num1)); } } -static void CheckCompare(const int64_t& num1, const int64_t& num2) +static void CheckCompare(int64_t num1, int64_t num2) { - const CBigNum bignum1(num1); - const CBigNum bignum2(num2); + const CScriptNum10 bignum1(num1); + const CScriptNum10 bignum2(num2); const CScriptNum scriptnum1(num1); const CScriptNum scriptnum2(num2); BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == scriptnum1)); - BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != scriptnum1)); - BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < scriptnum1)); - BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > scriptnum1)); - BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= scriptnum1)); - BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= scriptnum1)); + BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != scriptnum1)); + BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < scriptnum1)); + BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > scriptnum1)); + BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= scriptnum1)); + BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= scriptnum1)); BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == num1)); - BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != num1)); - BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < num1)); - BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > num1)); - BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= num1)); - BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= num1)); - - BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == scriptnum2)); - BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != scriptnum2)); - BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < scriptnum2)); - BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > scriptnum2)); - BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= scriptnum2)); - BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= scriptnum2)); - - BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == num2)); - BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != num2)); - BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < num2)); - BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > num2)); - BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= num2)); - BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= num2)); + BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != num1)); + BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < num1)); + BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > num1)); + BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= num1)); + BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= num1)); + + BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == scriptnum2)); + BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != scriptnum2)); + BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < scriptnum2)); + BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > scriptnum2)); + BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= scriptnum2)); + BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= scriptnum2)); + + BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == num2)); + BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != num2)); + BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < num2)); + BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > num2)); + BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= num2)); + BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= num2)); } -static void RunCreate(const int64_t& num) +static void RunCreate(int64_t num) { CheckCreateInt(num); CScriptNum scriptnum(num); if (scriptnum.getvch().size() <= CScriptNum::nDefaultMaxNumSize) - CheckCreateVch(num); - else { - BOOST_CHECK_THROW (CheckCreateVch(num), scriptnum_error); + CheckCreateVch(num); + } else { + BOOST_CHECK_THROW(CheckCreateVch(num), scriptnum10_error); } } -static void RunOperators(const int64_t& num1, const int64_t& num2) +static void RunOperators(int64_t num1, int64_t num2) { CheckAdd(num1, num2); CheckSubtract(num1, num2); @@ -163,35 +171,56 @@ static void RunOperators(const int64_t& num1, const int64_t& num2) BOOST_AUTO_TEST_CASE(creation) { - for(size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i) + for (size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i) { - for(size_t j = 0; j < sizeof(offsets) / sizeof(offsets[0]); ++j) + for (size_t j = 0; j < sizeof(offsets) / sizeof(offsets[0]); ++j) { - RunCreate(values[i]); - RunCreate(values[i] + offsets[j]); - RunCreate(values[i] - offsets[j]); + if (value_in_range(values[i])) { + RunCreate(values[i]); + } + if (addition_in_range(values[i], offsets[j])) { + RunCreate(values[i] + offsets[j]); + } + if (subtraction_in_range(values[i], offsets[j])) { + RunCreate(values[i] - offsets[j]); + } } } } BOOST_AUTO_TEST_CASE(operators) { - for(size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i) + for (size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i) { - for(size_t j = 0; j < sizeof(offsets) / sizeof(offsets[0]); ++j) + for (size_t j = 0; j < sizeof(values) / sizeof(values[0]); ++j) { - RunOperators(values[i], values[i]); - RunOperators(values[i], -values[i]); - RunOperators(values[i], values[j]); - RunOperators(values[i], -values[j]); - RunOperators(values[i] + values[j], values[j]); - RunOperators(values[i] + values[j], -values[j]); - RunOperators(values[i] - values[j], values[j]); - RunOperators(values[i] - values[j], -values[j]); - RunOperators(values[i] + values[j], values[i] + values[j]); - RunOperators(values[i] + values[j], values[i] - values[j]); - RunOperators(values[i] - values[j], values[i] + values[j]); - RunOperators(values[i] - values[j], values[i] - values[j]); + if (value_in_range(values[i])) + { + RunOperators(values[i], values[i]); + RunOperators(values[i], -values[i]); + } + if (value_in_range(values[i]) && value_in_range(values[j])) + { + RunOperators(values[i], values[j]); + RunOperators(values[i], -values[j]); + } + if (addition_in_range(values[i], values[j]) && value_in_range(values[j])) + { + RunOperators(values[i] + values[j], values[j]); + RunOperators(values[i] + values[j], -values[j]); + RunOperators(values[i] + values[j], values[i] + values[j]); + } + if (subtraction_in_range(values[i], values[j]) && value_in_range(values[j])) + { + RunOperators(values[i] - values[j], values[j]); + RunOperators(values[i] - values[j], -values[j]); + RunOperators(values[i] - values[j], values[i] - values[j]); + } + if (addition_in_range(values[i], values[j]) && subtraction_in_range(values[i], values[j])) + { + RunOperators(values[i] + values[j], values[i] - values[j]); + RunOperators(values[i] - values[j], values[i] + values[j]); + } } } } diff --git a/depend/zcash/src/test/sighash_tests.cpp b/depend/zcash/src/test/sighash_tests.cpp index 9affb9b68..01e04d8ef 100644 --- a/depend/zcash/src/test/sighash_tests.cpp +++ b/depend/zcash/src/test/sighash_tests.cpp @@ -4,25 +4,25 @@ #include "consensus/upgrades.h" #include "consensus/validation.h" -#include "data/sighash.json.h" +#include "test/data/sighash.json.h" #include "main.h" #include "test_random.h" #include "script/interpreter.h" #include "script/script.h" #include "serialize.h" #include "test/test_bitcoin.h" +#include "test/test_util.h" #include "util.h" #include "version.h" -#include "sodium.h" #include #include #include -#include +#include -extern UniValue read_json(const std::string& jsondata); +#include // Old script.cpp SignatureHash function uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType) @@ -78,7 +78,7 @@ uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, un } // Blank out the joinsplit signature. - memset(&txTmp.joinSplitSig[0], 0, txTmp.joinSplitSig.size()); + memset(&txTmp.joinSplitSig.bytes, 0, ED25519_SIGNATURE_LEN); // Serialize and hash CHashWriter ss(SER_GETHASH, 0); @@ -195,18 +195,18 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle, uint32_t co tx.vJoinSplit.push_back(jsdesc); } - unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES]; - crypto_sign_keypair(tx.joinSplitPubKey.begin(), joinSplitPrivKey); + Ed25519SigningKey joinSplitPrivKey; + ed25519_generate_keypair(&joinSplitPrivKey, &tx.joinSplitPubKey); // Empty output script. CScript scriptCode; CTransaction signTx(tx); uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId); - assert(crypto_sign_detached(&tx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey - ) == 0); + assert(ed25519_sign( + &joinSplitPrivKey, + dataToBeSigned.begin(), 32, + &tx.joinSplitSig)); } } diff --git a/depend/zcash/src/test/test_bitcoin.cpp b/depend/zcash/src/test/test_bitcoin.cpp index dae6174bb..feb7f9e4d 100644 --- a/depend/zcash/src/test/test_bitcoin.cpp +++ b/depend/zcash/src/test/test_bitcoin.cpp @@ -31,6 +31,8 @@ #include "librustzcash.h" CClientUIInterface uiInterface; // Declared but not defined in ui_interface.h + +TracingHandle* pTracingHandle = nullptr; FastRandomContext insecure_rand_ctx(true); extern bool fPrintToConsole; @@ -52,13 +54,10 @@ JoinSplitTestingSetup::JoinSplitTestingSetup(const std::string& chainName) : Bas librustzcash_init_zksnark_params( reinterpret_cast(sapling_spend_str.c_str()), sapling_spend_str.length(), - "8270785a1a0d0bc77196f000ee6d221c9c9894f55307bd9357c3f0105d31ca63991ab91324160d8f53e2bbd3c2633a6eb8bdf5205d822e7f3f73edac51b2b70c", reinterpret_cast(sapling_output_str.c_str()), sapling_output_str.length(), - "657e3d38dbb5cb5e7dd2970e8b03d69b4787dd907285b5a7f0790dcc8072f60bf593b32cc2d1c030e00ff5ae64bf84c5c3beb84ddc841d48264b4a171744d028", reinterpret_cast(sprout_groth16_str.c_str()), - sprout_groth16_str.length(), - "e9b238411bd6c0ec4791e9d04245ec350c9c5744f5610dfcce4365d5ca49dfefd5054e371842b3f88fa1b9d7e8e075249b3ebabd167fa8b0f3161292d36c180a" + sprout_groth16_str.length() ); } diff --git a/depend/zcash/src/test/test_util.cpp b/depend/zcash/src/test/test_util.cpp new file mode 100644 index 000000000..650d9e14e --- /dev/null +++ b/depend/zcash/src/test/test_util.cpp @@ -0,0 +1,121 @@ +#include "test_util.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "script/interpreter.h" +#include "rpc/client.h" +#include "rpc/server.h" + +static std::map mapFlagNames = boost::assign::map_list_of + (std::string("NONE"), (unsigned int)SCRIPT_VERIFY_NONE) + (std::string("P2SH"), (unsigned int)SCRIPT_VERIFY_P2SH) + (std::string("STRICTENC"), (unsigned int)SCRIPT_VERIFY_STRICTENC) + (std::string("LOW_S"), (unsigned int)SCRIPT_VERIFY_LOW_S) + (std::string("SIGPUSHONLY"), (unsigned int)SCRIPT_VERIFY_SIGPUSHONLY) + (std::string("MINIMALDATA"), (unsigned int)SCRIPT_VERIFY_MINIMALDATA) + (std::string("NULLDUMMY"), (unsigned int)SCRIPT_VERIFY_NULLDUMMY) + (std::string("DISCOURAGE_UPGRADABLE_NOPS"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) + (std::string("CLEANSTACK"), (unsigned int)SCRIPT_VERIFY_CLEANSTACK) + (std::string("CHECKLOCKTIMEVERIFY"), (unsigned int)SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY); + +UniValue +read_json(const std::string& jsondata) +{ + UniValue v; + + if (!v.read(jsondata) || !v.isArray()) + { + BOOST_ERROR("Parse error."); + return UniValue(UniValue::VARR); + } + return v.get_array(); +} + +unsigned int ParseScriptFlags(std::string strFlags) +{ + if (strFlags.empty()) { + return 0; + } + unsigned int flags = 0; + std::vector words; + boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(",")); + + BOOST_FOREACH(std::string word, words) + { + if (!mapFlagNames.count(word)) + BOOST_ERROR("Bad test: unknown verification flag '" << word << "'"); + flags |= mapFlagNames[word]; + } + + return flags; +} + +std::string FormatScriptFlags(unsigned int flags) +{ + if (flags == 0) { + return ""; + } + std::string ret; + std::map::const_iterator it = mapFlagNames.begin(); + while (it != mapFlagNames.end()) { + if (flags & it->second) { + ret += it->first + ","; + } + it++; + } + return ret.substr(0, ret.size() - 1); +} + +UniValue createArgs(int nRequired, const char* address1, const char* address2) +{ + UniValue result(UniValue::VARR); + result.push_back(nRequired); + UniValue addresses(UniValue::VARR); + if (address1) addresses.push_back(address1); + if (address2) addresses.push_back(address2); + result.push_back(addresses); + return result; +} + +UniValue CallRPC(std::string args) +{ + std::vector vArgs; + boost::split(vArgs, args, boost::is_any_of(" \t")); + std::string strMethod = vArgs[0]; + vArgs.erase(vArgs.begin()); + // Handle empty strings the same way as CLI + for (auto i = 0; i < vArgs.size(); i++) { + if (vArgs[i] == "\"\"") { + vArgs[i] = ""; + } + } + UniValue params = RPCConvertValues(strMethod, vArgs); + + rpcfn_type method = tableRPC[strMethod]->actor; + try { + UniValue result = (*method)(params, false); + return result; + } + catch (const UniValue& objError) { + throw std::runtime_error(find_value(objError, "message").get_str()); + } +} + +void CheckRPCThrows(std::string rpcString, std::string expectedErrorMessage) { + try { + CallRPC(rpcString); + // Note: CallRPC catches (const UniValue& objError) and rethrows a runtime_error + BOOST_FAIL("Should have caused an error"); + } catch (const std::runtime_error& e) { + BOOST_CHECK_EQUAL(expectedErrorMessage, e.what()); + } catch(const std::exception& e) { + BOOST_FAIL(std::string("Unexpected exception: ") + typeid(e).name() + ", message=\"" + e.what() + "\""); + } +} + diff --git a/depend/zcash/src/test/test_util.h b/depend/zcash/src/test/test_util.h new file mode 100644 index 000000000..acad077bf --- /dev/null +++ b/depend/zcash/src/test/test_util.h @@ -0,0 +1,15 @@ +#ifndef BITCOIN_TEST_TEST_UTIL_H +#define BITCOIN_TEST_TEST_UTIL_H + +#include + +#include + +UniValue read_json(const std::string& jsondata); +unsigned int ParseScriptFlags(std::string strFlags); +std::string FormatScriptFlags(unsigned int flags); +UniValue createArgs(int nRequired, const char* address1 = NULL, const char* address2 = NULL); +UniValue CallRPC(std::string args); + + +#endif diff --git a/depend/zcash/src/test/transaction_tests.cpp b/depend/zcash/src/test/transaction_tests.cpp index e1e45a6bc..5707176a0 100644 --- a/depend/zcash/src/test/transaction_tests.cpp +++ b/depend/zcash/src/test/transaction_tests.cpp @@ -2,8 +2,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or https://www.opensource.org/licenses/mit-license.php . -#include "data/tx_invalid.json.h" -#include "data/tx_valid.json.h" +#include "test/data/tx_invalid.json.h" +#include "test/data/tx_valid.json.h" #include "test/test_bitcoin.h" #include "init.h" @@ -20,22 +20,20 @@ #include "script/script.h" #include "script/script_error.h" #include "script/sign.h" +#include "test/test_util.h" #include "primitives/transaction.h" #include "transaction_builder.h" -#include "sodium.h" - #include #include #include -#include -#include #include #include -#include #include +#include + #include #include "zcash/Note.hpp" @@ -44,56 +42,6 @@ using namespace std; -// In script_tests.cpp -extern UniValue read_json(const std::string& jsondata); - -static std::map mapFlagNames = boost::assign::map_list_of - (string("NONE"), (unsigned int)SCRIPT_VERIFY_NONE) - (string("P2SH"), (unsigned int)SCRIPT_VERIFY_P2SH) - (string("STRICTENC"), (unsigned int)SCRIPT_VERIFY_STRICTENC) - (string("LOW_S"), (unsigned int)SCRIPT_VERIFY_LOW_S) - (string("SIGPUSHONLY"), (unsigned int)SCRIPT_VERIFY_SIGPUSHONLY) - (string("MINIMALDATA"), (unsigned int)SCRIPT_VERIFY_MINIMALDATA) - (string("NULLDUMMY"), (unsigned int)SCRIPT_VERIFY_NULLDUMMY) - (string("DISCOURAGE_UPGRADABLE_NOPS"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) - (string("CLEANSTACK"), (unsigned int)SCRIPT_VERIFY_CLEANSTACK) - (string("CHECKLOCKTIMEVERIFY"), (unsigned int)SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY); - -unsigned int ParseScriptFlags(string strFlags) -{ - if (strFlags.empty()) { - return 0; - } - unsigned int flags = 0; - vector words; - boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(",")); - - BOOST_FOREACH(string word, words) - { - if (!mapFlagNames.count(word)) - BOOST_ERROR("Bad test: unknown verification flag '" << word << "'"); - flags |= mapFlagNames[word]; - } - - return flags; -} - -string FormatScriptFlags(unsigned int flags) -{ - if (flags == 0) { - return ""; - } - string ret; - std::map::const_iterator it = mapFlagNames.begin(); - while (it != mapFlagNames.end()) { - if (flags & it->second) { - ret += it->first + ","; - } - it++; - } - return ret.substr(0, ret.size() - 1); -} - BOOST_FIXTURE_TEST_SUITE(transaction_tests, JoinSplitTestingSetup) BOOST_AUTO_TEST_CASE(tx_valid) @@ -361,7 +309,7 @@ BOOST_AUTO_TEST_CASE(test_basic_joinsplit_verification) auto witness = merkleTree.witness(); // create JSDescription - uint256 joinSplitPubKey; + Ed25519VerificationKey joinSplitPubKey; std::array inputs = { libzcash::JSInput(witness, note, k), libzcash::JSInput() // dummy input of zero value @@ -469,8 +417,8 @@ void test_simple_joinsplit_invalidity(uint32_t consensusBranchId, CMutableTransa CMutableTransaction newTx(tx); CValidationState state; - unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES]; - crypto_sign_keypair(newTx.joinSplitPubKey.begin(), joinSplitPrivKey); + Ed25519SigningKey joinSplitPrivKey; + ed25519_generate_keypair(&joinSplitPrivKey, &newTx.joinSplitPubKey); // No joinsplits, vin and vout, means it should be invalid. BOOST_CHECK(!CheckTransactionWithoutProofVerification(newTx, state)); @@ -496,10 +444,10 @@ void test_simple_joinsplit_invalidity(uint32_t consensusBranchId, CMutableTransa CTransaction signTx(newTx); uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId); - assert(crypto_sign_detached(&newTx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey - ) == 0); + assert(ed25519_sign( + &joinSplitPrivKey, + dataToBeSigned.begin(), 32, + &newTx.joinSplitSig)); BOOST_CHECK(CheckTransactionWithoutProofVerification(newTx, state)); BOOST_CHECK(ContextualCheckTransaction(newTx, state, Params(), 0, true)); diff --git a/depend/zcash/src/timedata.cpp b/depend/zcash/src/timedata.cpp index 2044105db..93e78839e 100644 --- a/depend/zcash/src/timedata.cpp +++ b/depend/zcash/src/timedata.cpp @@ -64,7 +64,7 @@ void CTimeWarning::Warn(size_t peersAhead, size_t peersBehind) } else { strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong Zcash will not work properly."); } - SetMiscWarning(strMessage); + SetMiscWarning(strMessage, GetTime()); LogPrintf("*** %s\n", strMessage); uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING); } diff --git a/depend/zcash/src/torcontrol.cpp b/depend/zcash/src/torcontrol.cpp index 6a4f80078..4ac7dd58d 100644 --- a/depend/zcash/src/torcontrol.cpp +++ b/depend/zcash/src/torcontrol.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include #include @@ -28,6 +28,8 @@ #include #include +using namespace boost::placeholders; + /** Default control port */ const std::string DEFAULT_TOR_CONTROL = "127.0.0.1:9051"; /** Tor cookie size (from control-spec.txt) */ @@ -406,7 +408,7 @@ static bool WriteBinaryFile(const std::string &filename, const std::string &data /****** Bitcoin specific TorController implementation ********/ /** Controller that connects to Tor control socket, authenticate, then create - * and maintain a ephemeral hidden service. + * and maintain an ephemeral hidden service. */ class TorController { diff --git a/depend/zcash/src/transaction_builder.cpp b/depend/zcash/src/transaction_builder.cpp index d79072ea8..301c007fd 100644 --- a/depend/zcash/src/transaction_builder.cpp +++ b/depend/zcash/src/transaction_builder.cpp @@ -13,7 +13,7 @@ #include "zcash/Note.hpp" #include -#include +#include SpendDescriptionInfo::SpendDescriptionInfo( libzcash::SaplingExpandedSpendingKey expsk, @@ -418,8 +418,8 @@ TransactionBuilderResult TransactionBuilder::Build() // Sprout JoinSplits // - unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES]; - crypto_sign_keypair(mtx.joinSplitPubKey.begin(), joinSplitPrivKey); + Ed25519SigningKey joinSplitPrivKey; + ed25519_generate_keypair(&joinSplitPrivKey, &mtx.joinSplitPubKey); // Create Sprout JSDescriptions if (!jsInputs.empty() || !jsOutputs.empty()) { @@ -467,19 +467,19 @@ TransactionBuilderResult TransactionBuilder::Build() librustzcash_sapling_proving_ctx_free(ctx); // Create Sprout joinSplitSig - if (crypto_sign_detached( - mtx.joinSplitSig.data(), NULL, + if (!ed25519_sign( + &joinSplitPrivKey, dataToBeSigned.begin(), 32, - joinSplitPrivKey) != 0) + &mtx.joinSplitSig)) { return TransactionBuilderResult("Failed to create Sprout joinSplitSig"); } // Sanity check Sprout joinSplitSig - if (crypto_sign_verify_detached( - mtx.joinSplitSig.data(), - dataToBeSigned.begin(), 32, - mtx.joinSplitPubKey.begin()) != 0) + if (!ed25519_verify( + &mtx.joinSplitPubKey, + &mtx.joinSplitSig, + dataToBeSigned.begin(), 32)) { return TransactionBuilderResult("Sprout joinSplitSig sanity check failed"); } diff --git a/depend/zcash/src/transaction_builder.h b/depend/zcash/src/transaction_builder.h index 379eeb2ee..db06ed07d 100644 --- a/depend/zcash/src/transaction_builder.h +++ b/depend/zcash/src/transaction_builder.h @@ -51,7 +51,7 @@ struct OutputDescriptionInfo { }; struct JSDescriptionInfo { - uint256 joinSplitPubKey; + Ed25519VerificationKey joinSplitPubKey; uint256 anchor; std::array inputs; std::array outputs; @@ -59,7 +59,7 @@ struct JSDescriptionInfo { CAmount vpub_new; JSDescriptionInfo( - uint256 joinSplitPubKey, + Ed25519VerificationKey joinSplitPubKey, uint256 anchor, std::array inputs, std::array outputs, diff --git a/depend/zcash/src/txdb.cpp b/depend/zcash/src/txdb.cpp index 78843beea..1abdc56ca 100644 --- a/depend/zcash/src/txdb.cpp +++ b/depend/zcash/src/txdb.cpp @@ -139,16 +139,21 @@ HistoryIndex CCoinsViewDB::GetHistoryLength(uint32_t epochId) const { } HistoryNode CCoinsViewDB::GetHistoryAt(uint32_t epochId, HistoryIndex index) const { - HistoryNode mmrNode; + HistoryNode mmrNode = {}; if (index >= GetHistoryLength(epochId)) { throw runtime_error("History data inconsistent - reindex?"); } - if (!db.Read(make_pair(DB_MMR_NODE, make_pair(epochId, index)), mmrNode)) { + // Read mmrNode into tmp std::array + std::array tmpMmrNode; + + if (!db.Read(make_pair(DB_MMR_NODE, make_pair(epochId, index)), tmpMmrNode)) { throw runtime_error("History data inconsistent (expected node not found) - reindex?"); } + std::copy(std::begin(tmpMmrNode), std::end(tmpMmrNode), mmrNode.bytes); + return mmrNode; } @@ -205,7 +210,10 @@ void BatchWriteHistory(CDBBatch& batch, CHistoryCacheMap& historyCacheMap) { // replace/append new/updated entries for (auto it = historyCache.appends.begin(); it != historyCache.appends.end(); it++) { - batch.Write(make_pair(DB_MMR_NODE, make_pair(epochId, it->first)), it->second); + // Write mmrNode into tmp std::array + std::array tmpMmrNode; + std::copy((it->second).bytes, (it->second).bytes + NODE_SERIALIZED_LENGTH, std::begin(tmpMmrNode)); + batch.Write(make_pair(DB_MMR_NODE, make_pair(epochId, it->first)), tmpMmrNode); } // write new length diff --git a/depend/zcash/src/ui_interface.h b/depend/zcash/src/ui_interface.h index d7524db40..f279351b9 100644 --- a/depend/zcash/src/ui_interface.h +++ b/depend/zcash/src/ui_interface.h @@ -15,6 +15,7 @@ class CBasicKeyStore; class CWallet; class uint256; +class CBlockIndex; /** General change type (added, updated, removed). */ enum ChangeType @@ -97,7 +98,7 @@ class CClientUIInterface boost::signals2::signal ShowProgress; /** New block has been accepted */ - boost::signals2::signal NotifyBlockTip; + boost::signals2::signal NotifyBlockTip; /** Transaction expired */ boost::signals2::signal NotifyTxExpiration; diff --git a/depend/zcash/src/uint256.h b/depend/zcash/src/uint256.h index b07047b04..d40b70a45 100644 --- a/depend/zcash/src/uint256.h +++ b/depend/zcash/src/uint256.h @@ -104,7 +104,6 @@ class blob88 : public base_blob<88> { class uint160 : public base_blob<160> { public: uint160() {} - uint160(const base_blob<160>& b) : base_blob<160>(b) {} explicit uint160(const std::vector& vch) : base_blob<160>(vch) {} }; @@ -116,7 +115,6 @@ class uint160 : public base_blob<160> { class uint256 : public base_blob<256> { public: uint256() {} - uint256(const base_blob<256>& b) : base_blob<256>(b) {} explicit uint256(const std::vector& vch) : base_blob<256>(vch) {} /** A cheap hash function that just returns 64 bits from the result, it can be diff --git a/depend/zcash/src/univalue/Makefile.am b/depend/zcash/src/univalue/Makefile.am index 0f5ba5995..49c4e7c6f 100644 --- a/depend/zcash/src/univalue/Makefile.am +++ b/depend/zcash/src/univalue/Makefile.am @@ -41,22 +41,22 @@ TEST_DATA_DIR=test test_unitester_SOURCES = test/unitester.cpp test_unitester_LDADD = libunivalue.la test_unitester_CXXFLAGS = -I$(top_srcdir)/include -DJSON_TEST_SRC=\"$(srcdir)/$(TEST_DATA_DIR)\" -test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) +test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) -lpthread test_test_json_SOURCES = test/test_json.cpp test_test_json_LDADD = libunivalue.la test_test_json_CXXFLAGS = -I$(top_srcdir)/include -test_test_json_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) +test_test_json_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) -lpthread test_no_nul_SOURCES = test/no_nul.cpp test_no_nul_LDADD = libunivalue.la test_no_nul_CXXFLAGS = -I$(top_srcdir)/include -test_no_nul_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) +test_no_nul_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) -lpthread test_object_SOURCES = test/object.cpp test_object_LDADD = libunivalue.la test_object_CXXFLAGS = -I$(top_srcdir)/include -test_object_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) +test_object_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) -lpthread TEST_FILES = \ $(TEST_DATA_DIR)/fail10.json \ diff --git a/depend/zcash/src/util.cpp b/depend/zcash/src/util.cpp index 82d705ea8..8c6f54aae 100644 --- a/depend/zcash/src/util.cpp +++ b/depend/zcash/src/util.cpp @@ -83,8 +83,6 @@ #include #include #include -#include -#include // Work around clang compilation problem in Boost 1.46: // /usr/include/boost/program_options/detail/config_file.hpp:163:17: error: call to function 'to_internal' that is neither visible in the template definition nor found by argument-dependent lookup @@ -102,244 +100,15 @@ using namespace std; const char * const BITCOIN_CONF_FILENAME = "zcash.conf"; const char * const BITCOIN_PID_FILENAME = "zcashd.pid"; -const char * const DEFAULT_DEBUGLOGFILE = "debug.log"; map mapArgs; map > mapMultiArgs; bool fDebug = false; -bool fPrintToConsole = false; -bool fPrintToDebugLog = true; bool fDaemon = false; bool fServer = false; -bool fLogTimestamps = DEFAULT_LOGTIMESTAMPS; -bool fLogTimeMicros = DEFAULT_LOGTIMEMICROS; -bool fLogIPs = DEFAULT_LOGIPS; -std::atomic fReopenDebugLog(false); CTranslationInterface translationInterface; -/** Init OpenSSL library multithreading support */ -static CCriticalSection** ppmutexOpenSSL; -void locking_callback(int mode, int i, const char* file, int line) NO_THREAD_SAFETY_ANALYSIS -{ - if (mode & CRYPTO_LOCK) { - ENTER_CRITICAL_SECTION(*ppmutexOpenSSL[i]); - } else { - LEAVE_CRITICAL_SECTION(*ppmutexOpenSSL[i]); - } -} - -// Init -static class CInit -{ -public: - CInit() - { - // Init OpenSSL library multithreading support - ppmutexOpenSSL = (CCriticalSection**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(CCriticalSection*)); - for (int i = 0; i < CRYPTO_num_locks(); i++) - ppmutexOpenSSL[i] = new CCriticalSection(); - CRYPTO_set_locking_callback(locking_callback); - - // OpenSSL can optionally load a config file which lists optional loadable modules and engines. - // We don't use them so we don't require the config. However some of our libs may call functions - // which attempt to load the config file, possibly resulting in an exit() or crash if it is missing - // or corrupt. Explicitly tell OpenSSL not to try to load the file. The result for our libs will be - // that the config appears to have been loaded and there are no modules/engines available. - OPENSSL_no_config(); - } - ~CInit() - { - // Shutdown OpenSSL library multithreading support - CRYPTO_set_locking_callback(NULL); - for (int i = 0; i < CRYPTO_num_locks(); i++) - delete ppmutexOpenSSL[i]; - OPENSSL_free(ppmutexOpenSSL); - } -} -instance_of_cinit; - -/** - * LogPrintf() has been broken a couple of times now - * by well-meaning people adding mutexes in the most straightforward way. - * It breaks because it may be called by global destructors during shutdown. - * Since the order of destruction of static/global objects is undefined, - * defining a mutex as a global object doesn't work (the mutex gets - * destroyed, and then some later destructor calls OutputDebugStringF, - * maybe indirectly, and you get a core dump at shutdown trying to lock - * the mutex). - */ - -static boost::once_flag debugPrintInitFlag = BOOST_ONCE_INIT; - -/** - * We use boost::call_once() to make sure mutexDebugLog and - * vMsgsBeforeOpenLog are initialized in a thread-safe manner. - * - * NOTE: fileout, mutexDebugLog and sometimes vMsgsBeforeOpenLog - * are leaked on exit. This is ugly, but will be cleaned up by - * the OS/libc. When the shutdown sequence is fully audited and - * tested, explicit destruction of these objects can be implemented. - */ -static FILE* fileout = NULL; -static boost::mutex* mutexDebugLog = NULL; -static list *vMsgsBeforeOpenLog; - -[[noreturn]] void new_handler_terminate() -{ - // Rather than throwing std::bad-alloc if allocation fails, terminate - // immediately to (try to) avoid chain corruption. - // Since LogPrintf may itself allocate memory, set the handler directly - // to terminate first. - std::set_new_handler(std::terminate); - fputs("Error: Out of memory. Terminating.\n", stderr); - LogPrintf("Error: Out of memory. Terminating.\n"); - - // The log was successful, terminate now. - std::terminate(); -}; - -static int FileWriteStr(const std::string &str, FILE *fp) -{ - return fwrite(str.data(), 1, str.size(), fp); -} - -static void DebugPrintInit() -{ - assert(mutexDebugLog == NULL); - mutexDebugLog = new boost::mutex(); - vMsgsBeforeOpenLog = new list; -} - -boost::filesystem::path GetDebugLogPath() -{ - boost::filesystem::path logfile(GetArg("-debuglogfile", DEFAULT_DEBUGLOGFILE)); - if (logfile.is_absolute()) { - return logfile; - } else { - return GetDataDir() / logfile; - } -} - -bool OpenDebugLog() -{ - boost::call_once(&DebugPrintInit, debugPrintInitFlag); - boost::mutex::scoped_lock scoped_lock(*mutexDebugLog); - - assert(fileout == NULL); - assert(vMsgsBeforeOpenLog); - - boost::filesystem::path pathDebug = GetDebugLogPath(); - fileout = fopen(pathDebug.string().c_str(), "a"); - if (!fileout) { - return false; - } - - setbuf(fileout, nullptr); // unbuffered - // dump buffered messages from before we opened the log - while (!vMsgsBeforeOpenLog->empty()) { - FileWriteStr(vMsgsBeforeOpenLog->front(), fileout); - vMsgsBeforeOpenLog->pop_front(); - } - - delete vMsgsBeforeOpenLog; - vMsgsBeforeOpenLog = NULL; - return true; -} - -bool LogAcceptCategory(const char* category) -{ - if (category != NULL) - { - if (!fDebug) - return false; - - // Give each thread quick access to -debug settings. - // This helps prevent issues debugging global destructors, - // where mapMultiArgs might be deleted before another - // global destructor calls LogPrint() - static boost::thread_specific_ptr > ptrCategory; - if (ptrCategory.get() == NULL) - { - const vector& categories = mapMultiArgs["-debug"]; - ptrCategory.reset(new set(categories.begin(), categories.end())); - // thread_specific_ptr automatically deletes the set when the thread ends. - } - const set& setCategories = *ptrCategory.get(); - - // if not debugging everything and not debugging specific category, LogPrint does nothing. - if (setCategories.count(string("")) == 0 && - setCategories.count(string("1")) == 0 && - setCategories.count(string(category)) == 0) - return false; - } - return true; -} - -/** - * fStartedNewLine is a state variable held by the calling context that will - * suppress printing of the timestamp when multiple calls are made that don't - * end in a newline. Initialize it to true, and hold it, in the calling context. - */ -static std::string LogTimestampStr(const std::string &str, bool *fStartedNewLine) -{ - string strStamped; - - if (!fLogTimestamps) - return str; - - if (*fStartedNewLine) - strStamped = DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()) + ' ' + str; - else - strStamped = str; - - if (!str.empty() && str[str.size()-1] == '\n') - *fStartedNewLine = true; - else - *fStartedNewLine = false; - - return strStamped; -} - -int LogPrintStr(const std::string &str) -{ - int ret = 0; // Returns total number of characters written - static bool fStartedNewLine = true; - if (fPrintToConsole) - { - // print to console - ret = fwrite(str.data(), 1, str.size(), stdout); - fflush(stdout); - } - else if (fPrintToDebugLog) - { - boost::call_once(&DebugPrintInit, debugPrintInitFlag); - boost::mutex::scoped_lock scoped_lock(*mutexDebugLog); - - string strTimestamped = LogTimestampStr(str, &fStartedNewLine); - - // buffer if we haven't opened the log yet - if (fileout == NULL) { - assert(vMsgsBeforeOpenLog); - ret = strTimestamped.length(); - vMsgsBeforeOpenLog->push_back(strTimestamped); - } - else - { - // reopen the log file, if requested - if (fReopenDebugLog) { - fReopenDebugLog = false; - boost::filesystem::path pathDebug = GetDebugLogPath(); - if (freopen(pathDebug.string().c_str(),"a",fileout) != NULL) - setbuf(fileout, NULL); // unbuffered - } - - ret = FileWriteStr(strTimestamped, fileout); - } - } - return ret; -} - /** Interpret string as boolean, for argument parsing */ static bool InterpretBool(const std::string& strValue) { @@ -502,7 +271,7 @@ static boost::filesystem::path pathCachedNetSpecific; static boost::filesystem::path zc_paramsPathCached; static CCriticalSection csPathCached; -static boost::filesystem::path ZC_GetBaseParamsDir() +static boost::filesystem::path ZC_GetDefaultBaseParamsDir() { // Copied from GetDefaultDataDir and adapter for zcash params. @@ -546,7 +315,14 @@ const boost::filesystem::path &ZC_GetParamsDir() if (!path.empty()) return path; - path = ZC_GetBaseParamsDir(); + if (mapArgs.count("-paramsdir")) { + path = fs::system_complete(mapArgs["-paramsdir"]); + if (!fs::is_directory(path)) { + throw std::runtime_error(strprintf("The -paramsdir '%s' does not exist or is not a directory", path.string())); + } + } else { + path = ZC_GetDefaultBaseParamsDir(); + } return path; } @@ -627,10 +403,38 @@ void ReadConfigFile(const std::string& confPath, set setOptions; setOptions.insert("*"); + const vector allowed_duplicates = { + "addnode", + "bind", + "connect", + "debug", + "externalip", + "fundingstream", + "loadblock", + "nuparams", + "onlynet", + "rpcallowip", + "rpcauth", + "rpcbind", + "seednode", + "uacomment", + "whitebind", + "whitelist" + }; + set unique_options; + for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it) { string strKey = string("-") + it->string_key; string strValue = it->value[0]; + + if (find(allowed_duplicates.begin(), allowed_duplicates.end(), it->string_key) == allowed_duplicates.end()) + { + if (!unique_options.insert(strKey).second) { + throw std::runtime_error(strprintf("Option '%s' is duplicated, which is not allowed.", strKey)); + } + } + InterpretNegativeSetting(strKey, strValue); // Don't overwrite existing settings so command line settings override zcash.conf if (mapSettingsRet.count(strKey) == 0) @@ -699,7 +503,7 @@ void FileCommit(FILE *fileout) #else #if defined(__linux__) || defined(__NetBSD__) fdatasync(fileno(fileout)); - #elif defined(__APPLE__) && defined(F_FULLFSYNC) + #elif defined(MAC_OSX) && defined(F_FULLFSYNC) fcntl(fileno(fileout), F_FULLFSYNC, 0); #else fsync(fileno(fileout)); @@ -784,30 +588,6 @@ void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) { #endif } -void ShrinkDebugFile() -{ - // Scroll debug.log if it's getting too big - boost::filesystem::path pathLog = GetDebugLogPath(); - FILE* file = fopen(pathLog.string().c_str(), "r"); - if (file && boost::filesystem::file_size(pathLog) > 10 * 1000000) - { - // Restart the file with some of the end - std::vector vch(200000,0); - fseek(file, -((long)vch.size()), SEEK_END); - int nBytes = fread(begin_ptr(vch), 1, vch.size(), file); - fclose(file); - - file = fopen(pathLog.string().c_str(), "w"); - if (file) - { - fwrite(begin_ptr(vch), 1, nBytes, file); - fclose(file); - } - } - else if (file != NULL) - fclose(file); -} - #ifdef WIN32 boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate) { @@ -929,9 +709,7 @@ std::string LicenseInfo() "\n" + FormatParagraph(_("This is experimental software.")) + "\n" + "\n" + - FormatParagraph(_("Distributed under the MIT software license, see the accompanying file COPYING or .")) + "\n" + - "\n" + - FormatParagraph(_("This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit and cryptographic software written by Eric Young.")) + + FormatParagraph(_("Distributed under the MIT software license, see the accompanying file COPYING or .")) + "\n"; } diff --git a/depend/zcash/src/util.h b/depend/zcash/src/util.h index d356cf8b4..77b9a5142 100644 --- a/depend/zcash/src/util.h +++ b/depend/zcash/src/util.h @@ -5,7 +5,7 @@ /** * Server/client environment: argument handling, config file parsing, - * logging, thread wrappers + * thread wrappers */ #ifndef BITCOIN_UTIL_H #define BITCOIN_UTIL_H @@ -15,6 +15,7 @@ #endif #include "compat.h" +#include "logging.h" #include "tinyformat.h" #include "utiltime.h" @@ -29,11 +30,6 @@ #include #include -static const bool DEFAULT_LOGTIMEMICROS = false; -static const bool DEFAULT_LOGIPS = false; -static const bool DEFAULT_LOGTIMESTAMPS = true; -extern const char * const DEFAULT_DEBUGLOGFILE; - /** Signals for translation. */ class CTranslationInterface { @@ -45,13 +41,8 @@ class CTranslationInterface extern std::map mapArgs; extern std::map > mapMultiArgs; extern bool fDebug; -extern bool fPrintToConsole; -extern bool fPrintToDebugLog; extern bool fServer; -extern bool fLogTimestamps; -extern bool fLogIPs; -extern std::atomic fReopenDebugLog; extern CTranslationInterface translationInterface; [[noreturn]] extern void new_handler_terminate(); @@ -72,48 +63,10 @@ inline std::string _(const char* psz) void SetupEnvironment(); bool SetupNetworking(); -/** Return true if log accepts specified category */ -bool LogAcceptCategory(const char* category); -/** Send a string to the log output */ -int LogPrintStr(const std::string &str); - -#define LogPrintf(...) LogPrint(NULL, __VA_ARGS__) - -/** - * When we switch to C++11, this can be switched to variadic templates instead - * of this macro-based construction (see tinyformat.h). - */ -#define MAKE_ERROR_AND_LOG_FUNC(n) \ - /** Print to debug.log if -debug=category switch is given OR category is NULL. */ \ - template \ - static inline int LogPrint(const char* category, const char* format, TINYFORMAT_VARARGS(n)) \ - { \ - if(!LogAcceptCategory(category)) return 0; \ - return LogPrintStr(tfm::format(format, TINYFORMAT_PASSARGS(n))); \ - } \ - /** Log error and return false */ \ - template \ - static inline bool error(const char* format, TINYFORMAT_VARARGS(n)) \ - { \ - LogPrintStr("ERROR: " + tfm::format(format, TINYFORMAT_PASSARGS(n)) + "\n"); \ - return false; \ - } - -TINYFORMAT_FOREACH_ARGNUM(MAKE_ERROR_AND_LOG_FUNC) - -/** - * Zero-arg versions of logging and error, these are not covered by - * TINYFORMAT_FOREACH_ARGNUM - */ -static inline int LogPrint(const char* category, const char* format) -{ - if(!LogAcceptCategory(category)) return 0; - return LogPrintStr(format); -} -static inline bool error(const char* format) +template +static inline bool error(const char* format, const Args&... args) { - LogPrintStr(std::string("ERROR: ") + format + "\n"); - return false; + return LogError("main", format, args...); } const boost::filesystem::path &ZC_GetParamsDir(); @@ -143,9 +96,6 @@ void ReadConfigFile(const std::string& confPath, std::map= std::numeric_limits::min() && diff --git a/depend/zcash/src/utiltest.cpp b/depend/zcash/src/utiltest.cpp index f00a9bcfa..2728764ef 100644 --- a/depend/zcash/src/utiltest.cpp +++ b/depend/zcash/src/utiltest.cpp @@ -9,7 +9,7 @@ #include -#include +#include // Sprout CMutableTransaction GetValidSproutReceiveTransaction( @@ -37,10 +37,8 @@ CMutableTransaction GetValidSproutReceiveTransaction( mtx.vin[1].prevout.n = 0; // Generate an ephemeral keypair. - uint256 joinSplitPubKey; - unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES]; - crypto_sign_keypair(joinSplitPubKey.begin(), joinSplitPrivKey); - mtx.joinSplitPubKey = joinSplitPubKey; + Ed25519SigningKey joinSplitPrivKey; + ed25519_generate_keypair(&joinSplitPrivKey, &mtx.joinSplitPubKey); std::array inputs = { libzcash::JSInput(), // dummy input @@ -74,10 +72,10 @@ CMutableTransaction GetValidSproutReceiveTransaction( uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId); // Add the signature - assert(crypto_sign_detached(&mtx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey - ) == 0); + assert(ed25519_sign( + &joinSplitPrivKey, + dataToBeSigned.begin(), 32, + &mtx.joinSplitSig)); return mtx; } @@ -141,10 +139,8 @@ CWalletTx GetValidSproutSpend(const libzcash::SproutSpendingKey& sk, mtx.vout[1].nValue = 0; // Generate an ephemeral keypair. - uint256 joinSplitPubKey; - unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES]; - crypto_sign_keypair(joinSplitPubKey.begin(), joinSplitPrivKey); - mtx.joinSplitPubKey = joinSplitPubKey; + Ed25519SigningKey joinSplitPrivKey; + ed25519_generate_keypair(&joinSplitPrivKey, &mtx.joinSplitPubKey); // Fake tree for the unused witness SproutMerkleTree tree; @@ -191,10 +187,10 @@ CWalletTx GetValidSproutSpend(const libzcash::SproutSpendingKey& sk, uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId); // Add the signature - assert(crypto_sign_detached(&mtx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey - ) == 0); + assert(ed25519_sign( + &joinSplitPrivKey, + dataToBeSigned.begin(), 32, + &mtx.joinSplitSig)); CTransaction tx {mtx}; CWalletTx wtx {NULL, tx}; return wtx; diff --git a/depend/zcash/src/validationinterface.cpp b/depend/zcash/src/validationinterface.cpp index e0e5dfd64..016f37d39 100644 --- a/depend/zcash/src/validationinterface.cpp +++ b/depend/zcash/src/validationinterface.cpp @@ -16,6 +16,8 @@ #include #include +using namespace boost::placeholders; + static CMainSignals g_signals; CMainSignals& GetMainSignals() @@ -29,7 +31,6 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) { g_signals.EraseTransaction.connect(boost::bind(&CValidationInterface::EraseFromWallet, pwalletIn, _1)); g_signals.UpdatedTransaction.connect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1)); g_signals.ChainTip.connect(boost::bind(&CValidationInterface::ChainTip, pwalletIn, _1, _2, _3)); - g_signals.SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1)); g_signals.Inventory.connect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1)); g_signals.Broadcast.connect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1)); g_signals.BlockChecked.connect(boost::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2)); @@ -44,7 +45,6 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) { g_signals.Broadcast.disconnect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1)); g_signals.Inventory.disconnect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1)); g_signals.ChainTip.disconnect(boost::bind(&CValidationInterface::ChainTip, pwalletIn, _1, _2, _3)); - g_signals.SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1)); g_signals.UpdatedTransaction.disconnect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1)); g_signals.EraseTransaction.disconnect(boost::bind(&CValidationInterface::EraseFromWallet, pwalletIn, _1)); g_signals.SyncTransaction.disconnect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2, _3)); @@ -58,7 +58,6 @@ void UnregisterAllValidationInterfaces() { g_signals.Broadcast.disconnect_all_slots(); g_signals.Inventory.disconnect_all_slots(); g_signals.ChainTip.disconnect_all_slots(); - g_signals.SetBestChain.disconnect_all_slots(); g_signals.UpdatedTransaction.disconnect_all_slots(); g_signals.EraseTransaction.disconnect_all_slots(); g_signals.SyncTransaction.disconnect_all_slots(); diff --git a/depend/zcash/src/validationinterface.h b/depend/zcash/src/validationinterface.h index 00aa882dc..ae129c179 100644 --- a/depend/zcash/src/validationinterface.h +++ b/depend/zcash/src/validationinterface.h @@ -38,7 +38,6 @@ class CValidationInterface { virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock, const int nHeight) {} virtual void EraseFromWallet(const uint256 &hash) {} virtual void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, std::optional> added) {} - virtual void SetBestChain(const CBlockLocator &locator) {} virtual void UpdatedTransaction(const uint256 &hash) {} virtual void Inventory(const uint256 &hash) {} virtual void ResendWalletTransactions(int64_t nBestBlockTime) {} @@ -61,8 +60,6 @@ struct CMainSignals { boost::signals2::signal UpdatedTransaction; /** Notifies listeners of a change to the tip of the active block chain. */ boost::signals2::signal>)> ChainTip; - /** Notifies listeners of a new active block chain. */ - boost::signals2::signal SetBestChain; /** Notifies listeners about an inventory item being seen on the network. */ boost::signals2::signal Inventory; /** Tells listeners to broadcast their data. */ diff --git a/depend/zcash/src/version.h b/depend/zcash/src/version.h index 971be1140..f8376bfb8 100644 --- a/depend/zcash/src/version.h +++ b/depend/zcash/src/version.h @@ -9,7 +9,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170011; +static const int PROTOCOL_VERSION = 170013; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; diff --git a/depend/zcash/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/depend/zcash/src/wallet/asyncrpcoperation_mergetoaddress.cpp index 181326727..2212c2413 100644 --- a/depend/zcash/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/depend/zcash/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -19,7 +19,6 @@ #include "rpc/protocol.h" #include "rpc/server.h" #include "script/interpreter.h" -#include "sodium.h" #include "timedata.h" #include "transaction_builder.h" #include "util.h" @@ -36,6 +35,8 @@ #include #include +#include + using namespace libzcash; int mta_find_output(UniValue obj, int n) @@ -256,8 +257,13 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() tx_ = CTransaction(rawTx); } - LogPrint(isPureTaddrOnlyTx ? "zrpc" : "zrpcunsafe", "%s: spending %s to send %s with fee %s\n", + if (isPureTaddrOnlyTx) { + LogPrint("zrpc", "%s: spending %s to send %s with fee %s\n", + getId(), FormatMoney(targetAmount), FormatMoney(sendAmount), FormatMoney(minersFee)); + } else { + LogPrint("zrpcunsafe", "%s: spending %s to send %s with fee %s\n", getId(), FormatMoney(targetAmount), FormatMoney(sendAmount), FormatMoney(minersFee)); + } LogPrint("zrpc", "%s: transparent input: %s\n", getId(), FormatMoney(t_inputs_total)); LogPrint("zrpcunsafe", "%s: private input: %s\n", getId(), FormatMoney(z_inputs_total)); if (isToTaddr_) { @@ -382,7 +388,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() // Prepare raw transaction to handle JoinSplits CMutableTransaction mtx(tx_); - crypto_sign_keypair(joinSplitPubKey_.begin(), joinSplitPrivKey_); + ed25519_generate_keypair(&joinSplitPrivKey_, &joinSplitPubKey_); mtx.joinSplitPubKey = joinSplitPubKey_; tx_ = CTransaction(mtx); std::string hexMemo = std::get<1>(recipient_); @@ -824,17 +830,21 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit( uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId_); // Add the signature - if (!(crypto_sign_detached(&mtx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey_) == 0)) { - throw std::runtime_error("crypto_sign_detached failed"); + if (!ed25519_sign( + &joinSplitPrivKey_, + dataToBeSigned.begin(), 32, + &mtx.joinSplitSig)) + { + throw std::runtime_error("ed25519_sign failed"); } // Sanity check - if (!(crypto_sign_verify_detached(&mtx.joinSplitSig[0], - dataToBeSigned.begin(), 32, - mtx.joinSplitPubKey.begin()) == 0)) { - throw std::runtime_error("crypto_sign_verify_detached failed"); + if (!ed25519_verify( + &mtx.joinSplitPubKey, + &mtx.joinSplitSig, + dataToBeSigned.begin(), 32)) + { + throw std::runtime_error("ed25519_verify failed"); } CTransaction rawTx(mtx); @@ -876,10 +886,6 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit( KeyIO keyIO(Params()); // !!! Payment disclosure START - unsigned char buffer[32] = {0}; - memcpy(&buffer[0], &joinSplitPrivKey_[0], 32); // private key in first half of 64 byte buffer - std::vector vch(&buffer[0], &buffer[0] + 32); - uint256 joinSplitPrivKey = uint256(vch); size_t js_index = tx_.vJoinSplit.size() - 1; uint256 placeholder; for (int i = 0; i < ZC_NUM_JS_OUTPUTS; i++) { @@ -888,7 +894,7 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit( PaymentDisclosureKey pdKey = {placeholder, js_index, mapped_index}; JSOutput output = outputs[mapped_index]; libzcash::SproutPaymentAddress zaddr = output.addr; // randomized output - PaymentDisclosureInfo pdInfo = {PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL, esk, joinSplitPrivKey, zaddr}; + PaymentDisclosureInfo pdInfo = {PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL, esk, joinSplitPrivKey_, zaddr}; paymentDisclosureData_.push_back(PaymentDisclosureKeyInfo(pdKey, pdInfo)); LogPrint("paymentdisclosure", "%s: Payment Disclosure: js=%d, n=%d, zaddr=%s\n", getId(), js_index, int(mapped_index), keyIO.EncodePaymentAddress(zaddr)); diff --git a/depend/zcash/src/wallet/asyncrpcoperation_mergetoaddress.h b/depend/zcash/src/wallet/asyncrpcoperation_mergetoaddress.h index e8476f37d..d2112f3be 100644 --- a/depend/zcash/src/wallet/asyncrpcoperation_mergetoaddress.h +++ b/depend/zcash/src/wallet/asyncrpcoperation_mergetoaddress.h @@ -19,9 +19,10 @@ #include #include -#include #include +#include + // Default transaction fee if caller does not specify one. #define MERGE_TO_ADDRESS_OPERATION_DEFAULT_MINERS_FEE 10000 @@ -97,8 +98,8 @@ class AsyncRPCOperation_mergetoaddress : public AsyncRPCOperation CTxDestination toTaddr_; PaymentAddress toPaymentAddress_; - uint256 joinSplitPubKey_; - unsigned char joinSplitPrivKey_[crypto_sign_SECRETKEYBYTES]; + Ed25519VerificationKey joinSplitPubKey_; + Ed25519SigningKey joinSplitPrivKey_; // The key is the result string from calling JSOutPoint::ToString() std::unordered_map jsopWitnessAnchorMap; diff --git a/depend/zcash/src/wallet/asyncrpcoperation_saplingmigration.cpp b/depend/zcash/src/wallet/asyncrpcoperation_saplingmigration.cpp index 10c85cbb5..89fa03cc6 100644 --- a/depend/zcash/src/wallet/asyncrpcoperation_saplingmigration.cpp +++ b/depend/zcash/src/wallet/asyncrpcoperation_saplingmigration.cpp @@ -71,7 +71,7 @@ void AsyncRPCOperation_saplingmigration::main() { bool AsyncRPCOperation_saplingmigration::main_impl() { LogPrint("zrpcunsafe", "%s: Beginning AsyncRPCOperation_saplingmigration.\n", getId()); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); auto nextActivationHeight = NextActivationHeight(targetHeight_, consensusParams); if (nextActivationHeight && targetHeight_ + MIGRATION_EXPIRY_DELTA >= nextActivationHeight.value()) { LogPrint("zrpcunsafe", "%s: Migration txs would be created before a NU activation but may expire after. Skipping this round.\n", getId()); diff --git a/depend/zcash/src/wallet/asyncrpcoperation_sendmany.cpp b/depend/zcash/src/wallet/asyncrpcoperation_sendmany.cpp index 9683c0472..3a8c8db3f 100644 --- a/depend/zcash/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/depend/zcash/src/wallet/asyncrpcoperation_sendmany.cpp @@ -27,7 +27,6 @@ #include "script/interpreter.h" #include "utiltime.h" #include "zcash/IncrementalMerkleTree.hpp" -#include "sodium.h" #include "miner.h" #include "wallet/paymentdisclosuredb.h" @@ -38,6 +37,8 @@ #include #include +#include + using namespace libzcash; int find_output(UniValue obj, int n) { @@ -90,8 +91,9 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany( KeyIO keyIO(Params()); + useanyutxo_ = fromAddress == "ANY_TADDR"; fromtaddr_ = keyIO.DecodeDestination(fromAddress); - isfromtaddr_ = IsValidDestination(fromtaddr_); + isfromtaddr_ = useanyutxo_ || IsValidDestination(fromtaddr_); isfromzaddr_ = false; if (!isfromtaddr_) { @@ -214,7 +216,8 @@ bool AsyncRPCOperation_sendmany::main_impl() { // When spending coinbase utxos, you can only specify a single zaddr as the change must go somewhere // and if there are multiple zaddrs, we don't know where to send it. if (isfromtaddr_) { - if (isSingleZaddrOutput) { + // Only select coinbase if we are spending from a single t-address to a single z-address. + if (!useanyutxo_ && isSingleZaddrOutput) { bool b = find_utxos(true); if (!b) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds, no UTXOs found for taddr from address."); @@ -223,7 +226,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { bool b = find_utxos(false); if (!b) { if (isMultipleZaddrOutput) { - throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any non-coinbase UTXOs to spend. Coinbase UTXOs can only be sent to a single zaddr recipient."); + throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any non-coinbase UTXOs to spend. Coinbase UTXOs can only be sent to a single zaddr recipient from a single taddr."); } else { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any non-coinbase UTXOs to spend."); } @@ -320,12 +323,8 @@ bool AsyncRPCOperation_sendmany::main_impl() { // update the transaction with these inputs if (isUsingBuilder_) { - CScript scriptPubKey = GetScriptForDestination(fromtaddr_); for (auto t : t_inputs_) { - uint256 txid = t.txid; - int vout = t.vout; - CAmount amount = t.amount; - builder_.AddTransparentInput(COutPoint(txid, vout), scriptPubKey, amount); + builder_.AddTransparentInput(COutPoint(t.txid, t.vout), t.scriptPubKey, t.amount); } } else { CMutableTransaction rawTx(tx_); @@ -340,8 +339,13 @@ bool AsyncRPCOperation_sendmany::main_impl() { } } - LogPrint((isfromtaddr_) ? "zrpc" : "zrpcunsafe", "%s: spending %s to send %s with fee %s\n", + if (isfromtaddr_) { + LogPrint("zrpc", "%s: spending %s to send %s with fee %s\n", getId(), FormatMoney(targetAmount), FormatMoney(sendAmount), FormatMoney(minersFee)); + } else { + LogPrint("zrpcunsafe", "%s: spending %s to send %s with fee %s\n", + getId(), FormatMoney(targetAmount), FormatMoney(sendAmount), FormatMoney(minersFee)); + } LogPrint("zrpc", "%s: transparent input: %s (to choose from)\n", getId(), FormatMoney(t_inputs_total)); LogPrint("zrpcunsafe", "%s: private input: %s (to choose from)\n", getId(), FormatMoney(z_inputs_total)); LogPrint("zrpc", "%s: transparent output: %s\n", getId(), FormatMoney(t_outputs_total)); @@ -505,7 +509,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { // Prepare raw transaction to handle JoinSplits CMutableTransaction mtx(tx_); - crypto_sign_keypair(joinSplitPubKey_.begin(), joinSplitPrivKey_); + ed25519_generate_keypair(&joinSplitPrivKey_, &joinSplitPubKey_); mtx.joinSplitPubKey = joinSplitPubKey_; tx_ = CTransaction(mtx); @@ -894,7 +898,9 @@ bool AsyncRPCOperation_sendmany::main_impl() { bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) { std::set destinations; - destinations.insert(fromtaddr_); + if (!useanyutxo_) { + destinations.insert(fromtaddr_); + } vector vecOutputs; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -927,8 +933,9 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) { continue; } + CScript scriptPubKey = out.tx->vout[out.i].scriptPubKey; CAmount nValue = out.tx->vout[out.i].nValue; - SendManyInputUTXO utxo(out.tx->GetHash(), out.i, nValue, isCoinbase); + SendManyInputUTXO utxo(out.tx->GetHash(), out.i, scriptPubKey, nValue, isCoinbase); t_inputs_.push_back(utxo); } @@ -1101,21 +1108,21 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit( uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId_); // Add the signature - if (!(crypto_sign_detached(&mtx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey_ - ) == 0)) + if (!ed25519_sign( + &joinSplitPrivKey_, + dataToBeSigned.begin(), 32, + &mtx.joinSplitSig)) { - throw std::runtime_error("crypto_sign_detached failed"); + throw std::runtime_error("ed25519_sign failed"); } // Sanity check - if (!(crypto_sign_verify_detached(&mtx.joinSplitSig[0], - dataToBeSigned.begin(), 32, - mtx.joinSplitPubKey.begin() - ) == 0)) + if (!ed25519_verify( + &mtx.joinSplitPubKey, + &mtx.joinSplitSig, + dataToBeSigned.begin(), 32)) { - throw std::runtime_error("crypto_sign_verify_detached failed"); + throw std::runtime_error("ed25519_verify failed"); } CTransaction rawTx(mtx); @@ -1157,10 +1164,6 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit( KeyIO keyIO(Params()); // !!! Payment disclosure START - unsigned char buffer[32] = {0}; - memcpy(&buffer[0], &joinSplitPrivKey_[0], 32); // private key in first half of 64 byte buffer - std::vector vch(&buffer[0], &buffer[0] + 32); - uint256 joinSplitPrivKey = uint256(vch); size_t js_index = tx_.vJoinSplit.size() - 1; uint256 placeholder; for (int i = 0; i < ZC_NUM_JS_OUTPUTS; i++) { @@ -1169,7 +1172,7 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit( PaymentDisclosureKey pdKey = {placeholder, js_index, mapped_index}; JSOutput output = outputs[mapped_index]; libzcash::SproutPaymentAddress zaddr = output.addr; // randomized output - PaymentDisclosureInfo pdInfo = {PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL, esk, joinSplitPrivKey, zaddr}; + PaymentDisclosureInfo pdInfo = {PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL, esk, joinSplitPrivKey_, zaddr}; paymentDisclosureData_.push_back(PaymentDisclosureKeyInfo(pdKey, pdInfo)); LogPrint("paymentdisclosure", "%s: Payment Disclosure: js=%d, n=%d, zaddr=%s\n", getId(), js_index, int(mapped_index), keyIO.EncodePaymentAddress(zaddr)); diff --git a/depend/zcash/src/wallet/asyncrpcoperation_sendmany.h b/depend/zcash/src/wallet/asyncrpcoperation_sendmany.h index 5f29bdee0..31e1de8d9 100644 --- a/depend/zcash/src/wallet/asyncrpcoperation_sendmany.h +++ b/depend/zcash/src/wallet/asyncrpcoperation_sendmany.h @@ -19,9 +19,10 @@ #include #include -#include #include +#include + // Default transaction fee if caller does not specify one. #define ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE 10000 @@ -41,11 +42,12 @@ class SendManyInputUTXO { public: uint256 txid; int vout; + CScript scriptPubKey; CAmount amount; bool coinbase; - SendManyInputUTXO(uint256 txid_, int vout_, CAmount amount_, bool coinbase_) : - txid(txid_), vout(vout_), amount(amount_), coinbase(coinbase_) {} + SendManyInputUTXO(uint256 txid_, int vout_, CScript scriptPubKey_, CAmount amount_, bool coinbase_) : + txid(txid_), vout(vout_), scriptPubKey(scriptPubKey_), amount(amount_), coinbase(coinbase_) {} }; class SendManyInputJSOP { @@ -111,14 +113,15 @@ class AsyncRPCOperation_sendmany : public AsyncRPCOperation { CAmount fee_; int mindepth_; std::string fromaddress_; + bool useanyutxo_; bool isfromtaddr_; bool isfromzaddr_; CTxDestination fromtaddr_; PaymentAddress frompaymentaddress_; SpendingKey spendingkey_; - - uint256 joinSplitPubKey_; - unsigned char joinSplitPrivKey_[crypto_sign_SECRETKEYBYTES]; + + Ed25519VerificationKey joinSplitPubKey_; + Ed25519SigningKey joinSplitPrivKey_; // The key is the result string from calling JSOutPoint::ToString() std::unordered_map jsopWitnessAnchorMap; diff --git a/depend/zcash/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/depend/zcash/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index 9ec5f92de..18b8ec84e 100644 --- a/depend/zcash/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/depend/zcash/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -27,7 +27,6 @@ #include "script/interpreter.h" #include "utiltime.h" #include "zcash/IncrementalMerkleTree.hpp" -#include "sodium.h" #include "miner.h" #include "wallet/paymentdisclosuredb.h" @@ -39,6 +38,8 @@ #include #include +#include + using namespace libzcash; static int find_output(UniValue obj, int n) { @@ -212,7 +213,7 @@ bool ShieldToAddress::operator()(const libzcash::SproutPaymentAddress &zaddr) co // Prepare raw transaction to handle JoinSplits CMutableTransaction mtx(m_op->tx_); - crypto_sign_keypair(m_op->joinSplitPubKey_.begin(), m_op->joinSplitPrivKey_); + ed25519_generate_keypair(&m_op->joinSplitPrivKey_, &m_op->joinSplitPubKey_); mtx.joinSplitPubKey = m_op->joinSplitPubKey_; m_op->tx_ = CTransaction(mtx); @@ -338,21 +339,21 @@ UniValue AsyncRPCOperation_shieldcoinbase::perform_joinsplit(ShieldCoinbaseJSInf uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId); // Add the signature - if (!(crypto_sign_detached(&mtx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey_ - ) == 0)) + if (!ed25519_sign( + &joinSplitPrivKey_, + dataToBeSigned.begin(), 32, + &mtx.joinSplitSig)) { - throw std::runtime_error("crypto_sign_detached failed"); + throw std::runtime_error("ed25519_sign failed"); } // Sanity check - if (!(crypto_sign_verify_detached(&mtx.joinSplitSig[0], - dataToBeSigned.begin(), 32, - mtx.joinSplitPubKey.begin() - ) == 0)) + if (!ed25519_verify( + &mtx.joinSplitPubKey, + &mtx.joinSplitSig, + dataToBeSigned.begin(), 32)) { - throw std::runtime_error("crypto_sign_verify_detached failed"); + throw std::runtime_error("ed25519_verify failed"); } CTransaction rawTx(mtx); @@ -394,10 +395,6 @@ UniValue AsyncRPCOperation_shieldcoinbase::perform_joinsplit(ShieldCoinbaseJSInf KeyIO keyIO(Params()); // !!! Payment disclosure START - unsigned char buffer[32] = {0}; - memcpy(&buffer[0], &joinSplitPrivKey_[0], 32); // private key in first half of 64 byte buffer - std::vector vch(&buffer[0], &buffer[0] + 32); - uint256 joinSplitPrivKey = uint256(vch); size_t js_index = tx_.vJoinSplit.size() - 1; uint256 placeholder; for (int i = 0; i < ZC_NUM_JS_OUTPUTS; i++) { @@ -406,7 +403,7 @@ UniValue AsyncRPCOperation_shieldcoinbase::perform_joinsplit(ShieldCoinbaseJSInf PaymentDisclosureKey pdKey = {placeholder, js_index, mapped_index}; JSOutput output = outputs[mapped_index]; libzcash::SproutPaymentAddress zaddr = output.addr; // randomized output - PaymentDisclosureInfo pdInfo = {PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL, esk, joinSplitPrivKey, zaddr}; + PaymentDisclosureInfo pdInfo = {PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL, esk, joinSplitPrivKey_, zaddr}; paymentDisclosureData_.push_back(PaymentDisclosureKeyInfo(pdKey, pdInfo)); LogPrint("paymentdisclosure", "%s: Payment Disclosure: js=%d, n=%d, zaddr=%s\n", getId(), js_index, int(mapped_index), keyIO.EncodePaymentAddress(zaddr)); diff --git a/depend/zcash/src/wallet/asyncrpcoperation_shieldcoinbase.h b/depend/zcash/src/wallet/asyncrpcoperation_shieldcoinbase.h index 8f0350b4f..7d60737ab 100644 --- a/depend/zcash/src/wallet/asyncrpcoperation_shieldcoinbase.h +++ b/depend/zcash/src/wallet/asyncrpcoperation_shieldcoinbase.h @@ -17,9 +17,10 @@ #include #include -#include #include +#include + // Default transaction fee if caller does not specify one. #define SHIELD_COINBASE_DEFAULT_MINERS_FEE 10000 @@ -75,8 +76,8 @@ class AsyncRPCOperation_shieldcoinbase : public AsyncRPCOperation { CAmount fee_; PaymentAddress tozaddr_; - uint256 joinSplitPubKey_; - unsigned char joinSplitPrivKey_[crypto_sign_SECRETKEYBYTES]; + Ed25519VerificationKey joinSplitPubKey_; + Ed25519SigningKey joinSplitPrivKey_; std::vector inputs_; diff --git a/depend/zcash/src/wallet/gtest/test_paymentdisclosure.cpp b/depend/zcash/src/wallet/gtest/test_paymentdisclosure.cpp index 9e655d56a..8dfb48bd2 100644 --- a/depend/zcash/src/wallet/gtest/test_paymentdisclosure.cpp +++ b/depend/zcash/src/wallet/gtest/test_paymentdisclosure.cpp @@ -21,12 +21,12 @@ #include "wallet/paymentdisclosure.h" #include "wallet/paymentdisclosuredb.h" -#include "sodium.h" - #include #include #include +#include + using namespace std; /* @@ -97,14 +97,9 @@ TEST(paymentdisclosure, mainnet) { for (int i=0; i vch(&buffer[0], &buffer[0] + 32); - uint256 joinSplitPrivKey = uint256(vch); + Ed25519SigningKey joinSplitPrivKey; + Ed25519VerificationKey joinSplitPubKey; + ed25519_generate_keypair(&joinSplitPrivKey, &joinSplitPubKey); // Create payment disclosure key and info data to store in test database size_t js = GetRandHash().GetCheapHash() % std::numeric_limits::max(); @@ -123,7 +118,7 @@ TEST(paymentdisclosure, mainnet) { // Modify this local variable and confirm it no longer matches info2.esk = GetRandHash(); - info2.joinSplitPrivKey = GetRandHash(); + GetRandBytes(info2.joinSplitPrivKey.bytes, ED25519_VERIFICATION_KEY_LEN); info2.zaddr = libzcash::SproutSpendingKey::random().address(); ASSERT_NE(info, info2); @@ -141,33 +136,29 @@ TEST(paymentdisclosure, mainnet) { uint256 dataToBeSigned = SerializeHash(payload, SER_GETHASH, 0); // Compute the payload signature - unsigned char payloadSig[64]; - if (!(crypto_sign_detached(&payloadSig[0], NULL, + Ed25519Signature payloadSig; + if (!ed25519_sign( + &joinSplitPrivKey, dataToBeSigned.begin(), 32, - &buffer[0] // buffer containing both private and public key required - ) == 0)) + &payloadSig)) { - throw std::runtime_error("crypto_sign_detached failed"); + throw std::runtime_error("ed25519_sign failed"); } // Sanity check - if (!(crypto_sign_verify_detached(&payloadSig[0], - dataToBeSigned.begin(), 32, - joinSplitPubKey.begin() - ) == 0)) + if (!ed25519_verify( + &joinSplitPubKey, + &payloadSig, + dataToBeSigned.begin(), 32)) { - throw std::runtime_error("crypto_sign_verify_detached failed"); + throw std::runtime_error("ed25519_verify failed"); } - // Convert signature buffer to boost array - std::array arrayPayloadSig; - memcpy(arrayPayloadSig.data(), &payloadSig[0], 64); - // Payment disclosure blob to pass around - PaymentDisclosure pd = {payload, arrayPayloadSig}; + PaymentDisclosure pd = {payload, payloadSig}; // Test payment disclosure constructors - PaymentDisclosure pd2(payload, arrayPayloadSig); + PaymentDisclosure pd2(payload, payloadSig); ASSERT_EQ(pd, pd2); PaymentDisclosure pd3(joinSplitPubKey, key, info, payload.message); ASSERT_EQ(pd, pd3); diff --git a/depend/zcash/src/wallet/gtest/test_wallet.cpp b/depend/zcash/src/wallet/gtest/test_wallet.cpp index 0e22f910d..45e5cb7b0 100644 --- a/depend/zcash/src/wallet/gtest/test_wallet.cpp +++ b/depend/zcash/src/wallet/gtest/test_wallet.cpp @@ -1,6 +1,5 @@ #include #include -#include #include "base58.h" #include "chainparams.h" diff --git a/depend/zcash/src/wallet/gtest/test_wallet_zkeys.cpp b/depend/zcash/src/wallet/gtest/test_wallet_zkeys.cpp index baa4a0d98..fc3580c1b 100644 --- a/depend/zcash/src/wallet/gtest/test_wallet_zkeys.cpp +++ b/depend/zcash/src/wallet/gtest/test_wallet_zkeys.cpp @@ -336,7 +336,6 @@ TEST(WalletZkeysTest, WriteViewingKeyDirectToDB) { /** * This test covers methods on CWalletDB to load/save crypted z keys. */ -/* TODO: Uncomment during PR for #3388 TEST(WalletZkeysTest, WriteCryptedzkeyDirectToDb) { SelectParams(CBaseChainParams::TESTNET); diff --git a/depend/zcash/src/wallet/paymentdisclosure.cpp b/depend/zcash/src/wallet/paymentdisclosure.cpp index fa28ec20d..7c1e77be8 100644 --- a/depend/zcash/src/wallet/paymentdisclosure.cpp +++ b/depend/zcash/src/wallet/paymentdisclosure.cpp @@ -7,7 +7,7 @@ #include "key_io.h" #include "util.h" -#include +#include std::string PaymentDisclosureInfo::ToString() const { KeyIO keyIO(Params()); @@ -16,7 +16,7 @@ std::string PaymentDisclosureInfo::ToString() const { } std::string PaymentDisclosure::ToString() const { - std::string s = HexStr(payloadSig.begin(), payloadSig.end()); + std::string s = HexStr(payloadSig.bytes, payloadSig.bytes + ED25519_SIGNATURE_LEN); return strprintf("PaymentDisclosure(payload=%s, payloadSig=%s)", payload.ToString(), s); } @@ -26,7 +26,11 @@ std::string PaymentDisclosurePayload::ToString() const { version, esk.ToString(), txid.ToString(), js, n, keyIO.EncodePaymentAddress(zaddr), message); } -PaymentDisclosure::PaymentDisclosure(const uint256 &joinSplitPubKey, const PaymentDisclosureKey &key, const PaymentDisclosureInfo &info, const std::string &message) +PaymentDisclosure::PaymentDisclosure( + const Ed25519VerificationKey& joinSplitPubKey, + const PaymentDisclosureKey& key, + const PaymentDisclosureInfo& info, + const std::string& message) { // Populate payload member variable payload.version = info.version; // experimental = 0, production = 1 etc. @@ -42,28 +46,24 @@ PaymentDisclosure::PaymentDisclosure(const uint256 &joinSplitPubKey, const Payme LogPrint("paymentdisclosure", "Payment Disclosure: signing raw payload = %s\n", dataToBeSigned.ToString()); - // Prepare buffer to store ed25519 key pair in libsodium-compatible format - unsigned char bufferKeyPair[64]; - memcpy(&bufferKeyPair[0], info.joinSplitPrivKey.begin(), 32); - memcpy(&bufferKeyPair[32], joinSplitPubKey.begin(), 32); - // Compute payload signature member variable - if (!(crypto_sign_detached(payloadSig.data(), NULL, - dataToBeSigned.begin(), 32, - &bufferKeyPair[0] - ) == 0)) + if (!ed25519_sign( + &info.joinSplitPrivKey, + dataToBeSigned.begin(), 32, + &payloadSig)) { - throw std::runtime_error("crypto_sign_detached failed"); + throw std::runtime_error("ed25519_sign failed"); } // Sanity check - if (!(crypto_sign_verify_detached(payloadSig.data(), - dataToBeSigned.begin(), 32, - joinSplitPubKey.begin()) == 0)) + if (!ed25519_verify( + &joinSplitPubKey, + &payloadSig, + dataToBeSigned.begin(), 32)) { - throw std::runtime_error("crypto_sign_verify_detached failed"); + throw std::runtime_error("ed25519_verify failed"); } - std::string sigString = HexStr(payloadSig.data(), payloadSig.data() + payloadSig.size()); + std::string sigString = HexStr(payloadSig.bytes, payloadSig.bytes + ED25519_SIGNATURE_LEN); LogPrint("paymentdisclosure", "Payment Disclosure: signature = %s\n", sigString); } diff --git a/depend/zcash/src/wallet/paymentdisclosure.h b/depend/zcash/src/wallet/paymentdisclosure.h index 2233c8820..0b0b53ecf 100644 --- a/depend/zcash/src/wallet/paymentdisclosure.h +++ b/depend/zcash/src/wallet/paymentdisclosure.h @@ -18,6 +18,8 @@ #include #include +#include + // Ensure that the two different protocol messages, payment disclosure blobs and transactions, // which are signed with the same key, joinSplitPrivKey, have disjoint encodings such that an @@ -36,7 +38,7 @@ typedef JSOutPoint PaymentDisclosureKey; struct PaymentDisclosureInfo { uint8_t version; // 0 = experimental, 1 = first production version, etc. uint256 esk; // zcash/NoteEncryption.cpp - uint256 joinSplitPrivKey; // primitives/transaction.h + Ed25519SigningKey joinSplitPrivKey; // primitives/transaction.h // ed25519 - not tied to implementation e.g. libsodium, see ed25519 rfc libzcash::SproutPaymentAddress zaddr; @@ -44,7 +46,7 @@ struct PaymentDisclosureInfo { PaymentDisclosureInfo() : version(PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL) { } - PaymentDisclosureInfo(uint8_t v, uint256 esk, uint256 key, libzcash::SproutPaymentAddress zaddr) : version(v), esk(esk), joinSplitPrivKey(key), zaddr(zaddr) { } + PaymentDisclosureInfo(uint8_t v, uint256 esk, Ed25519SigningKey key, libzcash::SproutPaymentAddress zaddr) : version(v), esk(esk), joinSplitPrivKey(key), zaddr(zaddr) { } ADD_SERIALIZE_METHODS; @@ -59,7 +61,14 @@ struct PaymentDisclosureInfo { std::string ToString() const; friend bool operator==(const PaymentDisclosureInfo& a, const PaymentDisclosureInfo& b) { - return (a.version == b.version && a.esk == b.esk && a.joinSplitPrivKey == b.joinSplitPrivKey && a.zaddr == b.zaddr); + return ( + a.version == b.version && + a.esk == b.esk && + std::equal( + a.joinSplitPrivKey.bytes, + a.joinSplitPrivKey.bytes + ED25519_SIGNING_KEY_LEN, + b.joinSplitPrivKey.bytes) && + a.zaddr == b.zaddr); } friend bool operator!=(const PaymentDisclosureInfo& a, const PaymentDisclosureInfo& b) { @@ -114,12 +123,16 @@ struct PaymentDisclosurePayload { struct PaymentDisclosure { PaymentDisclosurePayload payload; - std::array payloadSig; + Ed25519Signature payloadSig; // We use boost array because serialize doesn't like char buffer, otherwise we could do: unsigned char payloadSig[64]; PaymentDisclosure() {}; - PaymentDisclosure(const PaymentDisclosurePayload payload, const std::array sig) : payload(payload), payloadSig(sig) {}; - PaymentDisclosure(const uint256& joinSplitPubKey, const PaymentDisclosureKey& key, const PaymentDisclosureInfo& info, const std::string& message); + PaymentDisclosure(const PaymentDisclosurePayload payload, const Ed25519Signature sig) : payload(payload), payloadSig(sig) {}; + PaymentDisclosure( + const Ed25519VerificationKey& joinSplitPubKey, + const PaymentDisclosureKey& key, + const PaymentDisclosureInfo& info, + const std::string& message); ADD_SERIALIZE_METHODS; @@ -132,7 +145,13 @@ struct PaymentDisclosure { std::string ToString() const; friend bool operator==(const PaymentDisclosure& a, const PaymentDisclosure& b) { - return (a.payload == b.payload && a.payloadSig == b.payloadSig); + return ( + a.payload == b.payload && + std::equal( + a.payloadSig.bytes, + a.payloadSig.bytes + ED25519_SIGNATURE_LEN, + b.payloadSig.bytes) + ); } friend bool operator!=(const PaymentDisclosure& a, const PaymentDisclosure& b) { diff --git a/depend/zcash/src/wallet/rpcdisclosure.cpp b/depend/zcash/src/wallet/rpcdisclosure.cpp index 163feea6b..dc30181cc 100644 --- a/depend/zcash/src/wallet/rpcdisclosure.cpp +++ b/depend/zcash/src/wallet/rpcdisclosure.cpp @@ -23,12 +23,13 @@ #include #include -#include #include #include "zcash/Note.hpp" #include "zcash/NoteEncryption.hpp" +#include + using namespace std; using namespace libzcash; @@ -240,13 +241,22 @@ UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp) o.pushKV("version", pd.payload.version); o.pushKV("onetimePrivKey", pd.payload.esk.ToString()); o.pushKV("message", pd.payload.message); - o.pushKV("joinSplitPubKey", tx.joinSplitPubKey.ToString()); + + // Copy joinSplitPubKey into a uint256 so that + // it is byte-flipped in the RPC output. + uint256 joinSplitPubKey; + std::copy( + tx.joinSplitPubKey.bytes, + tx.joinSplitPubKey.bytes + ED25519_VERIFICATION_KEY_LEN, + joinSplitPubKey.begin()); + o.pushKV("joinSplitPubKey", joinSplitPubKey.ToString()); // Verify the payment disclosure was signed using the same key as the transaction i.e. the joinSplitPrivKey. uint256 dataToBeSigned = SerializeHash(pd.payload, SER_GETHASH, 0); - bool sigVerified = (crypto_sign_verify_detached(pd.payloadSig.data(), - dataToBeSigned.begin(), 32, - tx.joinSplitPubKey.begin()) == 0); + bool sigVerified = ed25519_verify( + &tx.joinSplitPubKey, + &pd.payloadSig, + dataToBeSigned.begin(), 32); o.pushKV("signatureVerified", sigVerified); if (!sigVerified) { errs.push_back("Payment disclosure signature does not match transaction signature"); diff --git a/depend/zcash/src/wallet/rpcwallet.cpp b/depend/zcash/src/wallet/rpcwallet.cpp index dc15a7e2c..961864018 100644 --- a/depend/zcash/src/wallet/rpcwallet.cpp +++ b/depend/zcash/src/wallet/rpcwallet.cpp @@ -34,8 +34,6 @@ #include "wallet/asyncrpcoperation_sendmany.h" #include "wallet/asyncrpcoperation_shieldcoinbase.h" -#include "sodium.h" - #include #include @@ -47,6 +45,8 @@ #include #include +#include + using namespace std; using namespace libzcash; @@ -87,6 +87,13 @@ void EnsureWalletIsUnlocked() throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); } +void ThrowIfInitialBlockDownload() +{ + if (IsInitialBlockDownload(Params())) { + throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Error: Sending transactions is not supported during initial block download."); + } +} + void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) { int confirms = wtx.GetDepthInMainChain(); @@ -2333,6 +2340,8 @@ UniValue settxfee(const UniValue& params, bool fHelp) return true; } +CAmount getBalanceZaddr(std::string address, int minDepth = 1, int maxDepth = INT_MAX, bool ignoreUnspendable=true); + UniValue getwalletinfo(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) @@ -2348,6 +2357,8 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp) " \"balance\": xxxxxxx, (numeric) the total confirmed transparent balance of the wallet in " + CURRENCY_UNIT + "\n" " \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed transparent balance of the wallet in " + CURRENCY_UNIT + "\n" " \"immature_balance\": xxxxxx, (numeric) the total immature transparent balance of the wallet in " + CURRENCY_UNIT + "\n" + " \"shielded_balance\": xxxxxxx, (numeric) the total confirmed shielded balance of the wallet in " + CURRENCY_UNIT + "\n" + " \"shielded_unconfirmed_balance\": xxx, (numeric) the total unconfirmed shielded balance of the wallet in " + CURRENCY_UNIT + "\n" " \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n" " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n" " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n" @@ -2367,6 +2378,8 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp) obj.pushKV("balance", ValueFromAmount(pwalletMain->GetBalance())); obj.pushKV("unconfirmed_balance", ValueFromAmount(pwalletMain->GetUnconfirmedBalance())); obj.pushKV("immature_balance", ValueFromAmount(pwalletMain->GetImmatureBalance())); + obj.pushKV("shielded_balance", FormatMoney(getBalanceZaddr("", 1, INT_MAX))); + obj.pushKV("shielded_unconfirmed_balance", FormatMoney(getBalanceZaddr("", 0, 0))); obj.pushKV("txcount", (int)pwalletMain->mapWallet.size()); obj.pushKV("keypoololdest", pwalletMain->GetOldestKeyPoolTime()); obj.pushKV("keypoolsize", (int)pwalletMain->GetKeyPoolSize()); @@ -2631,11 +2644,11 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) // User did not provide zaddrs, so use default i.e. all addresses std::set sproutzaddrs = {}; pwalletMain->GetSproutPaymentAddresses(sproutzaddrs); - + // Sapling support std::set saplingzaddrs = {}; pwalletMain->GetSaplingPaymentAddresses(saplingzaddrs); - + zaddrs.insert(sproutzaddrs.begin(), sproutzaddrs.end()); zaddrs.insert(saplingzaddrs.begin(), saplingzaddrs.end()); } @@ -2647,7 +2660,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) std::vector saplingEntries; pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, zaddrs, nMinDepth, nMaxDepth, true, !fIncludeWatchonly, false); std::set> nullifierSet = pwalletMain->GetNullifiersForAddresses(zaddrs); - + for (auto & entry : sproutEntries) { UniValue obj(UniValue::VOBJ); obj.pushKV("txid", entry.jsop.hash.ToString()); @@ -2762,7 +2775,7 @@ UniValue zc_sample_joinsplit(const UniValue& params, bool fHelp) LOCK(cs_main); - uint256 joinSplitPubKey; + Ed25519VerificationKey joinSplitPubKey; uint256 anchor = SproutMerkleTree().root(); auto samplejoinsplit = JSDescriptionInfo(joinSplitPubKey, anchor, @@ -3043,11 +3056,12 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp) const bool canopyActive = Params().GetConsensus().NetworkUpgradeActive(nextBlockHeight, Consensus::UPGRADE_CANOPY); - if (params[3].get_real() != 0.0) + if (params[3].get_real() != 0.0) { if (canopyActive) { throw JSONRPCError(RPC_VERIFY_REJECTED, "Sprout shielding is not supported after Canopy"); } vpub_old = AmountFromValue(params[3]); + } if (params[4].get_real() != 0.0) vpub_new = AmountFromValue(params[4]); @@ -3129,9 +3143,9 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp) throw runtime_error("unsupported joinsplit input/output counts"); } - uint256 joinSplitPubKey; - unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES]; - crypto_sign_keypair(joinSplitPubKey.begin(), joinSplitPrivKey); + Ed25519VerificationKey joinSplitPubKey; + Ed25519SigningKey joinSplitPrivKey; + ed25519_generate_keypair(&joinSplitPrivKey, &joinSplitPubKey); CMutableTransaction mtx(tx); mtx.nVersion = 4; @@ -3159,16 +3173,16 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp) uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId); // Add the signature - assert(crypto_sign_detached(&mtx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey - ) == 0); + assert(ed25519_sign( + &joinSplitPrivKey, + dataToBeSigned.begin(), 32, + &mtx.joinSplitSig)); // Sanity check - assert(crypto_sign_verify_detached(&mtx.joinSplitSig[0], - dataToBeSigned.begin(), 32, - mtx.joinSplitPubKey.begin() - ) == 0); + assert(ed25519_verify( + &mtx.joinSplitPubKey, + &mtx.joinSplitSig, + dataToBeSigned.begin(), 32)); CTransaction rawTx(mtx); @@ -3374,12 +3388,19 @@ CAmount getBalanceTaddr(std::string transparentAddress, int minDepth=1, bool ign return balance; } -CAmount getBalanceZaddr(std::string address, int minDepth = 1, bool ignoreUnspendable=true) { +CAmount getBalanceZaddr(std::string address, int minDepth, int maxDepth, bool ignoreUnspendable) { CAmount balance = 0; std::vector sproutEntries; std::vector saplingEntries; LOCK2(cs_main, pwalletMain->cs_wallet); - pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, address, minDepth, true, ignoreUnspendable); + + std::set filterAddresses; + if (address.length() > 0) { + KeyIO keyIO(Params()); + filterAddresses.insert(keyIO.DecodePaymentAddress(address)); + } + + pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, filterAddresses, minDepth, maxDepth, true, ignoreUnspendable); for (auto & entry : sproutEntries) { balance += CAmount(entry.note.value()); } @@ -3576,7 +3597,7 @@ UniValue z_getbalance(const UniValue& params, bool fHelp) if (fromTaddr) { nBalance = getBalanceTaddr(fromaddress, nMinDepth, false); } else { - nBalance = getBalanceZaddr(fromaddress, nMinDepth, false); + nBalance = getBalanceZaddr(fromaddress, nMinDepth, INT_MAX, false); } // inZat @@ -3638,7 +3659,7 @@ UniValue z_gettotalbalance(const UniValue& params, bool fHelp) // pwalletMain->GetBalance() does not accept min depth parameter // so we use our own method to get balance of utxos. CAmount nBalance = getBalanceTaddr("", nMinDepth, !fIncludeWatchonly); - CAmount nPrivateBalance = getBalanceZaddr("", nMinDepth, !fIncludeWatchonly); + CAmount nPrivateBalance = getBalanceZaddr("", nMinDepth, INT_MAX, !fIncludeWatchonly); CAmount nTotalBalance = nBalance + nPrivateBalance; UniValue result(UniValue::VOBJ); result.pushKV("transparent", FormatMoney(nBalance)); @@ -3805,7 +3826,10 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp) auto wtxPrev = pwalletMain->mapWallet.at(op.hash); // We don't need to check the leadbyte here: if wtx exists in - // the wallet, it must have already passed the leadbyte check + // the wallet, it must have been successfully decrypted. This + // means the plaintext leadbyte was valid at the block height + // where the note was received. + // https://zips.z.cash/zip-0212#changes-to-the-process-of-receiving-sapling-notes auto decrypted = wtxPrev.DecryptSaplingNoteWithoutLeadByteCheck(op).value(); auto notePt = decrypted.first; auto pa = decrypted.second; @@ -3835,7 +3859,10 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp) bool isOutgoing; // We don't need to check the leadbyte here: if wtx exists in - // the wallet, it must have already passed the leadbyte check + // the wallet, it must have been successfully decrypted. This + // means the plaintext leadbyte was valid at the block height + // where the note was received. + // https://zips.z.cash/zip-0212#changes-to-the-process-of-receiving-sapling-notes auto decrypted = wtx.DecryptSaplingNoteWithoutLeadByteCheck(op); if (decrypted) { notePt = decrypted->first; @@ -3997,12 +4024,17 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) throw runtime_error( "z_sendmany \"fromaddress\" [{\"address\":... ,\"amount\":...},...] ( minconf ) ( fee )\n" "\nSend multiple times. Amounts are decimal numbers with at most 8 digits of precision." - "\nChange generated from a taddr flows to a new taddr address, while change generated from a zaddr returns to itself." - "\nWhen sending coinbase UTXOs to a zaddr, change is not allowed. The entire value of the UTXO(s) must be consumed." + "\nChange generated from one or more transparent addresses flows to a new transparent" + "\naddress, while change generated from a shielded address returns to itself." + "\nWhen sending coinbase UTXOs to a shielded address, change is not allowed." + "\nThe entire value of the UTXO(s) must be consumed." + strprintf("\nBefore Sapling activates, the maximum number of zaddr outputs is %d due to transaction size limits.\n", Z_SENDMANY_MAX_ZADDR_OUTPUTS_BEFORE_SAPLING) + HelpRequiringPassphrase() + "\n" "\nArguments:\n" - "1. \"fromaddress\" (string, required) The taddr or zaddr to send the funds from.\n" + "1. \"fromaddress\" (string, required) The transparent or shielded address to send the funds from.\n" + " The following special strings are also accepted:\n" + " - \"ANY_TADDR\": Select non-coinbase UTXOs from any transparent addresses belonging to the wallet.\n" + " Use z_shieldcoinbase to shield coinbase UTXOs from multiple transparent addresses.\n" "2. \"amounts\" (array, required) An array of json objects representing the amounts to send.\n" " [{\n" " \"address\":address (string, required) The address is a taddr or zaddr\n" @@ -4015,33 +4047,40 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) "\nResult:\n" "\"operationid\" (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n" "\nExamples:\n" - + HelpExampleCli("z_sendmany", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" '[{\"address\": \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\" ,\"amount\": 5.0}]'") - + HelpExampleRpc("z_sendmany", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", [{\"address\": \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\" ,\"amount\": 5.0}]") + + HelpExampleCli("z_sendmany", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" '[{\"address\": \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\", \"amount\": 5.0}]'") + + HelpExampleCli("z_sendmany", "\"ANY_TADDR\" '[{\"address\": \"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", \"amount\": 2.0}]'") + + HelpExampleRpc("z_sendmany", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", [{\"address\": \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\", \"amount\": 5.0}]") ); LOCK2(cs_main, pwalletMain->cs_wallet); + ThrowIfInitialBlockDownload(); + // Check that the from address is valid. auto fromaddress = params[0].get_str(); bool fromTaddr = false; bool fromSapling = false; KeyIO keyIO(Params()); - CTxDestination taddr = keyIO.DecodeDestination(fromaddress); - fromTaddr = IsValidDestination(taddr); - if (!fromTaddr) { - auto res = keyIO.DecodePaymentAddress(fromaddress); - if (!IsValidPaymentAddress(res)) { - // invalid - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid from address, should be a taddr or zaddr."); - } + if (fromaddress == "ANY_TADDR") { + fromTaddr = true; + } else { + CTxDestination taddr = keyIO.DecodeDestination(fromaddress); + fromTaddr = IsValidDestination(taddr); + if (!fromTaddr) { + auto res = keyIO.DecodePaymentAddress(fromaddress); + if (!IsValidPaymentAddress(res)) { + // invalid + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid from address, should be a taddr or zaddr."); + } - // Check that we have the spending key - if (!std::visit(HaveSpendingKeyForPaymentAddress(pwalletMain), res)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, zaddr spending key not found."); - } + // Check that we have the spending key + if (!std::visit(HaveSpendingKeyForPaymentAddress(pwalletMain), res)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, zaddr spending key not found."); + } - // Remember whether this is a Sprout or Sapling address - fromSapling = std::get_if(&res) != nullptr; + // Remember whether this is a Sprout or Sapling address + fromSapling = std::get_if(&res) != nullptr; + } } // This logic will need to be updated if we add a new shielded pool bool fromSprout = !(fromTaddr || fromSapling); @@ -4268,7 +4307,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight); bool isShielded = !fromTaddr || zaddrRecipients.size() > 0; if (contextualTx.nVersion == 1 && isShielded) { - contextualTx.nVersion = 2; // Tx format should support vJoinSplits + contextualTx.nVersion = 2; // Tx format should support vJoinSplits } // Create operation and add to global queue @@ -4458,6 +4497,8 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); + ThrowIfInitialBlockDownload(); + // Validate the from address auto fromaddress = params[0].get_str(); bool isFromWildcard = fromaddress == "*"; @@ -4612,7 +4653,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction( Params().GetConsensus(), nextBlockHeight); if (contextualTx.nVersion == 1) { - contextualTx.nVersion = 2; // Tx format should support vJoinSplit + contextualTx.nVersion = 2; // Tx format should support vJoinSplit } // Create operation and add to global queue @@ -4694,6 +4735,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); + ThrowIfInitialBlockDownload(); + bool useAnyUTXO = false; bool useAnySprout = false; bool useAnySapling = false; diff --git a/depend/zcash/src/wallet/test/crypto_tests.cpp b/depend/zcash/src/wallet/test/crypto_tests.cpp index cd7aa989b..b3ad26e9a 100644 --- a/depend/zcash/src/wallet/test/crypto_tests.cpp +++ b/depend/zcash/src/wallet/test/crypto_tests.cpp @@ -10,76 +10,9 @@ #include #include -#include -#include BOOST_FIXTURE_TEST_SUITE(wallet_crypto, BasicTestingSetup) -bool OldSetKeyFromPassphrase(const SecureString& strKeyData, const std::vector& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod, unsigned char* chKey, unsigned char* chIV) -{ - if (nRounds < 1 || chSalt.size() != WALLET_CRYPTO_SALT_SIZE) - return false; - - int i = 0; - if (nDerivationMethod == 0) - i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha512(), &chSalt[0], - (unsigned char *)&strKeyData[0], strKeyData.size(), nRounds, chKey, chIV); - - if (i != (int)WALLET_CRYPTO_KEY_SIZE) - { - memory_cleanse(chKey, sizeof(chKey)); - memory_cleanse(chIV, sizeof(chIV)); - return false; - } - return true; -} - -bool OldEncrypt(const CKeyingMaterial& vchPlaintext, std::vector &vchCiphertext, const unsigned char chKey[32], const unsigned char chIV[16]) -{ - // max ciphertext len for a n bytes of plaintext is - // n + AES_BLOCK_SIZE - 1 bytes - int nLen = vchPlaintext.size(); - int nCLen = nLen + AES_BLOCK_SIZE, nFLen = 0; - vchCiphertext = std::vector (nCLen); - - bool fOk = true; - - EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); - assert(ctx); - if (fOk) fOk = EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, chKey, chIV) != 0; - if (fOk) fOk = EVP_EncryptUpdate(ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen) != 0; - if (fOk) fOk = EVP_EncryptFinal_ex(ctx, (&vchCiphertext[0]) + nCLen, &nFLen) != 0; - EVP_CIPHER_CTX_free(ctx); - - if (!fOk) return false; - - vchCiphertext.resize(nCLen + nFLen); - return true; -} - -bool OldDecrypt(const std::vector& vchCiphertext, CKeyingMaterial& vchPlaintext, const unsigned char chKey[32], const unsigned char chIV[16]) -{ - // plaintext will always be equal to or lesser than length of ciphertext - int nLen = vchCiphertext.size(); - int nPLen = nLen, nFLen = 0; - - vchPlaintext = CKeyingMaterial(nPLen); - - bool fOk = true; - - EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); - assert(ctx); - if (fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, chKey, chIV) != 0; - if (fOk) fOk = EVP_DecryptUpdate(ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen) != 0; - if (fOk) fOk = EVP_DecryptFinal_ex(ctx, (&vchPlaintext[0]) + nPLen, &nFLen) != 0; - EVP_CIPHER_CTX_free(ctx); - - if (!fOk) return false; - - vchPlaintext.resize(nPLen + nFLen); - return true; -} - class TestCrypter { public: @@ -87,25 +20,15 @@ static void TestPassphraseSingle(const std::vector& vchSalt, cons const std::vector& correctKey = std::vector(), const std::vector& correctIV=std::vector()) { - unsigned char chKey[WALLET_CRYPTO_KEY_SIZE]; - unsigned char chIV[WALLET_CRYPTO_IV_SIZE]; - CCrypter crypt; crypt.SetKeyFromPassphrase(passphrase, vchSalt, rounds, 0); - OldSetKeyFromPassphrase(passphrase, vchSalt, rounds, 0, chKey, chIV); - - BOOST_CHECK_MESSAGE(memcmp(chKey, crypt.vchKey.data(), crypt.vchKey.size()) == 0, \ - HexStr(chKey, chKey+sizeof(chKey)) + std::string(" != ") + HexStr(crypt.vchKey)); - BOOST_CHECK_MESSAGE(memcmp(chIV, crypt.vchIV.data(), crypt.vchIV.size()) == 0, \ - HexStr(chIV, chIV+sizeof(chIV)) + std::string(" != ") + HexStr(crypt.vchIV)); - if(!correctKey.empty()) - BOOST_CHECK_MESSAGE(memcmp(chKey, &correctKey[0], sizeof(chKey)) == 0, \ - HexStr(chKey, chKey+sizeof(chKey)) + std::string(" != ") + HexStr(correctKey.begin(), correctKey.end())); + BOOST_CHECK_MESSAGE(memcmp(crypt.vchKey.data(), correctKey.data(), crypt.vchKey.size()) == 0, \ + HexStr(crypt.vchKey.begin(), crypt.vchKey.end()) + std::string(" != ") + HexStr(correctKey.begin(), correctKey.end())); if(!correctIV.empty()) - BOOST_CHECK_MESSAGE(memcmp(chIV, &correctIV[0], sizeof(chIV)) == 0, - HexStr(chIV, chIV+sizeof(chIV)) + std::string(" != ") + HexStr(correctIV.begin(), correctIV.end())); + BOOST_CHECK_MESSAGE(memcmp(crypt.vchIV.data(), correctIV.data(), crypt.vchIV.size()) == 0, + HexStr(crypt.vchIV.begin(), crypt.vchIV.end()) + std::string(" != ") + HexStr(correctIV.begin(), correctIV.end())); } static void TestPassphrase(const std::vector& vchSalt, const SecureString& passphrase, uint32_t rounds, @@ -117,50 +40,26 @@ static void TestPassphrase(const std::vector& vchSalt, const Secu TestPassphraseSingle(vchSalt, SecureString(i, passphrase.end()), rounds); } - static void TestDecrypt(const CCrypter& crypt, const std::vector& vchCiphertext, \ const std::vector& vchPlaintext = std::vector()) { - CKeyingMaterial vchDecrypted1; - CKeyingMaterial vchDecrypted2; - int result1, result2; - result1 = crypt.Decrypt(vchCiphertext, vchDecrypted1); - result2 = OldDecrypt(vchCiphertext, vchDecrypted2, crypt.vchKey.data(), crypt.vchIV.data()); - BOOST_CHECK(result1 == result2); - - // These two should be equal. However, OpenSSL 1.0.1j introduced a change - // that would zero all padding except for the last byte for failed decrypts. - // This behavior was reverted for 1.0.1k. - if (vchDecrypted1 != vchDecrypted2 && vchDecrypted1.size() >= AES_BLOCK_SIZE && SSLeay() == 0x100010afL) - { - for(CKeyingMaterial::iterator it = vchDecrypted1.end() - AES_BLOCK_SIZE; it != vchDecrypted1.end() - 1; it++) - *it = 0; - } - - BOOST_CHECK_MESSAGE(vchDecrypted1 == vchDecrypted2, HexStr(vchDecrypted1.begin(), vchDecrypted1.end()) + " != " + HexStr(vchDecrypted2.begin(), vchDecrypted2.end())); - + CKeyingMaterial vchDecrypted; + crypt.Decrypt(vchCiphertext, vchDecrypted); if (vchPlaintext.size()) - BOOST_CHECK(CKeyingMaterial(vchPlaintext.begin(), vchPlaintext.end()) == vchDecrypted2); + BOOST_CHECK(CKeyingMaterial(vchPlaintext.begin(), vchPlaintext.end()) == vchDecrypted); } static void TestEncryptSingle(const CCrypter& crypt, const CKeyingMaterial& vchPlaintext, const std::vector& vchCiphertextCorrect = std::vector()) { - std::vector vchCiphertext1; - std::vector vchCiphertext2; - int result1 = crypt.Encrypt(vchPlaintext, vchCiphertext1); - - int result2 = OldEncrypt(vchPlaintext, vchCiphertext2, crypt.vchKey.data(), crypt.vchIV.data()); - BOOST_CHECK(result1 == result2); - BOOST_CHECK(vchCiphertext1 == vchCiphertext2); + std::vector vchCiphertext; + crypt.Encrypt(vchPlaintext, vchCiphertext); if (!vchCiphertextCorrect.empty()) - BOOST_CHECK(vchCiphertext2 == vchCiphertextCorrect); + BOOST_CHECK(vchCiphertext == vchCiphertextCorrect); const std::vector vchPlaintext2(vchPlaintext.begin(), vchPlaintext.end()); - - if(vchCiphertext1 == vchCiphertext2) - TestDecrypt(crypt, vchCiphertext1, vchPlaintext2); + TestDecrypt(crypt, vchCiphertext, vchPlaintext2); } static void TestEncrypt(const CCrypter& crypt, const std::vector& vchPlaintextIn, \ diff --git a/depend/zcash/src/wallet/test/rpc_wallet_tests.cpp b/depend/zcash/src/wallet/test/rpc_wallet_tests.cpp index 498e7f6a5..36fbff7d6 100644 --- a/depend/zcash/src/wallet/test/rpc_wallet_tests.cpp +++ b/depend/zcash/src/wallet/test/rpc_wallet_tests.cpp @@ -9,8 +9,6 @@ #include "main.h" #include "wallet/wallet.h" -#include "wallet/test/wallet_test_fixture.h" - #include "zcash/Address.hpp" #include "asyncrpcqueue.h" @@ -23,6 +21,10 @@ #include "init.h" #include "utiltest.h" +#include "test/test_bitcoin.h" +#include "test/test_util.h" +#include "wallet/test/wallet_test_fixture.h" + #include #include #include @@ -36,20 +38,37 @@ #include #include #include +#include #include using namespace std; -extern UniValue createArgs(int nRequired, const char* address1 = NULL, const char* address2 = NULL); -extern UniValue CallRPC(string args); - extern CWallet* pwalletMain; +namespace { + bool find_error(const UniValue& objError, const std::string& expected) { return find_value(objError, "message").get_str().find(expected) != string::npos; } +/** Set the working directory for the duration of the scope. */ +class PushCurrentDirectory { +public: + PushCurrentDirectory(const std::string &new_cwd) + : old_cwd(boost::filesystem::current_path()) { + boost::filesystem::current_path(new_cwd); + } + + ~PushCurrentDirectory() { + boost::filesystem::current_path(old_cwd); + } +private: + boost::filesystem::path old_cwd; +}; + +} + static UniValue ValueFromString(const std::string &str) { UniValue value; @@ -299,7 +318,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet) BOOST_CHECK_EQUAL(find_value(obj, "founders").get_real(), 1.25); BOOST_CHECK(!obj.exists("fundingstreams")); - auto check_funding_streams = [](UniValue obj, std::vector recipients, std::vector amounts) { + auto check_funding_streams = [](UniValue obj, std::vector recipients, std::vector amounts, std::vector addresses) { size_t n = recipients.size(); BOOST_REQUIRE_EQUAL(amounts.size(), n); UniValue fundingstreams = find_value(obj, "fundingstreams"); @@ -311,6 +330,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet) BOOST_CHECK_EQUAL(find_value(fsobj, "recipient").get_str(), recipients[i]); BOOST_CHECK_EQUAL(find_value(fsobj, "specification").get_str(), "https://zips.z.cash/zip-0214"); BOOST_CHECK_EQUAL(find_value(fsobj, "value").get_real(), amounts[i]); + BOOST_CHECK_EQUAL(find_value(fsobj, "address").get_str(), addresses[i]); } }; @@ -324,7 +344,12 @@ BOOST_AUTO_TEST_CASE(rpc_wallet) BOOST_CHECK_EQUAL(find_value(obj, "founders").get_real(), 0.0); if (canopyEnabled) { check_funding_streams(obj, {"Electric Coin Company", "Zcash Foundation", "Major Grants" }, - { 0.21875, 0.15625, 0.25 }); + { 0.21875, 0.15625, 0.25 }, + { + "t3LmX1cxWPPPqL4TZHx42HU3U5ghbFjRiif", + "t3dvVE3SQEi7kqNzwrfNePxZ1d4hUyztBA1", + "t3XyYW8yBFRuMnfvm5KLGFbEVz25kckZXym" + }); } BOOST_CHECK_NO_THROW(retValue = CallRPC("getblocksubsidy 2726399")); @@ -333,7 +358,12 @@ BOOST_AUTO_TEST_CASE(rpc_wallet) BOOST_CHECK_EQUAL(find_value(obj, "founders").get_real(), 0.0); if (canopyEnabled) { check_funding_streams(obj, {"Electric Coin Company", "Zcash Foundation", "Major Grants" }, - { 0.21875, 0.15625, 0.25 }); + { 0.21875, 0.15625, 0.25 }, + { + "t3XHAGxRP2FNfhAjxGjxbrQPYtQQjc3RCQD", + "t3dvVE3SQEi7kqNzwrfNePxZ1d4hUyztBA1", + "t3XyYW8yBFRuMnfvm5KLGFbEVz25kckZXym" + }); } BOOST_CHECK_NO_THROW(retValue = CallRPC("getblocksubsidy 2726400")); @@ -1112,7 +1142,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters) } try { - std::vector recipients = { SendManyRecipient("dummy",1.0, "") }; + std::vector recipients = { SendManyRecipient("dummy", 1*COIN, "") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, "INVALID", recipients, {}, 1) ); } catch (const UniValue& objError) { BOOST_CHECK( find_error(objError, "Invalid from address")); @@ -1120,7 +1150,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters) // Testnet payment addresses begin with 'zt'. This test detects an incorrect prefix. try { - std::vector recipients = { SendManyRecipient("dummy",1.0, "") }; + std::vector recipients = { SendManyRecipient("dummy", 1*COIN, "") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, "zcMuhvq8sEkHALuSU2i4NbNQxshSAYrpCExec45ZjtivYPbuiFPwk6WHy4SvsbeZ4siy1WheuRGjtaJmoD1J8bFqNXhsG6U", recipients, {}, 1) ); } catch (const UniValue& objError) { BOOST_CHECK( find_error(objError, "Invalid from address")); @@ -1129,7 +1159,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters) // Note: The following will crash as a google test because AsyncRPCOperation_sendmany // invokes a method on pwalletMain, which is undefined in the google test environment. try { - std::vector recipients = { SendManyRecipient("dummy",1.0, "") }; + std::vector recipients = { SendManyRecipient("dummy", 1*COIN, "") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, "ztjiDe569DPNbyTE6TSdJTaSDhoXEHLGvYoUnBU1wfVNU52TEyT6berYtySkd21njAeEoh8fFJUT42kua9r8EnhBaEKqCpP", recipients, {}, 1) ); } catch (const UniValue& objError) { BOOST_CHECK( find_error(objError, "no spending key found for zaddr")); @@ -1152,7 +1182,7 @@ BOOST_AUTO_TEST_CASE(asyncrpcoperation_sign_send_raw_transaction) { BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) { SelectParams(CBaseChainParams::TESTNET); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1176,7 +1206,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) // there are no utxos to spend { - std::vector recipients = { SendManyRecipient(zaddr1,100.0, "DEADBEEF") }; + std::vector recipients = { SendManyRecipient(zaddr1, 100*COIN, "DEADBEEF") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, taddr1, {}, recipients, 1) ); operation->main(); BOOST_CHECK(operation->isFailed()); @@ -1187,7 +1217,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) // minconf cannot be zero when sending from zaddr { try { - std::vector recipients = {SendManyRecipient(taddr1, 100.0, "DEADBEEF")}; + std::vector recipients = {SendManyRecipient(taddr1, 100*COIN, "DEADBEEF")}; std::shared_ptr operation(new AsyncRPCOperation_sendmany(std::nullopt, mtx, zaddr1, recipients, {}, 0)); BOOST_CHECK(false); // Fail test if an exception is not thrown } catch (const UniValue& objError) { @@ -1198,7 +1228,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) // there are no unspent notes to spend { - std::vector recipients = { SendManyRecipient(taddr1,100.0, "DEADBEEF") }; + std::vector recipients = { SendManyRecipient(taddr1, 100*COIN, "DEADBEEF") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, zaddr1, recipients, {}, 1) ); operation->main(); BOOST_CHECK(operation->isFailed()); @@ -1208,7 +1238,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) // get_memo_from_hex_string()) { - std::vector recipients = { SendManyRecipient(zaddr1,100.0, "DEADBEEF") }; + std::vector recipients = { SendManyRecipient(zaddr1, 100*COIN, "DEADBEEF") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, zaddr1, recipients, {}, 1) ); std::shared_ptr ptr = std::dynamic_pointer_cast (operation); TEST_FRIEND_AsyncRPCOperation_sendmany proxy(ptr); @@ -1259,7 +1289,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) // add_taddr_change_output_to_tx() will append a vout to a raw transaction { - std::vector recipients = { SendManyRecipient(zaddr1,100.0, "DEADBEEF") }; + std::vector recipients = { SendManyRecipient(zaddr1, 100*COIN, "DEADBEEF") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, zaddr1, recipients, {}, 1) ); std::shared_ptr ptr = std::dynamic_pointer_cast (operation); TEST_FRIEND_AsyncRPCOperation_sendmany proxy(ptr); @@ -1268,14 +1298,14 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) BOOST_CHECK(tx.vout.size() == 0); CReserveKey keyChange(pwalletMain); - CAmount amount = AmountFromValue(ValueFromString("123.456")); + CAmount amount = 12345600000; proxy.add_taddr_change_output_to_tx(keyChange, amount); tx = proxy.getTx(); BOOST_CHECK(tx.vout.size() == 1); CTxOut out = tx.vout[0]; BOOST_CHECK_EQUAL(out.nValue, amount); - amount = AmountFromValue(ValueFromString("1.111")); + amount = 111100000; proxy.add_taddr_change_output_to_tx(keyChange, amount); tx = proxy.getTx(); BOOST_CHECK(tx.vout.size() == 2); @@ -1286,9 +1316,9 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) // add_taddr_outputs_to_tx() will append many vouts to a raw transaction { std::vector recipients = { - SendManyRecipient("tmTGScYwiLMzHe4uGZtBYmuqoW4iEoYNMXt",CAmount(1.23), ""), - SendManyRecipient("tmUSbHz3vxnwLvRyNDXbwkZxjVyDodMJEhh",CAmount(4.56), ""), - SendManyRecipient("tmYZAXYPCP56Xa5JQWWPZuK7o7bfUQW6kkd",CAmount(7.89), ""), + SendManyRecipient("tmTGScYwiLMzHe4uGZtBYmuqoW4iEoYNMXt", 123000000, ""), + SendManyRecipient("tmUSbHz3vxnwLvRyNDXbwkZxjVyDodMJEhh", 456000000, ""), + SendManyRecipient("tmYZAXYPCP56Xa5JQWWPZuK7o7bfUQW6kkd", 789000000, ""), }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, zaddr1, recipients, {}, 1) ); std::shared_ptr ptr = std::dynamic_pointer_cast (operation); @@ -1298,15 +1328,15 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) CTransaction tx = proxy.getTx(); BOOST_CHECK(tx.vout.size() == 3); - BOOST_CHECK_EQUAL(tx.vout[0].nValue, CAmount(1.23)); - BOOST_CHECK_EQUAL(tx.vout[1].nValue, CAmount(4.56)); - BOOST_CHECK_EQUAL(tx.vout[2].nValue, CAmount(7.89)); + BOOST_CHECK_EQUAL(tx.vout[0].nValue, 123000000); + BOOST_CHECK_EQUAL(tx.vout[1].nValue, 456000000); + BOOST_CHECK_EQUAL(tx.vout[2].nValue, 789000000); } // Test the perform_joinsplit methods. { // Dummy input so the operation object can be instantiated. - std::vector recipients = { SendManyRecipient(zaddr1, 0.0005, "ABCD") }; + std::vector recipients = { SendManyRecipient(zaddr1, 50000, "ABCD") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, zaddr1, {}, recipients, 1) ); std::shared_ptr ptr = std::dynamic_pointer_cast (operation); @@ -1377,7 +1407,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_taddr_to_sapling) auto pa = pwalletMain->GenerateNewSaplingZKey(); std::string zaddr1 = keyIO.EncodePaymentAddress(pa); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); retValue = CallRPC("getblockcount"); int nextBlockHeight = retValue.get_int() + 1; @@ -1408,7 +1438,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_taddr_to_sapling) auto builder = TransactionBuilder(consensusParams, nextBlockHeight, pwalletMain); mtx = CreateNewContextualCMutableTransaction(consensusParams, nextBlockHeight); - std::vector recipients = { SendManyRecipient(zaddr1, 1 * COIN, "ABCD") }; + std::vector recipients = { SendManyRecipient(zaddr1, 1*COIN, "ABCD") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(builder, mtx, taddr1, {}, recipients, 0) ); std::shared_ptr ptr = std::dynamic_pointer_cast (operation); @@ -1490,7 +1520,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_encrypted_wallet_zkeys) strWalletPass.reserve(100); strWalletPass = "hello"; - boost::filesystem::current_path(GetArg("-datadir","/tmp/thisshouldnothappen")); + PushCurrentDirectory push_dir(GetArg("-datadir","/tmp/thisshouldnothappen")); BOOST_CHECK(pwalletMain->EncryptWallet(strWalletPass)); // Verify we can still list the keys imported @@ -1551,7 +1581,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_encrypted_wallet_sapzkeys) strWalletPass.reserve(100); strWalletPass = "hello"; - boost::filesystem::current_path(GetArg("-datadir","/tmp/thisshouldnothappen")); + PushCurrentDirectory push_dir(GetArg("-datadir","/tmp/thisshouldnothappen")); BOOST_CHECK(pwalletMain->EncryptWallet(strWalletPass)); // Verify we can still list the keys imported @@ -1709,7 +1739,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_shieldcoinbase_parameters) BOOST_AUTO_TEST_CASE(rpc_z_shieldcoinbase_internals) { SelectParams(CBaseChainParams::TESTNET); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1913,7 +1943,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters) BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals) { SelectParams(CBaseChainParams::TESTNET); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -2004,7 +2034,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals) TEST_FRIEND_AsyncRPCOperation_mergetoaddress proxy(ptr); // Enable test mode so tx is not sent and proofs are not generated - static_cast(operation.get())->testmode = true; + static_cast(operation.get())->testmode = true; MergeToAddressJSInfo info; std::vector> witnesses; diff --git a/depend/zcash/src/wallet/wallet.cpp b/depend/zcash/src/wallet/wallet.cpp index 31fb5d920..0d7ef05ec 100644 --- a/depend/zcash/src/wallet/wallet.cpp +++ b/depend/zcash/src/wallet/wallet.cpp @@ -17,6 +17,7 @@ #include "main.h" #include "net.h" #include "policy/policy.h" +#include "random.h" #include "rpc/protocol.h" #include "rpc/server.h" #include "script/script.h" @@ -28,6 +29,7 @@ #include "crypter.h" #include "wallet/asyncrpcoperation_saplingmigration.h" +#include #include #include @@ -589,17 +591,26 @@ void CWallet::ChainTipAdded(const CBlockIndex *pindex, IncrementNoteWitnesses(pindex, pblock, sproutTree, saplingTree); UpdateSaplingNullifierNoteMapForBlock(pblock); - // SetBestChain() can be expensive for large wallets, so do this - // at most once per hour; the wallet state will be brought up to - // date during rescanning on startup. + // SetBestChain() can be expensive for large wallets, so do only + // this sometimes; the wallet state will be brought up to date + // during rescanning on startup. int64_t nNow = GetTimeMicros(); if (nLastSetChain == 0) { // Don't flush during startup. nLastSetChain = nNow; } - if (nLastSetChain + (int64_t)DATABASE_WRITE_INTERVAL * 1000000 < nNow) { + if (++nSetChainUpdates >= WITNESS_WRITE_UPDATES || + nLastSetChain + (int64_t)WITNESS_WRITE_INTERVAL * 1000000 < nNow) { nLastSetChain = nNow; - SetBestChain(chainActive.GetLocator()); + nSetChainUpdates = 0; + CBlockLocator loc; + { + // The locator must be derived from the pindex used to increment + // the witnesses above; pindex can be behind chainActive.Tip(). + LOCK(cs_main); + loc = chainActive.GetLocator(pindex); + } + SetBestChain(loc); } } @@ -874,9 +885,19 @@ bool CWallet::Verify() LogPrintf("Using wallet %s\n", walletFile); uiInterface.InitMessage(_("Verifying wallet...")); - // Wallet file must be a plain filename without a directory - if (walletFile != boost::filesystem::basename(walletFile) + boost::filesystem::extension(walletFile)) - return UIError(strprintf(_("Wallet %s resides outside data directory %s"), walletFile, GetDataDir().string())); + if (walletFile != boost::filesystem::basename(walletFile) + boost::filesystem::extension(walletFile)) { + boost::filesystem::path path(walletFile); + if (path.is_absolute()) { + if (!boost::filesystem::exists(path.parent_path())) { + return UIError(strprintf(_("Absolute path %s does not exist"), walletFile)); + } + } else { + boost::filesystem::path full_path = GetDataDir() / path; + if (!boost::filesystem::exists(full_path.parent_path())) { + return UIError(strprintf(_("Relative path %s does not exist"), walletFile)); + } + } + } if (!bitdb.Open(GetDataDir())) { @@ -2674,8 +2695,9 @@ void CWallet::WitnessNoteCommitment(std::vector commitments, uint256 &final_anchor) { witnesses.resize(commitments.size()); - CBlockIndex* pindex = chainActive.Genesis(); SproutMerkleTree tree; + AssertLockHeld(cs_main); + CBlockIndex* pindex = chainActive.Genesis(); while (pindex) { CBlock block; @@ -3297,7 +3319,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int vector > > vValue; CAmount nTotalLower = 0; - random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); + std::shuffle(vCoins.begin(), vCoins.end(), ZcashRandomEngine()); BOOST_FOREACH(const COutput &output, vCoins) { @@ -3546,6 +3568,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt wtxNew.fTimeReceivedIsTxTime = true; wtxNew.BindWallet(this); + LOCK(cs_main); int nextBlockHeight = chainActive.Height() + 1; CMutableTransaction txNew = CreateNewContextualCMutableTransaction( Params().GetConsensus(), nextBlockHeight); @@ -3586,7 +3609,8 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt assert(txNew.nLockTime < LOCKTIME_THRESHOLD); { - LOCK2(cs_main, cs_wallet); + // cs_main already taken above + LOCK(cs_wallet); { nFeeRet = 0; // Start with no fee and loop until there is enough fee @@ -4526,6 +4550,7 @@ class CAffectedKeysVisitor { }; void CWallet::GetKeyBirthTimes(std::map &mapKeyBirth) const { + AssertLockHeld(cs_main); // chainActive AssertLockHeld(cs_wallet); // mapKeyMetadata mapKeyBirth.clear(); @@ -4640,7 +4665,7 @@ std::string CWallet::GetWalletHelpString(bool showDebug) strUsage += HelpMessageOpt("-txconfirmtarget=", strprintf(_("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)"), DEFAULT_TX_CONFIRM_TARGET)); strUsage += HelpMessageOpt("-txexpirydelta", strprintf(_("Set the number of blocks after which a transaction that has not been mined will become invalid (min: %u, default: %u (pre-Blossom) or %u (post-Blossom))"), TX_EXPIRING_SOON_THRESHOLD + 1, DEFAULT_PRE_BLOSSOM_TX_EXPIRY_DELTA, DEFAULT_POST_BLOSSOM_TX_EXPIRY_DELTA)); strUsage += HelpMessageOpt("-upgradewallet", _("Upgrade wallet to latest format on startup")); - strUsage += HelpMessageOpt("-wallet=", _("Specify wallet file (within data directory)") + " " + strprintf(_("(default: %s)"), DEFAULT_WALLET_DAT)); + strUsage += HelpMessageOpt("-wallet=", _("Specify wallet file absolute path or a path relative to the data directory") + " " + strprintf(_("(default: %s)"), DEFAULT_WALLET_DAT)); strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), DEFAULT_WALLETBROADCAST)); strUsage += HelpMessageOpt("-walletnotify=", _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)")); strUsage += HelpMessageOpt("-zapwallettxes=", _("Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup") + @@ -4765,7 +4790,7 @@ bool CWallet::InitLoadWallet(bool clearWitnessCaches) if (chainActive.Tip() && chainActive.Tip() != pindexRescan) { // We can't rescan beyond non-pruned blocks, stop and throw an error. - // This might happen if a user uses a old wallet within a pruned node, + // This might happen if a user uses an old wallet within a pruned node, // or if they ran -disablewallet for a longer time, then decided to re-enable. if (fPruneMode) { diff --git a/depend/zcash/src/wallet/wallet.h b/depend/zcash/src/wallet/wallet.h index 1605645ba..10bdc67c7 100644 --- a/depend/zcash/src/wallet/wallet.h +++ b/depend/zcash/src/wallet/wallet.h @@ -770,6 +770,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface int64_t nNextResend; int64_t nLastResend; int64_t nLastSetChain; + int nSetChainUpdates; bool fBroadcastTransactions; template @@ -931,6 +932,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface nNextResend = 0; nLastResend = 0; nLastSetChain = 0; + nSetChainUpdates = 0; nTimeFirstKey = 0; fBroadcastTransactions = false; nWitnessCacheSize = 0; diff --git a/depend/zcash/src/warnings.cpp b/depend/zcash/src/warnings.cpp index 80d7f2755..798c14e52 100644 --- a/depend/zcash/src/warnings.cpp +++ b/depend/zcash/src/warnings.cpp @@ -12,19 +12,21 @@ CCriticalSection cs_warnings; std::string strMiscWarning; +int64_t timestampWarning; bool fLargeWorkForkFound = false; bool fLargeWorkInvalidChainFound = false; -void SetMiscWarning(const std::string& strWarning) +void SetMiscWarning(const std::string& strWarning, int64_t timestamp) { LOCK(cs_warnings); strMiscWarning = strWarning; + timestampWarning = timestamp; } -std::string GetMiscWarning() +std::pair GetMiscWarning() { LOCK(cs_warnings); - return strMiscWarning; + return std::make_pair(strMiscWarning, timestampWarning); } void SetfLargeWorkForkFound(bool flag) @@ -51,36 +53,40 @@ bool GetfLargeWorkInvalidChainFound() return fLargeWorkInvalidChainFound; } -std::string GetWarnings(const std::string& strFor) +std::pair GetWarnings(const std::string& strFor) { + std::pair rpc; + std::pair statusbar; + statusbar.second = rpc.second = GetTime(); int nPriority = 0; - std::string strStatusBar; - std::string strRPC; LOCK(cs_warnings); if (!CLIENT_VERSION_IS_RELEASE) - strStatusBar = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"); + statusbar.first = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"); if (GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE)) - strStatusBar = strRPC = "testsafemode enabled"; + statusbar.first = rpc.first = "testsafemode enabled"; // Misc warnings like out of disk space and clock is wrong if (strMiscWarning != "") { nPriority = 1000; - strStatusBar = strMiscWarning; + statusbar.first = strMiscWarning; + statusbar.second = timestampWarning; } if (fLargeWorkForkFound) { nPriority = 2000; - strStatusBar = strRPC = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues."); + statusbar.first = rpc.first = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues."); + statusbar.second = rpc.second = GetTime(); } else if (fLargeWorkInvalidChainFound) { nPriority = 2000; - strStatusBar = strRPC = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade."); + statusbar.first = rpc.first = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade."); + statusbar.second = rpc.second = GetTime(); } // Alerts @@ -92,18 +98,20 @@ std::string GetWarnings(const std::string& strFor) if (alert.AppliesToMe() && alert.nPriority > nPriority) { nPriority = alert.nPriority; - strStatusBar = alert.strStatusBar; + statusbar.first = alert.strStatusBar; + statusbar.second = GetTime(); if (alert.nPriority >= ALERT_PRIORITY_SAFE_MODE) { - strRPC = alert.strRPCError; + rpc.first = alert.strRPCError; + rpc.second = statusbar.second; } } } } if (strFor == "statusbar") - return strStatusBar; + return statusbar; else if (strFor == "rpc") - return strRPC; + return rpc; assert(!"GetWarnings(): invalid parameter"); - return "error"; + return std::make_pair("error", GetTime()); } diff --git a/depend/zcash/src/warnings.h b/depend/zcash/src/warnings.h index 220b49504..db44aabde 100644 --- a/depend/zcash/src/warnings.h +++ b/depend/zcash/src/warnings.h @@ -9,13 +9,13 @@ #include #include -void SetMiscWarning(const std::string& strWarning); -std::string GetMiscWarning(); +void SetMiscWarning(const std::string& strWarning, int64_t timestamp); +std::pair GetMiscWarning(); void SetfLargeWorkForkFound(bool flag); bool GetfLargeWorkForkFound(); void SetfLargeWorkInvalidChainFound(bool flag); bool GetfLargeWorkInvalidChainFound(); -std::string GetWarnings(const std::string& strFor); +std::pair GetWarnings(const std::string& strFor); static const bool DEFAULT_TESTSAFEMODE = false; diff --git a/depend/zcash/src/zcash/History.cpp b/depend/zcash/src/zcash/History.cpp index 2ffbec2f0..72aae033d 100644 --- a/depend/zcash/src/zcash/History.cpp +++ b/depend/zcash/src/zcash/History.cpp @@ -54,7 +54,7 @@ HistoryNode NewNode( ) { CDataStream buf(SER_DISK, 0); - HistoryNode result; + HistoryNode result = {}; buf << subtreeCommitment; buf << startTime; @@ -68,7 +68,8 @@ HistoryNode NewNode( buf << COMPACTSIZE(endHeight); buf << COMPACTSIZE(saplingTxCount); - std::copy(buf.begin(), buf.end(), result.begin()); + assert(buf.size() <= NODE_SERIALIZED_LENGTH); + std::copy(std::begin(buf), std::end(buf), result.bytes); return result; } @@ -104,7 +105,11 @@ HistoryEntry NodeToEntry(const HistoryNode node, uint32_t left, uint32_t right) buf << code; buf << left; buf << right; - buf << node; + + std::array tmpMmrNode; + std::copy(node.bytes, node.bytes + NODE_SERIALIZED_LENGTH, std::begin(tmpMmrNode)); + + buf << tmpMmrNode; assert(buf.size() <= ENTRY_SERIALIZED_LENGTH); std::copy(std::begin(buf), std::end(buf), result.bytes); @@ -118,7 +123,11 @@ HistoryEntry LeafToEntry(const HistoryNode node) { uint8_t code = 1; buf << code; - buf << node; + + std::array tmpMmrNode; + std::copy(node.bytes, node.bytes + NODE_SERIALIZED_LENGTH, std::begin(tmpMmrNode)); + + buf << tmpMmrNode; assert(buf.size() <= ENTRY_SERIALIZED_LENGTH); std::copy(std::begin(buf), std::end(buf), result.bytes); @@ -126,4 +135,4 @@ HistoryEntry LeafToEntry(const HistoryNode node) { return result; } -} \ No newline at end of file +} diff --git a/depend/zcash/src/zcash/History.hpp b/depend/zcash/src/zcash/History.hpp index 3e25bd3e8..990764a32 100644 --- a/depend/zcash/src/zcash/History.hpp +++ b/depend/zcash/src/zcash/History.hpp @@ -13,10 +13,6 @@ namespace libzcash { -const int NODE_SERIALIZED_LENGTH = 171; - -typedef std::array HistoryNode; - typedef uint64_t HistoryIndex; class HistoryCache { @@ -66,6 +62,5 @@ HistoryEntry LeafToEntry(const HistoryNode node); typedef libzcash::HistoryCache HistoryCache; typedef libzcash::HistoryIndex HistoryIndex; -typedef libzcash::HistoryNode HistoryNode; #endif /* ZC_HISTORY_H_ */ \ No newline at end of file diff --git a/depend/zcash/src/zcash/JoinSplit.cpp b/depend/zcash/src/zcash/JoinSplit.cpp index e1efe7a1c..5a3aaf1ac 100644 --- a/depend/zcash/src/zcash/JoinSplit.cpp +++ b/depend/zcash/src/zcash/JoinSplit.cpp @@ -28,7 +28,7 @@ namespace libzcash { std::array& out_notes, std::array& out_ciphertexts, uint256& out_ephemeralKey, - const uint256& joinSplitPubKey, + const Ed25519VerificationKey& joinSplitPubKey, uint256& out_randomSeed, std::array& out_macs, std::array& out_nullifiers, @@ -206,7 +206,7 @@ template uint256 JoinSplit::h_sig( const uint256& randomSeed, const std::array& nullifiers, - const uint256& joinSplitPubKey + const Ed25519VerificationKey& joinSplitPubKey ) { const unsigned char personalization[BLAKE2bPersonalBytes] = {'Z','c','a','s','h','C','o','m','p','u','t','e','h','S','i','g'}; @@ -217,14 +217,14 @@ uint256 JoinSplit::h_sig( block.insert(block.end(), nullifiers[i].begin(), nullifiers[i].end()); } - block.insert(block.end(), joinSplitPubKey.begin(), joinSplitPubKey.end()); + block.insert(block.end(), joinSplitPubKey.bytes, joinSplitPubKey.bytes + ED25519_VERIFICATION_KEY_LEN); uint256 output; - auto state = rust_blake2b_init(32, personalization); - rust_blake2b_update(state, &block[0], block.size()); - rust_blake2b_finalize(state, output.begin(), 32); - rust_blake2b_free(state); + auto state = blake2b_init(32, personalization); + blake2b_update(state, &block[0], block.size()); + blake2b_finalize(state, output.begin(), 32); + blake2b_free(state); return output; } diff --git a/depend/zcash/src/zcash/JoinSplit.hpp b/depend/zcash/src/zcash/JoinSplit.hpp index 71f871171..9bee708d9 100644 --- a/depend/zcash/src/zcash/JoinSplit.hpp +++ b/depend/zcash/src/zcash/JoinSplit.hpp @@ -13,6 +13,8 @@ #include +#include + namespace libzcash { class JSInput { @@ -48,7 +50,7 @@ class JoinSplit { public: static uint256 h_sig(const uint256& randomSeed, const std::array& nullifiers, - const uint256& joinSplitPubKey + const Ed25519VerificationKey& joinSplitPubKey ); // Compute nullifiers, macs, note commitments & encryptions, and SNARK proof @@ -58,7 +60,7 @@ class JoinSplit { std::array& out_notes, std::array& out_ciphertexts, uint256& out_ephemeralKey, - const uint256& joinSplitPubKey, + const Ed25519VerificationKey& joinSplitPubKey, uint256& out_randomSeed, std::array& out_hmacs, std::array& out_nullifiers, diff --git a/depend/zcash/src/zcash/Note.cpp b/depend/zcash/src/zcash/Note.cpp index fd35d9ac0..b1af195ea 100644 --- a/depend/zcash/src/zcash/Note.cpp +++ b/depend/zcash/src/zcash/Note.cpp @@ -1,7 +1,9 @@ #include "Note.hpp" + #include "prf.h" #include "crypto/sha256.h" #include "consensus/consensus.h" +#include "logging.h" #include "random.h" #include "version.h" @@ -64,7 +66,7 @@ SaplingNote::SaplingNote( std::optional SaplingNote::cmu() const { uint256 result; uint256 rcm_tmp = rcm(); - if (!librustzcash_sapling_compute_cm( + if (!librustzcash_sapling_compute_cmu( d.data(), pk_d.begin(), value(), @@ -175,6 +177,7 @@ std::optional SaplingNotePlaintext::note(const SaplingIncomingViewi if (addr) { Zip212Enabled zip_212_enabled = Zip212Enabled::BeforeZip212; if (leadbyte != 0x01) { + assert(leadbyte == 0x02); zip_212_enabled = Zip212Enabled::AfterZip212; }; auto tmp = SaplingNote(d, addr.value().pk_d, value_, rseed, zip_212_enabled); @@ -230,6 +233,8 @@ std::optional SaplingNotePlaintext::decrypt( // Check leadbyte is allowed at block height if (!plaintext_version_is_valid(params, height, plaintext.get_leadbyte())) { + LogPrint("receiveunsafe", "Received note plaintext with invalid lead byte %d at height %d", + plaintext.get_leadbyte(), height); return std::nullopt; } @@ -278,7 +283,7 @@ std::optional SaplingNotePlaintext::plaintext_checks_witho uint256 cmu_expected; uint256 rcm = plaintext.rcm(); - if (!librustzcash_sapling_compute_cm( + if (!librustzcash_sapling_compute_cmu( plaintext.d.data(), pk_d.begin(), plaintext.value(), @@ -294,6 +299,7 @@ std::optional SaplingNotePlaintext::plaintext_checks_witho } if (plaintext.get_leadbyte() != 0x01) { + assert(plaintext.get_leadbyte() == 0x02); // ZIP 212: Check that epk is consistent to guard against linkability // attacks without relying on the soundness of the SNARK. uint256 expected_epk; @@ -328,6 +334,8 @@ std::optional SaplingNotePlaintext::decrypt( // Check leadbyte is allowed at block height if (!plaintext_version_is_valid(params, height, plaintext.get_leadbyte())) { + LogPrint("receiveunsafe", "Received note plaintext with invalid lead byte %d at height %d", + plaintext.get_leadbyte(), height); return std::nullopt; } @@ -371,7 +379,17 @@ std::optional SaplingNotePlaintext::plaintext_checks_witho const uint256 &cmu ) { - // Check that epk is consistent with esk + if (plaintext.get_leadbyte() != 0x01) { + assert(plaintext.get_leadbyte() == 0x02); + // ZIP 212: Additionally check that the esk provided to this function + // is consistent with the esk we can derive + if (esk != plaintext.generate_or_derive_esk()) { + return std::nullopt; + } + } + + // ZIP 212: The recipient MUST derive esk and check that epk is consistent with it. + // https://zips.z.cash/zip-0212#changes-to-the-process-of-receiving-sapling-notes uint256 expected_epk; if (!librustzcash_sapling_ka_derivepublic(plaintext.d.data(), esk.begin(), expected_epk.begin())) { return std::nullopt; @@ -382,7 +400,7 @@ std::optional SaplingNotePlaintext::plaintext_checks_witho uint256 cmu_expected; uint256 rcm = plaintext.rcm(); - if (!librustzcash_sapling_compute_cm( + if (!librustzcash_sapling_compute_cmu( plaintext.d.data(), pk_d.begin(), plaintext.value(), @@ -397,14 +415,6 @@ std::optional SaplingNotePlaintext::plaintext_checks_witho return std::nullopt; } - if (plaintext.get_leadbyte() != 0x01) { - // ZIP 212: Additionally check that the esk provided to this function - // is consistent with the esk we can derive - if (esk != plaintext.generate_or_derive_esk()) { - return std::nullopt; - } - } - return plaintext; } @@ -452,6 +462,7 @@ SaplingOutCiphertext SaplingOutgoingPlaintext::encrypt( uint256 SaplingNotePlaintext::rcm() const { if (leadbyte != 0x01) { + assert(leadbyte == 0x02); return PRF_rcm(rseed); } else { return rseed; @@ -468,6 +479,7 @@ uint256 SaplingNote::rcm() const { uint256 SaplingNotePlaintext::generate_or_derive_esk() const { if (leadbyte != 0x01) { + assert(leadbyte == 0x02); return PRF_esk(rseed); } else { uint256 esk; diff --git a/depend/zcash/src/zcash/NoteEncryption.cpp b/depend/zcash/src/zcash/NoteEncryption.cpp index dbecdc911..6276253c1 100644 --- a/depend/zcash/src/zcash/NoteEncryption.cpp +++ b/depend/zcash/src/zcash/NoteEncryption.cpp @@ -36,10 +36,10 @@ void PRF_ock( unsigned char personalization[BLAKE2bPersonalBytes] = {}; memcpy(personalization, "Zcash_Derive_ock", 16); - auto state = rust_blake2b_init(NOTEENCRYPTION_CIPHER_KEYSIZE, personalization); - rust_blake2b_update(state, block, 128); - rust_blake2b_finalize(state, K, NOTEENCRYPTION_CIPHER_KEYSIZE); - rust_blake2b_free(state); + auto state = blake2b_init(NOTEENCRYPTION_CIPHER_KEYSIZE, personalization); + blake2b_update(state, block, 128); + blake2b_finalize(state, K, NOTEENCRYPTION_CIPHER_KEYSIZE); + blake2b_free(state); } void KDF_Sapling( @@ -55,10 +55,10 @@ void KDF_Sapling( unsigned char personalization[BLAKE2bPersonalBytes] = {}; memcpy(personalization, "Zcash_SaplingKDF", 16); - auto state = rust_blake2b_init(NOTEENCRYPTION_CIPHER_KEYSIZE, personalization); - rust_blake2b_update(state, block, 64); - rust_blake2b_finalize(state, K, NOTEENCRYPTION_CIPHER_KEYSIZE); - rust_blake2b_free(state); + auto state = blake2b_init(NOTEENCRYPTION_CIPHER_KEYSIZE, personalization); + blake2b_update(state, block, 64); + blake2b_finalize(state, K, NOTEENCRYPTION_CIPHER_KEYSIZE); + blake2b_free(state); } void KDF(unsigned char K[NOTEENCRYPTION_CIPHER_KEYSIZE], @@ -83,10 +83,10 @@ void KDF(unsigned char K[NOTEENCRYPTION_CIPHER_KEYSIZE], memcpy(personalization, "ZcashKDF", 8); memcpy(personalization+8, &nonce, 1); - auto state = rust_blake2b_init(NOTEENCRYPTION_CIPHER_KEYSIZE, personalization); - rust_blake2b_update(state, block, 128); - rust_blake2b_finalize(state, K, NOTEENCRYPTION_CIPHER_KEYSIZE); - rust_blake2b_free(state); + auto state = blake2b_init(NOTEENCRYPTION_CIPHER_KEYSIZE, personalization); + blake2b_update(state, block, 128); + blake2b_finalize(state, K, NOTEENCRYPTION_CIPHER_KEYSIZE); + blake2b_free(state); } namespace libzcash { diff --git a/depend/zcash/src/zcash/address/zip32.cpp b/depend/zcash/src/zcash/address/zip32.cpp index 0f7d98e01..d36618960 100644 --- a/depend/zcash/src/zcash/address/zip32.cpp +++ b/depend/zcash/src/zcash/address/zip32.cpp @@ -38,11 +38,11 @@ uint256 ovkForShieldingFromTaddr(HDSeed& seed) { auto rawSeed = seed.RawSeed(); // I = BLAKE2b-512("ZcTaddrToSapling", seed) - auto state = rust_blake2b_init(64, ZCASH_TADDR_OVK_PERSONAL); - rust_blake2b_update(state, rawSeed.data(), rawSeed.size()); + auto state = blake2b_init(64, ZCASH_TADDR_OVK_PERSONAL); + blake2b_update(state, rawSeed.data(), rawSeed.size()); auto intermediate = std::array(); - rust_blake2b_finalize(state, intermediate.data(), 64); - rust_blake2b_free(state); + blake2b_finalize(state, intermediate.data(), 64); + blake2b_free(state); // I_L = I[0..32] uint256 intermediate_L; diff --git a/depend/zcash/src/zcash/prf.cpp b/depend/zcash/src/zcash/prf.cpp index f7e081d33..49c178e59 100644 --- a/depend/zcash/src/zcash/prf.cpp +++ b/depend/zcash/src/zcash/prf.cpp @@ -17,10 +17,10 @@ std::array PRF_expand(const uint256& sk, unsigned char t) memcpy(&blob[0], sk.begin(), 32); blob[32] = t; - auto state = rust_blake2b_init(64, ZCASH_EXPANDSEED_PERSONALIZATION); - rust_blake2b_update(state, blob, 33); - rust_blake2b_finalize(state, res.data(), 64); - rust_blake2b_free(state); + auto state = blake2b_init(64, ZCASH_EXPANDSEED_PERSONALIZATION); + blake2b_update(state, blob, 33); + blake2b_finalize(state, res.data(), 64); + blake2b_free(state); return res; } @@ -28,7 +28,7 @@ std::array PRF_expand(const uint256& sk, unsigned char t) uint256 PRF_rcm(const uint256& rseed) { uint256 rcm; - auto tmp = PRF_expand(rseed, 4); + auto tmp = PRF_expand(rseed, PRF_RCM_TAG); librustzcash_to_scalar(tmp.data(), rcm.begin()); return rcm; } @@ -36,7 +36,7 @@ uint256 PRF_rcm(const uint256& rseed) uint256 PRF_esk(const uint256& rseed) { uint256 esk; - auto tmp = PRF_expand(rseed, 5); + auto tmp = PRF_expand(rseed, PRF_ESK_TAG); librustzcash_to_scalar(tmp.data(), esk.begin()); return esk; } @@ -44,7 +44,7 @@ uint256 PRF_esk(const uint256& rseed) uint256 PRF_ask(const uint256& sk) { uint256 ask; - auto tmp = PRF_expand(sk, 0); + auto tmp = PRF_expand(sk, PRF_ASK_TAG); librustzcash_to_scalar(tmp.data(), ask.begin()); return ask; } @@ -52,7 +52,7 @@ uint256 PRF_ask(const uint256& sk) uint256 PRF_nsk(const uint256& sk) { uint256 nsk; - auto tmp = PRF_expand(sk, 1); + auto tmp = PRF_expand(sk, PRF_NSK_TAG); librustzcash_to_scalar(tmp.data(), nsk.begin()); return nsk; } @@ -60,7 +60,7 @@ uint256 PRF_nsk(const uint256& sk) uint256 PRF_ovk(const uint256& sk) { uint256 ovk; - auto tmp = PRF_expand(sk, 2); + auto tmp = PRF_expand(sk, PRF_OVK_TAG); memcpy(ovk.begin(), tmp.data(), 32); return ovk; } @@ -75,10 +75,10 @@ std::array default_diversifier(const uint256& sk) blob[33] = 0; while (true) { - auto state = rust_blake2b_init(64, ZCASH_EXPANDSEED_PERSONALIZATION); - rust_blake2b_update(state, blob, 34); - rust_blake2b_finalize(state, res.data(), 11); - rust_blake2b_free(state); + auto state = blake2b_init(64, ZCASH_EXPANDSEED_PERSONALIZATION); + blake2b_update(state, blob, 34); + blake2b_finalize(state, res.data(), 11); + blake2b_free(state); if (librustzcash_check_diversifier(res.data())) { break; diff --git a/depend/zcash/src/zcash/prf.h b/depend/zcash/src/zcash/prf.h index b9256769a..654410a77 100644 --- a/depend/zcash/src/zcash/prf.h +++ b/depend/zcash/src/zcash/prf.h @@ -25,6 +25,12 @@ uint256 PRF_ovk(const uint256& sk); uint256 PRF_rcm(const uint256& rseed); uint256 PRF_esk(const uint256& rseed); +const char PRF_ASK_TAG = 0; +const char PRF_NSK_TAG = 1; +const char PRF_OVK_TAG = 2; +const char PRF_RCM_TAG = 4; +const char PRF_ESK_TAG = 5; + std::array default_diversifier(const uint256& sk); #endif // ZC_PRF_H_ diff --git a/depend/zcash/src/zcash/util.cpp b/depend/zcash/src/zcash/util.cpp index 6f32bf79a..d4e6dbe49 100644 --- a/depend/zcash/src/zcash/util.cpp +++ b/depend/zcash/src/zcash/util.cpp @@ -6,7 +6,7 @@ std::vector convertIntToVectorLE(const uint64_t val_int) { std::vector bytes; for(size_t i = 0; i < 8; i++) { - bytes.push_back(val_int >> (i * 8)); + bytes.push_back((unsigned char) (val_int >> (i * 8))); } return bytes; diff --git a/depend/zcash/src/zcbenchmarks.cpp b/depend/zcash/src/zcbenchmarks.cpp index 35c92a1ad..2c13cf946 100644 --- a/depend/zcash/src/zcbenchmarks.cpp +++ b/depend/zcash/src/zcbenchmarks.cpp @@ -36,6 +36,8 @@ #include "zcash/Note.hpp" #include "librustzcash.h" +#include + using namespace libzcash; // This method is based on Shutdown from init.cpp void pre_wallet_load() @@ -96,7 +98,7 @@ double benchmark_sleep() double benchmark_create_joinsplit() { - uint256 joinSplitPubKey; + Ed25519VerificationKey joinSplitPubKey; /* Get the anchor of an empty commitment tree. */ uint256 anchor = SproutMerkleTree().root(); @@ -141,7 +143,7 @@ double benchmark_verify_joinsplit(const JSDescription &joinsplit) { struct timeval tv_start; timer_start(tv_start); - uint256 joinSplitPubKey; + Ed25519VerificationKey joinSplitPubKey; auto verifier = ProofVerifier::Strict(); verifier.VerifySprout(joinsplit, joinSplitPubKey); return timer_stop(tv_start); @@ -155,7 +157,7 @@ double benchmark_solve_equihash() CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss << I; - auto params = Params(CBaseChainParams::MAIN).GetConsensus(); + const Consensus::Params& params = Params(CBaseChainParams::MAIN).GetConsensus(); unsigned int n = params.nEquihashN; unsigned int k = params.nEquihashK; eh_HashState eh_state; @@ -288,7 +290,7 @@ double benchmark_try_decrypt_sprout_notes(size_t nKeys) double benchmark_try_decrypt_sapling_notes(size_t nKeys) { // Set params - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); auto masterKey = GetTestMasterSaplingSpendingKey(); @@ -327,7 +329,7 @@ CWalletTx CreateSproutTxWithNoteData(const libzcash::SproutSpendingKey& sk) { double benchmark_increment_sprout_note_witnesses(size_t nTxs) { - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); CWallet wallet; SproutMerkleTree sproutTree; @@ -389,7 +391,7 @@ CWalletTx CreateSaplingTxWithNoteData(const Consensus::Params& consensusParams, double benchmark_increment_sapling_note_witnesses(size_t nTxs) { - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); CWallet wallet; SproutMerkleTree sproutTree; diff --git a/depend/zcash/src/zmq/zmqnotificationinterface.cpp b/depend/zcash/src/zmq/zmqnotificationinterface.cpp index 22c3b3901..fa56291c9 100644 --- a/depend/zcash/src/zmq/zmqnotificationinterface.cpp +++ b/depend/zcash/src/zmq/zmqnotificationinterface.cpp @@ -73,10 +73,14 @@ CZMQNotificationInterface* CZMQNotificationInterface::CreateWithArguments(const // Called at startup to conditionally set up ZMQ socket(s) bool CZMQNotificationInterface::Initialize() { + int major = 0, minor = 0, patch = 0; + zmq_version(&major, &minor, &patch); + LogPrint("zmq", "zmq: version %d.%d.%d\n", major, minor, patch); + LogPrint("zmq", "zmq: Initialize notification interface\n"); assert(!pcontext); - pcontext = zmq_init(1); + pcontext = zmq_ctx_new(); if (!pcontext) { @@ -119,7 +123,7 @@ void CZMQNotificationInterface::Shutdown() LogPrint("zmq", " Shutdown notifier %s at %s\n", notifier->GetType(), notifier->GetAddress()); notifier->Shutdown(); } - zmq_ctx_destroy(pcontext); + zmq_ctx_term(pcontext); pcontext = 0; } diff --git a/depend/zcash/zcutil/afl/afl-run.sh b/depend/zcash/zcutil/afl/afl-run.sh index 6cbfffee3..f29368265 100755 --- a/depend/zcash/zcutil/afl/afl-run.sh +++ b/depend/zcash/zcutil/afl/afl-run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -eu -o pipefail +set -exu -o pipefail for d in src/fuzzing/*/ ; do fuzz_cases+="$(basename "$d"), " diff --git a/depend/zcash/zcutil/afl/zcash-wrapper b/depend/zcash/zcutil/afl/zcash-wrapper index 2b5b2434d..950c3ea03 100755 --- a/depend/zcash/zcutil/afl/zcash-wrapper +++ b/depend/zcash/zcutil/afl/zcash-wrapper @@ -2,7 +2,6 @@ set -ex -o pipefail -export ARGS=$@ instrument=( "\/src$" @@ -22,10 +21,22 @@ fi case $0 in *zcash-wrapper-g++) - COMPILER="g++" + OCOMPILER="g++" + ACOMPILER=$OCOMPILER ;; *zcash-wrapper-gcc) - COMPILER="gcc" + OCOMPILER="gcc" + ACOMPILER=$OCOMPILER + ;; +*zcash-wrapper-clang) + OCOMPILER="clang-6.0" + ACOMPILER="clang-fast" + CFLAGS="-fsanitize=address -static" + ;; +*zcash-wrapper-clang++) + OCOMPILER="clang++-6.0" + ACOMPILER="clang-fast++" + CPPFLAGS="-fsanitize=address -static" ;; *zcash-wrapper) echo "Call this script instead of your regular compiler, and if the absolute path of the CWD the wrapper was called from matches a regex in the array 'instrument', it will call AFL to instrument the resulting binary. Otherwise it will call either g++ or gcc depending on how it was invoked. \$AFL_INSTALL_DIR must be set to the path where AFL is installed." @@ -40,9 +51,9 @@ do if echo -- "`pwd`" | grep "$i"; then # We found a match, let's instrument this one. echo "Matched directory `pwd` to instrument element $i. Instrumenting this call." >> "$AFL_LOG_DIR/zcash-build-wrapper.log" - exec -- "$AFL_INSTALL_DIR/afl-$COMPILER" "$@" + exec -- "$AFL_INSTALL_DIR/afl-$ACOMPILER" "$@" fi done # No match, just pass-through. -exec -- "$COMPILER" "$@" +exec -- "$OCOMPILER" "$@" diff --git a/depend/zcash/zcutil/afl/zcash-wrapper-clang b/depend/zcash/zcutil/afl/zcash-wrapper-clang new file mode 120000 index 000000000..e640aa6e1 --- /dev/null +++ b/depend/zcash/zcutil/afl/zcash-wrapper-clang @@ -0,0 +1 @@ +zcash-wrapper \ No newline at end of file diff --git a/depend/zcash/zcutil/afl/zcash-wrapper-clang++ b/depend/zcash/zcutil/afl/zcash-wrapper-clang++ new file mode 120000 index 000000000..e640aa6e1 --- /dev/null +++ b/depend/zcash/zcutil/afl/zcash-wrapper-clang++ @@ -0,0 +1 @@ +zcash-wrapper \ No newline at end of file diff --git a/depend/zcash/zcutil/build.sh b/depend/zcash/zcutil/build.sh index 5ebe6ba32..f49cfc596 100755 --- a/depend/zcash/zcutil/build.sh +++ b/depend/zcash/zcutil/build.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -eu -o pipefail +set +x function cmd_pref() { if type -p "$2" > /dev/null; then @@ -46,7 +47,7 @@ Usage: $0 --help Show this help message and exit. -$0 [ --enable-proton ] [ MAKEARGS... ] +$0 [ MAKEARGS... ] Build Zcash and most of its transitive dependencies from source. MAKEARGS are applied to both dependencies and Zcash itself. @@ -56,9 +57,6 @@ $0 [ --enable-proton ] [ MAKEARGS... ] CONFIGURE_FLAGS="--enable-lcov --disable-hardening" ./zcutil/build.sh - If --enable-proton is passed, Zcash is configured to build the Apache Qpid Proton - library required for AMQP support. This library is not built by default. - For verbose output, use: ./zcutil/build.sh V=1 EOF @@ -67,19 +65,16 @@ fi set -x -# If --enable-proton is the next argument, enable building Proton code: -PROTON_ARG='' -if [ "x${1:-}" = 'x--enable-proton' ] -then - PROTON_ARG='--enable-proton' - shift -fi - eval "$MAKE" --version as --version -ld -v -HOST="$HOST" BUILD="$BUILD" WITH_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ +HOST="$HOST" BUILD="$BUILD" "$MAKE" "$@" -C ./depends/ + +if [ "${BUILD_STAGE:-all}" = "depends" ] +then + exit 0 +fi + ./autogen.sh -CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$PROTON_ARG" $CONFIGURE_FLAGS +CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure $CONFIGURE_FLAGS "$MAKE" "$@" diff --git a/depend/zcash/zcutil/distclean.sh b/depend/zcash/zcutil/distclean.sh index acb5c1f4f..feb1a639a 100755 --- a/depend/zcash/zcutil/distclean.sh +++ b/depend/zcash/zcutil/distclean.sh @@ -10,3 +10,6 @@ rm -rf depends/sources rm -rf afl-temp rm -rf src/fuzzing/*/output +# These are not in clean.sh because they are only generated when building dependencies. +rm -f zcutil/bin/db_* +rmdir zcutil/bin 2>/dev/null || true diff --git a/depend/zcash/zcutil/libfuzzer/libfuzzer-build.sh b/depend/zcash/zcutil/libfuzzer/libfuzzer-build.sh new file mode 100755 index 000000000..3fdb4c465 --- /dev/null +++ b/depend/zcash/zcutil/libfuzzer/libfuzzer-build.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env bash + +set -eu -o pipefail + +usage() { + echo "" + echo "$0 " + echo "" + echo "Build a fuzzer in the local repo using the following options:" + echo "" + echo ":" + echo " either \"depends\" or \"fuzzer\"" + echo "" + echo ":" + echo " -f,--fuzzer (ignored if building \"depends\")" + echo " [-s,--sanitizers ]" + echo " [-i,--instrument ]" + echo " [-l,--logfile ] # default is ./zcash-build-wrapper.log" + echo " [-h,--help]" + echo "" + echo "Where fuzzer is an entry in ./src/fuzzing/*, the default sanitizer" + echo "is \"address\" and default instrument is ( \"^.*/src/$\" )." + echo "" + exit -1 +} + +die() { + echo $1 + exit -1 +} + +# parse command line options + +POSITIONAL=() +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -f|--fuzzer) + FUZZER_NAME="$2" + if [ ! -f "./src/fuzzing/$FUZZER_NAME/fuzz.cpp" ] + then + die "Cannot find source code for fuzzer." + fi + shift + shift + ;; + -s|--sanitizers) + LLVM_SANITIZERS="$2" + shift + shift + ;; + -i|--instrument) + INSTRUMENT_CODE="$2" + shift + shift + ;; + -l|--logfile) + LOGFILE="$2" + shift + shift + ;; + -h|--help) + usage + shift + ;; + *) + POSITIONAL+=("$1") + shift + ;; +esac +done + +# positional arguments + +if [ ${#POSITIONAL[@]} -lt 1 ] +then + usage +else + BUILD_STAGE=${POSITIONAL[0]} +fi + +case "${BUILD_STAGE:-undefined}" in + depends) + FUZZER_NAME=notused + # fine + ;; + fuzzer) + # fine + ;; + *) + # not fine + usage + ;; +esac + +# required arguments + +if [ "${FUZZER_NAME:-undefined}" = "undefined" ] +then + usage +fi + +# default values + +if [ "${LLVM_SANITIZERS:-undefined}" = "undefined" ] +then + export LLVM_SANITIZERS="address" +fi +if [ "${INSTRUMENT_CODE:-undefined}" = "undefined" ] +then + export INSTRUMENT_CODE=("^.*\/src") +fi +if [ "${LOGFILE:-undefined}" = "undefined" ] +then + export LOGFILE=./zcash-build-wrapper.log +fi + +set -x + +export ZCUTIL=$(realpath "./zcutil") + +# overwrite the Linux make profile to use clang instead of GCC: + +cat $ZCUTIL/../depends/hosts/linux.mk | sed -e 's/=gcc/=clang/g' | sed -e 's/=g++/=clang++/g' > x +mv x $ZCUTIL/../depends/hosts/linux.mk + +# the build_stage distinction helps to layer an intermediate docker +# container for the built dependencies, so we can resume building +# from there assuming no other build arguments have changed + +if [ "$BUILD_STAGE" = "depends" ] +then + # make an empty fuzz file just so we can build dependencies + > src/fuzz.cpp +else + cp "./src/fuzzing/$FUZZER_NAME/fuzz.cpp" src/fuzz.cpp || die "Can't copy fuzz.cpp for that fuzzer" +fi + +# sneak the variable into zcashd's build.sh + +export BUILD_STAGE + +# run build.sh with our compiler wrapper, and BUILD_STAGE environment set: + +CONFIGURE_FLAGS="--enable-tests=no --disable-bench" \ + "$ZCUTIL/build.sh" \ + -j$(nproc) \ + "CC=$ZCUTIL/libfuzzer/zcash-wrapper-clang" \ + "CXX=$ZCUTIL/libfuzzer/zcash-wrapper-clang++" "${POSITIONAL[@]:1}" || die "Build failed at stage $BUILD_STAGE." diff --git a/depend/zcash/zcutil/libfuzzer/zcash-wrapper b/depend/zcash/zcutil/libfuzzer/zcash-wrapper new file mode 100755 index 000000000..8577ba764 --- /dev/null +++ b/depend/zcash/zcutil/libfuzzer/zcash-wrapper @@ -0,0 +1,123 @@ +#!/usr/bin/env bash + +# you shouldn't normally be calling this script directly, it should be called +# by build.sh, but only when build.sh is invoked from libfuzzer-build.sh. + +set -ex -o pipefail + +# logging functions + +export green="\e[92m" +export red="\e[95m" +export normal="\e[0m" + +export color=$normal + +function log { + while read line + do + (echo ; echo -e "${color}${line}${normal}") >> "$LOGFILE" ; + done +} + +# command-line parsing + +export FINAL_LINK=0 # by default we using -fsanitize=fuzzer-no-link + +for arg do + shift + if [ "$arg" = "-fPIE" ] # no more pie + then + set -- "$@" "-fPIC" "-fno-pie" + continue + fi + if [ "$arg" = "-pie" ] + then + set -- "$@" "-no-pie" + continue + fi + if [ "$arg" = "-o" ] # here an output file is being specified + then + if [ "$1" = "zcashd" ] # here zcashd is the output file + then + export FINAL_LINK=1 # we should use -fsanitize=fuzzer because that links libfuzzer + fi + # note no continue, we fall through to default set + fi + set -- "$@" "$arg" +done + +# which source dirs to instrument + +if [ "$dirs_to_instrument" = "" ] +then + export dirs_to_instrument=("^.*\/src$") +fi + +# Store the command line we were given to a file + +echo "`hostname`:`pwd` \$" | log +echo -- "original command: $0 $@" | log + +# decide on a sanitizer option beyond just fuzzing: +# to link nor not to link libfuzzer we only link on +# the final call, to the linker. + +if [ "$LLVM_SANITIZE" = "" ] +then + export LLVM_SANITIZE="address" # you can override this behavior by setting this environment variable first +fi + +if [ "$FINAL_LINK" = "1" ] +then + export LLVM_SANITIZE="-fsanitize=fuzzer,$LLVM_SANITIZE" +else + export LLVM_SANITIZE="-fsanitize=fuzzer-no-link,$LLVM_SANITIZE" +fi + + +# Work out which compiler we were called as + +case $0 in +*zcash-wrapper-clang) + COMPILER="clang" + export DEFINES_FLAGS="${CFLAGS} -DZCASH_FUZZ=1 -DFUZZ_WITH_LIBFUZZER=1 -fPIC" + export INSTRUMENT_FLAGS="${DEFINES_FLAGS} ${LLVM_SANITIZE}" + ;; +*zcash-wrapper-clang++) + COMPILER="clang++" + export DEFINES_FLAGS="${CXXFLAGS} -DZCASH_FUZZ=1 -DFUZZ_WITH_LIBFUZZER=1 -fPIC" + export INSTRUMENT_FLAGS="${DEFINES_FLAGS} ${LLVM_SANITIZE}" + ;; +*zcash-wrapper) + echo -n "Call this script instead of your regular compiler, and if the absolute " + echo -n "path of the CWD the wrapper was called from matches a regex in the " + echo -n "array 'dirs_to_instrument', it will instrument the resulting object. " + echo -n "Otherwise it will exec directly to the original compiler without " + echo "changing arguments." + echo -n "You can also set LLVM_SANITIZE to whatever sanitizers you'd like to use." + echo -n "the default is 'address'. You don't need the -fsanitize=fuzzer part, " + echo "this script handles that" + exit + ;; +esac + +# Check if we should instrument + +for i in "${dirs_to_instrument[@]}" +do + if echo -- "`pwd`" | grep "$i"; then + # We found a match, let's instrument this one. + echo "pwd (`pwd`) matches dirs_to_instrument array element ($i). Adding instrumentation flags..." | log + echo "command with defines and instrumentation added:" | color=$green log + echo -- "$COMPILER" $INSTRUMENT_FLAGS "$@" | log + exec -- "$COMPILER" $INSTRUMENT_FLAGS "$@" + fi +done + +# No match, just pass-through. + +echo -e -- "${red}command with defines added:${normal}" | color=$red log +echo -- "$COMPILER" $DEFINES_FLAGS "$@" | log +exec -- "$COMPILER" $DEFINES_FLAGS "$@" + diff --git a/depend/zcash/zcutil/libfuzzer/zcash-wrapper-clang b/depend/zcash/zcutil/libfuzzer/zcash-wrapper-clang new file mode 120000 index 000000000..e640aa6e1 --- /dev/null +++ b/depend/zcash/zcutil/libfuzzer/zcash-wrapper-clang @@ -0,0 +1 @@ +zcash-wrapper \ No newline at end of file diff --git a/depend/zcash/zcutil/libfuzzer/zcash-wrapper-clang++ b/depend/zcash/zcutil/libfuzzer/zcash-wrapper-clang++ new file mode 120000 index 000000000..e640aa6e1 --- /dev/null +++ b/depend/zcash/zcutil/libfuzzer/zcash-wrapper-clang++ @@ -0,0 +1 @@ +zcash-wrapper \ No newline at end of file diff --git a/depend/zcash/zcutil/make-release.py b/depend/zcash/zcutil/make-release.py index 717c9de0e..22504e3a7 100755 --- a/depend/zcash/zcutil/make-release.py +++ b/depend/zcash/zcutil/make-release.py @@ -84,6 +84,7 @@ def main_logged(release, releaseprev, releasefrom, releaseheight, hotfix): verify_tags(releaseprev, releasefrom) verify_version(release, releaseprev, hotfix) + verify_dependency_updates() initialize_git(release, hotfix) patch_version_in_files(release, releaseprev) patch_release_height(releaseheight) @@ -125,6 +126,11 @@ def verify_dependencies(dependencies): ), ) +@phase('Checking dependency updates.') +def verify_dependency_updates(): + status = subprocess.call(['python', 'qa/zcash/updatecheck.py']) + if status != 0: + raise SystemExit("Dependency update check did not pass.") @phase('Checking tags.') def verify_tags(releaseprev, releasefrom): diff --git a/depend/zcash/zcutil/release-notes.py b/depend/zcash/zcutil/release-notes.py index fdd23cf42..26674a822 100755 --- a/depend/zcash/zcutil/release-notes.py +++ b/depend/zcash/zcutil/release-notes.py @@ -35,7 +35,10 @@ 'paveljanik': 'Pavel Janík', 'Simon': 'Simon Liu', 'str4d': 'Jack Grigg', - 'zebambam': 'Benjamin Winston' + 'zebambam': 'Benjamin Winston', + 'therealyingtong': 'Ying Tong Lai', + 'zancas': 'Zancas Wilcox', + 'bambam': 'Benjamin Winston' } def apply_author_aliases(name): diff --git a/src/lib.rs b/src/lib.rs index ec3eef5b3..b58e61ac9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ #![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")] -#![doc(html_root_url = "https://docs.rs/zcash_script/0.1.4")] +#![doc(html_root_url = "https://docs.rs/zcash_script/0.1.5")] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] @@ -11,6 +11,12 @@ mod blake2b; #[cfg(test)] mod tests { pub use super::zcash_script_error_t; + use hex::FromHex; + + lazy_static::lazy_static! { + pub static ref SCRIPT_PUBKEY: Vec = >::from_hex("76a914f47cac1e6fec195c055994e8064ffccce0044dd788ac").unwrap(); + pub static ref SCRIPT_TX: Vec = >::from_hex("0400008085202f8901fcaf44919d4a17f6181a02a7ebe0420be6f7dad1ef86755b81d5a9567456653c010000006a473044022035224ed7276e61affd53315eca059c92876bc2df61d84277cafd7af61d4dbf4002203ed72ea497a9f6b38eb29df08e830d99e32377edb8a574b8a289024f0241d7c40121031f54b095eae066d96b2557c1f99e40e967978a5fd117465dbec0986ca74201a6feffffff020050d6dc0100000017a9141b8a9bda4b62cd0d0582b55455d0778c86f8628f870d03c812030000001976a914e4ff5512ffafe9287992a1cd177ca6e408e0300388ac62070d0095070d000000000000000000000000").expect("Block bytes are in valid hex representation"); + } pub fn verify_script( script_pub_key: &[u8], @@ -46,11 +52,44 @@ mod tests { Err(err) } } - use hex::FromHex; - lazy_static::lazy_static! { - pub static ref SCRIPT_PUBKEY: Vec = >::from_hex("76a914f47cac1e6fec195c055994e8064ffccce0044dd788ac").unwrap(); - pub static ref SCRIPT_TX: Vec = >::from_hex("0400008085202f8901fcaf44919d4a17f6181a02a7ebe0420be6f7dad1ef86755b81d5a9567456653c010000006a473044022035224ed7276e61affd53315eca059c92876bc2df61d84277cafd7af61d4dbf4002203ed72ea497a9f6b38eb29df08e830d99e32377edb8a574b8a289024f0241d7c40121031f54b095eae066d96b2557c1f99e40e967978a5fd117465dbec0986ca74201a6feffffff020050d6dc0100000017a9141b8a9bda4b62cd0d0582b55455d0778c86f8628f870d03c812030000001976a914e4ff5512ffafe9287992a1cd177ca6e408e0300388ac62070d0095070d000000000000000000000000").expect("Block bytes are in valid hex representation"); + pub fn verify_script_precompute( + script_pub_key: &[u8], + amount: i64, + tx_to: &[u8], + nIn: u32, + flags: u32, + consensus_branch_id: u32, + ) -> Result<(), zcash_script_error_t> { + let script_ptr = script_pub_key.as_ptr(); + let script_len = script_pub_key.len(); + let tx_to_ptr = tx_to.as_ptr(); + let tx_to_len = tx_to.len(); + let mut err = 0; + + let precomputed = + unsafe { super::zcash_script_new_precomputed_tx(tx_to_ptr, tx_to_len as _, &mut err) }; + + let ret = unsafe { + super::zcash_script_verify_precomputed( + precomputed, + nIn, + script_ptr, + script_len as u32, + amount, + flags, + consensus_branch_id, + &mut err, + ) + }; + + unsafe { super::zcash_script_free_precomputed_tx(precomputed) }; + + if ret == 1 { + Ok(()) + } else { + Err(err) + } } #[test] @@ -66,6 +105,19 @@ mod tests { verify_script(script_pub_key, amount, tx_to, nIn, flags, branch_id).unwrap(); } + #[test] + fn it_works_precomputed() { + let coin = i64::pow(10, 8); + let script_pub_key = &*SCRIPT_PUBKEY; + let amount = 212 * coin; + let tx_to = &*SCRIPT_TX; + let nIn = 0; + let flags = 1; + let branch_id = 0x2bb40e60; + + verify_script_precompute(script_pub_key, amount, tx_to, nIn, flags, branch_id).unwrap(); + } + #[test] fn it_doesnt_work() { let coin = i64::pow(10, 8); @@ -78,4 +130,17 @@ mod tests { verify_script(script_pub_key, amount, tx_to, nIn, flags, branch_id).unwrap_err(); } + + #[test] + fn it_doesnt_work_precomputed() { + let coin = i64::pow(10, 8); + let script_pub_key = &*SCRIPT_PUBKEY; + let amount = 212 * coin; + let tx_to = &*SCRIPT_TX; + let nIn = 0; + let flags = 1; + let branch_id = 0x2bb40e61; + + verify_script_precompute(script_pub_key, amount, tx_to, nIn, flags, branch_id).unwrap_err(); + } }