From 0007b3436f917a2042781626d0aef75cc323c281 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 12 Nov 2026 11:00:57 +0100 Subject: [PATCH 01/26] chore: pin rust-dashcore to the key-wallet collateral lock Point every rust-dashcore crate at 2cdb0d6f, the tip of dashpay/rust-dashcore#1391 (`claude/key-wallet-lock-masternode-collateral-5a3da6`), which keeps masternode collateral out of coin selection. The pin is temporary: it moves to the merged `dev` revision once #1391 lands. The revision is 46 commits ahead of the previous pin. Two things in Platform needed adapting: - Cargo.lock: dashcore-rpc-json now requires serde_with 3.24, so the two locked serde_with versions collapse into it, and the base-sdk crates come from crates.io instead of git. - `WalletEvent::BlockProcessed` and `WalletEvent::TransactionDetected` gained `locked_outpoints`; the 24 test constructors in platform-wallet set it to empty. The breaking upstream changes in that range (#1323, #1354, #1362, #1322, #1324) touch nothing Platform uses: `cargo check --workspace --all-targets` passes with no other change. Co-Authored-By: Claude Fable 5.2 --- Cargo.lock | 278 +++++++++--------- Cargo.toml | 16 +- .../src/changeset/core_bridge.rs | 15 + .../rs-platform-wallet/src/manager/mod.rs | 1 + .../rs-platform-wallet/src/test_support.rs | 1 + .../src/wallet/core/spend_observer.rs | 2 + .../identity/network/payment_handler.rs | 2 + .../src/wallet/identity/network/payments.rs | 3 + 8 files changed, 163 insertions(+), 155 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f31b4100ff..3d23d0a1e9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -484,18 +484,13 @@ checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" [[package]] name = "base58ck" version = "0.5.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?rev=7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516#7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df540278d807651653f9b6f21e18903d790d7769eadfbc0dc4df0a141260318f" dependencies = [ - "bitcoin-internals 0.7.0", + "bitcoin-internals 0.6.0", "bitcoin_hashes 1.2.0", ] -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.7" @@ -606,6 +601,17 @@ dependencies = [ "rand_core 0.6.4", "serde", "unicode-normalization", +] + +[[package]] +name = "bip39" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4559bb9225f8401dcea601cf8dc9ed81ea0dadd9cf7755fdefdd93ef7961e19e" +dependencies = [ + "bitcoin_hashes 0.14.101", + "serde", + "unicode-normalization", "zeroize", ] @@ -641,8 +647,9 @@ checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" [[package]] name = "bitcoin-consensus-encoding" -version = "1.2.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?rev=7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516#7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9daa31138eb443d5751b207f3f64154e2bb09cd59960562ccc7a7112be38147f" dependencies = [ "bitcoin-internals 0.7.0", "hex-conservative 1.3.0", @@ -651,11 +658,12 @@ dependencies = [ [[package]] name = "bitcoin-crypto" -version = "0.3.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?rev=7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516#7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef7512cb856b2e58bc249777297cbcd68b363bd9b0466b4726f9af47d680bbeb" dependencies = [ "base58ck", - "bitcoin-internals 0.7.0", + "bitcoin-internals 0.8.2", "bitcoin-network-kind", "bitcoin-primitives", "bitcoin_hashes 1.2.0", @@ -670,10 +678,32 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a90bbbfa552b49101a230fb2668f3f9ef968c81e6f83cf577e1d4b80f689e1aa" +[[package]] +name = "bitcoin-internals" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a30a22d1f112dde8e16be7b45c63645dc165cef254f835b3e1e9553e485cfa64" +dependencies = [ + "hex-conservative 0.3.2", +] + +[[package]] +name = "bitcoin-internals" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d573f4cf32996a8dce612e4348cece65a241f1882ed594047c9ba348e8869fa5" + [[package]] name = "bitcoin-internals" version = "0.7.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?rev=7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516#7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8bea3a9f0cfece4564e37cb49a38cc245ca5184719e50d7d0dda3268722c4e2" + +[[package]] +name = "bitcoin-internals" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3491249864b8cc929bf63e726045702ff1c1a39c990aef2d41bff0b42fee661" dependencies = [ "serde", ] @@ -690,19 +720,21 @@ dependencies = [ [[package]] name = "bitcoin-network-kind" version = "1.0.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?rev=7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516#7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ff0f6bcc535331aa9a99398e34d671a5b37b8385e1f41c18696781c172be3e5" dependencies = [ - "bitcoin-internals 0.7.0", + "bitcoin-internals 0.5.0", "serde", ] [[package]] name = "bitcoin-primitives" -version = "0.103.1" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?rev=7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516#7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516" +version = "0.104.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d569088c0dc0ce0ec5e0288e92011723c8e192f8c2d3ff09840974fa2cbe" dependencies = [ "bitcoin-consensus-encoding", - "bitcoin-internals 0.7.0", + "bitcoin-internals 0.8.2", "bitcoin-units", "bitcoin_hashes 1.2.0", "hex-conservative 1.3.0", @@ -710,11 +742,12 @@ dependencies = [ [[package]] name = "bitcoin-units" -version = "0.5.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?rev=7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516#7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e95f325c563b308c78fe6de36f46b359c1d326271082f0c0140fa4e1a854d26" dependencies = [ "bitcoin-consensus-encoding", - "bitcoin-internals 0.7.0", + "bitcoin-internals 0.8.2", "serde", ] @@ -740,10 +773,11 @@ dependencies = [ [[package]] name = "bitcoin_hashes" version = "1.2.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?rev=7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516#7ba35c7c1dd63892bfb9c9395bbd80e2ab5df516" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5304e53726dbe5f93141535e102ed97b5bf4714fbecefdda8f9fb98d7fdaff0e" dependencies = [ "bitcoin-consensus-encoding", - "bitcoin-internals 0.7.0", + "bitcoin-internals 0.6.0", "hex-conservative 1.3.0", "serde", ] @@ -1670,71 +1704,36 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.11" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" dependencies = [ - "darling_core 0.20.11", - "darling_macro 0.20.11", -] - -[[package]] -name = "darling" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" -dependencies = [ - "darling_core 0.23.0", - "darling_macro 0.23.0", + "darling_core", + "darling_macro", ] [[package]] name = "darling_core" -version = "0.20.11" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" dependencies = [ - "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.117", -] - -[[package]] -name = "darling_core" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" -dependencies = [ - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.117", -] - -[[package]] -name = "darling_macro" -version = "0.20.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" -dependencies = [ - "darling_core 0.20.11", - "quote", - "syn 2.0.117", + "syn 3.0.5", ] [[package]] name = "darling_macro" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" +checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" dependencies = [ - "darling_core 0.23.0", + "darling_core", "quote", - "syn 2.0.117", + "syn 3.0.5", ] [[package]] @@ -1777,7 +1776,7 @@ dependencies = [ [[package]] name = "dash-network" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" dependencies = [ "dash-params", "grovedb-bincode", @@ -1788,19 +1787,19 @@ dependencies = [ [[package]] name = "dash-network-seeds" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" dependencies = [ "dash-network", ] [[package]] name = "dash-num" -version = "0.2.0-beta" -source = "git+https://github.com/dashpay/base-sdk?rev=89828032b6be3341cafda0ce433c010a23217b39#89828032b6be3341cafda0ce433c010a23217b39" +version = "0.3.0-beta" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3da5b9d6becb6809650a2af390edec5492e2fe00845a462cc209f5db5de4fbd4" dependencies = [ "ambassador", - "bitcoin-consensus-encoding", - "bitcoin-internals 0.7.0", + "bitcoin-internals 0.8.2", "dash-types", "delegate", "hex-conservative 1.3.0", @@ -1809,8 +1808,9 @@ dependencies = [ [[package]] name = "dash-params" -version = "0.0.0" -source = "git+https://github.com/dashpay/base-sdk?rev=89828032b6be3341cafda0ce433c010a23217b39#89828032b6be3341cafda0ce433c010a23217b39" +version = "0.1.0-beta" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92befc422f546a50e88b842671c540cf5e275645a09d72651eb360d7349379d3" dependencies = [ "bitcoin-units", "bitcoin_hashes 1.2.0", @@ -1821,8 +1821,9 @@ dependencies = [ [[package]] name = "dash-pkc" -version = "0.2.0-beta" -source = "git+https://github.com/dashpay/base-sdk?rev=89828032b6be3341cafda0ce433c010a23217b39#89828032b6be3341cafda0ce433c010a23217b39" +version = "0.3.0-beta" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6976b4a29dbff7863950fcbdbd2e291b0e6297b1a82bca9311168c4d821e4c" dependencies = [ "aes 0.9.3", "base58ck", @@ -1887,8 +1888,9 @@ dependencies = [ [[package]] name = "dash-pow" -version = "0.1.0-beta" -source = "git+https://github.com/dashpay/base-sdk?rev=89828032b6be3341cafda0ce433c010a23217b39#89828032b6be3341cafda0ce433c010a23217b39" +version = "0.1.1-beta" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "172f6a208c002eba513f78f5e6de75c32dbf4dea708f0c4e4ef8846143e4a97f" dependencies = [ "digest 0.11.3", "wide", @@ -1959,7 +1961,7 @@ dependencies = [ [[package]] name = "dash-spv" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" dependencies = [ "async-trait", "bip324", @@ -1989,13 +1991,13 @@ dependencies = [ [[package]] name = "dash-types" -version = "0.2.0-beta" -source = "git+https://github.com/dashpay/base-sdk?rev=89828032b6be3341cafda0ce433c010a23217b39#89828032b6be3341cafda0ce433c010a23217b39" +version = "0.3.0-beta" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cb813ba640fd2d2cf06248d385e9624c944839547dfb064bea85ec02ab61e8" dependencies = [ "bitcoin-consensus-encoding", "bitcoin-primitives", "cfg-if", - "dash-types-marker", "hex-conservative 1.3.0", "serde", "subtle", @@ -2003,20 +2005,10 @@ dependencies = [ "zeroize", ] -[[package]] -name = "dash-types-marker" -version = "0.1.0-beta" -source = "git+https://github.com/dashpay/base-sdk?rev=89828032b6be3341cafda0ce433c010a23217b39#89828032b6be3341cafda0ce433c010a23217b39" -dependencies = [ - "quote", - "syn 2.0.117", - "xxhash-rust", -] - [[package]] name = "dashcore" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" dependencies = [ "anyhow", "base64 0.23.1", @@ -2042,8 +2034,9 @@ dependencies = [ [[package]] name = "dashcore-crypto" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" dependencies = [ + "base58ck", "bitcoin-crypto", "dash-network", "dash-pkc", @@ -2063,12 +2056,12 @@ dependencies = [ [[package]] name = "dashcore-private" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" [[package]] name = "dashcore-rpc" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" dependencies = [ "dashcore-rpc-json", "hex-conservative 1.3.0", @@ -2081,7 +2074,7 @@ dependencies = [ [[package]] name = "dashcore-rpc-json" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" dependencies = [ "dashcore", "grovedb-bincode", @@ -2090,13 +2083,13 @@ dependencies = [ "serde", "serde_json", "serde_repr", - "serde_with 2.3.3", + "serde_with", ] [[package]] name = "dashcore_hashes" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" dependencies = [ "bitcoin_hashes 1.2.0", "dash-pow", @@ -3195,7 +3188,7 @@ dependencies = [ [[package]] name = "git-state" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" [[package]] name = "glob" @@ -3503,7 +3496,7 @@ version = "6.1.1" source = "git+https://github.com/dashpay/grovedb?rev=fa92511cb7cdc19f5977d64f20f93107f62844b1#fa92511cb7cdc19f5977d64f20f93107f62844b1" dependencies = [ "serde", - "serde_with 3.21.0", + "serde_with", ] [[package]] @@ -4217,10 +4210,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4603d3033e49e2b0e31229fcab20a5d40089c607d975cd9c80551dc69eed9102" dependencies = [ "jiff-static", + "jiff-tzdb-platform", "log", "portable-atomic", "portable-atomic-util", "serde_core", + "windows-link", ] [[package]] @@ -4234,6 +4229,21 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "jiff-tzdb" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa8377070c6bae868759445e5a77f66d84f0b72f3a054bfb00e6d038b8282da7" + +[[package]] +name = "jiff-tzdb-platform" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" +dependencies = [ + "jiff-tzdb", +] + [[package]] name = "jni" version = "0.21.1" @@ -4406,10 +4416,10 @@ dependencies = [ [[package]] name = "key-wallet" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" dependencies = [ "async-trait", - "bip39", + "bip39 3.0.0", "bitflags 2.13.0", "dashcore", "dashcore_hashes", @@ -4427,7 +4437,7 @@ dependencies = [ [[package]] name = "key-wallet-manager" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" dependencies = [ "async-trait", "dashcore", @@ -7147,10 +7157,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.150" +version = "1.0.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" dependencies = [ + "foldhash 0.2.0", "indexmap 2.14.0", "itoa", "memchr", @@ -7204,62 +7215,35 @@ dependencies = [ [[package]] name = "serde_with" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" -dependencies = [ - "base64 0.13.1", - "chrono", - "hex", - "indexmap 1.9.3", - "serde", - "serde_json", - "serde_with_macros 2.3.3", - "time", -] - -[[package]] -name = "serde_with" -version = "3.21.0" +version = "3.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a5c54c7310e7b8b9577c286d7e399ddd876c3e12b3ed917a8aabc4b96e9e8c" +checksum = "df9adc193c780ef8f159aee8b61e2d5801aaa555e6eb0947fe45530ec506296f" dependencies = [ - "base64 0.22.1", + "base64 0.23.1", "bs58", "chrono", "hex", "indexmap 1.9.3", "indexmap 2.14.0", + "jiff", "schemars 0.9.0", "schemars 1.2.1", "serde_core", "serde_json", - "serde_with_macros 3.21.0", + "serde_with_macros", "time", ] [[package]] name = "serde_with_macros" -version = "2.3.3" +version = "3.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" +checksum = "3e17bbc68e28663bbbb90df47e058aa7eda4fb445b89fe70457bb94fbccf6e49" dependencies = [ - "darling 0.20.11", + "darling", "proc-macro2", "quote", - "syn 2.0.117", -] - -[[package]] -name = "serde_with_macros" -version = "3.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84d57bc0c8b9a17920c178daa6bb924850d54a9c97ab45194bb8c17ad66bb660" -dependencies = [ - "darling 0.23.0", - "proc-macro2", - "quote", - "syn 2.0.117", + "syn 3.0.5", ] [[package]] @@ -9010,7 +8994,7 @@ version = "5.0.3" dependencies = [ "async-trait", "base64 0.22.1", - "bip39", + "bip39 2.2.2", "console_error_panic_hook", "dapi-grpc", "dash-core-proof", diff --git a/Cargo.toml b/Cargo.toml index ae9ae03aa37..e8ae7b198c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,14 +70,14 @@ grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb grovedb-version = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb7cdc19f5977d64f20f93107f62844b1" } grovedb-epoch-based-storage-flags = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb7cdc19f5977d64f20f93107f62844b1" } grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb7cdc19f5977d64f20f93107f62844b1" } -dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -dashcore-crypto = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } +dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } +dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } +dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } +key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } +key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } +dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } +dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } +dashcore-crypto = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } tokio-metrics = "0.5" # Size-tuned profile for the iOS `rs-unified-sdk-ffi` staticlib, which diff --git a/packages/rs-platform-wallet/src/changeset/core_bridge.rs b/packages/rs-platform-wallet/src/changeset/core_bridge.rs index a0594b36402..417dbf56b2d 100644 --- a/packages/rs-platform-wallet/src/changeset/core_bridge.rs +++ b/packages/rs-platform-wallet/src/changeset/core_bridge.rs @@ -3200,6 +3200,7 @@ mod sent_payment_verdict_tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: Vec::new(), + locked_outpoints: Vec::new(), } } @@ -3373,6 +3374,7 @@ mod sent_payment_verdict_tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: Vec::new(), + locked_outpoints: Vec::new(), }; let overlay = sent_payment_verdicts(&wallet_manager, &event).await; @@ -3453,6 +3455,7 @@ mod sent_payment_verdict_tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: Vec::new(), + locked_outpoints: Vec::new(), }; assert!(sent_payment_evidence(&event).is_empty()); } @@ -3704,6 +3707,7 @@ mod contact_watch_only_projection_tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], } } @@ -3714,6 +3718,7 @@ mod contact_watch_only_projection_tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], } } @@ -4027,6 +4032,7 @@ mod contact_watch_only_projection_tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], }; let cs = build_core_changeset(&test_manager(), &event).await; @@ -4091,6 +4097,7 @@ mod contact_watch_only_projection_tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], }; let cs = build_core_changeset(&test_manager(), &event).await; @@ -4153,6 +4160,7 @@ mod contact_watch_only_projection_tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], }; merged.merge(build_core_changeset(&manager, &confirmation).await); @@ -4565,6 +4573,7 @@ mod contact_watch_only_projection_tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], }; let cs = build_core_changeset(&manager, &lone_event).await; @@ -6306,6 +6315,7 @@ mod tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], } } @@ -7471,6 +7481,7 @@ mod tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], }) .expect("send event"); @@ -7604,6 +7615,7 @@ mod tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], }) .expect("send reconstruction event"); let observed = obs_rx.recv().await.expect("reconstruction store"); @@ -7875,6 +7887,7 @@ mod tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], }) .expect("send block event"); let observed = obs_rx.recv().await.expect("first batch stored"); @@ -9068,6 +9081,7 @@ mod utxo_credit_verdict_tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], }; let cs = build_core_changeset(&manager, &event(wallet_id)).await; @@ -9161,6 +9175,7 @@ mod utxo_credit_verdict_tests { balance: WalletCoreBalance::default(), account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], }; let cs = build_core_changeset(&manager, &event).await; assert_eq!( diff --git a/packages/rs-platform-wallet/src/manager/mod.rs b/packages/rs-platform-wallet/src/manager/mod.rs index b074deb07ed..12deb900b55 100644 --- a/packages/rs-platform-wallet/src/manager/mod.rs +++ b/packages/rs-platform-wallet/src/manager/mod.rs @@ -2042,6 +2042,7 @@ mod tests { balance: corrected, account_balances: BTreeMap::new(), addresses_derived: vec![], + locked_outpoints: vec![], }); // Observable immediately — before the lifecycle writer commits. diff --git a/packages/rs-platform-wallet/src/test_support.rs b/packages/rs-platform-wallet/src/test_support.rs index edcf03a0194..30b691c1145 100644 --- a/packages/rs-platform-wallet/src/test_support.rs +++ b/packages/rs-platform-wallet/src/test_support.rs @@ -328,6 +328,7 @@ pub(crate) fn observed_spend_event( balance: key_wallet::WalletCoreBalance::default(), account_balances: std::collections::BTreeMap::new(), addresses_derived: Vec::new(), + locked_outpoints: Vec::new(), } } diff --git a/packages/rs-platform-wallet/src/wallet/core/spend_observer.rs b/packages/rs-platform-wallet/src/wallet/core/spend_observer.rs index e57e57c759b..14b590d66b9 100644 --- a/packages/rs-platform-wallet/src/wallet/core/spend_observer.rs +++ b/packages/rs-platform-wallet/src/wallet/core/spend_observer.rs @@ -274,6 +274,7 @@ mod tests { balance: WalletCoreBalance::default(), account_balances: std::collections::BTreeMap::new(), addresses_derived: Vec::new(), + locked_outpoints: Vec::new(), } } @@ -288,6 +289,7 @@ mod tests { balance: WalletCoreBalance::default(), account_balances: std::collections::BTreeMap::new(), addresses_derived: Vec::new(), + locked_outpoints: Vec::new(), } } diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/payment_handler.rs b/packages/rs-platform-wallet/src/wallet/identity/network/payment_handler.rs index fae2098da34..a6ab8b2b6f6 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/payment_handler.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/payment_handler.rs @@ -385,6 +385,7 @@ mod tests { balance: WalletCoreBalance::default(), account_balances: std::collections::BTreeMap::new(), addresses_derived: Vec::new(), + locked_outpoints: Vec::new(), } } @@ -427,6 +428,7 @@ mod tests { balance: WalletCoreBalance::default(), account_balances: std::collections::BTreeMap::new(), addresses_derived: Vec::new(), + locked_outpoints: Vec::new(), }; let txids: Vec<_> = dashpay_payment_records(&event) .iter() diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs b/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs index 5060aa6295d..56decc9a798 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs @@ -8783,6 +8783,7 @@ mod tests { balance: WalletCoreBalance::default(), account_balances: std::collections::BTreeMap::new(), addresses_derived: Vec::new(), + locked_outpoints: Vec::new(), }; // The payment handler must NOT write a sent-payment verdict: it runs @@ -8903,6 +8904,7 @@ mod tests { balance: WalletCoreBalance::default(), account_balances: std::collections::BTreeMap::new(), addresses_derived: Vec::new(), + locked_outpoints: Vec::new(), }; crate::changeset::core_bridge::sent_payment_verdicts(&iw.wallet_manager, &matured_event) .await; @@ -9060,6 +9062,7 @@ mod tests { balance: WalletCoreBalance::default(), account_balances: std::collections::BTreeMap::new(), addresses_derived: Vec::new(), + locked_outpoints: Vec::new(), }; crate::changeset::core_bridge::sent_payment_verdicts(&iw.wallet_manager, &event).await; From b6002606ab15aa7db8dd0ee24cf7d3a782b01abc Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 28 Sep 2026 13:00:16 +0700 Subject: [PATCH 02/26] feat(platform-wallet)!: keep masternode collateral out of coin selection The wallet now keeps outputs that back a registered masternode out of coin selection, persists those locks, and exposes explicit lock and unlock. Spending the collateral would end the masternode registration. key-wallet locks the collateral of every ProRegTx a transaction check processes and skips locked coins in every selection strategy, the asset-lock builder and special-transaction funding. This carries that lock set through platform-wallet: - PlatformWalletInfo::check_core_transaction queues the outpoints a check locked. No WalletEvent carries them, so the wallet-event adapter drains the queue into the wallet's next changeset, as CoreChangeSet::outpoint_locks. The load-time replay of unconfirmed sends queues its locks the same way. - PlatformWallet::lock_outpoint / unlock_outpoint / locked_outpoints lock and unlock by hand and persist the change before returning. - On load, and when a wallet is registered, the collateral of every ProRegTx in a wallet's history and of every tracked masternode whose registration is known is locked; a tracked masternode's refresh locks it once its registration is fetched. This covers a registration the wallet never processed and one restored without a check. - SQLite: V019 adds core_locked_outpoints, keyed (wallet_id, outpoint), written by core_state::apply and handed back through lock_outpoint on load; restored coins carry their lock. - FFI: a persist / load / free trio on the persistence extension, the OUTPOINT_LOCKS capability (bit 13), and platform_wallet_lock_outpoint, platform_wallet_unlock_outpoint and platform_wallet_locked_outpoints. - Swift: PersistentLockedOutpoint rows, the trio's callbacks, and ManagedPlatformWallet.lockedOutpoints / lockOutpoint / unlockOutpoint. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 523a81e0e9565146495886826c984e6e4a91a827) Conflicts with v5.1-dev are resolved by keeping both sides, and the new tests are placed at the end of the current test modules. The numbers that now collide (migration V019, capability bit 13), the adaptation of the tests to the current helpers and the move to the API of dashpay/rust-dashcore#1391 follow in separate commits. Co-Authored-By: Claude Fable 5.2 --- .../src/core_wallet_types.rs | 27 + packages/rs-platform-wallet-ffi/src/lib.rs | 2 + .../rs-platform-wallet-ffi/src/manager.rs | 24 +- .../src/outpoint_locks.rs | 189 ++++++ .../rs-platform-wallet-ffi/src/persistence.rs | 364 ++++++++++- packages/rs-platform-wallet-storage/SCHEMA.md | 1 + .../migrations/V019__core_locked_outpoints.rs | 28 + .../src/sqlite/persister.rs | 9 +- .../src/sqlite/rehydrate.rs | 16 + .../src/sqlite/schema/core_state.rs | 44 +- .../tests/sqlite_locked_outpoints.rs | 365 +++++++++++ .../src/changeset/changeset.rs | 25 + .../src/changeset/core_bridge.rs | 98 ++- .../src/changeset/persistence_capabilities.rs | 12 + .../src/manager/accessors.rs | 1 + .../rs-platform-wallet/src/manager/load.rs | 181 ++++++ .../src/manager/wallet_lifecycle.rs | 6 + .../src/masternode/tracked.rs | 40 +- .../src/masternode/update_service.rs | 57 ++ .../rs-platform-wallet/src/test_support.rs | 133 ++++ .../rs-platform-wallet/src/wallet/apply.rs | 1 + .../src/wallet/asset_lock/build.rs | 57 ++ .../wallet/asset_lock/sync/reconstruction.rs | 1 + .../src/wallet/asset_lock/sync/recovery.rs | 1 + .../src/wallet/core/transaction.rs | 201 ++++++ .../identity/network/contact_requests.rs | 1 + .../src/wallet/identity/network/payments.rs | 108 ++++ packages/rs-platform-wallet/src/wallet/mod.rs | 1 + .../src/wallet/outpoint_locks.rs | 602 ++++++++++++++++++ .../src/wallet/platform_wallet.rs | 12 +- .../src/wallet/platform_wallet_traits.rs | 6 + .../Persistence/DashModelContainer.swift | 3 +- .../Models/PersistentLockedOutpoint.swift | 25 + .../ManagedPlatformWallet.swift | 72 +++ .../PlatformWalletManager.swift | 6 + .../PlatformWalletPersistenceHandler.swift | 195 ++++++ .../DashModelMigrationTests.swift | 7 +- .../InvitationPersistenceTests.swift | 3 + packages/swift-sdk/schema-models.json | 3 +- 39 files changed, 2906 insertions(+), 21 deletions(-) create mode 100644 packages/rs-platform-wallet-ffi/src/outpoint_locks.rs create mode 100644 packages/rs-platform-wallet-storage/migrations/V019__core_locked_outpoints.rs create mode 100644 packages/rs-platform-wallet-storage/tests/sqlite_locked_outpoints.rs create mode 100644 packages/rs-platform-wallet/src/wallet/outpoint_locks.rs create mode 100644 packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentLockedOutpoint.swift diff --git a/packages/rs-platform-wallet-ffi/src/core_wallet_types.rs b/packages/rs-platform-wallet-ffi/src/core_wallet_types.rs index 5e5c28d9546..595baa17f91 100644 --- a/packages/rs-platform-wallet-ffi/src/core_wallet_types.rs +++ b/packages/rs-platform-wallet-ffi/src/core_wallet_types.rs @@ -147,6 +147,33 @@ pub fn build_dashpay_backfill_covered_for_callback( contact_identity_id: entry.contact.to_buffer(), account_index: entry.account_index, covered_from: entry.covered_from, +/// One change to a wallet's locked outpoints, carried by the persistence +/// extension's `on_persist_wallet_changeset_outpoint_locks_fn` slot. +/// +/// A locked outpoint is kept out of coin selection: the collateral of a +/// masternode registration the wallet processed (spending it would end the +/// registration), or an outpoint locked by hand. The lock does not need a +/// coin behind it, so a host keeps it apart from its UTXO rows, keyed by +/// `(wallet_id, outpoint)`, and hands every stored lock back through the +/// `on_load_wallet_locked_outpoints_fn` slot. +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct OutpointLockFFI { + pub outpoint: OutPointFFI, + /// `true`: store the lock. `false`: delete it. + pub locked: bool, +} + +/// Project a changeset's outpoint locks into their C mirrors for the +/// extension slot, in outpoint order. +pub(crate) fn build_outpoint_locks_for_callback( + cs: &platform_wallet::changeset::CoreChangeSet, +) -> Vec { + cs.outpoint_locks + .iter() + .map(|(outpoint, locked)| OutpointLockFFI { + outpoint: OutPointFFI::from(outpoint), + locked: *locked, }) .collect() } diff --git a/packages/rs-platform-wallet-ffi/src/lib.rs b/packages/rs-platform-wallet-ffi/src/lib.rs index 7689e70b984..7d88e41988d 100644 --- a/packages/rs-platform-wallet-ffi/src/lib.rs +++ b/packages/rs-platform-wallet-ffi/src/lib.rs @@ -65,6 +65,7 @@ pub mod masternode_update_service; pub mod masternode_withdrawal; pub mod memory_explorer; pub mod mnemonic_words; +pub mod outpoint_locks; pub mod parse_state_transition; pub mod persistence; pub mod platform_address_sync; @@ -153,6 +154,7 @@ pub use manager::*; pub use manager_diagnostics::*; pub use memory_explorer::*; pub use mnemonic_words::*; +pub use outpoint_locks::*; pub use persistence::*; pub use platform_address_sync::*; pub use platform_address_types::*; diff --git a/packages/rs-platform-wallet-ffi/src/manager.rs b/packages/rs-platform-wallet-ffi/src/manager.rs index 51e38104709..2b8790c54e8 100644 --- a/packages/rs-platform-wallet-ffi/src/manager.rs +++ b/packages/rs-platform-wallet-ffi/src/manager.rs @@ -9,15 +9,16 @@ use crate::event_handler::{ use crate::handle::*; use crate::persistence::{ FFIPersister, FreePrivateContactScanStateFn, FreePrivateContactScanStateWalletsFn, - FreeTrackedMasternodesFn, LoadAssetLockOperationIdFn, LoadAssetLockShieldedRecipientFn, - LoadIdentityBalanceBlockTimeFn, LoadPrivateContactScanStateFn, - LoadPrivateContactScanStateWalletsFn, LoadTrackedMasternodesFn, PersistAssetLockOperationIdFn, + FreeTrackedMasternodesFn, FreeWalletLockedOutpointsFn, LoadAssetLockOperationIdFn, + LoadAssetLockShieldedRecipientFn, LoadIdentityBalanceBlockTimeFn, + LoadPrivateContactScanStateFn, LoadPrivateContactScanStateWalletsFn, + LoadTrackedMasternodesFn, LoadWalletLockedOutpointsFn, PersistAssetLockOperationIdFn, PersistAssetLockShieldedRecipientFn, PersistDpnsNameStatesFn, PersistIdentityBalanceBlockTimeFn, PersistPrivateContactScanStateFn, PersistTrackedMasternodesFn, PersistWalletChangesetChainLockHeightFn, - PersistWalletChangesetSweepsFn, PersistWalletChangesetUtxoVerdictsFn, - PersistWalletDashPayBackfillFn, PersistenceCallbacks, PersistenceCallbacksExtension, - PersistenceCapabilitiesFFI, PersistenceExtensionCallbacks, + PersistWalletChangesetOutpointLocksFn, PersistWalletChangesetSweepsFn, + PersistWalletChangesetUtxoVerdictsFn, PersistWalletDashPayBackfillFn, PersistenceCallbacks, + PersistenceCallbacksExtension, PersistenceCapabilitiesFFI, PersistenceExtensionCallbacks, PLATFORM_WALLET_PERSISTENCE_CALLBACKS_EXTENSION_VERSION, }; use crate::runtime::runtime; @@ -407,6 +408,17 @@ unsafe fn persistence_extension_callbacks( load_private_contact_scan_state_wallets_free: slot!( on_load_private_contact_scan_state_wallets_free_fn, FreePrivateContactScanStateWalletsFn + wallet_changeset_outpoint_locks: slot!( + on_persist_wallet_changeset_outpoint_locks_fn, + PersistWalletChangesetOutpointLocksFn + ), + load_wallet_locked_outpoints: slot!( + on_load_wallet_locked_outpoints_fn, + LoadWalletLockedOutpointsFn + ), + load_wallet_locked_outpoints_free: slot!( + on_load_wallet_locked_outpoints_free_fn, + FreeWalletLockedOutpointsFn ), } } diff --git a/packages/rs-platform-wallet-ffi/src/outpoint_locks.rs b/packages/rs-platform-wallet-ffi/src/outpoint_locks.rs new file mode 100644 index 00000000000..3d72f003808 --- /dev/null +++ b/packages/rs-platform-wallet-ffi/src/outpoint_locks.rs @@ -0,0 +1,189 @@ +//! FFI bindings for a wallet's locked outpoints: the outpoints kept out of +//! coin selection. +//! +//! The wallet locks the collateral of every masternode registration it +//! processes, since spending the collateral would end the registration. +//! These calls list the locks and lock or unlock an outpoint by hand; a lock +//! or unlock is persisted before the call returns (see +//! `PlatformWallet::lock_outpoint`). + +use crate::check_ptr; +use crate::core_wallet_types::OutPointFFI; +use crate::error::*; +use crate::handle::*; +use crate::runtime::block_on_worker; +use crate::{unwrap_option_or_return, unwrap_result_or_return}; + +/// List the outpoints the wallet keeps out of coin selection, in outpoint +/// order. An entry may name a coin the wallet does not hold (yet). +/// +/// The caller owns the array and frees it with +/// [`platform_wallet_locked_outpoints_free`]. `out_outpoints` / `out_count` +/// are set to null / 0 when nothing is locked. +/// +/// # Safety +/// `out_outpoints` and `out_count` must be writable. `handle` must refer to +/// a live platform wallet for the duration of this call. +#[no_mangle] +pub unsafe extern "C" fn platform_wallet_locked_outpoints( + handle: Handle, + out_outpoints: *mut *const OutPointFFI, + out_count: *mut usize, +) -> PlatformWalletFFIResult { + check_ptr!(out_outpoints); + check_ptr!(out_count); + *out_outpoints = std::ptr::null(); + *out_count = 0; + + let option = PLATFORM_WALLET_STORAGE.with_item(handle, |wallet| { + let wallet = wallet.clone(); + block_on_worker(async move { wallet.locked_outpoints().await }) + }); + let result = unwrap_option_or_return!(option); + let outpoints: Vec = unwrap_result_or_return!(result) + .iter() + .map(OutPointFFI::from) + .collect(); + if outpoints.is_empty() { + return PlatformWalletFFIResult::ok(); + } + *out_count = outpoints.len(); + *out_outpoints = Box::into_raw(outpoints.into_boxed_slice()) as *const OutPointFFI; + PlatformWalletFFIResult::ok() +} + +/// Free an array returned by [`platform_wallet_locked_outpoints`]. +/// +/// # Safety +/// `outpoints` / `count` must be exactly what that call returned, freed once. +#[no_mangle] +pub unsafe extern "C" fn platform_wallet_locked_outpoints_free( + outpoints: *mut OutPointFFI, + count: usize, +) { + if !outpoints.is_null() && count > 0 { + let _ = Box::from_raw(std::ptr::slice_from_raw_parts_mut(outpoints, count)); + } +} + +/// Lock `outpoint`, so no send, asset lock or special-transaction fee spends +/// it until [`platform_wallet_unlock_outpoint`]. The wallet does not need to +/// hold the coin yet. `out_changed` is set to whether the outpoint was not +/// locked before. +/// +/// The lock is persisted before this returns. On a persistence error the +/// wallet still holds the lock in memory, but it does not survive a restart. +/// +/// # Safety +/// `outpoint` must be readable and `out_changed` writable. `handle` must +/// refer to a live platform wallet for the duration of this call. +#[no_mangle] +pub unsafe extern "C" fn platform_wallet_lock_outpoint( + handle: Handle, + outpoint: *const OutPointFFI, + out_changed: *mut bool, +) -> PlatformWalletFFIResult { + set_outpoint_lock(handle, outpoint, out_changed, true) +} + +/// Unlock `outpoint`, so coin selection may spend it again. Unlocking a +/// masternode collateral lets a send spend it, and spending it ends the +/// masternode registration. `out_changed` is set to whether the outpoint +/// was locked. +/// +/// The unlock is persisted before this returns. On a persistence error the +/// outpoint is unlocked in memory but comes back locked after a restart. +/// +/// # Safety +/// As [`platform_wallet_lock_outpoint`]. +#[no_mangle] +pub unsafe extern "C" fn platform_wallet_unlock_outpoint( + handle: Handle, + outpoint: *const OutPointFFI, + out_changed: *mut bool, +) -> PlatformWalletFFIResult { + set_outpoint_lock(handle, outpoint, out_changed, false) +} + +unsafe fn set_outpoint_lock( + handle: Handle, + outpoint: *const OutPointFFI, + out_changed: *mut bool, + locked: bool, +) -> PlatformWalletFFIResult { + check_ptr!(outpoint); + check_ptr!(out_changed); + *out_changed = false; + let outpoint = dashcore::OutPoint::from(&*outpoint); + + let option = PLATFORM_WALLET_STORAGE.with_item(handle, |wallet| { + let wallet = wallet.clone(); + block_on_worker(async move { + if locked { + wallet.lock_outpoint(outpoint).await + } else { + wallet.unlock_outpoint(outpoint).await + } + }) + }); + let result = unwrap_option_or_return!(option); + *out_changed = unwrap_result_or_return!(result); + PlatformWalletFFIResult::ok() +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::runtime::runtime; + use platform_wallet::test_support::test_platform_wallet_manager; + + unsafe fn listed(handle: Handle) -> Vec<(u8, u32)> { + let mut ptr: *const OutPointFFI = std::ptr::null(); + let mut count = 0usize; + let result = platform_wallet_locked_outpoints(handle, &mut ptr, &mut count); + assert_eq!(result.code, PlatformWalletFFIResultCode::Success); + if count == 0 { + assert!(ptr.is_null()); + return Vec::new(); + } + let entries = std::slice::from_raw_parts(ptr, count) + .iter() + .map(|outpoint| (outpoint.txid[0], outpoint.vout)) + .collect(); + platform_wallet_locked_outpoints_free(ptr as *mut OutPointFFI, count); + entries + } + + #[test] + fn should_lock_list_and_unlock_an_outpoint_through_the_ffi() { + let (manager, handle) = runtime().block_on(async { + let (manager, wallet_id) = test_platform_wallet_manager().await; + let wallet = manager.get_wallet(&wallet_id).await.expect("wallet"); + (manager, PLATFORM_WALLET_STORAGE.insert(wallet)) + }); + let outpoint = OutPointFFI { + txid: [0x33; 32], + vout: 2, + }; + let mut changed = false; + unsafe { + assert!(listed(handle).is_empty()); + + let result = platform_wallet_lock_outpoint(handle, &outpoint, &mut changed); + assert_eq!(result.code, PlatformWalletFFIResultCode::Success); + assert!(changed, "the outpoint was not locked before"); + assert_eq!(listed(handle), vec![(0x33, 2)]); + + let result = platform_wallet_unlock_outpoint(handle, &outpoint, &mut changed); + assert_eq!(result.code, PlatformWalletFFIResultCode::Success); + assert!(changed, "the outpoint was locked"); + assert!(listed(handle).is_empty()); + + let result = platform_wallet_unlock_outpoint(handle, &outpoint, &mut changed); + assert_eq!(result.code, PlatformWalletFFIResultCode::Success); + assert!(!changed, "unlocking twice changes nothing"); + } + PLATFORM_WALLET_STORAGE.remove(handle); + drop(manager); + } +} diff --git a/packages/rs-platform-wallet-ffi/src/persistence.rs b/packages/rs-platform-wallet-ffi/src/persistence.rs index 37bcecc9f82..e114992f167 100644 --- a/packages/rs-platform-wallet-ffi/src/persistence.rs +++ b/packages/rs-platform-wallet-ffi/src/persistence.rs @@ -59,9 +59,10 @@ use crate::contact_persistence::{ }; use crate::core_address_types::{AddressPoolTypeTagFFI, CoreAddressEntryFFI, KeyTypeTagFFI}; use crate::core_wallet_types::{ - build_dashpay_backfill_covered_for_callback, build_sweep_batches_for_callback, - build_utxo_credit_verdicts_for_callback, free_wallet_changeset_ffi, - DashPayBackfillCoveredContactFFI, SweepBatchFFI, UtxoCreditVerdictFFI, WalletChangeSetFFI, + build_dashpay_backfill_covered_for_callback, build_outpoint_locks_for_callback, + build_sweep_batches_for_callback, build_utxo_credit_verdicts_for_callback, + free_wallet_changeset_ffi, DashPayBackfillCoveredContactFFI, OutPointFFI, OutpointLockFFI, + SweepBatchFFI, UtxoCreditVerdictFFI, WalletChangeSetFFI, }; use crate::dashpay_payment::{build_payment_persist_entries, DashpayPaymentPersistEntryFFI}; use crate::dpns_name_state_persistence::{ @@ -198,6 +199,12 @@ pub const PLATFORM_WALLET_PERSISTENCE_CAPABILITY_ASSET_LOCK_SHIELDED_RECIPIENTS: /// un-ignore stores the sender's removal and the read-position rewind it /// brings in one changeset. pub const PLATFORM_WALLET_PERSISTENCE_CAPABILITY_PRIVATE_CONTACT_REQUEST_SCAN_STATE: u64 = 1 << 15; +/// Locked outpoints (masternode collateral, and outpoints locked by hand) +/// are persisted AND restored. Requires the extension trio +/// `on_persist_wallet_changeset_outpoint_locks_fn` + +/// `on_load_wallet_locked_outpoints_fn` + +/// `on_load_wallet_locked_outpoints_free_fn`, and the host declaring the bit. +pub const PLATFORM_WALLET_PERSISTENCE_CAPABILITY_OUTPOINT_LOCKS: u64 = 1 << 13; /// Version of [`PersistenceCallbacksExtension`]. The extension is deliberately /// separate from [`PersistenceCallbacks`]: existing hosts pass the latter by @@ -455,6 +462,35 @@ pub type FreePrivateContactScanStateWalletsFn = unsafe extern "C" fn( wallet_ids: *const [u8; 32], wallet_ids_count: usize, ); +/// Carries a round's changes to the wallet's locked outpoints (see +/// [`OutpointLockFFI`]): store a row per `locked` entry, keyed by +/// `(wallet_id, outpoint)`, and delete the row of every other entry. A lock +/// needs no coin behind it, so the row lives apart from the UTXO rows and +/// survives the coin being spent. Fired inside the round's begin/end bracket, +/// after the round's other core callbacks, only on rounds that carry a lock +/// change. A non-zero return fails the round like any other per-kind +/// callback. +pub type PersistWalletChangesetOutpointLocksFn = unsafe extern "C" fn( + context: *mut c_void, + wallet_id: *const u8, + locks: *const OutpointLockFFI, + locks_count: usize, +) -> i32; + +/// Return every outpoint the host keeps locked for `wallet_id`, whether or +/// not it holds the coin. The host allocates the array and keeps it valid +/// until Rust hands it back through the matching free callback. Called once +/// per restored wallet during load. +pub type LoadWalletLockedOutpointsFn = unsafe extern "C" fn( + context: *mut c_void, + wallet_id: *const u8, + out_outpoints: *mut *const OutPointFFI, + out_count: *mut usize, +) -> i32; + +/// Release an array previously returned by a [`LoadWalletLockedOutpointsFn`]. +pub type FreeWalletLockedOutpointsFn = + unsafe extern "C" fn(context: *mut c_void, outpoints: *const OutPointFFI, count: usize); /// Size- and version-tagged additive persistence callbacks. /// @@ -708,6 +744,32 @@ pub struct PersistenceCallbacksExtension { wallet_ids: *const [u8; 32], wallet_ids_count: usize, ), + /// The round's outpoint lock changes (see + /// [`PersistWalletChangesetOutpointLocksFn`]). Wired together with the + /// load + free pair below: the `OUTPOINT_LOCKS` capability is attested + /// only when all three are present (and declared). Appended under the + /// same version as every slot above; a host whose `struct_size` stops + /// before it keeps locks for the session only. + pub on_persist_wallet_changeset_outpoint_locks_fn: Option< + unsafe extern "C" fn( + context: *mut c_void, + wallet_id: *const u8, + locks: *const OutpointLockFFI, + locks_count: usize, + ) -> i32, + >, + /// See [`LoadWalletLockedOutpointsFn`]. + pub on_load_wallet_locked_outpoints_fn: Option< + unsafe extern "C" fn( + context: *mut c_void, + wallet_id: *const u8, + out_outpoints: *mut *const OutPointFFI, + out_count: *mut usize, + ) -> i32, + >, + /// See [`FreeWalletLockedOutpointsFn`]. + pub on_load_wallet_locked_outpoints_free_fn: Option< + unsafe extern "C" fn(context: *mut c_void, outpoints: *const OutPointFFI, count: usize), >, } @@ -736,6 +798,9 @@ impl Default for PersistenceCallbacksExtension { on_load_private_contact_scan_state_free_fn: None, on_load_private_contact_scan_state_wallets_fn: None, on_load_private_contact_scan_state_wallets_free_fn: None, + on_persist_wallet_changeset_outpoint_locks_fn: None, + on_load_wallet_locked_outpoints_fn: None, + on_load_wallet_locked_outpoints_free_fn: None, } } } @@ -764,6 +829,9 @@ pub struct PersistenceExtensionCallbacks { pub load_private_contact_scan_state_free: Option, pub load_private_contact_scan_state_wallets: Option, pub load_private_contact_scan_state_wallets_free: Option, + pub wallet_changeset_outpoint_locks: Option, + pub load_wallet_locked_outpoints: Option, + pub load_wallet_locked_outpoints_free: Option, } /// Return value by which a persistence callback reports a **retryable** @@ -1705,6 +1773,11 @@ pub struct FFIPersister { tracked_masternodes_callbacks: PersistenceExtensionCallbacks, persist_identity_balance_block_time_callback: Option, load_identity_balance_block_time_callback: Option, + /// Extension-negotiated outpoint-lock trio (persist / load / free). A + /// host without it keeps locks for the session only. + wallet_changeset_outpoint_locks_callback: Option, + load_wallet_locked_outpoints_callback: Option, + load_wallet_locked_outpoints_free_callback: Option, /// Semantic capability declaration supplied separately from the callback /// vtable by the additive manager-create API. Keeping this out of /// `PersistenceCallbacks` preserves that established C struct's size. @@ -1830,6 +1903,10 @@ impl FFIPersister { persist_identity_balance_block_time_callback: extensions .persist_identity_balance_block_time, load_identity_balance_block_time_callback: extensions.load_identity_balance_block_time, + wallet_changeset_outpoint_locks_callback: extensions.wallet_changeset_outpoint_locks, + load_wallet_locked_outpoints_callback: extensions.load_wallet_locked_outpoints, + load_wallet_locked_outpoints_free_callback: extensions + .load_wallet_locked_outpoints_free, declared_capabilities, round_lock: Mutex::new(RoundGuardState::default()), } @@ -1850,6 +1927,56 @@ impl FFIPersister { } } + /// Hand every outpoint lock the host stored for `wallet_id` back to the + /// wallet through `lock_outpoint`, which also moves a held coin into the + /// locked balance. A host without the load slot restores none. + fn restore_locked_outpoints( + &self, + wallet_id: &[u8; 32], + wallet_info: &mut key_wallet::wallet::ManagedWalletInfo, + ) -> Result<(), PersistenceError> { + let Some(load) = self.load_wallet_locked_outpoints_callback else { + return Ok(()); + }; + // Fail closed on a half-wired pair, like the tracked-masternode and + // shielded loads: without the free callback every load would leak + // the host's array. + let Some(free) = self.load_wallet_locked_outpoints_free_callback else { + return Err(PersistenceError::backend( + "on_load_wallet_locked_outpoints_fn requires \ + on_load_wallet_locked_outpoints_free_fn; wire both or neither", + )); + }; + let mut outpoints_ptr: *const OutPointFFI = std::ptr::null(); + let mut count: usize = 0; + let rc = unsafe { + load( + self.callbacks.context, + wallet_id.as_ptr(), + &mut outpoints_ptr, + &mut count, + ) + }; + if rc != 0 { + return Err(persist_callback_error( + rc, + format!("on_load_wallet_locked_outpoints_fn returned error code {rc}"), + )); + } + let mut outpoints = Vec::with_capacity(count); + if !outpoints_ptr.is_null() && count > 0 { + // SAFETY: the host guarantees `count` contiguous entries that stay + // valid until the free callback below. + let rows = unsafe { slice::from_raw_parts(outpoints_ptr, count) }; + outpoints.extend(rows.iter().map(dashcore::OutPoint::from)); + } + unsafe { free(self.callbacks.context, outpoints_ptr, count) }; + for outpoint in outpoints { + wallet_info.lock_outpoint(outpoint); + } + Ok(()) + } + /// Compute the callback contracts that are structurally complete in this /// vtable. This mask is only an upper bound: the host must separately attest /// the semantics it actually implements. @@ -1924,6 +2051,12 @@ impl FFIPersister { { capabilities = capabilities.union(PersistenceCapabilities::TRACKED_MASTERNODES); } + if self.wallet_changeset_outpoint_locks_callback.is_some() + && self.load_wallet_locked_outpoints_callback.is_some() + && self.load_wallet_locked_outpoints_free_callback.is_some() + { + capabilities = capabilities.union(PersistenceCapabilities::OUTPOINT_LOCKS); + } if self.callbacks.on_persist_wallet_changeset_fn.is_some() && wallet_restore && capabilities.contains(PersistenceCapabilities::ASSET_LOCK_FUNDING_INDICES) @@ -2661,6 +2794,34 @@ impl PlatformWalletPersistence for FFIPersister { } } } + + // Outpoint locks ride their own size-negotiated extension slot: + // a lock needs no coin behind it, so it has no place among the + // per-account UTXO rows of the frozen changeset struct. Fired + // last in the core block, only when the round changes a lock. A + // host without the slot keeps locks for the session only and + // cannot attest `OUTPOINT_LOCKS`. + if !core_cs.outpoint_locks.is_empty() { + if let Some(cb) = self.wallet_changeset_outpoint_locks_callback { + let locks = build_outpoint_locks_for_callback(core_cs); + let result = unsafe { + cb( + self.callbacks.context, + wallet_id.as_ptr(), + locks.as_ptr(), + locks.len(), + ) + }; + if result != 0 { + eprintln!( + "Wallet changeset outpoint-lock persistence callback returned error \ + code {}", + result + ); + outcome.record(result); + } + } + } } // The DashPay backfill record rides its own size-negotiated slot, @@ -3907,6 +4068,7 @@ impl PlatformWalletPersistence for FFIPersister { } } } + self.restore_locked_outpoints(&entry.wallet_id, &mut wallet_state.wallet_info)?; if let Some(cb) = self.load_identity_balance_block_time_callback { for identities in wallet_state.identity_manager.wallet_identities.values_mut() { for managed in identities.values_mut() { @@ -12193,6 +12355,8 @@ mod tests { assert_eq!( PLATFORM_WALLET_PERSISTENCE_CAPABILITY_PRIVATE_CONTACT_REQUEST_SCAN_STATE, PersistenceCapabilities::PRIVATE_CONTACT_REQUEST_SCAN_STATE.bits() + PLATFORM_WALLET_PERSISTENCE_CAPABILITY_OUTPOINT_LOCKS, + PersistenceCapabilities::OUTPOINT_LOCKS.bits() ); assert_eq!( PLATFORM_WALLET_PERSISTENCE_CAPABILITY_ACCOUNT_ADDRESS_POOLS, @@ -14980,3 +15144,197 @@ mod tests { assert_eq!(restored, ["alice", "bob", "carol"]); } } + +#[cfg(test)] +mod outpoint_lock_tests { + //! The outpoint-lock trio: a round's lock changes reach the host through + //! their own extension slot, the host's stored locks come back on load, + //! and `OUTPOINT_LOCKS` is attested only with the whole trio declared. + + use super::*; + use dashcore::hashes::Hash as _; + use key_wallet::wallet::initialization::WalletAccountCreationOptions; + use platform_wallet::changeset::CoreChangeSet; + + #[derive(Default)] + struct Sink { + locks: std::sync::Mutex>, + stored: Vec, + freed: std::sync::Mutex, + } + + unsafe extern "C" fn record_locks( + ctx: *mut c_void, + _wallet_id: *const u8, + locks: *const OutpointLockFFI, + locks_count: usize, + ) -> i32 { + let sink = &*(ctx as *const Sink); + let mut recorded = sink.locks.lock().unwrap(); + for lock in slice::from_raw_parts(locks, locks_count) { + recorded.push((dashcore::OutPoint::from(&lock.outpoint), lock.locked)); + } + 0 + } + + unsafe extern "C" fn load_locks( + ctx: *mut c_void, + _wallet_id: *const u8, + out_outpoints: *mut *const OutPointFFI, + out_count: *mut usize, + ) -> i32 { + let sink = &*(ctx as *const Sink); + *out_outpoints = sink.stored.as_ptr(); + *out_count = sink.stored.len(); + 0 + } + + unsafe extern "C" fn free_locks( + ctx: *mut c_void, + _outpoints: *const OutPointFFI, + _count: usize, + ) { + let sink = &*(ctx as *const Sink); + *sink.freed.lock().unwrap() += 1; + } + + fn outpoint(byte: u8, vout: u32) -> dashcore::OutPoint { + dashcore::OutPoint { + txid: dashcore::Txid::from_byte_array([byte; 32]), + vout, + } + } + + fn trio() -> PersistenceExtensionCallbacks { + PersistenceExtensionCallbacks { + wallet_changeset_outpoint_locks: Some(record_locks), + load_wallet_locked_outpoints: Some(load_locks), + load_wallet_locked_outpoints_free: Some(free_locks), + ..Default::default() + } + } + + #[test] + fn should_hand_a_rounds_lock_changes_to_the_host_in_outpoint_order() { + let sink = Sink::default(); + let callbacks = PersistenceCallbacks { + context: &sink as *const Sink as *mut c_void, + ..PersistenceCallbacks::default() + }; + let persister = FFIPersister::new_with_persistence_capabilities_and_extensions( + callbacks, + PersistenceCapabilities::NONE, + trio(), + ); + persister + .store( + [1u8; 32], + PlatformWalletChangeSet { + core: Some(CoreChangeSet { + synced_height: Some(10), + ..Default::default() + }), + ..Default::default() + }, + ) + .expect("a round without lock changes succeeds"); + assert!( + sink.locks.lock().unwrap().is_empty(), + "a round without lock changes never fires the slot" + ); + + persister + .store( + [1u8; 32], + PlatformWalletChangeSet { + core: Some(CoreChangeSet { + outpoint_locks: BTreeMap::from([ + (outpoint(0xCD, 0), false), + (outpoint(0xAB, 1), true), + ]), + ..Default::default() + }), + ..Default::default() + }, + ) + .expect("a lock round succeeds"); + assert_eq!( + sink.locks.lock().unwrap().clone(), + vec![(outpoint(0xAB, 1), true), (outpoint(0xCD, 0), false)] + ); + drop(persister); + } + + #[test] + fn should_restore_the_hosts_locks_into_the_wallet_on_load() { + let wallet = key_wallet::Wallet::from_seed_bytes( + [0x21; 64], + dashcore::Network::Testnet, + WalletAccountCreationOptions::Default, + ) + .expect("seed wallet"); + let mut info = key_wallet::wallet::ManagedWalletInfo::from_wallet(&wallet, 0); + let sink = Sink { + stored: vec![ + OutPointFFI::from(&outpoint(0x11, 0)), + OutPointFFI::from(&outpoint(0x22, 3)), + ], + ..Sink::default() + }; + let callbacks = PersistenceCallbacks { + context: &sink as *const Sink as *mut c_void, + ..PersistenceCallbacks::default() + }; + let persister = FFIPersister::new_with_persistence_capabilities_and_extensions( + callbacks, + PersistenceCapabilities::NONE, + trio(), + ); + + persister + .restore_locked_outpoints(&[1u8; 32], &mut info) + .expect("restore"); + assert!(info.is_outpoint_locked(&outpoint(0x11, 0))); + assert!(info.is_outpoint_locked(&outpoint(0x22, 3))); + assert_eq!( + *sink.freed.lock().unwrap(), + 1, + "the host's array is freed once" + ); + drop(persister); + } + + #[test] + fn should_attest_outpoint_locks_only_with_the_whole_trio_declared() { + let declared = PersistenceCapabilities::OUTPOINT_LOCKS; + let wired = FFIPersister::new_with_persistence_capabilities_and_extensions( + PersistenceCallbacks::default(), + declared, + trio(), + ); + assert!(wired + .persistence_capabilities() + .contains(PersistenceCapabilities::OUTPOINT_LOCKS)); + + let undeclared = FFIPersister::new_with_persistence_capabilities_and_extensions( + PersistenceCallbacks::default(), + PersistenceCapabilities::NONE, + trio(), + ); + assert!(!undeclared + .persistence_capabilities() + .contains(PersistenceCapabilities::OUTPOINT_LOCKS)); + + let without_free = FFIPersister::new_with_persistence_capabilities_and_extensions( + PersistenceCallbacks::default(), + declared, + PersistenceExtensionCallbacks { + load_wallet_locked_outpoints_free: None, + ..trio() + }, + ); + assert!(!without_free + .persistence_capabilities() + .contains(PersistenceCapabilities::OUTPOINT_LOCKS)); + } +} diff --git a/packages/rs-platform-wallet-storage/SCHEMA.md b/packages/rs-platform-wallet-storage/SCHEMA.md index 94485778a6c..10d51281946 100644 --- a/packages/rs-platform-wallet-storage/SCHEMA.md +++ b/packages/rs-platform-wallet-storage/SCHEMA.md @@ -851,3 +851,4 @@ table-rebuild migration, as V004 does. | V018 | `V018__identity_hard_delete.rs` | Retires identity tombstoning. Adds `cascade_children_on_identity_delete` (brooms `identity_keys` / `contacts` / `ignored_senders` / `pending_contact_crypto` by the deleted identity id, covering the rows no live FK reaches) plus its access-path indexes `idx_contacts_owner`, `idx_ignored_senders_owner`, and `idx_pending_contact_crypto_owner`; purges every already-tombstoned identity and its dependents; drops `identities.tombstoned`. | | V019 | `V019__asset_lock_operation_id.rs` | Adds the nullable `asset_locks.operation_id BLOB` column (CHECK: NULL or exactly 16 bytes) that correlates a wallet-drain operation with its funding outpoint; the lifecycle blob is untouched. Adds the unique partial index `asset_locks_wallet_operation_id` on `(wallet_id, operation_id) WHERE operation_id IS NOT NULL` and the `asset_locks_operation_id_immutable` BEFORE UPDATE trigger, which aborts any change to a non-NULL `operation_id`. Purely additive; existing rows read back NULL. | | V020 | `V020__asset_lock_shielded_recipient.rs` | Adds the nullable `asset_locks.shielded_recipient BLOB` column (CHECK: NULL or exactly 43 bytes, the raw Orchard address) recording the recipient a shielded asset-lock funding was built to pay, so a resume after restart pays that recipient and refuses another; the lifecycle blob is untouched. Adds the `asset_locks_shielded_recipient_immutable` BEFORE UPDATE trigger, which aborts any change to a non-NULL `shielded_recipient`. Purely additive; existing rows read back NULL and keep accepting the resuming caller's recipient. | +| V019 | `V019__core_locked_outpoints.rs` | Adds `core_locked_outpoints`, one row per `(wallet_id, outpoint)` the wallet keeps out of coin selection: the collateral of a registered masternode, or an outpoint locked by hand. A table of its own rather than a `core_utxos` column, because a lock can exist before its coin and outlives the coin's spend. Deleting the row unlocks the outpoint. Purely additive; an upgraded database starts with no locks. | diff --git a/packages/rs-platform-wallet-storage/migrations/V019__core_locked_outpoints.rs b/packages/rs-platform-wallet-storage/migrations/V019__core_locked_outpoints.rs new file mode 100644 index 00000000000..336dcaa6c7d --- /dev/null +++ b/packages/rs-platform-wallet-storage/migrations/V019__core_locked_outpoints.rs @@ -0,0 +1,28 @@ +//! Add the `core_locked_outpoints` table (outpoints a wallet keeps out of +//! coin selection). +//! +//! One row per `(wallet_id, outpoint)`, and the row is the lock: the +//! collateral of a registered masternode, locked when the wallet processes +//! its ProRegTx, or an outpoint locked by hand. Deleting the row unlocks it. +//! Spending a collateral would end its masternode registration, which is why +//! the wallet keeps it out of ordinary sends. +//! +//! A table of its own rather than a `core_utxos` column: a lock can exist +//! before its coin does (the ProRegTx can be processed before the collateral +//! it names arrives, and an outpoint can be locked by hand at any time), and +//! it outlives the coin being spent, so it cannot live on the coin's row. +//! `outpoint` carries the same encoding as `core_utxos.outpoint`. +//! +//! Purely additive: an upgraded database starts with no locks. + +pub fn migration() -> String { + "\ +CREATE TABLE core_locked_outpoints ( + wallet_id BLOB NOT NULL, + outpoint BLOB NOT NULL, + PRIMARY KEY (wallet_id, outpoint), + FOREIGN KEY (wallet_id) REFERENCES wallets(wallet_id) ON DELETE CASCADE +); +" + .to_string() +} diff --git a/packages/rs-platform-wallet-storage/src/sqlite/persister.rs b/packages/rs-platform-wallet-storage/src/sqlite/persister.rs index fb4080cc63c..47130de7e7f 100644 --- a/packages/rs-platform-wallet-storage/src/sqlite/persister.rs +++ b/packages/rs-platform-wallet-storage/src/sqlite/persister.rs @@ -1306,8 +1306,9 @@ impl PlatformWalletPersistence for SqlitePersister { fn persistence_capabilities(&self) -> PersistenceCapabilities { // Every `flush_inner` applies the complete changeset in one SQLite // transaction. The current schema also has lossless token balances, - // invitations, account pools, tracked asset locks, and - // deferred-contact-crypto queue rows. + // invitations, account pools, tracked asset locks, + // deferred-contact-crypto queue rows, and locked outpoints (applied + // by `core_state::apply`, handed back by `load_state`). // Do NOT attest WALLET_RESTORE (and therefore not provider restore): // token balances and the DashPay overlay have no load readers, so a // full restore remains lossy. Shielded viewing keys are native when @@ -1324,7 +1325,8 @@ impl PlatformWalletPersistence for SqlitePersister { .union(PersistenceCapabilities::ASSET_LOCK_SHIELDED_RECIPIENTS) .union(PersistenceCapabilities::TRACKED_MASTERNODES) .union(PersistenceCapabilities::CORE_SWEEP_REMOVAL) - .union(PersistenceCapabilities::DASHPAY_PAYMENTS); + .union(PersistenceCapabilities::DASHPAY_PAYMENTS) + .union(PersistenceCapabilities::OUTPOINT_LOCKS); #[cfg(feature = "shielded")] { capabilities.union(PersistenceCapabilities::SHIELDED_VIEWING_KEYS) @@ -2394,6 +2396,7 @@ mod tests { "contacts", "core_address_pool", "core_instant_locks", + "core_locked_outpoints", "core_sync_state", "core_transactions", "core_utxos", diff --git a/packages/rs-platform-wallet-storage/src/sqlite/rehydrate.rs b/packages/rs-platform-wallet-storage/src/sqlite/rehydrate.rs index 46af1bc4a5e..ce41869048e 100644 --- a/packages/rs-platform-wallet-storage/src/sqlite/rehydrate.rs +++ b/packages/rs-platform-wallet-storage/src/sqlite/rehydrate.rs @@ -220,6 +220,11 @@ pub(crate) fn restore_provider_platform_node_pool( /// entry is replayed through `mark_instant_send_utxos` after the UTXO /// restore, so instant-locked funds come back instant-locked instead of /// waiting for the next sync to re-learn them. +/// - **Locked outpoints** (masternode collateral and outpoints locked by +/// hand): every `outpoint_locks` entry is handed to +/// `ManagedWalletInfo::lock_outpoint` (an unlock to `unlock_outpoint`), so +/// a locked coin comes back in the locked balance and out of coin +/// selection, including one whose coin arrives only after the load. /// - **Sync watermarks**: `synced_height` / `last_processed_height`. /// /// # Reconstructed when the persister supplies it @@ -300,6 +305,17 @@ pub fn apply_persisted_core_state( wallet_info.metadata.last_applied_chain_lock = Some(cl.clone()); } + // Locked outpoints first: a lock needs no coin behind it, and the + // `update_balance()` below sets every restored coin's flag from the lock + // set, whatever flag the coin was restored with. + for (outpoint, locked) in &core.outpoint_locks { + if *locked { + wallet_info.lock_outpoint(*outpoint); + } else { + wallet_info.unlock_outpoint(outpoint); + } + } + // INTENTIONAL(tx-record-rehydration-gap): `core` also carries transaction // records, but they cannot be replayed here — injecting one needs the raw // `dashcore::Transaction`, and this crate persists only the abstracted diff --git a/packages/rs-platform-wallet-storage/src/sqlite/schema/core_state.rs b/packages/rs-platform-wallet-storage/src/sqlite/schema/core_state.rs index cc103ad5570..f0644b227e8 100644 --- a/packages/rs-platform-wallet-storage/src/sqlite/schema/core_state.rs +++ b/packages/rs-platform-wallet-storage/src/sqlite/schema/core_state.rs @@ -193,6 +193,25 @@ pub fn apply( ])?; } } + if !cs.outpoint_locks.is_empty() { + // A lock is a row of its own, never a `core_utxos` column: it can + // name a coin that has not arrived yet and outlives the coin's spend. + let mut lock_stmt = tx.prepare_cached( + "INSERT INTO core_locked_outpoints (wallet_id, outpoint) VALUES (?1, ?2) \ + ON CONFLICT(wallet_id, outpoint) DO NOTHING", + )?; + let mut unlock_stmt = tx.prepare_cached( + "DELETE FROM core_locked_outpoints WHERE wallet_id = ?1 AND outpoint = ?2", + )?; + for (outpoint, locked) in &cs.outpoint_locks { + let key = blob::encode_outpoint(outpoint)?; + if *locked { + lock_stmt.execute(params![wallet_id.as_slice(), &key[..]])?; + } else { + unlock_stmt.execute(params![wallet_id.as_slice(), &key[..]])?; + } + } + } let chainlock_height = cs .last_applied_chain_lock .as_ref() @@ -896,6 +915,11 @@ fn upsert_sync_state( /// and checked against their typed txid and height columns. /// - **IS-locks** / **sync watermarks**: decoded bit-exact, fail-hard on a /// corrupt blob. +/// - **Locked outpoints** (`outpoint_locks`): every `core_locked_outpoints` +/// row, as a lock, whether or not the wallet holds the coin. Each restored +/// UTXO's `is_locked` follows it. Fail-hard on a malformed outpoint, like +/// the UTXO reader: a dropped lock would hand a masternode collateral back +/// to coin selection. /// /// # Deferred to the first post-load `sync` (safe re-warm) /// @@ -958,6 +982,24 @@ pub fn load_state( } } + // Locked outpoints, read before the coins so each restored coin carries + // its lock. The wallet re-derives every coin's flag from the lock set it + // is handed (`ManagedWalletInfo::lock_outpoint`), so these flags only + // keep this changeset consistent with itself. Same pre-read length gate + // as the `core_utxos.outpoint` read below. + { + let mut stmt = conn.prepare( + "SELECT length(outpoint), outpoint FROM core_locked_outpoints WHERE wallet_id = ?1", + )?; + let mut rows = stmt.query(params![wallet_id.as_slice()])?; + while let Some(row) = rows.next()? { + blob::check_size(row.get::<_, i64>(0)?)?; + let op_bytes: Vec = row.get(1)?; + cs.outpoint_locks + .insert(blob::decode_outpoint(&op_bytes)?, true); + } + } + // Unspent UTXOs → new_utxos (the balance source). // Pre-read `length()` gates on `outpoint` and `script` before materializing // the Vec so tampered oversize values are caught before heap allocation. @@ -1007,7 +1049,7 @@ pub fn load_state( is_coinbase: false, is_confirmed: height.is_some(), is_instantlocked: false, - is_locked: false, + is_locked: cs.outpoint_locks.get(&outpoint).copied().unwrap_or(false), is_trusted: false, }; cs.new_utxos.push(utxo); diff --git a/packages/rs-platform-wallet-storage/tests/sqlite_locked_outpoints.rs b/packages/rs-platform-wallet-storage/tests/sqlite_locked_outpoints.rs new file mode 100644 index 00000000000..2aa818deaec --- /dev/null +++ b/packages/rs-platform-wallet-storage/tests/sqlite_locked_outpoints.rs @@ -0,0 +1,365 @@ +#![allow(clippy::field_reassign_with_default)] + +//! Locked outpoints (masternode collateral, and outpoints locked by hand) +//! survive the SQLite store: `core_locked_outpoints` rows come back through +//! `load_state` and `apply_persisted_core_state`, whether or not the wallet +//! already holds the coin, and keep the collateral out of coin selection. + +mod common; + +use std::collections::BTreeMap; + +use common::{ensure_wallet_meta, fresh_persister, wid}; +use dashcore::hashes::Hash; +use dashcore::{Address, BlockHash, OutPoint, Transaction, TxIn, TxOut}; +use key_wallet::transaction_checking::{BlockInfo, TransactionContext, WalletTransactionChecker}; +use key_wallet::wallet::initialization::WalletAccountCreationOptions; +use key_wallet::wallet::managed_wallet_info::wallet_info_interface::WalletInfoInterface; +use key_wallet::wallet::managed_wallet_info::ManagedWalletInfo; +use key_wallet::wallet::Wallet; +use key_wallet::Utxo; +use platform_wallet::changeset::{ + AccountRegistrationEntry, CoreChangeSet, PlatformWalletChangeSet, PlatformWalletPersistence, +}; +use platform_wallet::wallet::platform_wallet::WalletId; +use platform_wallet_storage::sqlite::schema::core_state; +use platform_wallet_storage::LoadCtx; + +const DUFFS_PER_DASH: u64 = 100_000_000; +const COLLATERAL: u64 = 1_000 * DUFFS_PER_DASH; +const SPARE: u64 = 5 * DUFFS_PER_DASH; +const HEIGHT: u32 = 100; + +fn test_wallet() -> Wallet { + Wallet::from_seed_bytes( + [0x42; 64], + key_wallet::Network::Testnet, + WalletAccountCreationOptions::Default, + ) + .expect("wallet from seed") +} + +fn manifest_for(wallet: &Wallet) -> Vec { + wallet + .accounts + .all_accounts() + .into_iter() + .map(|a| AccountRegistrationEntry { + account_type: a.account_type, + account_xpub: a.account_xpub, + }) + .collect() +} + +/// Two receive addresses of the wallet: one for the collateral, one for the +/// spare coin. +fn two_addresses(wallet: &Wallet) -> (Address, Address) { + let info = ManagedWalletInfo::from_wallet(wallet, 1); + let mut addresses = WalletInfoInterface::monitored_addresses(&info).into_iter(); + let first = addresses.next().expect("a monitored address"); + let second = addresses.next().expect("a second monitored address"); + (first, second) +} + +/// A transaction paying `value` to `address` as output 0. `marker` keeps the +/// txids of otherwise identical transactions apart. +fn payment(address: &Address, value: u64, marker: u8) -> Transaction { + Transaction { + version: 2, + lock_time: 0, + input: vec![TxIn { + previous_output: OutPoint::new(dashcore::Txid::from_byte_array([marker; 32]), 0), + ..TxIn::default() + }], + output: vec![TxOut { + value, + script_pubkey: address.script_pubkey(), + }], + special_transaction_payload: None, + } +} + +fn coin(tx: &Transaction, address: &Address) -> Utxo { + Utxo { + outpoint: OutPoint::new(tx.txid(), 0), + txout: tx.output[0].clone(), + address: address.clone(), + height: HEIGHT, + is_coinbase: false, + is_confirmed: true, + is_instantlocked: false, + is_locked: false, + is_trusted: false, + } +} + +fn store_core( + persister: &platform_wallet_storage::SqlitePersister, + w: WalletId, + core: CoreChangeSet, +) { + persister + .store( + w, + PlatformWalletChangeSet { + core: Some(core), + ..Default::default() + }, + ) + .expect("store"); +} + +fn locks(entries: &[(OutPoint, bool)]) -> BTreeMap { + entries.iter().copied().collect() +} + +/// Reopen the database and rebuild the wallet the way `load()` does. +fn reload(path: &std::path::Path, w: &WalletId, wallet: &Wallet) -> ManagedWalletInfo { + let persister = platform_wallet_storage::SqlitePersister::open( + platform_wallet_storage::SqlitePersisterConfig::new(path), + ) + .expect("reopen persister"); + let conn = persister.lock_conn_for_test(); + let (core, utxo_accounts) = + core_state::load_state(&conn, w, key_wallet::Network::Testnet, &LoadCtx::strict()) + .expect("load_state"); + drop(conn); + let mut info = ManagedWalletInfo::from_wallet(wallet, 1); + platform_wallet_storage::sqlite::rehydrate::apply_persisted_core_state( + &mut info, + &manifest_for(wallet), + &core, + &utxo_accounts, + &Default::default(), + &LoadCtx::strict(), + ) + .expect("apply persisted core state"); + info +} + +fn spendable_outpoints(info: &ManagedWalletInfo) -> Vec { + WalletInfoInterface::get_spendable_utxos(info) + .into_iter() + .map(|utxo| utxo.outpoint) + .collect() +} + +#[test] +fn should_restore_a_locked_collateral_in_the_locked_balance_after_reopen() { + let (persister, _tmp, path) = fresh_persister(); + let w = wid(0xC1); + ensure_wallet_meta(&persister, &w); + let wallet = test_wallet(); + let (collateral_address, spare_address) = two_addresses(&wallet); + let collateral_tx = payment(&collateral_address, COLLATERAL, 1); + let spare_tx = payment(&spare_address, SPARE, 2); + let collateral = OutPoint::new(collateral_tx.txid(), 0); + + store_core( + &persister, + w, + CoreChangeSet { + new_utxos: vec![ + coin(&collateral_tx, &collateral_address), + coin(&spare_tx, &spare_address), + ], + outpoint_locks: locks(&[(collateral, true)]), + synced_height: Some(HEIGHT), + last_processed_height: Some(HEIGHT), + ..Default::default() + }, + ); + drop(persister); + + let info = reload(&path, &w, &wallet); + assert!(info.is_outpoint_locked(&collateral)); + let balance = WalletInfoInterface::balance(&info); + assert_eq!(balance.locked(), COLLATERAL); + assert_eq!(balance.spendable(), SPARE); + assert_eq!( + spendable_outpoints(&info), + vec![OutPoint::new(spare_tx.txid(), 0)], + "coin selection must see only the spare coin" + ); +} + +#[test] +fn should_restore_a_lock_stored_before_its_coin() { + let (persister, _tmp, path) = fresh_persister(); + let w = wid(0xC2); + ensure_wallet_meta(&persister, &w); + let wallet = test_wallet(); + let (collateral_address, _) = two_addresses(&wallet); + let collateral_tx = payment(&collateral_address, COLLATERAL, 3); + let collateral = OutPoint::new(collateral_tx.txid(), 0); + + // The ProRegTx was processed first: the lock lands with no coin behind it. + store_core( + &persister, + w, + CoreChangeSet { + outpoint_locks: locks(&[(collateral, true)]), + ..Default::default() + }, + ); + // The collateral arrives in a later round. + store_core( + &persister, + w, + CoreChangeSet { + new_utxos: vec![coin(&collateral_tx, &collateral_address)], + synced_height: Some(HEIGHT), + last_processed_height: Some(HEIGHT), + ..Default::default() + }, + ); + drop(persister); + + let info = reload(&path, &w, &wallet); + let balance = WalletInfoInterface::balance(&info); + assert_eq!(balance.locked(), COLLATERAL); + assert_eq!(balance.spendable(), 0); + assert!(spendable_outpoints(&info).is_empty()); +} + +#[tokio::test] +async fn should_lock_a_coin_that_arrives_after_the_reload() { + let (persister, _tmp, path) = fresh_persister(); + let w = wid(0xC3); + ensure_wallet_meta(&persister, &w); + let mut wallet = test_wallet(); + let (collateral_address, _) = two_addresses(&wallet); + let collateral_tx = payment(&collateral_address, COLLATERAL, 4); + let collateral = OutPoint::new(collateral_tx.txid(), 0); + + store_core( + &persister, + w, + CoreChangeSet { + outpoint_locks: locks(&[(collateral, true)]), + ..Default::default() + }, + ); + drop(persister); + + let mut info = reload(&path, &w, &wallet); + assert!(info.is_outpoint_locked(&collateral)); + assert_eq!(WalletInfoInterface::balance(&info).locked(), 0); + + let block = BlockInfo::new(HEIGHT, BlockHash::all_zeros(), 1_700_000_000); + let result = info + .check_core_transaction( + &collateral_tx, + TransactionContext::InBlock(block), + &mut wallet, + true, + true, + ) + .await; + assert!(result.is_relevant, "the collateral pays this wallet"); + + let balance = WalletInfoInterface::balance(&info); + assert_eq!(balance.locked(), COLLATERAL, "the coin arrives locked"); + assert_eq!(balance.spendable(), 0); + assert!(spendable_outpoints(&info).is_empty()); +} + +#[test] +fn should_not_restore_an_unlocked_outpoint() { + let (persister, _tmp, path) = fresh_persister(); + let w = wid(0xC4); + ensure_wallet_meta(&persister, &w); + let wallet = test_wallet(); + let (collateral_address, _) = two_addresses(&wallet); + let collateral_tx = payment(&collateral_address, COLLATERAL, 5); + let collateral = OutPoint::new(collateral_tx.txid(), 0); + + store_core( + &persister, + w, + CoreChangeSet { + new_utxos: vec![coin(&collateral_tx, &collateral_address)], + outpoint_locks: locks(&[(collateral, true)]), + synced_height: Some(HEIGHT), + last_processed_height: Some(HEIGHT), + ..Default::default() + }, + ); + store_core( + &persister, + w, + CoreChangeSet { + outpoint_locks: locks(&[(collateral, false)]), + ..Default::default() + }, + ); + drop(persister); + + let info = reload(&path, &w, &wallet); + assert!(!info.is_outpoint_locked(&collateral)); + let balance = WalletInfoInterface::balance(&info); + assert_eq!(balance.locked(), 0); + assert_eq!(balance.spendable(), COLLATERAL); + assert_eq!(spendable_outpoints(&info), vec![collateral]); +} + +#[test] +fn should_keep_the_unlock_when_one_round_locks_then_unlocks() { + let mut first = CoreChangeSet { + outpoint_locks: locks(&[(OutPoint::new(dashcore::Txid::all_zeros(), 7), true)]), + ..Default::default() + }; + let second = CoreChangeSet { + outpoint_locks: locks(&[(OutPoint::new(dashcore::Txid::all_zeros(), 7), false)]), + ..Default::default() + }; + platform_wallet::changeset::Merge::merge(&mut first, second); + assert_eq!( + first.outpoint_locks, + locks(&[(OutPoint::new(dashcore::Txid::all_zeros(), 7), false)]) + ); +} + +#[test] +fn should_drop_a_wallets_locks_with_the_wallet() { + let (persister, _tmp, _path) = fresh_persister(); + let w = wid(0xC5); + let other = wid(0xC6); + ensure_wallet_meta(&persister, &w); + ensure_wallet_meta(&persister, &other); + let outpoint = OutPoint::new(dashcore::Txid::from_byte_array([0x77; 32]), 1); + for wallet_id in [w, other] { + store_core( + &persister, + wallet_id, + CoreChangeSet { + outpoint_locks: locks(&[(outpoint, true)]), + ..Default::default() + }, + ); + } + + persister + .delete_wallet_skip_backup(w) + .expect("delete wallet"); + + let conn = persister.lock_conn_for_test(); + let count = |wallet_id: &WalletId| -> i64 { + conn.query_row( + "SELECT COUNT(*) FROM core_locked_outpoints WHERE wallet_id = ?1", + [wallet_id.as_slice()], + |row| row.get(0), + ) + .expect("count locks") + }; + assert_eq!(count(&w), 0, "the deleted wallet's locks go with it"); + assert_eq!(count(&other), 1, "another wallet's lock stays"); +} + +#[test] +fn should_attest_that_locks_survive_a_restart() { + let (persister, _tmp, _path) = fresh_persister(); + assert!(persister + .persistence_capabilities() + .contains(platform_wallet::changeset::PersistenceCapabilities::OUTPOINT_LOCKS)); +} diff --git a/packages/rs-platform-wallet/src/changeset/changeset.rs b/packages/rs-platform-wallet/src/changeset/changeset.rs index 23d416973a3..bc83cb80702 100644 --- a/packages/rs-platform-wallet/src/changeset/changeset.rs +++ b/packages/rs-platform-wallet/src/changeset/changeset.rs @@ -71,6 +71,8 @@ use crate::wallet::identity::{ /// [`fold_same_txid_records`]), uses monotonic-max for the height /// watermarks, `extend` for the utxo vecs and for `sweeps` (in emission /// order — see the field), and last-write-wins for the IS-lock map. +/// [`Self::outpoint_locks`] carries unlocks as well as locks, and merges +/// last-write-wins per outpoint. /// /// # Why a projection instead of the upstream type /// @@ -320,6 +322,25 @@ pub struct CoreChangeSet { /// [`Self::sweeps`]. #[cfg_attr(feature = "serde", serde(default))] pub utxo_credit_verdicts: BTreeMap, + + /// Changes to the outpoints the wallet keeps out of coin selection: + /// `true` locks the outpoint, `false` unlocks it. + /// + /// The wallet locks the collateral of every masternode registration + /// (ProRegTx) it processes, since spending the collateral would end the + /// registration, and the user can lock or unlock any outpoint by hand. + /// The in-memory set is `ManagedWalletInfo::locked_outpoints`; this is + /// its persistence delta. A lock does not need a coin behind it (the + /// ProRegTx can arrive before its collateral) and outlives the coin's + /// spend, so a persister keeps locks apart from its UTXO rows. On load + /// it hands every stored lock back through + /// `ManagedWalletInfo::lock_outpoint`. + /// + /// Merge: newest wins per outpoint, so an unlock after a lock in one + /// fold persists the unlock. `serde(default)` for the same + /// backward-compatible reading as [`Self::sweeps`]. + #[cfg_attr(feature = "serde", serde(default))] + pub outpoint_locks: BTreeMap, } /// Why the engine did not credit a `Received` / `Change` output of a @@ -867,6 +888,9 @@ impl Merge for CoreChangeSet { // entries of records the newer changeset re-projected were dropped // at the top of this merge. self.utxo_credit_verdicts.extend(other.utxo_credit_verdicts); + + // Outpoint locks: newest wins per outpoint. + self.outpoint_locks.extend(other.outpoint_locks); } fn is_empty(&self) -> bool { @@ -883,6 +907,7 @@ impl Merge for CoreChangeSet { && self.account_highest_used.is_empty() && self.last_applied_chain_lock.is_none() && self.utxo_credit_verdicts.is_empty() + && self.outpoint_locks.is_empty() } } diff --git a/packages/rs-platform-wallet/src/changeset/core_bridge.rs b/packages/rs-platform-wallet/src/changeset/core_bridge.rs index 417dbf56b2d..58b4bbde007 100644 --- a/packages/rs-platform-wallet/src/changeset/core_bridge.rs +++ b/packages/rs-platform-wallet/src/changeset/core_bridge.rs @@ -1632,10 +1632,34 @@ async fn instant_lock_changeset( } /// Project an upstream [`WalletEvent`] into a [`CoreChangeSet`] suitable -/// for atomic persistence. +/// for atomic persistence, carrying every outpoint lock the wallet's +/// transaction checks queued since the last one. +/// +/// No `WalletEvent` carries a lock: a ProRegTx locks its collateral even +/// when the transaction is otherwise irrelevant and emits nothing. The locks +/// ride whichever event of the wallet comes next, which for a block is at +/// the latest the `SyncHeightAdvanced` watermark that certifies it. async fn build_core_changeset( wallet_manager: &Arc>>, event: &WalletEvent, +) -> CoreChangeSet { + let mut cs = project_core_event(wallet_manager, event).await; + let queued = { + let guard = wallet_manager.read().await; + guard + .get_wallet_info(&event.wallet_id()) + .map(PlatformWalletInfo::take_queued_outpoint_locks) + .unwrap_or_default() + }; + cs.outpoint_locks + .extend(queued.into_iter().map(|outpoint| (outpoint, true))); + cs +} + +/// The [`CoreChangeSet`] one [`WalletEvent`] describes. +async fn project_core_event( + wallet_manager: &Arc>>, + event: &WalletEvent, ) -> CoreChangeSet { use key_wallet::wallet::managed_wallet_info::wallet_info_interface::WalletInfoInterface; @@ -2732,6 +2756,7 @@ impl CoreChangeSet { && self.addresses_marked_used.is_empty() && self.account_highest_used.is_empty() && self.utxo_credit_verdicts.is_empty() + && self.outpoint_locks.is_empty() } } @@ -4473,6 +4498,7 @@ mod contact_watch_only_projection_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), observed_input_conflicts: Default::default(), finalized_spends: Default::default(), } @@ -9064,6 +9090,7 @@ mod utxo_credit_verdict_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), observed_input_conflicts: Default::default(), finalized_spends: Default::default(), }; @@ -9162,6 +9189,7 @@ mod utxo_credit_verdict_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), observed_input_conflicts: Default::default(), finalized_spends: Default::default(), }; @@ -9189,3 +9217,71 @@ mod utxo_credit_verdict_tests { ); } } + +#[cfg(test)] +mod outpoint_lock_projection_tests { + //! A ProRegTx locks its collateral without emitting any `WalletEvent`, + //! so the lock rides the wallet's next projected changeset. + + use super::*; + use crate::test_support::{masternode_registration, wallet_manager_with_registered_collateral}; + use dashcore::hashes::Hash; + use key_wallet::account::account_type::StandardAccountType; + use key_wallet::transaction_checking::BlockInfo; + + const SPARE: u64 = 500_000_000; + + fn sync_height(wallet_id: WalletId, height: u32) -> WalletEvent { + WalletEvent::SyncHeightAdvanced { wallet_id, height } + } + + #[tokio::test] + async fn should_carry_a_registration_lock_on_the_wallets_next_changeset_once() { + let (manager, wallet_id, _generation, _signer, collateral, _spare) = + wallet_manager_with_registered_collateral(StandardAccountType::BIP44Account, SPARE) + .await; + + let cs = build_core_changeset(&manager, &sync_height(wallet_id, 2)).await; + assert_eq!(cs.outpoint_locks, BTreeMap::from([(collateral, true)])); + let lock_only = CoreChangeSet { + outpoint_locks: cs.outpoint_locks.clone(), + ..CoreChangeSet::default() + }; + assert!( + !lock_only.is_empty_no_records(), + "a changeset carrying only a lock must still reach the persister" + ); + + let next = build_core_changeset(&manager, &sync_height(wallet_id, 3)).await; + assert!(next.outpoint_locks.is_empty(), "a lock is carried once"); + } + + #[tokio::test] + async fn should_not_queue_a_registration_seen_again() { + let (manager, wallet_id, _generation, _signer, collateral, _spare) = + wallet_manager_with_registered_collateral(StandardAccountType::BIP44Account, SPARE) + .await; + let _ = build_core_changeset(&manager, &sync_height(wallet_id, 2)).await; + + // The block that confirms it again, or a rescan. + manager + .write() + .await + .check_transaction_in_all_wallets( + &masternode_registration(collateral), + TransactionContext::InChainLockedBlock(BlockInfo::new( + 3, + dashcore::BlockHash::all_zeros(), + 1_700_000_200, + )), + true, + true, + ) + .await; + let cs = build_core_changeset(&manager, &sync_height(wallet_id, 3)).await; + assert!( + cs.outpoint_locks.is_empty(), + "the wallet already holds that lock" + ); + } +} diff --git a/packages/rs-platform-wallet/src/changeset/persistence_capabilities.rs b/packages/rs-platform-wallet/src/changeset/persistence_capabilities.rs index 55c549c015b..3301ee386f6 100644 --- a/packages/rs-platform-wallet/src/changeset/persistence_capabilities.rs +++ b/packages/rs-platform-wallet/src/changeset/persistence_capabilities.rs @@ -105,6 +105,16 @@ impl PersistenceCapabilities { /// declaration only when `on_persist_dashpay_payments_fn` is actually /// wired. pub const DASHPAY_PAYMENTS: Self = Self(1 << 12); + /// Locked outpoints (masternode collateral, and outpoints locked by hand) + /// are persisted AND restored: a stored `CoreChangeSet`'s + /// `outpoint_locks` are durably applied, a lock kept whether or not its + /// coin has a row yet, and a restart hands every stored lock back to the + /// wallet. Without this bit a lock lasts for the session, and a + /// collateral is locked again only when the wallet sees its registration + /// again. On the FFI surface locks travel through the persistence + /// extension's size-negotiated persist slot and come back through its + /// load and free slots; all three must be wired. + pub const OUTPOINT_LOCKS: Self = Self(1 << 13); /// Asset-lock operation UUIDs survive store/load, including consumed tombstones. /// Missing or malformed persistence data fails load rather than becoming an @@ -278,6 +288,7 @@ impl PersistenceCapabilities { PersistenceCapabilities::PRIVATE_CONTACT_REQUEST_SCAN_STATE, "private_contact_request_scan_state", ), + (PersistenceCapabilities::OUTPOINT_LOCKS, "outpoint_locks"), ]; KNOWN @@ -323,6 +334,7 @@ mod tests { assert_eq!(PersistenceCapabilities::TRACKED_MASTERNODES.bits(), 0x400); assert_eq!(PersistenceCapabilities::CORE_SWEEP_REMOVAL.bits(), 0x800); assert_eq!(PersistenceCapabilities::DASHPAY_PAYMENTS.bits(), 0x1000); + assert_eq!(PersistenceCapabilities::OUTPOINT_LOCKS.bits(), 0x2000); assert_eq!( PersistenceCapabilities::ASSET_LOCK_OPERATION_IDS.bits(), 0x2000 diff --git a/packages/rs-platform-wallet/src/manager/accessors.rs b/packages/rs-platform-wallet/src/manager/accessors.rs index b1389f98fe2..786aff3146c 100644 --- a/packages/rs-platform-wallet/src/manager/accessors.rs +++ b/packages/rs-platform-wallet/src/manager/accessors.rs @@ -2033,6 +2033,7 @@ pub(crate) mod txo_inventory_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), observed_input_conflicts: Default::default(), finalized_spends: Default::default(), }; diff --git a/packages/rs-platform-wallet/src/manager/load.rs b/packages/rs-platform-wallet/src/manager/load.rs index db5da2bd8ec..10a99fe7f43 100644 --- a/packages/rs-platform-wallet/src/manager/load.rs +++ b/packages/rs-platform-wallet/src/manager/load.rs @@ -11,6 +11,7 @@ use crate::changeset::{ use crate::error::PlatformWalletError; use crate::wallet::core::WalletGeneration; use crate::wallet::identity::IdentityManager; +use crate::wallet::outpoint_locks::lock_known_masternode_collaterals; use crate::wallet::platform_wallet::{PlatformWalletInfo, WalletId}; use crate::wallet::PlatformWallet; @@ -190,6 +191,11 @@ impl PlatformWalletManager

{ // `update_state` and `update_balance` are both on: the balance // this produces is what `generation.set(..)` mirrors a few lines // below, and the UI reads that. + // A replayed ProRegTx locks its collateral here, and nothing + // persists that lock unless it is queued with the rest: once the + // registration confirms it leaves this list and is never replayed + // again. + let mut replay_locks = Vec::new(); if !unconfirmed_outgoing_txs.is_empty() { let mut replayed = 0usize; for tx in &unconfirmed_outgoing_txs { @@ -202,6 +208,7 @@ impl PlatformWalletManager

{ true, ) .await; + replay_locks.extend(result.locked_outpoints); if result.is_relevant { replayed += 1; } @@ -291,7 +298,9 @@ impl PlatformWalletManager

{ dpns_name_states: std::collections::BTreeMap::new(), dashpay_backfill, rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; + platform_info.queue_outpoint_locks(replay_locks); // A restored outbound-account marker says the contact's external // account was built from its current xpub, which suppresses the // startup rebuild. It must not vouch for a pool the host kept @@ -721,6 +730,17 @@ impl PlatformWalletManager

{ return Err(err); } + // Keep the collateral of every masternode the wallets already know out + // of coin selection: registrations restored into their histories + // without a transaction check, and tracked masternodes whose + // registration has been fetched. New locks are queued for persistence + // like the ones a check makes. See `wallet::outpoint_locks`. + lock_known_masternode_collaterals( + &self.wallet_manager, + &self.tracked_masternodes_service().known_collaterals(), + ) + .await; + // Past the rollback point. A store configured before this load // restores the held wallets' private payments now, with no keys and // without waiting on the store, which a scan may hold; otherwise @@ -2200,3 +2220,164 @@ mod private_payment_hold_tests { assert!(pair_held(&manager, bound).await, "the pair is held"); } } + +#[cfg(test)] +mod masternode_collateral_load_tests { + //! A load locks the collateral of the masternodes the manager already + //! knows, including one whose registration the wallet never processed. + + use std::collections::BTreeMap; + use std::sync::Arc; + + use dashcore::hashes::Hash; + use dashcore::{BlockHash, OutPoint, Transaction}; + use key_wallet::test_utils::TestWalletContext; + use key_wallet::transaction_checking::{BlockInfo, TransactionContext}; + use key_wallet::wallet::managed_wallet_info::transaction_building::AccountTypePreference; + use key_wallet::wallet::ManagedWalletInfo; + use key_wallet::Wallet; + + use crate::changeset::{ + ClientStartState, ClientWalletStartState, IdentityManagerStartState, PersistenceError, + PlatformWalletChangeSet, PlatformWalletPersistence, + }; + use crate::masternode::{RegistrationDetails, TrackedMasternode, TrackedMasternodeSnapshot}; + use crate::test_support::{NoopTestEventHandler, MASTERNODE_COLLATERAL_DUFFS}; + use crate::wallet::platform_wallet::WalletId; + use crate::PlatformWalletManager; + + const SPARE: u64 = 500_000_000; + + /// Hands back one wallet and one tracked masternode. + struct TrackedCollateralPersister { + wallet: Wallet, + managed: ManagedWalletInfo, + tracked: TrackedMasternode, + } + + impl PlatformWalletPersistence for TrackedCollateralPersister { + fn store( + &self, + _wallet_id: WalletId, + _changeset: PlatformWalletChangeSet, + ) -> Result<(), PersistenceError> { + Ok(()) + } + + fn flush(&self, _wallet_id: WalletId) -> Result<(), PersistenceError> { + Ok(()) + } + + fn load(&self) -> Result { + let mut wallets = BTreeMap::new(); + wallets.insert( + self.wallet.compute_wallet_id(), + ClientWalletStartState { + wallet: self.wallet.clone(), + wallet_info: self.managed.clone(), + identity_manager: IdentityManagerStartState::default(), + unused_asset_locks: BTreeMap::new(), + unconfirmed_outgoing_txs: Vec::new(), + }, + ); + Ok(ClientStartState { + wallets, + ..Default::default() + }) + } + + fn load_tracked_masternodes( + &self, + _network: dashcore::Network, + ) -> Result, PersistenceError> { + Ok(vec![self.tracked.clone()]) + } + } + + /// The user tracks a masternode whose collateral sits in this wallet but + /// whose registration the wallet never processed (funded and signed + /// elsewhere). After a load the collateral is locked: it is out of the + /// spendable balance and out of every send's coin selection, and the + /// lock is queued for persistence. + #[tokio::test] + async fn should_lock_a_tracked_masternodes_collateral_on_load() { + let mut ctx = TestWalletContext::new_random(); + let funding = Transaction::dummy( + &ctx.receive_address, + 0..1, + &[MASTERNODE_COLLATERAL_DUFFS, SPARE], + ); + ctx.check_transaction( + &funding, + TransactionContext::InChainLockedBlock(BlockInfo::new( + 1, + BlockHash::all_zeros(), + 1_700_000_000, + )), + ) + .await; + let collateral = OutPoint::new(funding.txid(), 0); + let wallet_id = ctx.wallet.compute_wallet_id(); + let tracked = TrackedMasternode { + pro_tx_hash: [0x42; 32], + label: None, + added_at: 0, + snapshot: TrackedMasternodeSnapshot { + registration: Some(RegistrationDetails { + height: 2, + collateral: (collateral.txid.to_byte_array(), collateral.vout), + owner_key_hash: [0x01; 20], + voting_key_hash: [0x02; 20], + operator_public_key: [0x03; 48], + payout_script: Vec::new(), + service_address: None, + is_evonode: false, + platform_node_id: None, + platform_http_port: None, + }), + ..Default::default() + }, + }; + + let sdk = Arc::new(dash_sdk::SdkBuilder::new_mock().build().expect("mock sdk")); + let manager = Arc::new(PlatformWalletManager::new( + sdk, + Arc::new(TrackedCollateralPersister { + wallet: ctx.wallet, + managed: ctx.managed_wallet, + tracked, + }), + Arc::new(NoopTestEventHandler) as _, + )); + manager + .load_from_persistor() + .await + .expect("the wallet must load"); + + let wallet = manager + .get_wallet(&wallet_id) + .await + .expect("the loaded wallet must be registered"); + assert_eq!( + wallet.locked_outpoints().await.expect("locks"), + vec![collateral] + ); + assert_eq!(wallet.balance().locked(), MASTERNODE_COLLATERAL_DUFFS); + assert_eq!( + wallet + .core() + .pooled_spendable_balance(&[AccountTypePreference::BIP44][..], 0) + .await + .expect("pooled balance"), + SPARE, + "coin selection sees only the spare coin" + ); + let wm = wallet.wallet_manager().read().await; + let info = wm.get_wallet_info(&wallet_id).expect("wallet"); + assert_eq!( + info.take_queued_outpoint_locks(), + std::collections::BTreeSet::from([collateral]), + "the lock is queued for persistence" + ); + } +} diff --git a/packages/rs-platform-wallet/src/manager/wallet_lifecycle.rs b/packages/rs-platform-wallet/src/manager/wallet_lifecycle.rs index 466c6f5af35..b66262cd5d8 100644 --- a/packages/rs-platform-wallet/src/manager/wallet_lifecycle.rs +++ b/packages/rs-platform-wallet/src/manager/wallet_lifecycle.rs @@ -366,7 +366,13 @@ impl PlatformWalletManager

{ dpns_name_states: std::collections::BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; + // A tracked masternode's collateral may reach this wallet as it syncs; + // lock it now so it arrives locked. + platform_info.lock_known_masternode_collaterals( + &self.tracked_masternodes_service().known_collaterals(), + ); wallet.downgrade_to_external_signable(); diff --git a/packages/rs-platform-wallet/src/masternode/tracked.rs b/packages/rs-platform-wallet/src/masternode/tracked.rs index c79ebb8c6bf..c01758178aa 100644 --- a/packages/rs-platform-wallet/src/masternode/tracked.rs +++ b/packages/rs-platform-wallet/src/masternode/tracked.rs @@ -26,17 +26,18 @@ //! session-scoped; hosts read //! [`PersistenceCapabilities::TRACKED_MASTERNODES`] to know which they got. -use std::collections::BTreeMap; +use std::collections::{BTreeMap, BTreeSet}; use std::time::{SystemTime, UNIX_EPOCH}; use dash_sdk::platform::Fetch; use dashcore::transaction::special_transaction::provider_registration::ProviderMasternodeType; use dashcore::transaction::TransactionPayload; -use dashcore::{Address as DashAddress, Network}; +use dashcore::{Address as DashAddress, Network, OutPoint}; use dpp::identity::accessors::IdentityGettersV0; use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; use dpp::identity::{Identity, Purpose}; use dpp::prelude::Identifier; +use key_wallet_manager::WalletManager; use serde_json::{json, Value}; use super::list::MasternodeListSummary; @@ -53,6 +54,8 @@ use crate::manager::PlatformWalletManager; use crate::wallet::masternode_withdrawal::{ execute_masternode_withdrawal, MasternodeWithdrawalKey, RawSecretCoreSigner, }; +use crate::wallet::outpoint_locks::{lock_known_masternode_collaterals, named_collateral}; +use crate::wallet::platform_wallet::PlatformWalletInfo; // --------------------------------------------------------------------------- // Model @@ -500,6 +503,9 @@ pub struct TrackedMasternodes { sdk: std::sync::Arc, persister: std::sync::Arc, network: Network, + /// The manager's wallets, so a refresh that learns a registration can + /// lock its collateral in them. + wallet_manager: std::sync::Arc>>, } /// Apply one registry mutation and durably replace the persisted set as one @@ -672,6 +678,24 @@ impl TrackedMasternodes { } } + /// The collateral of every tracked masternode whose registration has + /// been fetched (see [`Self::refresh`]). + pub(crate) fn known_collaterals(&self) -> BTreeSet { + self.registry + .rows + .read() + .expect("tracked masternode registry lock poisoned") + .values() + .filter_map(|tracked| { + let registration = tracked.snapshot.registration.as_ref()?; + Some(named_collateral( + &tracked.pro_tx_hash, + registration.collateral, + )) + }) + .collect() + } + /// The wire proTxHashes currently tracked (for locate's /// `already_tracked` mark). pub fn hashes(&self) -> std::collections::BTreeSet<[u8; 32]> { @@ -813,6 +837,17 @@ impl TrackedMasternodes { ) .await?; + // Once the registration is known, keep its collateral out of every + // wallet's coin selection: spending it would end the registration. + if let Some(registration) = tracked.snapshot.registration.as_ref() { + let collateral = named_collateral(&tracked.pro_tx_hash, registration.collateral); + lock_known_masternode_collaterals( + self.wallet_manager.as_ref(), + &BTreeSet::from([collateral]), + ) + .await; + } + let entry = outcome .list_now .as_ref() @@ -1066,6 +1101,7 @@ impl PlatformWalletManager

{ sdk: self.sdk_arc(), persister: std::sync::Arc::clone(&self.persister) as _, network: self.sdk().network, + wallet_manager: std::sync::Arc::clone(&self.wallet_manager), } } diff --git a/packages/rs-platform-wallet/src/masternode/update_service.rs b/packages/rs-platform-wallet/src/masternode/update_service.rs index 9996530a311..82c341a4492 100644 --- a/packages/rs-platform-wallet/src/masternode/update_service.rs +++ b/packages/rs-platform-wallet/src/masternode/update_service.rs @@ -2086,4 +2086,61 @@ mod tests { .expect("the released UTXO funds the next build"); assert_eq!(rebuilt.transaction().input.len(), 1); } + + /// The fee of a ProUpServTx is funded like any send, so it never spends + /// the masternode's collateral: with a 5 DASH coin beside the 1,000 DASH + /// collateral the fee comes from the 5 DASH coin, and with that coin also + /// locked there is nothing left to pay it with. + #[tokio::test] + async fn should_fund_an_update_service_fee_without_the_masternode_collateral() { + const DASH: u64 = 100_000_000; + let (wallet_manager, wallet_id, generation, signer, _collateral, spare) = + crate::test_support::wallet_manager_with_registered_collateral( + StandardAccountType::BIP44Account, + 5 * DASH, + ) + .await; + let sdk = Arc::new(dash_sdk::SdkBuilder::new_mock().build().expect("mock sdk")); + let core = CoreWallet::new( + sdk, + wallet_manager, + wallet_id, + Arc::new(RecordingBroadcaster::default()), + generation, + ); + let entry = operator_entry(0x45, false); + + let placeholder = prepare_update_service_placeholder(&entry, None, ScriptBuf::new()) + .expect("placeholder"); + let prepared = + build_sign_update_service(&core, placeholder, Zeroizing::new(OPERATOR_SECRET), &signer) + .await + .expect("the spare coin pays the fee"); + let inputs: Vec<_> = prepared + .transaction() + .input + .iter() + .map(|input| input.previous_output) + .collect(); + assert_eq!(inputs, vec![spare], "only the spare coin may pay the fee"); + core.abandon_transaction(&prepared).await; + + { + let mut wm = core.wallet_manager.write().await; + let info = wm + .get_wallet_info_mut(&core.wallet_id()) + .expect("wallet present in manager"); + assert!(info.core_wallet.lock_outpoint(spare)); + } + let placeholder = prepare_update_service_placeholder(&entry, None, ScriptBuf::new()) + .expect("placeholder"); + let err = + build_sign_update_service(&core, placeholder, Zeroizing::new(OPERATOR_SECRET), &signer) + .await + .expect_err("only the collateral is left to pay the fee"); + assert!( + matches!(err, PlatformWalletError::CorePooledInsufficientFunds { .. }), + "expected a funding shortfall, got {err:?}" + ); + } } diff --git a/packages/rs-platform-wallet/src/test_support.rs b/packages/rs-platform-wallet/src/test_support.rs index 30b691c1145..b8a96bbb105 100644 --- a/packages/rs-platform-wallet/src/test_support.rs +++ b/packages/rs-platform-wallet/src/test_support.rs @@ -141,6 +141,14 @@ pub struct WalletSigner { wallet: Wallet, } +#[cfg(test)] +impl WalletSigner { + /// A signer over `wallet`'s seed. + pub(crate) fn for_wallet(wallet: Wallet) -> Self { + Self { wallet } + } +} + #[async_trait] impl Signer for WalletSigner { type Error = String; @@ -265,6 +273,7 @@ pub async fn funded_wallet_manager_with_outputs( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); @@ -273,6 +282,126 @@ pub async fn funded_wallet_manager_with_outputs( (Arc::new(RwLock::new(wm)), wallet_id, generation, signer) } +/// 1,000 DASH in duffs: the collateral of a regular masternode. +#[cfg(test)] +pub(crate) const MASTERNODE_COLLATERAL_DUFFS: u64 = 100_000_000_000; + +/// A masternode registration (ProRegTx) naming `collateral`, with no inputs +/// or outputs of its own and keys that belong to no test wallet: the shape +/// of a registration funded and signed elsewhere, which touches a wallet +/// only through the collateral it names. +#[cfg(test)] +pub(crate) fn masternode_registration(collateral: dashcore::OutPoint) -> Transaction { + use dashcore::blockdata::transaction::special_transaction::provider_registration::{ + ProviderMasternodeType, ProviderRegistrationPayload, + }; + use dashcore::blockdata::transaction::special_transaction::TransactionPayload; + use dashcore::bls_sig_utils::BLSPublicKey; + use dashcore::hash_types::InputsHash; + use dashcore::{PubkeyHash, ScriptBuf}; + + Transaction { + version: 3, + lock_time: 0, + input: vec![], + output: vec![], + special_transaction_payload: Some(TransactionPayload::ProviderRegistrationPayloadType( + ProviderRegistrationPayload { + version: ProviderRegistrationPayload::CURRENT_VERSION, + masternode_type: ProviderMasternodeType::Regular, + masternode_mode: 0, + collateral_outpoint: collateral, + service_address: "10.0.0.1:9999".parse().expect("socket address"), + owner_key_hash: PubkeyHash::from_byte_array([0x71; 20]), + operator_public_key: BLSPublicKey::from([0x72; 48]), + voting_key_hash: PubkeyHash::from_byte_array([0x73; 20]), + operator_reward: 0, + script_payout: ScriptBuf::new(), + inputs_hash: InputsHash::all_zeros(), + signature: vec![], + platform_node_id: None, + platform_p2p_port: None, + platform_http_port: None, + }, + )), + } +} + +/// The outpoint of the coin worth `value` in the wallet's `account_type` +/// index-0 account. +#[cfg(test)] +pub(crate) async fn coin_worth( + manager: &RwLock>, + wallet_id: &WalletId, + account_type: StandardAccountType, + value: u64, +) -> dashcore::OutPoint { + let wm = manager.read().await; + let info = wm.get_wallet_info(wallet_id).expect("wallet present"); + let account = match account_type { + StandardAccountType::BIP44Account => info.core_wallet.first_bip44_managed_account(), + StandardAccountType::BIP32Account => info.core_wallet.first_bip32_managed_account(), + } + .expect("funded account"); + account + .utxos + .values() + .find(|utxo| utxo.value() == value) + .map(|utxo| utxo.outpoint) + .expect("a coin of that value") +} + +/// Like [`funded_wallet_manager_with_outputs`], with the account holding a +/// 1,000 DASH masternode collateral and one `spare` coin, and the wallet +/// having processed the ProRegTx that registers the collateral, through the +/// same `check_transaction_in_all_wallets` path block processing takes. The +/// ProRegTx is otherwise irrelevant to the wallet. Returns the manager +/// fixture plus the collateral and spare outpoints. +#[cfg(test)] +pub(crate) async fn wallet_manager_with_registered_collateral( + account_type: StandardAccountType, + spare: u64, +) -> ( + Arc>>, + WalletId, + Arc, + WalletSigner, + dashcore::OutPoint, + dashcore::OutPoint, +) { + let (manager, wallet_id, generation, signer) = + funded_wallet_manager_with_outputs(account_type, &[MASTERNODE_COLLATERAL_DUFFS, spare]) + .await; + let collateral = coin_worth( + &manager, + &wallet_id, + account_type, + MASTERNODE_COLLATERAL_DUFFS, + ) + .await; + let spare = coin_worth(&manager, &wallet_id, account_type, spare).await; + { + let mut wm = manager.write().await; + wm.check_transaction_in_all_wallets( + &masternode_registration(collateral), + TransactionContext::InChainLockedBlock(BlockInfo::new( + 2, + BlockHash::all_zeros(), + 1_700_000_100, + )), + true, + true, + ) + .await; + let info = wm.get_wallet_info(&wallet_id).expect("wallet present"); + assert!( + info.core_wallet.is_outpoint_locked(&collateral), + "processing the registration locks its collateral" + ); + } + (manager, wallet_id, generation, signer, collateral, spare) +} + /// The `WalletEvent` the wallet emits when it first observes `tx` spending /// its outpoints — the real shape the spend-observation seam /// ([`SpendObservationHandler`](crate::wallet::core::SpendObservationHandler)) @@ -398,6 +527,7 @@ pub(crate) async fn funded_wallet_manager_dual_standard( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); let wallet_id = wm.insert_wallet(ctx.wallet, info).expect("insert wallet"); @@ -504,6 +634,7 @@ pub(crate) async fn funded_wallet_manager_with_contact( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); let wallet_id = wm.insert_wallet(ctx.wallet, info).expect("insert wallet"); @@ -575,6 +706,7 @@ pub(crate) async fn funded_coinjoin_wallet_manager() -> ( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); @@ -915,6 +1047,7 @@ pub(crate) async fn mnemonic_wallet_manager( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); diff --git a/packages/rs-platform-wallet/src/wallet/apply.rs b/packages/rs-platform-wallet/src/wallet/apply.rs index 81512cad78a..bdf9dca365a 100644 --- a/packages/rs-platform-wallet/src/wallet/apply.rs +++ b/packages/rs-platform-wallet/src/wallet/apply.rs @@ -498,6 +498,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), } } diff --git a/packages/rs-platform-wallet/src/wallet/asset_lock/build.rs b/packages/rs-platform-wallet/src/wallet/asset_lock/build.rs index 57a6ae3b46a..89d6ffc577d 100644 --- a/packages/rs-platform-wallet/src/wallet/asset_lock/build.rs +++ b/packages/rs-platform-wallet/src/wallet/asset_lock/build.rs @@ -5891,4 +5891,61 @@ mod tests { snapshot ); } + + /// An asset lock from a wallet holding a 1,000 DASH masternode collateral + /// and a 5 DASH coin is funded from the 5 DASH coin: a lock only the + /// collateral could fund is refused, and draining the account locks the + /// spare coin alone. + #[tokio::test] + async fn should_fund_an_asset_lock_without_the_masternode_collateral() { + const DASH: u64 = 100_000_000; + let (wallet_manager, wallet_id, _generation, signer, _collateral, spare) = + crate::test_support::wallet_manager_with_registered_collateral( + StandardAccountType::BIP44Account, + 5 * DASH, + ) + .await; + let (manager, _persistence) = asset_lock_manager_over( + wallet_manager, + wallet_id, + Arc::new(CountingOkBroadcaster::default()), + ); + + let shortfall = manager + .build_asset_lock_transaction( + 6 * DASH, + 0, + AssetLockFundingType::IdentityRegistration, + 0, + &signer, + ) + .await; + assert!( + matches!( + shortfall, + Err(PlatformWalletError::AssetLockInsufficientFunds { .. }) + ), + "a 6 DASH lock needs the collateral, got {shortfall:?}" + ); + + let (tx, _path, _token, _accounts) = manager + .build_asset_lock_transaction_with_funding( + super::AssetLockBuildAmount::DrainAll { + minimum_lock_duffs: None, + }, + &[AccountTypePreference::BIP44], + 0, + AssetLockFundingType::IdentityRegistration, + 0, + &signer, + ) + .await + .expect("draining the account locks the spare coin"); + let inputs: Vec = tx.input.iter().map(|input| input.previous_output).collect(); + assert_eq!( + inputs, + vec![spare], + "the drain must leave the collateral alone" + ); + } } diff --git a/packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs b/packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs index 5e6eadfb761..0ed1ca17415 100644 --- a/packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs +++ b/packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs @@ -668,6 +668,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; assert_eq!( funding_account_index(&info, &txid), diff --git a/packages/rs-platform-wallet/src/wallet/asset_lock/sync/recovery.rs b/packages/rs-platform-wallet/src/wallet/asset_lock/sync/recovery.rs index 922a47968b7..33a19652ee5 100644 --- a/packages/rs-platform-wallet/src/wallet/asset_lock/sync/recovery.rs +++ b/packages/rs-platform-wallet/src/wallet/asset_lock/sync/recovery.rs @@ -2584,6 +2584,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; let out_point = OutPoint::new(tx.txid(), 0); let lock = TrackedAssetLock { diff --git a/packages/rs-platform-wallet/src/wallet/core/transaction.rs b/packages/rs-platform-wallet/src/wallet/core/transaction.rs index d282fba6cb1..ca2688a24ec 100644 --- a/packages/rs-platform-wallet/src/wallet/core/transaction.rs +++ b/packages/rs-platform-wallet/src/wallet/core/transaction.rs @@ -2073,4 +2073,205 @@ mod tests { Err(PlatformWalletError::CoreInsufficientFunds { .. }) )); } + + const DASH: u64 = 100_000_000; + const SPARE: u64 = 5 * DASH; + + /// A BIP44 core wallet holding a 1,000 DASH masternode collateral, locked + /// by the registration the wallet processed, and one 5 DASH coin. + async fn collateral_core() -> ( + CoreWallet, + WalletSigner, + dashcore::OutPoint, + dashcore::OutPoint, + ) { + let (manager, wallet_id, generation, signer, collateral, spare) = + crate::test_support::wallet_manager_with_registered_collateral( + StandardAccountType::BIP44Account, + SPARE, + ) + .await; + let sdk = Arc::new(dash_sdk::SdkBuilder::new_mock().build().expect("mock sdk")); + ( + CoreWallet::new( + sdk, + manager, + wallet_id, + Arc::new(AlwaysOkBroadcaster), + generation, + ), + signer, + collateral, + spare, + ) + } + + fn largest_first_send(amount: u64) -> TransactionBuilder { + TransactionBuilder::new() + .set_selection_strategy(SelectionStrategy::LargestFirst) + .add_output(&DashAddress::dummy(Network::Testnet, 90), amount) + } + + /// Sending 1 DASH from a wallet holding a 1,000 DASH collateral and a + /// 5 DASH coin spends the 5 DASH coin. Largest-first would reach for the + /// collateral first, and the drain would sweep it, if the lock did not + /// keep it out of selection. + #[tokio::test] + async fn should_send_from_the_spare_coin_and_never_the_masternode_collateral() { + let (core, signer, _collateral, spare) = collateral_core().await; + + let finalized = core + .finalize_transaction( + largest_first_send(DASH), + &crate::SEND_FUNDING_SOURCES, + 0, + &signer, + ) + .await + .expect("the spare coin covers 1 DASH"); + let inputs: Vec<_> = finalized + .transaction() + .input + .iter() + .map(|input| input.previous_output) + .collect(); + assert_eq!(inputs, vec![spare], "only the spare coin may be spent"); + core.abandon_transaction(&finalized).await; + + let drain = core + .finalize_transaction( + TransactionBuilder::new() + .set_selection_strategy(SelectionStrategy::All) + .add_output(&DashAddress::dummy(Network::Testnet, 91), 0), + &crate::SEND_FUNDING_SOURCES, + 0, + &signer, + ) + .await + .expect("the drain spends the spare coin"); + let inputs: Vec<_> = drain + .transaction() + .input + .iter() + .map(|input| input.previous_output) + .collect(); + assert_eq!( + inputs, + vec![spare], + "a drain must leave the collateral alone" + ); + core.abandon_transaction(&drain).await; + } + + /// A payment only the collateral could cover is refused rather than + /// funded from it. + #[tokio::test] + async fn should_refuse_a_send_only_the_masternode_collateral_could_cover() { + let (core, signer, _collateral, _spare) = collateral_core().await; + let err = core + .finalize_transaction( + largest_first_send(6 * DASH), + &crate::SEND_FUNDING_SOURCES, + 0, + &signer, + ) + .await + .expect_err("6 DASH needs the collateral"); + assert!( + matches!(err, PlatformWalletError::CorePooledInsufficientFunds { .. }), + "expected a funding shortfall, got {err:?}" + ); + } + + /// The spendable pool and the max-sendable figure count the spare coin + /// only, so a host offering "send max" never offers the collateral. + #[tokio::test] + async fn should_leave_the_masternode_collateral_out_of_max_sendable() { + let (core, _signer, _collateral, _spare) = collateral_core().await; + let sources = [AccountTypePreference::BIP44]; + assert_eq!( + core.pooled_spendable_balance(&sources[..], 0) + .await + .expect("pooled balance"), + SPARE + ); + let fee = FeeRate::normal().calculate_fee(estimate_tx_size(1, 1, false)); + assert_eq!( + core.pooled_max_sendable(&sources[..], 0, None) + .await + .expect("max sendable"), + SPARE - fee, + "max sendable is the spare coin less the fee of spending it alone" + ); + } + + /// A caller-seeded copy of the collateral is dropped, not spent: a + /// reservation-only build seeded with nothing but the collateral has + /// nothing to fund from. + #[tokio::test] + async fn should_not_spend_a_seeded_masternode_collateral() { + let (core, signer, collateral, _spare) = collateral_core().await; + let seeded = { + let wm = core.wallet_manager.read().await; + let info = wm + .get_wallet_info(&core.wallet_id()) + .expect("wallet present in manager"); + info.core_wallet + .first_bip44_managed_account() + .expect("bip44 managed account") + .utxos + .get(&collateral) + .cloned() + .expect("the wallet holds its collateral") + }; + let err = core + .finalize_transaction_with_options( + largest_first_send(DASH).add_inputs([seeded]), + &[AccountTypePreference::BIP44], + 0, + &signer, + true, + ) + .await + .expect_err("the seeded collateral must not fund the send"); + assert!( + matches!(err, PlatformWalletError::CoreInsufficientFunds { .. }), + "expected a funding shortfall, got {err:?}" + ); + } + + /// Unlocking the collateral hands it back to coin selection: + /// largest-first then spends it. + #[tokio::test] + async fn should_spend_the_masternode_collateral_after_an_explicit_unlock() { + let (core, signer, collateral, _spare) = collateral_core().await; + { + let mut wm = core.wallet_manager.write().await; + let info = wm + .get_wallet_info_mut(&core.wallet_id()) + .expect("wallet present in manager"); + assert!(info.core_wallet.unlock_outpoint(&collateral)); + } + let finalized = core + .finalize_transaction( + largest_first_send(DASH), + &crate::SEND_FUNDING_SOURCES, + 0, + &signer, + ) + .await + .expect("the unlocked collateral funds the send"); + let inputs: Vec<_> = finalized + .transaction() + .input + .iter() + .map(|input| input.previous_output) + .collect(); + assert_eq!( + inputs, + vec![collateral], + "largest-first takes the collateral" + ); + core.abandon_transaction(&finalized).await; + } } diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs b/packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs index e99725d64cb..8d806ab4e49 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs @@ -5445,6 +5445,7 @@ mod sweep_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), } } diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs b/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs index 56decc9a798..90d85ba171f 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs @@ -15866,4 +15866,112 @@ mod tests { .expect("the refused send released the only coin"); iw.dashpay().abandon_prepared_payment(retry).await; } + + /// Broadcaster stub that accepts every transaction and keeps a copy, so a + /// send-path test can read the inputs the build selected. + struct RecordingBroadcaster { + sent: Mutex>, + } + + #[async_trait::async_trait] + impl crate::broadcaster::TransactionBroadcaster for RecordingBroadcaster { + async fn broadcast( + &self, + transaction: &dashcore::Transaction, + ) -> Result { + self.sent + .lock() + .expect("recorded transactions") + .push(transaction.clone()); + Ok(transaction.txid()) + } + } + + /// A DashPay payment of 1 DASH from a wallet holding a 1,000 DASH + /// masternode collateral and a 5 DASH coin spends the 5 DASH coin, and a + /// payment only the collateral could cover is refused. The payment path + /// selects largest-first, so without the lock the collateral would be the + /// first coin it takes. + #[tokio::test] + async fn should_pay_a_contact_from_the_spare_coin_and_never_the_masternode_collateral() { + use crate::test_support::{masternode_registration, MASTERNODE_COLLATERAL_DUFFS}; + use crate::wallet::identity::network::contact_requests::SeedCryptoProvider; + use dashcore::hashes::Hash; + use key_wallet::transaction_checking::{BlockInfo, TransactionContext}; + + const DASH: u64 = 100_000_000; + let (manager, _persister, wallet_id, owner_id, contact_id) = + register_sender_and_external_account().await; + fund_bip44_account_0(&manager, wallet_id, 0xC0, MASTERNODE_COLLATERAL_DUFFS).await; + fund_bip44_account_0(&manager, wallet_id, 0xC1, 5 * DASH).await; + let collateral = dashcore::OutPoint { + txid: dashcore::Txid::from_byte_array([0xC0; 32]), + vout: 0, + }; + let spare = dashcore::OutPoint { + txid: dashcore::Txid::from_byte_array([0xC1; 32]), + vout: 0, + }; + + let wallet = manager.get_wallet(&wallet_id).await.expect("wallet"); + { + let mut wm = wallet.identity().wallet_manager.write().await; + wm.check_transaction_in_all_wallets( + &masternode_registration(collateral), + TransactionContext::InChainLockedBlock(BlockInfo::new( + 101, + dashcore::BlockHash::all_zeros(), + 1_700_000_000, + )), + true, + true, + ) + .await; + } + + let seed = Mnemonic::from_phrase(TEST_MNEMONIC) + .expect("valid mnemonic") + .to_seed(""); + let provider = SeedCryptoProvider::from_seed(seed, Network::Testnet); + let signer = SeedSigner::new(seed, Network::Testnet); + let broadcaster = Arc::new(RecordingBroadcaster { + sent: Mutex::new(Vec::new()), + }); + let real = wallet.identity(); + let iw = crate::wallet::identity::IdentityWallet { + sdk: Arc::clone(&real.sdk), + wallet_manager: Arc::clone(&real.wallet_manager), + wallet_id: real.wallet_id, + asset_locks: Arc::clone(&real.asset_locks), + persister: real.persister.clone(), + broadcaster: Arc::clone(&broadcaster), + sdk_writer: Arc::clone(&real.sdk_writer), + dpns_operation_gate: Arc::clone(&real.dpns_operation_gate), + dpns_sync_progress: Arc::clone(&real.dpns_sync_progress), + }; + + let err = iw + .dashpay() + .send_payment(&owner_id, &contact_id, 6 * DASH, None, &signer, &provider) + .await + .expect_err("6 DASH needs the collateral"); + assert!( + matches!(&err, PlatformWalletError::TransactionBuild(reason) + if reason.to_lowercase().contains("insufficient")), + "expected a funding shortfall, got {err:?}" + ); + + iw.dashpay() + .send_payment(&owner_id, &contact_id, DASH, None, &signer, &provider) + .await + .expect("the spare coin covers 1 DASH"); + let sent = broadcaster.sent.lock().expect("recorded transactions"); + assert_eq!(sent.len(), 1, "one payment was broadcast"); + let inputs: Vec<_> = sent[0] + .input + .iter() + .map(|input| input.previous_output) + .collect(); + assert_eq!(inputs, vec![spare], "only the spare coin may be spent"); + } } diff --git a/packages/rs-platform-wallet/src/wallet/mod.rs b/packages/rs-platform-wallet/src/wallet/mod.rs index bbf1c58caf4..84408715e67 100644 --- a/packages/rs-platform-wallet/src/wallet/mod.rs +++ b/packages/rs-platform-wallet/src/wallet/mod.rs @@ -5,6 +5,7 @@ pub mod core_address_key; pub mod identity; pub mod masternode_withdrawal; pub mod mnemonic; +pub(crate) mod outpoint_locks; pub mod persister; pub mod platform_addresses; pub mod platform_wallet; diff --git a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs new file mode 100644 index 00000000000..00c35e9de58 --- /dev/null +++ b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs @@ -0,0 +1,602 @@ +//! Outpoints a wallet keeps out of coin selection, and their persistence. +//! +//! The lock set lives on `key_wallet`'s `ManagedWalletInfo` (see +//! [`ManagedWalletInfo::locked_outpoints`]): every masternode registration +//! (ProRegTx) the wallet processes locks its collateral, because spending the +//! collateral would end the registration, and coin selection, the asset-lock +//! builder and special-transaction funding all skip a locked coin. This module +//! carries that set to the persister and exposes explicit lock and unlock. +//! +//! Locks reach the persister through [`CoreChangeSet::outpoint_locks`] on two +//! paths: +//! +//! - A transaction check. `check_core_transaction` queues the outpoints it +//! locked on [`PlatformWalletInfo`], since no `WalletEvent` carries them, and +//! the wallet-event adapter drains the queue into the next changeset it +//! stores for the wallet. The `SyncHeightAdvanced` watermark that certifies +//! a block is a later event for the same wallet, so a lock made in a block +//! is stored with that watermark or before it. +//! - [`PlatformWallet::lock_outpoint`] and [`PlatformWallet::unlock_outpoint`], +//! which store the change themselves. +//! +//! On load each backend hands every stored lock back through +//! [`ManagedWalletInfo::lock_outpoint`]. +//! +//! # Masternodes the wallet already knows +//! +//! A ProRegTx locks its collateral only when a transaction check sees it. +//! Two kinds of registration can escape that: one restored into the +//! transaction history without a check (the mobile restore stages provider +//! transactions directly, and a wallet from before locks were kept has no +//! stored locks), and one the wallet never processed at all, such as a +//! registration funded and signed elsewhere for a collateral this wallet +//! holds. The first is in the wallet's transaction history; the second is +//! known only when the user tracks the masternode and its registration has +//! been fetched. [`lock_known_masternode_collaterals`] locks both kinds in +//! every wallet of a manager, on load, when a wallet is registered, and when +//! a tracked masternode's registration becomes known. +//! +//! [`ManagedWalletInfo::locked_outpoints`]: key_wallet::wallet::ManagedWalletInfo::locked_outpoints +//! [`ManagedWalletInfo::lock_outpoint`]: key_wallet::wallet::ManagedWalletInfo::lock_outpoint + +use std::collections::{BTreeMap, BTreeSet}; + +use dashcore::blockdata::transaction::special_transaction::TransactionPayload; +use dashcore::hashes::Hash; +use dashcore::{OutPoint, Transaction, Txid}; +use key_wallet_manager::WalletManager; +use tokio::sync::RwLock; + +use crate::changeset::{CoreChangeSet, PlatformWalletChangeSet}; +use crate::error::PlatformWalletError; +use crate::wallet::platform_wallet::{PlatformWallet, PlatformWalletInfo}; + +/// The collateral `tx` registers when it is a ProRegTx: the outpoint its +/// payload names, or, when that names a null txid, the ProRegTx's own output +/// at that index. `None` for any other transaction, and for an own-output +/// index past the outputs (such a registration names no coin). +pub(crate) fn registration_collateral(tx: &Transaction) -> Option { + let Some(TransactionPayload::ProviderRegistrationPayloadType(registration)) = + &tx.special_transaction_payload + else { + return None; + }; + let named = registration.collateral_outpoint; + if named.txid != Txid::all_zeros() { + return Some(named); + } + ((named.vout as usize) < tx.output.len()).then(|| OutPoint::new(tx.txid(), named.vout)) +} + +/// The collateral of a registration known by its proTxHash and the outpoint +/// its payload names, both as wire-order bytes, the way the tracked registry +/// keeps them. A null txid names the ProRegTx's own output, and the ProRegTx's +/// txid is the proTxHash. +pub(crate) fn named_collateral(pro_tx_hash: &[u8; 32], (txid, vout): ([u8; 32], u32)) -> OutPoint { + let txid = if txid == [0u8; 32] { + *pro_tx_hash + } else { + txid + }; + OutPoint::new(Txid::from_byte_array(txid), vout) +} + +/// Lock, in every wallet `wallet_manager` holds, the collateral of each +/// masternode registration in that wallet's transaction history and every +/// outpoint in `tracked`, and queue the new locks for persistence. Returns +/// how many locks were added across all wallets. +/// +/// A tracked collateral is locked in every wallet, whether or not the wallet +/// holds the coin yet: an entry needs no coin behind it, so a collateral +/// that reaches a wallet later (a restore still syncing) arrives locked. +pub(crate) async fn lock_known_masternode_collaterals( + wallet_manager: &RwLock>, + tracked: &BTreeSet, +) -> usize { + let mut wm = wallet_manager.write().await; + let wallet_ids: Vec<_> = wm.list_wallets().into_iter().copied().collect(); + let mut added = 0; + for wallet_id in &wallet_ids { + if let Some(info) = wm.get_wallet_info_mut(wallet_id) { + added += info.lock_known_masternode_collaterals(tracked); + } + } + added +} + +impl PlatformWalletInfo { + /// Lock the collateral of every masternode registration in this wallet's + /// transaction history, and every outpoint in `tracked`. The new locks + /// are queued for persistence. Returns how many were added. + pub(crate) fn lock_known_masternode_collaterals( + &mut self, + tracked: &BTreeSet, + ) -> usize { + let mut collaterals: BTreeSet = self + .core_wallet + .accounts + .all_accounts() + .iter() + .flat_map(|account| account.transactions().values()) + .filter_map(|record| registration_collateral(&record.transaction)) + .collect(); + collaterals.extend(tracked.iter().copied()); + let added: Vec = collaterals + .into_iter() + .filter(|outpoint| self.core_wallet.lock_outpoint(*outpoint)) + .collect(); + if !added.is_empty() { + self.publish_core_balance(); + } + let count = added.len(); + self.queue_outpoint_locks(added); + count + } + + /// Queue locks a transaction check made for the wallet-event adapter to + /// persist. + pub(crate) fn queue_outpoint_locks(&self, outpoints: impl IntoIterator) { + let mut outpoints = outpoints.into_iter().peekable(); + if outpoints.peek().is_none() { + return; + } + self.pending_outpoint_locks + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()) + .extend(outpoints); + } + + /// Take every queued lock, leaving the queue empty. + pub(crate) fn take_queued_outpoint_locks(&self) -> BTreeSet { + std::mem::take( + &mut *self + .pending_outpoint_locks + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()), + ) + } + + /// Drop a queued lock for `outpoint`: an explicit lock or unlock stores + /// the outpoint's state itself, and a queued lock stored after it would + /// overwrite an unlock. + fn forget_queued_outpoint_lock(&self, outpoint: &OutPoint) { + self.pending_outpoint_locks + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()) + .remove(outpoint); + } + + /// Mirror the core balance into the lock-free snapshot the UI reads. + fn publish_core_balance(&self) { + let balance = &self.core_wallet.balance; + self.generation.set( + balance.confirmed(), + balance.unconfirmed(), + balance.immature(), + balance.locked(), + ); + } +} + +impl PlatformWallet { + /// The outpoints this wallet keeps out of coin selection, in outpoint + /// order: the collateral of every masternode registration the wallet has + /// processed, and every outpoint locked with [`Self::lock_outpoint`]. + /// + /// An entry does not need a coin behind it: a collateral whose ProRegTx + /// arrived first, or an outpoint locked before its coin, is listed and + /// the coin arrives locked. + pub async fn locked_outpoints(&self) -> Result, PlatformWalletError> { + let wm = self.wallet_manager.read().await; + let info = wm + .get_wallet_info(&self.wallet_id()) + .ok_or_else(|| PlatformWalletError::WalletNotFound(hex::encode(self.wallet_id())))?; + Ok(info + .core_wallet + .locked_outpoints() + .iter() + .copied() + .collect()) + } + + /// Lock `outpoint`, so no send, asset lock or special-transaction fee + /// spends it until [`Self::unlock_outpoint`]. + /// + /// The wallet does not need to hold the coin yet. When it does, the + /// coin's value moves from the spendable balance to the locked one. + /// Returns `true` when the outpoint was not locked before. + /// + /// The lock is persisted before this returns. The state is stored even + /// when nothing changed, so calling again repeats a store that failed. + /// + /// # Errors + /// + /// [`PlatformWalletError::WalletNotFound`] when the wallet is no longer + /// registered, or the store's error when persisting fails. After a store + /// failure the wallet still holds the lock in memory, but it does not + /// survive a restart. + pub async fn lock_outpoint(&self, outpoint: OutPoint) -> Result { + self.set_outpoint_lock(outpoint, true).await + } + + /// Unlock `outpoint`, so coin selection may spend it again. + /// + /// Unlocking a masternode collateral lets a send spend it, and spending + /// it ends the masternode registration. The wallet never unlocks one on + /// its own. Processing the registration again (a rescan) locks it again. + /// Returns `true` when the outpoint was locked. + /// + /// Persisted before this returns, like [`Self::lock_outpoint`]. + /// + /// # Errors + /// + /// As [`Self::lock_outpoint`]. After a store failure the outpoint is + /// unlocked in memory but comes back locked after a restart. + pub async fn unlock_outpoint(&self, outpoint: OutPoint) -> Result { + self.set_outpoint_lock(outpoint, false).await + } + + async fn set_outpoint_lock( + &self, + outpoint: OutPoint, + locked: bool, + ) -> Result { + // The write lock is held through the store, so a transaction check + // cannot queue a lock for this outpoint between the change and its + // persistence. + let mut wm = self.wallet_manager.write().await; + let info = wm + .get_wallet_info_mut(&self.wallet_id()) + .ok_or_else(|| PlatformWalletError::WalletNotFound(hex::encode(self.wallet_id())))?; + let changed = if locked { + info.core_wallet.lock_outpoint(outpoint) + } else { + info.core_wallet.unlock_outpoint(&outpoint) + }; + info.forget_queued_outpoint_lock(&outpoint); + if changed { + info.publish_core_balance(); + } + + let persister = self.persister(); + let changeset = PlatformWalletChangeSet { + core: Some(CoreChangeSet { + outpoint_locks: BTreeMap::from([(outpoint, locked)]), + ..CoreChangeSet::default() + }), + ..PlatformWalletChangeSet::default() + }; + persister + .store(changeset) + .map_err(|e| persister.classify_store_failure(e))?; + if !persister.store_commits_inline() { + persister + .flush() + .map_err(|e| PlatformWalletError::Persistence(e.to_string()))?; + } + Ok(changed) + } +} + +#[cfg(test)] +mod tests { + use std::sync::{Arc, Mutex}; + + use dashcore::{BlockHash, Network, TxOut}; + use key_wallet::account::account_type::StandardAccountType; + use key_wallet::managed_account::managed_account_trait::ManagedAccountTrait; + use key_wallet::managed_account::transaction_record::{ + TransactionDirection, TransactionRecord, + }; + use key_wallet::transaction_checking::{BlockInfo, TransactionContext, TransactionType}; + use key_wallet::wallet::initialization::WalletAccountCreationOptions; + use key_wallet::wallet::managed_wallet_info::coin_selection::SelectionStrategy; + use key_wallet::wallet::managed_wallet_info::transaction_builder::TransactionBuilder; + use key_wallet::wallet::Wallet; + + use super::*; + use crate::changeset::{ClientStartState, PersistenceError, PlatformWalletPersistence}; + use crate::test_support::{ + funded_wallet_manager_with_outputs, masternode_registration, NoopTestEventHandler, + WalletSigner, MASTERNODE_COLLATERAL_DUFFS, + }; + use crate::wallet::platform_wallet::WalletId; + + const DASH: u64 = 100_000_000; + + /// Records the outpoint locks of every changeset it stores. + #[derive(Default)] + struct LockRecordingPersister { + stored: Mutex>>, + } + + impl PlatformWalletPersistence for LockRecordingPersister { + fn store( + &self, + _wallet_id: WalletId, + changeset: PlatformWalletChangeSet, + ) -> Result<(), PersistenceError> { + if let Some(core) = changeset.core { + if !core.outpoint_locks.is_empty() { + self.stored + .lock() + .expect("stored locks") + .push(core.outpoint_locks); + } + } + Ok(()) + } + + fn flush(&self, _wallet_id: WalletId) -> Result<(), PersistenceError> { + Ok(()) + } + + fn load(&self) -> Result { + Ok(ClientStartState::default()) + } + } + + fn block(height: u32) -> TransactionContext { + TransactionContext::InChainLockedBlock(BlockInfo::new( + height, + BlockHash::all_zeros(), + 1_700_000_000 + height, + )) + } + + #[test] + fn should_name_the_registrations_own_output_for_a_null_collateral_txid() { + let pro_tx_hash = [0x5A; 32]; + assert_eq!( + named_collateral(&pro_tx_hash, ([0u8; 32], 1)), + OutPoint::new(Txid::from_byte_array(pro_tx_hash), 1) + ); + assert_eq!( + named_collateral(&pro_tx_hash, ([0x11; 32], 3)), + OutPoint::new(Txid::from_byte_array([0x11; 32]), 3) + ); + } + + /// Unlocking through the wallet persists the unlock and hands the + /// collateral back to coin selection; locking again persists the lock + /// and takes it back out. + #[tokio::test] + async fn should_persist_explicit_unlock_and_lock_and_spend_the_collateral_only_while_unlocked() + { + let persister = Arc::new(LockRecordingPersister::default()); + let sdk = Arc::new(dash_sdk::SdkBuilder::new_mock().build().expect("mock sdk")); + let manager = Arc::new(crate::PlatformWalletManager::new( + sdk, + Arc::clone(&persister), + Arc::new(NoopTestEventHandler) as _, + )); + let seed = [0x3C; 64]; + let wallet = manager + .create_wallet_from_seed_bytes( + Network::Testnet, + &seed, + WalletAccountCreationOptions::Default, + Some(0), + ) + .await + .expect("create wallet"); + let signer = WalletSigner::for_wallet( + Wallet::from_seed_bytes( + seed, + Network::Testnet, + WalletAccountCreationOptions::Default, + ) + .expect("seed wallet"), + ); + + let address = wallet + .core() + .next_receive_address_for_account(0) + .await + .expect("receive address"); + let funding = Transaction::dummy(&address, 0..1, &[MASTERNODE_COLLATERAL_DUFFS, 5 * DASH]); + let collateral = OutPoint::new(funding.txid(), 0); + { + let mut wm = wallet.wallet_manager().write().await; + wm.check_transaction_in_all_wallets(&funding, block(1), true, true) + .await; + wm.check_transaction_in_all_wallets( + &masternode_registration(collateral), + block(2), + true, + true, + ) + .await; + } + assert_eq!( + wallet.locked_outpoints().await.expect("locks"), + vec![collateral] + ); + + assert!(wallet.unlock_outpoint(collateral).await.expect("unlock")); + assert!(wallet.locked_outpoints().await.expect("locks").is_empty()); + assert_eq!( + persister.stored.lock().expect("stored locks").last(), + Some(&BTreeMap::from([(collateral, false)])), + "the unlock is persisted" + ); + { + let wm = wallet.wallet_manager().read().await; + let info = wm.get_wallet_info(&wallet.wallet_id()).expect("wallet"); + assert!( + info.take_queued_outpoint_locks().is_empty(), + "the unlock drops the lock the registration queued, so the adapter cannot \ + store it over the unlock" + ); + } + assert_eq!( + wallet.balance().locked(), + 0, + "the UI balance follows the unlock" + ); + + let finalized = wallet + .core() + .finalize_transaction( + TransactionBuilder::new() + .set_selection_strategy(SelectionStrategy::LargestFirst) + .add_output(&dashcore::Address::dummy(Network::Testnet, 92), DASH), + &crate::SEND_FUNDING_SOURCES, + 0, + &signer, + ) + .await + .expect("the unlocked collateral funds the send"); + let inputs: Vec = finalized + .transaction() + .input + .iter() + .map(|input| input.previous_output) + .collect(); + assert_eq!( + inputs, + vec![collateral], + "largest-first takes the unlocked collateral" + ); + wallet.core().abandon_transaction(&finalized).await; + + assert!(wallet.lock_outpoint(collateral).await.expect("lock")); + assert!( + !wallet.lock_outpoint(collateral).await.expect("lock again"), + "a second lock changes nothing" + ); + assert_eq!( + persister.stored.lock().expect("stored locks").last(), + Some(&BTreeMap::from([(collateral, true)])), + "the lock is persisted" + ); + assert_eq!(wallet.balance().locked(), MASTERNODE_COLLATERAL_DUFFS); + let err = wallet + .core() + .finalize_transaction( + TransactionBuilder::new() + .set_selection_strategy(SelectionStrategy::LargestFirst) + .add_output(&dashcore::Address::dummy(Network::Testnet, 93), 6 * DASH), + &crate::SEND_FUNDING_SOURCES, + 0, + &signer, + ) + .await + .expect_err("locked again, the collateral cannot fund 6 DASH"); + assert!( + matches!(err, PlatformWalletError::CorePooledInsufficientFunds { .. }), + "expected a funding shortfall, got {err:?}" + ); + } + + /// A registration restored into the history without a transaction check + /// (the mobile restore stages provider transactions directly) has its + /// collateral locked by the known-masternode pass, once. + #[tokio::test] + async fn should_lock_the_collateral_of_a_registration_restored_into_the_history() { + let (manager, wallet_id, _generation, _signer) = funded_wallet_manager_with_outputs( + StandardAccountType::BIP44Account, + &[MASTERNODE_COLLATERAL_DUFFS, 5 * DASH], + ) + .await; + let collateral = crate::test_support::coin_worth( + &manager, + &wallet_id, + StandardAccountType::BIP44Account, + MASTERNODE_COLLATERAL_DUFFS, + ) + .await; + let registration = masternode_registration(collateral); + { + let mut wm = manager.write().await; + let info = wm.get_wallet_info_mut(&wallet_id).expect("wallet"); + let account = info + .core_wallet + .accounts + .standard_bip44_accounts + .get_mut(&0) + .expect("bip44 account"); + let record = TransactionRecord::new( + registration.clone(), + account.managed_account_type().to_account_type(), + block(2), + TransactionType::ProviderRegistration, + TransactionDirection::Internal, + Vec::new(), + Vec::new(), + 0, + ); + account + .transactions_mut() + .insert(registration.txid(), record); + assert!(!info.core_wallet.is_outpoint_locked(&collateral)); + } + + assert_eq!( + lock_known_masternode_collaterals(&manager, &BTreeSet::new()).await, + 1 + ); + assert_eq!( + lock_known_masternode_collaterals(&manager, &BTreeSet::new()).await, + 0, + "a lock is added once" + ); + let wm = manager.read().await; + let info = wm.get_wallet_info(&wallet_id).expect("wallet"); + assert!(info.core_wallet.is_outpoint_locked(&collateral)); + assert_eq!( + info.core_wallet.balance.locked(), + MASTERNODE_COLLATERAL_DUFFS + ); + assert_eq!(info.core_wallet.balance.spendable(), 5 * DASH); + assert_eq!( + info.take_queued_outpoint_locks(), + BTreeSet::from([collateral]), + "the new lock is queued for persistence" + ); + } + + /// A tracked masternode's collateral is locked in a wallet that does not + /// hold the coin yet, so the coin arrives locked when it syncs. + #[tokio::test] + async fn should_lock_a_tracked_collateral_before_its_coin_arrives() { + let (manager, wallet_id, _generation, _signer) = + funded_wallet_manager_with_outputs(StandardAccountType::BIP44Account, &[5 * DASH]) + .await; + let address = { + let wm = manager.read().await; + let info = wm.get_wallet_info(&wallet_id).expect("wallet"); + info.core_wallet + .first_bip44_managed_account() + .expect("bip44 account") + .utxos + .values() + .next() + .expect("funded coin") + .address + .clone() + }; + let incoming = Transaction { + output: vec![TxOut { + value: MASTERNODE_COLLATERAL_DUFFS, + script_pubkey: address.script_pubkey(), + }], + ..Transaction::dummy(&address, 7..8, &[1]) + }; + let collateral = OutPoint::new(incoming.txid(), 0); + + assert_eq!( + lock_known_masternode_collaterals(&manager, &BTreeSet::from([collateral])).await, + 1 + ); + let mut wm = manager.write().await; + wm.check_transaction_in_all_wallets(&incoming, block(3), true, true) + .await; + let info = wm.get_wallet_info(&wallet_id).expect("wallet"); + assert_eq!( + info.core_wallet.balance.locked(), + MASTERNODE_COLLATERAL_DUFFS + ); + assert_eq!(info.core_wallet.balance.spendable(), 5 * DASH); + } +} diff --git a/packages/rs-platform-wallet/src/wallet/platform_wallet.rs b/packages/rs-platform-wallet/src/wallet/platform_wallet.rs index 5efc258e1c5..c5419f69854 100644 --- a/packages/rs-platform-wallet/src/wallet/platform_wallet.rs +++ b/packages/rs-platform-wallet/src/wallet/platform_wallet.rs @@ -1,6 +1,6 @@ //! The main PlatformWallet struct combining core, identity (+DashPay), and platform sub-wallets. -use std::collections::BTreeMap; +use std::collections::{BTreeMap, BTreeSet}; use std::ops::{Deref, DerefMut}; use std::sync::Arc; @@ -367,6 +367,16 @@ pub struct PlatformWalletInfo { /// [`RewindBarrier`](crate::changeset::core_bridge::RewindBarrier). In /// memory only. pub rewind_barrier: crate::changeset::core_bridge::RewindBarrier, + /// Outpoints `core_wallet` locked during a transaction check that are not + /// persisted yet. + /// + /// Every ProRegTx the wallet processes locks its collateral, relevant or + /// not, and no `WalletEvent` carries that lock. The check queues it here + /// and the wallet-event adapter drains the queue into the next changeset + /// it stores for this wallet. Interior mutability because the adapter + /// projects under the manager's read lock; a poisoned mutex keeps its + /// contents. + pub(crate) pending_outpoint_locks: std::sync::Mutex>, } /// A platform wallet that combines core UTXO functionality with identity management. diff --git a/packages/rs-platform-wallet/src/wallet/platform_wallet_traits.rs b/packages/rs-platform-wallet/src/wallet/platform_wallet_traits.rs index 92b64b01522..556828af8e7 100644 --- a/packages/rs-platform-wallet/src/wallet/platform_wallet_traits.rs +++ b/packages/rs-platform-wallet/src/wallet/platform_wallet_traits.rs @@ -45,6 +45,7 @@ impl WalletInfoInterface for PlatformWalletInfo { dpns_name_states: std::collections::BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), } } @@ -62,6 +63,7 @@ impl WalletInfoInterface for PlatformWalletInfo { dpns_name_states: std::collections::BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), } } @@ -379,6 +381,10 @@ impl WalletTransactionChecker for PlatformWalletInfo { .filter(|record| record.context.is_chain_locked()), )); } + // A ProRegTx locks its collateral, relevant or not, and no + // `WalletEvent` carries the lock: queue it for the wallet-event + // adapter to persist with this wallet's next changeset. + self.queue_outpoint_locks(result.locked_outpoints.iter().copied()); result } } diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift b/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift index d41f20aba2a..9bb11174238 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift @@ -96,7 +96,8 @@ public enum DashModelContainer { PersistentTrackedMasternode.self, PersistentIdentityBalanceMetadata.self, PersistentPrivateContactRequestsPosition.self, - PersistentPrivateShieldedAddress.self + PersistentPrivateShieldedAddress.self, + PersistentLockedOutpoint.self ] } diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentLockedOutpoint.swift b/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentLockedOutpoint.swift new file mode 100644 index 00000000000..768a69c1b92 --- /dev/null +++ b/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentLockedOutpoint.swift @@ -0,0 +1,25 @@ +import Foundation +import SwiftData + +/// An outpoint a wallet keeps out of coin selection: the collateral of a +/// masternode registration the wallet processed (spending it would end the +/// registration), or an outpoint locked by hand. The row is the lock, and +/// deleting it unlocks the outpoint. +/// +/// A model of its own rather than a flag on `PersistentTxo`: a lock can +/// exist before its coin does and outlives the coin's spend. +@Model +public final class PersistentLockedOutpoint { + #Unique([\.networkRaw, \.walletId, \.outpoint]) + public var networkRaw: UInt32 + public var walletId: Data + /// 36 bytes, as `PersistentTxo.outpoint`: the txid's raw bytes, then the + /// vout little-endian. + public var outpoint: Data + + public init(networkRaw: UInt32, walletId: Data, outpoint: Data) { + self.networkRaw = networkRaw + self.walletId = walletId + self.outpoint = outpoint + } +} diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift index e8206d87778..74c7774550d 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift @@ -88,6 +88,78 @@ public final class ManagedPlatformWallet: @unchecked Sendable { ) } + // MARK: - Locked outpoints + + /// A transaction output: the txid's raw 32 bytes (the order the FFI + /// carries, as `PersistentTxo.outpoint`) and the output index. + public struct Outpoint: Hashable, Sendable { + public let txid: Data + public let vout: UInt32 + + public init(txid: Data, vout: UInt32) { + self.txid = txid + self.vout = vout + } + } + + /// The outpoints this wallet keeps out of coin selection: the collateral + /// of every masternode registration the wallet has processed, and every + /// outpoint locked with `lockOutpoint`. An entry may name a coin the + /// wallet does not hold yet; the coin arrives locked. + public func lockedOutpoints() throws -> [Outpoint] { + var entries: UnsafePointer? + var count: UInt = 0 + let result = platform_wallet_locked_outpoints(handle, &entries, &count) + try result.check() + guard let entries, count > 0 else { return [] } + defer { + platform_wallet_locked_outpoints_free(UnsafeMutablePointer(mutating: entries), count) + } + return (0.. Bool { + try await setOutpointLock(outpoint, locked: true) + } + + /// Unlock `outpoint`, so coin selection may spend it again. Unlocking a + /// masternode collateral lets a send spend it, and spending it ends the + /// masternode registration. Returns `true` when it was locked. The + /// unlock is persisted before this returns. + @discardableResult + public func unlockOutpoint(_ outpoint: Outpoint) async throws -> Bool { + try await setOutpointLock(outpoint, locked: false) + } + + private func setOutpointLock(_ outpoint: Outpoint, locked: Bool) async throws -> Bool { + guard outpoint.txid.count == 32 else { + throw PlatformWalletError.invalidParameter("txid must be 32 bytes") + } + var entry = OutPointFFI() + Swift.withUnsafeMutableBytes(of: &entry.txid) { dst in + outpoint.txid.withUnsafeBytes { src in dst.copyMemory(from: src) } + } + entry.vout = outpoint.vout + let ffiOutpoint = entry + return try await Task.detached(priority: .userInitiated) { [self] in + try withExtendedLifetime(self) { + var input = ffiOutpoint + var changed = false + let result = locked + ? platform_wallet_lock_outpoint(handle, &input, &changed) + : platform_wallet_unlock_outpoint(handle, &input, &changed) + try result.check() + return changed + } + }.value + } + // MARK: - Sub-wallet access /// Get the platform address wallet for BLAST sync, transfers, and withdrawals. diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManager.swift b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManager.swift index f512c31e473..9a2c190407b 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManager.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManager.swift @@ -126,6 +126,12 @@ public struct PlatformWalletPersistenceCapabilities: Equatable, Sendable { /// only honours the declaration when the extension carries the five /// scan-state callbacks. public static let privateContactRequestScanState: UInt64 = 1 << 15 + /// Locked outpoints (masternode collateral, and outpoints locked by + /// hand) are persisted and restored across restarts, through the + /// persistence extension's outpoint-lock persist / load / free slots. + /// Mirrors `PersistenceCapabilities::OUTPOINT_LOCKS`; Rust only honours + /// the declaration when all three slots are wired. + public static let outpointLocks: UInt64 = 1 << 13 public let version: UInt32 public let bits: UInt64 diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift index 3a3568ec2f2..03d520e9f11 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift @@ -3384,6 +3384,7 @@ public final class PlatformWalletPersistenceHandler: @unchecked Sendable { | PlatformWalletPersistenceCapabilities.assetLockOperationIds | PlatformWalletPersistenceCapabilities.assetLockShieldedRecipients | PlatformWalletPersistenceCapabilities.privateContactRequestScanState + | PlatformWalletPersistenceCapabilities.outpointLocks ) } @@ -3435,6 +3436,15 @@ public final class PlatformWalletPersistenceHandler: @unchecked Sendable { loadPrivateContactScanStateWalletsCallback extensionCallbacks.on_load_private_contact_scan_state_wallets_free_fn = loadPrivateContactScanStateWalletsFreeCallback + // Locked outpoints (masternode collateral, and outpoints locked by + // hand) persist through their own rows and come back per wallet on + // load; a lock needs no coin behind it, so it has no place on the + // frozen changeset struct's TXO rows. + extensionCallbacks.on_persist_wallet_changeset_outpoint_locks_fn = + persistWalletChangesetOutpointLocksCallback + extensionCallbacks.on_load_wallet_locked_outpoints_fn = loadWalletLockedOutpointsCallback + extensionCallbacks.on_load_wallet_locked_outpoints_free_fn = + loadWalletLockedOutpointsFreeCallback return extensionCallbacks } @@ -5410,6 +5420,116 @@ public final class PlatformWalletPersistenceHandler: @unchecked Sendable { } ) } + // MARK: - Locked outpoints (additive persistence extension) + + /// The lock rows of `walletId`. Keyed by network like the balance + /// metadata sidecar, resolved the same way. + private func lockedOutpointsDescriptor(walletId: Data) + -> FetchDescriptor { + let network = self.network ?? walletNetwork(walletId: walletId) ?? .testnet + let networkRaw = network.rawValue + return FetchDescriptor(predicate: #Predicate { + $0.networkRaw == networkRaw && $0.walletId == walletId + }) + } + + /// Apply a round's outpoint lock changes: insert a row for each lock, + /// delete the row of each unlock. A lock needs no coin behind it, so it + /// never touches `PersistentTxo`. Fired by Rust inside the begin/end + /// bracket, only on rounds that change a lock. Returns `false` to fail + /// the round: a lock dropped here would hand a masternode collateral back + /// to coin selection after the next restart. + func persistWalletChangesetOutpointLocks( + walletId: Data, + locks: UnsafePointer?, + count: UInt + ) -> Bool { + onQueue { + switch roundWalletLookup(walletId: walletId, callback: "wallet_changeset_outpoint_locks") { + case .failed: return false + case .absent: return true + case .found: break + } + guard count > 0, let locks else { return true } + do { + var stored: [Data: PersistentLockedOutpoint] = [:] + for row in try backgroundContext.fetch(lockedOutpointsDescriptor(walletId: walletId)) { + stored[row.outpoint] = row + } + let network = self.network ?? walletNetwork(walletId: walletId) ?? .testnet + for i in 0.. (entries: UnsafePointer?, count: Int, errored: Bool) { + onQueue { + let rows: [PersistentLockedOutpoint] + do { + rows = try backgroundContext.fetch(lockedOutpointsDescriptor(walletId: walletId)) + } catch { + SDKLogger.event( + "persistence_outpoint_locks_load_failed", + category: .persistence, + severity: .error, + fields: ["wallet_reference": .reference(walletId)], + error: error + ) + return (nil, 0, true) + } + // A key that is not 36 bytes names no outpoint. + let keys = rows.map(\.outpoint).filter { $0.count == 36 } + guard !keys.isEmpty else { return (nil, 0, false) } + let buf = UnsafeMutablePointer.allocate(capacity: keys.count) + for (i, key) in keys.enumerated() { + var entry = OutPointFFI() + copyBytes(key.prefix(32), into: &entry.txid) + var vout: UInt32 = 0 + _ = withUnsafeMutableBytes(of: &vout) { key.suffix(4).copyBytes(to: $0) } + entry.vout = UInt32(littleEndian: vout) + (buf + i).initialize(to: entry) + } + return (UnsafePointer(buf), keys.count, false) + } + } + + /// Release rows handed out by `loadWalletLockedOutpoints`. + func loadWalletLockedOutpointsFree(entries: UnsafePointer?, count: UInt) { + guard let entries else { return } + let buf = UnsafeMutablePointer(mutating: entries) + buf.deinitialize(count: Int(count)) + buf.deallocate() } // MARK: - Identity snapshot structs @@ -6980,6 +7100,19 @@ public final class PlatformWalletPersistenceHandler: @unchecked Sendable { where !claimedNetworks.contains(row.networkRaw) { backgroundContext.delete(row) } + // Outpoint locks carry the same explicit network key. + let locks: FetchDescriptor + if let raw = metadataNetwork?.rawValue { + locks = FetchDescriptor(predicate: #Predicate { + $0.walletId == walletId && $0.networkRaw == raw + }) + } else { + locks = FetchDescriptor(predicate: #Predicate { $0.walletId == walletId }) + } + for row in try backgroundContext.fetch(locks) + where !claimedNetworks.contains(row.networkRaw) { + backgroundContext.delete(row) + } if let walletRow = walletRow { // Wallet → identities is `.nullify`; this delete @@ -12544,3 +12677,65 @@ private func loadIdentityBalanceBlockTimeCallback( return 0 } catch { return -1 } } + +/// C shim for the extension's `on_persist_wallet_changeset_outpoint_locks_fn`. +/// A non-zero return fails the round. +private func persistWalletChangesetOutpointLocksCallback( + context: UnsafeMutableRawPointer?, + walletIdPtr: UnsafePointer?, + locksPtr: UnsafePointer?, + locksCount: UInt +) -> Int32 { + guard let context = context, + let walletIdPtr = walletIdPtr else { + return 0 + } + let handler = Unmanaged + .fromOpaque(context) + .takeUnretainedValue() + let walletId = Data(bytes: walletIdPtr, count: 32) + return handler.persistWalletChangesetOutpointLocks( + walletId: walletId, + locks: locksPtr, + count: locksCount + ) ? 0 : 1 +} + +/// C shim for the extension's `on_load_wallet_locked_outpoints_fn`. +private func loadWalletLockedOutpointsCallback( + context: UnsafeMutableRawPointer?, + walletIdPtr: UnsafePointer?, + outOutpoints: UnsafeMutablePointer?>?, + outCount: UnsafeMutablePointer? +) -> Int32 { + guard let context = context, + let walletIdPtr = walletIdPtr, + let outOutpoints = outOutpoints, + let outCount = outCount else { + return 1 + } + outOutpoints.pointee = nil + outCount.pointee = 0 + let handler = Unmanaged + .fromOpaque(context) + .takeUnretainedValue() + let (entries, count, errored) = handler.loadWalletLockedOutpoints( + walletId: Data(bytes: walletIdPtr, count: 32) + ) + outOutpoints.pointee = entries + outCount.pointee = UInt(count) + return errored ? 1 : 0 +} + +/// C shim for the extension's `on_load_wallet_locked_outpoints_free_fn`. +private func loadWalletLockedOutpointsFreeCallback( + context: UnsafeMutableRawPointer?, + outpoints: UnsafePointer?, + count: UInt +) { + guard let context = context else { return } + let handler = Unmanaged + .fromOpaque(context) + .takeUnretainedValue() + handler.loadWalletLockedOutpointsFree(entries: outpoints, count: count) +} diff --git a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DashModelMigrationTests.swift b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DashModelMigrationTests.swift index 94ee9120cf3..53245bbf079 100644 --- a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DashModelMigrationTests.swift +++ b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DashModelMigrationTests.swift @@ -447,11 +447,14 @@ final class DashModelMigrationTests: XCTestCase { } } - func testV3AddsTrackedMasternodesAndBalanceMetadataToTheBaselineEntitySet() { + func testV3AddsTrackedMasternodesBalanceMetadataAndLockedOutpointsToTheBaselineEntitySet() { XCTAssertEqual( Set(Schema(versionedSchema: DashSchemaV3.self).entities.map(\.name)) .subtracting(Schema(versionedSchema: DashSchemaV1.self).entities.map(\.name)), - ["PersistentTrackedMasternode", "PersistentIdentityBalanceMetadata"]) + [ + "PersistentTrackedMasternode", "PersistentIdentityBalanceMetadata", + "PersistentLockedOutpoint", + ]) } @MainActor diff --git a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/InvitationPersistenceTests.swift b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/InvitationPersistenceTests.swift index 036693cab39..6853158ebff 100644 --- a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/InvitationPersistenceTests.swift +++ b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/InvitationPersistenceTests.swift @@ -75,6 +75,9 @@ final class InvitationPersistenceTests: XCTestCase { // persist/load/free trio onto `PersistentPrivateContactRequestsPosition` // and `PersistentPrivateShieldedAddress`. | PlatformWalletPersistenceCapabilities.privateContactRequestScanState + // Locked outpoints: the handler wires the persist/load/free trio + // onto `PersistentLockedOutpoint`, so locks survive a restart. + | PlatformWalletPersistenceCapabilities.outpointLocks XCTAssertEqual( capabilities.version, diff --git a/packages/swift-sdk/schema-models.json b/packages/swift-sdk/schema-models.json index b7714b9657d..cf80a36a252 100644 --- a/packages/swift-sdk/schema-models.json +++ b/packages/swift-sdk/schema-models.json @@ -38,7 +38,8 @@ "PersistentTrackedMasternode": "packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentTrackedMasternode.swift", "PersistentIdentityBalanceMetadata": "packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentIdentityBalanceMetadata.swift", "PersistentPrivateContactRequestsPosition": "packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentPrivateContactRequestsPosition.swift", - "PersistentPrivateShieldedAddress": "packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentPrivateShieldedAddress.swift" + "PersistentPrivateShieldedAddress": "packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentPrivateShieldedAddress.swift", + "PersistentLockedOutpoint": "packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentLockedOutpoint.swift" }, "value_types": [ { From 1c98e04e86696c7b232bb1cd3a8122dbbd6ba0d9 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 29 Sep 2026 02:20:05 +0700 Subject: [PATCH 03/26] fix(platform-wallet): lock external collateral only once its ProRegTx is mined Move the rust-dashcore pin to e49cb97310, the collateral lock backport with its follow-up: key-wallet locks a collateral a ProRegTx names only once the ProRegTx is in a block (InBlock or InChainLockedBlock), and a collateral the ProRegTx creates as its own output from any sighting. An InstantSend context counts as unconfirmed. A lock also refreshes the balance on the mempool path. Only the rust-dashcore `source` lines of Cargo.lock change. The known-masternode pass follows the same rule. It locked the collateral of every ProRegTx in a wallet's transaction history, including one recorded unconfirmed; it now locks a collateral a ProRegTx names only from a record in a block, and one it creates from any record. The transaction check that confirms an unconfirmed registration locks its collateral, and the lock rides the wallet's next changeset as before. The docs that said every processed ProRegTx locks its collateral now state the rule. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit fbb254b8e410c257a6f57a7e584f965bca04a094) The rust-dashcore pin this commit moved is left out: the branch pins dashpay/rust-dashcore#1391, which carries the same rule. Co-Authored-By: Claude Fable 5.2 --- .../src/outpoint_locks.rs | 6 +- .../src/changeset/changeset.rs | 5 +- .../src/wallet/outpoint_locks.rs | 105 +++++++++++++++--- .../src/wallet/platform_wallet.rs | 5 +- .../ManagedPlatformWallet.swift | 5 +- 5 files changed, 102 insertions(+), 24 deletions(-) diff --git a/packages/rs-platform-wallet-ffi/src/outpoint_locks.rs b/packages/rs-platform-wallet-ffi/src/outpoint_locks.rs index 3d72f003808..b6555c538a9 100644 --- a/packages/rs-platform-wallet-ffi/src/outpoint_locks.rs +++ b/packages/rs-platform-wallet-ffi/src/outpoint_locks.rs @@ -1,8 +1,10 @@ //! FFI bindings for a wallet's locked outpoints: the outpoints kept out of //! coin selection. //! -//! The wallet locks the collateral of every masternode registration it -//! processes, since spending the collateral would end the registration. +//! The wallet locks the collateral of a masternode registration once the +//! registration is in a block (a collateral the ProRegTx creates as its own +//! output, from any sighting), since spending the collateral would end the +//! registration. //! These calls list the locks and lock or unlock an outpoint by hand; a lock //! or unlock is persisted before the call returns (see //! `PlatformWallet::lock_outpoint`). diff --git a/packages/rs-platform-wallet/src/changeset/changeset.rs b/packages/rs-platform-wallet/src/changeset/changeset.rs index bc83cb80702..cea2c252751 100644 --- a/packages/rs-platform-wallet/src/changeset/changeset.rs +++ b/packages/rs-platform-wallet/src/changeset/changeset.rs @@ -326,8 +326,9 @@ pub struct CoreChangeSet { /// Changes to the outpoints the wallet keeps out of coin selection: /// `true` locks the outpoint, `false` unlocks it. /// - /// The wallet locks the collateral of every masternode registration - /// (ProRegTx) it processes, since spending the collateral would end the + /// The wallet locks the collateral of the masternode registrations + /// (ProRegTx) it processes, a collateral a ProRegTx names once the + /// ProRegTx is in a block, since spending the collateral would end the /// registration, and the user can lock or unlock any outpoint by hand. /// The in-memory set is `ManagedWalletInfo::locked_outpoints`; this is /// its persistence delta. A lock does not need a coin behind it (the diff --git a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs index 00c35e9de58..c5d167ab809 100644 --- a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs +++ b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs @@ -1,10 +1,12 @@ //! Outpoints a wallet keeps out of coin selection, and their persistence. //! //! The lock set lives on `key_wallet`'s `ManagedWalletInfo` (see -//! [`ManagedWalletInfo::locked_outpoints`]): every masternode registration +//! [`ManagedWalletInfo::locked_outpoints`]): a masternode registration //! (ProRegTx) the wallet processes locks its collateral, because spending the //! collateral would end the registration, and coin selection, the asset-lock -//! builder and special-transaction funding all skip a locked coin. This module +//! builder and special-transaction funding all skip a locked coin. A +//! collateral the ProRegTx names is locked once the ProRegTx is in a block; a +//! collateral it creates, as its own output, from any sighting. This module //! carries that set to the persister and exposes explicit lock and unlock. //! //! Locks reach the persister through [`CoreChangeSet::outpoint_locks`] on two @@ -24,7 +26,8 @@ //! //! # Masternodes the wallet already knows //! -//! A ProRegTx locks its collateral only when a transaction check sees it. +//! A ProRegTx locks its collateral only when a transaction check sees it (in a +//! block, for a collateral it names). //! Two kinds of registration can escape that: one restored into the //! transaction history without a check (the mobile restore stages provider //! transactions directly, and a wallet from before locks were kept has no @@ -82,9 +85,10 @@ pub(crate) fn named_collateral(pro_tx_hash: &[u8; 32], (txid, vout): ([u8; 32], } /// Lock, in every wallet `wallet_manager` holds, the collateral of each -/// masternode registration in that wallet's transaction history and every -/// outpoint in `tracked`, and queue the new locks for persistence. Returns -/// how many locks were added across all wallets. +/// masternode registration in that wallet's transaction history (see +/// [`PlatformWalletInfo::lock_known_masternode_collaterals`] for which) and +/// every outpoint in `tracked`, and queue the new locks for persistence. +/// Returns how many locks were added across all wallets. /// /// A tracked collateral is locked in every wallet, whether or not the wallet /// holds the coin yet: an entry needs no coin behind it, so a collateral @@ -105,9 +109,15 @@ pub(crate) async fn lock_known_masternode_collaterals( } impl PlatformWalletInfo { - /// Lock the collateral of every masternode registration in this wallet's + /// Lock the collateral of the masternode registrations in this wallet's /// transaction history, and every outpoint in `tracked`. The new locks /// are queued for persistence. Returns how many were added. + /// + /// The same rule as a transaction check: a collateral a registration + /// names is locked only when its record is in a block, since an + /// unconfirmed ProRegTx is not a registration yet; a collateral it + /// creates, as its own output, from any record. The check that confirms + /// an unconfirmed registration locks the collateral it names. pub(crate) fn lock_known_masternode_collaterals( &mut self, tracked: &BTreeSet, @@ -118,7 +128,11 @@ impl PlatformWalletInfo { .all_accounts() .iter() .flat_map(|account| account.transactions().values()) - .filter_map(|record| registration_collateral(&record.transaction)) + .filter_map(|record| { + let collateral = registration_collateral(&record.transaction)?; + let creates_it = collateral.txid == record.txid; + (creates_it || record.is_confirmed()).then_some(collateral) + }) .collect(); collaterals.extend(tracked.iter().copied()); let added: Vec = collaterals @@ -180,8 +194,9 @@ impl PlatformWalletInfo { impl PlatformWallet { /// The outpoints this wallet keeps out of coin selection, in outpoint - /// order: the collateral of every masternode registration the wallet has - /// processed, and every outpoint locked with [`Self::lock_outpoint`]. + /// order: the collateral of the masternode registrations the wallet has + /// processed (see the module docs for when), and every outpoint locked + /// with [`Self::lock_outpoint`]. /// /// An entry does not need a coin behind it: a collateral whose ProRegTx /// arrived first, or an outpoint locked before its coin, is listed and @@ -489,11 +504,17 @@ mod tests { ); } - /// A registration restored into the history without a transaction check - /// (the mobile restore stages provider transactions directly) has its - /// collateral locked by the known-masternode pass, once. - #[tokio::test] - async fn should_lock_the_collateral_of_a_registration_restored_into_the_history() { + /// A wallet holding a 1,000 DASH collateral and 5 DASH, with a ProRegTx + /// naming the collateral restored into its history in `context` without a + /// transaction check (the mobile restore stages provider transactions + /// directly). Returns the manager, the wallet and the collateral. + async fn wallet_with_restored_registration( + context: TransactionContext, + ) -> ( + Arc>>, + WalletId, + OutPoint, + ) { let (manager, wallet_id, _generation, _signer) = funded_wallet_manager_with_outputs( StandardAccountType::BIP44Account, &[MASTERNODE_COLLATERAL_DUFFS, 5 * DASH], @@ -519,7 +540,7 @@ mod tests { let record = TransactionRecord::new( registration.clone(), account.managed_account_type().to_account_type(), - block(2), + context, TransactionType::ProviderRegistration, TransactionDirection::Internal, Vec::new(), @@ -531,6 +552,14 @@ mod tests { .insert(registration.txid(), record); assert!(!info.core_wallet.is_outpoint_locked(&collateral)); } + (manager, wallet_id, collateral) + } + + /// A registration restored into the history without a transaction check + /// has its collateral locked by the known-masternode pass, once. + #[tokio::test] + async fn should_lock_the_collateral_of_a_registration_restored_into_the_history() { + let (manager, wallet_id, collateral) = wallet_with_restored_registration(block(2)).await; assert_eq!( lock_known_masternode_collaterals(&manager, &BTreeSet::new()).await, @@ -556,6 +585,50 @@ mod tests { ); } + /// An unconfirmed ProRegTx in the history is not a registration yet: the + /// known-masternode pass leaves the collateral it names spendable, as a + /// transaction check does, and the block holding it locks the collateral. + #[tokio::test] + async fn should_lock_a_named_collateral_of_a_restored_registration_only_once_it_is_mined() { + let (manager, wallet_id, collateral) = + wallet_with_restored_registration(TransactionContext::Mempool).await; + + assert_eq!( + lock_known_masternode_collaterals(&manager, &BTreeSet::new()).await, + 0 + ); + { + let wm = manager.read().await; + let info = wm.get_wallet_info(&wallet_id).expect("wallet"); + assert!(!info.core_wallet.is_outpoint_locked(&collateral)); + assert_eq!( + info.core_wallet.balance.spendable(), + MASTERNODE_COLLATERAL_DUFFS + 5 * DASH + ); + assert!(info.take_queued_outpoint_locks().is_empty()); + } + + let mut wm = manager.write().await; + wm.check_transaction_in_all_wallets( + &masternode_registration(collateral), + block(3), + true, + true, + ) + .await; + let info = wm.get_wallet_info(&wallet_id).expect("wallet"); + assert!(info.core_wallet.is_outpoint_locked(&collateral)); + assert_eq!( + info.core_wallet.balance.locked(), + MASTERNODE_COLLATERAL_DUFFS + ); + assert_eq!( + info.take_queued_outpoint_locks(), + BTreeSet::from([collateral]), + "the block's lock is queued for persistence" + ); + } + /// A tracked masternode's collateral is locked in a wallet that does not /// hold the coin yet, so the coin arrives locked when it syncs. #[tokio::test] diff --git a/packages/rs-platform-wallet/src/wallet/platform_wallet.rs b/packages/rs-platform-wallet/src/wallet/platform_wallet.rs index c5419f69854..d1f93859123 100644 --- a/packages/rs-platform-wallet/src/wallet/platform_wallet.rs +++ b/packages/rs-platform-wallet/src/wallet/platform_wallet.rs @@ -370,8 +370,9 @@ pub struct PlatformWalletInfo { /// Outpoints `core_wallet` locked during a transaction check that are not /// persisted yet. /// - /// Every ProRegTx the wallet processes locks its collateral, relevant or - /// not, and no `WalletEvent` carries that lock. The check queues it here + /// A ProRegTx the wallet processes locks its collateral, relevant or not + /// (a collateral it names once it is in a block), and no `WalletEvent` + /// carries that lock. The check queues it here /// and the wallet-event adapter drains the queue into the next changeset /// it stores for this wallet. Interior mutability because the adapter /// projects under the manager's read lock; a poisoned mutex keeps its diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift index 74c7774550d..ae780047a9e 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift @@ -103,8 +103,9 @@ public final class ManagedPlatformWallet: @unchecked Sendable { } /// The outpoints this wallet keeps out of coin selection: the collateral - /// of every masternode registration the wallet has processed, and every - /// outpoint locked with `lockOutpoint`. An entry may name a coin the + /// of the masternode registrations the wallet has seen in a block (or + /// that created their collateral), and every outpoint locked with + /// `lockOutpoint`. An entry may name a coin the /// wallet does not hold yet; the coin arrives locked. public func lockedOutpoints() throws -> [Outpoint] { var entries: UnsafePointer? From 9efc4b6a11f83082db551a2f316ce888de18fed9 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 29 Sep 2026 02:20:06 +0700 Subject: [PATCH 04/26] test(platform-wallet-storage): allow the locked-outpoint load read in the prepare check `load_state` reads `core_locked_outpoints` with `prepare`, a read-only SELECT like the unspent-UTXO read beside it, so it joins the allow-list of `tc_p1_003_prepare_cached_in_writers`. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit b74b3b4356410203f4a30d01ca5dfd12e6cca5b2) --- .../tests/integration/sqlite_compile_time.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/rs-platform-wallet-storage/tests/integration/sqlite_compile_time.rs b/packages/rs-platform-wallet-storage/tests/integration/sqlite_compile_time.rs index 0e56f58d165..7a456d18ca2 100644 --- a/packages/rs-platform-wallet-storage/tests/integration/sqlite_compile_time.rs +++ b/packages/rs-platform-wallet-storage/tests/integration/sqlite_compile_time.rs @@ -71,6 +71,11 @@ const READ_ONLY_PREPARE_ALLOWED: &[(&str, &str)] = &[ "core_state.rs", "SELECT length(outpoint), outpoint, value, length(script), script", ), + // load_state locked-outpoint reader: pre-read length() gate on outpoint. + ( + "core_state.rs", + "SELECT length(outpoint), outpoint FROM core_locked_outpoints WHERE wallet_id", + ), ("core_state.rs", "SELECT DISTINCT script FROM core_utxos"), // Pool reader: verbatim used-set with owner columns, a one-shot read-only // scan per wallet. From 3874dd5de55f6e001e9fc04e09028f2fc909efa6 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 12 Nov 2026 11:22:19 +0100 Subject: [PATCH 05/26] fix(platform-wallet): port the collateral lock to current v5.1-dev The three commits before this one were written against a branch that is now about 790 commits behind. This makes them build and pass here: - The locked-outpoint migration becomes V021 (V019 and V020 were taken by the asset-lock operation id and shielded recipient), with the schema fingerprints refreshed from the pinning test's own output and the table added to SCHEMA.md's list. - `PersistenceCapabilities::OUTPOINT_LOCKS` moves from bit 13, now `ASSET_LOCK_OPERATION_IDS`, to bit 16, the next free one. - The persistence extension's three lock slots sit after the private contact scan-state slots, and the layout test chains through them. - `sqlite_locked_outpoints` joins the single integration test binary. - The tests use today's helpers: the five-argument `prepare_update_service_placeholder`, the current `IdentityWallet` fields, and key-wallet's `Transaction::dummy_provider_registration` in place of a hand-written payload that no longer matches `ProviderRegistrationPayload`. Co-Authored-By: Claude Fable 5.2 --- .../src/core_wallet_types.rs | 4 ++ .../rs-platform-wallet-ffi/src/manager.rs | 5 ++- .../rs-platform-wallet-ffi/src/persistence.rs | 38 +++++++++++++++- packages/rs-platform-wallet-storage/SCHEMA.md | 4 +- ...ints.rs => V021__core_locked_outpoints.rs} | 0 .../tests/integration/main.rs | 1 + .../sqlite_locked_outpoints.rs | 3 +- .../integration/sqlite_schema_pinning.rs | 4 +- .../src/changeset/core_bridge.rs | 6 ++- .../src/changeset/persistence_capabilities.rs | 28 ++++++------ .../rs-platform-wallet/src/manager/load.rs | 2 +- .../src/masternode/update_service.rs | 20 +++++++-- .../rs-platform-wallet/src/test_support.rs | 43 +++++-------------- .../src/wallet/identity/network/payments.rs | 8 ++-- .../src/wallet/outpoint_locks.rs | 1 - 15 files changed, 100 insertions(+), 67 deletions(-) rename packages/rs-platform-wallet-storage/migrations/{V019__core_locked_outpoints.rs => V021__core_locked_outpoints.rs} (100%) rename packages/rs-platform-wallet-storage/tests/{ => integration}/sqlite_locked_outpoints.rs (99%) diff --git a/packages/rs-platform-wallet-ffi/src/core_wallet_types.rs b/packages/rs-platform-wallet-ffi/src/core_wallet_types.rs index 595baa17f91..89c36fd77f1 100644 --- a/packages/rs-platform-wallet-ffi/src/core_wallet_types.rs +++ b/packages/rs-platform-wallet-ffi/src/core_wallet_types.rs @@ -147,6 +147,10 @@ pub fn build_dashpay_backfill_covered_for_callback( contact_identity_id: entry.contact.to_buffer(), account_index: entry.account_index, covered_from: entry.covered_from, + }) + .collect() +} + /// One change to a wallet's locked outpoints, carried by the persistence /// extension's `on_persist_wallet_changeset_outpoint_locks_fn` slot. /// diff --git a/packages/rs-platform-wallet-ffi/src/manager.rs b/packages/rs-platform-wallet-ffi/src/manager.rs index 2b8790c54e8..4189ce1899b 100644 --- a/packages/rs-platform-wallet-ffi/src/manager.rs +++ b/packages/rs-platform-wallet-ffi/src/manager.rs @@ -11,8 +11,8 @@ use crate::persistence::{ FFIPersister, FreePrivateContactScanStateFn, FreePrivateContactScanStateWalletsFn, FreeTrackedMasternodesFn, FreeWalletLockedOutpointsFn, LoadAssetLockOperationIdFn, LoadAssetLockShieldedRecipientFn, LoadIdentityBalanceBlockTimeFn, - LoadPrivateContactScanStateFn, LoadPrivateContactScanStateWalletsFn, - LoadTrackedMasternodesFn, LoadWalletLockedOutpointsFn, PersistAssetLockOperationIdFn, + LoadPrivateContactScanStateFn, LoadPrivateContactScanStateWalletsFn, LoadTrackedMasternodesFn, + LoadWalletLockedOutpointsFn, PersistAssetLockOperationIdFn, PersistAssetLockShieldedRecipientFn, PersistDpnsNameStatesFn, PersistIdentityBalanceBlockTimeFn, PersistPrivateContactScanStateFn, PersistTrackedMasternodesFn, PersistWalletChangesetChainLockHeightFn, @@ -408,6 +408,7 @@ unsafe fn persistence_extension_callbacks( load_private_contact_scan_state_wallets_free: slot!( on_load_private_contact_scan_state_wallets_free_fn, FreePrivateContactScanStateWalletsFn + ), wallet_changeset_outpoint_locks: slot!( on_persist_wallet_changeset_outpoint_locks_fn, PersistWalletChangesetOutpointLocksFn diff --git a/packages/rs-platform-wallet-ffi/src/persistence.rs b/packages/rs-platform-wallet-ffi/src/persistence.rs index e114992f167..45823c4dfdc 100644 --- a/packages/rs-platform-wallet-ffi/src/persistence.rs +++ b/packages/rs-platform-wallet-ffi/src/persistence.rs @@ -199,12 +199,13 @@ pub const PLATFORM_WALLET_PERSISTENCE_CAPABILITY_ASSET_LOCK_SHIELDED_RECIPIENTS: /// un-ignore stores the sender's removal and the read-position rewind it /// brings in one changeset. pub const PLATFORM_WALLET_PERSISTENCE_CAPABILITY_PRIVATE_CONTACT_REQUEST_SCAN_STATE: u64 = 1 << 15; + /// Locked outpoints (masternode collateral, and outpoints locked by hand) /// are persisted AND restored. Requires the extension trio /// `on_persist_wallet_changeset_outpoint_locks_fn` + /// `on_load_wallet_locked_outpoints_fn` + /// `on_load_wallet_locked_outpoints_free_fn`, and the host declaring the bit. -pub const PLATFORM_WALLET_PERSISTENCE_CAPABILITY_OUTPOINT_LOCKS: u64 = 1 << 13; +pub const PLATFORM_WALLET_PERSISTENCE_CAPABILITY_OUTPOINT_LOCKS: u64 = 1 << 16; /// Version of [`PersistenceCallbacksExtension`]. The extension is deliberately /// separate from [`PersistenceCallbacks`]: existing hosts pass the latter by @@ -462,6 +463,7 @@ pub type FreePrivateContactScanStateWalletsFn = unsafe extern "C" fn( wallet_ids: *const [u8; 32], wallet_ids_count: usize, ); + /// Carries a round's changes to the wallet's locked outpoints (see /// [`OutpointLockFFI`]): store a row per `locked` entry, keyed by /// `(wallet_id, outpoint)`, and delete the row of every other entry. A lock @@ -744,6 +746,7 @@ pub struct PersistenceCallbacksExtension { wallet_ids: *const [u8; 32], wallet_ids_count: usize, ), + >, /// The round's outpoint lock changes (see /// [`PersistWalletChangesetOutpointLocksFn`]). Wired together with the /// load + free pair below: the `OUTPOINT_LOCKS` capability is attested @@ -12286,6 +12289,36 @@ mod tests { PersistenceCallbacksExtension, on_load_private_contact_scan_state_wallets_free_fn ) + std::mem::size_of::>(), + std::mem::offset_of!( + PersistenceCallbacksExtension, + on_persist_wallet_changeset_outpoint_locks_fn + ) + ); + assert_eq!( + std::mem::offset_of!( + PersistenceCallbacksExtension, + on_persist_wallet_changeset_outpoint_locks_fn + ) + std::mem::size_of::>(), + std::mem::offset_of!( + PersistenceCallbacksExtension, + on_load_wallet_locked_outpoints_fn + ) + ); + assert_eq!( + std::mem::offset_of!( + PersistenceCallbacksExtension, + on_load_wallet_locked_outpoints_fn + ) + std::mem::size_of::>(), + std::mem::offset_of!( + PersistenceCallbacksExtension, + on_load_wallet_locked_outpoints_free_fn + ) + ); + assert_eq!( + std::mem::offset_of!( + PersistenceCallbacksExtension, + on_load_wallet_locked_outpoints_free_fn + ) + std::mem::size_of::>(), std::mem::size_of::() ); assert_eq!( @@ -12355,6 +12388,8 @@ mod tests { assert_eq!( PLATFORM_WALLET_PERSISTENCE_CAPABILITY_PRIVATE_CONTACT_REQUEST_SCAN_STATE, PersistenceCapabilities::PRIVATE_CONTACT_REQUEST_SCAN_STATE.bits() + ); + assert_eq!( PLATFORM_WALLET_PERSISTENCE_CAPABILITY_OUTPOINT_LOCKS, PersistenceCapabilities::OUTPOINT_LOCKS.bits() ); @@ -15152,7 +15187,6 @@ mod outpoint_lock_tests { //! and `OUTPOINT_LOCKS` is attested only with the whole trio declared. use super::*; - use dashcore::hashes::Hash as _; use key_wallet::wallet::initialization::WalletAccountCreationOptions; use platform_wallet::changeset::CoreChangeSet; diff --git a/packages/rs-platform-wallet-storage/SCHEMA.md b/packages/rs-platform-wallet-storage/SCHEMA.md index 10d51281946..a1e94fc31ab 100644 --- a/packages/rs-platform-wallet-storage/SCHEMA.md +++ b/packages/rs-platform-wallet-storage/SCHEMA.md @@ -42,7 +42,7 @@ Any `meta_*` row whose parent object does not exist — because it was never cre A future garbage-collection pass is expected to reap orphan metadata — rows with no live parent object older than approximately one week — but no such GC is implemented yet. Callers should not rely on orphan metadata persisting forever, nor assume it will be cleaned up promptly. `meta_global` is intentionally parentless and always survives. -The tables are split into five domain diagrams below. `WALLETS` is the root anchor and appears in each diagram. The diagrams cover 21 of V001's 23 tables; `pending_contact_crypto` and `ignored_senders` appear in the [Tables](#tables) section but are not diagrammed. They show the V001 tables as amended in place by every later migration that changes one of them (the current `core_utxos`, `core_transactions`, `platform_addresses`, and `asset_locks` shapes). Nine tables added by later migrations are not yet diagrammed here: `core_address_pool`, `meta_data_versions`, and `meta_store_generation` (V009, plus its V010–V011 `core_address_pool` columns), `invitations` (V003), `shielded_viewing_keys` (V013), `dpns_name_states` (V005), `tracked_masternodes` (V006), and the `identity_scan_states` / `identity_scan_failed_indices` pair (V017) — see the [Migrations](#migrations) log for what each adds in the meantime. +The tables are split into five domain diagrams below. `WALLETS` is the root anchor and appears in each diagram. The diagrams cover 21 of V001's 23 tables; `pending_contact_crypto` and `ignored_senders` appear in the [Tables](#tables) section but are not diagrammed. They show the V001 tables as amended in place by every later migration that changes one of them (the current `core_utxos`, `core_transactions`, `platform_addresses`, and `asset_locks` shapes). Ten tables added by later migrations are not yet diagrammed here: `core_address_pool`, `meta_data_versions`, and `meta_store_generation` (V009, plus its V010–V011 `core_address_pool` columns), `invitations` (V003), `shielded_viewing_keys` (V013), `dpns_name_states` (V005), `tracked_masternodes` (V006), the `identity_scan_states` / `identity_scan_failed_indices` pair (V017), and `core_locked_outpoints` (V021) — see the [Migrations](#migrations) log for what each adds in the meantime. ## Diagram 1 — Core / L1 (Bitcoin/Dash layer) @@ -851,4 +851,4 @@ table-rebuild migration, as V004 does. | V018 | `V018__identity_hard_delete.rs` | Retires identity tombstoning. Adds `cascade_children_on_identity_delete` (brooms `identity_keys` / `contacts` / `ignored_senders` / `pending_contact_crypto` by the deleted identity id, covering the rows no live FK reaches) plus its access-path indexes `idx_contacts_owner`, `idx_ignored_senders_owner`, and `idx_pending_contact_crypto_owner`; purges every already-tombstoned identity and its dependents; drops `identities.tombstoned`. | | V019 | `V019__asset_lock_operation_id.rs` | Adds the nullable `asset_locks.operation_id BLOB` column (CHECK: NULL or exactly 16 bytes) that correlates a wallet-drain operation with its funding outpoint; the lifecycle blob is untouched. Adds the unique partial index `asset_locks_wallet_operation_id` on `(wallet_id, operation_id) WHERE operation_id IS NOT NULL` and the `asset_locks_operation_id_immutable` BEFORE UPDATE trigger, which aborts any change to a non-NULL `operation_id`. Purely additive; existing rows read back NULL. | | V020 | `V020__asset_lock_shielded_recipient.rs` | Adds the nullable `asset_locks.shielded_recipient BLOB` column (CHECK: NULL or exactly 43 bytes, the raw Orchard address) recording the recipient a shielded asset-lock funding was built to pay, so a resume after restart pays that recipient and refuses another; the lifecycle blob is untouched. Adds the `asset_locks_shielded_recipient_immutable` BEFORE UPDATE trigger, which aborts any change to a non-NULL `shielded_recipient`. Purely additive; existing rows read back NULL and keep accepting the resuming caller's recipient. | -| V019 | `V019__core_locked_outpoints.rs` | Adds `core_locked_outpoints`, one row per `(wallet_id, outpoint)` the wallet keeps out of coin selection: the collateral of a registered masternode, or an outpoint locked by hand. A table of its own rather than a `core_utxos` column, because a lock can exist before its coin and outlives the coin's spend. Deleting the row unlocks the outpoint. Purely additive; an upgraded database starts with no locks. | +| V021 | `V021__core_locked_outpoints.rs` | Adds `core_locked_outpoints`, one row per `(wallet_id, outpoint)` the wallet keeps out of coin selection: the collateral of a registered masternode, or an outpoint locked by hand. A table of its own rather than a `core_utxos` column, because a lock can exist before its coin and outlives the coin's spend. Deleting the row unlocks the outpoint. Purely additive; an upgraded database starts with no locks. | diff --git a/packages/rs-platform-wallet-storage/migrations/V019__core_locked_outpoints.rs b/packages/rs-platform-wallet-storage/migrations/V021__core_locked_outpoints.rs similarity index 100% rename from packages/rs-platform-wallet-storage/migrations/V019__core_locked_outpoints.rs rename to packages/rs-platform-wallet-storage/migrations/V021__core_locked_outpoints.rs diff --git a/packages/rs-platform-wallet-storage/tests/integration/main.rs b/packages/rs-platform-wallet-storage/tests/integration/main.rs index 0f0a6c6f051..801a1c1dd55 100644 --- a/packages/rs-platform-wallet-storage/tests/integration/main.rs +++ b/packages/rs-platform-wallet-storage/tests/integration/main.rs @@ -53,6 +53,7 @@ mod sqlite_identity_scan_state; mod sqlite_legacy_state_migration; mod sqlite_load_reconstruction; mod sqlite_load_wiring; +mod sqlite_locked_outpoints; mod sqlite_migration_execution; mod sqlite_migrations; mod sqlite_money_column_overflow_on_read; diff --git a/packages/rs-platform-wallet-storage/tests/sqlite_locked_outpoints.rs b/packages/rs-platform-wallet-storage/tests/integration/sqlite_locked_outpoints.rs similarity index 99% rename from packages/rs-platform-wallet-storage/tests/sqlite_locked_outpoints.rs rename to packages/rs-platform-wallet-storage/tests/integration/sqlite_locked_outpoints.rs index 2aa818deaec..0f175d5fabf 100644 --- a/packages/rs-platform-wallet-storage/tests/sqlite_locked_outpoints.rs +++ b/packages/rs-platform-wallet-storage/tests/integration/sqlite_locked_outpoints.rs @@ -5,12 +5,11 @@ //! `load_state` and `apply_persisted_core_state`, whether or not the wallet //! already holds the coin, and keep the collateral out of coin selection. -mod common; +use crate::common; use std::collections::BTreeMap; use common::{ensure_wallet_meta, fresh_persister, wid}; -use dashcore::hashes::Hash; use dashcore::{Address, BlockHash, OutPoint, Transaction, TxIn, TxOut}; use key_wallet::transaction_checking::{BlockInfo, TransactionContext, WalletTransactionChecker}; use key_wallet::wallet::initialization::WalletAccountCreationOptions; diff --git a/packages/rs-platform-wallet-storage/tests/integration/sqlite_schema_pinning.rs b/packages/rs-platform-wallet-storage/tests/integration/sqlite_schema_pinning.rs index f1c5755c448..2e3e1b7d669 100644 --- a/packages/rs-platform-wallet-storage/tests/integration/sqlite_schema_pinning.rs +++ b/packages/rs-platform-wallet-storage/tests/integration/sqlite_schema_pinning.rs @@ -15,13 +15,13 @@ use platform_wallet_storage::sqlite::{migrations as mig, schema::versions::Domai /// Golden `(version, name)` fingerprint of the frozen migration set. Bump /// deliberately only when adding/removing/renaming a migration file. const EXPECTED_ID_FINGERPRINT: &str = - "b1e10a6494cc31d24fabe4852477b3b93a2a98a7f310681b132ca8d9adef7311"; + "41980ea9c79fde1adc2046e3c11b141236268180661a217ebf8bbf1de8259059"; /// Golden content-level fingerprint over every migration's rendered SQL. /// Bump it only when ADDING a migration file; a body change on an already /// applied migration is a defect, not a golden to refresh. const EXPECTED_SQL_FINGERPRINT: &str = - "4490b15ba9de27bf5b30a47e462dc3b71c061a47f738a5240cdc89b3abc4ff43"; + "e34c19e04cf267d4d502b644111d7eb384b22b11f956d401ec5d54340bbe8a7b"; /// The migrations merged `v4.2-dev` already ships. Refinery keys /// `refinery_schema_history` by version and validates an applied migration's diff --git a/packages/rs-platform-wallet/src/changeset/core_bridge.rs b/packages/rs-platform-wallet/src/changeset/core_bridge.rs index 58b4bbde007..d559e20efd1 100644 --- a/packages/rs-platform-wallet/src/changeset/core_bridge.rs +++ b/packages/rs-platform-wallet/src/changeset/core_bridge.rs @@ -5718,6 +5718,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; manager .write() @@ -5771,6 +5772,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; info.core_wallet.update_synced_height(1_000); let manager = test_manager(); @@ -5837,6 +5839,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; info.core_wallet.update_synced_height(1_000); let manager = test_manager(); @@ -5918,6 +5921,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; info.core_wallet.update_synced_height(synced_height); let manager = test_manager(); @@ -6148,6 +6152,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + pending_outpoint_locks: Default::default(), }; successor.rewind_barrier.inherit(retired); assert!( @@ -9225,7 +9230,6 @@ mod outpoint_lock_projection_tests { use super::*; use crate::test_support::{masternode_registration, wallet_manager_with_registered_collateral}; - use dashcore::hashes::Hash; use key_wallet::account::account_type::StandardAccountType; use key_wallet::transaction_checking::BlockInfo; diff --git a/packages/rs-platform-wallet/src/changeset/persistence_capabilities.rs b/packages/rs-platform-wallet/src/changeset/persistence_capabilities.rs index 3301ee386f6..881f111ac8c 100644 --- a/packages/rs-platform-wallet/src/changeset/persistence_capabilities.rs +++ b/packages/rs-platform-wallet/src/changeset/persistence_capabilities.rs @@ -105,17 +105,6 @@ impl PersistenceCapabilities { /// declaration only when `on_persist_dashpay_payments_fn` is actually /// wired. pub const DASHPAY_PAYMENTS: Self = Self(1 << 12); - /// Locked outpoints (masternode collateral, and outpoints locked by hand) - /// are persisted AND restored: a stored `CoreChangeSet`'s - /// `outpoint_locks` are durably applied, a lock kept whether or not its - /// coin has a row yet, and a restart hands every stored lock back to the - /// wallet. Without this bit a lock lasts for the session, and a - /// collateral is locked again only when the wallet sees its registration - /// again. On the FFI surface locks travel through the persistence - /// extension's size-negotiated persist slot and come back through its - /// load and free slots; all three must be wired. - pub const OUTPOINT_LOCKS: Self = Self(1 << 13); - /// Asset-lock operation UUIDs survive store/load, including consumed tombstones. /// Missing or malformed persistence data fails load rather than becoming an /// empty result. Required before a wallet drain can treat absence as not sent. @@ -160,13 +149,24 @@ impl PersistenceCapabilities { /// is marked. pub const PRIVATE_CONTACT_REQUEST_SCAN_STATE: Self = Self(1 << 15); + /// Locked outpoints (masternode collateral, and outpoints locked by hand) + /// are persisted AND restored: a stored `CoreChangeSet`'s + /// `outpoint_locks` are durably applied, a lock kept whether or not its + /// coin has a row yet, and a restart hands every stored lock back to the + /// wallet. Without this bit a lock lasts for the session, and a + /// collateral is locked again only when the wallet sees its registration + /// again. On the FFI surface locks travel through the persistence + /// extension's size-negotiated persist slot and come back through its + /// load and free slots; all three must be wired. + pub const OUTPOINT_LOCKS: Self = Self(1 << 16); + /// Index of the highest bit declared above. It lives here, beside the /// constants, so adding a bit and bumping this is one edit in one place /// — and `every_declared_bit_has_a_stable_name` walks up to it, so a new /// bit that never reaches `KNOWN` fails a test instead of gating /// behaviour invisibly. The same test asserts nothing above it is named, /// which is what catches a bit added without bumping this. - const HIGHEST_DECLARED_BIT: u32 = 15; + const HIGHEST_DECLARED_BIT: u32 = 16; /// Capabilities required before exporting and funding an invitation voucher. pub const INVITATION_CREATION: Self = Self( @@ -306,7 +306,7 @@ impl PersistenceCapabilities { /// failure the test exists to catch. Written as a module-level `const _` so /// it is evaluated in every build, test or not. const _: () = assert!( - PersistenceCapabilities::PRIVATE_CONTACT_REQUEST_SCAN_STATE.bits() + PersistenceCapabilities::OUTPOINT_LOCKS.bits() == 1u64 << PersistenceCapabilities::HIGHEST_DECLARED_BIT, "HIGHEST_DECLARED_BIT must name the highest declared capability bit" ); @@ -334,7 +334,6 @@ mod tests { assert_eq!(PersistenceCapabilities::TRACKED_MASTERNODES.bits(), 0x400); assert_eq!(PersistenceCapabilities::CORE_SWEEP_REMOVAL.bits(), 0x800); assert_eq!(PersistenceCapabilities::DASHPAY_PAYMENTS.bits(), 0x1000); - assert_eq!(PersistenceCapabilities::OUTPOINT_LOCKS.bits(), 0x2000); assert_eq!( PersistenceCapabilities::ASSET_LOCK_OPERATION_IDS.bits(), 0x2000 @@ -347,6 +346,7 @@ mod tests { PersistenceCapabilities::PRIVATE_CONTACT_REQUEST_SCAN_STATE.bits(), 0x8000 ); + assert_eq!(PersistenceCapabilities::OUTPOINT_LOCKS.bits(), 0x10000); assert_eq!(PersistenceCapabilities::WALLET_DRAIN.bits(), 0x2285); assert_eq!( PersistenceCapabilities::ASSET_LOCK_RECONCILIATION.bits(), diff --git a/packages/rs-platform-wallet/src/manager/load.rs b/packages/rs-platform-wallet/src/manager/load.rs index 10a99fe7f43..c58cac98528 100644 --- a/packages/rs-platform-wallet/src/manager/load.rs +++ b/packages/rs-platform-wallet/src/manager/load.rs @@ -2229,7 +2229,6 @@ mod masternode_collateral_load_tests { use std::collections::BTreeMap; use std::sync::Arc; - use dashcore::hashes::Hash; use dashcore::{BlockHash, OutPoint, Transaction}; use key_wallet::test_utils::TestWalletContext; use key_wallet::transaction_checking::{BlockInfo, TransactionContext}; @@ -2278,6 +2277,7 @@ mod masternode_collateral_load_tests { identity_manager: IdentityManagerStartState::default(), unused_asset_locks: BTreeMap::new(), unconfirmed_outgoing_txs: Vec::new(), + dashpay_backfill: Default::default(), }, ); Ok(ClientStartState { diff --git a/packages/rs-platform-wallet/src/masternode/update_service.rs b/packages/rs-platform-wallet/src/masternode/update_service.rs index 82c341a4492..03b2e7a3db9 100644 --- a/packages/rs-platform-wallet/src/masternode/update_service.rs +++ b/packages/rs-platform-wallet/src/masternode/update_service.rs @@ -2110,8 +2110,14 @@ mod tests { ); let entry = operator_entry(0x45, false); - let placeholder = prepare_update_service_placeholder(&entry, None, ScriptBuf::new()) - .expect("placeholder"); + let placeholder = prepare_update_service_placeholder( + &entry, + Network::Devnet, + false, + None, + ScriptBuf::new(), + ) + .expect("placeholder"); let prepared = build_sign_update_service(&core, placeholder, Zeroizing::new(OPERATOR_SECRET), &signer) .await @@ -2132,8 +2138,14 @@ mod tests { .expect("wallet present in manager"); assert!(info.core_wallet.lock_outpoint(spare)); } - let placeholder = prepare_update_service_placeholder(&entry, None, ScriptBuf::new()) - .expect("placeholder"); + let placeholder = prepare_update_service_placeholder( + &entry, + Network::Devnet, + false, + None, + ScriptBuf::new(), + ) + .expect("placeholder"); let err = build_sign_update_service(&core, placeholder, Zeroizing::new(OPERATOR_SECRET), &signer) .await diff --git a/packages/rs-platform-wallet/src/test_support.rs b/packages/rs-platform-wallet/src/test_support.rs index b8a96bbb105..278201004f8 100644 --- a/packages/rs-platform-wallet/src/test_support.rs +++ b/packages/rs-platform-wallet/src/test_support.rs @@ -14,6 +14,8 @@ use dashcore::blockdata::script::Builder; use dashcore::crypto::ecdsa::{EcdsaPublicKey as PublicKey, EcdsaSignature}; use dashcore::ecdsa::EcdsaSecretKey; use dashcore::BlockHash; +#[cfg(test)] +use dashcore::PubkeyHash; use dashcore::PublicKey as AddressPublicKey; #[cfg(test)] use dashcore::Txid; @@ -292,39 +294,14 @@ pub(crate) const MASTERNODE_COLLATERAL_DUFFS: u64 = 100_000_000_000; /// only through the collateral it names. #[cfg(test)] pub(crate) fn masternode_registration(collateral: dashcore::OutPoint) -> Transaction { - use dashcore::blockdata::transaction::special_transaction::provider_registration::{ - ProviderMasternodeType, ProviderRegistrationPayload, - }; - use dashcore::blockdata::transaction::special_transaction::TransactionPayload; - use dashcore::bls_sig_utils::BLSPublicKey; - use dashcore::hash_types::InputsHash; - use dashcore::{PubkeyHash, ScriptBuf}; - - Transaction { - version: 3, - lock_time: 0, - input: vec![], - output: vec![], - special_transaction_payload: Some(TransactionPayload::ProviderRegistrationPayloadType( - ProviderRegistrationPayload { - version: ProviderRegistrationPayload::CURRENT_VERSION, - masternode_type: ProviderMasternodeType::Regular, - masternode_mode: 0, - collateral_outpoint: collateral, - service_address: "10.0.0.1:9999".parse().expect("socket address"), - owner_key_hash: PubkeyHash::from_byte_array([0x71; 20]), - operator_public_key: BLSPublicKey::from([0x72; 48]), - voting_key_hash: PubkeyHash::from_byte_array([0x73; 20]), - operator_reward: 0, - script_payout: ScriptBuf::new(), - inputs_hash: InputsHash::all_zeros(), - signature: vec![], - platform_node_id: None, - platform_p2p_port: None, - platform_http_port: None, - }, - )), - } + let mut registration = Transaction::dummy_provider_registration( + collateral, + PubkeyHash::from_byte_array([0x71; 20]), + Vec::new(), + 0, + ); + registration.input.clear(); + registration } /// The outpoint of the coin worth `value` in the wallet's `account_type` diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs b/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs index 90d85ba171f..f0364cdb93f 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs @@ -15896,7 +15896,6 @@ mod tests { async fn should_pay_a_contact_from_the_spare_coin_and_never_the_masternode_collateral() { use crate::test_support::{masternode_registration, MASTERNODE_COLLATERAL_DUFFS}; use crate::wallet::identity::network::contact_requests::SeedCryptoProvider; - use dashcore::hashes::Hash; use key_wallet::transaction_checking::{BlockInfo, TransactionContext}; const DASH: u64 = 100_000_000; @@ -15932,8 +15931,8 @@ mod tests { let seed = Mnemonic::from_phrase(TEST_MNEMONIC) .expect("valid mnemonic") .to_seed(""); - let provider = SeedCryptoProvider::from_seed(seed, Network::Testnet); - let signer = SeedSigner::new(seed, Network::Testnet); + let provider = SeedCryptoProvider::from_seed(*seed, Network::Testnet); + let signer = SeedSigner::new(*seed, Network::Testnet); let broadcaster = Arc::new(RecordingBroadcaster { sent: Mutex::new(Vec::new()), }); @@ -15944,6 +15943,9 @@ mod tests { wallet_id: real.wallet_id, asset_locks: Arc::clone(&real.asset_locks), persister: real.persister.clone(), + sync_fault: Arc::clone(&real.sync_fault), + durable_cursors: Arc::clone(&real.durable_cursors), + generation: Arc::clone(&real.generation), broadcaster: Arc::clone(&broadcaster), sdk_writer: Arc::clone(&real.sdk_writer), dpns_operation_gate: Arc::clone(&real.dpns_operation_gate), diff --git a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs index c5d167ab809..437234a9f04 100644 --- a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs +++ b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs @@ -45,7 +45,6 @@ use std::collections::{BTreeMap, BTreeSet}; use dashcore::blockdata::transaction::special_transaction::TransactionPayload; -use dashcore::hashes::Hash; use dashcore::{OutPoint, Transaction, Txid}; use key_wallet_manager::WalletManager; use tokio::sync::RwLock; From daddbc08ac7af27257e92b27491222612e12775c Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 12 Nov 2026 11:30:59 +0100 Subject: [PATCH 06/26] refactor(platform-wallet): persist collateral locks from wallet events dashpay/rust-dashcore#1391 names the outpoints a transaction check locked on `WalletEvent::BlockProcessed` and `WalletEvent::TransactionDetected`, and emits `BlockProcessed` for a lock alone. The wallet-event adapter now copies them into `CoreChangeSet::outpoint_locks`, so a lock is stored in the changeset of the block or transaction that made it. That replaces the queue on `PlatformWalletInfo`, which held a check's locks behind a mutex until the wallet's next event drained them. The field, its three helpers and the queueing in `check_core_transaction` are gone. The locks made outside a transaction check have no event to ride, so their callers store them: the load (the replay of unconfirmed sends and the pass over known masternodes), a tracked masternode's refresh, and a wallet's registration, which carries them in its registration changeset. A failed store there is logged; the next load makes the lock again. The projection tests now process a real block holding a registration and check the changeset its event projects to. Co-Authored-By: Claude Fable 5.2 --- .../src/changeset/core_bridge.rs | 186 ++++++++++-------- .../src/manager/accessors.rs | 1 - .../rs-platform-wallet/src/manager/load.rs | 70 ++++--- .../src/manager/wallet_lifecycle.rs | 15 +- .../src/masternode/tracked.rs | 7 +- .../rs-platform-wallet/src/test_support.rs | 5 - .../rs-platform-wallet/src/wallet/apply.rs | 1 - .../wallet/asset_lock/sync/reconstruction.rs | 1 - .../src/wallet/asset_lock/sync/recovery.rs | 1 - .../identity/network/contact_requests.rs | 1 - .../src/wallet/outpoint_locks.rs | 182 +++++++++-------- .../src/wallet/platform_wallet.rs | 13 +- .../src/wallet/platform_wallet_traits.rs | 6 - 13 files changed, 257 insertions(+), 232 deletions(-) diff --git a/packages/rs-platform-wallet/src/changeset/core_bridge.rs b/packages/rs-platform-wallet/src/changeset/core_bridge.rs index d559e20efd1..cbdb9cfc7f9 100644 --- a/packages/rs-platform-wallet/src/changeset/core_bridge.rs +++ b/packages/rs-platform-wallet/src/changeset/core_bridge.rs @@ -1631,35 +1631,27 @@ async fn instant_lock_changeset( cs } +/// The outpoints an event reports locked, as the lock delta a persister +/// stores: each one locked. +fn newly_locked(locked_outpoints: &[OutPoint]) -> BTreeMap { + locked_outpoints + .iter() + .map(|outpoint| (*outpoint, true)) + .collect() +} + /// Project an upstream [`WalletEvent`] into a [`CoreChangeSet`] suitable -/// for atomic persistence, carrying every outpoint lock the wallet's -/// transaction checks queued since the last one. +/// for atomic persistence. /// -/// No `WalletEvent` carries a lock: a ProRegTx locks its collateral even -/// when the transaction is otherwise irrelevant and emits nothing. The locks -/// ride whichever event of the wallet comes next, which for a block is at -/// the latest the `SyncHeightAdvanced` watermark that certifies it. +/// The outpoints a transaction check locked (the collateral of a masternode +/// registration, see `wallet::outpoint_locks`) arrive on the +/// `TransactionDetected` or `BlockProcessed` event of the check that locked +/// them, so a lock is stored in the changeset of the block or transaction +/// that made it. A lock alone is enough for upstream to emit +/// `BlockProcessed`. async fn build_core_changeset( wallet_manager: &Arc>>, event: &WalletEvent, -) -> CoreChangeSet { - let mut cs = project_core_event(wallet_manager, event).await; - let queued = { - let guard = wallet_manager.read().await; - guard - .get_wallet_info(&event.wallet_id()) - .map(PlatformWalletInfo::take_queued_outpoint_locks) - .unwrap_or_default() - }; - cs.outpoint_locks - .extend(queued.into_iter().map(|outpoint| (outpoint, true))); - cs -} - -/// The [`CoreChangeSet`] one [`WalletEvent`] describes. -async fn project_core_event( - wallet_manager: &Arc>>, - event: &WalletEvent, ) -> CoreChangeSet { use key_wallet::wallet::managed_wallet_info::wallet_info_interface::WalletInfoInterface; @@ -1668,6 +1660,7 @@ async fn project_core_event( wallet_id, record, addresses_derived, + locked_outpoints, .. } => { // Live mempool matching emits ONE event per matched @@ -1746,6 +1739,7 @@ async fn project_core_event( addresses_marked_used, account_highest_used, utxo_credit_verdicts, + outpoint_locks: newly_locked(locked_outpoints), ..CoreChangeSet::default() } } @@ -1762,9 +1756,13 @@ async fn project_core_event( updated, matured, addresses_derived, + locked_outpoints, .. } => { - let mut cs = CoreChangeSet::default(); + let mut cs = CoreChangeSet { + outpoint_locks: newly_locked(locked_outpoints), + ..CoreChangeSet::default() + }; // Inserted records bring fresh UTXOs and may consume previous ones. for r in inserted { cs.new_utxos.extend(derive_new_utxos(r)); @@ -4498,7 +4496,6 @@ mod contact_watch_only_projection_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), observed_input_conflicts: Default::default(), finalized_spends: Default::default(), } @@ -5718,7 +5715,6 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; manager .write() @@ -5772,7 +5768,6 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; info.core_wallet.update_synced_height(1_000); let manager = test_manager(); @@ -5839,7 +5834,6 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; info.core_wallet.update_synced_height(1_000); let manager = test_manager(); @@ -5921,7 +5915,6 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; info.core_wallet.update_synced_height(synced_height); let manager = test_manager(); @@ -6152,7 +6145,6 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; successor.rewind_barrier.inherit(retired); assert!( @@ -9095,7 +9087,6 @@ mod utxo_credit_verdict_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), observed_input_conflicts: Default::default(), finalized_spends: Default::default(), }; @@ -9194,7 +9185,6 @@ mod utxo_credit_verdict_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), observed_input_conflicts: Default::default(), finalized_spends: Default::default(), }; @@ -9225,67 +9215,105 @@ mod utxo_credit_verdict_tests { #[cfg(test)] mod outpoint_lock_projection_tests { - //! A ProRegTx locks its collateral without emitting any `WalletEvent`, - //! so the lock rides the wallet's next projected changeset. + //! A block whose ProRegTx locks a collateral reaches the persister with + //! that lock, through the `BlockProcessed` event upstream emits for it. - use super::*; - use crate::test_support::{masternode_registration, wallet_manager_with_registered_collateral}; + use std::collections::BTreeSet; + + use dashcore::Block; use key_wallet::account::account_type::StandardAccountType; - use key_wallet::transaction_checking::BlockInfo; + use key_wallet_manager::WalletInterface; + use tokio::sync::broadcast::Receiver; + + use super::*; + use crate::test_support::{ + coin_worth, funded_wallet_manager_with_outputs, masternode_registration, + MASTERNODE_COLLATERAL_DUFFS, + }; const SPARE: u64 = 500_000_000; - fn sync_height(wallet_id: WalletId, height: u32) -> WalletEvent { - WalletEvent::SyncHeightAdvanced { wallet_id, height } + /// A wallet holding a 1,000 DASH coin and a spare one, with no + /// registration processed yet. Returns the manager, the wallet, a + /// subscription to its events and the 1,000 DASH coin. + async fn wallet_holding_a_collateral() -> ( + Arc>>, + WalletId, + Receiver, + OutPoint, + ) { + let (manager, wallet_id, _generation, _signer) = funded_wallet_manager_with_outputs( + StandardAccountType::BIP44Account, + &[MASTERNODE_COLLATERAL_DUFFS, SPARE], + ) + .await; + let collateral = coin_worth( + &manager, + &wallet_id, + StandardAccountType::BIP44Account, + MASTERNODE_COLLATERAL_DUFFS, + ) + .await; + let events = manager.read().await.subscribe_events(); + (manager, wallet_id, events, collateral) + } + + /// Process a block at `height` holding the registration of `collateral` + /// (funded and signed elsewhere, so nothing else of it is the wallet's) + /// and return the lock deltas of the changesets its events project to. + async fn locks_stored_for_registration_block( + manager: &Arc>>, + wallet_id: WalletId, + events: &mut Receiver, + collateral: OutPoint, + height: u32, + ) -> Vec> { + let block = Block::dummy(height, vec![masternode_registration(collateral)]); + manager + .write() + .await + .process_block_for_wallets( + &block, + block.block_hash(), + height, + &BTreeSet::from([wallet_id]), + ) + .await; + let mut stored = Vec::new(); + while let Ok(event) = events.try_recv() { + let cs = build_core_changeset(manager, &event).await; + if !cs.is_empty_no_records() && !cs.outpoint_locks.is_empty() { + stored.push(cs.outpoint_locks); + } + } + stored } #[tokio::test] - async fn should_carry_a_registration_lock_on_the_wallets_next_changeset_once() { - let (manager, wallet_id, _generation, _signer, collateral, _spare) = - wallet_manager_with_registered_collateral(StandardAccountType::BIP44Account, SPARE) + async fn should_store_a_registration_lock_with_the_block_that_made_it() { + let (manager, wallet_id, mut events, collateral) = wallet_holding_a_collateral().await; + + let stored = + locks_stored_for_registration_block(&manager, wallet_id, &mut events, collateral, 2) .await; - let cs = build_core_changeset(&manager, &sync_height(wallet_id, 2)).await; - assert_eq!(cs.outpoint_locks, BTreeMap::from([(collateral, true)])); - let lock_only = CoreChangeSet { - outpoint_locks: cs.outpoint_locks.clone(), - ..CoreChangeSet::default() - }; - assert!( - !lock_only.is_empty_no_records(), - "a changeset carrying only a lock must still reach the persister" + assert_eq!( + stored, + vec![BTreeMap::from([(collateral, true)])], + "the block's changeset carries the lock, and is not dropped as empty" ); - - let next = build_core_changeset(&manager, &sync_height(wallet_id, 3)).await; - assert!(next.outpoint_locks.is_empty(), "a lock is carried once"); } #[tokio::test] - async fn should_not_queue_a_registration_seen_again() { - let (manager, wallet_id, _generation, _signer, collateral, _spare) = - wallet_manager_with_registered_collateral(StandardAccountType::BIP44Account, SPARE) + async fn should_not_store_a_lock_the_wallet_already_holds() { + let (manager, wallet_id, mut events, collateral) = wallet_holding_a_collateral().await; + locks_stored_for_registration_block(&manager, wallet_id, &mut events, collateral, 2).await; + + // A later block carrying the registration again, as a rescan does. + let stored = + locks_stored_for_registration_block(&manager, wallet_id, &mut events, collateral, 3) .await; - let _ = build_core_changeset(&manager, &sync_height(wallet_id, 2)).await; - // The block that confirms it again, or a rescan. - manager - .write() - .await - .check_transaction_in_all_wallets( - &masternode_registration(collateral), - TransactionContext::InChainLockedBlock(BlockInfo::new( - 3, - dashcore::BlockHash::all_zeros(), - 1_700_000_200, - )), - true, - true, - ) - .await; - let cs = build_core_changeset(&manager, &sync_height(wallet_id, 3)).await; - assert!( - cs.outpoint_locks.is_empty(), - "the wallet already holds that lock" - ); + assert!(stored.is_empty(), "the lock is stored once"); } } diff --git a/packages/rs-platform-wallet/src/manager/accessors.rs b/packages/rs-platform-wallet/src/manager/accessors.rs index 786aff3146c..b1389f98fe2 100644 --- a/packages/rs-platform-wallet/src/manager/accessors.rs +++ b/packages/rs-platform-wallet/src/manager/accessors.rs @@ -2033,7 +2033,6 @@ pub(crate) mod txo_inventory_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), observed_input_conflicts: Default::default(), finalized_spends: Default::default(), }; diff --git a/packages/rs-platform-wallet/src/manager/load.rs b/packages/rs-platform-wallet/src/manager/load.rs index c58cac98528..7951bb19480 100644 --- a/packages/rs-platform-wallet/src/manager/load.rs +++ b/packages/rs-platform-wallet/src/manager/load.rs @@ -11,13 +11,14 @@ use crate::changeset::{ use crate::error::PlatformWalletError; use crate::wallet::core::WalletGeneration; use crate::wallet::identity::IdentityManager; -use crate::wallet::outpoint_locks::lock_known_masternode_collaterals; +use crate::wallet::outpoint_locks::{lock_known_masternode_collaterals, persist_outpoint_locks}; use crate::wallet::platform_wallet::{PlatformWalletInfo, WalletId}; use crate::wallet::PlatformWallet; use std::time::Duration; use crate::broadcaster::{BroadcastError, TransactionBroadcaster}; +use dashcore::OutPoint; use dpp::prelude::Identifier; use key_wallet::account::derivation::AccountDerivation; use key_wallet::managed_account::address_pool::{AddressPool, AddressPoolType}; @@ -141,6 +142,9 @@ impl PlatformWalletManager

{ let mut inserted_in_wallets: Vec<(WalletId, Arc)> = Vec::new(); let mut load_error: Option = None; + // The outpoints the replay of unconfirmed sends locked in each wallet, + // stored once the load is past its rollback point. + let mut replay_locks_by_wallet: BTreeMap> = BTreeMap::new(); // Each wallet's start state, and whether it was re-read under the // durable-cursor lock that `held` still holds (see the publication @@ -191,10 +195,10 @@ impl PlatformWalletManager

{ // `update_state` and `update_balance` are both on: the balance // this produces is what `generation.set(..)` mirrors a few lines // below, and the UI reads that. - // A replayed ProRegTx locks its collateral here, and nothing - // persists that lock unless it is queued with the rest: once the - // registration confirms it leaves this list and is never replayed - // again. + // A replayed ProRegTx locks its collateral here, and no wallet + // event carries that lock to the persister: it is stored with the + // other locks this load makes. Once the registration confirms it + // leaves this list and is never replayed again. let mut replay_locks = Vec::new(); if !unconfirmed_outgoing_txs.is_empty() { let mut replayed = 0usize; @@ -298,9 +302,10 @@ impl PlatformWalletManager

{ dpns_name_states: std::collections::BTreeMap::new(), dashpay_backfill, rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; - platform_info.queue_outpoint_locks(replay_locks); + if !replay_locks.is_empty() { + replay_locks_by_wallet.insert(wallet_id, replay_locks); + } // A restored outbound-account marker says the contact's external // account was built from its current xpub, which suppresses the // startup rebuild. It must not vouch for a pool the host kept @@ -733,13 +738,18 @@ impl PlatformWalletManager

{ // Keep the collateral of every masternode the wallets already know out // of coin selection: registrations restored into their histories // without a transaction check, and tracked masternodes whose - // registration has been fetched. New locks are queued for persistence - // like the ones a check makes. See `wallet::outpoint_locks`. - lock_known_masternode_collaterals( + // registration has been fetched. These locks and the ones the replay + // above made are stored here, since no wallet event carries them. See + // `wallet::outpoint_locks`. + let mut new_locks = lock_known_masternode_collaterals( &self.wallet_manager, &self.tracked_masternodes_service().known_collaterals(), ) .await; + for (wallet_id, locked) in replay_locks_by_wallet { + new_locks.entry(wallet_id).or_default().extend(locked); + } + persist_outpoint_locks(&*self.persister, new_locks); // Past the rollback point. A store configured before this load // restores the held wallets' private payments now, with no keys and @@ -2227,7 +2237,7 @@ mod masternode_collateral_load_tests { //! knows, including one whose registration the wallet never processed. use std::collections::BTreeMap; - use std::sync::Arc; + use std::sync::{Arc, Mutex}; use dashcore::{BlockHash, OutPoint, Transaction}; use key_wallet::test_utils::TestWalletContext; @@ -2247,19 +2257,29 @@ mod masternode_collateral_load_tests { const SPARE: u64 = 500_000_000; - /// Hands back one wallet and one tracked masternode. + /// Hands back one wallet and one tracked masternode, and records the + /// outpoint locks it is asked to store. struct TrackedCollateralPersister { wallet: Wallet, managed: ManagedWalletInfo, tracked: TrackedMasternode, + stored_locks: Mutex)>>, } impl PlatformWalletPersistence for TrackedCollateralPersister { fn store( &self, - _wallet_id: WalletId, - _changeset: PlatformWalletChangeSet, + wallet_id: WalletId, + changeset: PlatformWalletChangeSet, ) -> Result<(), PersistenceError> { + if let Some(core) = changeset.core { + if !core.outpoint_locks.is_empty() { + self.stored_locks + .lock() + .expect("stored locks") + .push((wallet_id, core.outpoint_locks)); + } + } Ok(()) } @@ -2298,7 +2318,7 @@ mod masternode_collateral_load_tests { /// whose registration the wallet never processed (funded and signed /// elsewhere). After a load the collateral is locked: it is out of the /// spendable balance and out of every send's coin selection, and the - /// lock is queued for persistence. + /// lock is stored. #[tokio::test] async fn should_lock_a_tracked_masternodes_collateral_on_load() { let mut ctx = TestWalletContext::new_random(); @@ -2340,13 +2360,15 @@ mod masternode_collateral_load_tests { }; let sdk = Arc::new(dash_sdk::SdkBuilder::new_mock().build().expect("mock sdk")); + let persister = Arc::new(TrackedCollateralPersister { + wallet: ctx.wallet, + managed: ctx.managed_wallet, + tracked, + stored_locks: Mutex::new(Vec::new()), + }); let manager = Arc::new(PlatformWalletManager::new( sdk, - Arc::new(TrackedCollateralPersister { - wallet: ctx.wallet, - managed: ctx.managed_wallet, - tracked, - }), + Arc::clone(&persister), Arc::new(NoopTestEventHandler) as _, )); manager @@ -2372,12 +2394,10 @@ mod masternode_collateral_load_tests { SPARE, "coin selection sees only the spare coin" ); - let wm = wallet.wallet_manager().read().await; - let info = wm.get_wallet_info(&wallet_id).expect("wallet"); assert_eq!( - info.take_queued_outpoint_locks(), - std::collections::BTreeSet::from([collateral]), - "the lock is queued for persistence" + *persister.stored_locks.lock().expect("stored locks"), + vec![(wallet_id, BTreeMap::from([(collateral, true)]))], + "the load stores the lock it made" ); } } diff --git a/packages/rs-platform-wallet/src/manager/wallet_lifecycle.rs b/packages/rs-platform-wallet/src/manager/wallet_lifecycle.rs index b66262cd5d8..612b28dc3ca 100644 --- a/packages/rs-platform-wallet/src/manager/wallet_lifecycle.rs +++ b/packages/rs-platform-wallet/src/manager/wallet_lifecycle.rs @@ -13,7 +13,7 @@ use key_wallet::Network; #[cfg(any(feature = "bls", feature = "eddsa"))] use crate::changeset::ProviderKeyExtendedPubKey; use crate::changeset::{ - AccountAddressPoolEntry, AccountRegistrationEntry, ClientWalletStartState, + AccountAddressPoolEntry, AccountRegistrationEntry, ClientWalletStartState, CoreChangeSet, PlatformWalletChangeSet, PlatformWalletPersistence, PrivateContactRequestsPosition, ProviderKeyAccountEntry, WalletMetadataEntry, }; @@ -366,11 +366,11 @@ impl PlatformWalletManager

{ dpns_name_states: std::collections::BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; // A tracked masternode's collateral may reach this wallet as it syncs; - // lock it now so it arrives locked. - platform_info.lock_known_masternode_collaterals( + // lock it now so it arrives locked. The locks are stored with the + // registration below. + let registration_locks = platform_info.lock_known_masternode_collaterals( &self.tracked_masternodes_service().known_collaterals(), ); @@ -650,6 +650,13 @@ impl PlatformWalletManager

{ }) .collect(), provider_key_account_registrations, + core: (!registration_locks.is_empty()).then(|| CoreChangeSet { + outpoint_locks: registration_locks + .into_iter() + .map(|outpoint| (outpoint, true)) + .collect(), + ..CoreChangeSet::default() + }), ..Default::default() }; diff --git a/packages/rs-platform-wallet/src/masternode/tracked.rs b/packages/rs-platform-wallet/src/masternode/tracked.rs index c01758178aa..e6a83cdaa9d 100644 --- a/packages/rs-platform-wallet/src/masternode/tracked.rs +++ b/packages/rs-platform-wallet/src/masternode/tracked.rs @@ -54,7 +54,9 @@ use crate::manager::PlatformWalletManager; use crate::wallet::masternode_withdrawal::{ execute_masternode_withdrawal, MasternodeWithdrawalKey, RawSecretCoreSigner, }; -use crate::wallet::outpoint_locks::{lock_known_masternode_collaterals, named_collateral}; +use crate::wallet::outpoint_locks::{ + lock_known_masternode_collaterals, named_collateral, persist_outpoint_locks, +}; use crate::wallet::platform_wallet::PlatformWalletInfo; // --------------------------------------------------------------------------- @@ -841,11 +843,12 @@ impl TrackedMasternodes { // wallet's coin selection: spending it would end the registration. if let Some(registration) = tracked.snapshot.registration.as_ref() { let collateral = named_collateral(&tracked.pro_tx_hash, registration.collateral); - lock_known_masternode_collaterals( + let locked = lock_known_masternode_collaterals( self.wallet_manager.as_ref(), &BTreeSet::from([collateral]), ) .await; + persist_outpoint_locks(self.persister.as_ref(), locked); } let entry = outcome diff --git a/packages/rs-platform-wallet/src/test_support.rs b/packages/rs-platform-wallet/src/test_support.rs index 278201004f8..0596e7df28e 100644 --- a/packages/rs-platform-wallet/src/test_support.rs +++ b/packages/rs-platform-wallet/src/test_support.rs @@ -275,7 +275,6 @@ pub async fn funded_wallet_manager_with_outputs( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); @@ -504,7 +503,6 @@ pub(crate) async fn funded_wallet_manager_dual_standard( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); let wallet_id = wm.insert_wallet(ctx.wallet, info).expect("insert wallet"); @@ -611,7 +609,6 @@ pub(crate) async fn funded_wallet_manager_with_contact( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); let wallet_id = wm.insert_wallet(ctx.wallet, info).expect("insert wallet"); @@ -683,7 +680,6 @@ pub(crate) async fn funded_coinjoin_wallet_manager() -> ( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); @@ -1024,7 +1020,6 @@ pub(crate) async fn mnemonic_wallet_manager( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); diff --git a/packages/rs-platform-wallet/src/wallet/apply.rs b/packages/rs-platform-wallet/src/wallet/apply.rs index bdf9dca365a..81512cad78a 100644 --- a/packages/rs-platform-wallet/src/wallet/apply.rs +++ b/packages/rs-platform-wallet/src/wallet/apply.rs @@ -498,7 +498,6 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), } } diff --git a/packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs b/packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs index 0ed1ca17415..5e6eadfb761 100644 --- a/packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs +++ b/packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs @@ -668,7 +668,6 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; assert_eq!( funding_account_index(&info, &txid), diff --git a/packages/rs-platform-wallet/src/wallet/asset_lock/sync/recovery.rs b/packages/rs-platform-wallet/src/wallet/asset_lock/sync/recovery.rs index 33a19652ee5..922a47968b7 100644 --- a/packages/rs-platform-wallet/src/wallet/asset_lock/sync/recovery.rs +++ b/packages/rs-platform-wallet/src/wallet/asset_lock/sync/recovery.rs @@ -2584,7 +2584,6 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), }; let out_point = OutPoint::new(tx.txid(), 0); let lock = TrackedAssetLock { diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs b/packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs index 8d806ab4e49..e99725d64cb 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs @@ -5445,7 +5445,6 @@ mod sweep_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), } } diff --git a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs index 437234a9f04..85a7c2d3770 100644 --- a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs +++ b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs @@ -9,17 +9,21 @@ //! collateral it creates, as its own output, from any sighting. This module //! carries that set to the persister and exposes explicit lock and unlock. //! -//! Locks reach the persister through [`CoreChangeSet::outpoint_locks`] on two -//! paths: +//! Locks reach the persister through [`CoreChangeSet::outpoint_locks`] on +//! three paths: //! -//! - A transaction check. `check_core_transaction` queues the outpoints it -//! locked on [`PlatformWalletInfo`], since no `WalletEvent` carries them, and -//! the wallet-event adapter drains the queue into the next changeset it -//! stores for the wallet. The `SyncHeightAdvanced` watermark that certifies -//! a block is a later event for the same wallet, so a lock made in a block -//! is stored with that watermark or before it. +//! - A transaction check. The `BlockProcessed` or `TransactionDetected` event +//! of the check names the outpoints it locked, and the wallet-event adapter +//! stores them in that event's changeset, so a lock is stored with the +//! block or transaction that made it. //! - [`PlatformWallet::lock_outpoint`] and [`PlatformWallet::unlock_outpoint`], //! which store the change themselves. +//! - The pass over the masternodes a wallet already knows (below), whose +//! caller stores what it locked with [`persist_outpoint_locks`]. +//! +//! An event still waiting in the adapter's channel when an outpoint is +//! unlocked by hand is stored after the unlock, so the store keeps that +//! outpoint locked and the next load locks it again. //! //! On load each backend hands every stored lock back through //! [`ManagedWalletInfo::lock_outpoint`]. @@ -49,9 +53,9 @@ use dashcore::{OutPoint, Transaction, Txid}; use key_wallet_manager::WalletManager; use tokio::sync::RwLock; -use crate::changeset::{CoreChangeSet, PlatformWalletChangeSet}; +use crate::changeset::{CoreChangeSet, PlatformWalletChangeSet, PlatformWalletPersistence}; use crate::error::PlatformWalletError; -use crate::wallet::platform_wallet::{PlatformWallet, PlatformWalletInfo}; +use crate::wallet::platform_wallet::{PlatformWallet, PlatformWalletInfo, WalletId}; /// The collateral `tx` registers when it is a ProRegTx: the outpoint its /// payload names, or, when that names a null txid, the ProRegTx's own output @@ -86,8 +90,8 @@ pub(crate) fn named_collateral(pro_tx_hash: &[u8; 32], (txid, vout): ([u8; 32], /// Lock, in every wallet `wallet_manager` holds, the collateral of each /// masternode registration in that wallet's transaction history (see /// [`PlatformWalletInfo::lock_known_masternode_collaterals`] for which) and -/// every outpoint in `tracked`, and queue the new locks for persistence. -/// Returns how many locks were added across all wallets. +/// every outpoint in `tracked`. Returns the locks it added, by wallet, for +/// the caller to store with [`persist_outpoint_locks`]. /// /// A tracked collateral is locked in every wallet, whether or not the wallet /// holds the coin yet: an entry needs no coin behind it, so a collateral @@ -95,22 +99,59 @@ pub(crate) fn named_collateral(pro_tx_hash: &[u8; 32], (txid, vout): ([u8; 32], pub(crate) async fn lock_known_masternode_collaterals( wallet_manager: &RwLock>, tracked: &BTreeSet, -) -> usize { +) -> BTreeMap> { let mut wm = wallet_manager.write().await; let wallet_ids: Vec<_> = wm.list_wallets().into_iter().copied().collect(); - let mut added = 0; - for wallet_id in &wallet_ids { - if let Some(info) = wm.get_wallet_info_mut(wallet_id) { - added += info.lock_known_masternode_collaterals(tracked); + let mut added = BTreeMap::new(); + for wallet_id in wallet_ids { + if let Some(info) = wm.get_wallet_info_mut(&wallet_id) { + let locked = info.lock_known_masternode_collaterals(tracked); + if !locked.is_empty() { + added.insert(wallet_id, locked); + } } } added } +/// Store `locks`, the outpoints locked in each wallet outside a transaction +/// check, so they survive a restart. +/// +/// A store that fails is logged and nothing else: the wallet holds the lock +/// in memory either way, and the next load makes it again from the same +/// registration. +pub(crate) fn persist_outpoint_locks( + persister: &dyn PlatformWalletPersistence, + locks: BTreeMap>, +) { + for (wallet_id, locked) in locks { + if locked.is_empty() { + continue; + } + let changeset = PlatformWalletChangeSet { + core: Some(CoreChangeSet { + outpoint_locks: locked + .into_iter() + .map(|outpoint| (outpoint, true)) + .collect(), + ..CoreChangeSet::default() + }), + ..PlatformWalletChangeSet::default() + }; + if let Err(error) = persister.store(wallet_id, changeset) { + tracing::warn!( + wallet_id = %hex::encode(wallet_id), + %error, + "failed to store masternode collateral locks; they are made again on the next load" + ); + } + } +} + impl PlatformWalletInfo { /// Lock the collateral of the masternode registrations in this wallet's - /// transaction history, and every outpoint in `tracked`. The new locks - /// are queued for persistence. Returns how many were added. + /// transaction history, and every outpoint in `tracked`. Returns the + /// locks it added, for the caller to store. /// /// The same rule as a transaction check: a collateral a registration /// names is locked only when its record is in a block, since an @@ -120,7 +161,7 @@ impl PlatformWalletInfo { pub(crate) fn lock_known_masternode_collaterals( &mut self, tracked: &BTreeSet, - ) -> usize { + ) -> Vec { let mut collaterals: BTreeSet = self .core_wallet .accounts @@ -141,42 +182,7 @@ impl PlatformWalletInfo { if !added.is_empty() { self.publish_core_balance(); } - let count = added.len(); - self.queue_outpoint_locks(added); - count - } - - /// Queue locks a transaction check made for the wallet-event adapter to - /// persist. - pub(crate) fn queue_outpoint_locks(&self, outpoints: impl IntoIterator) { - let mut outpoints = outpoints.into_iter().peekable(); - if outpoints.peek().is_none() { - return; - } - self.pending_outpoint_locks - .lock() - .unwrap_or_else(|poisoned| poisoned.into_inner()) - .extend(outpoints); - } - - /// Take every queued lock, leaving the queue empty. - pub(crate) fn take_queued_outpoint_locks(&self) -> BTreeSet { - std::mem::take( - &mut *self - .pending_outpoint_locks - .lock() - .unwrap_or_else(|poisoned| poisoned.into_inner()), - ) - } - - /// Drop a queued lock for `outpoint`: an explicit lock or unlock stores - /// the outpoint's state itself, and a queued lock stored after it would - /// overwrite an unlock. - fn forget_queued_outpoint_lock(&self, outpoint: &OutPoint) { - self.pending_outpoint_locks - .lock() - .unwrap_or_else(|poisoned| poisoned.into_inner()) - .remove(outpoint); + added } /// Mirror the core balance into the lock-free snapshot the UI reads. @@ -255,8 +261,8 @@ impl PlatformWallet { outpoint: OutPoint, locked: bool, ) -> Result { - // The write lock is held through the store, so a transaction check - // cannot queue a lock for this outpoint between the change and its + // The write lock is held through the store, so no transaction check + // changes this outpoint's lock between the change and its // persistence. let mut wm = self.wallet_manager.write().await; let info = wm @@ -267,7 +273,6 @@ impl PlatformWallet { } else { info.core_wallet.unlock_outpoint(&outpoint) }; - info.forget_queued_outpoint_lock(&outpoint); if changed { info.publish_core_balance(); } @@ -434,15 +439,6 @@ mod tests { Some(&BTreeMap::from([(collateral, false)])), "the unlock is persisted" ); - { - let wm = wallet.wallet_manager().read().await; - let info = wm.get_wallet_info(&wallet.wallet_id()).expect("wallet"); - assert!( - info.take_queued_outpoint_locks().is_empty(), - "the unlock drops the lock the registration queued, so the adapter cannot \ - store it over the unlock" - ); - } assert_eq!( wallet.balance().locked(), 0, @@ -562,11 +558,13 @@ mod tests { assert_eq!( lock_known_masternode_collaterals(&manager, &BTreeSet::new()).await, - 1 + BTreeMap::from([(wallet_id, vec![collateral])]), + "the new lock is handed back for persistence" ); - assert_eq!( - lock_known_masternode_collaterals(&manager, &BTreeSet::new()).await, - 0, + assert!( + lock_known_masternode_collaterals(&manager, &BTreeSet::new()) + .await + .is_empty(), "a lock is added once" ); let wm = manager.read().await; @@ -577,11 +575,6 @@ mod tests { MASTERNODE_COLLATERAL_DUFFS ); assert_eq!(info.core_wallet.balance.spendable(), 5 * DASH); - assert_eq!( - info.take_queued_outpoint_locks(), - BTreeSet::from([collateral]), - "the new lock is queued for persistence" - ); } /// An unconfirmed ProRegTx in the history is not a registration yet: the @@ -592,9 +585,10 @@ mod tests { let (manager, wallet_id, collateral) = wallet_with_restored_registration(TransactionContext::Mempool).await; - assert_eq!( - lock_known_masternode_collaterals(&manager, &BTreeSet::new()).await, - 0 + assert!( + lock_known_masternode_collaterals(&manager, &BTreeSet::new()) + .await + .is_empty() ); { let wm = manager.read().await; @@ -604,28 +598,28 @@ mod tests { info.core_wallet.balance.spendable(), MASTERNODE_COLLATERAL_DUFFS + 5 * DASH ); - assert!(info.take_queued_outpoint_locks().is_empty()); } let mut wm = manager.write().await; - wm.check_transaction_in_all_wallets( - &masternode_registration(collateral), - block(3), - true, - true, - ) - .await; + let checked = wm + .check_transaction_in_all_wallets( + &masternode_registration(collateral), + block(3), + true, + true, + ) + .await; + assert_eq!( + checked.per_wallet_locked_outpoints, + BTreeMap::from([(wallet_id, vec![collateral])]), + "the check reports the lock, which its event carries to the persister" + ); let info = wm.get_wallet_info(&wallet_id).expect("wallet"); assert!(info.core_wallet.is_outpoint_locked(&collateral)); assert_eq!( info.core_wallet.balance.locked(), MASTERNODE_COLLATERAL_DUFFS ); - assert_eq!( - info.take_queued_outpoint_locks(), - BTreeSet::from([collateral]), - "the block's lock is queued for persistence" - ); } /// A tracked masternode's collateral is locked in a wallet that does not @@ -659,7 +653,7 @@ mod tests { assert_eq!( lock_known_masternode_collaterals(&manager, &BTreeSet::from([collateral])).await, - 1 + BTreeMap::from([(wallet_id, vec![collateral])]) ); let mut wm = manager.write().await; wm.check_transaction_in_all_wallets(&incoming, block(3), true, true) diff --git a/packages/rs-platform-wallet/src/wallet/platform_wallet.rs b/packages/rs-platform-wallet/src/wallet/platform_wallet.rs index d1f93859123..5efc258e1c5 100644 --- a/packages/rs-platform-wallet/src/wallet/platform_wallet.rs +++ b/packages/rs-platform-wallet/src/wallet/platform_wallet.rs @@ -1,6 +1,6 @@ //! The main PlatformWallet struct combining core, identity (+DashPay), and platform sub-wallets. -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::BTreeMap; use std::ops::{Deref, DerefMut}; use std::sync::Arc; @@ -367,17 +367,6 @@ pub struct PlatformWalletInfo { /// [`RewindBarrier`](crate::changeset::core_bridge::RewindBarrier). In /// memory only. pub rewind_barrier: crate::changeset::core_bridge::RewindBarrier, - /// Outpoints `core_wallet` locked during a transaction check that are not - /// persisted yet. - /// - /// A ProRegTx the wallet processes locks its collateral, relevant or not - /// (a collateral it names once it is in a block), and no `WalletEvent` - /// carries that lock. The check queues it here - /// and the wallet-event adapter drains the queue into the next changeset - /// it stores for this wallet. Interior mutability because the adapter - /// projects under the manager's read lock; a poisoned mutex keeps its - /// contents. - pub(crate) pending_outpoint_locks: std::sync::Mutex>, } /// A platform wallet that combines core UTXO functionality with identity management. diff --git a/packages/rs-platform-wallet/src/wallet/platform_wallet_traits.rs b/packages/rs-platform-wallet/src/wallet/platform_wallet_traits.rs index 556828af8e7..92b64b01522 100644 --- a/packages/rs-platform-wallet/src/wallet/platform_wallet_traits.rs +++ b/packages/rs-platform-wallet/src/wallet/platform_wallet_traits.rs @@ -45,7 +45,6 @@ impl WalletInfoInterface for PlatformWalletInfo { dpns_name_states: std::collections::BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), } } @@ -63,7 +62,6 @@ impl WalletInfoInterface for PlatformWalletInfo { dpns_name_states: std::collections::BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), - pending_outpoint_locks: Default::default(), } } @@ -381,10 +379,6 @@ impl WalletTransactionChecker for PlatformWalletInfo { .filter(|record| record.context.is_chain_locked()), )); } - // A ProRegTx locks its collateral, relevant or not, and no - // `WalletEvent` carries the lock: queue it for the wallet-event - // adapter to persist with this wallet's next changeset. - self.queue_outpoint_locks(result.locked_outpoints.iter().copied()); result } } From 1cd6cae4617eb16c7e3d93f13ee6999163264e31 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 12 Nov 2026 11:41:19 +0100 Subject: [PATCH 07/26] fix(platform-wallet): lock a tracked collateral only where the wallet holds it A tracked masternode's collateral was locked in every wallet of the manager, so a wallet that never holds the coin listed and persisted a lock that matches nothing, and each load added it again. Upstream (dashpay/rust-dashcore#1391) locks only collateral tied to the wallet; this does the same for tracked masternodes. Each wallet now keeps the collaterals of the tracked masternodes in memory and locks one only when it holds the coin: - when the collateral becomes tracked: on load, when a wallet is registered, and when a refresh learns the registration; - when a transaction check brings the coin in. The lock is added to the check's `locked_outpoints`, so the wallet event of that block or transaction carries it to the persister. This also covers the case upstream leaves to its caller: a collateral that arrives after a registration involving nothing else of the wallet. A refresh no longer runs the pass over the transaction history, and it leaves a collateral that is already tracked alone, so an unlock by hand lasts until the next load instead of until the next refresh. Co-Authored-By: Claude Fable 5.2 --- .../src/changeset/core_bridge.rs | 55 +++- .../src/manager/accessors.rs | 1 + .../rs-platform-wallet/src/manager/load.rs | 1 + .../src/manager/wallet_lifecycle.rs | 7 +- .../src/masternode/tracked.rs | 11 +- .../rs-platform-wallet/src/test_support.rs | 5 + .../rs-platform-wallet/src/wallet/apply.rs | 1 + .../wallet/asset_lock/sync/reconstruction.rs | 1 + .../src/wallet/asset_lock/sync/recovery.rs | 1 + .../identity/network/contact_requests.rs | 1 + .../src/wallet/outpoint_locks.rs | 273 +++++++++++++++--- .../src/wallet/platform_wallet.rs | 10 +- .../src/wallet/platform_wallet_traits.rs | 10 +- 13 files changed, 328 insertions(+), 49 deletions(-) diff --git a/packages/rs-platform-wallet/src/changeset/core_bridge.rs b/packages/rs-platform-wallet/src/changeset/core_bridge.rs index cbdb9cfc7f9..8fff8d7d82f 100644 --- a/packages/rs-platform-wallet/src/changeset/core_bridge.rs +++ b/packages/rs-platform-wallet/src/changeset/core_bridge.rs @@ -4496,6 +4496,7 @@ mod contact_watch_only_projection_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), observed_input_conflicts: Default::default(), finalized_spends: Default::default(), } @@ -5715,6 +5716,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; manager .write() @@ -5768,6 +5770,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; info.core_wallet.update_synced_height(1_000); let manager = test_manager(); @@ -5834,6 +5837,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; info.core_wallet.update_synced_height(1_000); let manager = test_manager(); @@ -5915,6 +5919,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; info.core_wallet.update_synced_height(synced_height); let manager = test_manager(); @@ -6145,6 +6150,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; successor.rewind_barrier.inherit(retired); assert!( @@ -9087,6 +9093,7 @@ mod utxo_credit_verdict_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), observed_input_conflicts: Default::default(), finalized_spends: Default::default(), }; @@ -9185,6 +9192,7 @@ mod utxo_credit_verdict_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), observed_input_conflicts: Default::default(), finalized_spends: Default::default(), }; @@ -9220,7 +9228,7 @@ mod outpoint_lock_projection_tests { use std::collections::BTreeSet; - use dashcore::Block; + use dashcore::{Block, Transaction}; use key_wallet::account::account_type::StandardAccountType; use key_wallet_manager::WalletInterface; use tokio::sync::broadcast::Receiver; @@ -9230,6 +9238,7 @@ mod outpoint_lock_projection_tests { coin_worth, funded_wallet_manager_with_outputs, masternode_registration, MASTERNODE_COLLATERAL_DUFFS, }; + use crate::wallet::outpoint_locks::track_masternode_collaterals; const SPARE: u64 = 500_000_000; @@ -9316,4 +9325,48 @@ mod outpoint_lock_projection_tests { assert!(stored.is_empty(), "the lock is stored once"); } + + /// A tracked masternode's collateral that a block pays the wallet is + /// locked by that block's check, and the block's changeset stores the + /// lock. + #[tokio::test] + async fn should_store_the_lock_of_a_tracked_collateral_with_the_block_that_brings_it() { + let (manager, wallet_id, mut events, held) = wallet_holding_a_collateral().await; + let address = { + let wm = manager.read().await; + let info = wm.get_wallet_info(&wallet_id).expect("wallet"); + info.core_wallet + .first_bip44_managed_account() + .expect("bip44 account") + .utxos + .get(&held) + .expect("funded coin") + .address + .clone() + }; + let incoming = Transaction::dummy(&address, 9..10, &[MASTERNODE_COLLATERAL_DUFFS]); + let collateral = OutPoint::new(incoming.txid(), 0); + assert!( + track_masternode_collaterals(&manager, &BTreeSet::from([collateral])) + .await + .is_empty(), + "the wallet does not hold the coin yet" + ); + + let block = Block::dummy(2, vec![incoming]); + manager + .write() + .await + .process_block_for_wallets(&block, block.block_hash(), 2, &BTreeSet::from([wallet_id])) + .await; + let mut stored = Vec::new(); + while let Ok(event) = events.try_recv() { + let cs = build_core_changeset(&manager, &event).await; + if !cs.outpoint_locks.is_empty() { + stored.push(cs.outpoint_locks); + } + } + + assert_eq!(stored, vec![BTreeMap::from([(collateral, true)])]); + } } diff --git a/packages/rs-platform-wallet/src/manager/accessors.rs b/packages/rs-platform-wallet/src/manager/accessors.rs index b1389f98fe2..bc9bb14b242 100644 --- a/packages/rs-platform-wallet/src/manager/accessors.rs +++ b/packages/rs-platform-wallet/src/manager/accessors.rs @@ -2033,6 +2033,7 @@ pub(crate) mod txo_inventory_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), observed_input_conflicts: Default::default(), finalized_spends: Default::default(), }; diff --git a/packages/rs-platform-wallet/src/manager/load.rs b/packages/rs-platform-wallet/src/manager/load.rs index 7951bb19480..d38a5e5870d 100644 --- a/packages/rs-platform-wallet/src/manager/load.rs +++ b/packages/rs-platform-wallet/src/manager/load.rs @@ -302,6 +302,7 @@ impl PlatformWalletManager

{ dpns_name_states: std::collections::BTreeMap::new(), dashpay_backfill, rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; if !replay_locks.is_empty() { replay_locks_by_wallet.insert(wallet_id, replay_locks); diff --git a/packages/rs-platform-wallet/src/manager/wallet_lifecycle.rs b/packages/rs-platform-wallet/src/manager/wallet_lifecycle.rs index 612b28dc3ca..23396192bd8 100644 --- a/packages/rs-platform-wallet/src/manager/wallet_lifecycle.rs +++ b/packages/rs-platform-wallet/src/manager/wallet_lifecycle.rs @@ -366,10 +366,11 @@ impl PlatformWalletManager

{ dpns_name_states: std::collections::BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; - // A tracked masternode's collateral may reach this wallet as it syncs; - // lock it now so it arrives locked. The locks are stored with the - // registration below. + // A tracked masternode's collateral may reach this wallet as it syncs: + // track it now so it is locked when it arrives. Any lock made here is + // stored with the registration below. let registration_locks = platform_info.lock_known_masternode_collaterals( &self.tracked_masternodes_service().known_collaterals(), ); diff --git a/packages/rs-platform-wallet/src/masternode/tracked.rs b/packages/rs-platform-wallet/src/masternode/tracked.rs index e6a83cdaa9d..6fb514ac82a 100644 --- a/packages/rs-platform-wallet/src/masternode/tracked.rs +++ b/packages/rs-platform-wallet/src/masternode/tracked.rs @@ -55,7 +55,7 @@ use crate::wallet::masternode_withdrawal::{ execute_masternode_withdrawal, MasternodeWithdrawalKey, RawSecretCoreSigner, }; use crate::wallet::outpoint_locks::{ - lock_known_masternode_collaterals, named_collateral, persist_outpoint_locks, + named_collateral, persist_outpoint_locks, track_masternode_collaterals, }; use crate::wallet::platform_wallet::PlatformWalletInfo; @@ -506,7 +506,7 @@ pub struct TrackedMasternodes { persister: std::sync::Arc, network: Network, /// The manager's wallets, so a refresh that learns a registration can - /// lock its collateral in them. + /// have the wallet that holds its collateral lock it. wallet_manager: std::sync::Arc>>, } @@ -839,11 +839,12 @@ impl TrackedMasternodes { ) .await?; - // Once the registration is known, keep its collateral out of every - // wallet's coin selection: spending it would end the registration. + // Once the registration is known, the wallet that holds its + // collateral keeps it out of coin selection, now or when the coin + // arrives: spending it would end the registration. if let Some(registration) = tracked.snapshot.registration.as_ref() { let collateral = named_collateral(&tracked.pro_tx_hash, registration.collateral); - let locked = lock_known_masternode_collaterals( + let locked = track_masternode_collaterals( self.wallet_manager.as_ref(), &BTreeSet::from([collateral]), ) diff --git a/packages/rs-platform-wallet/src/test_support.rs b/packages/rs-platform-wallet/src/test_support.rs index 0596e7df28e..7e8229030b5 100644 --- a/packages/rs-platform-wallet/src/test_support.rs +++ b/packages/rs-platform-wallet/src/test_support.rs @@ -275,6 +275,7 @@ pub async fn funded_wallet_manager_with_outputs( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); @@ -503,6 +504,7 @@ pub(crate) async fn funded_wallet_manager_dual_standard( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); let wallet_id = wm.insert_wallet(ctx.wallet, info).expect("insert wallet"); @@ -609,6 +611,7 @@ pub(crate) async fn funded_wallet_manager_with_contact( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); let wallet_id = wm.insert_wallet(ctx.wallet, info).expect("insert wallet"); @@ -680,6 +683,7 @@ pub(crate) async fn funded_coinjoin_wallet_manager() -> ( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); @@ -1020,6 +1024,7 @@ pub(crate) async fn mnemonic_wallet_manager( dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; let mut wm = WalletManager::::new(Network::Testnet); diff --git a/packages/rs-platform-wallet/src/wallet/apply.rs b/packages/rs-platform-wallet/src/wallet/apply.rs index 81512cad78a..eddbd986603 100644 --- a/packages/rs-platform-wallet/src/wallet/apply.rs +++ b/packages/rs-platform-wallet/src/wallet/apply.rs @@ -498,6 +498,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), } } diff --git a/packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs b/packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs index 5e6eadfb761..41fa3273f68 100644 --- a/packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs +++ b/packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs @@ -668,6 +668,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; assert_eq!( funding_account_index(&info, &txid), diff --git a/packages/rs-platform-wallet/src/wallet/asset_lock/sync/recovery.rs b/packages/rs-platform-wallet/src/wallet/asset_lock/sync/recovery.rs index 922a47968b7..1e512e7373d 100644 --- a/packages/rs-platform-wallet/src/wallet/asset_lock/sync/recovery.rs +++ b/packages/rs-platform-wallet/src/wallet/asset_lock/sync/recovery.rs @@ -2584,6 +2584,7 @@ mod tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), }; let out_point = OutPoint::new(tx.txid(), 0); let lock = TrackedAssetLock { diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs b/packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs index e99725d64cb..b603653b2aa 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs @@ -5445,6 +5445,7 @@ mod sweep_tests { dpns_name_states: BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), } } diff --git a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs index 85a7c2d3770..fa46eb109c1 100644 --- a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs +++ b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs @@ -31,17 +31,27 @@ //! # Masternodes the wallet already knows //! //! A ProRegTx locks its collateral only when a transaction check sees it (in a -//! block, for a collateral it names). -//! Two kinds of registration can escape that: one restored into the -//! transaction history without a check (the mobile restore stages provider -//! transactions directly, and a wallet from before locks were kept has no -//! stored locks), and one the wallet never processed at all, such as a -//! registration funded and signed elsewhere for a collateral this wallet -//! holds. The first is in the wallet's transaction history; the second is -//! known only when the user tracks the masternode and its registration has -//! been fetched. [`lock_known_masternode_collaterals`] locks both kinds in -//! every wallet of a manager, on load, when a wallet is registered, and when -//! a tracked masternode's registration becomes known. +//! block, for a collateral it names). Two kinds of registration escape that: +//! +//! - One restored into the transaction history without a check: the mobile +//! restore stages provider transactions directly, and a wallet from before +//! locks were kept has no stored locks. On load, +//! [`PlatformWalletInfo::lock_registered_collaterals`] locks the collateral +//! of every registration in the wallet's history. +//! - One the wallet never processed, such as a registration funded and signed +//! elsewhere for a collateral this wallet holds. Key-wallet locks such a +//! collateral only when it is handed the registration's block while holding +//! the coin, and a compact-filter client is not handed that block. The +//! registration is known only when the user tracks the masternode and a +//! refresh has fetched it. +//! +//! For the second kind each wallet keeps the collaterals of the tracked +//! masternodes ([`PlatformWalletInfo::tracked_collaterals`]) and locks one +//! only when it holds the coin: when the collateral becomes tracked (on load, +//! when the wallet is registered, when a refresh learns the registration), +//! and when a transaction check brings the coin in. A wallet that never holds +//! the coin never lists it. A collateral already tracked is not locked again +//! by a later refresh, so an unlock by hand lasts until the next load. //! //! [`ManagedWalletInfo::locked_outpoints`]: key_wallet::wallet::ManagedWalletInfo::locked_outpoints //! [`ManagedWalletInfo::lock_outpoint`]: key_wallet::wallet::ManagedWalletInfo::lock_outpoint @@ -50,6 +60,7 @@ use std::collections::{BTreeMap, BTreeSet}; use dashcore::blockdata::transaction::special_transaction::TransactionPayload; use dashcore::{OutPoint, Transaction, Txid}; +use key_wallet::transaction_checking::account_checker::TransactionCheckResult; use key_wallet_manager::WalletManager; use tokio::sync::RwLock; @@ -87,25 +98,44 @@ pub(crate) fn named_collateral(pro_tx_hash: &[u8; 32], (txid, vout): ([u8; 32], OutPoint::new(Txid::from_byte_array(txid), vout) } -/// Lock, in every wallet `wallet_manager` holds, the collateral of each -/// masternode registration in that wallet's transaction history (see -/// [`PlatformWalletInfo::lock_known_masternode_collaterals`] for which) and -/// every outpoint in `tracked`. Returns the locks it added, by wallet, for -/// the caller to store with [`persist_outpoint_locks`]. -/// -/// A tracked collateral is locked in every wallet, whether or not the wallet -/// holds the coin yet: an entry needs no coin behind it, so a collateral -/// that reaches a wallet later (a restore still syncing) arrives locked. +/// On load: lock, in every wallet `wallet_manager` holds, the collateral of +/// each masternode registration in that wallet's transaction history, and +/// start tracking the collaterals in `tracked` (see +/// [`PlatformWalletInfo::track_collaterals`]). Returns the locks it added, +/// by wallet, for the caller to store with [`persist_outpoint_locks`]. pub(crate) async fn lock_known_masternode_collaterals( wallet_manager: &RwLock>, tracked: &BTreeSet, +) -> BTreeMap> { + lock_in_every_wallet(wallet_manager, |info| { + info.lock_known_masternode_collaterals(tracked) + }) + .await +} + +/// Start tracking the collaterals in `tracked` in every wallet +/// `wallet_manager` holds (see [`PlatformWalletInfo::track_collaterals`]). +/// Returns the locks it added, by wallet, for the caller to store with +/// [`persist_outpoint_locks`]. +pub(crate) async fn track_masternode_collaterals( + wallet_manager: &RwLock>, + tracked: &BTreeSet, +) -> BTreeMap> { + lock_in_every_wallet(wallet_manager, |info| info.track_collaterals(tracked)).await +} + +/// Run `lock` on every wallet `wallet_manager` holds and collect the locks +/// it reports adding, by wallet. +async fn lock_in_every_wallet( + wallet_manager: &RwLock>, + lock: impl Fn(&mut PlatformWalletInfo) -> Vec, ) -> BTreeMap> { let mut wm = wallet_manager.write().await; let wallet_ids: Vec<_> = wm.list_wallets().into_iter().copied().collect(); let mut added = BTreeMap::new(); for wallet_id in wallet_ids { if let Some(info) = wm.get_wallet_info_mut(&wallet_id) { - let locked = info.lock_known_masternode_collaterals(tracked); + let locked = lock(info); if !locked.is_empty() { added.insert(wallet_id, locked); } @@ -150,19 +180,27 @@ pub(crate) fn persist_outpoint_locks( impl PlatformWalletInfo { /// Lock the collateral of the masternode registrations in this wallet's - /// transaction history, and every outpoint in `tracked`. Returns the - /// locks it added, for the caller to store. + /// transaction history and start tracking the collaterals in `tracked`. + /// Returns the locks it added, for the caller to store. + pub(crate) fn lock_known_masternode_collaterals( + &mut self, + tracked: &BTreeSet, + ) -> Vec { + let mut added = self.lock_registered_collaterals(); + added.extend(self.track_collaterals(tracked)); + added + } + + /// Lock the collateral of the masternode registrations in this wallet's + /// transaction history. Returns the locks it added. /// /// The same rule as a transaction check: a collateral a registration /// names is locked only when its record is in a block, since an /// unconfirmed ProRegTx is not a registration yet; a collateral it /// creates, as its own output, from any record. The check that confirms /// an unconfirmed registration locks the collateral it names. - pub(crate) fn lock_known_masternode_collaterals( - &mut self, - tracked: &BTreeSet, - ) -> Vec { - let mut collaterals: BTreeSet = self + pub(crate) fn lock_registered_collaterals(&mut self) -> Vec { + let collaterals: BTreeSet = self .core_wallet .accounts .all_accounts() @@ -174,8 +212,73 @@ impl PlatformWalletInfo { (creates_it || record.is_confirmed()).then_some(collateral) }) .collect(); - collaterals.extend(tracked.iter().copied()); - let added: Vec = collaterals + self.lock_and_publish(collaterals) + } + + /// Start tracking `collaterals`, the collateral of tracked masternodes + /// (see [`Self::tracked_collaterals`]), and lock the newly tracked ones + /// this wallet holds. Returns the locks it added. + /// + /// A collateral the wallet does not hold is only remembered: + /// [`Self::lock_arrived_tracked_collaterals`] locks it when its coin + /// arrives. One that was already tracked is left as it is, so a refresh + /// does not lock again what the user unlocked. + pub(crate) fn track_collaterals(&mut self, collaterals: &BTreeSet) -> Vec { + let mut held = Vec::new(); + for outpoint in collaterals { + if self.tracked_collaterals.insert(*outpoint) && self.holds_coin(outpoint) { + held.push(*outpoint); + } + } + self.lock_and_publish(held) + } + + /// Lock each tracked masternode's collateral that `tx` creates and this + /// wallet now holds, and report it in `result` like a lock the check + /// made: the wallet event of the check then names it, and the + /// wallet-event adapter stores it. + /// + /// Call it once the accounts recorded `tx`. Checking the transaction + /// again locks the collateral again after an unlock, as checking a + /// registration again does. + pub(crate) fn lock_arrived_tracked_collaterals( + &mut self, + tx: &Transaction, + result: &mut TransactionCheckResult, + ) { + if self.tracked_collaterals.is_empty() { + return; + } + let txid = tx.txid(); + let arrived: Vec = self + .tracked_collaterals + .iter() + .filter(|outpoint| outpoint.txid == txid && self.holds_coin(outpoint)) + .copied() + .collect(); + for outpoint in arrived { + if self.core_wallet.lock_outpoint(outpoint) { + result.locked_outpoints.push(outpoint); + // The lock set is persisted wallet state. + result.state_modified = true; + } + } + } + + /// Whether a funds account of this wallet holds `outpoint` as an unspent + /// coin. + fn holds_coin(&self, outpoint: &OutPoint) -> bool { + self.core_wallet + .accounts + .all_funding_accounts() + .iter() + .any(|account| account.utxos.contains_key(outpoint)) + } + + /// Lock `outpoints`, mirror the balance to the UI when any lock was + /// added, and return the ones that were not locked before. + fn lock_and_publish(&mut self, outpoints: impl IntoIterator) -> Vec { + let added: Vec = outpoints .into_iter() .filter(|outpoint| self.core_wallet.lock_outpoint(*outpoint)) .collect(); @@ -622,10 +725,15 @@ mod tests { ); } - /// A tracked masternode's collateral is locked in a wallet that does not - /// hold the coin yet, so the coin arrives locked when it syncs. - #[tokio::test] - async fn should_lock_a_tracked_collateral_before_its_coin_arrives() { + /// A wallet holding one 5 DASH coin, and a transaction paying it a 1,000 + /// DASH coin it has not seen yet. Returns the manager, the wallet, that + /// transaction and the coin it creates. + async fn wallet_awaiting_a_collateral() -> ( + Arc>>, + WalletId, + Transaction, + OutPoint, + ) { let (manager, wallet_id, _generation, _signer) = funded_wallet_manager_with_outputs(StandardAccountType::BIP44Account, &[5 * DASH]) .await; @@ -650,14 +758,38 @@ mod tests { ..Transaction::dummy(&address, 7..8, &[1]) }; let collateral = OutPoint::new(incoming.txid(), 0); + (manager, wallet_id, incoming, collateral) + } - assert_eq!( - lock_known_masternode_collaterals(&manager, &BTreeSet::from([collateral])).await, - BTreeMap::from([(wallet_id, vec![collateral])]) + /// A tracked masternode's collateral the wallet does not hold is not + /// locked there and is not listed. It is locked by the transaction check + /// that brings the coin in, which reports the lock for its wallet event. + #[tokio::test] + async fn should_lock_a_tracked_collateral_only_once_the_wallet_holds_its_coin() { + let (manager, wallet_id, incoming, collateral) = wallet_awaiting_a_collateral().await; + + assert!( + track_masternode_collaterals(&manager, &BTreeSet::from([collateral])) + .await + .is_empty(), + "nothing is locked in a wallet that does not hold the coin" ); let mut wm = manager.write().await; - wm.check_transaction_in_all_wallets(&incoming, block(3), true, true) + assert!(wm + .get_wallet_info(&wallet_id) + .expect("wallet") + .core_wallet + .locked_outpoints() + .is_empty()); + + let checked = wm + .check_transaction_in_all_wallets(&incoming, block(3), true, true) .await; + assert_eq!( + checked.per_wallet_locked_outpoints, + BTreeMap::from([(wallet_id, vec![collateral])]), + "the check that brings the coin in reports its lock" + ); let info = wm.get_wallet_info(&wallet_id).expect("wallet"); assert_eq!( info.core_wallet.balance.locked(), @@ -665,4 +797,69 @@ mod tests { ); assert_eq!(info.core_wallet.balance.spendable(), 5 * DASH); } + + /// A coin that is no tracked masternode's collateral arrives spendable. + #[tokio::test] + async fn should_leave_an_arriving_coin_spendable_when_no_tracked_masternode_names_it() { + let (manager, wallet_id, incoming, collateral) = wallet_awaiting_a_collateral().await; + let other = OutPoint::new(collateral.txid, 1); + track_masternode_collaterals(&manager, &BTreeSet::from([other])).await; + + let mut wm = manager.write().await; + let checked = wm + .check_transaction_in_all_wallets(&incoming, block(3), true, true) + .await; + assert!(checked.per_wallet_locked_outpoints.is_empty()); + let info = wm.get_wallet_info(&wallet_id).expect("wallet"); + assert_eq!(info.core_wallet.balance.locked(), 0); + assert_eq!( + info.core_wallet.balance.spendable(), + MASTERNODE_COLLATERAL_DUFFS + 5 * DASH + ); + } + + /// Tracking a masternode whose collateral the wallet already holds locks + /// it at once, in that wallet. A later refresh of the same masternode + /// leaves an unlock by hand alone. + #[tokio::test] + async fn should_lock_a_held_collateral_when_it_becomes_tracked_and_not_again_on_a_refresh() { + let (manager, wallet_id, _generation, _signer) = funded_wallet_manager_with_outputs( + StandardAccountType::BIP44Account, + &[MASTERNODE_COLLATERAL_DUFFS, 5 * DASH], + ) + .await; + let collateral = crate::test_support::coin_worth( + &manager, + &wallet_id, + StandardAccountType::BIP44Account, + MASTERNODE_COLLATERAL_DUFFS, + ) + .await; + let tracked = BTreeSet::from([collateral]); + + assert_eq!( + track_masternode_collaterals(&manager, &tracked).await, + BTreeMap::from([(wallet_id, vec![collateral])]), + "the new lock is handed back for persistence" + ); + { + let mut wm = manager.write().await; + let info = wm.get_wallet_info_mut(&wallet_id).expect("wallet"); + assert_eq!( + info.core_wallet.balance.locked(), + MASTERNODE_COLLATERAL_DUFFS + ); + assert!(info.core_wallet.unlock_outpoint(&collateral)); + } + + assert!( + track_masternode_collaterals(&manager, &tracked) + .await + .is_empty(), + "a refresh does not lock again what was unlocked by hand" + ); + let wm = manager.read().await; + let info = wm.get_wallet_info(&wallet_id).expect("wallet"); + assert!(!info.core_wallet.is_outpoint_locked(&collateral)); + } } diff --git a/packages/rs-platform-wallet/src/wallet/platform_wallet.rs b/packages/rs-platform-wallet/src/wallet/platform_wallet.rs index 5efc258e1c5..8b9f9b70b5e 100644 --- a/packages/rs-platform-wallet/src/wallet/platform_wallet.rs +++ b/packages/rs-platform-wallet/src/wallet/platform_wallet.rs @@ -1,6 +1,6 @@ //! The main PlatformWallet struct combining core, identity (+DashPay), and platform sub-wallets. -use std::collections::BTreeMap; +use std::collections::{BTreeMap, BTreeSet}; use std::ops::{Deref, DerefMut}; use std::sync::Arc; @@ -367,6 +367,14 @@ pub struct PlatformWalletInfo { /// [`RewindBarrier`](crate::changeset::core_bridge::RewindBarrier). In /// memory only. pub rewind_barrier: crate::changeset::core_bridge::RewindBarrier, + /// The collateral of every tracked masternode whose registration is + /// known: outpoints this wallet locks once it holds the coin, whether the + /// coin was here when the collateral became tracked or a transaction + /// check brings it in later. A wallet that never holds the coin never + /// locks it. In memory only, filled again from the tracked registry on + /// load, so the collateral of a masternode the user stops tracking stays + /// here until then; see `wallet::outpoint_locks`. + pub(crate) tracked_collaterals: BTreeSet, } /// A platform wallet that combines core UTXO functionality with identity management. diff --git a/packages/rs-platform-wallet/src/wallet/platform_wallet_traits.rs b/packages/rs-platform-wallet/src/wallet/platform_wallet_traits.rs index 92b64b01522..aa9716a2479 100644 --- a/packages/rs-platform-wallet/src/wallet/platform_wallet_traits.rs +++ b/packages/rs-platform-wallet/src/wallet/platform_wallet_traits.rs @@ -45,6 +45,7 @@ impl WalletInfoInterface for PlatformWalletInfo { dpns_name_states: std::collections::BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), } } @@ -62,6 +63,7 @@ impl WalletInfoInterface for PlatformWalletInfo { dpns_name_states: std::collections::BTreeMap::new(), dashpay_backfill: Default::default(), rewind_barrier: Default::default(), + tracked_collaterals: Default::default(), } } @@ -359,10 +361,16 @@ impl WalletTransactionChecker for PlatformWalletInfo { update_balance: bool, ) -> TransactionCheckResult { // TODO: some logic must here - restore - let result = self + let mut result = self .core_wallet .check_core_transaction(tx, context, wallet, update_state, update_balance) .await; + // A tracked masternode's collateral that this transaction pays the + // wallet arrives locked. The lock is reported like one the check + // itself made, so the wallet event carries it to the persister. + if update_state { + self.lock_arrived_tracked_collaterals(tx, &mut result); + } // A transaction first seen, or confirmed, in a ChainLocked block is // dropped on the spot: keep what it spent, as `apply_chain_lock` // does for the records it promotes. Gate on each record's own From 65fc4507d5abce4107684e0e4794b7e04f07dbc4 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 12 Nov 2026 12:19:30 +0100 Subject: [PATCH 08/26] fix(swift-sdk): finish locked-outpoint persistence and cover it in the storage explorer The Swift side of the collateral lock had never been compiled. This makes it build and pass on the live schema: - `PlatformWalletPersistenceCapabilities.outpointLocks` is bit 16, as in Rust; bit 13 is `assetLockOperationIds` now. - `PersistentLockedOutpoint` stays in the live `DashSchemaV5`, which has not been released, and the V3 entity-set test is restored: V3 is a frozen snapshot. - The persistence handler's lock callbacks follow the pattern of the private contact scan state: the handler methods throw, the write needs an open changeset, and the shims return -1 on failure. A stored key that is not 36 bytes fails the load. A write for a wallet whose row is gone, or with no network known to file the lock under, stores nothing and lets the round go on, since the same round stores a block. - The merge had dropped a closing brace before the lock section. - `ManagedPlatformWallet.setOutpointLock` builds its `OutPointFFI` inside the detached task. - The storage explorer lists, counts and shows `PersistentLockedOutpoint` (the "Verify explorer covers all SwiftData models" check). - `LockedOutpointPersistenceTests` covers store, unlock, load by wallet, purge with the wallet, the network rules and the C shims. Co-Authored-By: Claude Fable 5.2 --- .../Persistence/DashModelContainer.swift | 5 +- .../Models/PersistentLockedOutpoint.swift | 12 + .../ManagedPlatformWallet.swift | 16 +- .../PlatformWalletManager.swift | 2 +- .../PlatformWalletPersistenceHandler.swift | 254 ++++++++---------- .../Views/StorageExplorerView.swift | 4 + .../Views/StorageModelListViews.swift | 33 +++ .../Views/StorageRecordDetailViews.swift | 25 ++ .../DashModelMigrationTests.swift | 7 +- .../LockedOutpointPersistenceTests.swift | 251 +++++++++++++++++ 10 files changed, 455 insertions(+), 154 deletions(-) create mode 100644 packages/swift-sdk/SwiftTests/SwiftDashSDKTests/LockedOutpointPersistenceTests.swift diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift b/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift index 9bb11174238..3b0331122a8 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift @@ -398,8 +398,9 @@ public enum DashSchemaV4: VersionedSchema { } /// Current schema: an asset lock records the optional Orchard recipient of its -/// shielded funding, and the private contact request sync keeps its scan state -/// (each identity's read position and its private contacts' shielded addresses). +/// shielded funding, the private contact request sync keeps its scan state +/// (each identity's read position and its private contacts' shielded addresses), +/// and a wallet keeps the outpoints it holds out of coin selection. public enum DashSchemaV5: VersionedSchema { public static var versionIdentifier: Schema.Version { Schema.Version(5, 0, 0) } public static var models: [any PersistentModel.Type] { DashModelContainer.modelTypes } diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentLockedOutpoint.swift b/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentLockedOutpoint.swift index 768a69c1b92..5f613902b56 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentLockedOutpoint.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentLockedOutpoint.swift @@ -22,4 +22,16 @@ public final class PersistentLockedOutpoint { self.walletId = walletId self.outpoint = outpoint } + + /// Human-readable outpoint (`:`), the txid in display + /// order as `PersistentTxo.outpointHex`. A key that is not 36 bytes + /// shows as its plain hex. + public var outpointHex: String { + guard outpoint.count == 36 else { + return outpoint.map { String(format: "%02x", $0) }.joined() + } + let txidHex = outpoint.prefix(32).reversed().map { String(format: "%02x", $0) }.joined() + let vout = outpoint.suffix(4).reversed().reduce(UInt32(0)) { $0 << 8 | UInt32($1) } + return "\(txidHex):\(vout)" + } } diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift index ae780047a9e..01d9e10681c 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift @@ -142,19 +142,17 @@ public final class ManagedPlatformWallet: @unchecked Sendable { guard outpoint.txid.count == 32 else { throw PlatformWalletError.invalidParameter("txid must be 32 bytes") } - var entry = OutPointFFI() - Swift.withUnsafeMutableBytes(of: &entry.txid) { dst in - outpoint.txid.withUnsafeBytes { src in dst.copyMemory(from: src) } - } - entry.vout = outpoint.vout - let ffiOutpoint = entry return try await Task.detached(priority: .userInitiated) { [self] in try withExtendedLifetime(self) { - var input = ffiOutpoint + var entry = OutPointFFI() + Swift.withUnsafeMutableBytes(of: &entry.txid) { dst in + outpoint.txid.withUnsafeBytes { src in dst.copyMemory(from: src) } + } + entry.vout = outpoint.vout var changed = false let result = locked - ? platform_wallet_lock_outpoint(handle, &input, &changed) - : platform_wallet_unlock_outpoint(handle, &input, &changed) + ? platform_wallet_lock_outpoint(handle, &entry, &changed) + : platform_wallet_unlock_outpoint(handle, &entry, &changed) try result.check() return changed } diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManager.swift b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManager.swift index 9a2c190407b..fa82de9e395 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManager.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManager.swift @@ -131,7 +131,7 @@ public struct PlatformWalletPersistenceCapabilities: Equatable, Sendable { /// persistence extension's outpoint-lock persist / load / free slots. /// Mirrors `PersistenceCapabilities::OUTPOINT_LOCKS`; Rust only honours /// the declaration when all three slots are wired. - public static let outpointLocks: UInt64 = 1 << 13 + public static let outpointLocks: UInt64 = 1 << 16 public let version: UInt32 public let bits: UInt64 diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift index 03d520e9f11..48d3d959fbc 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift @@ -5420,118 +5420,93 @@ public final class PlatformWalletPersistenceHandler: @unchecked Sendable { } ) } + } + // MARK: - Locked outpoints (additive persistence extension) - /// The lock rows of `walletId`. Keyed by network like the balance - /// metadata sidecar, resolved the same way. - private func lockedOutpointsDescriptor(walletId: Data) - -> FetchDescriptor { - let network = self.network ?? walletNetwork(walletId: walletId) ?? .testnet - let networkRaw = network.rawValue - return FetchDescriptor(predicate: #Predicate { - $0.networkRaw == networkRaw && $0.walletId == walletId - }) + /// One entry of a round's outpoint lock changes. + struct OutpointLockChange: Equatable { + /// 36 bytes, as `PersistentTxo.outpoint`. + let outpoint: Data + /// `true`: store the lock. `false`: delete it. + let locked: Bool } - /// Apply a round's outpoint lock changes: insert a row for each lock, - /// delete the row of each unlock. A lock needs no coin behind it, so it - /// never touches `PersistentTxo`. Fired by Rust inside the begin/end - /// bracket, only on rounds that change a lock. Returns `false` to fail - /// the round: a lock dropped here would hand a masternode collateral back - /// to coin selection after the next restart. - func persistWalletChangesetOutpointLocks( - walletId: Data, - locks: UnsafePointer?, - count: UInt - ) -> Bool { - onQueue { + /// Apply a round's outpoint lock changes: a row for each lock, no row + /// for each unlock. A lock needs no coin behind it, so it never touches + /// `PersistentTxo`. Throws to fail the round: a lock dropped here would + /// hand a masternode collateral back to coin selection after the next + /// restart. + /// + /// Gated on the wallet's row like the round's other core callbacks (a + /// stale callback after the wallet's deletion has nothing to write to, + /// and that is not a failure), and stored under this handler's network, + /// else the wallet row's. With neither known the locks are not stored + /// and the round goes on: these changes ride the round that stores a + /// block, and failing it would stop the wallet's sync for good. The + /// wallet keeps such a lock for the session and makes it again from the + /// registration on the next load. + func persistWalletChangesetOutpointLocks(walletId: Data, locks: [OutpointLockChange]) throws { + try onQueue { + guard inChangeset else { + throw PlatformWalletError.walletOperation("Outpoint locks require a changeset") + } + let wallet: PersistentWallet switch roundWalletLookup(walletId: walletId, callback: "wallet_changeset_outpoint_locks") { - case .failed: return false - case .absent: return true - case .found: break + case .failed: + throw PlatformWalletError.walletOperation("Could not read the wallet of the outpoint locks") + case .absent: return + case .found(let row): wallet = row } - guard count > 0, let locks else { return true } - do { - var stored: [Data: PersistentLockedOutpoint] = [:] - for row in try backgroundContext.fetch(lockedOutpointsDescriptor(walletId: walletId)) { - stored[row.outpoint] = row - } - let network = self.network ?? walletNetwork(walletId: walletId) ?? .testnet - for i in 0..( + predicate: #Predicate { $0.networkRaw == networkRaw && $0.walletId == walletId })) { + stored[row.outpoint] = row } + for change in locks { + if !change.locked { + if let row = stored.removeValue(forKey: change.outpoint) { + backgroundContext.delete(row) + } + } else if stored[change.outpoint] == nil { + let row = PersistentLockedOutpoint( + networkRaw: networkRaw, walletId: walletId, outpoint: change.outpoint) + backgroundContext.insert(row) + stored[change.outpoint] = row + } + } + // endChangeset performs the atomic save with the round's core rows. } } - /// Every outpoint stored as locked for `walletId`, as C rows loaned to - /// Rust and released by `loadWalletLockedOutpointsFree`. - func loadWalletLockedOutpoints( - walletId: Data - ) -> (entries: UnsafePointer?, count: Int, errored: Bool) { - onQueue { + /// Every outpoint stored as locked for `walletId`, as 36-byte keys. + /// Throws when the store cannot be read, so the load fails rather than + /// restoring the wallet with its collateral spendable. With no network + /// known the wallet's locks are read under every stored network rather + /// than a guessed one. + func loadWalletLockedOutpoints(walletId: Data) throws -> [Data] { + try onQueue { let rows: [PersistentLockedOutpoint] - do { - rows = try backgroundContext.fetch(lockedOutpointsDescriptor(walletId: walletId)) - } catch { - SDKLogger.event( - "persistence_outpoint_locks_load_failed", - category: .persistence, - severity: .error, - fields: ["wallet_reference": .reference(walletId)], - error: error - ) - return (nil, 0, true) - } - // A key that is not 36 bytes names no outpoint. - let keys = rows.map(\.outpoint).filter { $0.count == 36 } - guard !keys.isEmpty else { return (nil, 0, false) } - let buf = UnsafeMutablePointer.allocate(capacity: keys.count) - for (i, key) in keys.enumerated() { - var entry = OutPointFFI() - copyBytes(key.prefix(32), into: &entry.txid) - var vout: UInt32 = 0 - _ = withUnsafeMutableBytes(of: &vout) { key.suffix(4).copyBytes(to: $0) } - entry.vout = UInt32(littleEndian: vout) - (buf + i).initialize(to: entry) + if let networkRaw = (self.network ?? walletNetwork(walletId: walletId))?.rawValue { + rows = try backgroundContext.fetch(FetchDescriptor( + predicate: #Predicate { $0.networkRaw == networkRaw && $0.walletId == walletId })) + } else { + rows = try backgroundContext.fetch(FetchDescriptor( + predicate: #Predicate { $0.walletId == walletId })) } - return (UnsafePointer(buf), keys.count, false) + return rows.map(\.outpoint) } } - /// Release rows handed out by `loadWalletLockedOutpoints`. - func loadWalletLockedOutpointsFree(entries: UnsafePointer?, count: UInt) { - guard let entries else { return } - let buf = UnsafeMutablePointer(mutating: entries) - buf.deinitialize(count: Int(count)) - buf.deallocate() - } - // MARK: - Identity snapshot structs /// Swift-side snapshot of the Rust `IdentityEntryFFI` with C @@ -12678,64 +12653,69 @@ private func loadIdentityBalanceBlockTimeCallback( } catch { return -1 } } -/// C shim for the extension's `on_persist_wallet_changeset_outpoint_locks_fn`. +/// C shim for `on_persist_wallet_changeset_outpoint_locks_fn`. Copies every +/// entry before calling the handler, so Rust can drop its array on return. /// A non-zero return fails the round. private func persistWalletChangesetOutpointLocksCallback( - context: UnsafeMutableRawPointer?, - walletIdPtr: UnsafePointer?, - locksPtr: UnsafePointer?, - locksCount: UInt + context: UnsafeMutableRawPointer?, walletId: UnsafePointer?, + locks: UnsafePointer?, locksCount: UInt ) -> Int32 { - guard let context = context, - let walletIdPtr = walletIdPtr else { - return 0 + guard let context, let walletId else { return -1 } + guard locksCount == 0 || locks != nil else { return -1 } + let handler = Unmanaged.fromOpaque(context).takeUnretainedValue() + let changes = UnsafeBufferPointer(start: locks, count: Int(locksCount)).map { + PlatformWalletPersistenceHandler.OutpointLockChange( + outpoint: PersistentTxo.makeOutpoint(txid: hashData($0.outpoint.txid), vout: $0.outpoint.vout), + locked: $0.locked) } - let handler = Unmanaged - .fromOpaque(context) - .takeUnretainedValue() - let walletId = Data(bytes: walletIdPtr, count: 32) - return handler.persistWalletChangesetOutpointLocks( - walletId: walletId, - locks: locksPtr, - count: locksCount - ) ? 0 : 1 + do { + try handler.persistWalletChangesetOutpointLocks( + walletId: Data(bytes: walletId, count: 32), locks: changes) + return 0 + } catch { return -1 } } -/// C shim for the extension's `on_load_wallet_locked_outpoints_fn`. +/// C shim for `on_load_wallet_locked_outpoints_fn`. Hands Rust one array of +/// flat rows, released by the free shim below; no lock crosses as a null +/// array with a zero count. A stored key that is not 36 bytes names no +/// outpoint: the load fails, as for an unreadable store, rather than +/// handing back the rest without it. private func loadWalletLockedOutpointsCallback( - context: UnsafeMutableRawPointer?, - walletIdPtr: UnsafePointer?, + context: UnsafeMutableRawPointer?, walletId: UnsafePointer?, outOutpoints: UnsafeMutablePointer?>?, outCount: UnsafeMutablePointer? ) -> Int32 { - guard let context = context, - let walletIdPtr = walletIdPtr, - let outOutpoints = outOutpoints, - let outCount = outCount else { - return 1 - } + guard let context, let walletId, let outOutpoints, let outCount else { return -1 } outOutpoints.pointee = nil outCount.pointee = 0 - let handler = Unmanaged - .fromOpaque(context) - .takeUnretainedValue() - let (entries, count, errored) = handler.loadWalletLockedOutpoints( - walletId: Data(bytes: walletIdPtr, count: 32) - ) - outOutpoints.pointee = entries - outCount.pointee = UInt(count) - return errored ? 1 : 0 + let handler = Unmanaged.fromOpaque(context).takeUnretainedValue() + let keys: [Data] + do { + keys = try handler.loadWalletLockedOutpoints(walletId: Data(bytes: walletId, count: 32)) + } catch { return -1 } + guard keys.allSatisfy({ $0.count == 36 }) else { return -1 } + guard !keys.isEmpty else { return 0 } + let buffer = UnsafeMutablePointer.allocate(capacity: keys.count) + for (index, key) in keys.enumerated() { + var entry = OutPointFFI() + Swift.withUnsafeMutableBytes(of: &entry.txid) { _ = key.prefix(32).copyBytes(to: $0) } + var vout: UInt32 = 0 + Swift.withUnsafeMutableBytes(of: &vout) { _ = key.suffix(4).copyBytes(to: $0) } + entry.vout = UInt32(littleEndian: vout) + (buffer + index).initialize(to: entry) + } + outOutpoints.pointee = UnsafePointer(buffer) + outCount.pointee = UInt(keys.count) + return 0 } -/// C shim for the extension's `on_load_wallet_locked_outpoints_free_fn`. +/// C shim for `on_load_wallet_locked_outpoints_free_fn`: the rows are flat, +/// so releasing the array is all there is to it. private func loadWalletLockedOutpointsFreeCallback( - context: UnsafeMutableRawPointer?, - outpoints: UnsafePointer?, - count: UInt + context: UnsafeMutableRawPointer?, outpoints: UnsafePointer?, count: UInt ) { - guard let context = context else { return } - let handler = Unmanaged - .fromOpaque(context) - .takeUnretainedValue() - handler.loadWalletLockedOutpointsFree(entries: outpoints, count: count) + guard let outpoints else { return } + let buffer = UnsafeMutablePointer(mutating: outpoints) + buffer.deinitialize(count: Int(count)) + buffer.deallocate() } diff --git a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageExplorerView.swift b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageExplorerView.swift index d5565d27f42..9e5fef91fd5 100644 --- a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageExplorerView.swift +++ b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageExplorerView.swift @@ -162,6 +162,9 @@ struct StorageExplorerView: View { modelRow("Asset Locks", icon: "lock.shield", type: PersistentAssetLock.self) { AssetLockStorageListView(network: network) } + modelRow("Locked Outpoints", icon: "lock", type: PersistentLockedOutpoint.self) { + LockedOutpointStorageListView(network: network) + } modelRow("Masternodes", icon: "server.rack", type: PersistentMasternode.self) { MasternodeStorageListView(network: network) } @@ -313,6 +316,7 @@ struct StorageExplorerView: View { directCount(PersistentPlatformAddressesSyncState.self, predicate: #Predicate { $0.networkRaw == raw }) directCount(PersistentWallet.self, predicate: #Predicate { $0.networkRaw == raw }) directCount(PersistentWalletManagerMetadata.self, predicate: #Predicate { $0.networkRaw == raw }) + directCount(PersistentLockedOutpoint.self, predicate: #Predicate { $0.networkRaw == raw }) // Models that derive their network through a relationship — // SwiftData's predicate compiler can't follow optional diff --git a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageModelListViews.swift b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageModelListViews.swift index fb8ff7e41bb..302143e70bc 100644 --- a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageModelListViews.swift +++ b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageModelListViews.swift @@ -1895,6 +1895,39 @@ struct PendingInputStorageListView: View { } } +// MARK: - PersistentLockedOutpoint + +/// The outpoints each wallet keeps out of coin selection: masternode +/// collateral, and outpoints locked by hand. A row needs no TXO behind it. +struct LockedOutpointStorageListView: View { + let network: Network + @Query private var records: [PersistentLockedOutpoint] + + private var filtered: [PersistentLockedOutpoint] { + records.filter { $0.networkRaw == network.rawValue } + .sorted { ($0.walletId.toHexString(), $0.outpointHex) + < ($1.walletId.toHexString(), $1.outpointHex) } + } + + var body: some View { + let visible = filtered + List(visible) { record in + NavigationLink(destination: LockedOutpointStorageDetailView(record: record)) { + VStack(alignment: .leading, spacing: 4) { + Text(record.outpointHex) + .font(.system(.caption, design: .monospaced)) + .lineLimit(1).truncationMode(.middle) + Text("Wallet: \(record.walletId.toHexString())") + .font(.caption).foregroundColor(.secondary) + .lineLimit(1).truncationMode(.middle) + } + } + } + .navigationTitle("Locked Outpoints (\(visible.count))") + .overlay { if visible.isEmpty { ContentUnavailableView("No Records", systemImage: "lock") } } + } +} + // MARK: - PersistentAssetLock /// Storage explorer surface for tracked asset locks. SwiftData-backed diff --git a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageRecordDetailViews.swift b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageRecordDetailViews.swift index 4b2b4e0a471..b7c59ef77e2 100644 --- a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageRecordDetailViews.swift +++ b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageRecordDetailViews.swift @@ -2616,6 +2616,31 @@ struct ShieldedSyncStateStorageDetailView: View { } } +// MARK: - PersistentLockedOutpoint + +struct LockedOutpointStorageDetailView: View { + let record: PersistentLockedOutpoint + + var body: some View { + Form { + Section("Wallet") { + FieldRow(label: "Network", value: Network(rawValue: record.networkRaw)?.displayName ?? "raw \(record.networkRaw)") + FieldRow(label: "Wallet ID", value: hexString(record.walletId)) + } + Section { + FieldRow(label: "Outpoint", value: record.outpointHex) + } header: { + Text("Locked Outpoint") + } footer: { + Text("Kept out of coin selection: a masternode collateral, or an outpoint locked by " + + "hand. The row is the lock, and needs no TXO row behind it.") + } + } + .navigationTitle("Locked Outpoint") + .navigationBarTitleDisplayMode(.inline) + } +} + // MARK: - PersistentAssetLock struct AssetLockStorageDetailView: View { diff --git a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DashModelMigrationTests.swift b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DashModelMigrationTests.swift index 53245bbf079..94ee9120cf3 100644 --- a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DashModelMigrationTests.swift +++ b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DashModelMigrationTests.swift @@ -447,14 +447,11 @@ final class DashModelMigrationTests: XCTestCase { } } - func testV3AddsTrackedMasternodesBalanceMetadataAndLockedOutpointsToTheBaselineEntitySet() { + func testV3AddsTrackedMasternodesAndBalanceMetadataToTheBaselineEntitySet() { XCTAssertEqual( Set(Schema(versionedSchema: DashSchemaV3.self).entities.map(\.name)) .subtracting(Schema(versionedSchema: DashSchemaV1.self).entities.map(\.name)), - [ - "PersistentTrackedMasternode", "PersistentIdentityBalanceMetadata", - "PersistentLockedOutpoint", - ]) + ["PersistentTrackedMasternode", "PersistentIdentityBalanceMetadata"]) } @MainActor diff --git a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/LockedOutpointPersistenceTests.swift b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/LockedOutpointPersistenceTests.swift new file mode 100644 index 00000000000..d640ebbec04 --- /dev/null +++ b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/LockedOutpointPersistenceTests.swift @@ -0,0 +1,251 @@ +import XCTest +import SwiftData +import DashSDKFFI +@testable import SwiftDashSDK + +/// A wallet's locked outpoints (the outpoints kept out of coin selection) +/// round-trip through SwiftData and the persistence extension's C shims. +final class LockedOutpointPersistenceTests: XCTestCase { + private let walletId = Data(repeating: 42, count: 32) + private let otherWalletId = Data(repeating: 43, count: 32) + + private typealias Change = PlatformWalletPersistenceHandler.OutpointLockChange + + /// The 36-byte key of the outpoint `vout` of the txid made of `byte`. + private func outpoint(_ byte: UInt8, _ vout: UInt32) -> Data { + PersistentTxo.makeOutpoint(txid: Data(repeating: byte, count: 32), vout: vout) + } + + private func makeHandler() throws -> (ModelContainer, PlatformWalletPersistenceHandler) { + let container = try DashModelContainer.createInMemory() + let context = ModelContext(container) + context.insert(PersistentWallet(walletId: walletId, network: .testnet)) + context.insert(PersistentWallet(walletId: otherWalletId, network: .testnet)) + try context.save() + return (container, PlatformWalletPersistenceHandler(modelContainer: container, network: .testnet)) + } + + private func round( + _ handler: PlatformWalletPersistenceHandler, + _ locks: [Change], + wallet: Data? = nil, + success: Bool = true + ) throws { + let wallet = wallet ?? walletId + handler.beginChangeset(walletId: wallet) + try handler.persistWalletChangesetOutpointLocks(walletId: wallet, locks: locks) + XCTAssertEqual(handler.endChangeset(walletId: wallet, success: success), success) + } + + private func storedRows(_ container: ModelContainer) throws -> [PersistentLockedOutpoint] { + try ModelContext(container).fetch(FetchDescriptor()) + } + + func testShouldStoreARowForALockWithItsRound() throws { + let (container, handler) = try makeHandler() + try round(handler, [ + .init(outpoint: outpoint(0x11, 0), locked: true), + .init(outpoint: outpoint(0x22, 3), locked: true), + ]) + let rows = try storedRows(container) + XCTAssertEqual(Set(rows.map(\.outpoint)), [outpoint(0x11, 0), outpoint(0x22, 3)]) + XCTAssertEqual(Set(rows.map(\.walletId)), [walletId]) + XCTAssertEqual(Set(rows.map(\.networkRaw)), [Network.testnet.rawValue]) + + // Locking a locked outpoint again keeps its one row. + try round(handler, [.init(outpoint: outpoint(0x11, 0), locked: true)]) + XCTAssertEqual(try storedRows(container).count, 2) + + // A rolled-back round leaves the stored locks as they were. + try round(handler, [.init(outpoint: outpoint(0x33, 1), locked: true)], success: false) + XCTAssertEqual( + try Set(handler.loadWalletLockedOutpoints(walletId: walletId)), + [outpoint(0x11, 0), outpoint(0x22, 3)]) + } + + func testShouldDeleteTheRowOfAnUnlockedOutpoint() throws { + let (container, handler) = try makeHandler() + try round(handler, [ + .init(outpoint: outpoint(0x11, 0), locked: true), + .init(outpoint: outpoint(0x22, 3), locked: true), + ]) + try round(handler, [.init(outpoint: outpoint(0x11, 0), locked: false)]) + XCTAssertEqual(try storedRows(container).map(\.outpoint), [outpoint(0x22, 3)]) + + // Unlocking an outpoint with no stored lock changes nothing. + try round(handler, [.init(outpoint: outpoint(0x44, 9), locked: false)]) + XCTAssertEqual(try storedRows(container).map(\.outpoint), [outpoint(0x22, 3)]) + } + + func testShouldLoadTheLocksOfTheAskedWalletOnly() throws { + let (container, handler) = try makeHandler() + try round(handler, [ + .init(outpoint: outpoint(0x11, 0), locked: true), + .init(outpoint: outpoint(0x22, 3), locked: true), + ]) + try round(handler, [.init(outpoint: outpoint(0x66, 7), locked: true)], wallet: otherWalletId) + + XCTAssertEqual( + try Set(handler.loadWalletLockedOutpoints(walletId: walletId)), + [outpoint(0x11, 0), outpoint(0x22, 3)]) + XCTAssertEqual(try handler.loadWalletLockedOutpoints(walletId: otherWalletId), [outpoint(0x66, 7)]) + XCTAssertTrue(try handler.loadWalletLockedOutpoints(walletId: Data(repeating: 44, count: 32)).isEmpty) + + // The same wallet id under another network holds none of them. + let mainnet = PlatformWalletPersistenceHandler(modelContainer: container, network: .mainnet) + XCTAssertTrue(try mainnet.loadWalletLockedOutpoints(walletId: walletId).isEmpty) + } + + func testShouldPurgeAWalletsLocksWithItsData() throws { + let (container, handler) = try makeHandler() + try round(handler, [ + .init(outpoint: outpoint(0x11, 0), locked: true), + .init(outpoint: outpoint(0x22, 3), locked: true), + ]) + try round(handler, [.init(outpoint: outpoint(0x66, 7), locked: true)], wallet: otherWalletId) + + try handler.deleteWalletData(walletId: walletId) + let rows = try storedRows(container) + XCTAssertEqual(rows.map(\.walletId), [otherWalletId], "only the deleted wallet's locks go") + XCTAssertEqual(rows.map(\.outpoint), [outpoint(0x66, 7)]) + XCTAssertTrue(try handler.loadWalletLockedOutpoints(walletId: walletId).isEmpty) + } + + /// A handler configured with no network stores a lock under its wallet + /// row's network, and reads it back. + func testShouldStoreALockUnderItsWalletsNetworkWhenTheHandlerHasNone() throws { + let container = try DashModelContainer.createInMemory() + let context = ModelContext(container) + context.insert(PersistentWallet(walletId: walletId, network: .mainnet)) + try context.save() + let handler = PlatformWalletPersistenceHandler(modelContainer: container) + try round(handler, [.init(outpoint: outpoint(0x11, 0), locked: true)]) + XCTAssertEqual(try storedRows(container).map(\.networkRaw), [Network.mainnet.rawValue]) + XCTAssertEqual(try handler.loadWalletLockedOutpoints(walletId: walletId), [outpoint(0x11, 0)]) + } + + /// With no network known on the handler or the wallet row there is + /// nowhere to file a lock: nothing is stored and the round still + /// succeeds, since the same round stores a block. + func testShouldStoreNoLockAndKeepTheRoundWhenNoNetworkIsKnown() throws { + let container = try DashModelContainer.createInMemory() + let context = ModelContext(container) + context.insert(PersistentWallet(walletId: walletId)) + try context.save() + let handler = PlatformWalletPersistenceHandler(modelContainer: container) + handler.beginChangeset(walletId: walletId) + XCTAssertNoThrow(try handler.persistWalletChangesetOutpointLocks( + walletId: walletId, locks: [.init(outpoint: outpoint(0x11, 0), locked: true)])) + XCTAssertTrue(handler.endChangeset(walletId: walletId, success: true)) + XCTAssertTrue(try storedRows(container).isEmpty) + } + + /// A round for a wallet whose row is gone (a stale callback after the + /// wallet's deletion) writes nothing and does not fail. + func testShouldWriteNothingForAWalletWithNoRow() throws { + let (container, handler) = try makeHandler() + try round( + handler, [.init(outpoint: outpoint(0x11, 0), locked: true)], + wallet: Data(repeating: 44, count: 32)) + XCTAssertTrue(try storedRows(container).isEmpty) + } + + func testShouldRefuseALockWriteOutsideAChangeset() throws { + let (container, handler) = try makeHandler() + XCTAssertThrowsError(try handler.persistWalletChangesetOutpointLocks( + walletId: walletId, locks: [.init(outpoint: outpoint(0x11, 0), locked: true)])) + XCTAssertTrue(try storedRows(container).isEmpty) + } + + private func ffiLock(_ byte: UInt8, _ vout: UInt32, locked: Bool) -> OutpointLockFFI { + var entry = OutpointLockFFI() + Swift.withUnsafeMutableBytes(of: &entry.outpoint.txid) { + _ = Data(repeating: byte, count: 32).copyBytes(to: $0) + } + entry.outpoint.vout = vout + entry.locked = locked + return entry + } + + /// The C shims Rust calls: a lock persisted through the extension's + /// slot is read back through its load slot, an unlock removes it, and + /// the free slot returns the array. The capability is declared alongside + /// them. + func testShouldDeclareTheCapabilityAndRoundTripThroughTheCallbackShims() throws { + let (_, handler) = try makeHandler() + XCTAssertNotEqual( + handler.makePersistenceCapabilities().bits & PlatformWalletPersistenceCapabilities.outpointLocks, 0) + // Bit 16: bit 15 is the private contact request scan state's. + XCTAssertEqual(PlatformWalletPersistenceCapabilities.outpointLocks, 1 << 16) + XCTAssertEqual( + PlatformWalletPersistenceCapabilities.outpointLocks, + UInt64(PLATFORM_WALLET_PERSISTENCE_CAPABILITY_OUTPOINT_LOCKS)) + let ext = handler.makePersistenceCallbacksExtension() + let persist = try XCTUnwrap(ext.on_persist_wallet_changeset_outpoint_locks_fn) + let load = try XCTUnwrap(ext.on_load_wallet_locked_outpoints_fn) + let free = try XCTUnwrap(ext.on_load_wallet_locked_outpoints_free_fn) + let context = Unmanaged.passUnretained(handler).toOpaque() + + func persistRound(_ locks: [OutpointLockFFI]) -> Int32 { + handler.beginChangeset(walletId: walletId) + let rc = walletId.withUnsafeBytes { id in + persist(context, id.bindMemory(to: UInt8.self).baseAddress, locks, UInt(locks.count)) + } + XCTAssertTrue(handler.endChangeset(walletId: walletId, success: rc == 0)) + return rc + } + func loadKeys(_ wallet: Data) throws -> [Data] { + // Stale values: the shim resets both before it reads the store. + var outpoints: UnsafePointer? = UnsafePointer(bitPattern: 8) + var count: UInt = 7 + let rc = wallet.withUnsafeBytes { id in + load(context, id.bindMemory(to: UInt8.self).baseAddress, &outpoints, &count) + } + XCTAssertEqual(rc, 0) + guard count > 0 else { + XCTAssertNil(outpoints) + return [] + } + let rows = UnsafeBufferPointer(start: try XCTUnwrap(outpoints), count: Int(count)) + let keys = rows.map { PersistentTxo.makeOutpoint(txid: hashData($0.txid), vout: $0.vout) } + free(context, outpoints, count) + return keys + } + + // A vout with four distinct bytes: its byte order survives the trip. + XCTAssertEqual(persistRound([ + ffiLock(0x11, 0, locked: true), + ffiLock(0x22, 0x0102_0304, locked: true), + ]), 0) + XCTAssertEqual(try Set(loadKeys(walletId)), [outpoint(0x11, 0), outpoint(0x22, 0x0102_0304)]) + + XCTAssertEqual(persistRound([ffiLock(0x11, 0, locked: false)]), 0) + XCTAssertEqual(try loadKeys(walletId), [outpoint(0x22, 0x0102_0304)]) + + // A wallet with no lock hands back a null array with a zero count. + XCTAssertTrue(try loadKeys(otherWalletId).isEmpty) + } + + /// A stored key that is not 36 bytes names no outpoint: the load fails + /// instead of handing back the rest without it, which would restore + /// the wallet with that lock missing. + func testShouldFailTheLoadOnAStoredKeyThatNamesNoOutpoint() throws { + let (container, handler) = try makeHandler() + try round(handler, [.init(outpoint: outpoint(0x11, 0), locked: true)]) + let context = ModelContext(container) + context.insert(PersistentLockedOutpoint( + networkRaw: Network.testnet.rawValue, walletId: walletId, outpoint: Data(repeating: 9, count: 35))) + try context.save() + + let load = try XCTUnwrap(handler.makePersistenceCallbacksExtension().on_load_wallet_locked_outpoints_fn) + let shimContext = Unmanaged.passUnretained(handler).toOpaque() + var outpoints: UnsafePointer? + var count: UInt = 0 + let rc = walletId.withUnsafeBytes { wallet in + load(shimContext, wallet.bindMemory(to: UInt8.self).baseAddress, &outpoints, &count) + } + XCTAssertNotEqual(rc, 0) + XCTAssertNil(outpoints) + XCTAssertEqual(count, 0) + } +} From 14f16444622564c8c5a87e1136dd9cd6a8f763fc Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 12 Nov 2026 12:19:30 +0100 Subject: [PATCH 09/26] test(platform-wallet): import the coin helper in the lock tests Co-Authored-By: Claude Fable 5.2 --- packages/rs-platform-wallet/src/wallet/outpoint_locks.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs index fa46eb109c1..63741054b89 100644 --- a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs +++ b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs @@ -419,8 +419,8 @@ mod tests { use super::*; use crate::changeset::{ClientStartState, PersistenceError, PlatformWalletPersistence}; use crate::test_support::{ - funded_wallet_manager_with_outputs, masternode_registration, NoopTestEventHandler, - WalletSigner, MASTERNODE_COLLATERAL_DUFFS, + coin_worth, funded_wallet_manager_with_outputs, masternode_registration, + NoopTestEventHandler, WalletSigner, MASTERNODE_COLLATERAL_DUFFS, }; use crate::wallet::platform_wallet::WalletId; @@ -618,7 +618,7 @@ mod tests { &[MASTERNODE_COLLATERAL_DUFFS, 5 * DASH], ) .await; - let collateral = crate::test_support::coin_worth( + let collateral = coin_worth( &manager, &wallet_id, StandardAccountType::BIP44Account, @@ -828,7 +828,7 @@ mod tests { &[MASTERNODE_COLLATERAL_DUFFS, 5 * DASH], ) .await; - let collateral = crate::test_support::coin_worth( + let collateral = coin_worth( &manager, &wallet_id, StandardAccountType::BIP44Account, From ef24d31765211730484bba72f60eea411111a2c3 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 12 Nov 2026 14:58:46 +0100 Subject: [PATCH 10/26] fix(platform-wallet): close collateral lock gaps found in review - Bind a fetched registration to the requested proTxHash before caching it: DAPI's get-transaction reply is not authenticated, and the cached registration names the collateral the wallets lock. - A wallet handle reads and changes locks only of its own generation, so a handle to a removed wallet does not reach the wallet created again under the same id. - Lock the collateral of known masternodes on each wallet before the load publishes it, instead of in a pass after all wallets are published. - SQLite: lock the collateral of the registrations among the stored records on load, so a database from before locks were stored protects its collateral. - Stop watching a masternode's collateral once it is untracked. - FFI: fail the load when the host reports locks with no buffer. - Swift: a lock write with no network known fails the round, like the scan state, instead of reporting a lock stored that is not. - Keep the persister's classification of a flush failure. Co-Authored-By: Claude Fable 5.2 --- .../rs-platform-wallet-ffi/src/persistence.rs | 52 ++++- .../src/sqlite/rehydrate.rs | 15 +- .../integration/sqlite_locked_outpoints.rs | 102 ++++++++- packages/rs-platform-wallet/src/lib.rs | 1 + .../rs-platform-wallet/src/manager/load.rs | 41 ++-- .../src/masternode/tracked.rs | 69 +++++- .../src/wallet/outpoint_locks.rs | 215 +++++++++++++----- .../PlatformWalletPersistenceHandler.swift | 17 +- .../LockedOutpointPersistenceTests.swift | 10 +- 9 files changed, 406 insertions(+), 116 deletions(-) diff --git a/packages/rs-platform-wallet-ffi/src/persistence.rs b/packages/rs-platform-wallet-ffi/src/persistence.rs index 45823c4dfdc..808b862e5ec 100644 --- a/packages/rs-platform-wallet-ffi/src/persistence.rs +++ b/packages/rs-platform-wallet-ffi/src/persistence.rs @@ -1966,13 +1966,22 @@ impl FFIPersister { format!("on_load_wallet_locked_outpoints_fn returned error code {rc}"), )); } - let mut outpoints = Vec::with_capacity(count); - if !outpoints_ptr.is_null() && count > 0 { + // Fail closed like the wallet list load: a count with no buffer is + // not an empty lock set, and reading it as one would hand every + // locked coin back to coin selection. + if outpoints_ptr.is_null() && count != 0 { + return Err(PersistenceError::backend( + "on_load_wallet_locked_outpoints_fn returned a count with no buffer", + )); + } + let outpoints: Vec = if count == 0 { + Vec::new() + } else { // SAFETY: the host guarantees `count` contiguous entries that stay // valid until the free callback below. let rows = unsafe { slice::from_raw_parts(outpoints_ptr, count) }; - outpoints.extend(rows.iter().map(dashcore::OutPoint::from)); - } + rows.iter().map(dashcore::OutPoint::from).collect() + }; unsafe { free(self.callbacks.context, outpoints_ptr, count) }; for outpoint in outpoints { wallet_info.lock_outpoint(outpoint); @@ -15338,6 +15347,41 @@ mod outpoint_lock_tests { drop(persister); } + unsafe extern "C" fn load_a_count_with_no_buffer( + _ctx: *mut c_void, + _wallet_id: *const u8, + out_outpoints: *mut *const OutPointFFI, + out_count: *mut usize, + ) -> i32 { + *out_outpoints = std::ptr::null(); + *out_count = 1; + 0 + } + + #[test] + fn should_fail_the_load_when_the_host_reports_locks_without_a_buffer() { + let wallet = key_wallet::Wallet::from_seed_bytes( + [0x42; 64], + dashcore::Network::Testnet, + WalletAccountCreationOptions::Default, + ) + .expect("seed wallet"); + let mut info = key_wallet::wallet::ManagedWalletInfo::from_wallet(&wallet, 0); + let persister = FFIPersister::new_with_persistence_capabilities_and_extensions( + PersistenceCallbacks::default(), + PersistenceCapabilities::NONE, + PersistenceExtensionCallbacks { + load_wallet_locked_outpoints: Some(load_a_count_with_no_buffer), + ..trio() + }, + ); + + assert!(persister + .restore_locked_outpoints(&[1u8; 32], &mut info) + .is_err()); + assert!(info.locked_outpoints().is_empty()); + } + #[test] fn should_attest_outpoint_locks_only_with_the_whole_trio_declared() { let declared = PersistenceCapabilities::OUTPOINT_LOCKS; diff --git a/packages/rs-platform-wallet-storage/src/sqlite/rehydrate.rs b/packages/rs-platform-wallet-storage/src/sqlite/rehydrate.rs index ce41869048e..69898662721 100644 --- a/packages/rs-platform-wallet-storage/src/sqlite/rehydrate.rs +++ b/packages/rs-platform-wallet-storage/src/sqlite/rehydrate.rs @@ -15,6 +15,7 @@ use platform_wallet::changeset::provider_key_account::{ rebuild_provider_key_account, ProviderAccountRebuildError, }; use platform_wallet::changeset::{AccountRegistrationEntry, CoreChangeSet}; +use platform_wallet::registered_collaterals; use crate::sqlite::provider_accounts::{insert_platform_node_pool_entry, PlatformNodePoolError}; @@ -316,11 +317,17 @@ pub fn apply_persisted_core_state( } } + // A masternode registration among the stored records locks its + // collateral too. A database from before locks were stored has no lock + // rows, and the history is not replayed below, so nothing later in the + // load could make these locks from it. + for collateral in registered_collaterals(&core.records) { + wallet_info.lock_outpoint(collateral); + } + // INTENTIONAL(tx-record-rehydration-gap): `core` also carries transaction - // records, but they cannot be replayed here — injecting one needs the raw - // `dashcore::Transaction`, and this crate persists only the abstracted - // `TransactionRecord` blob. History re-warms on the next scan and is not a - // balance input. + // records, but they are not replayed into the accounts here. History + // re-warms on the next scan and is not a balance input. // Restore the UTXO set, routing each unspent outpoint to its true owning // funds account via `utxo_accounts` (matched on the same account identity diff --git a/packages/rs-platform-wallet-storage/tests/integration/sqlite_locked_outpoints.rs b/packages/rs-platform-wallet-storage/tests/integration/sqlite_locked_outpoints.rs index 0f175d5fabf..e9c3a9250c9 100644 --- a/packages/rs-platform-wallet-storage/tests/integration/sqlite_locked_outpoints.rs +++ b/packages/rs-platform-wallet-storage/tests/integration/sqlite_locked_outpoints.rs @@ -10,8 +10,12 @@ use crate::common; use std::collections::BTreeMap; use common::{ensure_wallet_meta, fresh_persister, wid}; -use dashcore::{Address, BlockHash, OutPoint, Transaction, TxIn, TxOut}; -use key_wallet::transaction_checking::{BlockInfo, TransactionContext, WalletTransactionChecker}; +use dashcore::{Address, BlockHash, OutPoint, PubkeyHash, Transaction, TxIn, TxOut}; +use key_wallet::account::{AccountType, StandardAccountType}; +use key_wallet::managed_account::transaction_record::{TransactionDirection, TransactionRecord}; +use key_wallet::transaction_checking::{ + BlockInfo, TransactionContext, TransactionType, WalletTransactionChecker, +}; use key_wallet::wallet::initialization::WalletAccountCreationOptions; use key_wallet::wallet::managed_wallet_info::wallet_info_interface::WalletInfoInterface; use key_wallet::wallet::managed_wallet_info::ManagedWalletInfo; @@ -302,6 +306,100 @@ fn should_not_restore_an_unlocked_outpoint() { assert_eq!(spendable_outpoints(&info), vec![collateral]); } +/// The record of a ProRegTx naming `collateral`, as a transaction check +/// stores it. +fn registration_record(collateral: OutPoint, context: TransactionContext) -> TransactionRecord { + TransactionRecord::new( + Transaction::dummy_provider_registration( + collateral, + PubkeyHash::from_byte_array([0x71; 20]), + Vec::new(), + 0, + ), + AccountType::Standard { + index: 0, + standard_account_type: StandardAccountType::BIP44Account, + }, + context, + TransactionType::ProviderRegistration, + TransactionDirection::Internal, + Vec::new(), + Vec::new(), + 0, + ) +} + +/// A database from before locks were stored holds a registration and its +/// collateral but no lock row: the load locks the collateral from the +/// stored registration. +#[test] +fn should_lock_the_collateral_of_a_stored_registration_that_has_no_lock_row() { + let (persister, _tmp, path) = fresh_persister(); + let w = wid(0xC7); + ensure_wallet_meta(&persister, &w); + let wallet = test_wallet(); + let (collateral_address, spare_address) = two_addresses(&wallet); + let collateral_tx = payment(&collateral_address, COLLATERAL, 6); + let spare_tx = payment(&spare_address, SPARE, 7); + let collateral = OutPoint::new(collateral_tx.txid(), 0); + let block = BlockInfo::new(HEIGHT, BlockHash::all_zeros(), 1_700_000_000); + + store_core( + &persister, + w, + CoreChangeSet { + records: vec![registration_record( + collateral, + TransactionContext::InBlock(block), + )], + new_utxos: vec![ + coin(&collateral_tx, &collateral_address), + coin(&spare_tx, &spare_address), + ], + synced_height: Some(HEIGHT), + last_processed_height: Some(HEIGHT), + ..Default::default() + }, + ); + drop(persister); + + let info = reload(&path, &w, &wallet); + assert!(info.is_outpoint_locked(&collateral)); + let balance = WalletInfoInterface::balance(&info); + assert_eq!(balance.locked(), COLLATERAL); + assert_eq!(balance.spendable(), SPARE); +} + +/// An unconfirmed ProRegTx is not a registration yet: the collateral it +/// names stays spendable, as after a transaction check. +#[test] +fn should_not_lock_the_collateral_named_by_a_stored_unconfirmed_registration() { + let (persister, _tmp, path) = fresh_persister(); + let w = wid(0xC8); + ensure_wallet_meta(&persister, &w); + let wallet = test_wallet(); + let (collateral_address, _) = two_addresses(&wallet); + let collateral_tx = payment(&collateral_address, COLLATERAL, 8); + let collateral = OutPoint::new(collateral_tx.txid(), 0); + + store_core( + &persister, + w, + CoreChangeSet { + records: vec![registration_record(collateral, TransactionContext::Mempool)], + new_utxos: vec![coin(&collateral_tx, &collateral_address)], + synced_height: Some(HEIGHT), + last_processed_height: Some(HEIGHT), + ..Default::default() + }, + ); + drop(persister); + + let info = reload(&path, &w, &wallet); + assert!(!info.is_outpoint_locked(&collateral)); + assert_eq!(WalletInfoInterface::balance(&info).spendable(), COLLATERAL); +} + #[test] fn should_keep_the_unlock_when_one_round_locks_then_unlocks() { let mut first = CoreChangeSet { diff --git a/packages/rs-platform-wallet/src/lib.rs b/packages/rs-platform-wallet/src/lib.rs index 13005d9c445..f14b0203150 100644 --- a/packages/rs-platform-wallet/src/lib.rs +++ b/packages/rs-platform-wallet/src/lib.rs @@ -101,6 +101,7 @@ pub use wallet::mnemonic::{ first_receive_address_for_mnemonic, master_key_for_mnemonic, parse_mnemonic_any_language, seed_for_mnemonic, wallet_id_for_mnemonic, }; +pub use wallet::outpoint_locks::registered_collaterals; pub use wallet::platform_wallet::PlatformWalletInfo; #[cfg(feature = "shielded")] pub use wallet::platform_wallet::{PrivateReplyPayment, ShieldedShieldPreflight}; diff --git a/packages/rs-platform-wallet/src/manager/load.rs b/packages/rs-platform-wallet/src/manager/load.rs index d38a5e5870d..4d05a8670e4 100644 --- a/packages/rs-platform-wallet/src/manager/load.rs +++ b/packages/rs-platform-wallet/src/manager/load.rs @@ -11,7 +11,7 @@ use crate::changeset::{ use crate::error::PlatformWalletError; use crate::wallet::core::WalletGeneration; use crate::wallet::identity::IdentityManager; -use crate::wallet::outpoint_locks::{lock_known_masternode_collaterals, persist_outpoint_locks}; +use crate::wallet::outpoint_locks::persist_outpoint_locks; use crate::wallet::platform_wallet::{PlatformWalletInfo, WalletId}; use crate::wallet::PlatformWallet; @@ -142,9 +142,10 @@ impl PlatformWalletManager

{ let mut inserted_in_wallets: Vec<(WalletId, Arc)> = Vec::new(); let mut load_error: Option = None; - // The outpoints the replay of unconfirmed sends locked in each wallet, - // stored once the load is past its rollback point. - let mut replay_locks_by_wallet: BTreeMap> = BTreeMap::new(); + // The outpoints this load locked in each wallet (the replay of + // unconfirmed sends, and the collateral of the masternodes the wallet + // already knows), stored once the load is past its rollback point. + let mut load_locks_by_wallet: BTreeMap> = BTreeMap::new(); // Each wallet's start state, and whether it was re-read under the // durable-cursor lock that `held` still holds (see the publication @@ -304,8 +305,18 @@ impl PlatformWalletManager

{ rewind_barrier: Default::default(), tracked_collaterals: Default::default(), }; - if !replay_locks.is_empty() { - replay_locks_by_wallet.insert(wallet_id, replay_locks); + // Keep the collateral of every masternode the wallet already + // knows out of coin selection before the wallet is published, so + // nothing can spend it in between: registrations restored into + // its history without a transaction check, and tracked + // masternodes whose registration has been fetched. See + // `wallet::outpoint_locks`. + let mut load_locks = replay_locks; + load_locks.extend(platform_info.lock_known_masternode_collaterals( + &self.tracked_masternodes_service().known_collaterals(), + )); + if !load_locks.is_empty() { + load_locks_by_wallet.insert(wallet_id, load_locks); } // A restored outbound-account marker says the contact's external // account was built from its current xpub, which suppresses the @@ -736,21 +747,9 @@ impl PlatformWalletManager

{ return Err(err); } - // Keep the collateral of every masternode the wallets already know out - // of coin selection: registrations restored into their histories - // without a transaction check, and tracked masternodes whose - // registration has been fetched. These locks and the ones the replay - // above made are stored here, since no wallet event carries them. See - // `wallet::outpoint_locks`. - let mut new_locks = lock_known_masternode_collaterals( - &self.wallet_manager, - &self.tracked_masternodes_service().known_collaterals(), - ) - .await; - for (wallet_id, locked) in replay_locks_by_wallet { - new_locks.entry(wallet_id).or_default().extend(locked); - } - persist_outpoint_locks(&*self.persister, new_locks); + // The locks this load made are stored here, since no wallet event + // carries them. See `wallet::outpoint_locks`. + persist_outpoint_locks(&*self.persister, load_locks_by_wallet); // Past the rollback point. A store configured before this load // restores the held wallets' private payments now, with no keys and diff --git a/packages/rs-platform-wallet/src/masternode/tracked.rs b/packages/rs-platform-wallet/src/masternode/tracked.rs index 6fb514ac82a..1cc8869d63b 100644 --- a/packages/rs-platform-wallet/src/masternode/tracked.rs +++ b/packages/rs-platform-wallet/src/masternode/tracked.rs @@ -32,7 +32,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use dash_sdk::platform::Fetch; use dashcore::transaction::special_transaction::provider_registration::ProviderMasternodeType; use dashcore::transaction::TransactionPayload; -use dashcore::{Address as DashAddress, Network, OutPoint}; +use dashcore::{Address as DashAddress, Network, OutPoint, Transaction, Txid}; use dpp::identity::accessors::IdentityGettersV0; use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; use dpp::identity::{Identity, Purpose}; @@ -56,6 +56,7 @@ use crate::wallet::masternode_withdrawal::{ }; use crate::wallet::outpoint_locks::{ named_collateral, persist_outpoint_locks, track_masternode_collaterals, + untrack_masternode_collateral_blocking, }; use crate::wallet::platform_wallet::PlatformWalletInfo; @@ -760,9 +761,20 @@ impl TrackedMasternodes { /// Stop tracking. Returns `Ok(true)` when a row was removed. The /// host owns any attached keys (secure storage) and deletes them - /// itself. Blocking. + /// itself. The wallets stop watching the masternode's collateral; a + /// lock already made stays. Blocking. pub fn untrack_blocking(&self, pro_tx_hash: &[u8; 32]) -> Result { - self.mutate_and_persist(|guard| Ok(guard.remove(pro_tx_hash).is_some())) + let removed = self.mutate_and_persist(|guard| Ok(guard.remove(pro_tx_hash)))?; + let collateral = removed + .as_ref() + .and_then(|tracked| tracked.snapshot.registration.as_ref()) + .map(|registration| named_collateral(pro_tx_hash, registration.collateral)); + if let Some(collateral) = collateral { + if !self.known_collaterals().contains(&collateral) { + untrack_masternode_collateral_blocking(self.wallet_manager.as_ref(), &collateral); + } + } + Ok(removed.is_some()) } /// Rename a tracked masternode (`None` / blank clears the label). @@ -957,10 +969,12 @@ impl TrackedMasternodes { if snapshot.registration.is_none() { match self.sdk.get_transaction(&hex::encode(display)).await { Ok(Some(fetched)) => { - if let Some(details) = - registration_from_transaction(&fetched.transaction, fetched.height) - { - snapshot.registration = Some(details); + match fetched_registration(pro_tx_hash, &fetched.transaction, fetched.height) { + Ok(Some(details)) => snapshot.registration = Some(details), + Ok(None) => {} + Err(e) => { + first_error.get_or_insert(e); + } } } Ok(None) => {} @@ -1136,6 +1150,29 @@ fn p2pkh_address(hash: &[u8; 20], network: Network) -> String { .to_string() } +/// The registration details of the transaction DAPI returned for +/// `pro_tx_hash` (wire order), binding the reply to the request first. +/// +/// DAPI's get-transaction reply is not authenticated, and the details are +/// cached and name the collateral the wallets keep out of coin selection. So +/// the transaction must hash to the requested proTxHash before its payload +/// is trusted: without the check a reply carrying another ProRegTx could +/// lock an unrelated coin of the wallet. +fn fetched_registration( + pro_tx_hash: &[u8; 32], + transaction: &Transaction, + height: u32, +) -> Result, PlatformWalletError> { + let expected = Txid::from_byte_array(*pro_tx_hash); + let actual = transaction.txid(); + if actual != expected { + return Err(PlatformWalletError::InvalidIdentityData(format!( + "DAPI returned transaction {actual} for requested registration transaction {expected}" + ))); + } + Ok(registration_from_transaction(transaction, height)) +} + /// Lift a ProRegTx into [`RegistrationDetails`]; `None` for any other /// transaction. pub fn registration_from_transaction( @@ -1648,6 +1685,24 @@ mod tests { assert_eq!(registration_from_transaction(&plain, 1), None); } + /// A reply that is not the requested transaction is refused, so its + /// registration is never cached and its collateral never locked. + #[test] + fn should_refuse_a_fetched_registration_that_is_not_the_requested_transaction() { + use super::super::record::core_v24_vectors::*; + + let transaction = decode(PRO_REG_TX_ONE_PAYOUT); + let requested = transaction.txid().to_byte_array(); + + assert!(fetched_registration(&requested, &transaction, 15_146) + .expect("the requested transaction") + .is_some()); + assert!(matches!( + fetched_registration(&[0x99; 32], &transaction, 15_146), + Err(PlatformWalletError::InvalidIdentityData(_)) + )); + } + /// A tracked node's ProRegTx is fetched once and cached, so a version-3 /// registration must be read right the first time: its payout from the /// payout list when it names one payout, none when it splits the reward diff --git a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs index 63741054b89..528a3e052af 100644 --- a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs +++ b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs @@ -18,8 +18,9 @@ //! block or transaction that made it. //! - [`PlatformWallet::lock_outpoint`] and [`PlatformWallet::unlock_outpoint`], //! which store the change themselves. -//! - The pass over the masternodes a wallet already knows (below), whose -//! caller stores what it locked with [`persist_outpoint_locks`]. +//! - The pass over the masternodes a wallet already knows (below), run on +//! each wallet before it is published, whose caller stores what it locked +//! with [`persist_outpoint_locks`]. //! //! An event still waiting in the adapter's channel when an outpoint is //! unlocked by hand is stored after the unlock, so the store keeps that @@ -51,15 +52,19 @@ //! when the wallet is registered, when a refresh learns the registration), //! and when a transaction check brings the coin in. A wallet that never holds //! the coin never lists it. A collateral already tracked is not locked again -//! by a later refresh, so an unlock by hand lasts until the next load. +//! by a later refresh, so an unlock by hand lasts until the next load. When +//! the masternode stops being tracked its collateral stops being watched; a +//! lock already made stays. //! //! [`ManagedWalletInfo::locked_outpoints`]: key_wallet::wallet::ManagedWalletInfo::locked_outpoints //! [`ManagedWalletInfo::lock_outpoint`]: key_wallet::wallet::ManagedWalletInfo::lock_outpoint use std::collections::{BTreeMap, BTreeSet}; +use std::sync::Arc; use dashcore::blockdata::transaction::special_transaction::TransactionPayload; use dashcore::{OutPoint, Transaction, Txid}; +use key_wallet::managed_account::transaction_record::TransactionRecord; use key_wallet::transaction_checking::account_checker::TransactionCheckResult; use key_wallet_manager::WalletManager; use tokio::sync::RwLock; @@ -85,6 +90,26 @@ pub(crate) fn registration_collateral(tx: &Transaction) -> Option { ((named.vout as usize) < tx.output.len()).then(|| OutPoint::new(tx.txid(), named.vout)) } +/// The collaterals that the masternode registrations among `records` keep +/// out of coin selection. +/// +/// The same rule as a transaction check: a collateral a registration names +/// counts only when its record is in a block, since an unconfirmed ProRegTx +/// is not a registration yet; a collateral it creates, as its own output, +/// from any record. +pub fn registered_collaterals<'a>( + records: impl IntoIterator, +) -> BTreeSet { + records + .into_iter() + .filter_map(|record| { + let collateral = registration_collateral(&record.transaction)?; + let creates_it = collateral.txid == record.txid; + (creates_it || record.is_confirmed()).then_some(collateral) + }) + .collect() +} + /// The collateral of a registration known by its proTxHash and the outpoint /// its payload names, both as wire-order bytes, the way the tracked registry /// keeps them. A null txid names the ProRegTx's own output, and the ProRegTx's @@ -98,21 +123,6 @@ pub(crate) fn named_collateral(pro_tx_hash: &[u8; 32], (txid, vout): ([u8; 32], OutPoint::new(Txid::from_byte_array(txid), vout) } -/// On load: lock, in every wallet `wallet_manager` holds, the collateral of -/// each masternode registration in that wallet's transaction history, and -/// start tracking the collaterals in `tracked` (see -/// [`PlatformWalletInfo::track_collaterals`]). Returns the locks it added, -/// by wallet, for the caller to store with [`persist_outpoint_locks`]. -pub(crate) async fn lock_known_masternode_collaterals( - wallet_manager: &RwLock>, - tracked: &BTreeSet, -) -> BTreeMap> { - lock_in_every_wallet(wallet_manager, |info| { - info.lock_known_masternode_collaterals(tracked) - }) - .await -} - /// Start tracking the collaterals in `tracked` in every wallet /// `wallet_manager` holds (see [`PlatformWalletInfo::track_collaterals`]). /// Returns the locks it added, by wallet, for the caller to store with @@ -120,22 +130,13 @@ pub(crate) async fn lock_known_masternode_collaterals( pub(crate) async fn track_masternode_collaterals( wallet_manager: &RwLock>, tracked: &BTreeSet, -) -> BTreeMap> { - lock_in_every_wallet(wallet_manager, |info| info.track_collaterals(tracked)).await -} - -/// Run `lock` on every wallet `wallet_manager` holds and collect the locks -/// it reports adding, by wallet. -async fn lock_in_every_wallet( - wallet_manager: &RwLock>, - lock: impl Fn(&mut PlatformWalletInfo) -> Vec, ) -> BTreeMap> { let mut wm = wallet_manager.write().await; let wallet_ids: Vec<_> = wm.list_wallets().into_iter().copied().collect(); let mut added = BTreeMap::new(); for wallet_id in wallet_ids { if let Some(info) = wm.get_wallet_info_mut(&wallet_id) { - let locked = lock(info); + let locked = info.track_collaterals(tracked); if !locked.is_empty() { added.insert(wallet_id, locked); } @@ -144,6 +145,24 @@ async fn lock_in_every_wallet( added } +/// Stop watching `collateral` in every wallet `wallet_manager` holds: its +/// masternode is no longer tracked, so a coin that arrives at it later is an +/// ordinary coin. A lock already made stays until it is unlocked by hand. +/// +/// Blocking: call it from a thread that is not running async tasks. +pub(crate) fn untrack_masternode_collateral_blocking( + wallet_manager: &RwLock>, + collateral: &OutPoint, +) { + let mut wm = wallet_manager.blocking_write(); + let wallet_ids: Vec<_> = wm.list_wallets().into_iter().copied().collect(); + for wallet_id in wallet_ids { + if let Some(info) = wm.get_wallet_info_mut(&wallet_id) { + info.tracked_collaterals.remove(collateral); + } + } +} + /// Store `locks`, the outpoints locked in each wallet outside a transaction /// check, so they survive a restart. /// @@ -192,26 +211,19 @@ impl PlatformWalletInfo { } /// Lock the collateral of the masternode registrations in this wallet's - /// transaction history. Returns the locks it added. + /// transaction history (see [`registered_collaterals`] for which). + /// Returns the locks it added. /// - /// The same rule as a transaction check: a collateral a registration - /// names is locked only when its record is in a block, since an - /// unconfirmed ProRegTx is not a registration yet; a collateral it - /// creates, as its own output, from any record. The check that confirms - /// an unconfirmed registration locks the collateral it names. + /// The check that confirms an unconfirmed registration locks the + /// collateral it names. pub(crate) fn lock_registered_collaterals(&mut self) -> Vec { - let collaterals: BTreeSet = self - .core_wallet - .accounts - .all_accounts() - .iter() - .flat_map(|account| account.transactions().values()) - .filter_map(|record| { - let collateral = registration_collateral(&record.transaction)?; - let creates_it = collateral.txid == record.txid; - (creates_it || record.is_confirmed()).then_some(collateral) - }) - .collect(); + let collaterals = registered_collaterals( + self.core_wallet + .accounts + .all_accounts() + .iter() + .flat_map(|account| account.transactions().values()), + ); self.lock_and_publish(collaterals) } @@ -311,8 +323,11 @@ impl PlatformWallet { /// the coin arrives locked. pub async fn locked_outpoints(&self) -> Result, PlatformWalletError> { let wm = self.wallet_manager.read().await; + // A wallet removed and created again under the same id is another + // wallet: this handle neither reads nor changes its locks. let info = wm .get_wallet_info(&self.wallet_id()) + .filter(|info| Arc::ptr_eq(&info.generation, &self.generation)) .ok_or_else(|| PlatformWalletError::WalletNotFound(hex::encode(self.wallet_id())))?; Ok(info .core_wallet @@ -335,7 +350,8 @@ impl PlatformWallet { /// # Errors /// /// [`PlatformWalletError::WalletNotFound`] when the wallet is no longer - /// registered, or the store's error when persisting fails. After a store + /// registered (a wallet created again under the same id is another + /// wallet), or the store's error when persisting fails. After a store /// failure the wallet still holds the lock in memory, but it does not /// survive a restart. pub async fn lock_outpoint(&self, outpoint: OutPoint) -> Result { @@ -370,6 +386,7 @@ impl PlatformWallet { let mut wm = self.wallet_manager.write().await; let info = wm .get_wallet_info_mut(&self.wallet_id()) + .filter(|info| Arc::ptr_eq(&info.generation, &self.generation)) .ok_or_else(|| PlatformWalletError::WalletNotFound(hex::encode(self.wallet_id())))?; let changed = if locked { info.core_wallet.lock_outpoint(outpoint) @@ -394,7 +411,7 @@ impl PlatformWallet { if !persister.store_commits_inline() { persister .flush() - .map_err(|e| PlatformWalletError::Persistence(e.to_string()))?; + .map_err(PlatformWalletError::from_flush_failure)?; } Ok(changed) } @@ -659,19 +676,18 @@ mod tests { async fn should_lock_the_collateral_of_a_registration_restored_into_the_history() { let (manager, wallet_id, collateral) = wallet_with_restored_registration(block(2)).await; + let mut wm = manager.write().await; + let info = wm.get_wallet_info_mut(&wallet_id).expect("wallet"); assert_eq!( - lock_known_masternode_collaterals(&manager, &BTreeSet::new()).await, - BTreeMap::from([(wallet_id, vec![collateral])]), + info.lock_known_masternode_collaterals(&BTreeSet::new()), + vec![collateral], "the new lock is handed back for persistence" ); assert!( - lock_known_masternode_collaterals(&manager, &BTreeSet::new()) - .await + info.lock_known_masternode_collaterals(&BTreeSet::new()) .is_empty(), "a lock is added once" ); - let wm = manager.read().await; - let info = wm.get_wallet_info(&wallet_id).expect("wallet"); assert!(info.core_wallet.is_outpoint_locked(&collateral)); assert_eq!( info.core_wallet.balance.locked(), @@ -688,14 +704,12 @@ mod tests { let (manager, wallet_id, collateral) = wallet_with_restored_registration(TransactionContext::Mempool).await; - assert!( - lock_known_masternode_collaterals(&manager, &BTreeSet::new()) - .await - .is_empty() - ); { - let wm = manager.read().await; - let info = wm.get_wallet_info(&wallet_id).expect("wallet"); + let mut wm = manager.write().await; + let info = wm.get_wallet_info_mut(&wallet_id).expect("wallet"); + assert!(info + .lock_known_masternode_collaterals(&BTreeSet::new()) + .is_empty()); assert!(!info.core_wallet.is_outpoint_locked(&collateral)); assert_eq!( info.core_wallet.balance.spendable(), @@ -818,6 +832,85 @@ mod tests { ); } + /// A handle to a removed wallet does not reach the wallet created again + /// from the same seed: it neither lists nor changes that wallet's locks. + #[tokio::test] + async fn should_not_reach_the_locks_of_a_wallet_created_again_under_the_same_id() { + let persister = Arc::new(LockRecordingPersister::default()); + let sdk = Arc::new(dash_sdk::SdkBuilder::new_mock().build().expect("mock sdk")); + let manager = Arc::new(crate::PlatformWalletManager::new( + sdk, + Arc::clone(&persister), + Arc::new(NoopTestEventHandler) as _, + )); + let seed = [0x3D; 64]; + let removed = manager + .create_wallet_from_seed_bytes( + Network::Testnet, + &seed, + WalletAccountCreationOptions::Default, + Some(0), + ) + .await + .expect("create wallet"); + manager + .remove_wallet(&removed.wallet_id()) + .await + .expect("remove wallet"); + let current = manager + .create_wallet_from_seed_bytes( + Network::Testnet, + &seed, + WalletAccountCreationOptions::Default, + Some(0), + ) + .await + .expect("create the wallet again"); + let outpoint = OutPoint::new(Txid::from_byte_array([0x51; 32]), 0); + assert!(current.lock_outpoint(outpoint).await.expect("lock")); + + assert!(matches!( + removed.unlock_outpoint(outpoint).await, + Err(PlatformWalletError::WalletNotFound(_)) + )); + assert!(matches!( + removed.locked_outpoints().await, + Err(PlatformWalletError::WalletNotFound(_)) + )); + assert_eq!( + current.locked_outpoints().await.expect("locks"), + vec![outpoint] + ); + assert_eq!( + persister.stored.lock().expect("stored locks").last(), + Some(&BTreeMap::from([(outpoint, true)])), + "the removed handle stored no unlock" + ); + } + + /// Once a masternode is no longer tracked its collateral is not watched: + /// a coin that arrives at it afterwards is an ordinary coin. + #[tokio::test] + async fn should_leave_a_coin_spendable_that_arrives_after_its_masternode_is_untracked() { + let (manager, wallet_id, incoming, collateral) = wallet_awaiting_a_collateral().await; + track_masternode_collaterals(&manager, &BTreeSet::from([collateral])).await; + + let untracking = Arc::clone(&manager); + tokio::task::spawn_blocking(move || { + untrack_masternode_collateral_blocking(&untracking, &collateral) + }) + .await + .expect("untrack"); + + let mut wm = manager.write().await; + let checked = wm + .check_transaction_in_all_wallets(&incoming, block(3), true, true) + .await; + assert!(checked.per_wallet_locked_outpoints.is_empty()); + let info = wm.get_wallet_info(&wallet_id).expect("wallet"); + assert_eq!(info.core_wallet.balance.locked(), 0); + } + /// Tracking a masternode whose collateral the wallet already holds locks /// it at once, in that wallet. A later refresh of the same masternode /// leaves an unlock by hand alone. diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift index 48d3d959fbc..4ea98d287f5 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift @@ -5441,11 +5441,10 @@ public final class PlatformWalletPersistenceHandler: @unchecked Sendable { /// Gated on the wallet's row like the round's other core callbacks (a /// stale callback after the wallet's deletion has nothing to write to, /// and that is not a failure), and stored under this handler's network, - /// else the wallet row's. With neither known the locks are not stored - /// and the round goes on: these changes ride the round that stores a - /// block, and failing it would stop the wallet's sync for good. The - /// wallet keeps such a lock for the session and makes it again from the - /// registration on the next load. + /// else the wallet row's. With neither known the write refuses, like the + /// private contact request scan state, rather than file the lock under a + /// guessed network or report a lock stored that is not: a lock made by + /// hand cannot be made again from a registration on the next load. func persistWalletChangesetOutpointLocks(walletId: Data, locks: [OutpointLockChange]) throws { try onQueue { guard inChangeset else { @@ -5459,13 +5458,7 @@ public final class PlatformWalletPersistenceHandler: @unchecked Sendable { case .found(let row): wallet = row } guard let networkRaw = (self.network ?? wallet.network)?.rawValue else { - SDKLogger.event( - "persistence_outpoint_locks_without_network", - category: .persistence, - severity: .error, - fields: ["wallet_reference": .reference(walletId)] - ) - return + throw PlatformWalletError.walletOperation("No network to store the outpoint locks under") } var stored: [Data: PersistentLockedOutpoint] = [:] for row in try backgroundContext.fetch(FetchDescriptor( diff --git a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/LockedOutpointPersistenceTests.swift b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/LockedOutpointPersistenceTests.swift index d640ebbec04..bdd885bf188 100644 --- a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/LockedOutpointPersistenceTests.swift +++ b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/LockedOutpointPersistenceTests.swift @@ -125,18 +125,18 @@ final class LockedOutpointPersistenceTests: XCTestCase { } /// With no network known on the handler or the wallet row there is - /// nowhere to file a lock: nothing is stored and the round still - /// succeeds, since the same round stores a block. - func testShouldStoreNoLockAndKeepTheRoundWhenNoNetworkIsKnown() throws { + /// nowhere to file a lock: the write refuses, so the round does not + /// report a lock stored that is not. + func testShouldRefuseALockWriteWhenNoNetworkIsKnown() throws { let container = try DashModelContainer.createInMemory() let context = ModelContext(container) context.insert(PersistentWallet(walletId: walletId)) try context.save() let handler = PlatformWalletPersistenceHandler(modelContainer: container) handler.beginChangeset(walletId: walletId) - XCTAssertNoThrow(try handler.persistWalletChangesetOutpointLocks( + XCTAssertThrowsError(try handler.persistWalletChangesetOutpointLocks( walletId: walletId, locks: [.init(outpoint: outpoint(0x11, 0), locked: true)])) - XCTAssertTrue(handler.endChangeset(walletId: walletId, success: true)) + _ = handler.endChangeset(walletId: walletId, success: false) XCTAssertTrue(try storedRows(container).isEmpty) } From 826f6901d0b6bf3e7ecec8312159772af1605839 Mon Sep 17 00:00:00 2001 From: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com> Date: Fri, 13 Nov 2026 03:14:07 -0600 Subject: [PATCH 11/26] fix(platform)!: a data contract holds a bounded number of patterns of bounded compiled size (PV15) (#5879) Co-authored-by: Claude Mythos 5.2 Co-authored-by: QuantumExplorer --- book/src/contract-keywords.md | 2 + book/src/contract-keywords/contested.md | 1 + .../src/contract-keywords/property-schemas.md | 2 + .../v1/mod.rs | 17 + .../rs-dpp/src/data_contract/methods/mod.rs | 2 + .../methods/registration_cost/mod.rs | 12 +- .../methods/registration_cost/v3/mod.rs | 229 ++++++ .../methods/validate_schema_patterns/mod.rs | 729 ++++++++++++++++++ .../validate_schema_patterns/v0/mod.rs | 313 ++++++++ packages/rs-dpp/src/data_contract/mod.rs | 136 ++++ .../data_contract/serialized_version/mod.rs | 98 +++ packages/rs-dpp/tests/contract_corpus.rs | 35 + .../check_tx_verification/v0/mod.rs | 32 + .../check_tx_schema_patterns.rs | 35 + .../contract_structure_test_harness.rs | 103 +++ .../data_contract_common/mod.rs | 3 + .../contract_structure_error_tests.rs | 152 +++- .../contract_structure_error_tests.rs | 32 +- .../src/query/contract_cache_tests.rs | 153 ++++ .../contract_document_removals/v0/mod.rs | 2 +- .../contract_fee_pots/v0/mod.rs | 2 +- .../query/contract_moderation_queries/mod.rs | 2 +- .../data_contract/v0/mod.rs | 52 +- .../data_contract_history/v0/mod.rs | 17 +- .../data_contracts/v0/mod.rs | 55 +- .../data_contracts_by_range/v0/mod.rs | 66 +- .../src/query/document_history/v0/mod.rs | 12 +- .../src/query/document_history/v1/mod.rs | 9 +- .../src/query/document_history/v1/tests.rs | 47 ++ packages/rs-drive-abci/src/query/mod.rs | 3 + .../query/private_document_entries/v0/mod.rs | 2 +- .../v0/mod.rs | 2 +- .../fetch_serialized_contract_history/mod.rs | 161 ++++ .../v0/mod.rs | 60 ++ .../src/drive/contract/get_fetch/mod.rs | 1 + .../resolve.rs | 93 ++- .../vote_polls_by_document_type_query.rs | 56 +- .../dpp_versions/dpp_contract_versions/mod.rs | 6 + .../dpp_versions/dpp_contract_versions/v1.rs | 1 + .../dpp_versions/dpp_contract_versions/v2.rs | 1 + .../dpp_versions/dpp_contract_versions/v3.rs | 1 + .../dpp_versions/dpp_contract_versions/v4.rs | 1 + .../dpp_versions/dpp_contract_versions/v5.rs | 1 + .../dpp_versions/dpp_contract_versions/v6.rs | 1 + .../dpp_versions/dpp_contract_versions/v7.rs | 11 + .../drive_contract_method_versions/mod.rs | 1 + .../drive_contract_method_versions/v1.rs | 1 + .../drive_contract_method_versions/v2.rs | 1 + .../drive_contract_method_versions/v3.rs | 1 + .../src/version/mocks/v2_test.rs | 2 + .../src/version/system_limits/mod.rs | 13 + .../src/version/system_limits/v1.rs | 2 + .../src/version/system_limits/v2.rs | 2 + .../src/version/system_limits/v3.rs | 2 + .../src/version/system_limits/v4.rs | 4 +- .../src/version/system_limits/v5.rs | 4 + .../rs-platform-version/src/version/v15.rs | 22 +- 57 files changed, 2741 insertions(+), 65 deletions(-) create mode 100644 packages/rs-dpp/src/data_contract/methods/registration_cost/v3/mod.rs create mode 100644 packages/rs-dpp/src/data_contract/methods/validate_schema_patterns/mod.rs create mode 100644 packages/rs-dpp/src/data_contract/methods/validate_schema_patterns/v0/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/check_tx_schema_patterns.rs create mode 100644 packages/rs-drive-abci/src/query/contract_cache_tests.rs create mode 100644 packages/rs-drive/src/drive/contract/get_fetch/fetch_serialized_contract_history/mod.rs create mode 100644 packages/rs-drive/src/drive/contract/get_fetch/fetch_serialized_contract_history/v0/mod.rs diff --git a/book/src/contract-keywords.md b/book/src/contract-keywords.md index 907ac7bd19b..c3e8c76f8fc 100644 --- a/book/src/contract-keywords.md +++ b/book/src/contract-keywords.md @@ -337,5 +337,7 @@ The first three limits come from the meta-schema, the rest from protocol version | `max_time_range_ttl_seconds` | 604800 | a `timeRange` index's `ttl` | | `max_contested_summed_value_magnitude` | 134217728 (2^27) | the `minimum` and `maximum` of a summed property on a type with a contested index | | `max_expiring_signed_summed_value_magnitude` | 134217728 (2^27) | the `minimum` and `maximum` of a summed property that admits negative values, on a type with a `ttl` | +| `max_contract_schema_patterns` | 32 (in blocks from protocol version 15; the mempool holds a contract to it at every version) | the patterns one contract holds: every `pattern`, and every `regexPattern` of a contested index, in its document schemas and `$defs`, one in `$defs` counted once for each document type | +| `max_schema_pattern_compiled_size` | 131072 bytes (in blocks from protocol version 15; the mempool holds a contract to it at every version) | what any one of those patterns compiles to | | `max_private_document_entry_size` | 4096 bytes (protocol version 15) | a private type's `private.entrySize` | | `max_private_document_entries_per_transition` | 16 (protocol version 15) | the entries one `PrivateDocumentCreateFromShieldedPool` appends | diff --git a/book/src/contract-keywords/contested.md b/book/src/contract-keywords/contested.md index 59fe914d062..890d59791cb 100644 --- a/book/src/contract-keywords/contested.md +++ b/book/src/contract-keywords/contested.md @@ -71,6 +71,7 @@ The fund, the windows, the tallies and the special case of moderation elections - A document type has at most one contested index, and no other unique index beside it (`ContestedUniqueIndexWithUniqueIndexError`, 10249). - `resolution` is present and is `0`, `1` or `2`; `1` is refused before protocol version 14 and `2` before protocol version 15. - `fieldMatches`, when present, holds at least one entry, and each `regexPattern` is a valid regular expression (`RegexError`, 10247). +- From protocol version 15 each `regexPattern` counts toward the 32 patterns a contract may hold and must compile to at most 128 KiB, as a property's [`pattern`](property-schemas.md#strings) must (`InvalidContractStructure`, 10231). - From protocol version 15, the contest is decided by the index values, so that two documents with the same values are both contested or both ordinary: every `fieldMatches` field is a property of the index, and a match on a string property that may be empty (no `minLength` of at least 1) treats `""` and `"\0"` alike, since the two share one index key (`InvalidContractStructure`, 10231). Otherwise an ordinary document could take the values of a contested one, and the contest would have nothing left to award. A contract registered earlier keeps its contest, but can no longer be updated, since an update is checked like a registration; while such a contest is live, a create outside it with the same index values is refused (`DuplicateUniqueIndexError`). - From protocol version 15, every property of the index is a top-level property of the document: no property path such as `records.identity` and no system property such as `$ownerId` (`InvalidContractStructure`, 10231). A contested create finds the contest by reading each index value from the document's top-level properties, where such a property is never found, so no contested create could open or join the contest. A contract registered earlier keeps such an index, but can no longer be updated. - A contested index cannot carry a [`timeRange`](time-range.md), an [`integerRange`](integer-range.md) or a ranking (a ranking needs a non-unique index), and an [index-only type](index-only.md) cannot have one. diff --git a/book/src/contract-keywords/property-schemas.md b/book/src/contract-keywords/property-schemas.md index 4a4d3d9e5f3..067f22302df 100644 --- a/book/src/contract-keywords/property-schemas.md +++ b/book/src/contract-keywords/property-schemas.md @@ -112,6 +112,8 @@ A `username` is 3 to 63 letters, digits or underscores. - `minLength` and `maxLength` count characters, and a character takes 1 to 4 bytes in UTF-8. To cap the stored size, add [`maxBytes`](max-bytes.md). Whatever `maxLength` says, no single string may exceed 5120 bytes (10417). - `pattern` is written in the syntax of Rust's `regex` crate, which has no lookaround and no backreferences. A pattern that does not compile is refused at registration (10101). +- From protocol version 15 a contract holds at most 32 patterns across its document schemas and `$defs`, a contested index's `regexPattern`s counted with them and one in `$defs` counted once for each document type, and each must compile to at most 128 KiB (`InvalidContractStructure`, 10231). Compiling a pattern takes time and memory in proportion to its compiled size, not its length: a bounded repetition of a Unicode class such as `\pL{20}` compiles to far more than `\pL+` beside a `maxLength`. +- Before protocol version 15 a node's mempool accepts less than a block does. It holds a contract to these two limits, and refuses a schema declaring `format: regex`, a `patternProperties`, and, in a contract holding a pattern, a `$ref` that is not `#/$defs/` followed by a definition's name or an `$id` that is not a plain name. A contract a block accepts may so be refused when it is submitted. From protocol version 15 the mempool holds patterns to what a block does. - `format` is checked on every document. The validator knows `date-time`, `date`, `time`, `email`, `idn-email`, `hostname`, `ipv4`, `ipv6`, `uri` and `regex`. Any other format, `uuid` and `uri-reference` included, is refused at registration (10101). - A string with `pattern` or `format` must declare a `maxLength` of at most 50000, so that matching stays cheap. - A string used in an index needs a `maxLength` of at most 63 (`InvalidIndexedPropertyConstraintError`, 10205). See [Indexes](indexes.md). diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/create_document_types_from_document_schemas/v1/mod.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/create_document_types_from_document_schemas/v1/mod.rs index 961869f2cae..6808c0d101f 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/create_document_types_from_document_schemas/v1/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/create_document_types_from_document_schemas/v1/mod.rs @@ -16,6 +16,8 @@ use crate::data_contract::document_type::{ use crate::data_contract::errors::DataContractError; use crate::data_contract::{DocumentName, TokenConfiguration, TokenContractPosition}; use crate::identity::Purpose; +#[cfg(feature = "validation")] +use crate::prelude::DataContract; use crate::validation::operations::ProtocolValidationOperation; use crate::version::PlatformVersion; use crate::ProtocolError; @@ -45,6 +47,21 @@ impl DocumentType { )); } + // Before any schema is parsed, so that nothing compiles a pattern this refuses. In + // place in this generation, which protocol versions before 15 select too: the + // method's own gate, `validate_schema_patterns`, is `None` there, so it refuses nothing + #[cfg(feature = "validation")] + if full_validation { + let result = DataContract::validate_schema_patterns( + &document_schemas, + schema_defs, + platform_version, + )?; + if let Some(error) = result.errors.into_iter().next() { + return Err(ProtocolError::ConsensusError(Box::new(error))); + } + } + for (name, schema) in document_schemas.into_iter() { let document_type = match platform_version .dpp diff --git a/packages/rs-dpp/src/data_contract/methods/mod.rs b/packages/rs-dpp/src/data_contract/methods/mod.rs index 04f79db8876..59222dabb59 100644 --- a/packages/rs-dpp/src/data_contract/methods/mod.rs +++ b/packages/rs-dpp/src/data_contract/methods/mod.rs @@ -6,4 +6,6 @@ pub mod validate_document; #[cfg(feature = "validation")] pub mod validate_groups; #[cfg(feature = "validation")] +pub mod validate_schema_patterns; +#[cfg(feature = "validation")] pub mod validate_update; diff --git a/packages/rs-dpp/src/data_contract/methods/registration_cost/mod.rs b/packages/rs-dpp/src/data_contract/methods/registration_cost/mod.rs index 37648fd327d..6edf1508698 100644 --- a/packages/rs-dpp/src/data_contract/methods/registration_cost/mod.rs +++ b/packages/rs-dpp/src/data_contract/methods/registration_cost/mod.rs @@ -1,5 +1,6 @@ mod v1; mod v2; +mod v3; use crate::data_contract::serialized_version::DataContractInSerializationFormat; use crate::data_contract::DataContract; @@ -25,6 +26,7 @@ impl DataContract { /// - Version 0: Always returns `0` (used before protocol version 9, ie before 2.0, where registration cost was not charged). /// - Version 1: Uses a detailed cost model based on document types, indexes, tokens, and keyword count. /// - Version 2: Version 1 plus the surcharge for tokens with a once-per-identity distribution (protocol version 14). + /// - Version 3: Version 2, for a parsed contract (protocol version 15). pub fn registration_cost( &self, platform_version: &PlatformVersion, @@ -37,10 +39,11 @@ impl DataContract { { 0 => Ok(0), // Before 2.0 it's just 0 (There was some validation cost) 1 => Ok(self.registration_cost_v1(platform_version)), - 2 => Ok(self.registration_cost_v2(platform_version)), + // Generation 3 changes how the serialization format reads an index only + 2 | 3 => Ok(self.registration_cost_v2(platform_version)), version => Err(ProtocolError::UnknownVersionMismatch { method: "DataContract::registration_cost".to_string(), - known_versions: vec![0, 1, 2], + known_versions: vec![0, 1, 2, 3], received: version, }), } @@ -66,6 +69,8 @@ impl DataContractInSerializationFormat { /// - Version 0: Always returns `0` (used before protocol version 9, ie before 2.0, where registration cost was not charged). /// - Version 1: Uses a detailed cost model based on document types, indexes, tokens, and keyword count. /// - Version 2: Version 1 plus the surcharge for tokens with a once-per-identity distribution (protocol version 14). + /// - Version 3: Version 2, but an index is billed by the keys it declares, without parsing it + /// and compiling its field matches (protocol version 15). pub fn registration_cost( &self, platform_version: &PlatformVersion, @@ -79,9 +84,10 @@ impl DataContractInSerializationFormat { 0 => Ok(0), // Before 2.0 it's just 0 (There was some validation cost) 1 => Ok(self.registration_cost_v1(platform_version)), 2 => Ok(self.registration_cost_v2(platform_version)), + 3 => Ok(self.registration_cost_v3(platform_version)), version => Err(ProtocolError::UnknownVersionMismatch { method: "DataContract::registration_cost".to_string(), - known_versions: vec![0, 1, 2], + known_versions: vec![0, 1, 2, 3], received: version, }), } diff --git a/packages/rs-dpp/src/data_contract/methods/registration_cost/v3/mod.rs b/packages/rs-dpp/src/data_contract/methods/registration_cost/v3/mod.rs new file mode 100644 index 00000000000..20be1cba125 --- /dev/null +++ b/packages/rs-dpp/src/data_contract/methods/registration_cost/v3/mod.rs @@ -0,0 +1,229 @@ +use crate::data_contract::associated_token::token_configuration::accessors::v0::TokenConfigurationV0Getters; +use crate::data_contract::associated_token::token_distribution_rules::accessors::v0::TokenDistributionRulesV0Getters; +use crate::data_contract::associated_token::token_distribution_rules::accessors::v1::TokenDistributionRulesV1Getters; +use crate::data_contract::document_type::property_names::INDICES; +use crate::data_contract::serialized_version::DataContractInSerializationFormat; +use crate::fee::Credits; +use platform_value::Value; +use platform_version::version::PlatformVersion; + +/// The key that makes an index contested. +const CONTESTED: &str = "contested"; +/// The key that makes an index unique. +const UNIQUE: &str = "unique"; + +impl DataContractInSerializationFormat { + /// What [`registration_cost_v2`](Self::registration_cost_v2) computes, but an index is + /// billed by the keys it declares instead of by parsing it: contested when it has a + /// `contested`, otherwise unique when its last boolean `unique` is `true`, as the index + /// parser reads the two. + /// + /// Parsing an index compiles every `regexPattern` of its contested `fieldMatches`. The + /// balance pre-check runs this before contract registration and update hold the patterns + /// to `max_contract_schema_patterns` and `max_schema_pattern_compiled_size`, so a parse + /// here compiled any number of them, each within the `regex` crate's 10 MiB default. + /// Every index of a contract that registers parses, so such a contract costs here what it + /// costs under generation 2. An index that does not parse is billed as well, and the + /// contract is refused once it is parsed. + pub(super) fn registration_cost_v3(&self, platform_version: &PlatformVersion) -> Credits { + let fee_version = &platform_version.fee_version.data_contract_registration; + let mut cost = fee_version.base_contract_registration_fee; + + for document_type_schema in self.document_schemas().values() { + cost = cost.saturating_add(fee_version.document_type_registration_fee); + + let Ok(schema_map) = document_type_schema.to_map() else { + continue; + }; + let Ok(Some(index_values)) = + Value::inner_optional_array_slice_value(schema_map, INDICES) + else { + continue; + }; + for index_value in index_values { + let Ok(index_value_map) = index_value.to_map() else { + continue; + }; + let contested = index_value_map + .iter() + .any(|(key, _)| key.as_text() == Some(CONTESTED)); + let unique = index_value_map.iter().fold(false, |unique, (key, value)| { + match (key.as_text(), value) { + (Some(UNIQUE), Value::Bool(declared)) => *declared, + _ => unique, + } + }); + let base_index_fee = if contested { + fee_version.document_type_base_contested_index_registration_fee + } else if unique { + fee_version.document_type_base_unique_index_registration_fee + } else { + fee_version.document_type_base_non_unique_index_registration_fee + }; + cost = cost.saturating_add(base_index_fee); + } + } + + for token_config in self.tokens().values() { + cost = cost.saturating_add(fee_version.token_registration_fee); + + if token_config + .distribution_rules() + .perpetual_distribution() + .is_some() + { + cost = cost.saturating_add(fee_version.token_uses_perpetual_distribution_fee); + } + + if token_config + .distribution_rules() + .pre_programmed_distribution() + .is_some() + { + cost = cost.saturating_add(fee_version.token_uses_pre_programmed_distribution_fee); + } + + if token_config + .distribution_rules() + .once_per_identity_distribution() + .is_some() + { + cost = + cost.saturating_add(fee_version.token_uses_once_per_identity_distribution_fee); + } + } + + let keyword_cost = fee_version + .search_keyword_fee + .saturating_mul(self.keywords().len() as u64); + + cost.saturating_add(keyword_cost) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::data_contract::conversion::value::v0::DataContractValueConversionMethodsV0; + use crate::prelude::DataContract; + use crate::tests::fixtures::get_dashpay_contract_fixture; + use platform_value::string_encoding::Encoding; + use platform_value::Identifier; + use platform_version::TryFromPlatformVersioned; + use serde_json::json; + + fn serialized(contract: DataContract) -> DataContractInSerializationFormat { + DataContractInSerializationFormat::try_from_platform_versioned( + contract, + PlatformVersion::latest(), + ) + .expect("expected the serialization format") + } + + /// A contract whose document type `item` has a contested index and one that is neither + /// contested nor unique, and whose document type `tag` has a unique one. + fn contract_with_every_kind_of_index() -> DataContract { + let label = json!({ "type": "string", "maxLength": 20, "position": 0 }); + let other = json!({ "type": "string", "maxLength": 20, "position": 1 }); + let value = platform_value::to_value(json!({ + "$formatVersion": "1", + "id": Identifier::from([7; 32]).to_string(Encoding::Base58), + "ownerId": Identifier::from([8; 32]).to_string(Encoding::Base58), + "version": 1, + "documentSchemas": { + "item": { + "type": "object", + "documentsMutable": false, + "canBeDeleted": false, + "properties": { "label": label, "other": other }, + "required": ["label", "other"], + "indices": [ + { + "name": "byLabel", + "properties": [{ "label": "asc" }], + "unique": true, + "contested": { + "fieldMatches": [ + { "field": "label", "regexPattern": "^[a-z]{3,9}$" } + ], + "resolution": 0 + } + }, + { "name": "byOther", "properties": [{ "other": "asc" }] } + ], + "additionalProperties": false + }, + "tag": { + "type": "object", + "properties": { "label": label }, + "required": ["label"], + "indices": [ + { "name": "byLabel", "properties": [{ "label": "asc" }], "unique": true } + ], + "additionalProperties": false + } + } + })) + .expect("the contract should convert"); + DataContract::from_value(value, true, PlatformVersion::latest()) + .expect("the contract should parse") + } + + #[test] + fn should_bill_a_contract_that_registers_as_generation_2_does() { + let platform_version = PlatformVersion::latest(); + for contract in [ + contract_with_every_kind_of_index(), + get_dashpay_contract_fixture(None, 0, platform_version.protocol_version) + .data_contract_owned(), + ] { + let parsed = contract.registration_cost_v2(platform_version); + let serialized = serialized(contract); + assert_eq!(serialized.registration_cost_v3(platform_version), parsed); + assert_eq!(serialized.registration_cost_v2(platform_version), parsed); + } + } + + /// Generation 2 parses the index, which compiles its field matches, and bills nothing for + /// one that does not compile. Generation 3 compiles none and bills the index all the same. + #[test] + fn should_bill_a_contested_index_without_compiling_its_field_matches() { + let platform_version = PlatformVersion::latest(); + let fee_version = &platform_version.fee_version.data_contract_registration; + let mut contract = serialized(contract_with_every_kind_of_index()); + let schemas = contract + .document_schemas_mut() + .expect("expected a transport format's schemas"); + let field_match = schemas + .get_mut("item") + .and_then(|schema| schema.get_optional_value_mut("indices").ok().flatten()) + .and_then(|indices| indices.as_array_mut()) + .and_then(|indices| indices.first_mut()) + .and_then(|index| index.get_optional_value_mut("contested").ok().flatten()) + .and_then(|contested| { + contested + .get_optional_value_mut("fieldMatches") + .ok() + .flatten() + }) + .and_then(|field_matches| field_matches.as_array_mut()) + .and_then(|field_matches| field_matches.first_mut()) + .expect("expected the contested index's field match"); + field_match + .set_value("regexPattern", Value::Text("(".to_string())) + .expect("expected to replace the pattern"); + + let unique_and_plain = fee_version.base_contract_registration_fee + + 2 * fee_version.document_type_registration_fee + + fee_version.document_type_base_unique_index_registration_fee + + fee_version.document_type_base_non_unique_index_registration_fee; + assert_eq!( + contract.registration_cost_v2(platform_version), + unique_and_plain + ); + assert_eq!( + contract.registration_cost_v3(platform_version), + unique_and_plain + fee_version.document_type_base_contested_index_registration_fee + ); + } +} diff --git a/packages/rs-dpp/src/data_contract/methods/validate_schema_patterns/mod.rs b/packages/rs-dpp/src/data_contract/methods/validate_schema_patterns/mod.rs new file mode 100644 index 00000000000..3fb8e4fb514 --- /dev/null +++ b/packages/rs-dpp/src/data_contract/methods/validate_schema_patterns/mod.rs @@ -0,0 +1,729 @@ +mod v0; + +use crate::data_contract::DocumentName; +use crate::prelude::DataContract; +use crate::validation::SimpleConsensusValidationResult; +use crate::ProtocolError; +use platform_value::Value; +use platform_version::version::PlatformVersion; +use std::collections::BTreeMap; +use v0::DefinitionsCount; + +impl DataContract { + /// Holds the regular expressions a contract's schemas carry to a bound, before anything + /// compiles one: compiling takes time and memory in proportion to the compiled size, not + /// to the pattern's length, and every pattern is compiled when a contract is parsed and + /// again for the validator its documents are checked with. + /// + /// A pattern is every string under a `pattern` key and every `regexPattern` of a contested + /// index's `fieldMatches`, wherever the document schemas and `$defs` hold one: the walk + /// reads keys, not the grammar, so a value a `const`, `enum` or `default` holds under one + /// of these keys counts too. A pattern in `$defs` counts once for each document type, + /// since the schema check reads every definition for each type it checks. A contract may + /// hold `max_contract_schema_patterns` patterns so counted, and each must compile within + /// `max_schema_pattern_compiled_size` bytes, a `pattern` as the document validator + /// compiles it and a `regexPattern` as the index parser does. A protocol version that + /// predates the rule refuses nothing. + pub fn validate_schema_patterns( + document_schemas: &BTreeMap, + schema_defs: Option<&BTreeMap>, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .dpp + .contract_versions + .methods + .validate_schema_patterns + { + None => Ok(SimpleConsensusValidationResult::new()), + Some(0) => Ok(Self::validate_schema_patterns_v0( + document_schemas, + schema_defs, + DefinitionsCount::OncePerDocumentType, + false, + platform_version, + )), + Some(version) => Err(ProtocolError::UnknownVersionMismatch { + method: "DataContract::validate_schema_patterns".to_string(), + known_versions: vec![0], + received: version, + }), + } + } + + /// What a mempool holds a contract's patterns to: the bound of + /// [`Self::validate_schema_patterns`], at every protocol version. + /// + /// A protocol version that predates the rule has no bound in consensus, and its blocks + /// must keep accepting what they accepted. Its mempool applies generation 0 of the rule + /// with its own system limits all the same, counting a pattern in `$defs` also once for + /// each `$ref` that reaches it where that is more: the JSON Schema validator those + /// versions check documents with compiles what a `$ref` names once for each `$ref`. That + /// validator resolves a `$ref` through the `$id`s of a schema, so there a contract holding + /// a pattern is refused with a `$ref` that is not `#/$defs/` and a definition's name, or + /// an `$id` that is not a plain name. It also compiles each key of a `patternProperties`, + /// wherever the document meta-schema leaves a schema unchecked, so that is refused there. + /// And it compiles each value of a property declaring `format: regex` when a document is + /// checked, under no bound a contract can be held to, so a schema declaring one is refused + /// there too. A protocol version with the rule checks such a value's syntax without + /// compiling it, and its mempool refuses nothing its blocks accept. + pub fn validate_schema_patterns_for_mempool( + document_schemas: &BTreeMap, + schema_defs: Option<&BTreeMap>, + platform_version: &PlatformVersion, + ) -> Result { + let (definitions_count, refuse_regex_format) = match platform_version + .dpp + .contract_versions + .methods + .validate_schema_patterns + { + None => (DefinitionsCount::OncePerReference, true), + Some(0) => (DefinitionsCount::OncePerDocumentType, false), + Some(version) => { + return Err(ProtocolError::UnknownVersionMismatch { + method: "DataContract::validate_schema_patterns_for_mempool".to_string(), + known_versions: vec![0], + received: version, + }) + } + }; + Ok(Self::validate_schema_patterns_v0( + document_schemas, + schema_defs, + definitions_count, + refuse_regex_format, + platform_version, + )) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::consensus::basic::BasicError; + use crate::consensus::ConsensusError; + use crate::data_contract::errors::DataContractError; + use assert_matches::assert_matches; + use platform_value::platform_value; + + /// A `pattern` and a `regexPattern` any limit admits. + const SMALL: &str = "^[a-z]{1,20}$"; + /// Unicode letters, twenty times: over the limit in either dialect, though under the + /// 5 and 10 MiB the parsers compile a pattern within. + const LARGE: &str = r"^\pL{20}$"; + + fn before_the_rule() -> &'static PlatformVersion { + PlatformVersion::get(14).expect("expected protocol version 14") + } + + /// The most patterns a contract may hold, the same at every protocol version. + fn most() -> usize { + usize::from( + PlatformVersion::latest() + .system_limits + .max_contract_schema_patterns, + ) + } + + /// The fragment of the refusal of a contract holding more than [`most`] patterns. + fn too_many_message() -> String { + format!("at most {} patterns", most()) + } + + /// A document type of `count` string properties, each with `pattern`. + fn schema_with_patterns(count: usize, pattern: &str) -> Value { + let properties: Vec<(Value, Value)> = (0..count) + .map(|position| { + ( + Value::Text(format!("p{position}")), + platform_value!({ + "type": "string", + "pattern": pattern, + "maxLength": 63, + "position": position as u64, + }), + ) + }) + .collect(); + platform_value!({ + "type": "object", + "properties": Value::Map(properties), + "additionalProperties": false, + }) + } + + /// A document type whose contested index lists `count` field matches of `pattern`. + fn schema_with_field_matches(count: usize, pattern: &str) -> Value { + let field_matches: Vec = (0..count) + .map(|_| platform_value!({ "field": "label", "regexPattern": pattern })) + .collect(); + platform_value!({ + "type": "object", + "properties": { + "label": { "type": "string", "maxLength": 63, "position": 0 }, + }, + "indices": [{ + "name": "byLabel", + "properties": [{ "label": "asc" }], + "unique": true, + "contested": { "fieldMatches": field_matches, "resolution": 0 }, + }], + "additionalProperties": false, + }) + } + + fn schemas(schema: Value) -> BTreeMap { + BTreeMap::from([("item".to_string(), schema)]) + } + + fn refusal_message(result: SimpleConsensusValidationResult) -> String { + assert_matches!( + result.errors.as_slice(), + [ConsensusError::BasicError(BasicError::ContractError( + DataContractError::InvalidContractStructure(message) + ))] => message.clone() + ) + } + + fn validate( + document_schemas: &BTreeMap, + schema_defs: Option<&BTreeMap>, + platform_version: &PlatformVersion, + ) -> SimpleConsensusValidationResult { + DataContract::validate_schema_patterns(document_schemas, schema_defs, platform_version) + .expect("expected the rule to run") + } + + fn validate_for_mempool( + document_schemas: &BTreeMap, + schema_defs: Option<&BTreeMap>, + platform_version: &PlatformVersion, + ) -> SimpleConsensusValidationResult { + DataContract::validate_schema_patterns_for_mempool( + document_schemas, + schema_defs, + platform_version, + ) + .expect("expected the rule to run") + } + + #[test] + fn should_hold_a_contract_to_the_most_patterns_it_may_hold() { + let platform_version = PlatformVersion::latest(); + let most = usize::from(platform_version.system_limits.max_contract_schema_patterns); + + let at_the_limit = schemas(schema_with_patterns(most, SMALL)); + assert!(validate(&at_the_limit, None, platform_version).is_valid()); + + let over_the_limit = schemas(schema_with_patterns(most + 1, SMALL)); + let message = refusal_message(validate(&over_the_limit, None, platform_version)); + assert!(message.contains(&too_many_message()), "{message}"); + } + + #[test] + fn should_count_the_patterns_of_every_document_type_and_of_the_defs_together() { + let platform_version = PlatformVersion::latest(); + let most = usize::from(platform_version.system_limits.max_contract_schema_patterns); + let document_schemas = BTreeMap::from([ + ("a".to_string(), schema_with_patterns(most / 2, SMALL)), + ( + "b".to_string(), + schema_with_field_matches(most - most / 2, SMALL), + ), + ]); + assert!(validate(&document_schemas, None, platform_version).is_valid()); + + let schema_defs = BTreeMap::from([( + "label".to_string(), + platform_value!({ "type": "string", "pattern": SMALL }), + )]); + let message = refusal_message(validate( + &document_schemas, + Some(&schema_defs), + platform_version, + )); + assert!(message.contains(&too_many_message()), "{message}"); + } + + #[test] + fn should_refuse_too_many_patterns_without_compiling_one() { + // None of these compiles, and the refusal is for their number + let document_schemas = schemas(schema_with_field_matches(most() + 1, "(")); + let message = refusal_message(validate(&document_schemas, None, PlatformVersion::latest())); + assert!(message.contains(&too_many_message()), "{message}"); + } + + #[test] + fn should_refuse_a_pattern_that_compiles_to_more_than_the_size_limit() { + let platform_version = PlatformVersion::latest(); + for document_schemas in [ + schemas(schema_with_patterns(1, LARGE)), + schemas(schema_with_field_matches(1, LARGE)), + ] { + let message = refusal_message(validate(&document_schemas, None, platform_version)); + assert!( + message.contains(LARGE) && message.contains("compiles within 131072 bytes"), + "{message}" + ); + } + // A long pattern compiles to little: the limit is on the compiled size + let long = format!("^({})$", vec!["[a-z]{1,20}"; 40].join("|")); + assert!(validate( + &schemas(schema_with_patterns(1, &long)), + None, + platform_version + ) + .is_valid()); + } + + #[test] + fn should_compile_each_pattern_as_what_reads_it_does() { + // The document validator reads `\w` as the ASCII word characters, the index parser as + // every Unicode one, which compiles to far more + let platform_version = PlatformVersion::latest(); + let words = r"^\w{20}$"; + assert!(validate( + &schemas(schema_with_patterns(1, words)), + None, + platform_version + ) + .is_valid()); + let message = refusal_message(validate( + &schemas(schema_with_field_matches(1, words)), + None, + platform_version, + )); + assert!(message.contains("`regexPattern`"), "{message}"); + } + + #[test] + fn should_refuse_a_pattern_that_is_not_a_regular_expression() { + let message = refusal_message(validate( + &schemas(schema_with_patterns(1, "(")), + None, + PlatformVersion::latest(), + )); + assert!(message.contains("`pattern` `(`"), "{message}"); + } + + #[test] + fn should_walk_a_schema_nested_deeper_than_the_stack_holds() { + let mut schema = platform_value!({ "pattern": "(" }); + for _ in 0..200_000 { + schema = Value::Array(vec![schema]); + } + let document_schemas = schemas(schema); + let message = refusal_message(validate(&document_schemas, None, PlatformVersion::latest())); + assert!(message.contains("`pattern` `(`"), "{message}"); + // Dropping a value this deep recurses as deep + std::mem::forget(document_schemas); + } + + #[test] + fn should_refuse_nothing_in_consensus_before_protocol_version_15() { + for document_schemas in [ + schemas(schema_with_patterns(most() + 1, SMALL)), + schemas(schema_with_patterns(1, LARGE)), + schemas(schema_with_field_matches(1, "(")), + ] { + assert!(validate(&document_schemas, None, before_the_rule()).is_valid()); + } + } + + #[test] + fn should_hold_the_mempool_to_the_bound_before_consensus_has_it() { + let message = refusal_message(validate_for_mempool( + &schemas(schema_with_patterns(most() + 1, SMALL)), + None, + before_the_rule(), + )); + assert!(message.contains(&too_many_message()), "{message}"); + + let message = refusal_message(validate_for_mempool( + &schemas(schema_with_field_matches(1, LARGE)), + None, + before_the_rule(), + )); + assert!( + message.contains("compiles within 131072 bytes"), + "{message}" + ); + + assert!(validate_for_mempool( + &schemas(schema_with_patterns(most(), SMALL)), + None, + before_the_rule() + ) + .is_valid()); + } + + #[test] + fn should_keep_a_regex_format_out_of_the_mempool_only_before_the_rule() { + let document_schemas = schemas(platform_value!({ + "type": "object", + "properties": { + "expression": { + "type": "string", + "format": "regex", + "maxLength": 63, + "position": 0, + }, + }, + "additionalProperties": false, + })); + + // The JSON Schema validator compiles every value of such a property + let message = refusal_message(validate_for_mempool( + &document_schemas, + None, + before_the_rule(), + )); + assert!(message.contains("`format: regex`"), "{message}"); + assert!(validate(&document_schemas, None, before_the_rule()).is_valid()); + + // The native validator checks a value's syntax without compiling it + let platform_version = PlatformVersion::latest(); + assert!(validate_for_mempool(&document_schemas, None, platform_version).is_valid()); + assert!(validate(&document_schemas, None, platform_version).is_valid()); + } + + /// `count` document types, each with one property that is a `$ref` to `definition`. + fn schemas_referring_to(count: usize, definition: &str) -> BTreeMap { + let reference = format!("#/$defs/{definition}"); + (0..count) + .map(|index| { + ( + format!("item{index}"), + platform_value!({ + "type": "object", + "properties": { + "label": { "$ref": reference.clone(), "position": 0 }, + }, + "additionalProperties": false, + }), + ) + }) + .collect() + } + + /// A definition `labels` holding `count` string properties, each with a pattern. + fn definitions_with_patterns(count: usize) -> BTreeMap { + BTreeMap::from([("labels".to_string(), schema_with_patterns(count, SMALL))]) + } + + #[test] + fn should_count_a_pattern_in_the_defs_for_each_document_type() { + // The schema check reads every definition for each type, referred to or not + let platform_version = PlatformVersion::latest(); + let schema_defs = definitions_with_patterns(most() / 4); + + let four_types = schemas_referring_to(4, "labels"); + assert!(validate(&four_types, Some(&schema_defs), platform_version).is_valid()); + + let five_types = schemas_referring_to(5, "labels"); + let message = refusal_message(validate(&five_types, Some(&schema_defs), platform_version)); + assert!( + message.contains("counted for each document type"), + "{message}" + ); + + let mut never_referring = schemas(schema_with_patterns(0, SMALL)); + never_referring.extend(schemas_referring_to(4, "labels")); + let message = refusal_message(validate( + &never_referring, + Some(&schema_defs), + platform_version, + )); + assert!( + message.contains("counted for each document type"), + "{message}" + ); + } + + #[test] + fn should_count_the_patterns_of_the_defs_once_in_a_contract_without_document_types() { + let platform_version = PlatformVersion::latest(); + let no_document_types = BTreeMap::new(); + assert!(validate( + &no_document_types, + Some(&definitions_with_patterns(most())), + platform_version + ) + .is_valid()); + let message = refusal_message(validate( + &no_document_types, + Some(&definitions_with_patterns(most() + 1)), + platform_version, + )); + assert!(message.contains(&too_many_message()), "{message}"); + } + + /// One document type whose `count` properties are each a `$ref` to `definition`. + fn schema_referring_often_to(count: usize, definition: &str) -> BTreeMap { + let reference = format!("#/$defs/{definition}"); + let properties: Vec<(Value, Value)> = (0..count) + .map(|position| { + ( + Value::Text(format!("p{position}")), + platform_value!({ + "$ref": reference.clone(), + "position": position as u64, + }), + ) + }) + .collect(); + schemas(platform_value!({ + "type": "object", + "properties": Value::Map(properties), + "additionalProperties": false, + })) + } + + #[test] + fn should_count_a_pattern_for_each_ref_reaching_it_in_the_mempool_before_the_rule() { + // The JSON Schema validator compiles a definition once for each `$ref` to it; the + // native one, once for the type + let schema_defs = definitions_with_patterns(1); + let within = schema_referring_often_to(most(), "labels"); + let over = schema_referring_often_to(most() + 1, "labels"); + + assert!(validate_for_mempool(&within, Some(&schema_defs), before_the_rule()).is_valid()); + let message = refusal_message(validate_for_mempool( + &over, + Some(&schema_defs), + before_the_rule(), + )); + assert!(message.contains("for each `$ref` to it"), "{message}"); + + assert!(validate(&over, Some(&schema_defs), PlatformVersion::latest()).is_valid()); + } + + #[test] + fn should_count_a_pattern_through_the_refs_of_the_definitions_before_the_rule() { + // `d0` refers twice to `d1`, which refers twice to `d2`, and so on to `d7`, which + // holds the one pattern: 128 `$ref`s reach it + let mut schema_defs = definitions_with_patterns(0); + for level in 0..7 { + let next = format!("#/$defs/d{}", level + 1); + schema_defs.insert( + format!("d{level}"), + platform_value!({ + "type": "object", + "properties": { + "a": { "$ref": next.clone(), "position": 0 }, + "b": { "$ref": next, "position": 1 }, + }, + "additionalProperties": false, + }), + ); + } + schema_defs.insert( + "d7".to_string(), + platform_value!({ "type": "string", "pattern": SMALL, "maxLength": 63 }), + ); + + let from_the_top = schema_referring_often_to(1, "d0"); + let message = refusal_message(validate_for_mempool( + &from_the_top, + Some(&schema_defs), + before_the_rule(), + )); + assert!(message.contains("for each `$ref` to it"), "{message}"); + + let from_half_way = schema_referring_often_to(1, "d2"); + assert!( + validate_for_mempool(&from_half_way, Some(&schema_defs), before_the_rule()).is_valid() + ); + } + + #[test] + fn should_stop_at_definitions_referring_to_each_other() { + let cycle = |pattern: Option<&str>| { + let mut leaf = platform_value!({ "type": "string", "maxLength": 63 }); + if let Some(pattern) = pattern { + leaf.insert("pattern".to_string(), Value::Text(pattern.to_string())) + .expect("expected a map"); + } + BTreeMap::from([ + ( + "a".to_string(), + platform_value!({ "allOf": [{ "$ref": "#/$defs/b" }, leaf] }), + ), + ( + "b".to_string(), + platform_value!({ "allOf": [{ "$ref": "#/$defs/a" }] }), + ), + ]) + }; + let document_schemas = schema_referring_often_to(1, "a"); + + // Nothing to compile however far the cycle is followed + assert!( + validate_for_mempool(&document_schemas, Some(&cycle(None)), before_the_rule()) + .is_valid() + ); + // A pattern compiled once more each time round + let message = refusal_message(validate_for_mempool( + &document_schemas, + Some(&cycle(Some(SMALL))), + before_the_rule(), + )); + assert!(message.contains("for each `$ref` to it"), "{message}"); + } + + #[test] + fn should_keep_an_id_that_may_move_a_ref_out_of_the_mempool_before_the_rule() { + // The JSON Schema validator looks a `$ref` up among the `$id`s of a schema before it + // reads it as a pointer: each `$ref` to `plain` reaches `holder`, though by its + // pointer it reaches no pattern + let holder_and_plain = |id: &str| { + let mut holder = schema_with_patterns(1, SMALL); + holder + .insert("$id".to_string(), Value::Text(id.to_string())) + .expect("expected a map"); + BTreeMap::from([ + ("holder".to_string(), holder), + ("plain".to_string(), platform_value!({ "type": "integer" })), + ]) + }; + let document_schemas = schema_referring_often_to(most() + 1, "plain"); + + let message = refusal_message(validate_for_mempool( + &document_schemas, + Some(&holder_and_plain("#/$defs/plain")), + before_the_rule(), + )); + assert!( + message.contains("`$id` that is not a plain name"), + "{message}" + ); + + // A plain name is what a keyword's data holds under this key, and moves nothing + assert!(validate_for_mempool( + &document_schemas, + Some(&holder_and_plain("targetId")), + before_the_rule() + ) + .is_valid()); + + // Nothing to compile, wherever a `$ref` leads + let mut no_pattern = holder_and_plain("#/$defs/plain"); + no_pattern.insert( + "holder".to_string(), + platform_value!({ "$id": "#/$defs/plain", "type": "string" }), + ); + assert!( + validate_for_mempool(&document_schemas, Some(&no_pattern), before_the_rule()) + .is_valid() + ); + + // The validation schema of protocol version 15 refuses such an `$id` itself + assert!(validate_for_mempool( + &document_schemas, + Some(&holder_and_plain("#/$defs/plain")), + PlatformVersion::latest() + ) + .is_valid()); + } + + #[test] + fn should_keep_a_ref_that_is_no_plain_pointer_out_of_the_mempool_before_the_rule() { + let schema_defs = definitions_with_patterns(1); + for reference in [ + // `labels`, percent-encoded, and with a tab a URL parser drops + "#/$defs/%6Cabels", + "#/$defs/lab\tels", + " #/$defs/labels", + // The document schema itself, and a part of it + "#", + "#/properties/label", + "#/$defs/labels/", + "https://example.com/schema#/$defs/labels", + ] { + let document_schemas = schemas(platform_value!({ + "type": "object", + "properties": { + "label": { "$ref": reference, "position": 0 }, + }, + "additionalProperties": false, + })); + let message = refusal_message(validate_for_mempool( + &document_schemas, + Some(&schema_defs), + before_the_rule(), + )); + assert!( + message.contains("`$ref` that is not `#/$defs/`"), + "{reference}: {message}" + ); + assert!( + validate_for_mempool(&document_schemas, None, before_the_rule()).is_valid(), + "{reference}" + ); + } + + let into_a_definition = schemas(platform_value!({ + "type": "object", + "properties": { + "label": { "$ref": "#/$defs/labels/properties/p0", "position": 0 }, + }, + "additionalProperties": false, + })); + assert!( + validate_for_mempool(&into_a_definition, Some(&schema_defs), before_the_rule()) + .is_valid() + ); + } + + #[test] + fn should_keep_pattern_properties_out_of_the_mempool_before_the_rule() { + // The document meta-schema leaves a `contains` unchecked, and the JSON Schema + // validator compiles each key of a `patternProperties` it meets there + let keys = Value::Map(vec![(Value::Text(LARGE.to_string()), platform_value!({}))]); + let document_schemas = schemas(platform_value!({ + "type": "object", + "properties": { + "tags": { + "type": "array", + "byteArray": true, + "maxItems": 2, + "contains": { "patternProperties": keys }, + "position": 0, + }, + }, + "additionalProperties": false, + })); + + let message = refusal_message(validate_for_mempool( + &document_schemas, + None, + before_the_rule(), + )); + assert!(message.contains("`patternProperties`"), "{message}"); + // A block of that protocol version accepts what it accepted + assert!(validate(&document_schemas, None, before_the_rule()).is_valid()); + + // The validation schema of protocol version 15 refuses the keyword itself, and a + // property may be named after it + let property_of_that_name = schemas(platform_value!({ + "type": "object", + "properties": { + "patternProperties": { + "type": "object", + "properties": { + "label": { "type": "string", "maxLength": 63, "position": 0 }, + }, + "additionalProperties": false, + "position": 0, + }, + }, + "additionalProperties": false, + })); + for document_schemas in [&document_schemas, &property_of_that_name] { + let platform_version = PlatformVersion::latest(); + assert!(validate_for_mempool(document_schemas, None, platform_version).is_valid()); + assert!(validate(document_schemas, None, platform_version).is_valid()); + } + } +} diff --git a/packages/rs-dpp/src/data_contract/methods/validate_schema_patterns/v0/mod.rs b/packages/rs-dpp/src/data_contract/methods/validate_schema_patterns/v0/mod.rs new file mode 100644 index 00000000000..fc8c91405a2 --- /dev/null +++ b/packages/rs-dpp/src/data_contract/methods/validate_schema_patterns/v0/mod.rs @@ -0,0 +1,313 @@ +use crate::consensus::basic::BasicError; +use crate::consensus::ConsensusError; +use crate::data_contract::document_type::schema::validation_schema::validator_regex_within; +use crate::data_contract::errors::DataContractError; +use crate::data_contract::DocumentName; +use crate::prelude::DataContract; +use crate::validation::SimpleConsensusValidationResult; +use platform_value::Value; +use platform_version::version::PlatformVersion; +use regex::RegexBuilder; +use std::collections::{BTreeMap, BTreeSet}; + +/// The key a property schema holds its pattern under. +const PATTERN: &str = "pattern"; +/// The key a `fieldMatches` entry of a contested index holds its pattern under. +const REGEX_PATTERN: &str = "regexPattern"; +const REFERENCE: &str = "$ref"; +const IDENTIFIER: &str = "$id"; +const PATTERN_PROPERTIES: &str = "patternProperties"; +const FORMAT: &str = "format"; +const REGEX_FORMAT: &str = "regex"; + +/// What compiles a pattern, each in its own dialect. +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +enum Compiler { + /// The document validator, for a `pattern`. + DocumentValidator, + /// The index parser, for a `regexPattern`. + IndexParser, +} + +impl Compiler { + fn compiles(self, pattern: &str, size_limit: usize) -> bool { + match self { + Compiler::DocumentValidator => { + validator_regex_within(pattern, Some(size_limit)).is_some() + } + Compiler::IndexParser => RegexBuilder::new(pattern) + .size_limit(size_limit) + .build() + .is_ok(), + } + } + + fn key(self) -> &'static str { + match self { + Compiler::DocumentValidator => PATTERN, + Compiler::IndexParser => REGEX_PATTERN, + } + } +} + +/// What compiles the patterns of `$defs`, which is what their count follows. +#[derive(Clone, Copy, PartialEq, Eq)] +pub(super) enum DefinitionsCount { + /// Once for each document type. The native schema check reads every definition for each + /// type it checks, and the native document validator, which keeps one compiled pattern + /// for a type however many of its `$ref`s reach it, compiles no more than those. + OncePerDocumentType, + /// Once for each document type, or once for each `$ref` reaching one where that is more: + /// the JSON Schema validator compiles what a `$ref` names when a document first reaches + /// that `$ref`, and keeps it there. It resolves a `$ref` through the `$id`s of a schema + /// before its pointer, so a contract holding a pattern is refused with a `$ref` or an + /// `$id` this count cannot follow. It also compiles each key of a `patternProperties`, + /// which the validation schema that replaces it refuses, so that is refused too. + OncePerReference, +} + +impl DefinitionsCount { + fn counted_for_each(self) -> &'static str { + match self { + DefinitionsCount::OncePerDocumentType => "document type", + DefinitionsCount::OncePerReference => "document type, or for each `$ref` to it", + } + } +} + +/// What one document schema, or one definition of `$defs`, holds. +#[derive(Default)] +struct Found<'a> { + patterns: Vec<(Compiler, &'a str)>, + /// The definition each `$ref` names. + references: Vec<&'a str>, + /// Holds a `$ref` that is no plain pointer into `$defs`, or an `$id` that is no plain + /// name: the JSON Schema validator may resolve a `$ref` elsewhere than its pointer names. + moves_a_reference: bool, + holds_pattern_properties: bool, + declares_regex_format: bool, +} + +impl<'a> Found<'a> { + /// Every string `root` holds under one of the keys above, at any depth. Not recursive: + /// nothing has bounded the depth of the value yet. + fn within(root: &'a Value) -> Self { + let mut found = Found::default(); + let mut pending = vec![root]; + while let Some(value) = pending.pop() { + match value { + Value::Map(entries) => { + for (key, inner) in entries { + if key.as_text() == Some(PATTERN_PROPERTIES) + && matches!(inner, Value::Map(keys) if !keys.is_empty()) + { + found.holds_pattern_properties = true; + } + if let (Some(key), Value::Text(text)) = (key.as_text(), inner) { + match key { + PATTERN => found.patterns.push((Compiler::DocumentValidator, text)), + REGEX_PATTERN => found.patterns.push((Compiler::IndexParser, text)), + REFERENCE => match referenced_definition(text) { + Some(definition) => found.references.push(definition), + None => found.moves_a_reference = true, + }, + IDENTIFIER if !is_plain_name(text) => { + found.moves_a_reference = true + } + FORMAT if text == REGEX_FORMAT => { + found.declares_regex_format = true + } + _ => {} + } + } + } + pending.extend(entries.iter().rev().map(|(_, inner)| inner)); + } + Value::Array(items) => pending.extend(items.iter().rev()), + _ => {} + } + } + found + } +} + +/// The definition a `$ref` names, when it is a plain pointer into `$defs`: one a URL parser +/// and a JSON pointer both read as it is written. +fn referenced_definition(reference: &str) -> Option<&str> { + let pointer = reference.strip_prefix("#/$defs/")?; + let name = pointer.split('/').next()?; + pointer.split('/').all(is_plain_name).then_some(name) +} + +/// What an `$id` must be for the JSON Schema validator to resolve no `$ref` through it or +/// against it, as the validation schema of protocol version 15 requires of one. +fn is_plain_name(name: &str) -> bool { + !name.is_empty() + && name + .bytes() + .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b'-' | b'.' | b'$')) +} + +/// The definitions of `$defs`. +struct Definitions<'a> { + definitions: BTreeMap<&'a str, Found<'a>>, + /// Every pattern the definitions hold. + patterns: usize, +} + +impl<'a> Definitions<'a> { + fn new(schema_defs: Option<&'a BTreeMap>) -> Self { + let definitions: BTreeMap<&str, Found> = schema_defs + .into_iter() + .flatten() + .map(|(name, definition)| (name.as_str(), Found::within(definition))) + .collect(); + let patterns = definitions.values().map(|found| found.patterns.len()).sum(); + Definitions { + definitions, + patterns, + } + } + + /// For each definition, how many patterns compiling what a `$ref` to it names compiles, + /// when each `$ref` met on the way compiles what it names in turn: its own, and those of + /// every `$ref` it holds. Counted up to `ceiling` and no further, which a cycle of + /// definitions reaching a pattern arrives at. + fn patterns_compiled_through_each(&self, ceiling: usize) -> BTreeMap<&'a str, usize> { + let mut compiled: BTreeMap<&str, usize> = BTreeMap::new(); + let mut referrers: BTreeMap<&str, Vec<&str>> = BTreeMap::new(); + // Each count still to add to what the definitions referring to one compile + let mut pending: Vec<(&str, usize)> = Vec::new(); + for (&name, found) in &self.definitions { + for &definition in &found.references { + referrers.entry(definition).or_default().push(name); + } + let own = found.patterns.len().min(ceiling); + compiled.insert(name, own); + if own > 0 { + pending.push((name, own)); + } + } + // Every step raises a count below the ceiling by at least one, so this ends + while let Some((name, added)) = pending.pop() { + for &referrer in referrers.get(name).into_iter().flatten() { + let Some(count) = compiled.get_mut(referrer) else { + continue; + }; + let raised = count.saturating_add(added).min(ceiling); + if raised > *count { + pending.push((referrer, raised - *count)); + *count = raised; + } + } + } + compiled + } +} + +impl DataContract { + /// Refuses more than `max_contract_schema_patterns` patterns without compiling any, then + /// the first that does not compile within `max_schema_pattern_compiled_size`, each + /// distinct pattern compiled once. With `refuse_regex_format`, also refuses a schema + /// declaring `format: regex`. + #[inline(always)] + pub(super) fn validate_schema_patterns_v0( + document_schemas: &BTreeMap, + schema_defs: Option<&BTreeMap>, + definitions_count: DefinitionsCount, + refuse_regex_format: bool, + platform_version: &PlatformVersion, + ) -> SimpleConsensusValidationResult { + let max_patterns = usize::from(platform_version.system_limits.max_contract_schema_patterns); + let size_limit = platform_version + .system_limits + .max_schema_pattern_compiled_size as usize; + + let definitions = Definitions::new(schema_defs); + let document_types: Vec = document_schemas.values().map(Found::within).collect(); + + // One past the limit is as far as a count needs to go to be refused + let ceiling = max_patterns.saturating_add(1); + let compiled_through_each = match definitions_count { + DefinitionsCount::OncePerDocumentType => None, + DefinitionsCount::OncePerReference => { + Some(definitions.patterns_compiled_through_each(ceiling)) + } + }; + // The definitions' patterns count once in a contract with no document type + let mut count = if document_types.is_empty() { + definitions.patterns + } else { + 0 + }; + for document_type in &document_types { + let of_definitions = match &compiled_through_each { + None => definitions.patterns, + Some(compiled_through_each) => document_type + .references + .iter() + .map(|definition| compiled_through_each.get(definition).copied().unwrap_or(0)) + .fold(0usize, usize::saturating_add) + .max(definitions.patterns), + }; + count = count + .saturating_add(document_type.patterns.len()) + .saturating_add(of_definitions); + } + if count > max_patterns { + return refusal(format!( + "the document schemas and `$defs` of a contract may hold at most {max_patterns} \ + patterns (`{PATTERN}` and `{REGEX_PATTERN}`), one in `$defs` counted for each {}", + definitions_count.counted_for_each() + )); + } + + let schemas = || { + document_types + .iter() + .chain(definitions.definitions.values()) + }; + if definitions_count == DefinitionsCount::OncePerReference + && schemas().any(|found| found.holds_pattern_properties) + { + return refusal(format!( + "a schema holding `{PATTERN_PROPERTIES}` is not accepted: the JSON Schema \ + validator compiles each of its keys as a pattern, which is not counted" + )); + } + if definitions_count == DefinitionsCount::OncePerReference + && count > 0 + && schemas().any(|found| found.moves_a_reference) + { + return refusal(format!( + "a contract holding a pattern is not accepted with a `{REFERENCE}` that is not \ + `#/$defs/` and a definition's name, or an `{IDENTIFIER}` that is not a plain \ + name: what the JSON Schema validator compiles through either is not counted" + )); + } + if refuse_regex_format && schemas().any(|found| found.declares_regex_format) { + return refusal(format!( + "a schema declaring `{FORMAT}: {REGEX_FORMAT}` is not accepted: every value of \ + such a property is compiled as a pattern when a document is checked" + )); + } + + let mut compiled = BTreeSet::new(); + for &(compiler, pattern) in schemas().flat_map(|found| &found.patterns) { + if compiled.insert((compiler, pattern)) && !compiler.compiles(pattern, size_limit) { + return refusal(format!( + "the `{}` `{pattern}` is not a regular expression that compiles within \ + {size_limit} bytes", + compiler.key() + )); + } + } + SimpleConsensusValidationResult::new() + } +} + +fn refusal(message: String) -> SimpleConsensusValidationResult { + SimpleConsensusValidationResult::new_with_error(ConsensusError::BasicError( + BasicError::ContractError(DataContractError::InvalidContractStructure(message)), + )) +} diff --git a/packages/rs-dpp/src/data_contract/mod.rs b/packages/rs-dpp/src/data_contract/mod.rs index e2c7736ab6f..85c6441b16c 100644 --- a/packages/rs-dpp/src/data_contract/mod.rs +++ b/packages/rs-dpp/src/data_contract/mod.rs @@ -290,6 +290,24 @@ impl DataContract { let carried_size = carried_size.unwrap_or(bytes.len()); Ok((bytes, carried_size)) } + + /// The bytes [`PlatformSerializableWithPlatformVersion::serialize_to_bytes_with_platform_version`] + /// gives for the contract a node stored as `storage_bytes`, read as + /// [`PlatformDeserializableWithPotentialValidationFromVersionedStructureTrusted::versioned_deserialize_trusted`] + /// reads it without full validation, but without parsing the contract: a stored revision in + /// schema form would build every document type, its patterns compiled, each time it is + /// read. For a query that answers with stored contracts it does not otherwise use. + pub fn carried_bytes_from_storage_bytes( + storage_bytes: &[u8], + platform_version: &PlatformVersion, + ) -> Result, ProtocolError> { + let (stored, _) = + decode_serialization_format_trusted(storage_bytes, no_limit_config(), "DataContract")?; + let carried = stored.try_into_carried_format(platform_version)?; + bincode::encode_to_vec(carried, PLATFORM_BINCODE_CONFIG).map_err(|e| { + PlatformSerializationError(format!("unable to serialize DataContract: {}", e)) + }) + } } /// Decodes the stored serialization format with the ordinary decoder: bytes @@ -796,3 +814,121 @@ mod compiled_size_tests { assert!(operations.is_empty()); } } + +#[cfg(test)] +mod carried_bytes_tests { + use super::*; + use crate::data_contract::serialized_version::v0::DataContractInSerializationFormatV0; + use crate::data_contract::serialized_version::v1::DataContractInSerializationFormatV1; + use crate::tests::fixtures::get_data_contract_fixture; + use platform_value::Value; + use platform_version::version::PLATFORM_VERSIONS; + use std::collections::BTreeSet; + + fn fixture_contract() -> DataContract { + get_data_contract_fixture(None, 0, PlatformVersion::latest().protocol_version) + .data_contract_owned() + } + + fn encode(format: DataContractInSerializationFormat) -> Vec { + bincode::encode_to_vec(format, PLATFORM_BINCODE_CONFIG).expect("expected to encode") + } + + /// The fixture contract in each format a node has stored a contract in: format versions 0 + /// and 1 in schema form, 1 with the fields only it holds and keywords to lowercase, and 2, + /// compiled. + fn stored_forms() -> Vec<(&'static str, Vec)> { + let contract = fixture_contract(); + let format_v1 = DataContractInSerializationFormatV1::from(contract.clone()); + let mut format_v1_with_its_fields = format_v1.clone(); + format_v1_with_its_fields.created_at = Some(1_700_000_000_000); + format_v1_with_its_fields.created_at_block_height = Some(12); + format_v1_with_its_fields.keywords = vec!["Social".to_string(), "PAY".to_string()]; + format_v1_with_its_fields.description = Some("A contract".to_string()); + let compiled = contract + .serialize_to_storage_bytes(PlatformVersion::latest()) + .expect("expected to store the contract"); + assert!( + matches!( + decode_serialization_format_trusted(&compiled, no_limit_config(), "DataContract") + .expect("expected to decode") + .0, + DataContractInSerializationFormat::V2(_) + ), + "the latest version stores contracts compiled" + ); + vec![ + ( + "format version 0", + encode(DataContractInSerializationFormatV0::from(contract).into()), + ), + ("format version 1", encode(format_v1.into())), + ( + "format version 1 with its own fields", + encode(format_v1_with_its_fields.into()), + ), + ("format version 2", compiled), + ] + } + + #[test] + fn should_carry_a_stored_contract_as_reading_and_serializing_it_does() { + let mut compared = BTreeSet::new(); + for (form, stored) in stored_forms() { + for platform_version in PLATFORM_VERSIONS { + let version = platform_version.protocol_version; + // A version that can not read the contract, or carry it, is not compared + let Ok(contract) = + DataContract::versioned_deserialize_trusted(&stored, false, platform_version) + else { + continue; + }; + let Ok(expected) = + contract.serialize_to_bytes_with_platform_version(platform_version) + else { + continue; + }; + let carried = + DataContract::carried_bytes_from_storage_bytes(&stored, platform_version) + .unwrap_or_else(|e| panic!("{form} at protocol version {version}: {e}")); + assert_eq!(carried, expected, "{form} at protocol version {version}"); + compared.insert((form, version)); + } + } + let latest = PlatformVersion::latest().protocol_version; + let first = PlatformVersion::first().protocol_version; + for (form, _) in stored_forms() { + assert!( + compared.contains(&(form, latest)), + "{form} is compared at the latest version" + ); + assert!( + compared.contains(&(form, first)), + "{form} is compared at the first version, which carries format version 0" + ); + } + } + + #[test] + fn should_carry_a_stored_contract_without_parsing_its_schemas() { + let latest = PlatformVersion::latest(); + let mut format_v1 = DataContractInSerializationFormatV1::from(fixture_contract()); + let broken = Value::Text("not a schema".to_string()); + format_v1 + .document_schemas + .insert("broken".to_string(), broken.clone()); + let stored = encode(format_v1.into()); + assert!( + DataContract::versioned_deserialize_trusted(&stored, false, latest).is_err(), + "reading the contract parses its schemas" + ); + + let carried = DataContract::carried_bytes_from_storage_bytes(&stored, latest) + .expect("expected to carry the contract without parsing it"); + + let (carried, _) = + decode_serialization_format_trusted(&carried, no_limit_config(), "DataContract") + .expect("expected to decode"); + assert_eq!(carried.document_schemas().get("broken"), Some(&broken)); + } +} diff --git a/packages/rs-dpp/src/data_contract/serialized_version/mod.rs b/packages/rs-dpp/src/data_contract/serialized_version/mod.rs index cb981d41814..6672db279b5 100644 --- a/packages/rs-dpp/src/data_contract/serialized_version/mod.rs +++ b/packages/rs-dpp/src/data_contract/serialized_version/mod.rs @@ -381,6 +381,104 @@ impl DataContractInSerializationFormat { }), } } + + /// The contract in the format state transitions, query responses and clients carry at + /// `platform_version` (`contract_serialization_version`), as reading it into a + /// [`DataContract`] without full validation and converting that contract back gives it, + /// without parsing its document schemas: reading them builds every document type, its + /// patterns compiled. The fields the contract structure of `platform_version` holds are + /// kept (format version 2 its format version 1, keywords lowercased), the config lowered + /// to what `platform_version` admits, and the document schemas and `$defs` kept as given, + /// as a document type keeps its schema. Unlike reading it, this refuses no schema that does + /// not parse at `platform_version`. + pub(in crate::data_contract) fn try_into_carried_format( + self, + platform_version: &PlatformVersion, + ) -> Result { + let mut format_v1 = match self { + DataContractInSerializationFormat::V0(v0) => DataContractInSerializationFormatV1 { + id: v0.id, + config: v0.config, + version: v0.version, + owner_id: v0.owner_id, + schema_defs: v0.schema_defs, + document_schemas: v0.document_schemas, + created_at: None, + updated_at: None, + created_at_block_height: None, + updated_at_block_height: None, + created_at_epoch: None, + updated_at_epoch: None, + groups: Default::default(), + tokens: Default::default(), + keywords: Default::default(), + description: None, + }, + DataContractInSerializationFormat::V1(v1) => v1, + DataContractInSerializationFormat::V2(v2) => v2.into(), + }; + match platform_version + .dpp + .contract_versions + .contract_structure_version + { + // DataContractV0 holds none of format version 1's own fields + 0 => { + format_v1.created_at = None; + format_v1.updated_at = None; + format_v1.created_at_block_height = None; + format_v1.updated_at_block_height = None; + format_v1.created_at_epoch = None; + format_v1.updated_at_epoch = None; + format_v1.groups = Default::default(); + format_v1.tokens = Default::default(); + format_v1.keywords = Default::default(); + format_v1.description = None; + } + 1 => { + format_v1.keywords = std::mem::take(&mut format_v1.keywords) + .into_iter() + .map(|keyword| keyword.to_lowercase()) + .collect(); + } + version => { + return Err(ProtocolError::UnknownVersionMismatch { + method: "DataContractInSerializationFormat::try_into_carried_format" + .to_string(), + known_versions: vec![0, 1], + received: version, + }) + } + } + format_v1 + .config + .ensure_admitted_by_platform_version(platform_version)?; + format_v1.config = format_v1 + .config + .config_valid_for_platform_version(platform_version); + match platform_version + .dpp + .contract_versions + .contract_serialization_version + .default_current_version + { + 0 => Ok(DataContractInSerializationFormatV0 { + id: format_v1.id, + config: format_v1.config, + version: format_v1.version, + owner_id: format_v1.owner_id, + schema_defs: format_v1.schema_defs, + document_schemas: format_v1.document_schemas, + } + .into()), + 1 => Ok(format_v1.into()), + version => Err(ProtocolError::UnknownVersionMismatch { + method: "DataContractInSerializationFormat::try_into_carried_format".to_string(), + known_versions: vec![0, 1], + received: version, + }), + } + } } impl TryFromPlatformVersioned for DataContractInSerializationFormat { diff --git a/packages/rs-dpp/tests/contract_corpus.rs b/packages/rs-dpp/tests/contract_corpus.rs index 53404ac21d2..3c91252939b 100644 --- a/packages/rs-dpp/tests/contract_corpus.rs +++ b/packages/rs-dpp/tests/contract_corpus.rs @@ -17,6 +17,7 @@ use dpp::serialization::{ PlatformSerializableWithPlatformVersion, }; use dpp::version::PlatformVersion; +use std::collections::BTreeMap; /// Loads a stored contract the way Drive does: trusted bytes, no full validation. fn load(contract: &CorpusContract, platform_version: &PlatformVersion) -> DataContract { @@ -83,6 +84,40 @@ fn should_load_every_corpus_contract_at_the_latest_protocol_version() { } } +/// No contract registered on either network holds more patterns, or a larger one, than +/// consensus admits from protocol version 15, or than a mempool admits before it, where it +/// also keeps out a schema declaring `format: regex`. +#[test] +fn should_hold_every_corpus_contract_within_the_schema_pattern_bounds() { + let latest = PlatformVersion::latest(); + let before_the_rule = PlatformVersion::get(14).expect("expected protocol version 14"); + for contract in contracts() { + let loaded = load(&contract, latest); + let document_schemas: BTreeMap = loaded + .document_schemas() + .into_iter() + .map(|(name, schema)| (name, schema.clone())) + .collect(); + for result in [ + DataContract::validate_schema_patterns(&document_schemas, loaded.schema_defs(), latest), + DataContract::validate_schema_patterns_for_mempool( + &document_schemas, + loaded.schema_defs(), + before_the_rule, + ), + ] { + let result = result.expect("expected the pattern bound to run"); + assert!( + result.is_valid(), + "{:?} contract {} is over the pattern bound: {:?}", + contract.network, + contract.id, + result.errors + ); + } + } +} + #[test] fn should_reload_every_corpus_contract_reserialized_at_the_latest_protocol_version() { let platform_version = PlatformVersion::latest(); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs index b7034f1248a..48171b1ac7c 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs @@ -39,6 +39,7 @@ use crate::execution::validation::state_transition::ValidationMode; use crate::execution::validation::state_transition::processor::traits::address_balances_and_nonces::StateTransitionAddressBalancesAndNoncesValidation; use crate::execution::validation::state_transition::batch::BatchTransitionCheckTxStateValidatingTransformer; use crate::execution::validation::state_transition::identity_update::added_key_proofs_of_possession::v0::IdentityUpdateAddedKeyProofsOfPossessionValidationV0; +use crate::execution::validation::state_transition::state_transitions::data_contract_common::check_tx_schema_patterns::validate_contract_schema_patterns_for_check_tx; use drive::state_transition_action::StateTransitionAction; use std::collections::BTreeMap; use dpp::address_funds::PlatformAddress; @@ -260,6 +261,23 @@ pub(super) fn state_transition_to_execution_event_for_check_tx_v0<'a, C: CoreRPC None }; + // A contract create or update is held to the mempool's pattern bound before the + // balance pre-check estimates its registration fee: before protocol version 15 the + // estimate parses every index, compiling each `regexPattern` of a contested index, + // and nothing has bounded how many there are or how large they compile. After the + // signature, so only the holder of an identity's key has a contract's patterns + // read. Mempool policy, as the bound describes; block execution never runs this + // function. + let result = + validate_contract_schema_patterns_for_check_tx(state_transition, platform_version)?; + if !result.is_valid() { + return Ok( + ConsensusValidationResult::>::new_with_errors( + result.errors, + ), + ); + } + // For identity credit withdrawal and identity credit transfers we have a balance pre check that includes a // processing amount and the transfer amount. // For other state transitions we only check a min balance for an amount set per version. @@ -631,6 +649,20 @@ pub(super) fn state_transition_to_execution_event_for_check_tx_v0<'a, C: CoreRPC } None => false, }; + + // As on the first check, before the non-validating parse compiles the patterns + let result = validate_contract_schema_patterns_for_check_tx( + state_transition, + platform_version, + )?; + if !result.is_valid() { + return Ok( + ConsensusValidationResult::>::new_with_errors( + result.errors, + ), + ); + } + let state_transition_action_result = transform_into_action_for_check_tx( state_transition, platform, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/check_tx_schema_patterns.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/check_tx_schema_patterns.rs new file mode 100644 index 00000000000..dd0e7fd1afc --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/check_tx_schema_patterns.rs @@ -0,0 +1,35 @@ +//! The pattern bound `check_tx` holds a contract to before anything compiles its patterns. + +use dpp::data_contract::DataContract; +use dpp::state_transition::data_contract_create_transition::accessors::DataContractCreateTransitionAccessorsV0; +use dpp::state_transition::data_contract_update_transition::accessors::DataContractUpdateTransitionAccessorsV0; +use dpp::state_transition::StateTransition; +use dpp::validation::SimpleConsensusValidationResult; +use dpp::version::PlatformVersion; +use dpp::ProtocolError; + +/// Holds the patterns of the contract a create or update carries to +/// `DataContract::validate_schema_patterns_for_mempool`. Any other transition passes. +/// +/// `check_tx` runs this before the identity balance pre-check and `recheck_tx` before the +/// transformer. Before protocol version 15 the pre-check estimates the registration fee by +/// parsing every index, which compiles each `regexPattern` of a contested index, and at every +/// version the transformer's non-validating parse compiles every pattern. Neither refuses a +/// pattern for how many there are or how large it compiles. +/// +/// Mempool only: it keeps out a contract a block may still accept, as that method describes. +pub(in crate::execution) fn validate_contract_schema_patterns_for_check_tx( + state_transition: &StateTransition, + platform_version: &PlatformVersion, +) -> Result { + let contract = match state_transition { + StateTransition::DataContractCreate(create) => create.data_contract(), + StateTransition::DataContractUpdate(update) => update.data_contract(), + _ => return Ok(SimpleConsensusValidationResult::new()), + }; + DataContract::validate_schema_patterns_for_mempool( + contract.document_schemas(), + contract.schema_defs(), + platform_version, + ) +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/contract_structure_test_harness.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/contract_structure_test_harness.rs index 4e769201c17..5661dc44344 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/contract_structure_test_harness.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/contract_structure_test_harness.rs @@ -193,6 +193,86 @@ pub(in crate::execution) fn add_ref_dag_document_type( schemas.insert("item_summed_u64".to_string(), summed_u64_schema()); } +/// The fragment of the pattern bound's message for a contract holding too many patterns. +pub(in crate::execution) const TOO_MANY_PATTERNS_MESSAGE: &str = "patterns (`pattern` and"; + +/// The fragment of the pattern bound's message for a pattern that compiles to too much. +pub(in crate::execution) const PATTERN_TOO_LARGE_MESSAGE: &str = + "is not a regular expression that compiles within"; + +/// A pattern any limit admits. +pub(in crate::execution) const SMALL_PATTERN: &str = "^[a-z]{1,20}$"; + +/// One pattern more than a contract may hold. +pub(in crate::execution) fn one_pattern_too_many() -> usize { + usize::from( + PlatformVersion::latest() + .system_limits + .max_contract_schema_patterns, + ) + 1 +} + +/// A document type of `count` string properties, each with `pattern`. +pub(in crate::execution) fn patterned_schema(count: usize, pattern: &str) -> Value { + let properties: Vec<(Value, Value)> = (0..count) + .map(|position| { + ( + Value::Text(format!("p{position}")), + platform_value!({ + "type": "string", + "pattern": pattern, + "maxLength": 63, + "position": position as u64, + }), + ) + }) + .collect(); + platform_value!({ + "type": "object", + "properties": Value::Map(properties), + "additionalProperties": false, + }) +} + +/// A document type whose one index lists `count` contested field matches of `pattern`, then a +/// key no index has: the non-validating parse compiles every one of them before it refuses the +/// key, with an error of its own. +pub(in crate::execution) fn field_matches_before_an_unknown_index_key_schema( + count: usize, + pattern: &str, +) -> Value { + let field_matches: Vec = (0..count) + .map(|_| platform_value!({ "field": "label", "regexPattern": pattern })) + .collect(); + platform_value!({ + "type": "object", + "properties": { + "label": { "type": "string", "maxLength": 63, "position": 0 }, + }, + "indices": [{ + "contested": { "fieldMatches": field_matches }, + "notAnIndexKey": 1, + }], + "additionalProperties": false, + }) +} + +/// A document type with one `format: regex` string property. +pub(in crate::execution) fn regex_format_schema() -> Value { + platform_value!({ + "type": "object", + "properties": { + "expression": { + "type": "string", + "format": "regex", + "maxLength": 63, + "position": 0, + }, + }, + "additionalProperties": false, + }) +} + /// What `check_tx` and one block made of a transition. pub(in crate::execution) struct Outcome { /// The consensus errors `check_tx` refused the transition with, or its own error. @@ -387,6 +467,29 @@ pub(in crate::execution) fn assert_paid_contract_structure_error_in_block( ); } +/// A contract mempool policy keeps out and consensus still admits: `check_tx` refuses the +/// transition with the pattern bound's `InvalidContractStructure`, and a block that holds it +/// all the same executes it. +pub(in crate::execution) fn assert_kept_out_of_the_mempool_and_executed_in_block( + outcome: &Outcome, + needle: &str, +) { + assert_matches!( + outcome.check_tx.as_deref(), + Ok([ConsensusError::BasicError(BasicError::ContractError( + DataContractError::InvalidContractStructure(message) + ))]) if message.contains(needle), + "check_tx: {:?}", + outcome.check_tx + ); + assert_matches!( + &outcome.block, + StateTransitionExecutionResult::SuccessfulExecution { .. }, + "block: {:?}", + outcome.block + ); +} + /// A paid rejection of a `$defs` graph reaching one definition along two paths: `check_tx` /// refuses it with the schema depth check's cycle error before its non-validating parse would /// expand the graph, and the block charges the owner for the same error and bumps the nonce to diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/mod.rs index da1a9d5347e..9ea8eae57bb 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/mod.rs @@ -1,6 +1,9 @@ /// The schema depth check `check_tx` runs before parsing a contract. pub(in crate::execution) mod check_tx_schema_depth; +/// The pattern bound `check_tx` holds a contract to before estimating its fee or parsing it. +pub(in crate::execution) mod check_tx_schema_patterns; + /// Validation of the reference declarations a contract's document types carry. pub mod data_contract_reference_validation; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/contract_structure_error_tests.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/contract_structure_error_tests.rs index 5413aa8c88f..423f1120c43 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/contract_structure_error_tests.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/contract_structure_error_tests.rs @@ -2,13 +2,17 @@ //! document meta-schema, through `check_tx` and block processing. use crate::execution::validation::state_transition::state_transitions::data_contract_common::contract_structure_test_harness::{ - add_ref_dag_document_type, add_token_with_trade_mode, assert_paid_contract_structure_error, + add_ref_dag_document_type, add_token_with_trade_mode, + assert_kept_out_of_the_mempool_and_executed_in_block, assert_paid_contract_structure_error, assert_paid_contract_structure_error_in_block, assert_paid_ref_cycle_error, assert_refused_unpaid_as_not_active, assert_unpaid_internal_error, check_and_process, - contested_unbounded_sum_schema, expiring_unbounded_sum_schema, resign_with_contract, - summed_u64_schema, terminal_without_index_only_schema, Outcome, - CONTESTED_UNBOUNDED_SUM_MESSAGE, EXPIRING_UNBOUNDED_SUM_MESSAGE, SUMMED_U64_MESSAGE, - TERMINAL_WITHOUT_INDEX_ONLY_MESSAGE, + contested_unbounded_sum_schema, expiring_unbounded_sum_schema, + field_matches_before_an_unknown_index_key_schema, one_pattern_too_many, patterned_schema, + regex_format_schema, + resign_with_contract, summed_u64_schema, terminal_without_index_only_schema, Outcome, + CONTESTED_UNBOUNDED_SUM_MESSAGE, EXPIRING_UNBOUNDED_SUM_MESSAGE, PATTERN_TOO_LARGE_MESSAGE, + SMALL_PATTERN, SUMMED_U64_MESSAGE, TERMINAL_WITHOUT_INDEX_ONLY_MESSAGE, + TOO_MANY_PATTERNS_MESSAGE, }; use crate::execution::validation::state_transition::state_transitions::tests::setup_identity; use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult; @@ -16,6 +20,7 @@ use crate::rpc::core::MockCoreRPCLike; use crate::test::helpers::setup::{TempPlatform, TestPlatformBuilder}; use assert_matches::assert_matches; use dpp::consensus::basic::BasicError; +use dpp::consensus::state::state_error::StateError; use dpp::consensus::ConsensusError; use dpp::dash_to_credits; use dpp::data_contract::associated_token::token_marketplace_rules::v0::TokenTradeMode; @@ -578,3 +583,140 @@ async fn should_register_a_contract_with_a_token_that_is_not_tradeable_at_protoc outcome.block ); } + +/// Unicode letters, twenty times: more than a pattern may compile to, though under the 5 and +/// 10 MiB the parsers compile one within. +const LARGE_PATTERN: &str = r"^\pL{20}$"; + +#[tokio::test] +async fn should_refuse_more_patterns_than_a_contract_may_hold_with_a_paid_consensus_error() { + let registration = register_contract_with_schema( + patterned_schema(one_pattern_too_many(), SMALL_PATTERN), + PlatformVersion::latest().protocol_version, + ) + .await; + + assert_paid_contract_structure_error(®istration.outcome, TOO_MANY_PATTERNS_MESSAGE, 1); +} + +#[tokio::test] +async fn should_refuse_a_pattern_over_the_compiled_size_limit_with_a_paid_consensus_error() { + let registration = register_contract_with_schema( + patterned_schema(1, LARGE_PATTERN), + PlatformVersion::latest().protocol_version, + ) + .await; + + assert_paid_contract_structure_error(®istration.outcome, PATTERN_TOO_LARGE_MESSAGE, 1); +} + +/// `check_tx` runs the pattern bound before its non-validating parse, which would compile +/// every field match, each to megabytes, and then refuse the index with an error of its own. +/// The block refuses the contract for its patterns too, and charges for it. +#[tokio::test] +async fn should_refuse_field_matches_over_the_bound_in_check_tx_before_the_parse_compiles_them() { + let registration = register_contract_with_schema_and_balance( + field_matches_before_an_unknown_index_key_schema(one_pattern_too_many(), r"\w{200}"), + PlatformVersion::latest().protocol_version, + // A contested index costs a registration fee the default balance does not cover + dash_to_credits!(2.0), + ) + .await; + + assert_paid_contract_structure_error(®istration.outcome, TOO_MANY_PATTERNS_MESSAGE, 1); +} + +/// The balance pre-check estimates the registration fee before the contract is parsed. +/// `check_tx` holds the patterns to the bound before it, so an owner who cannot pay is refused +/// for the patterns. The block's estimate bills the contested index by its keys, without +/// compiling a field match, and refuses the owner, unpaid, for the balance. +#[tokio::test] +async fn should_refuse_field_matches_over_the_bound_before_the_balance_pre_check() { + let registration = register_contract_with_schema( + field_matches_before_an_unknown_index_key_schema(one_pattern_too_many(), r"\w{200}"), + PlatformVersion::latest().protocol_version, + ) + .await; + let outcome = ®istration.outcome; + + assert_matches!( + outcome.check_tx.as_deref(), + Ok([ConsensusError::BasicError(BasicError::ContractError( + DataContractError::InvalidContractStructure(message) + ))]) if message.contains(TOO_MANY_PATTERNS_MESSAGE), + "check_tx: {:?}", + outcome.check_tx + ); + assert_matches!( + &outcome.block, + StateTransitionExecutionResult::UnpaidConsensusError(ConsensusError::StateError( + StateError::IdentityInsufficientBalanceError(_) + )), + "block: {:?}", + outcome.block + ); + assert_eq!(outcome.nonce_after, outcome.nonce_before); + assert_eq!(outcome.balance_after, outcome.balance_before); +} + +/// Protocol version 14 has no pattern bound in consensus, so a block still registers what it +/// registered, while `check_tx` keeps it out of the mempool. +#[tokio::test] +async fn should_keep_registering_patterns_over_the_bound_at_protocol_version_14_outside_the_mempool( +) { + for (schema, message) in [ + ( + patterned_schema(one_pattern_too_many(), SMALL_PATTERN), + TOO_MANY_PATTERNS_MESSAGE, + ), + ( + patterned_schema(1, LARGE_PATTERN), + PATTERN_TOO_LARGE_MESSAGE, + ), + ] { + let registration = register_contract_with_schema(schema, 14).await; + + assert_kept_out_of_the_mempool_and_executed_in_block(®istration.outcome, message); + } +} + +/// Before protocol version 15 every value of a `format: regex` property is compiled as a +/// pattern when a document is checked, so `check_tx` keeps a contract declaring one out of the +/// mempool, and a block registers it as before. From 15 a value's syntax is checked without +/// compiling it, and the mempool admits the contract. +#[tokio::test] +async fn should_keep_a_regex_format_out_of_the_mempool_before_protocol_version_15() { + let registration = register_contract_with_schema(regex_format_schema(), 14).await; + assert_kept_out_of_the_mempool_and_executed_in_block(®istration.outcome, "`format: regex`"); + + let registration = register_contract_with_schema( + regex_format_schema(), + PlatformVersion::latest().protocol_version, + ) + .await; + assert_matches!( + registration.outcome.check_tx.as_deref(), + Ok([]), + "check_tx: {:?}", + registration.outcome.check_tx + ); + assert_matches!( + registration.outcome.block, + StateTransitionExecutionResult::SuccessfulExecution { .. } + ); +} + +#[tokio::test] +async fn should_register_a_contract_holding_as_many_patterns_as_it_may() { + let registration = register_contract_with_schema( + patterned_schema(one_pattern_too_many() - 1, SMALL_PATTERN), + PlatformVersion::latest().protocol_version, + ) + .await; + + assert_matches!(registration.outcome.check_tx.as_deref(), Ok([])); + assert_matches!( + registration.outcome.block, + StateTransitionExecutionResult::SuccessfulExecution { .. } + ); +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/contract_structure_error_tests.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/contract_structure_error_tests.rs index 5f4505a53cd..eed2de4d24c 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/contract_structure_error_tests.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/contract_structure_error_tests.rs @@ -2,12 +2,14 @@ //! through `check_tx` and block processing. use crate::execution::validation::state_transition::state_transitions::data_contract_common::contract_structure_test_harness::{ - add_ref_dag_document_type, add_token_with_trade_mode, assert_paid_contract_structure_error, + add_ref_dag_document_type, add_token_with_trade_mode, + assert_kept_out_of_the_mempool_and_executed_in_block, assert_paid_contract_structure_error, assert_paid_contract_structure_error_in_block, assert_paid_ref_cycle_error, assert_refused_unpaid_as_not_active, assert_unpaid_internal_error, check_and_process, - expiring_summed_schema, resign_with_contract, summed_u64_schema, - terminal_without_index_only_schema, Outcome, EXPIRING_UNBOUNDED_SUM_MESSAGE, - SUMMED_U64_MESSAGE, TERMINAL_WITHOUT_INDEX_ONLY_MESSAGE, + expiring_summed_schema, one_pattern_too_many, patterned_schema, resign_with_contract, + summed_u64_schema, terminal_without_index_only_schema, Outcome, + EXPIRING_UNBOUNDED_SUM_MESSAGE, SMALL_PATTERN, SUMMED_U64_MESSAGE, + TERMINAL_WITHOUT_INDEX_ONLY_MESSAGE, TOO_MANY_PATTERNS_MESSAGE, }; use crate::execution::validation::state_transition::state_transitions::tests::setup_identity; use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult; @@ -385,3 +387,25 @@ async fn should_admit_an_update_adding_a_token_that_is_not_tradeable_at_protocol outcome.check_tx ); } + +#[tokio::test] +async fn should_refuse_an_update_adding_more_patterns_than_a_contract_may_hold() { + let outcome = update_contract_adding_schema( + patterned_schema(one_pattern_too_many(), SMALL_PATTERN), + PlatformVersion::latest().protocol_version, + ) + .await; + + assert_paid_contract_structure_error(&outcome, TOO_MANY_PATTERNS_MESSAGE, UPDATE_NONCE); +} + +/// Protocol version 14 has no pattern bound in consensus, so a block still applies the update, +/// while `check_tx` keeps it out of the mempool. +#[tokio::test] +async fn should_keep_applying_an_update_adding_patterns_over_the_bound_at_protocol_version_14() { + let outcome = + update_contract_adding_schema(patterned_schema(one_pattern_too_many(), SMALL_PATTERN), 14) + .await; + + assert_kept_out_of_the_mempool_and_executed_in_block(&outcome, TOO_MANY_PATTERNS_MESSAGE); +} diff --git a/packages/rs-drive-abci/src/query/contract_cache_tests.rs b/packages/rs-drive-abci/src/query/contract_cache_tests.rs new file mode 100644 index 00000000000..d143411c5df --- /dev/null +++ b/packages/rs-drive-abci/src/query/contract_cache_tests.rs @@ -0,0 +1,153 @@ +//! A contract stored as its schemas is parsed each time it is read from state, every pattern +//! it holds compiled. So a query that reads a contract reads it through the contract cache and +//! caches it on a miss, also when it refuses the request once it has read the contract. + +use crate::query::tests::{setup_platform, store_data_contract}; +use dapi_grpc::platform::v0::get_contract_document_removals_request::get_contract_document_removals_request_v0::Selection; +use dapi_grpc::platform::v0::get_contract_document_removals_request::{ + GetContractDocumentRemovalsRequestV0, Page, +}; +use dapi_grpc::platform::v0::get_contract_fee_pots_request::GetContractFeePotsRequestV0; +use dapi_grpc::platform::v0::get_contract_moderation_status_request::GetContractModerationStatusRequestV0; +use dapi_grpc::platform::v0::get_private_document_entries_request::GetPrivateDocumentEntriesRequestV0; +use dapi_grpc::platform::v0::get_token_perpetual_distribution_last_claim_request::{ + ContractTokenInfo, GetTokenPerpetualDistributionLastClaimRequestV0, +}; +use dapi_grpc::platform::v0::{ + get_contract_document_removals_request, get_contract_fee_pots_request, + get_contract_moderation_status_request, get_private_document_entries_request, + get_token_perpetual_distribution_last_claim_request, ContractModerationList, + GetContractDocumentRemovalsRequest, GetContractFeePotsRequest, + GetContractModerationStatusRequest, GetPrivateDocumentEntriesRequest, + GetTokenPerpetualDistributionLastClaimRequest, +}; +use dpp::dashcore::Network; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::tests::fixtures::get_data_contract_fixture; +use std::sync::Arc; + +#[test] +fn should_cache_the_contract_a_query_reads_from_a_cold_cache() { + let (platform, state, version) = setup_platform(None, Network::Testnet, None); + let contract = + get_data_contract_fixture(None, 0, version.protocol_version).data_contract_owned(); + store_data_contract(&platform, &contract, version); + let id = contract.id().to_buffer(); + let cache = &platform.drive.cache.data_contracts; + + let queries: Vec<(&str, Box)> = vec![ + ( + // Refused once read, as a Drive error: the type is not private + "getPrivateDocumentEntries", + Box::new(|| { + let request = GetPrivateDocumentEntriesRequest { + version: Some(get_private_document_entries_request::Version::V0( + GetPrivateDocumentEntriesRequestV0 { + data_contract_id: id.to_vec(), + document_type_name: "niceDocument".to_string(), + start_position: 0, + prove: false, + }, + )), + }; + let _ = platform.query_private_document_entries(request, &state, version); + }), + ), + ( + "getContractDocumentRemovals", + Box::new(|| { + let request = GetContractDocumentRemovalsRequest { + version: Some(get_contract_document_removals_request::Version::V0( + GetContractDocumentRemovalsRequestV0 { + contract_id: id.to_vec(), + document_type_name: "niceDocument".to_string(), + selection: Some(Selection::Page(Page { + start_after: None, + limit: None, + })), + prove: false, + }, + )), + }; + platform + .query_contract_document_removals(request, &state, version) + .expect("expected the query to run"); + }), + ), + ( + "getContractFeePots", + Box::new(|| { + let request = GetContractFeePotsRequest { + version: Some(get_contract_fee_pots_request::Version::V0( + GetContractFeePotsRequestV0 { + contract_id: id.to_vec(), + prove: false, + }, + )), + }; + platform + .query_contract_fee_pots(request, &state, version) + .expect("expected the query to run"); + }), + ), + ( + // Refused once read: the contract has no token at position 0 + "getTokenPerpetualDistributionLastClaim", + Box::new(|| { + let request = GetTokenPerpetualDistributionLastClaimRequest { + version: Some( + get_token_perpetual_distribution_last_claim_request::Version::V0( + GetTokenPerpetualDistributionLastClaimRequestV0 { + token_id: vec![1; 32], + contract_info: Some(ContractTokenInfo { + contract_id: id.to_vec(), + token_contract_position: 0, + }), + identity_id: vec![2; 32], + prove: false, + }, + ), + ), + }; + platform + .query_token_perpetual_distribution_last_claim(request, &state, version) + .expect("expected the query to run"); + }), + ), + ( + // Refused once read: the contract keeps no banlist + "getContractModerationStatus", + Box::new(|| { + let request = GetContractModerationStatusRequest { + version: Some(get_contract_moderation_status_request::Version::V0( + GetContractModerationStatusRequestV0 { + contract_id: id.to_vec(), + identity_id: vec![2; 32], + lists: vec![ContractModerationList::Banlist as i32], + prove: false, + }, + )), + }; + platform + .query_contract_moderation_status(request, &state, version) + .expect("expected the query to run"); + }), + ), + ]; + + for (name, query) in queries { + cache.clear(); + query(); + let read_from_state = cache + .get(id, false) + .unwrap_or_else(|| panic!("{name}: the query caches the contract it read")); + query(); + let read_again = cache + .get(id, false) + .unwrap_or_else(|| panic!("{name}: the contract stays cached")); + assert!( + Arc::ptr_eq(&read_from_state, &read_again), + "{name}: the second query is answered with the cached contract" + ); + } +} diff --git a/packages/rs-drive-abci/src/query/contract_moderation_queries/contract_document_removals/v0/mod.rs b/packages/rs-drive-abci/src/query/contract_moderation_queries/contract_document_removals/v0/mod.rs index 0a4b36e64a4..be30cc17c5d 100644 --- a/packages/rs-drive-abci/src/query/contract_moderation_queries/contract_document_removals/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/contract_moderation_queries/contract_document_removals/v0/mod.rs @@ -92,7 +92,7 @@ impl Platform { let Some(contract_fetch_info) = self.drive.get_contract_with_fetch_info( contract_id.to_buffer(), - false, + true, None, platform_version, )? diff --git a/packages/rs-drive-abci/src/query/contract_moderation_queries/contract_fee_pots/v0/mod.rs b/packages/rs-drive-abci/src/query/contract_moderation_queries/contract_fee_pots/v0/mod.rs index 1833ad0b707..1a612f8155a 100644 --- a/packages/rs-drive-abci/src/query/contract_moderation_queries/contract_fee_pots/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/contract_moderation_queries/contract_fee_pots/v0/mod.rs @@ -40,7 +40,7 @@ impl Platform { if self .drive - .get_contract_with_fetch_info(contract_id.to_buffer(), false, None, platform_version)? + .get_contract_with_fetch_info(contract_id.to_buffer(), true, None, platform_version)? .is_none() { return Ok(QueryValidationResult::new_with_error(QueryError::NotFound( diff --git a/packages/rs-drive-abci/src/query/contract_moderation_queries/mod.rs b/packages/rs-drive-abci/src/query/contract_moderation_queries/mod.rs index 5d91ac51f11..b4466664e85 100644 --- a/packages/rs-drive-abci/src/query/contract_moderation_queries/mod.rs +++ b/packages/rs-drive-abci/src/query/contract_moderation_queries/mod.rs @@ -169,7 +169,7 @@ impl Platform { ) -> Result, QueryError>, Error> { Ok(self .drive - .get_contract_with_fetch_info(contract_id.to_buffer(), false, None, platform_version)? + .get_contract_with_fetch_info(contract_id.to_buffer(), true, None, platform_version)? .ok_or_else(|| QueryError::NotFound(format!("contract {} not found", contract_id)))) } diff --git a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs index be5734efbb8..4109883f459 100644 --- a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs @@ -42,16 +42,14 @@ impl Platform { metadata: Some(self.response_metadata_v0(platform_state, CheckpointUsed::Current)), } } else { - let maybe_data_contract_fetch_info = self - .drive - .fetch_contract( - contract_id.into_buffer(), - None, - None, - None, - platform_version, - ) - .unwrap()?; + // Through the contract cache, as `getDataContracts` reads: a contract stored as its + // schemas is parsed, every pattern it holds compiled, each time it is read from state + let maybe_data_contract_fetch_info = self.drive.get_contract_with_fetch_info( + contract_id.into_buffer(), + true, + None, + platform_version, + )?; let data_contract_fetch_info = check_validation_result_with_data!(maybe_data_contract_fetch_info.ok_or_else( @@ -83,6 +81,7 @@ mod tests { use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::serialization::PlatformDeserializableWithPotentialValidationFromVersionedStructureTrusted; use dpp::tests::fixtures::get_data_contract_fixture; + use std::sync::Arc; #[test] fn test_invalid_data_contract_id() { @@ -295,4 +294,37 @@ mod tests { Some(get_data_contract_response_v0::Result::Proof(_)) )); } + + /// A contract stored as its schemas is parsed each time it is read from state, every + /// pattern it holds compiled, so a query reads it through the contract cache. + #[test] + fn should_answer_through_the_contract_cache() { + let (platform, state, version) = setup_platform(None, Network::Testnet, None); + let contract = + get_data_contract_fixture(None, 0, version.protocol_version).data_contract_owned(); + store_data_contract(&platform, &contract, version); + let id = contract.id().to_buffer(); + // What stored the contract cached it + let cache = &platform.drive.cache.data_contracts; + cache.clear(); + + let query = || { + let request = GetDataContractRequestV0 { + id: id.to_vec(), + prove: false, + }; + let result = platform + .query_data_contract_v0(request, &state, version) + .expect("expected query to succeed"); + assert!(result.errors.is_empty(), "{:?}", result.errors); + cache.get(id, false).expect("the query caches the contract") + }; + + let read_from_state = query(); + let read_again = query(); + assert!( + Arc::ptr_eq(&read_from_state, &read_again), + "the second query is answered with the cached contract" + ); + } } diff --git a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract_history/v0/mod.rs b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract_history/v0/mod.rs index 81ae758562f..f79348e99b8 100644 --- a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract_history/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract_history/v0/mod.rs @@ -5,10 +5,9 @@ use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_data_contract_history_request::GetDataContractHistoryRequestV0; use dapi_grpc::platform::v0::get_data_contract_history_response::{get_data_contract_history_response_v0, GetDataContractHistoryResponseV0}; use dpp::identifier::Identifier; -use dpp::serialization::PlatformSerializableWithPlatformVersion; use dpp::validation::ValidationResult; use dpp::version::PlatformVersion; -use dpp::{check_validation_result_with_data, ProtocolError}; +use dpp::check_validation_result_with_data; use dapi_grpc::platform::v0::get_data_contract_history_response::get_data_contract_history_response_v0::DataContractHistoryEntry; use drive::drive::contract::MAX_CONTRACT_HISTORY_FETCH_LIMIT; use drive::error::query::QuerySyntaxError; @@ -87,7 +86,9 @@ impl Platform { metadata: Some(self.response_metadata_v0(platform_state, CheckpointUsed::Current)), } } else { - let contracts = self.drive.fetch_contract_with_history( + // Each revision serialized without parsing it: one stored in schema form would + // build every document type, its patterns compiled, on every request + let contracts = self.drive.fetch_serialized_contract_history( contract_id.to_buffer(), None, start_at_ms, @@ -104,14 +105,8 @@ impl Platform { let contract_historical_entries: Vec = contracts .into_iter() - .map(|(date_in_seconds, data_contract)| { - Ok::(DataContractHistoryEntry { - date: date_in_seconds, - value: data_contract - .serialize_to_bytes_with_platform_version(platform_version)?, - }) - }) - .collect::, ProtocolError>>()?; + .map(|(date, value)| DataContractHistoryEntry { date, value }) + .collect(); GetDataContractHistoryResponseV0 { result: Some( diff --git a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts/v0/mod.rs b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts/v0/mod.rs index 7fbce1000ed..4f2d00198ba 100644 --- a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts/v0/mod.rs @@ -68,9 +68,15 @@ impl Platform { metadata: Some(self.response_metadata_v0(platform_state, CheckpointUsed::Current)), } } else { + // Each contract once, and kept in the contract cache: a contract stored as its schemas + // is parsed, every pattern it holds compiled, each time it is read from state. The + // response holds one entry for an id however often the request names it + let mut distinct_contract_ids = contract_ids; + distinct_contract_ids.sort_unstable(); + distinct_contract_ids.dedup(); let contracts = self.drive.get_contracts_with_fetch_info( - contract_ids.as_slice(), - false, + distinct_contract_ids.as_slice(), + true, None, platform_version, )?; @@ -110,8 +116,12 @@ mod tests { use super::*; use crate::query::tests::{ assert_invalid_argument_status, assert_invalid_identifier, setup_platform, + store_data_contract, }; use dpp::dashcore::Network; + use dpp::data_contract::accessors::v0::DataContractV0Getters; + use dpp::tests::fixtures::get_data_contract_fixture; + use std::sync::Arc; #[test] fn test_invalid_data_contract_id() { @@ -238,4 +248,45 @@ mod tests { version, )); } + + /// A contract stored as its schemas is parsed each time it is read from state, every + /// pattern it holds compiled, so a request naming one id many times reads it once, and + /// through the contract cache. + #[test] + fn should_read_a_repeated_id_once_through_the_contract_cache() { + let (platform, state, version) = setup_platform(None, Network::Testnet, None); + let contract = + get_data_contract_fixture(None, 0, version.protocol_version).data_contract_owned(); + store_data_contract(&platform, &contract, version); + let id = contract.id().to_buffer(); + // What stored the contract cached it + let cache = &platform.drive.cache.data_contracts; + cache.clear(); + + let query = || { + let request = GetDataContractsRequestV0 { + ids: vec![id.to_vec(); 3], + prove: false, + }; + let result = platform + .query_data_contracts_v0(request, &state, version) + .expect("expected query to succeed"); + assert!(matches!( + result.data, + Some(GetDataContractsResponseV0 { + result: Some(get_data_contracts_response_v0::Result::DataContracts(contracts)), + metadata: Some(_), + }) if contracts.data_contract_entries.len() == 1 + && contracts.data_contract_entries[0].data_contract.is_some() + )); + cache.get(id, false).expect("the query caches the contract") + }; + + let read_from_state = query(); + let read_again = query(); + assert!( + Arc::ptr_eq(&read_from_state, &read_again), + "the second query is answered with the cached contract" + ); + } } diff --git a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts_by_range/v0/mod.rs b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts_by_range/v0/mod.rs index 466ca21e3b2..0d1abd1309d 100644 --- a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts_by_range/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts_by_range/v0/mod.rs @@ -101,14 +101,27 @@ impl Platform { }) .collect() } else { - self.drive - .fetch_contracts(start_at, limit, None, platform_version)? - .into_iter() - .map(|contract| { + // The ids of the range, then each contract through the contract cache, as + // `getDataContracts` reads: a contract stored as its schemas is parsed, every + // pattern it holds compiled, each time it is read from state + let contract_ids = + self.drive + .fetch_contract_ids(start_at, limit, None, platform_version)?; + let mut contracts = self.drive.get_contracts_with_fetch_info( + &contract_ids, + true, + None, + platform_version, + )?; + contract_ids + .iter() + .filter_map(|contract_id| contracts.remove(contract_id).flatten()) + .map(|fetch_info| { Ok(DataContractEntry { - identifier: contract.id().to_vec(), + identifier: fetch_info.contract.id().to_vec(), data_contract: Some( - contract + fetch_info + .contract .serialize_to_bytes_with_platform_version(platform_version)?, ), }) @@ -428,4 +441,45 @@ mod tests { ); assert!(page.iter().all(|(_, contract)| contract.is_some())); } + + /// A contract stored as its schemas is parsed each time it is read from state, every + /// pattern it holds compiled, so a page of full contracts reads each through the contract + /// cache. + #[test] + fn should_answer_full_contracts_through_the_contract_cache() { + let (platform, state, version) = setup_platform(None, Network::Testnet, None); + let ids = store_three_contracts(&platform, version); + // What stored the contracts cached them + let cache = &platform.drive.cache.data_contracts; + cache.clear(); + + let query = || { + let page = entries( + platform + .query_data_contracts_by_range_v0( + page_request(None, None, false, false), + &state, + version, + ) + .expect("expected query to succeed"), + ); + assert!(page.iter().all(|entry| entry.data_contract.is_some())); + ids.iter() + .map(|id| { + cache + .get(*id, false) + .expect("the query caches the contract") + }) + .collect::>() + }; + + let read_from_state = query(); + let read_again = query(); + for (first, second) in read_from_state.iter().zip(&read_again) { + assert!( + std::sync::Arc::ptr_eq(first, second), + "the second query is answered with the cached contract" + ); + } + } } diff --git a/packages/rs-drive-abci/src/query/document_history/v0/mod.rs b/packages/rs-drive-abci/src/query/document_history/v0/mod.rs index afaee71c255..df4f826cb3c 100644 --- a/packages/rs-drive-abci/src/query/document_history/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/document_history/v0/mod.rs @@ -79,10 +79,14 @@ impl Platform { ))); } - let maybe_contract_fetch_info = self - .drive - .fetch_contract(contract_id.to_buffer(), None, None, None, platform_version) - .unwrap()?; + // Through the contract cache, as `getDataContract` reads: a contract stored as its + // schemas is parsed, every pattern it holds compiled, each time it is read from state + let maybe_contract_fetch_info = self.drive.get_contract_with_fetch_info( + contract_id.to_buffer(), + true, + None, + platform_version, + )?; let contract_fetch_info = check_validation_result_with_data!(maybe_contract_fetch_info .ok_or_else(|| { QueryError::NotFound(format!("data contract {} not found", contract_id)) diff --git a/packages/rs-drive-abci/src/query/document_history/v1/mod.rs b/packages/rs-drive-abci/src/query/document_history/v1/mod.rs index 4b0aca47628..d72ec517002 100644 --- a/packages/rs-drive-abci/src/query/document_history/v1/mod.rs +++ b/packages/rs-drive-abci/src/query/document_history/v1/mod.rs @@ -64,10 +64,11 @@ impl Platform { check_validation_result_with_data!(query .validate() .map_err(|error| QueryError::InvalidArgument(error.to_string()))); - let fetched = self - .drive - .fetch_contract(contract_id, None, None, None, platform_version) - .value?; + // Through the contract cache, as `getDataContract` reads: a contract stored as its + // schemas is parsed, every pattern it holds compiled, each time it is read from state + let fetched = + self.drive + .get_contract_with_fetch_info(contract_id, true, None, platform_version)?; let fetched = check_validation_result_with_data!( fetched.ok_or_else(|| QueryError::NotFound("data contract not found".to_owned())) ); diff --git a/packages/rs-drive-abci/src/query/document_history/v1/tests.rs b/packages/rs-drive-abci/src/query/document_history/v1/tests.rs index d42720cb744..5ab082cabe5 100644 --- a/packages/rs-drive-abci/src/query/document_history/v1/tests.rs +++ b/packages/rs-drive-abci/src/query/document_history/v1/tests.rs @@ -633,6 +633,53 @@ fn should_reject_missing_selectors_before_reading_state() { .is_valid()); } +/// A contract stored as its schemas is parsed each time it is read from state, every pattern +/// it holds compiled, so a history query reads it through the contract cache. +#[test] +fn should_read_the_contract_through_the_contract_cache() { + let (platform, state, version) = setup_platform(None, Network::Testnet, None); + let contract = json_document_to_contract( + concat!( + env!("CARGO_MANIFEST_DIR"), + "/../rs-drive/tests/supporting_files/contract/dashpay/dashpay-contract-with-profile-history.json" + ), + false, + version, + ) + .unwrap(); + platform + .drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .unwrap(); + let id = contract.id().to_buffer(); + // What stored the contract cached it + let cache = &platform.drive.cache.data_contracts; + cache.clear(); + + let query = || { + let request = GetDocumentHistoryRequestV1 { + data_contract_id: id.to_vec(), + document_type_name: "profile".into(), + document_id: vec![2; 32], + filter: Some(Filter::StartAtRevision(1)), + limit: None, + prove: false, + }; + // The document does not exist; what matters is how the contract was read + platform + .query_document_history_v1(request, &state, version) + .expect("expected the query to run"); + cache.get(id, false).expect("the query caches the contract") + }; + + let read_from_state = query(); + let read_again = query(); + assert!( + Arc::ptr_eq(&read_from_state, &read_again), + "the second query is answered with the cached contract" + ); +} + #[test] fn should_derive_deleted_and_erasing_lifecycle_from_the_proof() { let (platform, state, version) = setup_platform(None, Network::Testnet, None); diff --git a/packages/rs-drive-abci/src/query/mod.rs b/packages/rs-drive-abci/src/query/mod.rs index 2ba273621b8..586e4b530d6 100644 --- a/packages/rs-drive-abci/src/query/mod.rs +++ b/packages/rs-drive-abci/src/query/mod.rs @@ -17,6 +17,9 @@ mod token_queries; mod validator_queries; mod voting; +#[cfg(test)] +mod contract_cache_tests; + use crate::error::query::QueryError; use dpp::validation::ValidationResult; diff --git a/packages/rs-drive-abci/src/query/private_document_entries/v0/mod.rs b/packages/rs-drive-abci/src/query/private_document_entries/v0/mod.rs index aab5a0133f8..07adfd07152 100644 --- a/packages/rs-drive-abci/src/query/private_document_entries/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/private_document_entries/v0/mod.rs @@ -69,7 +69,7 @@ impl Platform { let maybe_contract_fetch_info = self.drive.get_contract_with_fetch_info( contract_id.to_buffer(), - false, + true, None, platform_version, )?; diff --git a/packages/rs-drive-abci/src/query/token_queries/token_perpetual_distribution_last_claim/v0/mod.rs b/packages/rs-drive-abci/src/query/token_queries/token_perpetual_distribution_last_claim/v0/mod.rs index 01847e0f782..e5052d206a9 100644 --- a/packages/rs-drive-abci/src/query/token_queries/token_perpetual_distribution_last_claim/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/token_queries/token_perpetual_distribution_last_claim/v0/mod.rs @@ -84,7 +84,7 @@ impl Platform { .drive .get_contract_with_fetch_info( contract_id.into_buffer(), - false, + true, None, platform_version ) diff --git a/packages/rs-drive/src/drive/contract/get_fetch/fetch_serialized_contract_history/mod.rs b/packages/rs-drive/src/drive/contract/get_fetch/fetch_serialized_contract_history/mod.rs new file mode 100644 index 00000000000..3f13cdf81e4 --- /dev/null +++ b/packages/rs-drive/src/drive/contract/get_fetch/fetch_serialized_contract_history/mod.rs @@ -0,0 +1,161 @@ +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; +use std::collections::BTreeMap; + +mod v0; + +impl Drive { + /// Fetches a contract's history as [`Drive::fetch_contract_with_history`] does, each + /// revision serialized as the contract it holds serializes at `platform_version` + /// (`contract_serialization_version`), the bytes a query answers with, without parsing it: + /// a revision stored in schema form would build every document type, its patterns + /// compiled, each time it is read, and the contract cache holds only a contract's latest + /// revision. + /// + /// # Returns + /// + /// The revisions by the time, in milliseconds, they were stored at. + /// + /// # Errors + /// + /// The errors of [`Drive::fetch_contract_with_history`], except that a revision whose + /// schemas do not parse at `platform_version` is returned rather than refused. + pub fn fetch_serialized_contract_history( + &self, + contract_id: [u8; 32], + transaction: TransactionArg, + start_at_date: u64, + limit: Option, + offset: Option, + platform_version: &PlatformVersion, + ) -> Result>, Error> { + match platform_version + .drive + .methods + .contract + .get + .fetch_serialized_contract_history + { + 0 => self.fetch_serialized_contract_history_v0( + contract_id, + transaction, + start_at_date, + limit, + offset, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_serialized_contract_history".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} + +#[cfg(feature = "server")] +#[cfg(test)] +mod tests { + use super::*; + use crate::util::test_helpers::setup::setup_drive_with_initial_state_structure; + use dpp::block::block_info::BlockInfo; + use dpp::data_contract::accessors::v0::{DataContractV0Getters, DataContractV0Setters}; + use dpp::data_contract::config::v0::DataContractConfigSettersV0; + use dpp::data_contract::schema::DataContractSchemaMethodsV0; + use dpp::platform_value::platform_value; + use dpp::serialization::PlatformSerializableWithPlatformVersion; + use dpp::tests::fixtures::get_data_contract_fixture; + use grovedb::query_result_type::QueryResultType; + use grovedb::Element; + + /// A revision stored before protocol version 15 is in schema form, one stored from it + /// compiled: both answer as the contract read and serialized again does. + #[test] + fn should_serialize_each_revision_as_the_contract_it_holds() { + let latest = PlatformVersion::latest(); + let before_compiled = PlatformVersion::get(14).expect("protocol version 14 must exist"); + let drive = setup_drive_with_initial_state_structure(None); + let mut contract = + get_data_contract_fixture(None, 0, latest.protocol_version).data_contract_owned(); + contract.config_mut().set_keeps_history(true); + contract.config_mut().set_readonly(false); + let block_at = |time_ms| BlockInfo { + time_ms, + ..Default::default() + }; + drive + .apply_contract(&contract, block_at(1000), true, None, None, before_compiled) + .expect("expected to apply the contract"); + + contract + .set_document_schema( + "niceDocument", + platform_value!({ + "type": "object", + "properties": { + "name": {"type": "string", "position": 0}, + "newProp": {"type": "integer", "minimum": 0, "position": 1} + }, + "required": ["$createdAt"], + "additionalProperties": false + }), + true, + &mut vec![], + latest, + ) + .expect("expected to set the document schema"); + contract.increment_version(); + drive + .apply_contract(&contract, block_at(2000), true, None, None, latest) + .expect("expected to apply the update"); + + let id = contract.id().to_buffer(); + let (stored, _) = drive + .grove_get_path_query( + &Drive::fetch_contract_history_query(id, 0, Some(10), None) + .expect("expected a history query"), + None, + QueryResultType::QueryElementResultType, + &mut vec![], + &latest.drive, + ) + .expect("expected to read the stored revisions"); + // A contract's bytes open with its format version + let stored_formats: Vec = stored + .to_elements() + .into_iter() + .map(|element| match element { + Element::Item(bytes, _) => bytes[0], + _ => panic!("expected a stored revision"), + }) + .collect(); + assert_eq!( + stored_formats, + vec![2, 1], + "newest first: compiled, then schema form" + ); + + let serialized = drive + .fetch_serialized_contract_history(id, None, 0, Some(10), None, latest) + .expect("expected to fetch the serialized history"); + let read = drive + .fetch_contract_with_history(id, None, 0, Some(10), None, latest) + .expect("expected to fetch the history"); + + assert_eq!(serialized.len(), 2); + assert!(serialized.keys().eq(read.keys())); + for ((time, bytes), contract) in serialized.iter().zip(read.values()) { + assert_eq!( + bytes, + &contract + .serialize_to_bytes_with_platform_version(latest) + .expect("expected to serialize"), + "the revision stored at {time}" + ); + } + } +} diff --git a/packages/rs-drive/src/drive/contract/get_fetch/fetch_serialized_contract_history/v0/mod.rs b/packages/rs-drive/src/drive/contract/get_fetch/fetch_serialized_contract_history/v0/mod.rs new file mode 100644 index 00000000000..df1c5e9e6d0 --- /dev/null +++ b/packages/rs-drive/src/drive/contract/get_fetch/fetch_serialized_contract_history/v0/mod.rs @@ -0,0 +1,60 @@ +use crate::util::common::decode::decode_u64; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::data_contract::DataContract; + +use dpp::version::PlatformVersion; +use grovedb::query_result_type::{QueryResultElement, QueryResultType}; +use grovedb::{Element, TransactionArg}; +use std::collections::BTreeMap; + +impl Drive { + /// [`Drive::fetch_contract_with_history`]'s revisions, each serialized as + /// [`DataContract::carried_bytes_from_storage_bytes`] gives it, without parsing it. + #[inline(always)] + pub(super) fn fetch_serialized_contract_history_v0( + &self, + contract_id: [u8; 32], + transaction: TransactionArg, + start_at_date: u64, + limit: Option, + offset: Option, + platform_version: &PlatformVersion, + ) -> Result>, Error> { + let mut ops = Vec::new(); + + let path_query = + Self::fetch_contract_history_query(contract_id, start_at_date, limit, offset)?; + + let (results, _cost) = self.grove_get_path_query( + &path_query, + transaction, + QueryResultType::QueryKeyElementPairResultType, + &mut ops, + &platform_version.drive, + )?; + + results + .elements + .iter() + .map(|el| match el { + QueryResultElement::KeyElementPairResultItem((key, Element::Item(item, _))) => { + let contract_time = decode_u64(key).map_err(|_| { + Error::Drive(DriveError::CorruptedContractPath( + "contract key is not a valid u64", + )) + })?; + let serialized = + DataContract::carried_bytes_from_storage_bytes(item, platform_version)?; + Ok((contract_time, serialized)) + } + _ => Err(Error::Drive(DriveError::CorruptedContractPath( + "contract path did not refer to a contract element", + ))), + }) + .collect() + } +} diff --git a/packages/rs-drive/src/drive/contract/get_fetch/mod.rs b/packages/rs-drive/src/drive/contract/get_fetch/mod.rs index 90b976a82c2..e877f889467 100644 --- a/packages/rs-drive/src/drive/contract/get_fetch/mod.rs +++ b/packages/rs-drive/src/drive/contract/get_fetch/mod.rs @@ -3,6 +3,7 @@ mod fetch_contract_ids; mod fetch_contract_version; mod fetch_contract_with_history; mod fetch_contracts; +mod fetch_serialized_contract_history; mod get_cached_contract_with_fetch_info; mod get_contract_with_fetch_info; mod get_contracts_with_fetch_info; diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs index a1cb9bc1ef5..9d9b59e19b4 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs @@ -129,7 +129,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote index_values, } = self; - let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; + let contract = drive.get_contract_with_fetch_info(contract_id.to_buffer(), true, transaction, platform_version)?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; Ok(ContestedDocumentResourceVotePollWithContractInfo { contract: DataContractOwnedResolvedInfo::DataContractFetchInfo(contract), document_type_name: document_type_name.clone(), @@ -152,7 +152,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote index_values, } = self; - let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll as owned".to_string())))?; + let contract = drive.get_contract_with_fetch_info(contract_id.to_buffer(), true, transaction, platform_version)?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll as owned".to_string())))?; Ok(ContestedDocumentResourceVotePollWithContractInfo { contract: DataContractOwnedResolvedInfo::DataContractFetchInfo(contract), document_type_name, @@ -175,7 +175,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote index_values, } = self; - let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll as borrowed".to_string())))?; + let contract = drive.get_contract_with_fetch_info(contract_id.to_buffer(), true, transaction, platform_version)?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll as borrowed".to_string())))?; Ok( ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract: DataContractResolvedInfo::ArcDataContractFetchInfo(contract), @@ -259,7 +259,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote index_values, } = self; - let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll as owned, but allowing borrowed".to_string())))?; + let contract = drive.get_contract_with_fetch_info(contract_id.to_buffer(), true, transaction, platform_version)?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll as owned, but allowing borrowed".to_string())))?; Ok( ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract: DataContractResolvedInfo::ArcDataContractFetchInfo(contract), @@ -328,3 +328,88 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote }) } } + +#[cfg(all(test, feature = "full"))] +mod tests { + use super::*; + use crate::util::object_size_info::{DataContractOwnedResolvedInfo, DataContractResolvedInfo}; + use crate::util::test_helpers::setup::setup_drive_with_initial_state_structure; + use dpp::block::block_info::BlockInfo; + use dpp::tests::fixtures::get_dpns_data_contract_fixture; + + /// A contract stored as its schemas is parsed each time it is read from state, every + /// pattern it holds compiled, so each resolver reads it through the contract cache. + #[test] + fn should_resolve_the_contract_through_the_contract_cache() { + let platform_version = PlatformVersion::latest(); + let drive = setup_drive_with_initial_state_structure(None); + let contract = get_dpns_data_contract_fixture(None, 0, platform_version.protocol_version) + .data_contract_owned(); + drive + .apply_contract( + &contract, + BlockInfo::default(), + true, + None, + None, + platform_version, + ) + .expect("expected to apply the contract"); + // What stored the contract cached it + drive.cache.data_contracts.clear(); + + let vote_poll = ContestedDocumentResourceVotePoll { + contract_id: contract.id(), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![], + }; + let owned = |resolved: ContestedDocumentResourceVotePollWithContractInfo| { + let DataContractOwnedResolvedInfo::DataContractFetchInfo(fetch_info) = + resolved.contract + else { + panic!("expected the fetched contract"); + }; + fetch_info + }; + let borrowed = + |resolved: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed| { + let DataContractResolvedInfo::ArcDataContractFetchInfo(fetch_info) = + resolved.contract + else { + panic!("expected the fetched contract"); + }; + fetch_info + }; + + let read_from_state = owned( + vote_poll + .resolve(&drive, None, platform_version) + .expect("expected to resolve"), + ); + for read_again in [ + owned( + vote_poll + .clone() + .resolve_owned(&drive, None, platform_version) + .expect("expected to resolve"), + ), + borrowed( + vote_poll + .resolve_allow_borrowed(&drive, None, platform_version) + .expect("expected to resolve"), + ), + borrowed( + vote_poll + .clone() + .resolve_owned_allow_borrowed(&drive, None, platform_version) + .expect("expected to resolve"), + ), + ] { + assert!( + Arc::ptr_eq(&read_from_state, &read_again), + "a later resolve is answered with the cached contract" + ); + } + } +} diff --git a/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs b/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs index d32ed05fc8d..9491fb8b1de 100644 --- a/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs @@ -112,15 +112,15 @@ impl VotePollsByDocumentTypeQuery { limit, order_ascending, } = self; + // Through the contract cache: a contract stored as its schemas is parsed, every pattern + // it holds compiled, each time it is read from state let contract = drive - .fetch_contract( + .get_contract_with_fetch_info( contract_id.to_buffer(), - None, - None, + true, transaction, platform_version, - ) - .unwrap()? + )? .ok_or(Error::DataContract(DataContractError::MissingContract( "data contract not found when resolving vote polls by document type query" .to_string(), @@ -571,6 +571,52 @@ mod tests { .expect("should resolve") } + /// A contract stored as its schemas is parsed each time it is read from state, every + /// pattern it holds compiled, so the query reads it through the contract cache. + #[cfg(feature = "full")] + #[test] + fn should_resolve_the_contract_through_the_contract_cache() { + use crate::util::object_size_info::DataContractResolvedInfo; + use crate::util::test_helpers::setup::setup_drive_with_initial_state_structure; + use dpp::block::block_info::BlockInfo; + + let platform_version = PlatformVersion::latest(); + let drive = setup_drive_with_initial_state_structure(None); + let contract = get_dpns_data_contract_fixture(None, 0, platform_version.protocol_version) + .data_contract_owned(); + drive + .apply_contract( + &contract, + BlockInfo::default(), + true, + None, + None, + platform_version, + ) + .expect("expected to apply the contract"); + // What stored the contract cached it + drive.cache.data_contracts.clear(); + + let query = build_query(&contract, vec![], vec![], None, Some(10), true); + let resolve = || { + let resolved = query + .resolve(&drive, None, platform_version) + .expect("expected to resolve"); + let DataContractResolvedInfo::ArcDataContractFetchInfo(fetch_info) = resolved.contract + else { + panic!("expected the fetched contract"); + }; + fetch_info + }; + + let read_from_state = resolve(); + let read_again = resolve(); + assert!( + std::sync::Arc::ptr_eq(&read_from_state, &read_again), + "the second resolve is answered with the cached contract" + ); + } + // ----------------------------------------------------------------------- // resolve_with_provided_borrowed_contract // ----------------------------------------------------------------------- diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/mod.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/mod.rs index 80d63a7f2b5..182f7027e26 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/mod.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/mod.rs @@ -47,6 +47,12 @@ pub struct DataContractMethodVersions { pub validate_moderation_config: FeatureVersion, pub equal_ignoring_time_fields: FeatureVersion, pub registration_cost: FeatureVersion, + /// `DataContract::validate_schema_patterns`: refuses a contract whose document schemas and + /// `$defs` hold more patterns than `max_contract_schema_patterns`, or one that does not + /// compile within `max_schema_pattern_compiled_size`. `None` on versions that predate the + /// rule: the method refuses nothing there, so the shipped + /// `create_document_types_from_document_schemas` 1 that calls it is inert. + pub validate_schema_patterns: OptionalFeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v1.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v1.rs index 3e9120f2d1b..3c0e8ed778b 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v1.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v1.rs @@ -29,6 +29,7 @@ pub const CONTRACT_VERSIONS_V1: DPPContractVersions = DPPContractVersions { validate_moderation_config: 0, equal_ignoring_time_fields: 0, registration_cost: 0, + validate_schema_patterns: None, }, document_type_versions: DocumentTypeVersions { index_versions: DocumentTypeIndexVersions { diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v2.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v2.rs index db69d92fcf8..6493cf85e8b 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v2.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v2.rs @@ -29,6 +29,7 @@ pub const CONTRACT_VERSIONS_V2: DPPContractVersions = DPPContractVersions { validate_moderation_config: 0, equal_ignoring_time_fields: 0, registration_cost: 1, //changed to version 1 + validate_schema_patterns: None, }, document_type_versions: DocumentTypeVersions { index_versions: DocumentTypeIndexVersions { diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v3.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v3.rs index dcce56520e6..602e8e52c32 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v3.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v3.rs @@ -31,6 +31,7 @@ pub const CONTRACT_VERSIONS_V3: DPPContractVersions = DPPContractVersions { validate_moderation_config: 0, equal_ignoring_time_fields: 0, registration_cost: 1, + validate_schema_patterns: None, }, document_type_versions: DocumentTypeVersions { index_versions: DocumentTypeIndexVersions { diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v4.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v4.rs index bbe18185686..34e7fe13943 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v4.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v4.rs @@ -31,6 +31,7 @@ pub const CONTRACT_VERSIONS_V4: DPPContractVersions = DPPContractVersions { validate_moderation_config: 0, equal_ignoring_time_fields: 0, registration_cost: 1, + validate_schema_patterns: None, }, document_type_versions: DocumentTypeVersions { index_versions: DocumentTypeIndexVersions { diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v5.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v5.rs index 94113e6aaad..19248e9736f 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v5.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v5.rs @@ -33,6 +33,7 @@ pub const CONTRACT_VERSIONS_V5: DPPContractVersions = DPPContractVersions { validate_moderation_config: 0, equal_ignoring_time_fields: 0, registration_cost: 1, + validate_schema_patterns: None, }, document_type_versions: DocumentTypeVersions { index_versions: DocumentTypeIndexVersions { diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v6.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v6.rs index 9630324a042..7974e0ab550 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v6.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v6.rs @@ -67,6 +67,7 @@ pub const CONTRACT_VERSIONS_V6: DPPContractVersions = DPPContractVersions { validate_moderation_config: 0, equal_ignoring_time_fields: 0, registration_cost: 2, // changed: charges the once-per-identity token distribution surcharge + validate_schema_patterns: None, }, document_type_versions: DocumentTypeVersions { index_versions: DocumentTypeIndexVersions { diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v7.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v7.rs index b8058bc425f..c58b4b21b62 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v7.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v7.rs @@ -34,6 +34,13 @@ use crate::version::dpp_versions::dpp_contract_versions::{ /// - `apply_generated_from`, `Some(1)` rather than `Some(0)`: a `generatedFrom` property may /// also be generated with `sys.tokens.decimals`, the decimals of the token an identifier /// property names, on an integer property; +/// - `validate_schema_patterns`, `Some(0)` rather than `None`: registration and update refuse +/// a contract whose document schemas and `$defs` hold more than +/// `max_contract_schema_patterns` patterns, or one that does not compile within +/// `max_schema_pattern_compiled_size`; +/// - `registration_cost`, 3 rather than 2: the fee a state transition's contract is estimated +/// at bills each index by the keys it declares instead of parsing it, which compiled the +/// field matches of a contested index before anything bounded them; /// - `contract_storage_serialization_version`, 2 rather than 1: Drive stores a contract in /// format version 2, its document types compiled, while state transitions and clients keep /// format version 1; @@ -49,6 +56,10 @@ pub const CONTRACT_VERSIONS_V7: DPPContractVersions = DPPContractVersions { // `jsonschema` crate: uniqueItems treats signed zeros as one value, and a // format:regex value is checked for syntax rather than compilation validate_document: 2, + // changed: a contract's schemas hold a bounded number of patterns of bounded size + validate_schema_patterns: Some(0), + // changed: the fee estimate bills an index without compiling its field matches + registration_cost: 3, ..CONTRACT_VERSIONS_V6.methods }, document_type_versions: DocumentTypeVersions { diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/mod.rs b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/mod.rs index 801d3e5014e..6976dd1f042 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/mod.rs @@ -116,6 +116,7 @@ pub struct DriveContractGetMethodVersions { pub fetch_contract_version: FeatureVersion, pub fetch_contracts: FeatureVersion, pub fetch_contract_with_history: FeatureVersion, + pub fetch_serialized_contract_history: FeatureVersion, pub get_cached_contract_with_fetch_info: FeatureVersion, pub get_contract_with_fetch_info: FeatureVersion, pub get_contracts_with_fetch_info: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v1.rs b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v1.rs index a92c9cb64ee..5a456a76c03 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v1.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v1.rs @@ -39,6 +39,7 @@ pub const DRIVE_CONTRACT_METHOD_VERSIONS_V1: DriveContractMethodVersions = fetch_contract_version: 0, fetch_contracts: 0, fetch_contract_with_history: 0, + fetch_serialized_contract_history: 0, get_cached_contract_with_fetch_info: 0, get_contract_with_fetch_info: 0, get_contracts_with_fetch_info: 0, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v2.rs b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v2.rs index c3da47f91bc..e94ddfda47a 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v2.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v2.rs @@ -39,6 +39,7 @@ pub const DRIVE_CONTRACT_METHOD_VERSIONS_V2: DriveContractMethodVersions = fetch_contract_version: 0, fetch_contracts: 0, fetch_contract_with_history: 0, + fetch_serialized_contract_history: 0, get_cached_contract_with_fetch_info: 0, get_contract_with_fetch_info: 0, get_contracts_with_fetch_info: 0, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v3.rs b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v3.rs index a81ed95a0df..c39fc475159 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v3.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v3.rs @@ -50,6 +50,7 @@ pub const DRIVE_CONTRACT_METHOD_VERSIONS_V3: DriveContractMethodVersions = fetch_contract_version: 0, fetch_contracts: 0, fetch_contract_with_history: 0, + fetch_serialized_contract_history: 0, get_cached_contract_with_fetch_info: 0, get_contract_with_fetch_info: 0, get_contracts_with_fetch_info: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 9160f53fd68..19ff20f0c9f 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -606,6 +606,8 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { max_document_value_depth: None, max_typed_array_items: 1024, max_index_property_name_bytes: 255, + max_contract_schema_patterns: 32, + max_schema_pattern_compiled_size: 131_072, max_compiled_contract_size: None, max_private_document_entry_size: None, private_document_store_target_chunk_bytes: None, diff --git a/packages/rs-platform-version/src/version/system_limits/mod.rs b/packages/rs-platform-version/src/version/system_limits/mod.rs index 198206481fc..c572525e802 100644 --- a/packages/rs-platform-version/src/version/system_limits/mod.rs +++ b/packages/rs-platform-version/src/version/system_limits/mod.rs @@ -31,6 +31,19 @@ pub struct SystemLimits { /// version 15), which refuses a longer name; the document meta-schema checked before it /// admitted 256 characters. Never reached before protocol version 15. pub max_index_property_name_bytes: u16, + /// Most patterns the document schemas and `$defs` of one contract may hold: every string + /// under a `pattern` key, and every `regexPattern` of a contested index's `fieldMatches`, + /// one in `$defs` counted once for each document type. + /// Each is compiled when the contract is parsed and again for the validator its documents + /// are checked with, so this and `max_schema_pattern_compiled_size` bound the work and the + /// memory one contract costs every node. Read by `DataContract::validate_schema_patterns` + /// 0, which contract registration and update run under full validation from protocol + /// version 15 and never before; `check_tx` holds a contract to the same bound at every + /// protocol version, as mempool policy where consensus has no such rule. + pub max_contract_schema_patterns: u16, + /// The `regex` size limit, in bytes, every such pattern must compile within. Read with + /// `max_contract_schema_patterns`. + pub max_schema_pattern_compiled_size: u32, /// Maximum bytes of a contract stored compiled (format version 2, its document types /// compiled beside its schemas): 1 MiB from `SYSTEM_LIMITS_V5` (protocol version 15), /// `None` in the earlier tables, which store no contract compiled. The format transitions diff --git a/packages/rs-platform-version/src/version/system_limits/v1.rs b/packages/rs-platform-version/src/version/system_limits/v1.rs index 5f6bc24a3ea..d4c2f8c9b3b 100644 --- a/packages/rs-platform-version/src/version/system_limits/v1.rs +++ b/packages/rs-platform-version/src/version/system_limits/v1.rs @@ -9,6 +9,8 @@ pub const SYSTEM_LIMITS_V1: SystemLimits = SystemLimits { max_document_value_depth: None, max_typed_array_items: 1024, max_index_property_name_bytes: 255, + max_contract_schema_patterns: 32, + max_schema_pattern_compiled_size: 131_072, max_compiled_contract_size: None, max_private_document_entry_size: None, private_document_store_target_chunk_bytes: None, diff --git a/packages/rs-platform-version/src/version/system_limits/v2.rs b/packages/rs-platform-version/src/version/system_limits/v2.rs index b4269f213ab..9a74de90d71 100644 --- a/packages/rs-platform-version/src/version/system_limits/v2.rs +++ b/packages/rs-platform-version/src/version/system_limits/v2.rs @@ -15,6 +15,8 @@ pub const SYSTEM_LIMITS_V2: SystemLimits = SystemLimits { max_document_value_depth: None, max_typed_array_items: 1024, max_index_property_name_bytes: 255, + max_contract_schema_patterns: 32, + max_schema_pattern_compiled_size: 131_072, max_compiled_contract_size: None, max_private_document_entry_size: None, private_document_store_target_chunk_bytes: None, diff --git a/packages/rs-platform-version/src/version/system_limits/v3.rs b/packages/rs-platform-version/src/version/system_limits/v3.rs index dbb9017d491..da29418d9b7 100644 --- a/packages/rs-platform-version/src/version/system_limits/v3.rs +++ b/packages/rs-platform-version/src/version/system_limits/v3.rs @@ -17,6 +17,8 @@ pub const SYSTEM_LIMITS_V3: SystemLimits = SystemLimits { max_document_value_depth: Some(256), max_typed_array_items: 1024, max_index_property_name_bytes: 255, + max_contract_schema_patterns: 32, + max_schema_pattern_compiled_size: 131_072, max_compiled_contract_size: None, max_private_document_entry_size: None, private_document_store_target_chunk_bytes: None, diff --git a/packages/rs-platform-version/src/version/system_limits/v4.rs b/packages/rs-platform-version/src/version/system_limits/v4.rs index e7e4e40c143..6ef0d5f2efa 100644 --- a/packages/rs-platform-version/src/version/system_limits/v4.rs +++ b/packages/rs-platform-version/src/version/system_limits/v4.rs @@ -138,7 +138,9 @@ pub const SYSTEM_LIMITS_V4: SystemLimits = SystemLimits { max_document_value_depth: Some(256), max_typed_array_items: 1024, // typed array properties (new in v14): contract registration caps their maxItems here max_index_property_name_bytes: 255, // native registration checks (new in v15): an index property name holds at most the 255 bytes of a GroveDB key - max_compiled_contract_size: None, // no contract is stored compiled before protocol version 15 + max_contract_schema_patterns: 32, // schema pattern bounds (consensus from v15, mempool policy before): a contract holds at most 32 patterns + max_schema_pattern_compiled_size: 131_072, // and each compiles within 128 KiB + max_compiled_contract_size: None, // no contract is stored compiled before protocol version 15 max_private_document_entry_size: None, // no private document type before protocol version 15 private_document_store_target_chunk_bytes: None, private_document_store_min_chunk_power: None, diff --git a/packages/rs-platform-version/src/version/system_limits/v5.rs b/packages/rs-platform-version/src/version/system_limits/v5.rs index 358e38a8141..ffe2e8d18e0 100644 --- a/packages/rs-platform-version/src/version/system_limits/v5.rs +++ b/packages/rs-platform-version/src/version/system_limits/v5.rs @@ -15,6 +15,10 @@ use crate::version::system_limits::SystemLimits; /// (`private_document_store_min_chunk_power`, `private_document_store_max_chunk_power`), all /// `None` before. A `PrivateDocumentCreateFromShieldedPool` appends at most 16 entries /// (`max_private_document_entries_per_transition`, `None` before). +/// * Schema patterns: protocol version 15 is the first whose consensus reads +/// `max_contract_schema_patterns` (32) and `max_schema_pattern_compiled_size` (128 KiB), +/// through `validate_schema_patterns` 0. The numbers are unchanged from the earlier tables, +/// which hold them for `check_tx` alone. /// * Retained-history erasure: one transition removes at most 100 revisions /// (`max_document_revisions_erased_per_transition`, `None` before), as enforced by /// `erase_document_for_contract_operations` 0. diff --git a/packages/rs-platform-version/src/version/v15.rs b/packages/rs-platform-version/src/version/v15.rs index b4b3733f502..2a3c212d2a9 100644 --- a/packages/rs-platform-version/src/version/v15.rs +++ b/packages/rs-platform-version/src/version/v15.rs @@ -893,6 +893,26 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// Parser 4 admits `canBeErased` with meta-schema 3; compiled type storage keeps generation /// 0 and its existing non-lifecycle bytes. Protocols through 14 retain their handlers, /// limits and wire bounds, and cannot admit an erase. +/// 42. **A contract's patterns are bounded**: `CONTRACT_VERSIONS_V7` selects +/// `validate_schema_patterns` 0. Contract registration and update refuse a contract whose +/// document schemas and `$defs` hold more than 32 patterns +/// (`max_contract_schema_patterns`: every string under a `pattern` key and every +/// `regexPattern` of a contested index, one in `$defs` counted once for each document +/// type), or a pattern that does not compile within 128 KiB +/// (`max_schema_pattern_compiled_size`), before anything compiles one. Every pattern is +/// compiled when a contract is parsed and again for the validator its documents are +/// checked with, under a limit of 5 or 10 MiB each and in any number, so one 20 KiB +/// contract cost a node tens of seconds to check and over a gigabyte to keep. The balance +/// pre-check estimates the registration fee before that, and its estimate parsed every +/// index, compiling the field matches of a contested one: `registration_cost` 3 bills an +/// index by the keys it declares instead, the same fee for every contract that registers. +/// Both numbers are in every system limits table: `check_tx` holds a contract to them +/// before the balance pre-check at every protocol version, as mempool policy where +/// consensus has no such rule, and there also keeps a schema declaring `format: regex` out +/// of the mempool, whose values the `jsonschema` crate compiles. Protocol v14 selects no +/// `validate_schema_patterns` and `registration_cost` 2, so a block accepts there what it +/// accepted before, and a contract registered earlier is not checked again when it is +/// read. pub const PLATFORM_V15: PlatformVersion = PlatformVersion { protocol_version: PROTOCOL_VERSION_15, drive: DRIVE_VERSION_V10, // changed: calculate_fee 1 prices a refund at the storing epoch's rate (note 27); apply_contract_with_serialization 1 writes nothing for a contract whose format version 1 bytes match the stored one's (note 8); vote method versions v4: register_identity_vote 1 registers a yes/no vote, remove_all_votes_given_by_identities 1 also removes the yes/no votes of a masternode that left the list, every yes_no method and remove_vote_poll_end_date_query_operations Some(0) make yes/no polls active, add_vote_poll_end_date_query_operations 1 adds only the entry when the batch already queues the end date's tree with other storage flags, and verify methods v4 make the yes/no proof verifiers active (note 10) and verify_private_document_entries Some(0) a page of a private type's store (note 13); state transition method versions v5: document_create_transition 1 deletes a consumed document from what its lookup read (note 11); document method versions v5: insert_empty_private_document_store_operation Some(0) creates a private document type's store, and fetch_private_document_entries and prove_private_document_entries Some(0) read and prove a page of it (note 13); apply_drive_operations 2 resolves a batch's estimate, remove_reference_for_index_level_for_contract_operations 2, add_reference_for_index_level_for_contract_operations 1, stateless_delete_of_non_tree_for_costs 1 and for_total_system_credits_update 1 describe their layers as they are (note 14); create_initial_state_structure 5 adds the token marketplace escrow trees; calculate_total_tokens_balance 2 counts escrowed tokens; the escrow primitives; the identity balance, token balance, prefunded specialized balance and contract fee pot estimations (for_balances 1, for_token_balances 1, estimated_cost_for_prefunded_specialized_balance_update 2, add_estimation_costs_for_contract_fee_pot_update 1) keep a deeper layer description (note 17); fetch_core_fork_activation_height and store_core_fork_activation_height Some(0) keep the Core fork activations (note 18); document method versions v5: append_private_document_entries_operations Some(0) appends a private document create's entries (note 25); grove_version GROVE_V5 (note 26); verify methods v4: verify_proof_keep_serialized 1 verifies a document that may be contested (note 29); document method versions v5: single_document_path_query 1 selects the latest retained revision at or before a block time, and verify_proof_keep_serialized 1 verifies it (note 31); retained-history writers, readers, estimates and verifiers select the per-type revision layout (note 35); add_new_keys_to_masternode_identity 1 adds a masternode key whose hash the identity already holds a reference for (note 32); document method versions v5: insert.add_document_for_contract_operations 2, delete.delete_document_for_contract_operations 1, delete.remove_document_from_primary_storage 1 and its estimate 1, query.fetch_document_lifecycle Some(0), and the erase/lifecycle estimate and erase_refund_recipient_cost selectors Some(0); batch_operations.convert_drive_operations_to_grove_operations 2; state transition method versions v5: document_delete_transition 1 and document_erase_transition Some(0); verify methods v4: single_document.verify_proof 1 extend retained history (note 41); document method versions v5: add_indices_for_top_index_level_for_contract_operations 3 writes no entry in an expired time range bucket (note 36) @@ -911,7 +931,7 @@ pub const PLATFORM_V15: PlatformVersion = PlatformVersion { state_transition_conversion_versions: STATE_TRANSITION_CONVERSION_VERSIONS_V2, state_transition_method_versions: STATE_TRANSITION_METHOD_VERSIONS_V2, state_transitions: STATE_TRANSITION_VERSIONS_V5, // changed: validate_asset_lock_transaction_structure 1 drops the input cap and validate_instant_asset_lock_proof_structure 1 applies it to instant proofs only, so a chain proof redeems a lock of more than 100 inputs (note 30) - contract_versions: CONTRACT_VERSIONS_V7, // changed: parse_property_constraints 1 lets countOf and sumOf match byte array keys (note 4); validate_document 2 checks documents natively (note 6); check_document_type_schema 1 checks schemas natively at registration (note 7); contract_storage_serialization_version 2 stores contracts compiled (note 8); parse_private_document 0 parses private document types (note 13); apply_generated_from 1 admits sys.tokens.decimals (note 15); try_from_schema 4 parses lifecycle flags (note 41) + contract_versions: CONTRACT_VERSIONS_V7, // changed: parse_property_constraints 1 lets countOf and sumOf match byte array keys (note 4); validate_document 2 checks documents natively (note 6); check_document_type_schema 1 checks schemas natively at registration (note 7); contract_storage_serialization_version 2 stores contracts compiled (note 8); parse_private_document 0 parses private document types (note 13); apply_generated_from 1 admits sys.tokens.decimals (note 15); try_from_schema 4 parses lifecycle flags (note 41); validate_schema_patterns 0 bounds the patterns of a contract and registration_cost 3 estimates its fee without compiling one (note 42) document_versions: DOCUMENT_VERSIONS_V4, identity_versions: IDENTITY_VERSIONS_V1, voting_versions: VOTING_VERSION_V3, // changed: the yes/no poll's stored info, id, parameter rules and decision rules are active (note 10), and the decision proposal's poll (note 12) From 7db39b847ba94cc14a14f30ec3652ad7a23c86ad Mon Sep 17 00:00:00 2001 From: lklimek <842586+lklimek@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:16:27 +0100 Subject: [PATCH 12/26] refactor: reject legacy BLS storage formats (#5323) Co-authored-by: pasta Co-authored-by: Claude Opus 5.5 (1M context) Co-authored-by: infraclaw-dash Co-authored-by: ktechmidas <9920871+ktechmidas@users.noreply.github.com> Co-authored-by: Codex --- .github/SELF_HOSTED_RUNNER.md | 6 +- .github/actions/npm-release-build/action.yaml | 2 +- .github/workflows/kotlin-sdk-build.yml | 2 +- .github/workflows/release-kotlin-sdk.yml | 2 +- .github/workflows/tests-rs-workspace.yml | 4 +- Cargo.lock | 23 +- packages/rs-drive-abci/Cargo.toml | 7 +- .../update_operator_identity/v0/mod.rs | 44 +--- .../storage/fetch_platform_state/mod.rs | 48 +++- .../src/mimic/fixtures/README.md | 15 ++ .../src/mimic/fixtures/core_quorums.json | 63 +++++ .../rs-drive-abci/src/mimic/test_quorum.rs | 230 ++++++++++++++---- .../rs-drive-abci/src/platform_types/mod.rs | 2 + .../src/platform_types/platform_state/mod.rs | 77 ++++-- .../platform_state_for_saving/mod.rs | 4 +- .../platform_state_for_saving/v0/mod.rs | 114 ++------- .../v0/old_structures/mod.rs | 128 +--------- .../signature_verification_quorum_set/mod.rs | 40 ++- .../v0/fixtures/README.md | 6 +- .../v0/for_saving_v0.rs | 230 ++---------------- .../v0/for_saving_v1.rs | 74 ++---- .../v0/for_saving_v2.rs | 4 - .../v0/mod.rs | 4 +- .../v0/storage_tests.rs | 29 ++- .../unsupported_legacy_bls_storage.rs | 13 + .../src/test/fixture/platform_state.rs | 15 ++ .../masternode_list_item_helpers.rs | 22 +- .../tests/strategy_tests/masternodes.rs | 22 +- 28 files changed, 553 insertions(+), 677 deletions(-) create mode 100644 packages/rs-drive-abci/src/mimic/fixtures/README.md create mode 100644 packages/rs-drive-abci/src/mimic/fixtures/core_quorums.json create mode 100644 packages/rs-drive-abci/src/platform_types/unsupported_legacy_bls_storage.rs diff --git a/.github/SELF_HOSTED_RUNNER.md b/.github/SELF_HOSTED_RUNNER.md index 6978bff1889..c753839f6e1 100644 --- a/.github/SELF_HOSTED_RUNNER.md +++ b/.github/SELF_HOSTED_RUNNER.md @@ -27,13 +27,17 @@ downloaded toolchains to exact URLs and SHA-256 hashes. It includes: | Toolchain | Contract | | --- | --- | -| Native build | build-essential, clang/LLVM, Snappy, CMake, GMP, OpenSSL, pkg-config | +| Native build | build-essential, clang/LLVM, GMP, Snappy, CMake, OpenSSL, pkg-config | | Rust | rustup plus the repository baseline; exact repo-selected toolchains may be installed user-locally | | Cargo helpers | llvm-cov **0.9.1**, nextest **0.9.144**, machete **0.9.2**, ndk **4.1.2** | | Protobuf / Java | protoc **32.0**, JDK **17** | | Android | API **35**, build-tools **35.0.0**, NDK **28.1.13356709**, pinned emulator/system image | | Other job tools | Git, GitHub CLI, jq, Python 3, gpg, zip/unzip | +GMP remains in both image manifests because the pinned trusted publisher requires +it. Rust no longer needs it after the legacy BLS crate removal; dropping it from +the images requires updating the publisher contract first. + The SDK is image-owned. The persistent Kotlin workflow uses the image's `ci-android-emulator` wrapper to create user-writable AVDs, boot with KVM, and stop the emulator after testing. It does **not** run setup-android, sdkmanager, or an diff --git a/.github/actions/npm-release-build/action.yaml b/.github/actions/npm-release-build/action.yaml index 6250df11fa2..dec33ffbd0b 100644 --- a/.github/actions/npm-release-build/action.yaml +++ b/.github/actions/npm-release-build/action.yaml @@ -14,7 +14,7 @@ runs: ci-image-contract verify .github/runner-requirements.json python3 packages/dapi-grpc/scripts/setup-codegen.py - for pkg in build-essential cmake curl jq libgmp-dev libssl-dev pkg-config python3 unzip zip; do + for pkg in build-essential cmake curl jq libssl-dev pkg-config python3 unzip zip; do dpkg-query -W -f='${Status}' "$pkg" | grep -Fx 'install ok installed' done test -x "$HOME/.cargo/bin/rustup" diff --git a/.github/workflows/kotlin-sdk-build.yml b/.github/workflows/kotlin-sdk-build.yml index f1fc725e270..e488dcf1ca5 100644 --- a/.github/workflows/kotlin-sdk-build.yml +++ b/.github/workflows/kotlin-sdk-build.yml @@ -95,7 +95,7 @@ jobs: for tool in cmake curl jq python3 rustup unzip zip; do command -v "$tool" >/dev/null 2>&1 || missing+=("$tool") done - for pkg in build-essential libgmp-dev libpulse0 libssl-dev libx11-xcb1 pkg-config; do + for pkg in build-essential libpulse0 libssl-dev libx11-xcb1 pkg-config; do dpkg -s "$pkg" >/dev/null 2>&1 || missing+=("$pkg") done if [ ${#missing[@]} -gt 0 ]; then diff --git a/.github/workflows/release-kotlin-sdk.yml b/.github/workflows/release-kotlin-sdk.yml index 6d568495770..c7b38a4e0b0 100644 --- a/.github/workflows/release-kotlin-sdk.yml +++ b/.github/workflows/release-kotlin-sdk.yml @@ -91,7 +91,7 @@ jobs: run: | set -euo pipefail - for pkg in build-essential cmake curl gh jq libgmp-dev libpulse0 libssl-dev libx11-xcb1 pkg-config python3 unzip zip; do + for pkg in build-essential cmake curl gh jq libpulse0 libssl-dev libx11-xcb1 pkg-config python3 unzip zip; do dpkg-query -W -f='${Status}' "$pkg" | grep -Fx 'install ok installed' done test -x "$HOME/.cargo/bin/rustup" diff --git a/.github/workflows/tests-rs-workspace.yml b/.github/workflows/tests-rs-workspace.yml index 7e766cded80..26ef3419bb1 100644 --- a/.github/workflows/tests-rs-workspace.yml +++ b/.github/workflows/tests-rs-workspace.yml @@ -172,7 +172,7 @@ jobs: missing=1 fi done - for library in /opt/homebrew/opt/gmp/include/gmp.h /opt/homebrew/opt/gmp/lib/libgmp.dylib /opt/homebrew/opt/llvm/lib/libclang.dylib; do + for library in /opt/homebrew/opt/llvm/lib/libclang.dylib; do if [ ! -r "$library" ]; then echo "::error::Missing or unreadable $library. Provision this dependency on the runner before running CI." missing=1 @@ -192,7 +192,7 @@ jobs: for tool in clang cmake gh jq llvm-config rustup zip; do command -v "$tool" >/dev/null 2>&1 || missing+=("$tool") done - for pkg in build-essential clang libgmp-dev libsnappy-dev libssl-dev llvm pkg-config; do + for pkg in build-essential clang libsnappy-dev libssl-dev llvm pkg-config; do dpkg -s "$pkg" >/dev/null 2>&1 || missing+=("$pkg") done if [ ${#missing[@]} -gt 0 ]; then diff --git a/Cargo.lock b/Cargo.lock index 533e6c7cc37..0d3f3b9ca61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -833,27 +833,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bls-dash-sys" -version = "1.2.5" -source = "git+https://github.com/dashpay/bls-signatures?rev=0842b17583888e8f46c252a4ee84cdfd58e0546f#0842b17583888e8f46c252a4ee84cdfd58e0546f" -dependencies = [ - "bindgen 0.65.1", - "cc", - "glob", -] - -[[package]] -name = "bls-signatures" -version = "1.2.5" -source = "git+https://github.com/dashpay/bls-signatures?rev=0842b17583888e8f46c252a4ee84cdfd58e0546f#0842b17583888e8f46c252a4ee84cdfd58e0546f" -dependencies = [ - "bls-dash-sys", - "hex", - "rand 0.8.6", - "serde", -] - [[package]] name = "bls12_381" version = "0.8.0" @@ -2496,7 +2475,6 @@ dependencies = [ "assert_matches", "async-trait", "blake3", - "bls-signatures", "bytes", "chrono", "ciborium", @@ -2505,6 +2483,7 @@ dependencies = [ "dapi-grpc", "dash-platform-macros", "dash-platform-queries", + "dashcore-crypto", "delegate", "derive_more 1.0.0", "dotenvy", diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index d95b730e78b..bd7ecc81a38 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -81,7 +81,7 @@ tokio-util = { version = "0.7" } derive_more = { version = "1.0", features = ["from", "deref", "deref_mut"] } async-trait = "0.1.77" console-subscriber = { version = "0.4", optional = true } -bls-signatures = { git = "https://github.com/dashpay/bls-signatures", rev = "0842b17583888e8f46c252a4ee84cdfd58e0546f", optional = true } +dashcore-crypto = { workspace = true, features = ["bls"], optional = true } grovedb-commitment-tree = { workspace = true } nonempty = "0.11" # Shielded-pool snapshot needs raw RocksDB SstFileWriter + ingest_external_file_cf @@ -121,7 +121,6 @@ strategy-tests = { path = "../strategy-tests" } grovedb-commitment-tree = { workspace = true, features = ["client"] } assert_matches = "1.5.0" drive-abci = { path = ".", features = ["testing-config", "mocks", "shielded_test_data"] } -bls-signatures = { git = "https://github.com/dashpay/bls-signatures", rev = "0842b17583888e8f46c252a4ee84cdfd58e0546f" } mockall = { version = "0.13" } dash-platform-macros = { path = "../rs-dash-platform-macros" } libc = "0.2" @@ -136,8 +135,8 @@ grovedb-path = { workspace = true } grovedb-storage = { workspace = true } [features] -default = ["bls-signatures"] -mocks = ["mockall", "drive/fixtures-and-mocks", "bls-signatures"] +default = [] +mocks = ["mockall", "drive/fixtures-and-mocks", "dep:dashcore-crypto"] console = ["console-subscriber", "tokio/tracing"] testing-config = [] # Compiles in the shielded-pool seeder, the `snapshot-bake` subcommand, and diff --git a/packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/update_operator_identity/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/update_operator_identity/v0/mod.rs index 40630e61aec..67cb2fc3c69 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/update_operator_identity/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/update_operator_identity/v0/mod.rs @@ -426,16 +426,7 @@ mod tests { let node_id_bytes: [u8; 20] = rng.gen(); // Create a public key operator and payout address - let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(rng) - .expect("expected to generate a private key") - .to_bytes() - .to_vec(); - let private_key_operator = BlsPrivateKey::from_be_bytes( - &private_key_operator_bytes - .try_into() - .expect("expected the secret key to be 32 bytes"), - ) - .expect("Core fixture secret key must decode"); + let private_key_operator = BlsPrivateKey::random(&mut *rng); let pub_key_operator = private_key_operator.public_key().to_bytes().to_vec(); let operator_key: IdentityPublicKey = IdentityPublicKeyV0 { @@ -970,16 +961,7 @@ mod tests { ) = create_operator_identity(&platform, &mut rng); // Generate a new public key operator - let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(&mut rng) - .expect("expected to generate a private key") - .to_bytes() - .to_vec(); - let private_key_operator = BlsPrivateKey::from_be_bytes( - &private_key_operator_bytes - .try_into() - .expect("expected the secret key to be 32 bytes"), - ) - .expect("Core fixture secret key must decode"); + let private_key_operator = BlsPrivateKey::random(&mut rng); let new_pub_key_operator = private_key_operator.public_key().to_bytes().to_vec(); // Create an old masternode state @@ -1068,16 +1050,7 @@ mod tests { ) = create_operator_identity(&platform, &mut rng); // Pre-create an operator identity for the new operator key that lacks the platform node key - let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(&mut rng) - .expect("expected to generate a private key") - .to_bytes() - .to_vec(); - let private_key_operator = BlsPrivateKey::from_be_bytes( - &private_key_operator_bytes - .try_into() - .expect("expected the secret key to be 32 bytes"), - ) - .expect("Core fixture secret key must decode"); + let private_key_operator = BlsPrivateKey::random(&mut rng); let new_pub_key_operator = private_key_operator.public_key().to_bytes().to_vec(); let new_operator_identifier = Identifier::create_operator_identifier( @@ -1210,16 +1183,7 @@ mod tests { ) = create_operator_identity(&platform, &mut rng); // Generate a new public key operator - let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(&mut rng) - .expect("expected to generate a private key") - .to_bytes() - .to_vec(); - let private_key_operator = BlsPrivateKey::from_be_bytes( - &private_key_operator_bytes - .try_into() - .expect("expected the secret key to be 32 bytes"), - ) - .expect("Core fixture secret key must decode"); + let private_key_operator = BlsPrivateKey::random(&mut rng); let new_pub_key_operator = private_key_operator.public_key().to_bytes().to_vec(); // Create an old masternode state with original public key operator diff --git a/packages/rs-drive-abci/src/execution/storage/fetch_platform_state/mod.rs b/packages/rs-drive-abci/src/execution/storage/fetch_platform_state/mod.rs index 20156496066..2c54dea975b 100644 --- a/packages/rs-drive-abci/src/execution/storage/fetch_platform_state/mod.rs +++ b/packages/rs-drive-abci/src/execution/storage/fetch_platform_state/mod.rs @@ -44,7 +44,8 @@ mod tests { use crate::platform_types::signature_verification_quorum_set::SignatureVerificationQuorumSetV0Methods; use crate::rpc::core::MockCoreRPCLike; use crate::test::fixture::platform_state::{ - PLATFORM_STATE_V3_TESTNET, PLATFORM_STATE_V8_DEVNET, + PLATFORM_STATE_V3_TESTNET, PLATFORM_STATE_V3_TESTNET_SUPPORTED, PLATFORM_STATE_V8_DEVNET, + PLATFORM_STATE_V8_DEVNET_SUPPORTED, }; use crate::test::helpers::setup::TestPlatformBuilder; use dpp::dashcore_rpc::json::QuorumType; @@ -56,21 +57,58 @@ mod tests { /// A saved quorum config: its type, active signers, rotation and window type SavedQuorumConfig = (QuorumType, u16, bool, u32); - /// A testnet state in the first saved format and a devnet state in the second, each with - /// the chain lock quorum config it was saved with + /// A testnet and a devnet state in the supported saved format, each with the chain lock + /// quorum config it was saved with fn fixtures() -> [(&'static str, SavedQuorumConfig); 2] { [ ( - PLATFORM_STATE_V3_TESTNET.deref(), + PLATFORM_STATE_V3_TESTNET_SUPPORTED.deref(), (QuorumType::Llmq50_60, 24, false, 24), ), ( - PLATFORM_STATE_V8_DEVNET.deref(), + PLATFORM_STATE_V8_DEVNET_SUPPORTED.deref(), (QuorumType::LlmqDevnet, 4, false, 24), ), ] } + #[test] + fn should_refuse_to_restore_saved_state_in_a_retired_legacy_bls_format() { + let platform = TestPlatformBuilder::new().build_with_mock_rpc(); + + // Protocol version 13 reads the saved state with fetch_platform_state v0, 14 with v1 + for platform_version in [PlatformVersion::get(13).unwrap(), PlatformVersion::latest()] { + for fixture in [ + PLATFORM_STATE_V3_TESTNET.deref(), + PLATFORM_STATE_V8_DEVNET.deref(), + ] { + let transaction = platform.drive.grove.start_transaction(); + platform + .drive + .store_platform_state_bytes( + &hex::decode(fixture).unwrap(), + Some(&transaction), + platform_version, + ) + .unwrap(); + let result = Platform::::fetch_platform_state( + &platform.drive, + Some(&transaction), + platform_version, + ); + assert!( + matches!( + &result, + Err(Error::Protocol(ProtocolError::PlatformDeserializationError(message))) + if message.contains("Unsupported legacy BLS state format") + ), + "protocol version {}: got {result:?}", + platform_version.protocol_version + ); + } + } + } + /// The bytes of `fixture` with its chain lock quorum config, saved as `saved`, holding /// `active_signers` and `window`, encoded the way a `u16` and a `u32` were fn with_chain_lock_quorum_config( diff --git a/packages/rs-drive-abci/src/mimic/fixtures/README.md b/packages/rs-drive-abci/src/mimic/fixtures/README.md new file mode 100644 index 00000000000..b3af06294d0 --- /dev/null +++ b/packages/rs-drive-abci/src/mimic/fixtures/README.md @@ -0,0 +1,15 @@ +# Core quorum compatibility vectors + +`core_quorums.json` freezes outputs from `dashpay/bls-signatures` at +`0842b17583888e8f46c252a4ee84cdfd58e0546f`, captured before its removal. +These synthetic keys are public test material. + +Each case seeds rand 0.8.5 `StdRng` with 42, calls `PrivateKey::generate_dash_many` +for 2, 3 or 5 members, and calls `PrivateKey::threshold_recover` on those keys. +Member index `i` has a 32-byte ID with byte 0 equal to `i + 1`, byte 31 equal +to `i + 11`, and all other bytes zero. The asymmetric IDs pin Core's scalar +byte order. Signatures use the Basic scheme over `b"quorum compatibility"`. + +The test checks generated member keys, the interpolated quorum key, and its +signature against these frozen values. It preserves an independent compatibility +oracle without linking or building the historical implementation. diff --git a/packages/rs-drive-abci/src/mimic/fixtures/core_quorums.json b/packages/rs-drive-abci/src/mimic/fixtures/core_quorums.json new file mode 100644 index 00000000000..400a85759f2 --- /dev/null +++ b/packages/rs-drive-abci/src/mimic/fixtures/core_quorums.json @@ -0,0 +1,63 @@ +[ + { + "members": [ + { + "secret_key": "60cc232b5d9fd6f6a17b9f807e17d269463b8be9d79d8c8d8e7b7325467ef724", + "public_key": "85d81dd12c73cca83f7d1bf8b78fadb695e3a2bc21d53b35ff2f74eaa28c6e163c98d3d5f9bb7252b4d836e484c7cc60" + }, + { + "secret_key": "60d4cd010b78057205135c1024f2e62847e5f2a94cb429011bb28680a3e27ba4", + "public_key": "969c5d5873f49aa994c5f6a850924ca1840c4ad1791aaaecd90093d4a5c0c3799f2d98540f5366cfa0a33f143fd69263" + } + ], + "secret_key": "1fcedaede8dcf78f22a37886ba8c5a6819b54f0df353226fde8254ded687f4be", + "public_key": "af9b0df76bd36c822a3c033a32a9f85a2dd1c2f608d8f77fabe86f3e642f71d7c6b391c6aa1fe47e9b4dfba9a0f86a0c", + "signature": "ad5b7abba9e99925463851e70bd76f80f0be6f72ebf6d7a5cbcb7d94eac919708666e2669f3448b383bf178c08c41c6a015e242e7c2b898772bdf36b2e17f529876f89367e791dc1b059e3170b2f656cf77c64fe3d942aa6775f5c38147d9897" + }, + { + "members": [ + { + "secret_key": "60cc232b5d9fd6f6a17b9f807e17d269463b8be9d79d8c8d8e7b7325467ef724", + "public_key": "85d81dd12c73cca83f7d1bf8b78fadb695e3a2bc21d53b35ff2f74eaa28c6e163c98d3d5f9bb7252b4d836e484c7cc60" + }, + { + "secret_key": "60d4cd010b78057205135c1024f2e62847e5f2a94cb429011bb28680a3e27ba4", + "public_key": "969c5d5873f49aa994c5f6a850924ca1840c4ad1791aaaecd90093d4a5c0c3799f2d98540f5366cfa0a33f143fd69263" + }, + { + "secret_key": "1875901a20c05263718b60b6c7d076d17f198be2c1c74076a987a8247b831374", + "public_key": "82e296280f7b8220cf4822c6767f1dac24a55e2ef4250ba3690ef17207ebfc3de1b0af1e1b92a3b0a5db73c3dff3e82e" + } + ], + "secret_key": "6a7016bc45678d62d7f42c98c20b70d183579cd811b13e1bb832b8f15b317366", + "public_key": "94074dae16b081c8c4eb132cf0be7e718f83bb51e7e1ebc557adb21776344a161067a73e50b04251051a48d6ce5005f3", + "signature": "89359843132417bf3112e0ab09bc64904dbce8ce07e55f4cf65f0c6dd8179e46f89e1eecf94c18a7903fcd054874a0f416d427a594105d83e256ab4d45f57679d6c298d5659fd4189290a90c9489ea3e36218d8f70ac7854fae10fc07c56ad90" + }, + { + "members": [ + { + "secret_key": "60cc232b5d9fd6f6a17b9f807e17d269463b8be9d79d8c8d8e7b7325467ef724", + "public_key": "85d81dd12c73cca83f7d1bf8b78fadb695e3a2bc21d53b35ff2f74eaa28c6e163c98d3d5f9bb7252b4d836e484c7cc60" + }, + { + "secret_key": "60d4cd010b78057205135c1024f2e62847e5f2a94cb429011bb28680a3e27ba4", + "public_key": "969c5d5873f49aa994c5f6a850924ca1840c4ad1791aaaecd90093d4a5c0c3799f2d98540f5366cfa0a33f143fd69263" + }, + { + "secret_key": "1875901a20c05263718b60b6c7d076d17f198be2c1c74076a987a8247b831374", + "public_key": "82e296280f7b8220cf4822c6767f1dac24a55e2ef4250ba3690ef17207ebfc3de1b0af1e1b92a3b0a5db73c3dff3e82e" + }, + { + "secret_key": "36e6194880c3797f0ee82a463b5bf94d69462756b62a0fbe88fe3f706b1540aa", + "public_key": "8a2f736a2488f75742c863f5e57430c77b6fd7a96b2cebff104319ddee98a2afcf181b0448bc7af7847b478af2ec4ec2" + }, + { + "secret_key": "0625b848ac8adcf9a492c608b6f3c68de3a695ee52684282a359dd1485982094", + "public_key": "b60530373ad3505639863ed4c3d56c9ad90c7385b3e81bc66dde9705ff5b9b090957ae1b2010036e28457aa14e9ba4bd" + } + ], + "secret_key": "1e998cb2d5e16542273243f3a39146714b1f52e51d882051654fd01d2ffbccf0", + "public_key": "b11e0e7d90633d09f69aedcc1c2853c30357bc3cff19682c693bc1bdef488bf87119290f0aae643227ba91bdeb43de7e", + "signature": "b9f8f49b1c38b4c9d96a6c9812d8c58961783f7b68e1925953f0d19e5b968223800dd7695348f576db68164a36b66b68136a4ed2699f7c0627ee9d153d1c1ba8077886f39614d773564e415652b7a2bb32044f8d253e82b7dcf8a0e971de722d" + } +] diff --git a/packages/rs-drive-abci/src/mimic/test_quorum.rs b/packages/rs-drive-abci/src/mimic/test_quorum.rs index 9625c6f1645..aa6f4de56ae 100644 --- a/packages/rs-drive-abci/src/mimic/test_quorum.rs +++ b/packages/rs-drive-abci/src/mimic/test_quorum.rs @@ -1,6 +1,8 @@ use crate::platform_types::validator::v0::ValidatorV0; use crate::platform_types::validator_set::v0::ValidatorSetV0; -use dpp::bls::{PublicKey as BlsPublicKey, PublicKey, SecretKey as BlsPrivateKey, SecretKey}; +use dashcore_crypto::dash_pkc::__deps::ff::{Field, PrimeField}; +use dashcore_crypto::dash_pkc::bls::Fr; +use dpp::bls::{PublicKey as BlsPublicKey, SecretKey as BlsPrivateKey}; use dpp::dashcore::{ProTxHash, PubkeyHash, QuorumHash}; use dpp::dashcore_rpc::dashcore_rpc_json::{QuorumInfoResult, QuorumMember, QuorumType}; use rand::rngs::StdRng; @@ -122,6 +124,39 @@ fn random_socket_addr(rng: &mut StdRng) -> SocketAddr { SocketAddr::new(IpAddr::V4(random_ipv4_address(rng)), random_port(rng)) } +// TODO: replace this mock-only interpolation with dash-pkc secret-share recovery. +// https://github.com/dashpay/base-sdk/issues/113 +fn recover_quorum_private_key(members: &[(ProTxHash, BlsPrivateKey)]) -> BlsPrivateKey { + assert!(members.len() >= 2, "expected at least two quorum members"); + // Core reads the stored proTxHash bytes as a big-endian scalar, reduced modulo r. + let ids: Vec<_> = members + .iter() + .map(|(id, _)| { + Fr::from_bendian_reduce(&id.to_byte_array()).expect("nonzero quorum member id") + }) + .collect(); + let mut recovered = Fr::ZERO; + for (i, (_, key)) in members.iter().enumerate() { + // Interpolate the mock secret shares at zero: product of x_j / (x_j - x_i). + let mut numerator = Fr::ONE; + let mut denominator = Fr::ONE; + for (j, id) in ids.iter().enumerate() { + if i != j { + numerator *= id; + denominator *= *id - ids[i]; + } + } + let inverse = denominator + .invert() + .expect("distinct quorum member identifiers"); + let scalar = Fr::from_bendian_reduce(&key.to_be_bytes()).expect("nonzero member key"); + recovered += scalar * numerator * inverse; + } + let mut bytes = recovered.to_repr(); + bytes.reverse(); + BlsPrivateKey::from_be_bytes(&bytes).expect("nonzero recovered quorum private key") +} + impl TestQuorumInfo { /// Constructs a new `TestQuorumInfo` object from a quorum hash and a list of `ProTxHash` identifiers. /// The `TestQuorumInfo` object contains a set of validators, as well as a map of validators indexed by their @@ -133,39 +168,21 @@ impl TestQuorumInfo { pro_tx_hashes: Vec, rng: &mut StdRng, ) -> Self { - // We test on purpose with the bls library that Dash Core uses - let private_keys = bls_signatures::PrivateKey::generate_dash_many(pro_tx_hashes.len(), rng) - .expect("expected to generate private keys"); - assert_eq!( - private_keys.len(), - pro_tx_hashes.len(), - "zipped private keys and pro_tx_hashes must have the same length" - ); - let bls_id_private_key_pairs = private_keys + let members: Vec<_> = pro_tx_hashes .into_iter() - .zip(pro_tx_hashes) - .map(|(private_key, pro_tx_hashes)| { - (pro_tx_hashes.to_byte_array().to_vec(), private_key) - }) - .collect::>(); - let recovered_private_key = - bls_signatures::PrivateKey::threshold_recover(&bls_id_private_key_pairs) - .expect("expected to recover a private key"); - let validator_set: Vec<_> = bls_id_private_key_pairs + .map(|id| (id, BlsPrivateKey::random(&mut *rng))) + .collect(); + let recovered_private_key = recover_quorum_private_key(&members); + let validator_set: Vec<_> = members .into_iter() .map(|(pro_tx_hash, key)| { - let public_key = key.g1_element().expect("expected to get public key"); + let public_key = key.public_key(); ValidatorInQuorum { - pro_tx_hash: ProTxHash::from_slice(pro_tx_hash.as_slice()) - .expect("expected 32 bytes for pro_tx_hash"), - private_key: SecretKey::from_be_bytes( - &key.to_bytes().to_vec().try_into().expect("32 bytes"), - ) - .expect("expected conversion to work"), - public_key: PublicKey::try_from(public_key.to_bytes().as_slice()) - .expect("expected conversion to work"), + pro_tx_hash, + private_key: key, + public_key, node_ip: random_socket_addr(rng).to_string(), - node_id: PubkeyHash::from_slice(pro_tx_hash.split_at(20).0).unwrap(), + node_id: PubkeyHash::from_slice(&pro_tx_hash.to_byte_array()[..20]).unwrap(), core_port: 1, platform_http_port: 2, platform_p2p_port: 3, @@ -173,9 +190,7 @@ impl TestQuorumInfo { } }) .collect(); - let public_key = recovered_private_key - .g1_element() - .expect("expected to get G1 Element"); + let public_key = recovered_private_key.public_key(); let map = validator_set .iter() .map(|v| (v.pro_tx_hash, v.clone())) @@ -186,16 +201,8 @@ impl TestQuorumInfo { quorum_index, validator_set, validator_map: map, - private_key: SecretKey::from_be_bytes( - &recovered_private_key - .to_bytes() - .to_vec() - .try_into() - .expect("32 bytes"), - ) - .expect("expected conversion to work"), - public_key: PublicKey::try_from(public_key.to_bytes().as_slice()) - .expect("expected conversion to work"), + private_key: recovered_private_key, + public_key, } } } @@ -287,3 +294,142 @@ impl From<&TestQuorumInfo> for QuorumInfoResult { } } } + +#[cfg(test)] +mod tests { + use super::*; + use rand::SeedableRng; + use serde::Deserialize; + + #[derive(Deserialize)] + struct MemberVector { + secret_key: String, + public_key: String, + } + + #[derive(Deserialize)] + struct QuorumVector { + members: Vec, + secret_key: String, + public_key: String, + signature: String, + } + + fn member_hash(index: u8) -> ProTxHash { + let mut id = [0; 32]; + id[0] = index + 1; + id[31] = index + 11; + ProTxHash::from_byte_array(id) + } + + #[test] + fn should_preserve_frozen_core_quorum_keys_and_signatures() { + let vectors: Vec = + serde_json::from_str(include_str!("fixtures/core_quorums.json")).unwrap(); + assert_eq!(vectors.len(), 3); + for vector in vectors { + let ids = (0..vector.members.len()) + .map(|i| member_hash(i as u8)) + .collect(); + let quorum = TestQuorumInfo::from_quorum_hash_and_pro_tx_hashes( + 100, + QuorumHash::from_byte_array([42; 32]), + Some(1), + ids, + &mut StdRng::seed_from_u64(42), + ); + for (member, expected) in quorum.validator_set.iter().zip(vector.members) { + assert_eq!( + hex::encode(member.private_key.to_be_bytes()), + expected.secret_key + ); + assert_eq!( + hex::encode(member.public_key.to_bytes()), + expected.public_key + ); + let signature = member.private_key.sign(b"quorum compatibility").unwrap(); + signature + .verify(&member.public_key, b"quorum compatibility") + .unwrap(); + } + assert_eq!( + hex::encode(quorum.private_key.to_be_bytes()), + vector.secret_key + ); + assert_eq!(hex::encode(quorum.public_key.to_bytes()), vector.public_key); + let signature = quorum.private_key.sign(b"quorum compatibility").unwrap(); + assert_eq!(hex::encode(signature.to_bytes()), vector.signature); + signature + .verify(&quorum.public_key, b"quorum compatibility") + .unwrap(); + } + } + + #[test] + #[should_panic(expected = "at least two quorum members")] + fn should_reject_an_empty_quorum() { + TestQuorumInfo::from_quorum_hash_and_pro_tx_hashes( + 100, + QuorumHash::from_byte_array([42; 32]), + None, + vec![], + &mut StdRng::seed_from_u64(42), + ); + } + + #[test] + #[should_panic(expected = "at least two quorum members")] + fn should_reject_a_single_quorum_member() { + TestQuorumInfo::from_quorum_hash_and_pro_tx_hashes( + 100, + QuorumHash::from_byte_array([42; 32]), + None, + vec![member_hash(0)], + &mut StdRng::seed_from_u64(42), + ); + } + + #[test] + #[should_panic(expected = "distinct quorum member identifiers")] + fn should_reject_duplicate_quorum_members() { + TestQuorumInfo::from_quorum_hash_and_pro_tx_hashes( + 100, + QuorumHash::from_byte_array([42; 32]), + None, + vec![member_hash(0); 2], + &mut StdRng::seed_from_u64(42), + ); + } + + #[test] + #[should_panic(expected = "nonzero quorum member id")] + fn should_reject_a_zero_quorum_member_identifier() { + TestQuorumInfo::from_quorum_hash_and_pro_tx_hashes( + 100, + QuorumHash::from_byte_array([42; 32]), + None, + vec![ProTxHash::all_zeros(), member_hash(0)], + &mut StdRng::seed_from_u64(42), + ); + } + + #[test] + #[should_panic(expected = "distinct quorum member identifiers")] + fn should_reject_member_identifiers_equal_modulo_the_scalar_order() { + let mut one = [0; 32]; + one[31] = 1; + let order_plus_one = + hex::decode("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000002") + .unwrap(); + TestQuorumInfo::from_quorum_hash_and_pro_tx_hashes( + 100, + QuorumHash::from_byte_array([42; 32]), + None, + vec![ + ProTxHash::from_byte_array(one), + ProTxHash::from_slice(&order_plus_one).unwrap(), + ], + &mut StdRng::seed_from_u64(42), + ); + } +} diff --git a/packages/rs-drive-abci/src/platform_types/mod.rs b/packages/rs-drive-abci/src/platform_types/mod.rs index 0f3b33981de..b9a6b1587f4 100644 --- a/packages/rs-drive-abci/src/platform_types/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/mod.rs @@ -24,6 +24,8 @@ pub mod required_identity_public_key_set; pub mod signature_verification_quorum_set; /// The state transition execution result as part of the block execution outcome pub mod state_transitions_processing_result; +/// Rejection of unsupported legacy BLS storage formats. +pub(crate) mod unsupported_legacy_bls_storage; /// The validator module /// A validator is a masternode that can participate in consensus by being part of a validator set pub mod validator; diff --git a/packages/rs-drive-abci/src/platform_types/platform_state/mod.rs b/packages/rs-drive-abci/src/platform_types/platform_state/mod.rs index 51bd37a2884..070b6fb1cae 100644 --- a/packages/rs-drive-abci/src/platform_types/platform_state/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/platform_state/mod.rs @@ -324,18 +324,7 @@ impl TryFromPlatformVersioned for PlatformState { platform_version: &PlatformVersion, ) -> Result { match value { - PlatformStateForSaving::V0(v0) => { - match platform_version.drive_abci.structs.platform_state_structure { - 0 => Ok(PlatformState::from(v0)), - version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: - "PlatformState::try_from_platform_versioned(PlatformStateForSavingV0)" - .to_string(), - known_versions: vec![0], - received: version, - })), - } - } + PlatformStateForSaving::V0(retired) => match retired {}, PlatformStateForSaving::V1(v1) => { match platform_version.drive_abci.structs.platform_state_structure { 0 => Ok(PlatformState::from(v1)), @@ -369,26 +358,36 @@ mod tests { mod versioned_deserialize { use super::*; use crate::test::fixture::platform_state::{ - PLATFORM_STATE_V3_TESTNET, PLATFORM_STATE_V8_DEVNET, + PLATFORM_STATE_V3_TESTNET, PLATFORM_STATE_V8_DEVNET, PLATFORM_STATE_V8_DEVNET_SUPPORTED, }; use platform_version::version::v3::PLATFORM_V3; use platform_version::version::v9::PLATFORM_V9; use std::ops::Deref; #[test] - fn should_deserialize_state_stored_in_version_0_from_testnet() { + fn should_reject_legacy_bls_state_from_testnet_with_upgrade_instructions() { let serialized_state = hex::decode(PLATFORM_STATE_V3_TESTNET.deref()).expect("failed to decode hex"); - PlatformState::versioned_deserialize_trusted(&serialized_state, &PLATFORM_V3) - .expect("failed to deserialize state"); + let error = + match PlatformState::versioned_deserialize_trusted(&serialized_state, &PLATFORM_V3) + { + Ok(_) => panic!("legacy state must require an intermediate upgrade"), + Err(error) => error, + }; + assert!(matches!( + error, + ProtocolError::PlatformDeserializationError(_) + )); + assert!(error.to_string().contains("v4.0.0")); + assert!(error.to_string().contains("commit at least one block")); } /// Serializing through the borrowed conversion must preserve the saved format. #[test] fn should_preserve_pre_change_serialization_hash() { - let serialized_state = - hex::decode(PLATFORM_STATE_V8_DEVNET.deref()).expect("failed to decode hex"); + let serialized_state = hex::decode(PLATFORM_STATE_V8_DEVNET_SUPPORTED.deref()) + .expect("failed to decode hex"); let state = PlatformState::versioned_deserialize_trusted(&serialized_state, &PLATFORM_V9) @@ -405,12 +404,48 @@ mod tests { } #[test] - fn should_deserialize_state_stored_in_version_8_from_devnet() { + fn should_preserve_supported_storage_tags_and_bytes() { + let bytes = hex::decode(PLATFORM_STATE_V8_DEVNET_SUPPORTED.deref()).unwrap(); + let state = PlatformState::versioned_deserialize_trusted(&bytes, &PLATFORM_V9).unwrap(); + let config = PLATFORM_BINCODE_CONFIG; + let v1 = PlatformStateForSavingV1::try_from(&state).unwrap(); + for quorums in [ + &v1.chain_lock_validating_quorums, + &v1.instant_lock_validating_quorums, + ] { + let encoded = bincode::encode_to_vec(quorums, config).unwrap(); + assert_eq!(encoded[0], 2, "quorum storage tag must remain V2"); + } + let v2 = PlatformStateForSavingV2::from(&state); + for (tag, record) in [ + (1, PlatformStateForSaving::V1(v1)), + (2, PlatformStateForSaving::V2(v2)), + ] { + let encoded = bincode::encode_to_vec(record, config).unwrap(); + assert_eq!(encoded[0], tag, "platform storage tag must not change"); + let (decoded, consumed): (PlatformStateForSaving, _) = + bincode::borrow_decode_from_slice(&encoded, config).unwrap(); + assert_eq!(consumed, encoded.len()); + assert_eq!(bincode::encode_to_vec(decoded, config).unwrap(), encoded); + } + } + + #[test] + fn should_reject_devnet_state_containing_legacy_quorums() { let serialized_state = hex::decode(PLATFORM_STATE_V8_DEVNET.deref()).expect("failed to decode hex"); - PlatformState::versioned_deserialize_trusted(&serialized_state, &PLATFORM_V9) - .expect("failed to deserialize state"); + let error = + match PlatformState::versioned_deserialize_trusted(&serialized_state, &PLATFORM_V9) + { + Ok(_) => panic!("legacy quorums must require an intermediate upgrade"), + Err(error) => error, + }; + assert!(matches!( + error, + ProtocolError::PlatformDeserializationError(_) + )); + assert!(error.to_string().contains("v4.0.0")); } } } diff --git a/packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/mod.rs b/packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/mod.rs index c737c7a1a8b..2cc49357c8c 100644 --- a/packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/mod.rs @@ -5,7 +5,7 @@ use bincode::Encode; use derive_more::From; use dpp::platform_serialization::de::Decode; -/// Structure 0 as first shipped. +/// Structure 0 as first shipped, retired in Platform v5.1.0 by #5323. pub mod v0; /// Structure 0 with the previous fee versions. pub mod v1; @@ -15,7 +15,7 @@ pub mod v2; /// Platform state #[derive(Clone, Debug, Encode, Decode, From)] pub enum PlatformStateForSaving { - /// Version 0 + /// Retired in Platform v5.1.0 by #5323; its tag remains reserved. V0(PlatformStateForSavingV0), /// Version 1 V1(PlatformStateForSavingV1), diff --git a/packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/v0/mod.rs b/packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/v0/mod.rs index 5fa538d3b1d..c0a79298b47 100644 --- a/packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/v0/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/v0/mod.rs @@ -1,97 +1,33 @@ -use crate::platform_types::masternode::Masternode; -use crate::platform_types::platform_state::entry_changes::EntryChanges; -use crate::platform_types::platform_state::PlatformState; -use crate::platform_types::signature_verification_quorum_set::SignatureVerificationQuorumSetForSaving; -use bincode::Encode; -use dpp::block::block_info::BlockInfo; -use dpp::block::extended_block_info::ExtendedBlockInfo; -use dpp::dashcore::{ProTxHash, QuorumHash}; -use dpp::fee::default_costs::CachedEpochIndexFeeVersionsFieldsBeforeVersion4; -use dpp::platform_serialization::de::Decode; -use dpp::platform_value::Bytes32; -use dpp::util::deserializer::ProtocolVersion; -use dpp::version::fee::FeeVersion; -use std::collections::BTreeMap; +//! Retired: Platform state structure 0 as first shipped, tag 0 of `PlatformStateForSaving`. +//! +//! The reader was removed in Platform v5.1.0 by #5323, to drop the C++ `bls-signatures` +//! dependency from the default production node: the reader decoded this format's keys through +//! that crate. Platform v4.0.0 is the upgrade path, as it reads this format and writes a +//! supported one. Only this placeholder remains, and it keeps the tag reserved, so the tags of +//! the supported formats do not move. + +use crate::platform_types::unsupported_legacy_bls_storage::unsupported_legacy_bls_storage_error; +use bincode::de::Decoder; +use bincode::enc::Encoder; +use bincode::error::{DecodeError, EncodeError}; +use bincode::{Decode, Encode}; mod old_structures; -/// Platform state -#[derive(Clone, Debug, Encode, Decode)] -pub struct PlatformStateForSavingV0 { - /// Information about the genesis block - pub genesis_block_info: Option, - /// Information about the last block - pub last_committed_block_info: Option, - /// Current Version - pub current_protocol_version_in_consensus: ProtocolVersion, - /// upcoming protocol version - pub next_epoch_protocol_version: ProtocolVersion, - /// current quorum - pub current_validator_set_quorum_hash: Bytes32, - /// next quorum - pub next_validator_set_quorum_hash: Option, - /// current validator set quorums - /// The validator set quorums are a subset of the quorums, but they also contain the list of - /// all members - #[bincode(with_serde)] - pub validator_sets: Vec<(Bytes32, old_structures::OldStructureValidatorSet)>, +/// Has no values: nothing can write this format, and decoding it always fails. +#[derive(Clone, Debug)] +pub enum PlatformStateForSavingV0 {} - /// The quorums used for validating chain locks - pub chain_lock_validating_quorums: SignatureVerificationQuorumSetForSaving, - - /// The quorums used for validating instant locks - pub instant_lock_validating_quorums: SignatureVerificationQuorumSetForSaving, - - /// current full masternode list - pub full_masternode_list: BTreeMap, - - /// current HPMN masternode list - pub hpmn_masternode_list: BTreeMap, - - /// previous FeeVersions - pub previous_fee_versions: CachedEpochIndexFeeVersionsFieldsBeforeVersion4, +impl Encode for PlatformStateForSavingV0 { + fn encode(&self, _encoder: &mut E) -> Result<(), EncodeError> { + match *self {} + } } -impl From for PlatformState { - fn from(value: PlatformStateForSavingV0) -> Self { - PlatformState { - genesis_block_info: value.genesis_block_info, - last_committed_block_info: value.last_committed_block_info, - current_protocol_version_in_consensus: value.current_protocol_version_in_consensus, - next_epoch_protocol_version: value.next_epoch_protocol_version, - current_validator_set_quorum_hash: QuorumHash::from_byte_array( - value.current_validator_set_quorum_hash.to_buffer(), - ), - next_validator_set_quorum_hash: value - .next_validator_set_quorum_hash - .map(|bytes| QuorumHash::from_byte_array(bytes.to_buffer())), - validator_sets: value - .validator_sets - .into_iter() - .map(|(k, v)| (QuorumHash::from_byte_array(k.to_buffer()), v.into())) - .collect(), - chain_lock_validating_quorums: value.chain_lock_validating_quorums.into(), - instant_lock_validating_quorums: value.instant_lock_validating_quorums.into(), - full_masternode_list: value - .full_masternode_list - .into_iter() - .map(|(k, v)| (ProTxHash::from_byte_array(k.to_buffer()), v.into())) - .collect(), - hpmn_masternode_list: value - .hpmn_masternode_list - .into_iter() - .map(|(k, v)| (ProTxHash::from_byte_array(k.to_buffer()), v.into())) - .collect(), - previous_fee_versions: value - .previous_fee_versions - .into_keys() - .map(|epoch_index| (epoch_index, FeeVersion::first())) - .collect(), - // a state read back from disk has not been written in full since - heavy_fields_dirty: true, - // this record carried the collections itself, so no entries back it on disk - masternode_changes: EntryChanges::all(), - validator_set_changes: EntryChanges::all(), - } +impl Decode for PlatformStateForSavingV0 { + fn decode>(_decoder: &mut D) -> Result { + Err(unsupported_legacy_bls_storage_error()) } } + +bincode::impl_borrow_decode!(PlatformStateForSavingV0); diff --git a/packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/v0/old_structures/mod.rs b/packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/v0/old_structures/mod.rs index 8ad16315f56..9174f6c89b4 100644 --- a/packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/v0/old_structures/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/v0/old_structures/mod.rs @@ -1,122 +1,6 @@ -#[cfg(feature = "bls-signatures")] -use dpp::bls::PublicKey; -use dpp::dashcore::{ProTxHash, PubkeyHash, QuorumHash}; -use serde::{Deserialize, Serialize}; -use std::collections::BTreeMap; - -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] -pub enum OldStructureValidatorSet { - /// Version 0 - V0(OldStructureValidatorSetV0), -} - -impl From for dpp::core_types::validator_set::ValidatorSet { - fn from(value: OldStructureValidatorSet) -> Self { - match value { - OldStructureValidatorSet::V0(v0) => { - dpp::core_types::validator_set::ValidatorSet::V0(v0.into()) - } - } - } -} - -/// The validator set is only slightly different from a quorum as it does not contain non valid -/// members -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] -pub struct OldStructureValidatorSetV0 { - /// The quorum hash - pub quorum_hash: QuorumHash, - /// Rotation quorum index is available only for DIP24 quorums - pub quorum_index: Option, - /// Active height - pub core_height: u32, - /// The list of masternodes - pub members: BTreeMap, - /// The threshold quorum public key - #[cfg(feature = "bls-signatures")] - pub threshold_public_key: bls_signatures::PublicKey, - - /// Extra fields for forward compatibility. - #[cfg(not(feature = "bls-signatures"))] - #[serde(flatten)] - pub extra_fields: std::collections::HashMap, -} - -impl From for dpp::core_types::validator_set::v0::ValidatorSetV0 { - fn from(value: OldStructureValidatorSetV0) -> Self { - let OldStructureValidatorSetV0 { - quorum_hash, - quorum_index, - core_height, - members, - #[cfg(feature = "bls-signatures")] - threshold_public_key, - .. - } = value; - Self { - quorum_hash, - quorum_index, - core_height, - members: members - .into_iter() - .map(|(pro_tx_hash, validator)| (pro_tx_hash, validator.into())) - .collect(), - #[cfg(feature = "bls-signatures")] - threshold_public_key: PublicKey::try_from(threshold_public_key.to_bytes().as_slice()) - .expect("this should not be possible to error as the threshold_public_key was already verified on disk"), - #[cfg(not(feature = "bls-signatures"))] - threshold_public_key: Default::default(), - } - } -} - -/// A validator in the context of a quorum -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] -pub struct ValidatorV0 { - /// The proTxHash - pub pro_tx_hash: ProTxHash, - /// The public key share of this validator for this quorum - #[cfg(feature = "bls-signatures")] - pub public_key: Option, - /// The node address - pub node_ip: String, - /// The node id - pub node_id: PubkeyHash, - /// Core port - pub core_port: u16, - /// Http port - pub platform_http_port: u16, - /// Tenderdash port - pub platform_p2p_port: u16, - /// Is the validator banned - pub is_banned: bool, -} - -impl From for dpp::core_types::validator::v0::ValidatorV0 { - fn from(value: ValidatorV0) -> Self { - let ValidatorV0 { - pro_tx_hash, - #[cfg(feature = "bls-signatures")] - public_key, - node_ip, - node_id, - core_port, - platform_http_port, - platform_p2p_port, - is_banned, - } = value; - Self { - pro_tx_hash, - #[cfg(feature = "bls-signatures")] - public_key: public_key.map(|pk| PublicKey::try_from(pk.to_bytes().as_slice()).expect("this should not be possible to error as the public_key was already verified on disk")), - #[cfg(not(feature = "bls-signatures"))] - public_key: None, - node_ip, - node_id, - core_port, - platform_http_port, - platform_p2p_port, - is_banned, - } - } -} +//! Retired: the validator set types only Platform state structure 0 read. +//! +//! Removed in Platform v5.1.0 by #5323 with the reader in the parent module, to drop the C++ +//! `bls-signatures` dependency from the node. They were read only through the +//! parent's `with_serde` field, so they have no entry point of their own: the parent's decoder +//! refuses the whole record first. diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs index 1d4a9e71967..0aff9a523e0 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/mod.rs @@ -118,9 +118,9 @@ impl SignatureVerificationQuorumSetV0Methods for SignatureVerificationQuorumSet /// Core Quorum Set structure for saving to the database #[derive(Debug, Clone, Encode, Decode)] pub enum SignatureVerificationQuorumSetForSaving { - /// Version 0 of the signature verification quorums + /// Retired in Platform v5.1.0 by #5323; its tag remains reserved. V0(SignatureVerificationQuorumSetForSavingV0), - /// Version 1 of the signature verification quorums + /// Retired in Platform v5.1.0 by #5323; its tag remains reserved. V1(SignatureVerificationQuorumSetForSavingV1), /// Version 2 of the signature verification quorums V2(SignatureVerificationQuorumSetForSavingV2), @@ -139,15 +139,39 @@ impl From for SignatureVerificationQuorumSetForS impl From for SignatureVerificationQuorumSet { fn from(value: SignatureVerificationQuorumSetForSaving) -> Self { match value { - SignatureVerificationQuorumSetForSaving::V0(v0) => { - SignatureVerificationQuorumSet::V0(v0.into()) - } - SignatureVerificationQuorumSetForSaving::V1(v1) => { - SignatureVerificationQuorumSet::V0(v1.into()) - } + SignatureVerificationQuorumSetForSaving::V0(retired) => match retired {}, + SignatureVerificationQuorumSetForSaving::V1(retired) => match retired {}, SignatureVerificationQuorumSetForSaving::V2(v2) => { SignatureVerificationQuorumSet::V0(v2.into()) } } } } + +#[cfg(test)] +mod legacy_storage_tests { + use super::SignatureVerificationQuorumSetForSaving; + use bincode::{config, error::DecodeError}; + + #[test] + fn should_reject_legacy_bls_quorum_formats_before_reading_their_payload() { + for version in [0u32, 1] { + let bytes = bincode::encode_to_vec(version, config::standard().with_big_endian()) + .expect("encode format tag"); + let error = bincode::decode_from_slice::( + &bytes, + config::standard().with_big_endian(), + ) + .expect_err("legacy quorum format must be rejected"); + let borrowed_error = bincode::borrow_decode_from_slice::< + SignatureVerificationQuorumSetForSaving, + _, + >(&bytes, config::standard().with_big_endian()) + .expect_err("borrowed decoding must reject legacy quorums too"); + assert_eq!(error.to_string(), borrowed_error.to_string()); + assert!(matches!(error, DecodeError::Other(_))); + assert!(error.to_string().contains("v4.0.0")); + assert!(error.to_string().contains("commit at least one block")); + } + } +} diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/fixtures/README.md b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/fixtures/README.md index 5da5bdd4f7e..ca75958c959 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/fixtures/README.md +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/fixtures/README.md @@ -24,9 +24,9 @@ The previous-quorum heights are 1000 (last active), 1008 (updated), and `Some(900)` (previous change). Configuration is `Llmq400_60`, four active signers, no rotation, and a 288-block window. -The test decodes the production storage enum and converts it to the runtime -quorum set, exercising the historical C++-to-DPP key conversion for both lists. -Expected keys and metadata are asserted independently of the current writer. +The reader of this format was retired in Platform v5.1.0 by #5323, so these bytes +no longer decode: `should_reject_historical_v0_and_v1_quorums_with_upgrade_instructions` +asserts that the production storage enum refuses them with the upgrade error. Reproduce all storage fixtures with the [historical generation script](../../../../../../../scripts/historical-test-vectors/README.md). Its ignored tests use a pinned checkout; the V0 generator explicitly selects diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v0.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v0.rs index 8a0e14de0ac..6a775a3ab58 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v0.rs +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v0.rs @@ -1,217 +1,31 @@ -use crate::platform_types::signature_verification_quorum_set::v0::quorum_config_for_saving_v0::QuorumConfigForSavingV0; -use crate::platform_types::signature_verification_quorum_set::v0::quorum_set::PreviousPastQuorumsV0; -use crate::platform_types::signature_verification_quorum_set::{ - Quorums, SignatureVerificationQuorumSetForSaving, SignatureVerificationQuorumSetV0, - VerificationQuorum, -}; +//! Retired: quorum storage version 0, tag 0 of `SignatureVerificationQuorumSetForSaving`. +//! +//! The reader was removed in Platform v5.1.0 by #5323, to drop the C++ `bls-signatures` +//! dependency from the default production node: the reader decoded this format's keys through +//! that crate. Platform v4.0.0 is the upgrade path, as it reads this format and writes a +//! supported one. Only this placeholder remains, and it keeps the tag reserved, so the tags of +//! the supported formats do not move. + +use crate::platform_types::unsupported_legacy_bls_storage::unsupported_legacy_bls_storage_error; +use bincode::de::Decoder; +use bincode::enc::Encoder; +use bincode::error::{DecodeError, EncodeError}; use bincode::{Decode, Encode}; -use dpp::dashcore::QuorumHash; -use dpp::platform_value::Bytes32; -#[derive(Debug, Clone, Encode, Decode)] -pub struct SignatureVerificationQuorumSetForSavingV0 { - config: QuorumConfigForSavingV0, - current_quorums: Vec, - previous_quorums: Option, -} - -impl From for SignatureVerificationQuorumSetForSaving { - fn from(value: SignatureVerificationQuorumSetForSavingV0) -> Self { - SignatureVerificationQuorumSetForSaving::V0(value) - } -} - -impl From for SignatureVerificationQuorumSetForSavingV0 { - fn from(value: SignatureVerificationQuorumSetV0) -> Self { - let SignatureVerificationQuorumSetV0 { - config, - current_quorums, - previous, - } = value; - - Self { - config: config.into(), - current_quorums: current_quorums.into(), - previous_quorums: previous.map(|previous| previous.into()), - } - } -} +/// Has no values: nothing can write this format, and decoding it always fails. +#[derive(Debug, Clone)] +pub enum SignatureVerificationQuorumSetForSavingV0 {} -impl From for SignatureVerificationQuorumSetV0 { - fn from(value: SignatureVerificationQuorumSetForSavingV0) -> Self { - let SignatureVerificationQuorumSetForSavingV0 { - config, - current_quorums, - previous_quorums, - } = value; - - Self { - config: config.into(), - current_quorums: current_quorums.into(), - previous: previous_quorums.map(|previous| previous.into()), - } - } -} - -#[derive(Debug, Clone, Encode, Decode)] -pub struct PreviousPastQuorumsForSavingV0 { - quorums: Vec, - last_active_core_height: u32, - updated_at_core_height: u32, - previous_change_height: Option, -} - -impl From for PreviousPastQuorumsForSavingV0 { - fn from(value: PreviousPastQuorumsV0) -> Self { - let PreviousPastQuorumsV0 { - quorums, - last_active_core_height, - updated_at_core_height, - previous_change_height, - } = value; - - Self { - quorums: quorums.into(), - last_active_core_height, - updated_at_core_height, - previous_change_height, - } +impl Encode for SignatureVerificationQuorumSetForSavingV0 { + fn encode(&self, _encoder: &mut E) -> Result<(), EncodeError> { + match *self {} } } -impl From for PreviousPastQuorumsV0 { - fn from(value: PreviousPastQuorumsForSavingV0) -> Self { - let PreviousPastQuorumsForSavingV0 { - quorums, - last_active_core_height: active_core_height, - updated_at_core_height, - previous_change_height, - } = value; - - Self { - quorums: quorums.into(), - last_active_core_height: active_core_height, - updated_at_core_height, - previous_change_height, - } +impl Decode for SignatureVerificationQuorumSetForSavingV0 { + fn decode>(_decoder: &mut D) -> Result { + Err(unsupported_legacy_bls_storage_error()) } } -#[derive(Debug, Clone, Encode, Decode)] -pub struct QuorumForSavingV0 { - hash: Bytes32, - #[cfg(feature = "bls-signatures")] - #[bincode(with_serde)] - public_key: bls_signatures::PublicKey, - index: Option, -} - -impl From> for Quorums { - fn from(value: Vec) -> Self { - Quorums::from_iter(value.into_iter().map(|quorum| { - ( - QuorumHash::from_byte_array(quorum.hash.to_buffer()), - VerificationQuorum { - #[cfg(feature = "bls-signatures")] - public_key: dpp::bls::PublicKey::try_from( - quorum.public_key.to_bytes().as_slice(), - ) - .expect("expected to convert between BLS key libraries (from chia)"), - #[cfg(not(feature = "bls-signatures"))] - public_key: Default::default(), - index: quorum.index, - }, - ) - })) - } -} - -impl From> for Vec { - fn from(quorums: Quorums) -> Self { - quorums - .into_iter() - .map(|(hash, quorum)| QuorumForSavingV0 { - hash: Bytes32::from(hash.as_byte_array()), - #[cfg(feature = "bls-signatures")] - public_key: bls_signatures::PublicKey::from_bytes(&quorum.public_key.to_bytes()) - .expect("expected to convert between BLS key libraries (to chia)"), - index: quorum.index, - }) - .collect() - } -} - -#[cfg(all(test, feature = "bls-signatures"))] -mod tests { - use super::*; - use crate::platform_types::signature_verification_quorum_set::SignatureVerificationQuorumSet; - use dpp::dashcore_rpc::json::QuorumType; - use dpp::platform_serialization::PLATFORM_BINCODE_CONFIG; - - fn assert_quorum( - quorums: &Quorums, - hash: u8, - public_key: &str, - index: Option, - ) { - let quorum = quorums - .get(&QuorumHash::from_byte_array([hash; 32])) - .unwrap(); - assert_eq!( - quorum.public_key.to_bytes().as_slice(), - hex::decode(public_key).unwrap() - ); - assert_eq!(quorum.index, index); - } - - #[test] - fn should_restore_current_and_previous_quorums_from_frozen_v0_storage() { - let bytes = hex::decode(super::super::storage_vectors::QUORUM_STORAGE_V0.trim()).unwrap(); - let config = PLATFORM_BINCODE_CONFIG; - let (stored, consumed): (SignatureVerificationQuorumSetForSaving, _) = - bincode::decode_from_slice(&bytes, config).unwrap(); - assert_eq!(consumed, bytes.len()); - assert!(matches!( - stored, - SignatureVerificationQuorumSetForSaving::V0(_) - )); - assert_eq!(bincode::encode_to_vec(&stored, config).unwrap(), bytes); - - let SignatureVerificationQuorumSet::V0(restored) = stored.into(); - assert_eq!(restored.config.quorum_type, QuorumType::Llmq400_60); - assert_eq!(restored.config.active_signers.get(), 4); - assert!(!restored.config.rotation); - assert_eq!(restored.config.window.get(), 288); - assert_eq!(restored.current_quorums.len(), 2); - assert_quorum( - &restored.current_quorums, - 0x11, - "97f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb", - None, - ); - assert_quorum( - &restored.current_quorums, - 0x22, - "a572cbea904d67468808c8eb50a9450c9721db309128012543902d0ac358a62ae28f75bb8f1c7c42c39a8c5529bf0f4e", - Some(0), - ); - - let previous = restored.previous.unwrap(); - assert_eq!(previous.last_active_core_height, 1000); - assert_eq!(previous.updated_at_core_height, 1008); - assert_eq!(previous.previous_change_height, Some(900)); - assert_eq!(previous.quorums.len(), 2); - assert_quorum( - &previous.quorums, - 0x33, - "95fde78acd5f6886ddaf5d0056610167c513d09c1c0efabbc7cdcc69beea113779c4a81e2d24daafc5387dbf6ac5fe48", - Some(1), - ); - assert_quorum( - &previous.quorums, - 0x44, - "b7f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb", - None, - ); - } -} +bincode::impl_borrow_decode!(SignatureVerificationQuorumSetForSavingV0); diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs index 1978067e2d5..1b98c15f2c3 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs @@ -1,68 +1,40 @@ +//! Retired: quorum storage version 1, tag 1 of `SignatureVerificationQuorumSetForSaving`. +//! +//! The reader was removed in Platform v5.1.0 by #5323, to drop the C++ `bls-signatures` +//! dependency from the default production node: the reader decoded this format's previous quorums +//! through that crate. Platform v4.0.0 is the upgrade path, as it reads this format and writes a +//! supported one. Only the placeholder remains, and it keeps the tag reserved, so the tags of the +//! supported formats do not move. The quorum types below it are live: version 2 stores them. + use super::public_key_for_saving::PublicKeyForSaving; -#[cfg(feature = "bls-signatures")] -use crate::platform_types::signature_verification_quorum_set::v0::for_saving_v0::PreviousPastQuorumsForSavingV0; -use crate::platform_types::signature_verification_quorum_set::v0::quorum_config_for_saving_v0::QuorumConfigForSavingV0; use crate::platform_types::signature_verification_quorum_set::v0::quorum_set::PreviousPastQuorumsV0; -use crate::platform_types::signature_verification_quorum_set::{ - Quorums, SignatureVerificationQuorumSetForSaving, SignatureVerificationQuorumSetV0, - VerificationQuorum, -}; +use crate::platform_types::signature_verification_quorum_set::{Quorums, VerificationQuorum}; +use crate::platform_types::unsupported_legacy_bls_storage::unsupported_legacy_bls_storage_error; +use bincode::de::Decoder; +use bincode::enc::Encoder; +use bincode::error::{DecodeError, EncodeError}; use bincode::{Decode, Encode}; use dpp::dashcore::QuorumHash; use dpp::platform_value::Bytes32; -#[derive(Debug, Clone, Encode, Decode)] -pub struct SignatureVerificationQuorumSetForSavingV1 { - config: QuorumConfigForSavingV0, - current_quorums: Vec, - #[cfg(feature = "bls-signatures")] - previous_quorums: Option, -} +/// Has no values: nothing can write this format, and decoding it always fails. +#[derive(Debug, Clone)] +pub enum SignatureVerificationQuorumSetForSavingV1 {} -impl From for SignatureVerificationQuorumSetForSaving { - fn from(value: SignatureVerificationQuorumSetForSavingV1) -> Self { - SignatureVerificationQuorumSetForSaving::V1(value) +impl Encode for SignatureVerificationQuorumSetForSavingV1 { + fn encode(&self, _encoder: &mut E) -> Result<(), EncodeError> { + match *self {} } } -impl From for SignatureVerificationQuorumSetForSavingV1 { - fn from(value: SignatureVerificationQuorumSetV0) -> Self { - #[allow(unused_variables)] - let SignatureVerificationQuorumSetV0 { - config, - current_quorums, - previous, - } = value; - - Self { - config: config.into(), - current_quorums: current_quorums.into(), - #[cfg(feature = "bls-signatures")] - previous_quorums: previous.map(|previous| previous.into()), - } +impl Decode for SignatureVerificationQuorumSetForSavingV1 { + fn decode>(_decoder: &mut D) -> Result { + Err(unsupported_legacy_bls_storage_error()) } } -impl From for SignatureVerificationQuorumSetV0 { - fn from(value: SignatureVerificationQuorumSetForSavingV1) -> Self { - let SignatureVerificationQuorumSetForSavingV1 { - config, - current_quorums, - #[cfg(feature = "bls-signatures")] - previous_quorums, - } = value; - - Self { - config: config.into(), - current_quorums: current_quorums.into(), - #[cfg(feature = "bls-signatures")] - previous: previous_quorums.map(|previous| previous.into()), - #[cfg(not(feature = "bls-signatures"))] - previous: None, - } - } -} +bincode::impl_borrow_decode!(SignatureVerificationQuorumSetForSavingV1); #[derive(Debug, Clone, Encode, Decode)] pub struct QuorumForSavingV1 { diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v2.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v2.rs index 60f0b4d7b9a..27cc8c656ef 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v2.rs +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v2.rs @@ -7,10 +7,6 @@ use crate::platform_types::signature_verification_quorum_set::{ }; use bincode::{Decode, Encode}; -// We needed to introduce this V2 because the PreviousPastQuorumsForSavingV1 were using a QuorumForSavingV0 -// This was an oversight in SignatureVerificationQuorumSetForSavingV1. -// This would cause the previous quorums to still use the old BLS sigs library for serialization/deserialization. - #[derive(Debug, Clone, Encode, Decode)] pub struct SignatureVerificationQuorumSetForSavingV2 { config: QuorumConfigForSavingV0, diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs index 58a17f5ba25..811ac921c6e 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/mod.rs @@ -6,8 +6,8 @@ pub mod quorum_config_for_saving_v0; pub mod quorum_set; pub mod quorums; -#[cfg(all(test, feature = "bls-signatures"))] +#[cfg(test)] mod storage_tests; -#[cfg(all(test, feature = "bls-signatures"))] +#[cfg(test)] mod storage_vectors; diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/storage_tests.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/storage_tests.rs index 46edffb7125..c8728e46a2a 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/storage_tests.rs +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/storage_tests.rs @@ -80,20 +80,33 @@ fn assert_quorums(set: &SignatureVerificationQuorumSet) { } #[test] -fn should_preserve_current_and_previous_quorums_in_old_v1_and_v2_records() { +fn should_reject_historical_v0_and_v1_quorums_with_upgrade_instructions() { for fixture in [ - super::storage_vectors::QUORUM_STORAGE_V1, - super::storage_vectors::QUORUM_STORAGE_V2, + storage_vectors::QUORUM_STORAGE_V0, + storage_vectors::QUORUM_STORAGE_V1, ] { let bytes = hex::decode(fixture.trim()).unwrap(); - let (stored, read): (SignatureVerificationQuorumSetForSaving, _) = - bincode::decode_from_slice(&bytes, config()).unwrap(); - assert_eq!(read, bytes.len()); - assert_eq!(bincode::encode_to_vec(&stored, config()).unwrap(), bytes); - assert_quorums(&stored.into()); + let error = bincode::decode_from_slice::( + &bytes, + config(), + ) + .expect_err("legacy quorums require an intermediate upgrade"); + assert!(matches!(error, bincode::error::DecodeError::Other(_))); + assert!(error.to_string().contains("v4.0.0")); + assert!(error.to_string().contains("commit at least one block")); } } +#[test] +fn should_preserve_current_and_previous_quorums_in_historical_v2_records() { + let bytes = hex::decode(storage_vectors::QUORUM_STORAGE_V2.trim()).unwrap(); + let (stored, read): (SignatureVerificationQuorumSetForSaving, _) = + bincode::decode_from_slice(&bytes, config()).unwrap(); + assert_eq!(read, bytes.len()); + assert_eq!(bincode::encode_to_vec(&stored, config()).unwrap(), bytes); + assert_quorums(&stored.into()); +} + #[test] fn should_load_old_saved_state_and_checkpoint_with_both_quorum_sets() { for fixture in [ diff --git a/packages/rs-drive-abci/src/platform_types/unsupported_legacy_bls_storage.rs b/packages/rs-drive-abci/src/platform_types/unsupported_legacy_bls_storage.rs new file mode 100644 index 00000000000..67f38aaeb5c --- /dev/null +++ b/packages/rs-drive-abci/src/platform_types/unsupported_legacy_bls_storage.rs @@ -0,0 +1,13 @@ +//! Rejection of database formats that require an intermediate Platform upgrade. +//! +//! Each storage generation retired in Platform v5.1.0 by #5323 keeps a placeholder at its +//! historical path, and they all answer with this one error. + +use bincode::error::DecodeError; + +/// The error a retired storage generation's decoder returns, before reading its payload. +pub(crate) fn unsupported_legacy_bls_storage_error() -> DecodeError { + DecodeError::Other( + "Unsupported legacy BLS state format. Run Platform v4.0.0 on this database and let it successfully commit at least one block before upgrading.", + ) +} diff --git a/packages/rs-drive-abci/src/test/fixture/platform_state.rs b/packages/rs-drive-abci/src/test/fixture/platform_state.rs index e5c5c2f6184..87909995f0e 100644 --- a/packages/rs-drive-abci/src/test/fixture/platform_state.rs +++ b/packages/rs-drive-abci/src/test/fixture/platform_state.rs @@ -12,3 +12,18 @@ pub static PLATFORM_STATE_V3_TESTNET: LazyLock<&str> = LazyLock::new(|| { pub static PLATFORM_STATE_V8_DEVNET: LazyLock<&str> = LazyLock::new(|| { "01000100fd00000196679379cde0fb4cf8335c28e2d5b81fe8563beff647c4a74bac7165d84276eb62dc46fd2cc6bfe53f6b00000299b14717769ec09ccd478a1f3c5f27ba04e6c5fe67b5c26d96ba54f8741533fd4861a2205ac950c9f39bfcb92d75c30010cc6e83d23eee89792132cf78ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e51104418388bcb4a1798aebc9b25e3d444ff15e4b272c4ee5dbf51309147db28421f49a736a6fb0260ea8b075f8309331caed3f99b193410cee745b02ad9b93d16c22cc7bfac642917c93c288e2a1977f325fb0b76cc6c22447d363c43a20bb89c89d3253300080800000299b14717769ec09ccd478a1f3c5f27ba04e6c5fe67b5c26d96ba54f8740004000005c2a084bd68f4c908dfd772db63462a1a26be397eb1ad018bb9199cb8d900000005c2a084bd68f4c908dfd772db63462a1a26be397eb1ad018bb9199cb8d900fb4ce00a2001e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601b7536c30ebb2297379cce4e832c5c88828dba988b1b339ba403621a67cc26325baf14d809cbd4b30ef07c783a45749130d35342e3230322e3233312e32309eb3c89309106d441cc1749640ab5613046f6ad0fb4e21fb05a3fb8f300020122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b080122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b08001b6aa2516aa6e47c9824efc13422cccc45a73fbe0bab83334fc31122f99c2e6fc37f667928c20176702284a4211393f4e0d31382e3234362e3232372e3231a7822db397ca4e35b81d016ce52bdbaae74880abfb4e21fb05a3fb8f3000204838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b164838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b1601a1f07095b3171384f7d7cd23d766cb5ef32cf1bc3808eb5dd6cbc4c910ee0e51d11f47f2673db173c166749f5c61f4790d34342e3234372e3136302e3532c6e2f8c23c3b847ae4b8f0c452408f843fe3afa6fb4e21fb05a3fb8f3000204c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc514c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc5101846f0ab803a4569eae1a616443456bf498f0493b9d32c919a59d6bb722bcd2200077e9439d9fb621d9f966bef1009bde0d35342e3231342e37372e313038cca358aba0b27446e73f6cbc372d549de4039d43fb4e21fb05a3fb8f300020aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc3aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc301b117767d537e5c34c7c459a76b97af529a1255e0bf2c61ea96316c347f2c13abf6755e52ae2e8ae41a41414617ed6afd0c33352e38392e3234362e383620499e02a93241d54692c96b4ef147e46b123275fb4e21fb05a3fb8f300020ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e5110441838ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e511044183801abac813a50f33c5e2c53284e880a47b831c3683a63686991146f473ec129e324a80492f1bde63986f0564304e5bd36b30d34342e3234352e39362e313634acc20a8324d0b1f914a4ffe605d488f21a026cd6fb4e21fb05a3fb8f300020c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fbc254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb01ab9ecac6c4edbb91ec9b91347b3f0cdd9872c8278432f3f7550d3812f5b82afe7e1701984edd53b0b84f59fe56ebd66a0d35342e3230332e3131362e3931f77c894ac83526befcc07157a82e52cc2b1697f1fb4e21fb05a3fb8f300020d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945018be3cda106e64ec22ab90dff0b9aebf399f64925ec460896683df9ebfe77a767315ceeb51a395fac87a3cecfd0d9f2580e33342e3232322e3231342e3137301e8d732727fff4006299e0b23d5d724fb0e688b3fb4e21fb05a3fb8f300020ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408ebed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb01a342022a1ff0f2e8a9b42f0d031d3704fa89a6dc85e8bf31e88266f4dbcbc2d1f9255913b5dd51d7f96fc25b04af53100b35322e38382e31362e3436da8a388088177826d85d98d2518a7a42bf04663ffb4e21fb05a3fb8f300020f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1af7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a01a612b7515f24806d24b34176383f3d73ac673eae61142860c2ceed761f8f1435d988f64a33d0fb9a529e870c68dd50990d35322e34302e3138362e323334a3f4164595cffe3fb0e79c3cf06a4ea1d5d474b4fb4e21fb05a3fb8f3000ae243894aa11a2c9f1bb0464499864376b85c773c8ff5a7f5d57bfee2977459db996ce325d9bc4996582baa0f96b59b60000041ad2e1652e70ca1db2e3bcb39a5271b4862c4e2aa3197eafba20ec02ce000000041ad2e1652e70ca1db2e3bcb39a5271b4862c4e2aa3197eafba20ec02ce00fb4cc80a2001e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab506018ebacd1b1061d80715fe840a199b6635830ad7abc379e1af869998c1b91257b4819935f1796d1c6bc86c79f263a64c430d35342e3230322e3233312e32309eb3c89309106d441cc1749640ab5613046f6ad0fb4e21fb05a3fb8f300020122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b080122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b08001ab5a092f14f019e1ae79ec037ebe88d3501139a82736521b2aabca4f078f934bbf9d136383c2386ce5739f6f9a5f9d490d31382e3234362e3232372e3231a7822db397ca4e35b81d016ce52bdbaae74880abfb4e21fb05a3fb8f3000204838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b164838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b16018aaabc36b1e2f42664abec989208b9821650b704323cb8d66be00095954a1d20194ef23c33c839e760f03f0ac0bcca350d34342e3234372e3136302e3532c6e2f8c23c3b847ae4b8f0c452408f843fe3afa6fb4e21fb05a3fb8f3000204c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc514c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc5101aa6bf2536b37af83b6e88a50b35216aebcf2e433758d419e150e00d19caf6ca6fcffa234d49c86a2905e400f41d5a3a50d35342e3231342e37372e313038cca358aba0b27446e73f6cbc372d549de4039d43fb4e21fb05a3fb8f300020aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc3aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc301aadc92e09655108cc8736b055e5abf288e060b06de527a4f6fc5b65516037e555ca0b9944c65ea678dc59348d6e138e70c33352e38392e3234362e383620499e02a93241d54692c96b4ef147e46b123275fb4e21fb05a3fb8f300020ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e5110441838ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e511044183801b919077a4108af14570de90782408632b048b528df100076077598a8555758d656cae0fd3ec132b1fd113e18d3b623d50d34342e3234352e39362e313634acc20a8324d0b1f914a4ffe605d488f21a026cd6fb4e21fb05a3fb8f300020c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fbc254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb01a7553852f9a1692b7696cb063e49e173ca655b80e1fa95d8e03926dabb0a16f1ca4e7d7f32666e838d53d228e80bf5390d35342e3230332e3131362e3931f77c894ac83526befcc07157a82e52cc2b1697f1fb4e21fb05a3fb8f300020d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945018babe479bf760cd34be2b57e088e9756d3eac5e92f5e978b5abdf3e8a4d3ea5f4bb93e3c5e6227d1c9174fd7e38ad5140e33342e3232322e3231342e3137301e8d732727fff4006299e0b23d5d724fb0e688b3fb4e21fb05a3fb8f300020ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408ebed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb01b7be15daa0d2513874b47d5d4283563969a933bb473e21222c63271dfae2ddd560df3806172b9b897926b214542b73a40b35322e38382e31362e3436da8a388088177826d85d98d2518a7a42bf04663ffb4e21fb05a3fb8f300020f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1af7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a0193d0baee082057cc2e7a17bf6cad8d3df0e4fc5438de2027ea77bb20a7910862ecc145b4631bcd58e39fd62a19e2ea150d35322e34302e3138362e323334a3f4164595cffe3fb0e79c3cf06a4ea1d5d474b4fb4e21fb05a3fb8f30008028075a0cca9efbc93a7c50b3c670ed90c129b64705f1c3c2ccedc811ff5844ed6f1e34601a13a2b59bc94329b74606000017fd360e19c0346ceb923e43c1fc601153ba921ad0186320347d6ad6796800000017fd360e19c0346ceb923e43c1fc601153ba921ad0186320347d6ad6796800fb4cb00a2001e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601aaac3862eed7b02ba53f7a019047849d5b492ec41c8f5541e4b81811ae989d703c200ca058226e9e78f081e07f0742b20d35342e3230322e3233312e32309eb3c89309106d441cc1749640ab5613046f6ad0fb4e21fb05a3fb8f300020122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b080122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b08001b57396d68a27a823604af7404e7fa28e9d0a559b42e94464eee8ee322a0f5b017d50827c0a460adb57d98555ac5d31ac0d31382e3234362e3232372e3231a7822db397ca4e35b81d016ce52bdbaae74880abfb4e21fb05a3fb8f3000204838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b164838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b1601b45e2079572eea6d7890f5199ceef69fc7e71a353fa919a8a58a44b3aab65926b60fc10cfcb62b85b4f422f49d3e92e90d34342e3234372e3136302e3532c6e2f8c23c3b847ae4b8f0c452408f843fe3afa6fb4e21fb05a3fb8f3000204c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc514c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc51018a47a2fe45a808aea52b26adfe15d75fa422762d9a8615bc8cdd9987c68e2b84bc06bbff4378f639f3aa57133a1aa81a0d35342e3231342e37372e313038cca358aba0b27446e73f6cbc372d549de4039d43fb4e21fb05a3fb8f300020aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc3aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc301aadf1764b8f7f60788cc90d95f0403b249acce9ee6e4bb31c90061d9dd5cfe32812b64249ec0b017bcf67f30e44c3bc50c33352e38392e3234362e383620499e02a93241d54692c96b4ef147e46b123275fb4e21fb05a3fb8f300020ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e5110441838ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e51104418380185b29d05607cf79e2dbeff52d40751a30a2f1bd8fd63508b2c45ff75577f6f3f3c92951069690a8b4976ece9fedc966b0d34342e3234352e39362e313634acc20a8324d0b1f914a4ffe605d488f21a026cd6fb4e21fb05a3fb8f300020c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fbc254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb01a8e81b88af2eefb6ab3b39652a651a4ea57e0c82eedb90908769716ecd9928fe825fdd142c4938e7049dc31c43bda2e70d35342e3230332e3131362e3931f77c894ac83526befcc07157a82e52cc2b1697f1fb4e21fb05a3fb8f300020d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc377194501ab750eb8ce4e3cb196dac1890bae03e6a1cdf9bf0b70a63ea6ca64f7ee1946b8fe02b8362290765cb9ffeda0e5088a0b0e33342e3232322e3231342e3137301e8d732727fff4006299e0b23d5d724fb0e688b3fb4e21fb05a3fb8f300020ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408ebed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb019031840125574c094554c02649a65b9dec67285d6e0f89ebbae56b55eedd5393757bb81a4fec886422d8e3ac485dc2740b35322e38382e31362e3436da8a388088177826d85d98d2518a7a42bf04663ffb4e21fb05a3fb8f300020f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1af7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a018f922fdc28078e252b6e221b3ccaa6f3451885b4413e7a21b4a7850eb924122cbed5fb366af8485bd1d8d67f185232d60d35322e34302e3138362e323334a3f4164595cffe3fb0e79c3cf06a4ea1d5d474b4fb4e21fb05a3fb8f3000b887b3dbc961b87e02fd7e16929fe771133d6c76fa1faebb35c2b1da15d32292a314b477f60f4c6d02b46110c0ef6eec00000299b14717769ec09ccd478a1f3c5f27ba04e6c5fe67b5c26d96ba54f8740000000299b14717769ec09ccd478a1f3c5f27ba04e6c5fe67b5c26d96ba54f87400fb4c980a2001e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601a4037c6dc40a494e120de11721a221e876b75fd099c852bb1b44a2ba882bc4c25a0998d60e56ca29983abe918f15a2ad0d35342e3230322e3233312e32309eb3c89309106d441cc1749640ab5613046f6ad0fb4e21fb05a3fb8f300020122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b080122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b08001a12ace1e26c8ce82f2e736b26653f64a477ec58de0f964b8e79b67aea72b70c4c46d0e8c48a77b83fbde7d4e5b6b00910d31382e3234362e3232372e3231a7822db397ca4e35b81d016ce52bdbaae74880abfb4e21fb05a3fb8f3000204838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b164838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b160181d6653d0930d0c17ae170c3a492abaed7790a43b064258684e520e47e8627c0e7f331fdb14cf8a303c6f472d8240c3b0d34342e3234372e3136302e3532c6e2f8c23c3b847ae4b8f0c452408f843fe3afa6fb4e21fb05a3fb8f3000204c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc514c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc51019209cfef89be975385818843303544dbbdbe5e71fb035de048aa870972d83b0a2822ef1dc28f02f1e1d94e9e50a091790d35342e3231342e37372e313038cca358aba0b27446e73f6cbc372d549de4039d43fb4e21fb05a3fb8f300020aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc3aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc301b64f956fed0ea351b56e6271d9da59e5b053cc5b707ef057fc165ad23176e6bf5160bab2d8f5ad1abd45ac508856b8d40c33352e38392e3234362e383620499e02a93241d54692c96b4ef147e46b123275fb4e21fb05a3fb8f300020ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e5110441838ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e511044183801a98cd5f09273c6a038b6a29af2eaff1570e62e03b25bbb6ba21354a01b96cfca07dca4ae4b3ae5496a4d62d63c1ec7cc0d34342e3234352e39362e313634acc20a8324d0b1f914a4ffe605d488f21a026cd6fb4e21fb05a3fb8f300020c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fbc254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb01acd8ed44c9de6126a9b683b915c85ec85ee67983603bba65f5427fbcf62d5460a89a91d03dbabb4b041d0585fa8a99200d35342e3230332e3131362e3931f77c894ac83526befcc07157a82e52cc2b1697f1fb4e21fb05a3fb8f300020d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc377194501aab6f5e05fb6544513c6af9624c6d18b8dcca7eee3356d61631d718931630075811af66ed540b43baeab4b3a8339becc0e33342e3232322e3231342e3137301e8d732727fff4006299e0b23d5d724fb0e688b3fb4e21fb05a3fb8f300020ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408ebed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb0185187e5ec226e3aa03eb2f6e157f042ef8e0aa444c80f018664956c895e45a894dcea801ed3f3acafe78be22051801600b35322e38382e31362e3436da8a388088177826d85d98d2518a7a42bf04663ffb4e21fb05a3fb8f300020f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1af7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a018d0b0344f40beddbd946ae247a5617e3329894d88e84f94a56990a2af72d3ff67d05b86f8ec6145ff65578aae1d9a1730d35322e34302e3138362e323334a3f4164595cffe3fb0e79c3cf06a4ea1d5d474b4fb4e21fb05a3fb8f30008cf580fb386270abfc216e3beb47d028c5c49dac56d706b2797ee9fb65322a680bb632a2a81191dfdea453569adf049e01070400180400000299b14717769ec09ccd478a1f3c5f27ba04e6c5fe67b5c26d96ba54f8748c786a8a62110a49cf5032723429517beff088867f048c5ff795d394322aa5ae0d51f87fad5f5a3e7864aee139aef68a000000041ad2e1652e70ca1db2e3bcb39a5271b4862c4e2aa3197eafba20ec02ce84b18ace26a0084f94122e5b88c24a16d678efdb36ecec9088c81dc572ced080a8ebc5c2e35f80b48ffe5efab68890b600000005c2a084bd68f4c908dfd772db63462a1a26be397eb1ad018bb9199cb8d98b5be5697a66e7fc3b1e0fb0e247f2be6f68096888b578ca1c35761a057e2ff9fc308d692c115f3cf252cea1423f2d1e00000017fd360e19c0346ceb923e43c1fc601153ba921ad0186320347d6ad6796893fba22ce69238d34733636602fc26e1b841da63dd37cc0af69efb1ba815cfcb3a7a5be870db4d2f1a940dc3ad407f7a00010400000299b14717769ec09ccd478a1f3c5f27ba04e6c5fe67b5c26d96ba54f874308c786a8a62110a49cf5032723429517beff088867f048c5ff795d394322aa5ae0d51f87fad5f5a3e7864aee139aef68a00000003e208609aa86a58da32e5465fa6ae8ee72d2e2b3936f2d8cfafd52f05813093c47178fa64592f11a32f7718bd518d90b3c847c7b8fa4bca6addaece93581dab9a3429ec2c7c7347ce920e88979e56000000041ad2e1652e70ca1db2e3bcb39a5271b4862c4e2aa3197eafba20ec02ce3084b18ace26a0084f94122e5b88c24a16d678efdb36ecec9088c81dc572ced080a8ebc5c2e35f80b48ffe5efab68890b600000017fd360e19c0346ceb923e43c1fc601153ba921ad0186320347d6ad679683093fba22ce69238d34733636602fc26e1b841da63dd37cc0af69efb1ba815cfcb3a7a5be870db4d2f1a940dc3ad407f7a00fb4ceafb4ceb01fb4cd4010b020130020000057d6aec5a186ff690e13b41e10c938d06c9ba25046836c740549b0e3969b8faca3e409109d3549187247ab50bfe5843545c3064ef953653f52f5a0ddefb4b91325812def3cc26808067624327890101000005c2a084bd68f4c908dfd772db63462a1a26be397eb1ad018bb9199cb8d9aac58025b9e50077a3edfe1aaab170fcdb6b15b3a500212460265cb756ea33cba57ca432916bca4c4ef72b1b172600c20100010200000074d7b31cf77817c30df933d80fa6e354b6582c29ef416799a50863103930a8dc97e32336fe44d357d4936d196f08731328f15758cd7760fe584862869944556826905742737e3da542d782e57acb0101000017fd360e19c0346ceb923e43c1fc601153ba921ad0186320347d6ad6796830b7f439f6c82070bd8a73313e98d228b9f11b1c0232a1b9733580155bfbd27a3c399ecc5babdd4a6cf2908a836ccba2720100fb4cebfb4cec01fb4cbe0a01e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50600012001e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50620a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca10790356e79d2b2b0ac0761f6a4526b7d047d74e28f546000000000036cae714fb4e21fb101900000058127be0d801051a163bf0353cc5bb9defd2f57358127be0d801051a163bf0353cc5bb9defd2f573a986f69f8d9d9a073287487365e0c31a1a6ec33d30b104db07b513ef45b0da4c1379599b7c5981860fa588d7968cbc0408a1cc729fcb64b2c7586c9719caa7d33ddaccf42900019eb3c89309106d441cc1749640ab5613046f6ad001fb8f3001fb05a3122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b080000120122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b08020a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107906903790983928ee282b9644cbf9c8e6cee72efe90000000000012f6e315fb4e21fb10190000009b482e4b8f5da7583a15fc887928e6c404e17f9b9b482e4b8f5da7583a15fc887928e6c404e17f9ba986f69f8d9d9a073287487365e0c31a1a6ec33d30b5c57edb1258f5c1cfdb21b6680de011ddeea93e797e5f597dedd0abb85eea27bf862ff95528ed80c9cb0bae3a2715fa0001a7822db397ca4e35b81d016ce52bdbaae74880ab01fb8f3001fb05a34838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b160001204838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b1620a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079079150fb7c07cdbac70f458cd23487e212760de68500000000002cf7a034fb4e21fb1019000000579ecdebf8c2a3f347c301cd56f8d25a60821ebd579ecdebf8c2a3f347c301cd56f8d25a60821ebda986f69f8d9d9a073287487365e0c31a1a6ec33d30b455073ebdd660759753d3158e0af7038620bc484d5b206cc76cd517ccd4aaedff0a967d3a2245ca12dd39eaec565dc10001c6e2f8c23c3b847ae4b8f0c452408f843fe3afa601fb8f3001fb05a34c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc510001204c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc5120a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca10790ad2e5173d4d1f2ddab7848de87288ef7fea4a5bc2000000000036d64d6cfb4e21fb101900000032d019c0a0521635e2c50baa0639afde38128ca032d019c0a0521635e2c50baa0639afde38128ca0a986f69f8d9d9a073287487365e0c31a1a6ec33d3085918a1ce01bed79b0f2f73b4b9cf3d3beb0d79508801139611d488cd5ecd7184f72c5489eb78330d5f43caebc9a0a110001cca358aba0b27446e73f6cbc372d549de4039d4301fb8f3001fb05a3aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc3000120aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc320a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079089a27487a58654bceeacfd3fb1a2cda28642ddb2700000000002359f656fb4e21fb1019000000a4639a40da95a2eca6bd0b821de9d45e6b4a2b2ba4639a40da95a2eca6bd0b821de9d45e6b4a2b2ba986f69f8d9d9a073287487365e0c31a1a6ec33d30b343c9b538cc9694dbb8cf3ecc288875ec6e53175c72d557c2ac5fad08659084a83a9aeb670d6aa484f293de2d85af33000120499e02a93241d54692c96b4ef147e46b12327501fb8f3001fb05a3ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e5110441838000120ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e511044183820a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079057ba786e269da8db182526a7dd051b5b5dc231fb500000000002cf560a4fb4e21fb101900000081b0121840d749be5f287a4117515f4d8f3fd65f81b0121840d749be5f287a4117515f4d8f3fd65fa986f69f8d9d9a073287487365e0c31a1a6ec33d30b03a8cb594e95d4d3e9d993e5a2df17ef5161fcf67560bd91fff3bbd5d4a4fe26082c6c37fac5a73491dc93e1900b4950001acc20a8324d0b1f914a4ffe605d488f21a026cd601fb8f3001fb05a3c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb000120c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb20a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107902493372ccd17dea09c98b8c35077387b21f8ad28d000000000036cb745bfb4e21fb1019000000fcd87a7892e645ebba5647bd9eebc25b34ddde70fcd87a7892e645ebba5647bd9eebc25b34ddde70a986f69f8d9d9a073287487365e0c31a1a6ec33d30a2cff2a27595a6bc79ce79c4f360713a35e20350ec106f20d01a90d1374ac0c5ef709ce968bcc0a7888340f5871805040001f77c894ac83526befcc07157a82e52cc2b1697f101fb8f3001fb05a3d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945000120d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc377194520a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107904645e20b1c5090f6f05b601eec64d6c17cd88094a000000000022ded6aafb4e21fb1019000000d6cdf6df678342ca7e9d906e354dd9355445cb80d6cdf6df678342ca7e9d906e354dd9355445cb80a986f69f8d9d9a073287487365e0c31a1a6ec33d308c89302e7919585c6c9870d5ec60e89abe15bdc62e8043a7db8d47ecb15535711b290547a2a314cf6f1d931c62a8214300011e8d732727fff4006299e0b23d5d724fb0e688b301fb8f3001fb05a3ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb000120ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb20a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107909a18bfec024e4f56a56e3efee94d5b541a627b31c00000000003458102efb4e21fb10190000002cef49cf84da8e7fae2059188b7c4f3df078f4e22cef49cf84da8e7fae2059188b7c4f3df078f4e2a986f69f8d9d9a073287487365e0c31a1a6ec33d308144775a433e210fd111aa673239c996226c99555bb9aa4f96741ec57b78db0aaa69100f9f3fdfa9e90bcd0d3b25f59d0001da8a388088177826d85d98d2518a7a42bf04663f01fb8f3001fb05a3f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a000120f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a20a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079011fc39eaccf31144a236ca22c780d64a3b317b77d00000000003428baeafb4e21fb10190000000381536671c212e9666e5fb5d4a29fe0948773900381536671c212e9666e5fb5d4a29fe094877390a986f69f8d9d9a073287487365e0c31a1a6ec33d30b0ea9db0fa7191c90fbc55dcd984630f9a2892d3250add2ab807132845122644ad888ad2276d59600efdfaf2f4fbf9000001a3f4164595cffe3fb0e79c3cf06a4ea1d5d474b401fb8f3001fb05a30a01e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50600012001e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50620a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca10790356e79d2b2b0ac0761f6a4526b7d047d74e28f546000000000036cae714fb4e21fb101900000058127be0d801051a163bf0353cc5bb9defd2f57358127be0d801051a163bf0353cc5bb9defd2f573a986f69f8d9d9a073287487365e0c31a1a6ec33d30b104db07b513ef45b0da4c1379599b7c5981860fa588d7968cbc0408a1cc729fcb64b2c7586c9719caa7d33ddaccf42900019eb3c89309106d441cc1749640ab5613046f6ad001fb8f3001fb05a3122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b080000120122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b08020a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107906903790983928ee282b9644cbf9c8e6cee72efe90000000000012f6e315fb4e21fb10190000009b482e4b8f5da7583a15fc887928e6c404e17f9b9b482e4b8f5da7583a15fc887928e6c404e17f9ba986f69f8d9d9a073287487365e0c31a1a6ec33d30b5c57edb1258f5c1cfdb21b6680de011ddeea93e797e5f597dedd0abb85eea27bf862ff95528ed80c9cb0bae3a2715fa0001a7822db397ca4e35b81d016ce52bdbaae74880ab01fb8f3001fb05a34838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b160001204838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b1620a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079079150fb7c07cdbac70f458cd23487e212760de68500000000002cf7a034fb4e21fb1019000000579ecdebf8c2a3f347c301cd56f8d25a60821ebd579ecdebf8c2a3f347c301cd56f8d25a60821ebda986f69f8d9d9a073287487365e0c31a1a6ec33d30b455073ebdd660759753d3158e0af7038620bc484d5b206cc76cd517ccd4aaedff0a967d3a2245ca12dd39eaec565dc10001c6e2f8c23c3b847ae4b8f0c452408f843fe3afa601fb8f3001fb05a34c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc510001204c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc5120a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca10790ad2e5173d4d1f2ddab7848de87288ef7fea4a5bc2000000000036d64d6cfb4e21fb101900000032d019c0a0521635e2c50baa0639afde38128ca032d019c0a0521635e2c50baa0639afde38128ca0a986f69f8d9d9a073287487365e0c31a1a6ec33d3085918a1ce01bed79b0f2f73b4b9cf3d3beb0d79508801139611d488cd5ecd7184f72c5489eb78330d5f43caebc9a0a110001cca358aba0b27446e73f6cbc372d549de4039d4301fb8f3001fb05a3aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc3000120aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc320a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079089a27487a58654bceeacfd3fb1a2cda28642ddb2700000000002359f656fb4e21fb1019000000a4639a40da95a2eca6bd0b821de9d45e6b4a2b2ba4639a40da95a2eca6bd0b821de9d45e6b4a2b2ba986f69f8d9d9a073287487365e0c31a1a6ec33d30b343c9b538cc9694dbb8cf3ecc288875ec6e53175c72d557c2ac5fad08659084a83a9aeb670d6aa484f293de2d85af33000120499e02a93241d54692c96b4ef147e46b12327501fb8f3001fb05a3ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e5110441838000120ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e511044183820a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079057ba786e269da8db182526a7dd051b5b5dc231fb500000000002cf560a4fb4e21fb101900000081b0121840d749be5f287a4117515f4d8f3fd65f81b0121840d749be5f287a4117515f4d8f3fd65fa986f69f8d9d9a073287487365e0c31a1a6ec33d30b03a8cb594e95d4d3e9d993e5a2df17ef5161fcf67560bd91fff3bbd5d4a4fe26082c6c37fac5a73491dc93e1900b4950001acc20a8324d0b1f914a4ffe605d488f21a026cd601fb8f3001fb05a3c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb000120c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb20a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107902493372ccd17dea09c98b8c35077387b21f8ad28d000000000036cb745bfb4e21fb1019000000fcd87a7892e645ebba5647bd9eebc25b34ddde70fcd87a7892e645ebba5647bd9eebc25b34ddde70a986f69f8d9d9a073287487365e0c31a1a6ec33d30a2cff2a27595a6bc79ce79c4f360713a35e20350ec106f20d01a90d1374ac0c5ef709ce968bcc0a7888340f5871805040001f77c894ac83526befcc07157a82e52cc2b1697f101fb8f3001fb05a3d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945000120d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc377194520a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107904645e20b1c5090f6f05b601eec64d6c17cd88094a000000000022ded6aafb4e21fb1019000000d6cdf6df678342ca7e9d906e354dd9355445cb80d6cdf6df678342ca7e9d906e354dd9355445cb80a986f69f8d9d9a073287487365e0c31a1a6ec33d308c89302e7919585c6c9870d5ec60e89abe15bdc62e8043a7db8d47ecb15535711b290547a2a314cf6f1d931c62a8214300011e8d732727fff4006299e0b23d5d724fb0e688b301fb8f3001fb05a3ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb000120ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb20a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107909a18bfec024e4f56a56e3efee94d5b541a627b31c00000000003458102efb4e21fb10190000002cef49cf84da8e7fae2059188b7c4f3df078f4e22cef49cf84da8e7fae2059188b7c4f3df078f4e2a986f69f8d9d9a073287487365e0c31a1a6ec33d308144775a433e210fd111aa673239c996226c99555bb9aa4f96741ec57b78db0aaa69100f9f3fdfa9e90bcd0d3b25f59d0001da8a388088177826d85d98d2518a7a42bf04663f01fb8f3001fb05a3f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a000120f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a20a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079011fc39eaccf31144a236ca22c780d64a3b317b77d00000000003428baeafb4e21fb10190000000381536671c212e9666e5fb5d4a29fe0948773900381536671c212e9666e5fb5d4a29fe094877390a986f69f8d9d9a073287487365e0c31a1a6ec33d30b0ea9db0fa7191c90fbc55dcd984630f9a2892d3250add2ab807132845122644ad888ad2276d59600efdfaf2f4fbf9000001a3f4164595cffe3fb0e79c3cf06a4ea1d5d474b401fb8f3001fb05a3013201" }); + +/// Version 8 devnet platform state in the supported storage format: platform +/// state V1 with V2 quorums. Re-serialized from [`PLATFORM_STATE_V8_DEVNET`] +/// at commit 734bd4eea7, before removal of the legacy readers. +pub static PLATFORM_STATE_V8_DEVNET_SUPPORTED: LazyLock<&str> = LazyLock::new(|| { + "01000100fd00000196679379cde0fb4cf8335c28e2d5b81fe8563beff647c4a74bac7165d84276eb62dc46fd2cc6bfe53f6b00000299b14717769ec09ccd478a1f3c5f27ba04e6c5fe67b5c26d96ba54f8741533fd4861a2205ac950c9f39bfcb92d75c30010cc6e83d23eee89792132cf78ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e51104418388bcb4a1798aebc9b25e3d444ff15e4b272c4ee5dbf51309147db28421f49a736a6fb0260ea8b075f8309331caed3f99b193410cee745b02ad9b93d16c22cc7bfac642917c93c288e2a1977f325fb0b76cc6c22447d363c43a20bb89c89d3253300080800000299b14717769ec09ccd478a1f3c5f27ba04e6c5fe67b5c26d96ba54f8740004000005c2a084bd68f4c908dfd772db63462a1a26be397eb1ad018bb9199cb8d900000005c2a084bd68f4c908dfd772db63462a1a26be397eb1ad018bb9199cb8d900fb4ce00a2001e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601b7536c30ebb2297379cce4e832c5c88828dba988b1b339ba403621a67cc26325baf14d809cbd4b30ef07c783a45749130d35342e3230322e3233312e32309eb3c89309106d441cc1749640ab5613046f6ad0fb4e21fb05a3fb8f300020122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b080122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b08001b6aa2516aa6e47c9824efc13422cccc45a73fbe0bab83334fc31122f99c2e6fc37f667928c20176702284a4211393f4e0d31382e3234362e3232372e3231a7822db397ca4e35b81d016ce52bdbaae74880abfb4e21fb05a3fb8f3000204838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b164838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b1601a1f07095b3171384f7d7cd23d766cb5ef32cf1bc3808eb5dd6cbc4c910ee0e51d11f47f2673db173c166749f5c61f4790d34342e3234372e3136302e3532c6e2f8c23c3b847ae4b8f0c452408f843fe3afa6fb4e21fb05a3fb8f3000204c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc514c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc5101846f0ab803a4569eae1a616443456bf498f0493b9d32c919a59d6bb722bcd2200077e9439d9fb621d9f966bef1009bde0d35342e3231342e37372e313038cca358aba0b27446e73f6cbc372d549de4039d43fb4e21fb05a3fb8f300020aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc3aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc301b117767d537e5c34c7c459a76b97af529a1255e0bf2c61ea96316c347f2c13abf6755e52ae2e8ae41a41414617ed6afd0c33352e38392e3234362e383620499e02a93241d54692c96b4ef147e46b123275fb4e21fb05a3fb8f300020ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e5110441838ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e511044183801abac813a50f33c5e2c53284e880a47b831c3683a63686991146f473ec129e324a80492f1bde63986f0564304e5bd36b30d34342e3234352e39362e313634acc20a8324d0b1f914a4ffe605d488f21a026cd6fb4e21fb05a3fb8f300020c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fbc254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb01ab9ecac6c4edbb91ec9b91347b3f0cdd9872c8278432f3f7550d3812f5b82afe7e1701984edd53b0b84f59fe56ebd66a0d35342e3230332e3131362e3931f77c894ac83526befcc07157a82e52cc2b1697f1fb4e21fb05a3fb8f300020d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945018be3cda106e64ec22ab90dff0b9aebf399f64925ec460896683df9ebfe77a767315ceeb51a395fac87a3cecfd0d9f2580e33342e3232322e3231342e3137301e8d732727fff4006299e0b23d5d724fb0e688b3fb4e21fb05a3fb8f300020ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408ebed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb01a342022a1ff0f2e8a9b42f0d031d3704fa89a6dc85e8bf31e88266f4dbcbc2d1f9255913b5dd51d7f96fc25b04af53100b35322e38382e31362e3436da8a388088177826d85d98d2518a7a42bf04663ffb4e21fb05a3fb8f300020f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1af7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a01a612b7515f24806d24b34176383f3d73ac673eae61142860c2ceed761f8f1435d988f64a33d0fb9a529e870c68dd50990d35322e34302e3138362e323334a3f4164595cffe3fb0e79c3cf06a4ea1d5d474b4fb4e21fb05a3fb8f3000ae243894aa11a2c9f1bb0464499864376b85c773c8ff5a7f5d57bfee2977459db996ce325d9bc4996582baa0f96b59b60000041ad2e1652e70ca1db2e3bcb39a5271b4862c4e2aa3197eafba20ec02ce000000041ad2e1652e70ca1db2e3bcb39a5271b4862c4e2aa3197eafba20ec02ce00fb4cc80a2001e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab506018ebacd1b1061d80715fe840a199b6635830ad7abc379e1af869998c1b91257b4819935f1796d1c6bc86c79f263a64c430d35342e3230322e3233312e32309eb3c89309106d441cc1749640ab5613046f6ad0fb4e21fb05a3fb8f300020122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b080122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b08001ab5a092f14f019e1ae79ec037ebe88d3501139a82736521b2aabca4f078f934bbf9d136383c2386ce5739f6f9a5f9d490d31382e3234362e3232372e3231a7822db397ca4e35b81d016ce52bdbaae74880abfb4e21fb05a3fb8f3000204838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b164838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b16018aaabc36b1e2f42664abec989208b9821650b704323cb8d66be00095954a1d20194ef23c33c839e760f03f0ac0bcca350d34342e3234372e3136302e3532c6e2f8c23c3b847ae4b8f0c452408f843fe3afa6fb4e21fb05a3fb8f3000204c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc514c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc5101aa6bf2536b37af83b6e88a50b35216aebcf2e433758d419e150e00d19caf6ca6fcffa234d49c86a2905e400f41d5a3a50d35342e3231342e37372e313038cca358aba0b27446e73f6cbc372d549de4039d43fb4e21fb05a3fb8f300020aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc3aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc301aadc92e09655108cc8736b055e5abf288e060b06de527a4f6fc5b65516037e555ca0b9944c65ea678dc59348d6e138e70c33352e38392e3234362e383620499e02a93241d54692c96b4ef147e46b123275fb4e21fb05a3fb8f300020ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e5110441838ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e511044183801b919077a4108af14570de90782408632b048b528df100076077598a8555758d656cae0fd3ec132b1fd113e18d3b623d50d34342e3234352e39362e313634acc20a8324d0b1f914a4ffe605d488f21a026cd6fb4e21fb05a3fb8f300020c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fbc254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb01a7553852f9a1692b7696cb063e49e173ca655b80e1fa95d8e03926dabb0a16f1ca4e7d7f32666e838d53d228e80bf5390d35342e3230332e3131362e3931f77c894ac83526befcc07157a82e52cc2b1697f1fb4e21fb05a3fb8f300020d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945018babe479bf760cd34be2b57e088e9756d3eac5e92f5e978b5abdf3e8a4d3ea5f4bb93e3c5e6227d1c9174fd7e38ad5140e33342e3232322e3231342e3137301e8d732727fff4006299e0b23d5d724fb0e688b3fb4e21fb05a3fb8f300020ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408ebed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb01b7be15daa0d2513874b47d5d4283563969a933bb473e21222c63271dfae2ddd560df3806172b9b897926b214542b73a40b35322e38382e31362e3436da8a388088177826d85d98d2518a7a42bf04663ffb4e21fb05a3fb8f300020f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1af7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a0193d0baee082057cc2e7a17bf6cad8d3df0e4fc5438de2027ea77bb20a7910862ecc145b4631bcd58e39fd62a19e2ea150d35322e34302e3138362e323334a3f4164595cffe3fb0e79c3cf06a4ea1d5d474b4fb4e21fb05a3fb8f30008028075a0cca9efbc93a7c50b3c670ed90c129b64705f1c3c2ccedc811ff5844ed6f1e34601a13a2b59bc94329b74606000017fd360e19c0346ceb923e43c1fc601153ba921ad0186320347d6ad6796800000017fd360e19c0346ceb923e43c1fc601153ba921ad0186320347d6ad6796800fb4cb00a2001e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601aaac3862eed7b02ba53f7a019047849d5b492ec41c8f5541e4b81811ae989d703c200ca058226e9e78f081e07f0742b20d35342e3230322e3233312e32309eb3c89309106d441cc1749640ab5613046f6ad0fb4e21fb05a3fb8f300020122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b080122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b08001b57396d68a27a823604af7404e7fa28e9d0a559b42e94464eee8ee322a0f5b017d50827c0a460adb57d98555ac5d31ac0d31382e3234362e3232372e3231a7822db397ca4e35b81d016ce52bdbaae74880abfb4e21fb05a3fb8f3000204838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b164838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b1601b45e2079572eea6d7890f5199ceef69fc7e71a353fa919a8a58a44b3aab65926b60fc10cfcb62b85b4f422f49d3e92e90d34342e3234372e3136302e3532c6e2f8c23c3b847ae4b8f0c452408f843fe3afa6fb4e21fb05a3fb8f3000204c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc514c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc51018a47a2fe45a808aea52b26adfe15d75fa422762d9a8615bc8cdd9987c68e2b84bc06bbff4378f639f3aa57133a1aa81a0d35342e3231342e37372e313038cca358aba0b27446e73f6cbc372d549de4039d43fb4e21fb05a3fb8f300020aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc3aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc301aadf1764b8f7f60788cc90d95f0403b249acce9ee6e4bb31c90061d9dd5cfe32812b64249ec0b017bcf67f30e44c3bc50c33352e38392e3234362e383620499e02a93241d54692c96b4ef147e46b123275fb4e21fb05a3fb8f300020ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e5110441838ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e51104418380185b29d05607cf79e2dbeff52d40751a30a2f1bd8fd63508b2c45ff75577f6f3f3c92951069690a8b4976ece9fedc966b0d34342e3234352e39362e313634acc20a8324d0b1f914a4ffe605d488f21a026cd6fb4e21fb05a3fb8f300020c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fbc254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb01a8e81b88af2eefb6ab3b39652a651a4ea57e0c82eedb90908769716ecd9928fe825fdd142c4938e7049dc31c43bda2e70d35342e3230332e3131362e3931f77c894ac83526befcc07157a82e52cc2b1697f1fb4e21fb05a3fb8f300020d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc377194501ab750eb8ce4e3cb196dac1890bae03e6a1cdf9bf0b70a63ea6ca64f7ee1946b8fe02b8362290765cb9ffeda0e5088a0b0e33342e3232322e3231342e3137301e8d732727fff4006299e0b23d5d724fb0e688b3fb4e21fb05a3fb8f300020ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408ebed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb019031840125574c094554c02649a65b9dec67285d6e0f89ebbae56b55eedd5393757bb81a4fec886422d8e3ac485dc2740b35322e38382e31362e3436da8a388088177826d85d98d2518a7a42bf04663ffb4e21fb05a3fb8f300020f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1af7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a018f922fdc28078e252b6e221b3ccaa6f3451885b4413e7a21b4a7850eb924122cbed5fb366af8485bd1d8d67f185232d60d35322e34302e3138362e323334a3f4164595cffe3fb0e79c3cf06a4ea1d5d474b4fb4e21fb05a3fb8f3000b887b3dbc961b87e02fd7e16929fe771133d6c76fa1faebb35c2b1da15d32292a314b477f60f4c6d02b46110c0ef6eec00000299b14717769ec09ccd478a1f3c5f27ba04e6c5fe67b5c26d96ba54f8740000000299b14717769ec09ccd478a1f3c5f27ba04e6c5fe67b5c26d96ba54f87400fb4c980a2001e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50601a4037c6dc40a494e120de11721a221e876b75fd099c852bb1b44a2ba882bc4c25a0998d60e56ca29983abe918f15a2ad0d35342e3230322e3233312e32309eb3c89309106d441cc1749640ab5613046f6ad0fb4e21fb05a3fb8f300020122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b080122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b08001a12ace1e26c8ce82f2e736b26653f64a477ec58de0f964b8e79b67aea72b70c4c46d0e8c48a77b83fbde7d4e5b6b00910d31382e3234362e3232372e3231a7822db397ca4e35b81d016ce52bdbaae74880abfb4e21fb05a3fb8f3000204838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b164838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b160181d6653d0930d0c17ae170c3a492abaed7790a43b064258684e520e47e8627c0e7f331fdb14cf8a303c6f472d8240c3b0d34342e3234372e3136302e3532c6e2f8c23c3b847ae4b8f0c452408f843fe3afa6fb4e21fb05a3fb8f3000204c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc514c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc51019209cfef89be975385818843303544dbbdbe5e71fb035de048aa870972d83b0a2822ef1dc28f02f1e1d94e9e50a091790d35342e3231342e37372e313038cca358aba0b27446e73f6cbc372d549de4039d43fb4e21fb05a3fb8f300020aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc3aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc301b64f956fed0ea351b56e6271d9da59e5b053cc5b707ef057fc165ad23176e6bf5160bab2d8f5ad1abd45ac508856b8d40c33352e38392e3234362e383620499e02a93241d54692c96b4ef147e46b123275fb4e21fb05a3fb8f300020ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e5110441838ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e511044183801a98cd5f09273c6a038b6a29af2eaff1570e62e03b25bbb6ba21354a01b96cfca07dca4ae4b3ae5496a4d62d63c1ec7cc0d34342e3234352e39362e313634acc20a8324d0b1f914a4ffe605d488f21a026cd6fb4e21fb05a3fb8f300020c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fbc254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb01acd8ed44c9de6126a9b683b915c85ec85ee67983603bba65f5427fbcf62d5460a89a91d03dbabb4b041d0585fa8a99200d35342e3230332e3131362e3931f77c894ac83526befcc07157a82e52cc2b1697f1fb4e21fb05a3fb8f300020d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc377194501aab6f5e05fb6544513c6af9624c6d18b8dcca7eee3356d61631d718931630075811af66ed540b43baeab4b3a8339becc0e33342e3232322e3231342e3137301e8d732727fff4006299e0b23d5d724fb0e688b3fb4e21fb05a3fb8f300020ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408ebed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb0185187e5ec226e3aa03eb2f6e157f042ef8e0aa444c80f018664956c895e45a894dcea801ed3f3acafe78be22051801600b35322e38382e31362e3436da8a388088177826d85d98d2518a7a42bf04663ffb4e21fb05a3fb8f300020f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1af7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a018d0b0344f40beddbd946ae247a5617e3329894d88e84f94a56990a2af72d3ff67d05b86f8ec6145ff65578aae1d9a1730d35322e34302e3138362e323334a3f4164595cffe3fb0e79c3cf06a4ea1d5d474b4fb4e21fb05a3fb8f30008cf580fb386270abfc216e3beb47d028c5c49dac56d706b2797ee9fb65322a680bb632a2a81191dfdea453569adf049e02070400180400000299b14717769ec09ccd478a1f3c5f27ba04e6c5fe67b5c26d96ba54f8748c786a8a62110a49cf5032723429517beff088867f048c5ff795d394322aa5ae0d51f87fad5f5a3e7864aee139aef68a000000041ad2e1652e70ca1db2e3bcb39a5271b4862c4e2aa3197eafba20ec02ce84b18ace26a0084f94122e5b88c24a16d678efdb36ecec9088c81dc572ced080a8ebc5c2e35f80b48ffe5efab68890b600000005c2a084bd68f4c908dfd772db63462a1a26be397eb1ad018bb9199cb8d98b5be5697a66e7fc3b1e0fb0e247f2be6f68096888b578ca1c35761a057e2ff9fc308d692c115f3cf252cea1423f2d1e00000017fd360e19c0346ceb923e43c1fc601153ba921ad0186320347d6ad6796893fba22ce69238d34733636602fc26e1b841da63dd37cc0af69efb1ba815cfcb3a7a5be870db4d2f1a940dc3ad407f7a00010400000299b14717769ec09ccd478a1f3c5f27ba04e6c5fe67b5c26d96ba54f8748c786a8a62110a49cf5032723429517beff088867f048c5ff795d394322aa5ae0d51f87fad5f5a3e7864aee139aef68a00000003e208609aa86a58da32e5465fa6ae8ee72d2e2b3936f2d8cfafd52f058193c47178fa64592f11a32f7718bd518d90b3c847c7b8fa4bca6addaece93581dab9a3429ec2c7c7347ce920e88979e56000000041ad2e1652e70ca1db2e3bcb39a5271b4862c4e2aa3197eafba20ec02ce84b18ace26a0084f94122e5b88c24a16d678efdb36ecec9088c81dc572ced080a8ebc5c2e35f80b48ffe5efab68890b600000017fd360e19c0346ceb923e43c1fc601153ba921ad0186320347d6ad6796893fba22ce69238d34733636602fc26e1b841da63dd37cc0af69efb1ba815cfcb3a7a5be870db4d2f1a940dc3ad407f7a00fb4ceafb4ceb01fb4cd4020b020130020000057d6aec5a186ff690e13b41e10c938d06c9ba25046836c740549b0e3969b8faca3e409109d3549187247ab50bfe5843545c3064ef953653f52f5a0ddefb4b91325812def3cc26808067624327890101000005c2a084bd68f4c908dfd772db63462a1a26be397eb1ad018bb9199cb8d9aac58025b9e50077a3edfe1aaab170fcdb6b15b3a500212460265cb756ea33cba57ca432916bca4c4ef72b1b172600c20100010200000074d7b31cf77817c30df933d80fa6e354b6582c29ef416799a508631039a8dc97e32336fe44d357d4936d196f08731328f15758cd7760fe584862869944556826905742737e3da542d782e57acb0101000017fd360e19c0346ceb923e43c1fc601153ba921ad0186320347d6ad67968b7f439f6c82070bd8a73313e98d228b9f11b1c0232a1b9733580155bfbd27a3c399ecc5babdd4a6cf2908a836ccba2720100fb4cebfb4cec01fb4cbe0a01e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50600012001e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50620a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca10790356e79d2b2b0ac0761f6a4526b7d047d74e28f546000000000036cae714fb4e21fb101900000058127be0d801051a163bf0353cc5bb9defd2f57358127be0d801051a163bf0353cc5bb9defd2f573a986f69f8d9d9a073287487365e0c31a1a6ec33d30b104db07b513ef45b0da4c1379599b7c5981860fa588d7968cbc0408a1cc729fcb64b2c7586c9719caa7d33ddaccf42900019eb3c89309106d441cc1749640ab5613046f6ad001fb8f3001fb05a3122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b080000120122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b08020a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107906903790983928ee282b9644cbf9c8e6cee72efe90000000000012f6e315fb4e21fb10190000009b482e4b8f5da7583a15fc887928e6c404e17f9b9b482e4b8f5da7583a15fc887928e6c404e17f9ba986f69f8d9d9a073287487365e0c31a1a6ec33d30b5c57edb1258f5c1cfdb21b6680de011ddeea93e797e5f597dedd0abb85eea27bf862ff95528ed80c9cb0bae3a2715fa0001a7822db397ca4e35b81d016ce52bdbaae74880ab01fb8f3001fb05a34838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b160001204838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b1620a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079079150fb7c07cdbac70f458cd23487e212760de68500000000002cf7a034fb4e21fb1019000000579ecdebf8c2a3f347c301cd56f8d25a60821ebd579ecdebf8c2a3f347c301cd56f8d25a60821ebda986f69f8d9d9a073287487365e0c31a1a6ec33d30b455073ebdd660759753d3158e0af7038620bc484d5b206cc76cd517ccd4aaedff0a967d3a2245ca12dd39eaec565dc10001c6e2f8c23c3b847ae4b8f0c452408f843fe3afa601fb8f3001fb05a34c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc510001204c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc5120a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca10790ad2e5173d4d1f2ddab7848de87288ef7fea4a5bc2000000000036d64d6cfb4e21fb101900000032d019c0a0521635e2c50baa0639afde38128ca032d019c0a0521635e2c50baa0639afde38128ca0a986f69f8d9d9a073287487365e0c31a1a6ec33d3085918a1ce01bed79b0f2f73b4b9cf3d3beb0d79508801139611d488cd5ecd7184f72c5489eb78330d5f43caebc9a0a110001cca358aba0b27446e73f6cbc372d549de4039d4301fb8f3001fb05a3aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc3000120aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc320a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079089a27487a58654bceeacfd3fb1a2cda28642ddb2700000000002359f656fb4e21fb1019000000a4639a40da95a2eca6bd0b821de9d45e6b4a2b2ba4639a40da95a2eca6bd0b821de9d45e6b4a2b2ba986f69f8d9d9a073287487365e0c31a1a6ec33d30b343c9b538cc9694dbb8cf3ecc288875ec6e53175c72d557c2ac5fad08659084a83a9aeb670d6aa484f293de2d85af33000120499e02a93241d54692c96b4ef147e46b12327501fb8f3001fb05a3ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e5110441838000120ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e511044183820a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079057ba786e269da8db182526a7dd051b5b5dc231fb500000000002cf560a4fb4e21fb101900000081b0121840d749be5f287a4117515f4d8f3fd65f81b0121840d749be5f287a4117515f4d8f3fd65fa986f69f8d9d9a073287487365e0c31a1a6ec33d30b03a8cb594e95d4d3e9d993e5a2df17ef5161fcf67560bd91fff3bbd5d4a4fe26082c6c37fac5a73491dc93e1900b4950001acc20a8324d0b1f914a4ffe605d488f21a026cd601fb8f3001fb05a3c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb000120c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb20a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107902493372ccd17dea09c98b8c35077387b21f8ad28d000000000036cb745bfb4e21fb1019000000fcd87a7892e645ebba5647bd9eebc25b34ddde70fcd87a7892e645ebba5647bd9eebc25b34ddde70a986f69f8d9d9a073287487365e0c31a1a6ec33d30a2cff2a27595a6bc79ce79c4f360713a35e20350ec106f20d01a90d1374ac0c5ef709ce968bcc0a7888340f5871805040001f77c894ac83526befcc07157a82e52cc2b1697f101fb8f3001fb05a3d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945000120d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc377194520a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107904645e20b1c5090f6f05b601eec64d6c17cd88094a000000000022ded6aafb4e21fb1019000000d6cdf6df678342ca7e9d906e354dd9355445cb80d6cdf6df678342ca7e9d906e354dd9355445cb80a986f69f8d9d9a073287487365e0c31a1a6ec33d308c89302e7919585c6c9870d5ec60e89abe15bdc62e8043a7db8d47ecb15535711b290547a2a314cf6f1d931c62a8214300011e8d732727fff4006299e0b23d5d724fb0e688b301fb8f3001fb05a3ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb000120ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb20a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107909a18bfec024e4f56a56e3efee94d5b541a627b31c00000000003458102efb4e21fb10190000002cef49cf84da8e7fae2059188b7c4f3df078f4e22cef49cf84da8e7fae2059188b7c4f3df078f4e2a986f69f8d9d9a073287487365e0c31a1a6ec33d308144775a433e210fd111aa673239c996226c99555bb9aa4f96741ec57b78db0aaa69100f9f3fdfa9e90bcd0d3b25f59d0001da8a388088177826d85d98d2518a7a42bf04663f01fb8f3001fb05a3f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a000120f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a20a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079011fc39eaccf31144a236ca22c780d64a3b317b77d00000000003428baeafb4e21fb10190000000381536671c212e9666e5fb5d4a29fe0948773900381536671c212e9666e5fb5d4a29fe094877390a986f69f8d9d9a073287487365e0c31a1a6ec33d30b0ea9db0fa7191c90fbc55dcd984630f9a2892d3250add2ab807132845122644ad888ad2276d59600efdfaf2f4fbf9000001a3f4164595cffe3fb0e79c3cf06a4ea1d5d474b401fb8f3001fb05a30a01e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50600012001e1f3c05fd243c23711ec8d9a220f4f0a6e757e06df7c8f80d32e110beab50620a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca10790356e79d2b2b0ac0761f6a4526b7d047d74e28f546000000000036cae714fb4e21fb101900000058127be0d801051a163bf0353cc5bb9defd2f57358127be0d801051a163bf0353cc5bb9defd2f573a986f69f8d9d9a073287487365e0c31a1a6ec33d30b104db07b513ef45b0da4c1379599b7c5981860fa588d7968cbc0408a1cc729fcb64b2c7586c9719caa7d33ddaccf42900019eb3c89309106d441cc1749640ab5613046f6ad001fb8f3001fb05a3122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b080000120122be582d024c032d83575f04453b794fd7aaefef926cfc2664baa23c612b08020a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107906903790983928ee282b9644cbf9c8e6cee72efe90000000000012f6e315fb4e21fb10190000009b482e4b8f5da7583a15fc887928e6c404e17f9b9b482e4b8f5da7583a15fc887928e6c404e17f9ba986f69f8d9d9a073287487365e0c31a1a6ec33d30b5c57edb1258f5c1cfdb21b6680de011ddeea93e797e5f597dedd0abb85eea27bf862ff95528ed80c9cb0bae3a2715fa0001a7822db397ca4e35b81d016ce52bdbaae74880ab01fb8f3001fb05a34838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b160001204838bb71ef5136100dbf35ee184370fe1e42d5d7b41fbcdd0652bbad7a705b1620a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079079150fb7c07cdbac70f458cd23487e212760de68500000000002cf7a034fb4e21fb1019000000579ecdebf8c2a3f347c301cd56f8d25a60821ebd579ecdebf8c2a3f347c301cd56f8d25a60821ebda986f69f8d9d9a073287487365e0c31a1a6ec33d30b455073ebdd660759753d3158e0af7038620bc484d5b206cc76cd517ccd4aaedff0a967d3a2245ca12dd39eaec565dc10001c6e2f8c23c3b847ae4b8f0c452408f843fe3afa601fb8f3001fb05a34c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc510001204c51cd612d4a8e94a5952037ebae6871c8ab623b01b8cd16c2aa9c814b78bc5120a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca10790ad2e5173d4d1f2ddab7848de87288ef7fea4a5bc2000000000036d64d6cfb4e21fb101900000032d019c0a0521635e2c50baa0639afde38128ca032d019c0a0521635e2c50baa0639afde38128ca0a986f69f8d9d9a073287487365e0c31a1a6ec33d3085918a1ce01bed79b0f2f73b4b9cf3d3beb0d79508801139611d488cd5ecd7184f72c5489eb78330d5f43caebc9a0a110001cca358aba0b27446e73f6cbc372d549de4039d4301fb8f3001fb05a3aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc3000120aa3577bdeb9a8e7b7ab09e3a1b3e2dd90444b17d9c4776f63aa540e1e1437bc320a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079089a27487a58654bceeacfd3fb1a2cda28642ddb2700000000002359f656fb4e21fb1019000000a4639a40da95a2eca6bd0b821de9d45e6b4a2b2ba4639a40da95a2eca6bd0b821de9d45e6b4a2b2ba986f69f8d9d9a073287487365e0c31a1a6ec33d30b343c9b538cc9694dbb8cf3ecc288875ec6e53175c72d557c2ac5fad08659084a83a9aeb670d6aa484f293de2d85af33000120499e02a93241d54692c96b4ef147e46b12327501fb8f3001fb05a3ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e5110441838000120ba63e68b75a038508dccb221901b391a14737d9ae68beff0afb11e511044183820a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079057ba786e269da8db182526a7dd051b5b5dc231fb500000000002cf560a4fb4e21fb101900000081b0121840d749be5f287a4117515f4d8f3fd65f81b0121840d749be5f287a4117515f4d8f3fd65fa986f69f8d9d9a073287487365e0c31a1a6ec33d30b03a8cb594e95d4d3e9d993e5a2df17ef5161fcf67560bd91fff3bbd5d4a4fe26082c6c37fac5a73491dc93e1900b4950001acc20a8324d0b1f914a4ffe605d488f21a026cd601fb8f3001fb05a3c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb000120c254079a24a9041590b9a3fa01ad41dcccaaae8a0397e71497ceafd7a9b9b6fb20a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107902493372ccd17dea09c98b8c35077387b21f8ad28d000000000036cb745bfb4e21fb1019000000fcd87a7892e645ebba5647bd9eebc25b34ddde70fcd87a7892e645ebba5647bd9eebc25b34ddde70a986f69f8d9d9a073287487365e0c31a1a6ec33d30a2cff2a27595a6bc79ce79c4f360713a35e20350ec106f20d01a90d1374ac0c5ef709ce968bcc0a7888340f5871805040001f77c894ac83526befcc07157a82e52cc2b1697f101fb8f3001fb05a3d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc3771945000120d7f774f9156c2de6102f0e920b92ca04b02af8491ae8168634aa783dc377194520a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107904645e20b1c5090f6f05b601eec64d6c17cd88094a000000000022ded6aafb4e21fb1019000000d6cdf6df678342ca7e9d906e354dd9355445cb80d6cdf6df678342ca7e9d906e354dd9355445cb80a986f69f8d9d9a073287487365e0c31a1a6ec33d308c89302e7919585c6c9870d5ec60e89abe15bdc62e8043a7db8d47ecb15535711b290547a2a314cf6f1d931c62a8214300011e8d732727fff4006299e0b23d5d724fb0e688b301fb8f3001fb05a3ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb000120ed6b98d27580f4c7659889ff1e8a4490486b4d980caa2180693fbb76aa9408eb20a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca107909a18bfec024e4f56a56e3efee94d5b541a627b31c00000000003458102efb4e21fb10190000002cef49cf84da8e7fae2059188b7c4f3df078f4e22cef49cf84da8e7fae2059188b7c4f3df078f4e2a986f69f8d9d9a073287487365e0c31a1a6ec33d308144775a433e210fd111aa673239c996226c99555bb9aa4f96741ec57b78db0aaa69100f9f3fdfa9e90bcd0d3b25f59d0001da8a388088177826d85d98d2518a7a42bf04663f01fb8f3001fb05a3f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a000120f7f8eaf6e911b3dc815b257465f4473a80ad70fe63bb6722c389ce286fc2ed1a20a425162eaa80ebcd6932b83d69ae21be306addaafa7cbf8a9f89722265ca1079011fc39eaccf31144a236ca22c780d64a3b317b77d00000000003428baeafb4e21fb10190000000381536671c212e9666e5fb5d4a29fe0948773900381536671c212e9666e5fb5d4a29fe094877390a986f69f8d9d9a073287487365e0c31a1a6ec33d30b0ea9db0fa7191c90fbc55dcd984630f9a2892d3250add2ab807132845122644ad888ad2276d59600efdfaf2f4fbf9000001a3f4164595cffe3fb0e79c3cf06a4ea1d5d474b401fb8f3001fb05a3013201" +}); + +/// Version 3 testnet platform state in the supported storage format: platform +/// state V1 with V2 quorums. Re-serialized from [`PLATFORM_STATE_V3_TESTNET`] +/// with protocol version 3 at commit e0f21d7137, before removal of the legacy +/// readers. +pub static PLATFORM_STATE_V3_TESTNET_SUPPORTED: LazyLock<&str> = LazyLock::new(|| { + "01000100fd00000192670b9514fb78b1fc00110ab7fb078b34bbc2a6b045158657746dc5db1105bdd6cb6b28a3adcd8735e91dc2e78d8253000000b91e2a2fe9ab4c3899dc7d2d85c9e00e068603afe59058d5415a84773de28aaaab739907a87bba3ff79428d1c8ef5c2a1f8ae5e8f95dfb32a3e07a767440784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d8a7a96ca935bbc898e4a56cd3865874a44134f0cccff168f01a38d25c03aa3bbfe4234869a8f0e57fbe611139cd6d7ac0a310f08ab1583ed6e70afd63ac3649faff1682184939d0a32f5abf1fbc8eeb487c29332191033d1c156f863c09d34b0000303000000b91e2a2fe9ab4c3899dc7d2d85c9e00e068603afe59058d5415a84773d0018000000f1187cb12e35cb2a20fa7ebaad86a10a07f37a26d91068fcbde0ee462d00000000f1187cb12e35cb2a20fa7ebaad86a10a07f37a26d91068fcbde0ee462d00fc00110aa8192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea801b15b76938c54f51b8386980eb3b8631b34ccd35c6884830a43ae3e52ff5a273aa5026d4adf2ebb33cf7c678b72eab8bb0d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a2018897e2f392f0e1f2aad3ab24051db60ec4863b99d031c8c8c97b55156547d55cced5bfe08996a05ee652418ea98151870e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113018dd61f6d77efbc7a1f689fed01dbab0566c71a2acf19a0d26b19a4c3daa582ca5d21c5e137df714d513bef879f0bdb040d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c01b661002db656ba258788a2f9af91710a2e91c0d138b2edddde50d651a5173b3f8e248c4c7e22beee609072fc81ac89f30c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb01a3ad85022b69916fa555be50d6b8d77d5b91f8ca72cc91f106b7f4b9fb806478362d5976a34a5e2b9361262e32defff50d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f3000203971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be13971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be101b0a6419f2650de0abe6cefbe8305b31e5cac7cb80f23472036009076904bb40a7282aae4b3fb6025d437813c3619691b0d39322e36332e3137362e32303261c274080f47a95be5372ef8c69bb60ab1d4ca82fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d01b309f7e2254b0d55fd6e75be528f7b05ed8623dcaf0addf51ff50b13cec0312ec15d00b6394981ef2a9c7fcea3549a9b0c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301b6f7f4e44b06e8f588473c21d6aa2645b6638eeecdb5f0290889ef7cb3d94b138bd46a4d91b5b56cf9bf96777a13579d0d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef43601a743d1bf6e3165cb7450b97a907b4b524de83538c85b2110f59bfde026cdce7104c91715e254b77b25175b9c28d8ec9c0d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb01b5286eded79114127ddc14075e3cc71e179f5247c88059e574416224da0e8c2b0cd65f2d1941dc9dfeaa22873e8339880c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e52863320966018261037fde2ea2c99bc904ae23c6cb827177aa9dbc70119e1cffa0716681f0e92da1639df91d91c6fd194c128a8add900e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70190199d894f15fd6a36a44f56a48502b6da8315ce203e8b7908105eab9fcf1e8fca01ee40bbf1a67a2828541a0da9e3d21fb0d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e01a8a91ee2617de812f7f1cc2c4fbbf2cea408edaf225a8da74761f6ca6cbed60b2054ff1730f54298e82af67d888042470c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be429001b2631ef598d8bebfbcb40b6653250d25d07e42be82709160b1d01e4d3e59af5c3be2262d88ee86c91385ba3b35ce15b10d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82401b84771f8c123270fcee41986222050294edde00dbbc2abdb2e24dfdcbed36383ea34261eecdf4684e9be3339c235a44c0d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc401961e707780b035e2bf7d82ad6a98a82b81615d31129f9be4a43b7ac0e91a7a4f408836b1a067605bc4cb8bb1699c8d190c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f01ae4d8adbece1973d8625d725a644a1dbeb36dcda498040abc45392caa46f515be917ea83400be5342cad96304dc321460d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df5401ab0a7879ee8ad513c0633490d3e86ab2645ff07701f24cd887b9f3bcf1c38baef517a76b2641d0fa47f0be61d368b5d20d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba092096018bd3c1a90462ec65d5df7e3e8f93b67f57e174c1c272d7a33bf6faabc28daccd899f88e208379378be95ac500d7713570c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c018b10630f61ec66b84180ad865634e62a22448b595d8f1876da42c87dcc63c5601f393fccfed6bfb17cbe0c0db125c86a0c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421601a668ab57cd5700686114d03df153295640e5939144d84fb386ee9811ac459cc48876013df04ad44cca5d27461492e95b0d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba80194ea96483a36db9fb9647a2fbaf2bf3df39a9e375ae7a8a8b81c71d4ef5e33f704e69ad50d20ca9a1164484ffd5289a00d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89018ceddd73271ab74091fe496bea3786f10d49b68eeb5357300fd5e71c295b726666da80631ad29a5d7cee5ff9eba6b1e10d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba786399038101adef1c638134ebeb1fe996643698f056c4f0c90c2f122d70dbdccc83abc04f9c558d9dd95084443f3c238c0ecff2977b0d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac901a9b37ba5ebf8695acb31339b2200e7b34881d809654003fb2845e48e24819cfaae2833da5fec3547d51869acaef931290d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f3000a6cbd47ba3201352f0e23d2434f83e1e2029b2514e7273280f9c0a746ce81624e99290d62ddd96097068ef7999d326e40000004689a842c049d460ee314df1bbfa36530ff86632142fe3b6eee8240034000000004689a842c049d460ee314df1bbfa36530ff86632142fe3b6eee824003400fc00110a90192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea80184d7ad239563f639a16a9cdb055a81e683f2a0c654f882c9a54d38c2bc10c110da7829f313e9f4b2c70651207cb273110d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a2018942b5fe5ab5b6636bc0ebfff21dc7a21f0397cc2ea9362e9b476b10b5668aae608dbf5f1ece54a479747634d74041ea0e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f1130184cd7e8744a28e4036feedf3b6f3d691c8ea21e8e69f0c862215e51a15a51205799f0fa0516c7b7cf02b691dca89d2f50d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c018de99ca88d7256389dd5c27ac00b98b95bbead6c7b3008fd8dc6bdaec9f4fe1110f7ffe0fc7ad40aefa37919df04968d0c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb01aaf815d4d59789b72527426251177acf276c39c3113810b9e6614fc866ae21a3f65cbde04edccd8bf791940b73fa84ea0d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d01a4cad187d6efd489b5bac71f56ec6b91e8ed6965bbdd4bebe898678716ddc8a6b7d4e6a0a6fa17bc91a4c1c16d1e64930c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301b222d9014e083f3b542bae5c3daaa94ab024b602e39e045a279d101c128214d1a7d9742e8afa7a6140de6ad61eaf421a0d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb01aa2538b75155fe0304fde0c908be3deacc9abae62bcc0e0336f9cc0c24583d55ff3959963affeb7afcf2a6a0bd6d61410c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209660199f0aa551bd2df9baf3eb6adf0261df8a749a9413f62dd8473fd6ab03b3a6917157a1b5d3b01307d4b32d65fd495be8f0e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be4290018a81e53c43f6ecb09730e937d44984c697938ad776c58424eb626580507642977097ce8daee7ca61e0e8e052fcc44a820d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891801b361d2179cadf86c3d4788078a5380afe844c3b354a4336a35ef6fb774a565f3c1319e597841f87182d6dbce0527ec180e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f23401aa71b13016a1a1fee60d1db3d6987aafcbb813e7cb4ade9766f0b9ea92a89eaefbf540af24d4b7fd021565041edd1ade0d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e081501b886ecda081643bc5e24dfe7d0403bd2639afebf056cbde277b5558e2d497837f26c0acc02d3742e298c5e8ad3f83a650c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc40191b43a2470e00f9aa20ca5f759bfc2181a9822830f057c299ed9f5324f5266c7f3fbc934a4a20baa9a01563a12632fc60c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f01b35c64527fbc2578fd2723311fe76a4ef602f9314596f9133a2626aa2bd818a828d067946799b3150e25324e0e77e4790d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d018b8a33b1554491346591a0147b376489af1adac664b6a0b2b4c542627553429c6dfde43048681ae55cd12ea84806fa880c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df540199cc490e6796af6a93c03be74e46603ee8d597a40c53fee0ef58cde0dd5c70526c6da8b633d2f231d4a1b6ab12329e330d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba0920960197309058064a4efd3dac7d1f83e0c9acaf820cc26be3844e38260203eb9de1ab343b85663df57db01030231a58fe51300c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c0191408bdb75e94dcd5f529e04d40e1338cdd59105e20f644f30035345bd8a1abb4f26a30ed33a5f718fc0651d5e3ea17e0c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f01804761ed1300c056087c87255d97a6163b5583f9db147b4c13a302783e03ccb91b9c41bd85b5749e6ac1cd66618ee2c80b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421601b18bb95e55a3159681810e3bba2d820554605bbe094863d2175a58a729ccb5d5c4005668ad5e1568a5a4e6fc9e44868a0d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba801ac27a016518e3768ba8fdcb01af7a6c3668e2594d90f2d199491cd82b4bd1b8f46f869aa9ca3b82c592360222cded8690d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f8901aaab1fef4dd9ec25e263524b62b04151d74a51f94bd0bd1d96a69ec372827c0c4e5a3f157e6bcbc5bc9c8f52119e670b0d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba786399038101a3eb4ba1d46723c1321ae975611049a27cffa5de8a9d86348c8f8e00432f515b71e6846a26c466d559db3d0fb24bc70a0d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac90193fecca26bf5ad7a125463e41ec77a3e3fc962672fd71ae5982bfb3c0b0dda2276c9a8df4b42795034bf6642c9043b140d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f3000b3c85502f9c7789d7ce97199d4b411ee93a771c0209bc6a6b61e3b637eb8f2de1778f8a9c2bbd18ef27a07ac2b7f21210000010832789d4cdff3cc8a63fad668ccac708af7433c42e189ada6c6e5e66e000000010832789d4cdff3cc8a63fad668ccac708af7433c42e189ada6c6e5e66e00fc00110a78192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea801a9f8fc1cbb8413542a88a12c2bd8ed37d164176e3ec69ef1da36b17732e9edfe26d5a4637b714871c0969e85c5ed49340d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f11301b77c254aa8967f93938cccda412ff4cc2ae33c1632fdf22d6d6e01e350bee7cda4293fcf7bdd08421a89d89d31f3d3700d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c01a95cfa0fb3e2b7405577f766f10f8a527b4f0ea8da4fd9e308eaef910c82b6bfe395ebac71d7344db812de815e0b7a6e0c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000203971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be13971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be101972fa1195e580291865db0045df4ca36e3775c91bc14107259ecde0fbbabaa90c965949a00cd11e9a7c288d9b325edb00d39322e36332e3137362e32303261c274080f47a95be5372ef8c69bb60ab1d4ca82fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a018ce9094c3230172b326a5ee57a2f76413371a66bda5c34c6ef0f0f62cef8fab9fa44b9423c182ca2e8779d17b77bb14a0e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d01b5b6cda330445e2e8ae0289b476aab0b925f0f6f62975c2af939512ab2ecb00a669a099c9d1a9f3b1c322eed82a0a6430c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301a99d91eda26d9a436188ecfce2df4f7afc9954764a421234713f1083fd445abd9733e0b8bbf0e6fe43db02cfa07fb11f0d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef436018c2bf1a5c7782b57c78edc0c9a780bb03fd12b563b43cdf7f0b1e1e96081f8d11d3e131988f37ebe2799eaaedbd065c40d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e5286332096601a2a5775aec8818a7914b1a610d095343e5e54e3834a51fe0c2c8b0d85e5e347bbc205a2cc19d665da624996f5c797a520e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701901b2613f4f71b8cb2d6d5d40312bb676bf0272fcb4d141e2aa23dfe8698655a4c1c93150b244488a13f5cf60dc3301c1830d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e01ae815e003eeb65606f18a624ca248f83c1a70c168b15a75d935127fa479ba75a30d734d40b008c4f26e6b384957837fc0c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be429001b0b9f5db3633b48d5359d5b8d9e99f2eaf5e6603fae01746602f538e8d9e923ff1f47a5f84ff0be24d24d6e80d2710df0d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891801a36373377b1befa6f35aec8f2c56b95433324e2526748116338d7cda1274090cca1c69959b02e3f9c97a1787798e05ac0e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f23401ab3ac53a601829b7d999c55095069f25b6df87616d2276386b3eb28c68a861ce46352a008ce967f2a9b68c06a41cab1a0d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e081501a42e3e2fdf2fe5c7f368e695f0649831a6817d8670f895c9b1475836a284ae985703ef520b369adff6a4fc00edc4cfff0c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc401a1172e43ca64a94af9ebc84191b9a8d071c4ef72f2d20a1d4982753e6a875821784dfd5b81f9670fd3c88ba79bfd74800c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c001b9f7bdfe0077e3a924a4d881683a3a51aa4204329451ce160c83c78a908eae5614e965220e26daff6894bcad781c06250c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df54019362f6b7585fe368cd6e82e0ac831ebfb04d65663a3f997db0c55b6397e73565f691f4968ba9e60418b94f6e1b8466430d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209601a8f426b9e58b4448cb7fcc01f05196567b7cca3ae0b601dbe096853916cab1c4c3e6e77fb59d0e944d5546fb3e74099e0c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c0188e2df5210ce24801f4fd9fed061152862ac4bf8209ce7a9635581d9e204ad2aca8dac837a392f2e692fffd2bd18d8890c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f01a3079ebff53a2eaa226c29515eb1f2f83c32a9f8730c1cfd22af38823153046ec09afdd6439b21de4c0ec7943e3ff5640b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb801b6083baad99daa8ef067cbaa396436591c52f338cb89ecdf76ab9804c4b02ee9934df13205c483167edaaf446609e6420c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba801a87180e5349d3e6f9472bf19021fb38c8363b36d53feae8f57754e68676b2ba1ceb7680879981cb63fbf51c8f96323790d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f8901a5b8be704d75fba99633db0e207603eacf3fc51a77b15d3f73ce6b75de19dcce4b5a3ca86b247b1414cb13bfd21d67c80d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381018ed36f99ba583e180b66367374229462d8f7826abbff8c3422107d5c17a2c624bd3a154c0eae0e44f3f56d06b4da4d0e0d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f3000b10b6159372531cd813094527b17eef8a077d4300503c6fc147e07abb40ed05a32fcfdd166e91d1c54a388d0d0f5df4f00000072da33f586cdd86a566cb30268f411dad855dc3fd18c5669410c7cdaea0000000072da33f586cdd86a566cb30268f411dad855dc3fd18c5669410c7cdaea00fc00110a60192012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a2000e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113000d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c000c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb000d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f3000203971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be13971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be1000d39322e36332e3137362e32303261c274080f47a95be5372ef8c69bb60ab1d4ca82fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a000e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef436000d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb000c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e52863320966000e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf7019000d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e000c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be824000d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d678918000e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f000b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f234000d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e0815000c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc4000c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c0000c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df54000d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba092096000c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f000b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8000c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8000d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381000d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9000d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f30008363bb90232bac7a56c8a751b0e92029974d09eb0d894ddfa56e2cead1d7204e820692844e3ddbe248f477633e0c903b000000e5d8948d2c695de557f1327a8f323fe00ea463ab53d415589456cae54300000000e5d8948d2c695de557f1327a8f323fe00ea463ab53d415589456cae54300fc00110a48192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea801969e860529b2ff3468eb673067a839e89cb70cd1d945192b91965bd36d5d3fa4fe504619892c15f98225e79a3a7d47090d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f1130184cd37a5e9a78f8b1dd5642869b38051aeb448e0fd7f1d3848e33d649fc4631d4d49ff0931a050d59790bd0531f397200d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb018deb2b0dff4093f71fbafc7bae4b29b17ea30485ece48b32470952f9126356b873514122831c2951e7a3abb6f9a81bbe0d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f3000203971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be13971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be101a5f030ce39676a17427193f0ca4cc9ee43a4f902e107773cfa1e540b26cad7f267e8c3079b8cdf4c0add74a2e84dcea30d39322e36332e3137362e32303261c274080f47a95be5372ef8c69bb60ab1d4ca82fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a018ebbe8af7fc4642314003a46929b4099c64842f64f9e69e6da327632aba34d40b35aea294ee5cb61d3d9acdaae8cd38b0e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301a63effa991db7f60139f66d7ce6d9b009b50415bea8a473e308d23b984e95c16e65dd19080c9dd203f0ff7a73a5946540d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf7019018227fa4a5a3770831ee93c7f52edb284567beaf78c37ae47c6731589cafe50efd98478cb2b078310199b36b08a8c3e670d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e01aefc5fd6504acb6801a3531e8ca8c42a57c9891f61a505114dec9f0607aaa15ac5f1ab94f5b46c3bff9b12a31ee82b7b0c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42900185d05de36a1b5ed656048a64569cf42a5807ce65c29a91c2b3a00f8bf9bdabe99715d3d62b8aab75b7173fcb36862abd0d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82401a7c71dc1a14889412cd99e7c2714560d81fc63ec74ce9e6aff290503d28e4283fa41c09f7f33a0fa039cfdfeac4e71d70d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891801a858472dffbc0aabf6e25b30037d38a71a563359fce61c7f8636e15c16ed7373fef2ce7e476761c6c8f5c8d945fd976b0e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f018b0b6b19ffd7b384cc664de9d04e0bc65d75374df2ae888489812b122294904372b8df973d58795578e2f960692b46650b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f23401844d1bba28048dd41472b1c2b663cc37dbbe7633ce65d6d514a99b13234760ed0df5644596438d4ac52570742bcb564d0d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e081501a04e60f14500bec7d0a9dd2800de360694d7557767791090c96a271e854f74ec3cb9b6f77bf73a8ac6a8385b14f684850c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc401b122c5d8c54ed1f6697988003e6cf37ab70b25bd700e3c5217d85f56af1454b9e03a3ebf8882af455650e1ec1cf6e02f0c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c001b5a22609f0513b65e2157a13109628f1b5a58802347518e7b16edc63d7f555e9218c437b67cef2f5c2e0852fa39f2ead0c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f01b52c68fe953aa91acadea41238e533cf63e0fe775d9bfad8cf300d746517e9141e1e09ed9470f50f599fc3726108a3a80d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d0190d6d5f5e92a3cf42953447fc2993da64507785ab28e8d800f24a203759ec184ecb4581bf4bc797265d159db56ad21130c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba092096018ce455a85113cbb3f226996c42cffe8ec3c18879e7f3351844b36bd6f455d092f26e1593c67847077b794e9b9338df500c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c018bde4bc57ed1376b3c1ea5cbfa427aa4e7f5458d3bb7bbcdd3edf5ff1316d636082ecf6adf8d91a6b1f294743e09e0e40c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421601b5c487a28336e7e237dc06a260855ccadac81c0befca82d851f59a62dd037dbf4245a9c8d3851993c39b831a4ae41e800d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb801b1538d4316211a05c7e88931ab8c9ac68bf59f3a157be38c7c59db2e0edd27ab4acf632546aaaf74da4c3c52da02c3a90c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba801a042172d66535219d6616449610f3257ea2a1661ab700ad8e242f56e708fdd4328005f7a256e90c48b58660d73c895e20d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba786399038101b1897a9037794f448cb3d65fcfe458a68af52b1193075b21f5c54ceb480b50aacafc12c705ecbeab07655a5db52344920d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac901ac6b9425d33076bd863a8331058733b29ec6da69d70936e7af23576e747971d7e1f54ecbcbe92e70cc9a4ea725d9bffa0d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f3000b9b745e239b0131f2ae8386bf2512c0548e499cbcb27d722b29982c464f3f4854dffd934fc633ca893a8b20b76b4b5cd0000000b8cd4ead1ee12d25126921d918020cd77745d9cce5b59f7287a2a296e000000000b8cd4ead1ee12d25126921d918020cd77745d9cce5b59f7287a2a296e00fc00110a301920143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f11301804fb84c41e4ef70fa136be9e1b4a1de7509d51d4f4f48ad0be8b6689cfb888b3376611201c88f8d2ff4b8bbc8859ab10d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c01966937f030398b1e57153a449a48f5a8cc4b17782b4553075050498ed6acae479e1b8f053ba7fea2dcdb8511b01cc8330c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb01a0e490268a9ac6f614abda6d2c9773f78027df23205e51319d26e4a59e6226dbd2d44dadf21a7fc2af9bfa4491436e0e0d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a0188e19fb0f79180331d93d2e1a9bd84a2b35505cc72aefef50d427196df3025478cf19f15478dc4f8e36379a2c762946d0e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301995b7089c977df3b5855d481b20dddfc3a203a0b28c0d899929948e3c634138d0d6e4166b95a62bf2aeb7bfb77b33b430d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef43601a8cddde49c1a90c2977def8b0cb06bf1f1545163c01accb8d5b489c6a57b86da38fe13ad211315efb16065d049edb6d90d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb01a979e9907653676d99ad236d9d7ad7f1caa7b8c145a631e86e9a3c7f217bf1af6c96f591860661775bd0703bad1be8c50c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e5286332096601b2af25880010cc44b694bfd03af48b1d67d1c8f7799aba3803537d66bad445b5a9ade42f1a169d82e29ec29d5b509e670e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70190197d6313c96e3d4a72866547f8b6946b0b16027404c3941645533649fab02ce8c68c1b1fe153ebfc450ac4f0c197de8220d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e01985bda42120b76d3118d53f76ff49f8f1056a6d9044c165498acd2449afcf0f04928090aacce43f95bb1130f1774c2a10c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be4290018c99f0600654d103f2cc2e8afd413f92ce0b1703e4b2695e441ea6ca41c04aa02b17a417f537c3738fc2d55c9d7c465c0d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82401b3ebfc2a01c5e5f81e5b751db91cbbb2dd28a8125221d91c7cabe348abea7140ba157311cb0706e8b2a021ca4b9df7980d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f01a9a7425ddeee5373c8dc48863d1c7a9abd856a95d26f4146dd818c0b8d8e7669d4a35837b83e1fc1c32ed951dcd179350b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f23401b98ebc6724479085f5da42cb91861d1449a3ca648d955751f5c3b91b096a840f092676c348f2f00b5039481dca12b9630d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e081501a61f28db421160121dfc7c0fb707c0a28d7ee8bbf0f3ae522029783af248144b8ff12015083e6cc7f7dcf42c0f7455710c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc401b2cad9ab34e5a8d11dc038e34918476731a014a4d250e087c0231690acce6eb1dc5aee354356f83eb0171f5269c9b8820c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c00183bdc72d5ba2383a5fcd5b3f69df233b38363c98a191de6ab39375b6a88b529a150a314d448714ea7908433c9bf2cfd90c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df5401a13129fdef659fc1d53aeebb283e3dfaf398ded529cd03046faa4452c09f0dd3b9507c128a8fff1379f41f6dc3f3dca40d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209601a02732ceeb00cbc22c6a3513e33364fbbe668f9b18d6d179a0ae8a624e54d6e70313ee5d114f4a90934c558046d7778b0c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c01b8b9bde8dd4ada170f591c79c7799b3a3110da70e66a5d9bd958c0ee09aa9318b66a51b6e848f9d89ebdc95aa03f98890c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f01b066eb4def83361ffc67185aa1e0d731674c29b63f6094195e51fcd538ea20d92dd4a8d565fa5a4952d7003a6dc6ae860b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421601a6e8c59c8ca50f24d6ba38e9c2170eb7e7ecb218025bf5b872e7757127dff5e358f8996cedeffb73183d75e0da1ce2a80d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb801b02657330749afaba1d7f537a8d7a2f7f5d769dfeb35c611997de1fde5aeee25a2b36cd5b29658a99bfa26ac11295ef10c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba80196b913b9291edf58bd3dcaa9d4ca9a22cbcfdb8aa5ca6e3f0be4b9c84f251ab1a4dedc2eb735aab46559e71d81d34d580d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f890185fc1d0b5171e799df05263801d116cb5091e8b61a6dedaeb7d555acc70faebf8888c32892877db163f92fb3d37697510d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300098dbb9b35974480142186275c072950c403c009244f48be412f76d3fdbbb079126b9a3e2d9902d74fb3fcf571179c8ba0000013b5860da205d4132c60deedcd2f06f18c77718fc9f96a5473d05e596fa000000013b5860da205d4132c60deedcd2f06f18c77718fc9f96a5473d05e596fa00fc00110a18192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea801aefbe4d19c74f3038be0d800cecadf43701500341a07b66c54780eff1d919af02df5981f40298d42d71a21203f5861830d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c01a6318708e3cf020d9a4d6acc99290e20852673b3fd56111a41f768d62c774cf7634621e292811aadacba01405ee0dd4c0c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000203971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be13971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be101932daaeb7b3d00c345c7928cf668dd5b93f00c8ae932c3b02ec60a32f3bc70a06d54de27ebcd7d754ba8ab457d4220fe0d39322e36332e3137362e32303261c274080f47a95be5372ef8c69bb60ab1d4ca82fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a01b6dc1e01c3c5adf1c45d2ffdc8b3e2bb191ddc96155093c44d2ea4dbf825a1b58c2a9b2f352ea9bfb82069224dfc12a20e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d01aacc0b07512ca510f795d08610bb19b86765fab3ebe38247bc66894bb487873517751be72d6623aa4c6f0de8b9fb86300c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301b2386d3b8287a94917087b2214107fb7604a296aaa68ad405c267cfe0ac50254edc13916213526c93ae969da3e2e19dd0d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4360189a560690e28c68c6503d32257037db0901e0e7e58e2a49502f27ef146faf9785c3a6d0d7a83f51f54e8a416b8fc5d5a0d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb018123b9c30ea0afee794b67b78633b351d4e8a6861f9089db1eddaea2063052b4b8e6fe6d7aa8adaa8d14daee571921190c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e52863320966018784b66c8bacc5e407ba4388af1ce9634c0c65fae5ccb415d99622e2568fddd81860551836c6857651b7e68bf777051e0e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70190188ca8aaf57cc7e2af48b2036bc3ce08b729115792ddd891d748809feb5131a78834a444d4bf5d682372030bdef0aeef60d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be4290018a1844847acbbd40ed0102cf8978803b46626cf1ff053d3962dc017bcf9274ac64016269ed9c4cbaaea230cd582ce7c10d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891801b2bb87347b1d029ee08969d8b183be7cb5bb7030333e7b1ebc590ef95bbdea0060106943d82fe1287e66b0a6ea9fbda70e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f01902b68a0d6aaaa88f5448e7847aa844ca290312883ccc45d513b6f55c186a66b430d9be46a39b36d65968f35e21672c50b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f23401b02ec92b3976b32d0fe09a82c478f9ad352a176b4af5c95c14021a39068e8e0f0ee3a9665a7347dadcc5495a6c54be830d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc401a8b4baf7a0ad0776ad239d4795d86e25d77a4f59d054ed7c4dcc31f97ded0485e6a0b1475d744f20b491438d2e53937f0c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c001a220d7da059c4f6129c623b728dd3f59f9e12f4d6cb81a7291ed72323f48906c411cf04b926906323e4fcf9c64a7afa20c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d0190dc1560bf0fee4e480e85565e796ba90608bcdc82c5be50a17a0276126b3011c0b05c53d5b57971677ee6dc4065e2620c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df5401a280d0efc97a9f5877d4d5d26842c2b1eb5a972f6721ad04f59379ceeee8eea2279b41c55b2d91f326d1a081e2308b2c0d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209601ae50333bb9c084b8235209009bc79e95ac93ea7e720f645f40210985cacb95d938359f1c2054c54f8ffecc46b46c72520c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c01902df93b14e13fa8c2bc56f8dd885933e7664a040742e9db1944c022a362f1f59bf392c8f2b619b6aa902751a0d97eb60c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f01b846359de05b4e141f1bf41c6f11a74858fead3a20c0b197f25eb081056520000a8e5f665d2504b0c3722d07fe9d48390b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb801b64ffd3afa423be6e3c703eba0a16b25c86ec60e391d005bf47a73d33c66bcf7d0b2172d0f55041ee8d7869f7c6f352c0c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f8901a6314c087034d4edfdb09dee1471a52b7906905da4510346d1a4c932c40174a753d2658cdbc734b83430d9a19fde876b0d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba786399038101a3c22f17c427c3f66373ab1eada7d9288fcb81114eaed49edd48647aada20c6d439f2d603cc9f4d00e92cbe844f432910d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac901b5ea66b9c53fbbe4159192277264bfec6873a97e5c585a7adf5a62cbae4481aceface1dff0868ea001ed514810a75fe60d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f300082d71ec73b651ee1603038edce0b1b453e6cdf03a7c5dae542ecfa36e8e646ad5f8b2c6fd2947ebf3504a1e9aa36a31100000050b5530a426cc3a37ae64b7e37879c0905cd90391226fd7395a19cad2b0000000050b5530a426cc3a37ae64b7e37879c0905cd90391226fd7395a19cad2b00fc00110a00192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea8000d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a2000e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113000d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c000c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb000d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d000c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef436000d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb000c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e52863320966000e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e000c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be4290000d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be824000d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d678918000e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f000b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f234000d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e0815000c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc4000c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f000d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df54000d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba092096000c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c000c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8000c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8000d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89000d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381000d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f30009115ebe490480078d6ed0b6cbb6b14a67e8c87a481a9b899ad9b69df05b58319a845f03c8b12333714e40cd371e8678400000029787a10cbbd05260d3c7a8114746b568d0a5fbd2fdb9f080ac12c5acd0000000029787a10cbbd05260d3c7a8114746b568d0a5fbd2fdb9f080ac12c5acd00fc001109e8192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea801970d7b81b480412fc43ea1f788843b1d09f0dc907586b3e260b050c7644f6d41fb27b1a42c480e34004c32c09977e93f0d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a201a820e13b8769adac09e564cd1cb18bc063cfcf3924f15636b0760c4f5b0fe84cf2fb570335b9f5a480e175a1d3bf271c0e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f1130198a0e5d3895c330ff366206535e6868f2b68d9a187883d14a20d439471981e61b208ab0e8a3550b3a9b896864e2e97630d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c01a5873d03f1d4625d480393ef389ef41c6c64d996285ffa796cc08208824d35dccf69f861d6adc1692fb714c09031a02b0c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb01b202608dae582e081fddaf3e2a6a79cb3f843fb9af4edcc5c5ca173c3802851be056b863ca2e7f754d6ebd7273dce89c0d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f3000203971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be13971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be1018292b344b60fc7e2a7039a8d36fad7680caa319305f1a48bf517c70d669145757311e299990b96f2a1725d8d15122c210d39322e36332e3137362e32303261c274080f47a95be5372ef8c69bb60ab1d4ca82fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d018022bb20ab0892ac7fceddccffafed851a6b99462fe1fbc8ed302eb13dcd34104e8b640d6863e22b3c0334c65bb1353d0c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301a8d80210f5a8421b7d0e7aefb73de90996043824f763ba7ba2f2bccf65fe2692a843be92a6c948e3ec379cc4873ab8620d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef436018b71e75c86b6dbe16c8d77b58c54c3046b879c9b2870ad5978bd66822a5495c088be770cbaa7b07606e4bea48f1d57520d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701901a5db974fcc27c6e6659be41f6e60cda5595e476219e92f1a42891a2129efa57e7168cb1ed7e910567b28b50f49ec89580d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e018a0faa9aa37cb733914dcb2f0238e7ecd1cc6e1bca84ea82f40f56ac676cfbfdddfebb17145fd119724acbac6526925d0c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be429001a43cce1d88a28cce331807a9d82ebb836e179712045ecb44f4d9e30e3dadd1fd56eb794e1ff4b77f6389cf070ab4335e0d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82401ac38307fb06ab201fad2e7d995746ca822aa65b3efacdb2944840dc49cae820ef8cda959b3022fa5825aa6c185b2d2e80d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f01b0a830cc01b28f5268aae63f37e8edee59c0cf638e56add0f8fc6a63fa67754d550acb8c1844fe49dd969384b3e47d4d0b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f23401897c23a6f47c9459e7c374ab0fa826f27a035794b8aeb965fd6ee02bac15546e4c74b4dc878f9aeca6811ee30376479a0d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e081501923d83d963dcad047de4b636c1002972099365c6ca34d86b2b0c4d9d5f1e3c76a82a4775b6973933f08b4efca67c39140c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc401acf9fca5575dd9432d04bf48208d4d6233327efd892d7dc8a19c221875b19150e386e59c596a26f805c51b782266ed2d0c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c0019656eb5ec24456fafd42a36eaaa7777a1a07126cdba616f306f5922962edb86c84eb63eb1c4fe73b77c2c125c03e0e8a0c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f018458cd94f39953a2cbe980f26296dbc935f5bfa0c51840267d34529a14c40a62dbbcde39372748c0c555169d692852dd0d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df5401b8986d8ccb4735db954e68d32a0d544778f631523e347b673ec19f522241a4a78e842d21e3dbafaf7c1dde9b7a87af610d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c01a4922f49f620b1db38fa2ee28facca3aa818e29858e47d8afa467f1f6e78512f7f81b09ec5debc0d6ba820c5afcf730a0c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f01b0bd0eaedab09436d694b6fbfd5d7ff130d10a5b0793363383556d4d4e203892d50c6d7ff5fd418c113e46dd03e680f90b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e2542160196b15178f4a27b4e2c957fba6321c9e0c6a52cc181b78bdff133af13378578429140857bcd7bef984123d4a0c1bb0a0f0d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f8901a92fbcf877ae8f1126dd2000c14f94e984b0b8417ef08a5d41e8e4f25b1c4345d604ea4d5628cb3b465c0f133c1680ea0d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba78639903810180cf4159f981ea771039b37a355c87b1b63d08f5ca1fe187b43dab3d69aba34c296486fbe95169d4e86aff8e5b7d4ec10d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f3000b9cbddb5cb09af2419de553627792b168d70fec7f4b86455fad63931bd68cef1eb7aee5d8b52e592167c2b5e2b7778b4000000ca47540e3e2bbbfc91ad3581df6b5f730ea457841a3544e2ab3c54c24500000000ca47540e3e2bbbfc91ad3581df6b5f730ea457841a3544e2ab3c54c24500fc001109d0192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea801b8b06499c583a0fd22b6891f1b2fbc982c65889f34a41303a4e6add3335e6f03de51013907906849ae0606f4642546e90d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a201a74f5ce985df2786c2aff01e9030ac94d60a087d9bb7e67f6ed82fd2bfdec5ffa365fa0234cc36cffe48ed7a891566f40e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f1130189c4a5d69af324ffe22e0c8d9b8b0dd4ebcc23a8947dbefa423dd21d6bca38d83903018bd19233fdf82db3cf58b121120d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c01a97a7c20f8e962e0f42eb82a8574a40d592a6c045e2d0dd022d30ae7580f63121f1b127de8c8fdbc0a09be310be140630c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb0195b29cd5c1260dad12e00db7df6264adf1e129db92db275c512024ef882d525bc76aae7b91e98cc50f02b467b729a4230d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f3000203971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be13971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be101b36395d295eb39ab7a37a6dbae201d69783252554528616a2cd694ece2bcfa1c228bfbe9f11189e58464f1f818222cb80d39322e36332e3137362e32303261c274080f47a95be5372ef8c69bb60ab1d4ca82fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a01a5c5eb179bcfa04fff58a455c31a4434d2956ee64992ad90fa984e22bb0271349b34ed391adb5d14e92fe4e909e66fed0e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d01990581eeaa1de281b5b427562103f13d36926683d2fd547c9594ef7814b4eae5d1873a8935db2014270fbf6a8324a0650c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a230192859d855e078b0d51bb59700c2f97084b7b9cb756877df99999a141599e2398a1d801ba447e87243666bfccda43b3a80d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef43601a517a483d86831f719bea10f0fd570a991d4d31f842eacdb7bcedd2b4574832c8c9f8faffdf3dd5855b958fab30f28ea0d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb018d6b47b552e835caf543b4e12228069e2b017e9697e9a53769477a17f911ebb6d60902335c80dbc5f8a3f1fddb901a2d0c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82401959e4b96408015ba5f09b91b6075879d793c8e23ac87c8c7bfb488570359603a5555912d439396eff96196a8a48509350d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891801b48413f0072f49e797ac6d1e24416a891a045f9381882ee222801da1872c6edc1f96b10d5fc1e35ac986dabbe1a6bebb0e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f0180b9a527a7102ef8fa92958d687466a5e660408c19aa20631b5ba92e6ad6c05ce0756df6fb5ddef9f3541096b1a507c60b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2340196224eff9b71fa242635fc530e66dc5a352d930491a7f6835420101c3f5f9ded42b8b81342d46430e7cc2a7d2c6118640d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c0018b083dafad8abb0439badd1bee47c8c40ff94d9b0cb3a170e80b79d7291eff897897984cb854f731777298d9a4c53ff70c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f0199ec50553765cb873f210513dc1f50cf370711af9283042cfa0047b50de960c54343213a10f86443605e72c8158fbdbe0d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d019418730d55f9813b944c857e73544681bfb28cfb0cb8f80cc6853b060ce980d5124c451302681fd64507973dafd4fe050c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df54019373b16af5c5922151307961ff6ba2932577a762412ddcecd8ea5e9d9de353687517a99179641a64867412dfa02b30e50d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209601aa42f5cc6c6b0b157ebbccb51c179e6da1f657aa975cfe316bba65bb795d27c1a36fc89f277310e10d648b4eb2f3a4d70c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f01b9b68ea1d8c99b7cf1241fe98bbb671d4503b181af78d2cdd3b6c26717c5bbcc0f9977fd5e1ba2a89681f2c7193b30590b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb801b9b9b9d80cac56a2354054847aad75cac16f3e004983c4287887ce67fe9151dc85ca64efced2acbb2fe1249edb97aeaa0c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89018c5fe2277f8f09c710ebc292b57abae1db9fb98a55db37c6d84d22d28616b0241a136a89addfbcf6d40a7cca5fbeb7020d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba786399038101b29a3615c31170fc5065b8c97c12db5f6dc30a6f7d3d851f7e8b5794dd4868b72eac1cf8e0938af1818f36eccf96b7560d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac901a7219c2a26bf3628b8dad42325c9e2d03dd265015c2552990081ac3461f49b1ffc0e89f32fe01155655b12f2e5a2869f0d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f3000b16ea424860dc0726c5e7215e1e982a42eab9330137b9fc25cb52f631237c875a75c2f1f601750686e417f0ccbdf3981000000e7654d577ec30cf6779bb7f025807118c9ee33113ea249fa1ce949064600000000e7654d577ec30cf6779bb7f025807118c9ee33113ea249fa1ce949064600fc001109b8192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea8018b962de6fb2b78ecd4a0d38a1e6599629e2f2ee7cf9bf120d2a42a5187f6b7bff3ad999d489ad01402952e13a7b2a0cd0d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a2018f075ac06941ccf4426e74cca625cba70aa51383684e5b2ca68a5969980c577692a2a4fc04eaf6d75e06d46d47789d8a0e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f1130194ef996c8d9e5d050b0eb315c2953b3e7a6a2c0c814a4f091b0a899758193809d59932a177bb4bfe3612795c1cb1af180d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c01b5c4608e61eec256009dced5e14f32abea62323bf9afc6bd3aa94775a69deffb4fbe7ced991719ae42f0464143739c050c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb01af4e360b85ba0e07ff4daf222828646b8553d34e13d27e0c0ab73b8d0819a7de542c8b75b908f2a522783805e98161ed0d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f3000203971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be13971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be101b3c583538cd672a8811fd6ad676f0ab86fb20142cde7318f6821ab80c747d667e65aac29cad1642220484b528e2b97a60d39322e36332e3137362e32303261c274080f47a95be5372ef8c69bb60ab1d4ca82fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a018fa018aa37212ef01b6736ed5642f2e72bee1de375bfa8b8b670d3f91c6740d603d4d28712b4bf20a9823816dc0395220e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d01864d618197d9c45ce9466461c76b2a7706c7651d52fd0a9c66dacea54359b82788580f51c44144d13d03924a2f231a6b0c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301b7e90c414091b2b3fc3167cdf880027601fa23caacd4d806e561dd60368f4926fbf2794ed7256d2b9cae61cdd37cf61a0d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb018062ad18e48955d3c60465639795e5eb5d06a307710278c033336338e1f165bb3f38d8193b331e7b8e5c7174f1bcc3290c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e5286332096601a3c4dc99f61b79db373f2cbb31282dab6c9f1e061d3ae149f292e7d2a57867af64dbaff63d8209eb2eae7bc4d19f18ba0e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701901b0d3a176e29c34f594cd740859a21fdeddea237d66b706439b745b64da4bc910a6454a6c24766007bef5fddc60025aa00d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e018f9b3c93f75c54aaa7e94af920af8d570dbeccc8f03976a95aa6cd4956c57c4320ff54d3b9a6383801d78f3e89e842880c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d6789180198bacabb7caa139502f082638a2c5557402755a734420a4170e0625ba4cc6a90236624023c697478134010ecf2a024710e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f018f176c317a778eb340cbff32a482253eccade757f6be7ce3264efb3cc6bae9a49f44ac1634dbd916280d1f935f4da87c0b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e0815019861cc2ef8a3969143f1b32a715a6e10c3c2d7ba46cb7bc54e4e8101f08b85589f3ad825896c5b21e5d608d9200496840c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc401a45b1a6bffa54f659e58329868160e6e4503756ebffe1cc7bba724987832f81811883638133ef1b55a877a0650e6c4d10c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c00185ae9000f50f53adb25405b339df3a86c180a2312ba857d94c077e474a3a577e3dc4eb53a0cd2b1b1e880383d3680af80c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f01a8534f9a11dda86ea001342d7166778b70849462281cf7a5f92bcb82044900b5abb42f7301ff900e62915898bf8835710d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d01b080fa15ef37262f5c499bdf9c9487a0e8f3419c3a809aa794af4cae7cde22052eb8323559da812edce33431f0d826020c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209601add41989d620cc7df4eafbc7b268d334953c1e8ba5608f454c9d0a427b58721950c46f79c0b22038b12eebc7e6ec83100c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f01872c5ed02a4b12f4131bd64f4c59271102507c9a96dbd531b35cf3c1d10b285b8edb0dc6d6f641c5868f1ec065ab08050b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421601b0c7d63093cb1972c8aa94c78045cff4973d79ae141365aa6392aba6939d7cf6f5a7395fc57ac6045781acaae05f67cd0d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba80192ae2a2792e73608a20d7b12888d2582d6647b43eb8ee8f61e09e9520732dfdd7160dfe5c6f3386a32955171b59e9b230d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac90186abcf53a568276f5dace92dbdaf038d5f959742360527941a2e3b320334bff61c9e36af902b6332e667d54b4e43f20f0d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f30008624b652c48f38d61cda305260bff8d679d8d4194d3f94263f4be2b109b459fd257d09b21daea3ce5d607f5cf329fcc0000001d6bd1fcac1f64325a6a26b0a3a02d1e3b61267d50f855984a873c3d68900000001d6bd1fcac1f64325a6a26b0a3a02d1e3b61267d50f855984a873c3d68900fc001109a0192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea801801d1caeb0249874c51e6aef9c319b3260af3a7f4abd77e44f7f2794be2b1f1211ac2e06d951dc1102541944767bf70b0d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a2018959077c75d865f18eb0e6da55e1685c071b16b2ebc6ae717d9ecb15c40783a22cfc80283ec15b1b58d011f5d211de470e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f11301964add28e4e033a83073203713210ba9451300e370901e24c64c170c9c714df36bcdfee02c6358c7e9348cc2193c1c790d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb018dd74a742631dd039ae8b11e2f3f2f1fc2503ba590ee5487a9af71d4713c0b7df9c91e730f246c5b012d682623bfe5980d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f3000203971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be13971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be101839b06bd3faa0249a1de9e490de0ae9b1f687f01748000720b6181271185e83deb5ee39085aacb7a19164e2c7995b9510d39322e36332e3137362e32303261c274080f47a95be5372ef8c69bb60ab1d4ca82fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a018ad035bbe534c684bcc4edd241a3ae3710ff2484e4cbfdd7e2778574a4a10a038716232d4645f6a0986116156930da2d0e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d01a48d35c8976bdb0d6feaed8a7fafecd6c9790eca8cc5a1e576e1ab1081caaddc5d35dbed22462b065da699d9796470030c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a23019761664a2d48424101e4d22d0ddb7bf68a1a51d10278418bfa86125eddbf53a73116d8e11d35fc56dcdf7dd1cbc198340d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef436019444afcc0ef76d51219a693687d3373ae2d63cf0f2982ac364cde53ea5f3f4aad1abd2e9236848dd229fcc7bd461f4e70d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb018f6f64001871f148e8f2befa5562d682e5ea35b15d651c1e5632a9ec007897ae1accdb7c771935efaadb053584f0f0ec0c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e5286332096601b2bdf73ed77b5ee1eba76d9597269b9acb54c53483f48d8a96724a8d41c77a7b54853ef41561c95823ae001fe226cd070e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701901ac23ec29fa032506a8a1f534c0dbbfe234ab8c4a2492c6513a7a0cf8b9ba8ee80c2b8677acbe1005e9552608eef4c74f0d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e01a806786c7e246db9861c45ddbc16849415da9abbca80b2a92f07aa09b19c258598c62dce654153b5815b50ce21506e970c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be8240191096939bbbc3b696e76a7def9734e8afd250c49b307930f2be484a5cfb353cfb08aee953809cfa8e25138c9230bece70d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891801a64af69f8174bf8a7f8398cba7e349b62b2fd2ecf61446a10a16a9e71cd67c8f2eb725d4cbd1c2081a5200cc2016e74a0e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f018e7b3b55424d3b06d8aa1c4ca3af5de96b8af54adb860d22f6b857cf836038ef9b711dc3a1c47cb0f0bd31e553904de50b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f234018d003529801f709ead3ed646f86e29eefd3563fd10eb48c5814929970e48691da65986d9d798cb084b085327e3e2210e0d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e081501b5d56dbd660b42d9c79be5d94912c86001c7c0118508e90ea71113f81b7ef412a56ed53bf635f8463495db374ad105b20c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc40191557309e257281d2910e7914b80bb4cfa78a74530d8c0a54b088ca244380e3f248f95e3d716b2e8043d0e74d3c362460c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c001874f7d242343c8a96748110a12dbb246a3fcc772e25e1ad6a7dcae333ae99c205c9a85ef73441097f8b88ff2253bdb680c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d018bc0894362a31bb574775fb54873f6f4b231df32e8142bc2f18839bfb54422df8f6295590fc51fab1c27040c2b34b51a0c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df54018ccc32d24ef5626ddcd2b28e9736617e4674fe9108af2a67f3ab4d88857d8e932cad9abe7f37a81cb42e00b5a23924c20d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421601b12d38eb7f5de9b145b9f9e14e97e0e624ff91e61c9ef66e50366df4439e1f5936494e12b4216352919679e4d759c0e00d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8018654755a932cc93d963a2d802cabae33db99828405fe03a3838f73a05ae88c0733f9170f77f92b66d3291d7c8675dc6b0d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba78639903810184980eccb0d1103b2ca52e2180e96c26b287ff0dbe1038e495bb6e77bfe339a5890f7d3c10c40aa756c72c1349dd27be0d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300087087556f670d7bc712e350d4b5afbf9ef0224447ac207a2ee76e040c468605d8b9cabbabe620278d01a8da30ee7026b000000b6ebee5a8f801f7b66c32a3454b12513c76ab58b121a4e9c579bcd4e8c00000000b6ebee5a8f801f7b66c32a3454b12513c76ab58b121a4e9c579bcd4e8c00fc00110988192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea801a703c06bb0c06e1af4dc7396d1f19f8959c5a56e99717647a91b65cc8aa543fd700b7ec561e3050ef9e868104f3c6b790d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a201a324d275351dad7c90e3a9a94f6efbd8ea6b865f34a09a20fb82ed55134c45982f798e26a4e80e1fb0a8c50813b86d280e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f11301ad5a967b04be6266f12c245cb62edb02873a37f72d2de496d8d1f1cc92905786be7aa7c24c7941ca80b11675f44fd48f0d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c018aa08b567a66acb8356e54f688575350edd7f2d9efa7e1c9a3897011f83caa03a7deac4146592b8ca527263332e4d0840c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb01ac508c0feb7d9b38e641298a71e6f10f3a8a30fa42c01856b6cfded1b452d802b6196e4b66602ea8cfafae03a37e57a00d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d01940b0a12e79c9c2b8889e6cf84f1d2c64277587471a8eecd7abec19c9f9a558791199c8fc6f07abd9b0459527e9625fd0c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301b32376df0aa47f5bc41d383d00ba171eae10e87eb5dec1ffa8cb498dacdf98462e3f562e8c4901acde83da95d0d454780d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef43601a50f2b1af92150d81387393503c15a485518b8375578b721e52bd84b1124e9a265e985681eb76e15c6a478d5b529f5ed0d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb01b4c6e2f51056f17dc3cce763ea819a77770edc7122c39e68a0d8629ea8f36937468761952d9fca90a7c2c7f78f8b85770c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209660180266707faf18059f5040438724f9f46921d5f600dd837dc1aea1f08f3dc2a7d12247a3ca0feff3ebde6855e221503c30e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701901976e8ee23029edeaae45c1737a2ab7e440145fc145a2410aff4a0735335c6d73320c6dc5425449c00458fe214f10f0c70d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82401b311bf70f84c1332681af71fe6d684933be12807de50e6a3eed260d649891e3b409c75fff910381db43f5e5cc3eec96b0d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891801a57c0905911f436b83521d87ef76513c25e1c7177050b62ce038c0c485c7d7286b86822a1db20ee50e14c7bbca115e2f0e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f01b642e74f36ecfc0984377db6259e30010d61d4b4b309668af59718d570c8f9f253baa2ac00dc6041b12c79b77eb646af0b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f23401b5f63cf0be89e8e46af538e71e1a98d33173f83131572bff054c5fc3855fdd8f4d2359b91f164a082f65232960a6bb8b0d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e081501a201efcc30db8655f99be543485d749efaaf164e222370f9dd50a3ecb0a428a07a16f7d9f9d7be5182e0974f926405f20c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc401b54279aae2009b7651c29c87d6a00bace24b0112690401ac71c935ba79c637ebab1dd1b6c8e5dd70c002846b87c580430c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f018b55bd02dd900fc8f513373fc4275474e3c64f489463a2d167d93eb81cd6e41c54f06554d280ac71bd80b12f93c386e30d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d01b847c83b10bac91203bd0ffbdee778131803975467db2d0889defa1f4671ab9207d330e944772f7ac7b7b05c04b59d5c0c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c01a76f59dad02d335374150895bcda911a1c8f77fc49938a60fc913ac1b01dca06eaf67c34145efa68f02d8ed5aacf60980c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421601a510330a7be7301de1872e3fb864ce4a6d9e6faad494159a5a29476c7110dc8fa10921c63d3e93f4181845c7fabd2c7f0d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb801b29f367ac0aa1c4a047507c039c7b406ddd38256b55fcc636ed00badef8240e50905b96d810b2eefc2ff0a82d0434a5f0c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba801b04058eaf4d337cdc95914d77fbc9f22be1dadd3fce162bf4bf3f67372383b7cc287eef82634ba9f69182c9e615b83ce0d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba786399038101a190aad82d3d99b77ba2ec6019caa72e82575fb72cf05d9eb97ef0f8d3f088c7350fbeb19c8a13c95f7e68073ef64fb20d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9018d0c12f1fc8ee77846153c42e78d2e420358de9478058680d0c1019b33e65b1da765e8a369620e06145a573f46d5d6a70d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f3000a6ece569edd51a503a2cfe5b2be0e24c33179ee6f8afa152d185b19f87fccb8ce5ecff6300fc600bd0418b69dcc3f4f2000000e78672b7a792c03ffc5e06c6512e0ae64c4b5410a2e41b6b871036e5d300000000e78672b7a792c03ffc5e06c6512e0ae64c4b5410a2e41b6b871036e5d300fc00110970192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea8000d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a2000e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c000c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a000e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d000c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb000c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e52863320966000e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf7019000d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e000c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be4290000d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be824000d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d678918000e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f000b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f234000d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e0815000c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc4000c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c0000c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f000d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d000c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba092096000c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c000c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f000b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8000d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89000d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381000d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f3000952b5f1b8f31ad775ba1420d465e22b9db941245eacc8d738bee5b8e4704771d461a42949afe7e2ae91d49e795cf9ba200000021160aae5b92562c94a5d6735c5dff3a92aa0a8d9b02aa0c614ca7154a0000000021160aae5b92562c94a5d6735c5dff3a92aa0a8d9b02aa0c614ca7154a00fc00110958192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea8000d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a2000e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113000d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c000c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb000d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a000e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d000c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef436000d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb000c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e52863320966000e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be4290000d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f000b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f234000d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc4000c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c0000c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f000d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d000c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df54000d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f000b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216000d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8000c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8000d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89000d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381000d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9000d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f3000afe32c814088749bdf90012b78f156d0bea19ba06a56d4d6a22e80fbe9444d64c5b1545b55bb0f1c92fd79a1eae4e29d000001561ac909f7762f03b801661c0ab46943d603d2883b36535ad5f6344cb800000001561ac909f7762f03b801661c0ab46943d603d2883b36535ad5f6344cb800fc00110940192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea8000d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a2000e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113000d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb000d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a000e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d000c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef436000d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb000c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e52863320966000e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e000c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be4290000d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be824000d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f000b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f234000d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e0815000c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc4000c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c0000c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f000d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df54000d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba092096000c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f000b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8000c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8000d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89000d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381000d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f30008759c691df7b1ba670491acca647d6b73b22357fdd6bc666f9ff12e0b05386c9b448b2565acc758f8200037776704fd1000000c9c3825db4b9a1751e94ef41634a33e2df66e8f9ddcd56dd435232f48f00000000c9c3825db4b9a1751e94ef41634a33e2df66e8f9ddcd56dd435232f48f00fc00110928192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea801924ad656b10ed6bb91d0e3d628dcdb849ea66d25e377f2371bfd491c40e74788c859ad024da1d5cf4949834b7e79f2ee0d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a201aac9ede908775e57d5b1bce4b6b7fc2b1c50c8ac8353232620e979fb669b1af81690c2739bc60f35a8958764496946280e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f1130183ce4eb1e593141192a2453ca0ed4cfe462af4c2f564099e1defb49bc7febbb62b5f2dfd1e64e9a57e65354df6327d1c0d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c01adc8f74781a33cc6773cdce95d58a3c2cbe36a40c4f971987226a8027787d5ddf82bfb51dbd48023b5cfacb152029c970c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb01b5ac90f960f003df563d7d8dc350e26e218efbc993f9cb52a59290579da516e83a69b56dea7be3f0d29f6266b9caa2b50d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301aa742f3326d38b837ef98fb9736469642f166926f7961859c5d01dd49bfc66904b49edabf995b8e0a3b6389387614a2c0d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef43601976d7f5ed93385d48d42851930ed313180a8a9be816085db2763dfcc233c8cf07a78ce2f3e90a48ae48f3c6203f3766f0d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb0183dd7663c78d21bda4652a64bd714dc888a76b8e60da2d3cccb5530b73722ec81e67815668af7a71ed484347b60586320c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209660183bcb86817efb833569855c921422c2bf1b091def65d4ad85e19e668720c238bbfed72b10f46c2a4018acdf170007d080e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701901971f8a04797eaaa9b3b9dd3d693cd306521e1cf500952419a34b1977d086a3df182a700b02872dff3cb290a04208a9c50d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e0181b9ffd0d23314602ccc44eaaa8f2c40583963c2100106341900d1280850b4e84f7a31950c2279d43202348c3c857f330c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be429001acd93627366f7f42ef27d343f9c57a8db738e45db943c10fcd26f960a1a23a8ea25d4a3202a7ed7cc194b75f47d35c100d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891801b6c4b5c7ce4c90a8f2c49558894d88400f82cc709c639c0331ae0e576f37548d54bdad91e49445ec9e68881cb392e9220e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f0199419898f07b65df952ce60727b69493cae876e624d268710df77535afd899f6a02cdcba635b8ad3cc9842ae140e7fc90b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c00183d49c9014f9cf4a73ec9166c321ec4dffe9d7610ae2690141470fa2906dc8b8b0b65c38b881f4c87d5ba273a36476460c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d01a5b2b14324b75a8f03645434878fd9b78326125ca9a5479b3a63fc9c3e269f07e0914101476f0f7a81ce74db682df2330c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209601a910e926ae8a2a9ac7130053e40ff33f8a6b05f465619eaeea156550ef956c663797d5096f7db4eb1db5bf328ba963440c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c01ad328fa477cf797787c60fb91c2cb603896d04de19515bfa94fcf6dcd943a5dfe09f3341ca7ca0872cd8da59e68d72b10c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f01b123e19529c06f90a4c62c60fa86a64681ad3d93a0ada42ebc496f1643448819bed2a94b1ff5e5ff32ca3a9589fc37590b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421601a3e517adf8333dfc0ae60504cfaa02dc1387a5c2d59cbf8d9cf07a84bedbea0b0b40821152f18a17529e2bf1fece004c0d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb801b345c75d74bd26b8c95f30eb1e23a2a892b507269f5f5416faefd7f4ce9e721210246dc074f6b2a42129a1f8dce17dfc0c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba801a556c58a4ceca86bf6e7c7cec01ecea90d9ddabc76eaa64de7e15d71ec4463d0712ddb7fc27afcf9328348e9b4555d320d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f8901b97076e5170bae287a101f96a2a57c43d88d28f24c74eb3b5f19dbe8e9b0556abcaed75ff70b48f0a742afbdc32f368f0d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba786399038101b720e1f87cdd506feece2e0778a91d716671c7c7f19e766e5e13541074c9e053406f59816566cf4a67239d9e8101ff8d0d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac901875fe89958bd413087ee35b99293b326b5b505482a25a3bfab04e5ac59ee2c0687c01febceffc2cc50cab76bce3cad510d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f3000875f8e47eb3ef86e27ad3a5b0003289cdf445aed6ee7ab0f21c24e595c1f19fe9d969fdc6c5a6eeb66d712bf75846cf7000000b91e2a2fe9ab4c3899dc7d2d85c9e00e068603afe59058d5415a84773d00000000b91e2a2fe9ab4c3899dc7d2d85c9e00e068603afe59058d5415a84773d00fc00110910192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea8000d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a2000e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c000c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb000d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a000e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d000c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef436000d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb000c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e52863320966000e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e000c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be4290000d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d678918000e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f234000d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e0815000c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc4000c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c0000c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df54000d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba092096000c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c000c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f000b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216000d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8000c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8000d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89000d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381000d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f3000811c99ba6830312caf298444f81f4cf1007ddb18aafc86c3b07709355078e76b5c6dc4986f90e3ab4c49eb3277e8f058000000503099f9f7fc49ca9350ce1951c09325670b8b459f3a55ebe6811f13e100000000503099f9f7fc49ca9350ce1951c09325670b8b459f3a55ebe6811f13e100fc001108f8192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea801ade4f9ac0bf7a220bd7931db817cfe4a1948c980bda2b9fa47f388094c433ae05f4ca9336b866f1f0ad1df11d84d9aa40d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a201a0aae269176730e5448cb9f9ad9112e5d8ecf10e7cd60749573096bce1f92a8c54ab971b159b181b2e77d91f03a163420e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113018f158752c7ec2792ed365eb5452ffb7284baa0daaccabc0a373fe93e4437ac914e99fa3585ee13b2233ea957a7b875f30d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb01a61711a34d191e0c70f0f357c9ef6c12f0933031d2d5364ad77f2d2139232bba8450d3dd947923639669dbcb2cdc77000d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a0195fe0a1e5cec63ada905498014c403049ee0fac572b21ff7d9bfc64e0c58bfc04ec29aa4567fcaf9af431b8925d001e40e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d01b504e0534e88aeb51c3a3f7ca3d6668753ad6502218f173eee918767286822d99f4ee80bf7c07e717d2b107745d63fd70c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301a16d937e47da149a8c71d34c552c98585faafa99c2986397fc8455e45adf1573dd4535806a8a084b7fa34bbeea9253a80d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef43601a547a8172171c9ddaeae2eb272e92184a751a53d51476684342c06f6968c32dd9a23742df2e9194613934c5e58ef7e620d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb01a5374524f11f982d5bc082567c60fa9c1bc5be1510eeb42b0f6c2810c8e6da16e609603ce456f17df3636c5407ca5d160c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e5286332096601972f1c4070d037808f22be8a28ec2b12a4737a70d803498b39b9c1cd5f060a3c14b8682c484517e66b10f8a339e1f1900e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701901843e716b0c02fff03ab196cf7807890ea4135b104698007370fbaad68eda6926588a2252c8716fbcff2f2e18de92da4e0d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e01ace190d30463989a24b517945d94dc45894993e493cd32be40bc8b0d0946801af5be6ce4cd0bdf1189436bf085ed96df0c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be4290018a393458f5158095c5b380e1bc1a19ebc9060d6322422bcebf338382de0accb2d24783a33ad9f0bd06f0b522ce9b2dfa0d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82401868eea59f1f6748680f0513feec4c06fbc416c3a37a45494fc1a8aab3982c3c0dd206af2d6bdfd28f3f88be4fd3b2f080d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891801862184496a4ed2deea7ad130bca509f8ca0ebda660ab7b5189f3c40e8f3e62c665e0031ccc7bffdc32a5fb921a022e930e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f0197f08edddfd65e13651bf00b0f3485e2d81a477f45d9b46bdda40a416178cb0fb16199a2f8e969cfb37ed37c234a9cd20b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f23401a8e6429fd5e3e981383c03637e707d3b313fbc1606a8023a40e48bf071e45db9b451a3fd2760d28d75a43417e958e7830d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c001b2fad499c0eced2e83c79ea1c2b03ec399b2fb7411fe2a744979277b75d401b039dbcece4d9d3c0e035c339901d7a6330c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f01990f8dfc1e064ccb5c1dae252c390fc0ca792e730cada8ca1bd9a0b87a22bd08692827b19e614886125734d25bdbbb1c0d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d0182743c519fc81d9496a0b6b5dea3010daebd5d07e7819fdca3a7b9763c9cc96554f45243e4f3dd3bd550556630ea0e4c0c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c01a87c6b9f8d841bac3ad961c636f6112def93e8f1444da8ed44fb45eb8b8f76c64c4eb56f2d6a4c73bfc7bebbe388bff60c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba801821654a83db6fda5da7398f8caf30cec37f572cbb06ab2c16087b5a10f5bc02ecb9b577282b56be8efd15dd743d3a49a0d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f8901b95ef4d4f00f59a98abefd80d26838fa5e6ebbbf7f53708cea1e4bb5bc29b4db8df9a2b212915bce9c6c9243335695150d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba78639903810182799988066eb079178da860dea57e31e6908b1395b7ff048078d62c21a8c1a8d3356aaedfa3946054ef8803b04d82700d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac901b99743b53234d7c72f44f464edf915d5ede43f8864b8c5224c7b2ff1f3d3afe29ee1313bd1d24eb20ea9436fd59d0e5c0d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f3000b5da956497c5d4f39fca6f5b1c03f6c05992d1d654f226cf79019376aa64597614dd570190e16958718b9941acd718a10000004d43bd84ac6be16b9b7e352b3e9905e1337d7d4d6dd0b8a0ff92a89f1c000000004d43bd84ac6be16b9b7e352b3e9905e1337d7d4d6dd0b8a0ff92a89f1c00fc001108e01920143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113018b460fcb3cc7ee796175caa6f052d3bdc69e818d74112b2ab846c918669bf638c7ee40ed205995a29033acc18d59ddb80d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c01ae54bad16d671bc5c15961a2831600a97d2d45656a05d3ff23e1dfbca7b7ffaf3f6849b963d7c6da2207bc45f82149180c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a01a754aef784851c7b33edc0672fdc4acbbb5b68d18cc599d5ea0f90dc18f1d0f9b240852300bb4897a840c3ad75ad92720e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d01997667cb4a12ed8a163f798d3adb2ce58fd6893a43f6076aaa4361fb72252e0b199e4ec1ce8a5f7c28cd4569f22811760c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a23018f7f1b73f23c47a901bc0fcafee3390f1814082c6ba58fbe8ff3bfb2d8ae59e166b9bf4cafeb73ab84f8c92bf025d5680d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb01af907e5db8f2044c7439fcf769805a1cb6d6fe054dcc0143f1fc016887fa3e5d118d00ee3915a17232d4d3399fe72d5b0c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e5286332096601a09832716c65b1546e347932ef900e805a201ce2dcc0f63f9a4134f0f63e1f1a8fe21c73c8bb611f8be20e39534e083c0e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701901b08d9d26e9e4be1c5126efd8ddb59794fd773a02842acc3d3da4bac6c0c617e6d7252eb8b6cf39c31768046f428d2ce20d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e0197532b6be5b41d239a8645d8d64afb5cef699c098a67b4a9937821bc1dd20b5bdee4c1e426c5a7f8052eb3952190cfa70c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be429001ab556ce9c2e2700225559ec1959d45c83253cb296dce2b6b33cbfe9b874dbfe9dbe904fa2dcea902415fc1ecfc39474a0d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82401b54b2015b5e21346dbc940cc84bf51b4e6ff48dde45eee42fda6fd2e52ecb69a3a59583d4f07abcb116277878de85d590d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891801b07b9e19df45bab4886e1725af1ceb51c9ec8d6b7de345396996a5d541f0360fde8b4cd19e09c01fb82bf36460c9ce060e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e081501a2578e7fa88cdd15a5eaf6f627d5180fb2c5867b1a63435e6cc69087b219012d39fdd00bed9c975a4692ef5b55212ba20c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc40188f04eb6df9fd7339e63ceb4eebc70de145b4013dd6df67e22de136983e4065a5afe874be3352522a801c2c20a7f90cd0c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c00189ef74e90f14b3548986e55bf793a404f6c6c51d37ac118fe09f8869c71fd25aeba2f6c6951cf41fd5ca240907a760690c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f019796d4499f58876deedf4904e96de7c6f308aea15e7f1495db988e1dd70c5703fc3338127dd6fbaa638fd09d9a2495440d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d01a28553f210bcac6400cfae3cf36294b373acdd4d66b92bd30c0c7230f5cc080e6546eb961f6432e51e0d88d1449185f70c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df5401a04038f4955841d76aae11e2c4b51c4efbf4bbc4c5af0a6132d9d8d5134ea141ed2e791cff5056981015b9eb03f96d790d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209601a883d1e8398a8cf66ff2c695422b1caaaa7df58efc0637b38b48621c2e3357d25618b6e54335a311fba33c1a60fa8c540c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c01aab78e91fd352d70ed1c717c4d69726dc6cfeba4c6047040fb52cb0b6eb06aacba7c11e780f17e29da8886d5207d7d2d0c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f0192d3231b5c4ca6ad3957123950f519f38d5a03a65161eadfddbe218afc12a9845ada84209325149769949c8870a25d4a0b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e2542160183f05b849c08d76c2b699210c780112ef7ee1d76ae57cb216afc4a0a97ebe696e723f4c0f885a5329c8efd2727ee9f9f0d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb80186283e5e604d24192e21ce9a909afbc49045776ee5145aeccdedd7b52e4a0ebb184ca3c9d837f2d4d6a1b0e91104fd2b0c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8018c9d01a4115483815958f4a125dfbf62d7ec434070e27d4aa68900709d9e6c178b1d4109fc9b6de2c7485cfc0e8597f30d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f8901a4ed1dc172bcaed49303cf1fc09c8b7307cd3a6ce73813c7ad4771f165e11c091a5f6b89f1faaca3596e70dd23a81cdd0d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300094c59ea9aec7e4e60572a74af7ccb95127fb165f09adc32178ad80e4bc58f63161d9f02833a9980c23db78640cd67e83000000d4b6e3c3b706bd8941885c8fb46dee63ffbe116888d8892b7f53a0a0da00000000d4b6e3c3b706bd8941885c8fb46dee63ffbe116888d8892b7f53a0a0da00fc001108c8192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea801a05b8b13fdcc6917524714eb250387f6330775cb97dbc6724a73246a480c1504469a777d03478de1d3bb535baeef5c7f0d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f30002012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a201a726d33bb1b575eef918031911618076c72b24b7c00e0f093feb2c2f14d1fd83d3ef4e4351d329afa693264644dd220c0e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f11301af03210533c4b3b2200dbc65961590904b19e8132fc759c0bd6ab38c88078ce9f1ded55e4c46e8f000f5744e5927fcd80d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c01a7740f3302e48e88527030630d7c776cd4f0738a0413fa26b1acd1053e24eb42aad8c606f24b226fdae48a25db7b62d00c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb01967b38cebd11a41fc82acb6739a375e5459c51804ed58be7e7eb384481dc6631ebb32ad78ed5c21624ea6af1202ef03a0d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a018b5e034afabfc19434e05306ed05e611efba5eb2b6e199114266d60f315a9d3aba5e913d20dd060478d58667cda4c6290e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d019398faf325dbac5f84b53d53dc0118e187ef1cfab954a1f41e5474d893e779fad2cf9206df0f28ba31938a07543ae1c00c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301abc8583618c7a847a00a0d2164a28ebdcead0d7a23df00553f9e0fdca2a8049f0504d9a4d472131e671de8fc1d4e99960d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef43601a6d31c009e09302a3d19f5dd1c56ad3e8b9205a1a23c49e93721599d6623be423bf85f72aa3ada53bcbfe0d9da1a93fc0d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb01a0ff36d3273675e24d02d0f3e4083f99388b3561333abbeea8a46ad84e06e536f595382ca44aefc370ca7d64ef88b5b90c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e01b56355b74fbe62ca05d14bdf3d1896465cd5b41e897da999c08ad39e7a4fafe32c46fee3536dce92db32347a0fcebc5e0c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82401ae8ea031f0c46ea23fe6c45199e9e089283dd1003d6eeac30541b20b45989756052e943853f83e015e7060fdffae94c80d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d6789180188c024a804b1cd694b087c8648789fbb3b4653784a1bbfab88db8afc2c8fb87cfdff5aed6eb6561d301e4cff2336c9060e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f0193aae6cf15f02ce0939bad8f654d85a724c70b8bbffeccb336bcdf7cae780057ed4e579d25511d3dc8c79700f7902c8a0b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f234018596fa5844b472ff7e62d6a083c2c37dbced2d8279d617392f79329539a30606f24f072a6f89119f8580c031867c97750d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08150195e700df712726032efacc015206cc8905c6a262d2a09f39c0c4947186778dad1c7e7c0bbd994a828ebf7381297e5a090c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc401acc4a68d6a4a1a02f015c149e62943d6e2d03699bba71092bb324abdc68a78cd05d28f570ed6517edb456a38cbc20b860c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d01a95f3700cbeb45904f7c09df31e142193aa9b277ec80da5458136a0b4c4c1bf26eb9b8f420b788779d2d92a5db71a4360c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df5401944d564c8f03423d7923069004a0ff33a9febb61295158fb95ada04745f8070410e4f22041d6c5ab1227c8ca7ec5d2b00d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba092096018b6c3bd1b6d10f712dcdc043287608210e64357e44076bae3f630063f27a00134479b06655305d4dfc14d783c610ef190c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421601a4545d995258e0c25eaa5395cdd85aba924c7653248c79e9b6d54c5c95457f9c383aec10e9c7135910efc896a552cb400d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb801a963c8918e33ab77885122c7e72dc5d5ed58747b6341d055c36af803af19b674eaacfa397368cfe31e50e0458663a7700c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba801b09a36c2cd9523f2036fe71755ce02b4722467eabbe2d9606ddcaf5c1c73f8dd21c1d697c9bece75d952f13adac2b9670d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f8901a0f49df8abdbc389ab1bbb99ca45a4268d7858301b259652dfc699795db7f35113f2d29f4c41cd0029faa88df14c549d0d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac901864a2eb7c4019522c831b28bb8c84ec256556f06d90e71f05d12cebd6cc3e8a9360749637e9f7acd2c8bf08d438eaead0d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f3000a89b8a9e053bcedea6d6c29e63526edf069639d25ec8ceb1f6f127e3259c71769f1e54d867ca5b8449c8d55c19248cd7000000ceb90097be7a897c47be4752340dab3c394e860cac4f03f7bce60caa8600000000ceb90097be7a897c47be4752340dab3c394e860cac4f03f7bce60caa8600fc001108b0192012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a20188a4d69c5ae7263da2494237b4eb77db4cc5e59d3a3f1413a35c96684b858db2be1f22203712c93a51befaf591bd972c0e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c01aebaa7d29121c7845ae2aa701eea659f2d54c0151eabaf7f2069ffed57a846deb657e6376f5f5f6aed9c3060e2ffeb030c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb018e081ac0afd47eb31e2e796c69a3cba48c4a7f5c63b71ff5ad946c6b193bd0c921fe3ae922eb0e8d5c6123907ca66ba60d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301a1814ef35a03c54d6ea3170d794a4dd10bd6d49aea8fe03d1607a240c94083dceb3a69e1dad6ec2f3f49f818b9ee462a0d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef43601a71ce89bb92a4730672b2c774de958dd4c85dc53461cb41105d7766aabe1b473722a483585603c3323e2bf7bfb3d47e90d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209660193bec6a7ba821198140ab7a1d0ea93a96d8a2b961f7a09b594ec768b0e99bbb74e8ef075efc43943f7f4d2c73d967ed00e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701901b8de15f05a0fa8b4606fc7aa14fef15c5c9ac74b8b8de56761fd870c40d1fe9f0a1e0e75fd05ce23989acd3002aa54100d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be4290018cc7fc20d72fbad37344f1f22fd028878f9eb1ce487464d8bb7e88511703289b03f636cbe329bc724d1fd7a5e0e228950d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82401826005c487974a10dfc6c0e9b81d36d01f7868f28cd41bcbf1c70ea40085d054e1c466f7e3481fed2c051bcf3f2e8ffb0d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891801ab28bc9b23df49c4dab9d8ed5dce583172aa6115c64f4799b640337b8f789d1776e8dd2a54fef6cb688421f4f4405f540e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f01a69dd93e9acc2df9091efdbb6af018914c02610ecba8f9a87d0072bcb905e69f2f86ef5b0a9db53fe9e0468ea8b47bf10b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f23401a28b26c15833231fb3e4f819803c6c197c9ca4666d6bae08c684ec87d36f087d3f7311db12c1d316aa48807a38389af70d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc4019576536e85632411c5464c48458c59388447399d11717b8fb9bd08654efaf40d2c4263574eee84333c569a01186f3cbe0c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c0018b16d7e9c9d09f4c1c68a485a842c42df657993e39852ecf497a343e2e4091244d6c54426765ed3b35fa5428c56c42060c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f01a723e5361a30fa8b8abe2ada16f6355bef4426fa666248b1e7acc1166b9c771327a26d8476219366264af23d3690c6850d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d01a0c9d56c59553573bfd2820e100c32677a0f8acef152aec3a9ba26de65f5c00111e607f84f06054fd9715d53467923a60c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df5401b7da304a882b4b043fb3c9f4b3f1a95b712348df94041029612a987e91eb902dcd12b287747776fec40ca8920df8fe5f0d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209601ad516ec8101f2b352444645838f496ef4d3d692cc4f7058175c3dae158625f3a735d78da982faab68d89909392595ddd0c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c01adf3ec0568e65c42c340b3dbc03145486abb34af601372b30a992aa66ca5800247e4e3df8c14a74933e7dcbb25f271dd0c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862fb3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f01982d001eb233cd0e83f9112eb853945033cee76decb4618ee280bf6125fd082c179639ad92154990877e9d63a55637400b35322e34332e31332e393241b308f737ca9e39f67b553158903198a88c516efb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e2542160190980e5b0b2050070d1217dbd9694f7c58f00f67827613c3b045897c7fbbdd18e30a9068fb0dff2b73c76946f979ab1c0d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb801ad04595d1ecbded5cc553eca173eea397c402aab1fc08eb46e38013ebb7a4f859fe1f2b32d922bab2fd628d38b9f541f0c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89018478b47312f9b93e9d7fc2262c286b0ff0f14edc2fab154c5b6739f849d9257a5c767c06db8e9d27ffec3084ab645fcf0d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba78639903810182e166338742861b258ef7ba49636a4f1b0febeb9a19216c758465c4e6d0822ed3f7887e9f474ed474ffad65d86496ee0d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac901a58ac81821f89a959b0e3feb0768e7301b918a348227704a7685deb45c29196e4f4a1c2715327a127d08fb5d33a731240d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f3000b3601dc016ef030a4707e2afd8669eaf547aed29a43a3c3f0a1f5da0f50d3ccf3717876623efaaf4fd01d56d4f19c4af0000007672f63d6d54737b0dc862fe00a4c146100e922c39e2b8349a48088d52000000007672f63d6d54737b0dc862fe00a4c146100e922c39e2b8349a48088d5200fc00110898192012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a212de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a201b868374061b0f68d2c262e87dc45c2bf048a9f3a9f6e91f51cb1b7fe623deb3709b439cdaec9a48519201cfaceaa3bf40e3231322e32342e3130332e313439c1161c96de3dae28cd7f20ff8c2aa7b94b866d76fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f11301b4915f6d8f4ddb2132ddeaa39ac3c7ee6a6e4e026d1a634c146c705a0a1e5303939da3957af20e322f32bdeeda3bf78c0d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c01a962184d452a61d4adf3d719cda3a02eb6eaf1b7838144b2e0bd9fe8db237c14912369484d2eeed76159e9592604cf150c33352e38352e32312e31373935d9eb76397d05b43b5cd8da7ccfa8408bc89ab3fb4e1ffb05a3fb8f3000202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb2e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb01ad0d7d5ef86215650c75e1b9b6773db96a06835508dd97590f56f8b678313f8fe082112bb8ced61e0ae797981ede6f7a0d35342e3134392e33332e3136371ffbf1d32541dcb8f5555305295704a9ff9adc24fb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a01adcefadcab21ba07c09f07eaedaf087adf5b674028af47d1251bdc3cfcf032b79ea71e530caccb20361b9a5c25a440460e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d018abf30d7c88c6104d05ca58f08fb61c70c3d655576b559a27c2b1baff75802b6bc99fb206db5473ebabda0bdf79bad400c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2301ae3b8d52b37ae8382811cf52d9b29fddd46fd66c098dc03df1857a50effa2c85674e195d4ae0ac22d25df111b9289cd50d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef43601916c39a7d78a348ce8c99f798ed84d7368601612dce992277e945ee3d34308a70e92b08635258ca6cac8539355779f0c0d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb01ac518d843f4893fb55f7db299c2fba948107223385f82981dd8aa4e073731029efbb116b85ebd2912f69e8a20b898ec30c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209660181730f2f8ca06b21e037e1413f4e07286daa61effdddffedb1e3d37be25be8f724a2c5cedd2267bc712e09ecc864b94f0e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701901a666c20f678260e6cf732ca2d9c335aa7eee07e9a48f15fc52bc70a0e91bbbb601235905a7c2e94f7b73d4be85684fb50d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42900194813102a7c65673c8421b5098bdb3527a6374488c6e4005077589ea6d88cb978149246858b01f5c043b0db861bfd7710d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891887075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891801a4e5e437e79ca948abb1c47d227e0cf431223858e232efc678f2f44c01b8f03fc8bfc783de1c9aa25fa33ff26e34683b0e33352e3136372e3134352e3134399b9cdbfe3568cc0b37f136b00a634c75653f05e3fb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f01b96bbcd66fe7998497d85b794b7ac3db4f6aa623cda276bd5794ef34e187556fda94f0a79e9f821ef4c75c27366cd7480b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e0815018f492b943a251501373b176dfb18a0f7870823efe32b9cff53992283704048e8760a9000f26b94dd297621f8d8deba080c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc48de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc401b2079d4be290c58b34c9c14fbfd01bb9f1aaef01d002b319925a243335c52878ac883f9b7e0127271590188df43119f60c35322e34332e38362e323331337b7fb5d2c531825c3e0123ac3354018085b302fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f01a92f9d9f46f6c9553c28adbe4855f42298c48953fdceec62c7382ec7ded8e0bbff64efe7df4db32c7829f41719d340690d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d01aef0a3f51cd505157dcdf018bf77412f70236117262a69892b426c48ccb906614b68adbb916310fbfe770b29c0e109ad0c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df5401813f9716f1fefada2d1a750779935e9571bded5f0a2a0a08b19edbf4d821538999d4acdd537755599eff93717fa071430d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c0195202e363e72de2c2f1824d118a6b19243808d4bf3090cd6ce1bcf0c92937f6b2665f05e497f0dd27586452f9e1507230c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421601b5ad25d83182aea77532834687bab1d6240b7b40a55ca27e60259c1e4f5077ffb26c3b1a0434d9eef529596d632c9b710d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba801b9a2cdce8e51b6a514e599ab5edda00e6d69fc0cc43c380915149abe7159f9c856e5ad391e7eb443ff8a5bfeed2659d10d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f8901a5d068fa707cd7a1dae2b4e30f384a516e4b86bd69ea0ae40204f35235fe866a3f54e1f7460ed9744485b7744b58c4850d34342e3234302e39382e3130327034f0d3853c5351fb8e0ffd3c1daf12c51c2d89fb4e1ffb05a3fb8f300020f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba786399038101b11e5897513333cacd8b5761d884b08699da6d8dac9e965a366599813ab7599ea6ac86f064060761559940e2e1fad3ad0d35322e31332e3235302e313832fe2d4798df3e9b41a6823bc0b3f020478e87925dfb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac901b006eca834e243cfa364f0b6a127aa221306b1d3f51d29b99e673d69a2e6fe60e27dbe859bcd85ac786430a8cbd6775b0d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f3000a8aa56233bd002f4e294ab97dd212cbca4f79aea9cf6e80ff7a568ed5668569cfb5dac816a3f8561ef04251a28fd530c000000251c6293f36145e149a75179d723b88d675332f8efd1667cf871d2467100000000251c6293f36145e149a75179d723b88d675332f8efd1667cf871d2467100fc00110880192005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea805b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea801990f9bdf2dc93b6566cc92ebeff39bdcc062a37575b737848ef93f040e09d8fc7104116a48c83376d050ef245e90fdf50d35322e32342e3132342e3136328feb00404d6f765856c95e587b2523a365bc7258fb4e1ffb05a3fb8f300020143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f11301a306779bbe3f86d7b731176aa1a86a6ee080adf527953a6844e02e668b67fab78e859690844d72aad89602d175150e3e0d33352e3136342e32332e323435b5f25f8f70cf8d05c2d2970bdf186c994431d84efb4e1ffb05a3fb8f30002039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a39741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a018db9d17923c5acb439a2ca05d6b8a9b8e4b68a0554b1a0325c926e92e13ea0a8c4c9a6f38bb16b9d7807532ef96064490e33352e3136332e3134342e323330ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4fb4e1ffb05a3fb8f30002040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d40784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d01a660a964938e90ba91e8f1bcf46f5b61edf9e7bd1c974e7f58ece9f6806f9e6e6fa06301e75cdffd923089c78ecf5a610c35322e31302e3232392e31313e8b10646ee9d6c28d75c280b357dd3a9ae9f962fb4e1ffb05a3fb8f3000205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a235b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a23018e64b6456c41e771170854d8415bb95fd47c597373c00a55a4beeea43d6a22830e2e4c6dbe4dc03794e0c8786d9a040b0d33352e3136352e35302e313236f460a07a2b0dc932e1d8ff2dee2b984ac415dcebfb4e1ffb05a3fb8f3000205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4365c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef436018317d15d474b38602d5e3ec6d1c3da6284da53b47b5084534b65debf30c2018a048b3561c38429530a53f2ea5583de9a0d34342e3233392e33392e313533972a33056d57359de8acfa4fb8b29dc1c14f76b8fb4e1ffb05a3fb8f30002061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb01b09010ae7148d6459b2e3821ee2ea2e8c2077bd948a16ded93977f4865ba6d04a3e82ece2da5703d04e0d68fcec043610c35322e31322e3137362e39307ada3e486409b39c94a0833c8d782f35bc24e96afb4e1ffb05a3fb8f3000206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209666d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209660188412ab841f7b0951d6f0d035a9e91472983c1f66801e14ded8f71f7e6ffbf4d37ad1097cf4b2df332b4bf30ff5f45430e34342e3232382e3234322e313831c374f016ea61e76aab79b8bb95a1ba0e6e3eee6ffb4e1ffb05a3fb8f3000207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70197135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701901aec0362b40aff3bd20153844977a6b5178c8f4a0b59d13c3331c1713a984d9d0fe4e33bd73892fc7b9db0276f04822dc0d35342e3138392e3136342e3339f9956e70daffa263e8cf29fa6557b7b630a595a8fb4e1ffb05a3fb8f300020754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e019757740efe454850a7e553e29ec92082f41c8559c209738e4bf2622856ce8a25c982715ab6b6b51224ae7b98f822e4b80c34342e3233332e34342e393546d938862af6d9a291e26c0048177db2892a710bfb4e1ffb05a3fb8f3000207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42907718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be4290018c41f9e11ecb851812be5235cd0cee625e9bebb624583096ff39a673d20f589021c6f3870191bbdafc32ed5245738b520d34342e3232372e3133372e37370498ade3c80045c2a7520e921180ae1c39da5c57fb4e1ffb05a3fb8f30002085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82485f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82401af5da56ee0a828c4ba881d28c2adc2ae288690fe37535a075ba54b72c6532c26095cc71d80f681d725e063d1f500e06d0d35342e3230312e33322e31333168c506d43816d1a8389c860c1d162be44d1e777cfb4e1ffb05a3fb8f30002088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f88251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f01a51dbf35096235fe2018a7f1ff00c3c18e541e6e5ae2a81c0952ed5a3c8800e1e6b5632ec1dad41af24c0d9bd8cdd2b00b35322e33332e32382e3437711fd9548ae19b2e91c7a9b4067000467ccdd2b5fb4e1ffb05a3fb8f3000208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2348917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f23401b8f10efb4b60b6a2cc781c0f894151e0053e764175e261c75af516ec1cdab766de87b69453a73be3c234e6f4aefee6fe0d35322e31332e3133322e3134365bdbf34a0dad860c6ec71523ae39373325225cc1fb4e1ffb05a3fb8f3000208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08158b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e081501afa10520f621ca2cf4ee8ac229f9ffafdf0837f802eada2a823255235841f08544fcdb989fb4bff6348de6bb6cce8a0d0c35322e33342e3134342e3530a0a0e17bfe82a484fefe348b7569a6d77d29d2c2fb4e1ffb05a3fb8f3000208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c08e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c001b1bf5c07ab8dbc65148edb38632459cc79b85290185b7bd6870f9352bde07980986a5427f783cbe3ec3946a5eeddc3300c35322e38392e3135342e34386d57707c196e06487d326094c964f258f5b77c35fb4e1ffb05a3fb8f3000208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f8eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f01a56d524c550f683ffa4aa0be33fdd59b3b02b6c46bcf4696283da657d2d7581cc4ee52a38671b310d7d7e526f7f4557c0d35342e36382e3233352e323031c075993a8336f93a13bb7bbb7e0e89928be4aafbfb4e1ffb05a3fb8f30002091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d91bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d01a818137a518d06c03a98e2bdf2fe4fbef96ebcda3042504d109feab8c28692fc8d521de2f3cf75e3a412e09f9dbf17a30c35322e34302e3231392e343102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd9fb4e1ffb05a3fb8f3000209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df549712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df5401a94edfaa78eadaa7cad31be5997fba9465def62ae4e6abd5b94483b67836e61b418ec9288e3e5d928cfbd70a739928530d33352e38322e3139372e313937ed1131823bcea23ac78af8c01e4d24683d6ecf88fb4e1ffb05a3fb8f30002098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209698ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209601b59b4cef03be4158392249c56d61e50a21785005ba8982c4afa93d271bc4d0b7c19415013cdea9403c23c4a814aa1b920c34342e3233322e3139362e36d6ece912cbf02627a4efc3dd37e6833cf3671551fb4e1ffb05a3fb8f3000209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c9cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c01885910160755543c1bbe191ccc79fc8eea5d6683a2186fa7666ad88caf4fb08c6c92b7baf1db457cdc11956e35b8a2050c33342e3231342e34382e363862e960a3f6b650feed98a266b3ccdf6e363562cffb4e1ffb05a3fb8f300020ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421601ae0682a10deb1a2c80076b617e220491c372ec9b62870789b419914c56f998ff30fc260ed11569e6ed864ef5774d95ee0d35322e34322e3230322e31323862e0104ce0aafc1f06bde37c73702fe84b307f05fb4e1ffb05a3fb8f300020bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb801a9eb13ce08f590b3346f9f6f36ec10a7860e3c1eae70c9df7663772224a60c7773f83ea2f080d0f74ae67ba223a9dec90c33352e38322e34392e313936dbbebbc52a5bae21b818e0487311041c91b2683bfb4e1ffb05a3fb8f300020c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba80195e62cf6ff14e6d8ef16761cde3384fc19533ea21e46001b57181b7af678eecaed015cdc58d10c4de4acfc937b5f18ac0d35342e3231332e3230342e3835fdae7cdf38811659ce9481975b326a5d07236bc5fb4e1ffb05a3fb8f300020ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9019338650338a17c01b5b225d5618187861fdfb4ecee36d56c141ffc55a5b1f31120fd0148f8f50bb071734375ac888afb0d35342e3138372e31342e32333267e05b1b52c7c896adf20035036fe1d30dcefc9cfb4e1ffb05a3fb8f30008bbe3bb70f3f0e4204b96c4ab65ee2574d35ced1d63e67379d9dda4017504767ac94148797747faf41a1532578e2ad400200180018180000000b8cd4ead1ee12d25126921d918020cd77745d9cce5b59f7287a2a296e9860460119622e94b562c3dcec8445e63d04f8f88d4d0835358f79ced0342b43822e32a35c32ebdf76eca5d940a999480000000021160aae5b92562c94a5d6735c5dff3a92aa0a8d9b02aa0c614ca7154ab450abf6838c0026c4a8526d7dcb44426b02f225d98ec9d43bbbf91a204b9c50252b2e3c9af4c237dc117d73fd60345100000000251c6293f36145e149a75179d723b88d675332f8efd1667cf871d2467186fb47b84caacf7734799c2106fa87d8dac68bcceefa3fd33dd568ecbd7bae3fe312835eff8d68b9bfefa852d12589cc0000000029787a10cbbd05260d3c7a8114746b568d0a5fbd2fdb9f080ac12c5acda53f79f722b98c47ce515144b41daa3a97cc7176c456b05fee6d5fd0216e123c07b1c0ae5eccb6d637d88e9d45bd544c000000004689a842c049d460ee314df1bbfa36530ff86632142fe3b6eee8240034a0fc274fc7b00cebe08b5a91f39ff7435b0d944ba82abb5a3df6a768051b674fcda0c9ed7478801f58abb1d081319e3c000000004d43bd84ac6be16b9b7e352b3e9905e1337d7d4d6dd0b8a0ff92a89f1c844a36bc9a23cadfc278a9cd6df42b375ce2080c106c8ce01b3aefcac3f81ac3ba2abd5208165ff95039bed9d8ff94ab00000000503099f9f7fc49ca9350ce1951c09325670b8b459f3a55ebe6811f13e18c43a90fc0e9a3b85297dfc221a1edd2b791c03bb2f5cda875a8844edfb73d8548bcc3be5ac5cf6548b9023fc551dffa0000000050b5530a426cc3a37ae64b7e37879c0905cd90391226fd7395a19cad2ba99406603295d31f2f2bac6c2cf95a3b950b7abbdf74928010514d2ec53a5c4d3111fde6eb703f6e5599bddfb6ef2de30000000072da33f586cdd86a566cb30268f411dad855dc3fd18c5669410c7cdaea935e67335f895fc17481cb14a4cf7976d449446bc45714c8c33888228d1a8833b372f0bf5e57d3da8d8b46a3df24ba18000000007672f63d6d54737b0dc862fe00a4c146100e922c39e2b8349a48088d5284fd520baf70c5d1f099f89c30e4824cf9307db2d50d04ad055a3cd4b1ca382e097615cb41a814d6c8af1df3f41ea40e00000000b6ebee5a8f801f7b66c32a3454b12513c76ab58b121a4e9c579bcd4e8ca073fdd826b6f0528d57640ed2c442f427ae50365c8ee533aea561a43f0a847535d1de724b4cb33d8f1ebb1b7ec1fee800000000b91e2a2fe9ab4c3899dc7d2d85c9e00e068603afe59058d5415a84773dacdda79998aa4a7c8db61e4de0c0033a6ad68b8e898017a0a1e478204a9fff434dc7d874a4346ff3f0cad0e6d6a7f0cc00000000c9c3825db4b9a1751e94ef41634a33e2df66e8f9ddcd56dd435232f48f97fbe82232f01d505db016f9acedd89b3b64aeebe3ee42c618a70940c223b44702d47289706c066001f399911b13e5d900000000ca47540e3e2bbbfc91ad3581df6b5f730ea457841a3544e2ab3c54c245b81e791bfd854cadc0ade4456d2eb225c921545d3c6511771be3e41f96b828e14fb560a4c8d86eab9935b6b3f7dfa0e000000000ceb90097be7a897c47be4752340dab3c394e860cac4f03f7bce60caa86b594ee3dce15b395606f54f5269d69688c38b90958253f6f75897a312849d64f5f991600032a11b4f44162d429a08b9b00000000d4b6e3c3b706bd8941885c8fb46dee63ffbe116888d8892b7f53a0a0da85a9c445b48a8fd3703c240ac3c838f65f78f6208698dc651d1a24ea3f09a72dc43389bea4e65f4576708b39f139b9f100000000e5d8948d2c695de557f1327a8f323fe00ea463ab53d415589456cae5439428bbc401fabb4f3e7c3a6a5bcc139a4ae581645729bd4dee7f272446357cb0c4064ffde38e5eed63720df03259ca7e00000000e7654d577ec30cf6779bb7f025807118c9ee33113ea249fa1ce9490646aee6aa85f79fefcde7fb71a8c880f6474fde2cbfd5cb6d1afe1cec9506fb25b1f8908e1934648898c79dc403f2094d6300000000e78672b7a792c03ffc5e06c6512e0ae64c4b5410a2e41b6b871036e5d3a89228f3c8f7b8cc5080b6721668c5f6ffa0c6b7c7fbd6182e968882e6676a436d47ea673c2ddc83aa6692c44972a6fa00000000f1187cb12e35cb2a20fa7ebaad86a10a07f37a26d91068fcbde0ee462da7bbbc25d144e31734003aa26cbb696ff91d5895c67110369dd24998e7da857bbe7a40a9086b96752c1e35e19a485594000000010832789d4cdff3cc8a63fad668ccac708af7433c42e189ada6c6e5e66e83e592e3320143c10ef29d05f6094f428fbeec17671057917f2bc2f6d71f8151e3c22379c9414e41f568a0dad43a49a2000000013b5860da205d4132c60deedcd2f06f18c77718fc9f96a5473d05e596fab64e26f35b32ed7fcdbf760a3806137ee21208642ee072e3284df4a1f9197b2b2c1036a355d2fc670b37f6d06631195600000001561ac909f7762f03b801661c0ab46943d603d2883b36535ad5f6344cb8a9c57b1671efe72ccf52577b20fdee42c4f93c2098dcce5e0589b4eced2a1403c4834084b950f775a23745c73f85edfe00000001d6bd1fcac1f64325a6a26b0a3a02d1e3b61267d50f855984a873c3d6898c3f90fa3b27af67e8f0b3078169ea2cc61ef13b075fd8e0d2d6a7e83ccf0c59370020e5c753a0ad1a684efcfd68499a0001180000000b8cd4ead1ee12d25126921d918020cd77745d9cce5b59f7287a2a296e9860460119622e94b562c3dcec8445e63d04f8f88d4d0835358f79ced0342b43822e32a35c32ebdf76eca5d940a999480000000021160aae5b92562c94a5d6735c5dff3a92aa0a8d9b02aa0c614ca7154ab450abf6838c0026c4a8526d7dcb44426b02f225d98ec9d43bbbf91a204b9c50252b2e3c9af4c237dc117d73fd60345100000000251c6293f36145e149a75179d723b88d675332f8efd1667cf871d2467186fb47b84caacf7734799c2106fa87d8dac68bcceefa3fd33dd568ecbd7bae3fe312835eff8d68b9bfefa852d12589cc0000000029787a10cbbd05260d3c7a8114746b568d0a5fbd2fdb9f080ac12c5acda53f79f722b98c47ce515144b41daa3a97cc7176c456b05fee6d5fd0216e123c07b1c0ae5eccb6d637d88e9d45bd544c000000004689a842c049d460ee314df1bbfa36530ff86632142fe3b6eee8240034a0fc274fc7b00cebe08b5a91f39ff7435b0d944ba82abb5a3df6a768051b674fcda0c9ed7478801f58abb1d081319e3c000000004d43bd84ac6be16b9b7e352b3e9905e1337d7d4d6dd0b8a0ff92a89f1c844a36bc9a23cadfc278a9cd6df42b375ce2080c106c8ce01b3aefcac3f81ac3ba2abd5208165ff95039bed9d8ff94ab00000000503099f9f7fc49ca9350ce1951c09325670b8b459f3a55ebe6811f13e18c43a90fc0e9a3b85297dfc221a1edd2b791c03bb2f5cda875a8844edfb73d8548bcc3be5ac5cf6548b9023fc551dffa0000000050b5530a426cc3a37ae64b7e37879c0905cd90391226fd7395a19cad2ba99406603295d31f2f2bac6c2cf95a3b950b7abbdf74928010514d2ec53a5c4d3111fde6eb703f6e5599bddfb6ef2de30000000072da33f586cdd86a566cb30268f411dad855dc3fd18c5669410c7cdaea935e67335f895fc17481cb14a4cf7976d449446bc45714c8c33888228d1a8833b372f0bf5e57d3da8d8b46a3df24ba18000000007672f63d6d54737b0dc862fe00a4c146100e922c39e2b8349a48088d5284fd520baf70c5d1f099f89c30e4824cf9307db2d50d04ad055a3cd4b1ca382e097615cb41a814d6c8af1df3f41ea40e00000000a9510131c07fb58ce1f572165af5af245f7be594245cdc40b7b4b95cc78ab76c9e9a341d200635323b462be31199e93cd43bfeecdc1243d7c8d1ba41910edc07cf6f197d55da1f5c760dd661fc00000000b6ebee5a8f801f7b66c32a3454b12513c76ab58b121a4e9c579bcd4e8ca073fdd826b6f0528d57640ed2c442f427ae50365c8ee533aea561a43f0a847535d1de724b4cb33d8f1ebb1b7ec1fee800000000b91e2a2fe9ab4c3899dc7d2d85c9e00e068603afe59058d5415a84773dacdda79998aa4a7c8db61e4de0c0033a6ad68b8e898017a0a1e478204a9fff434dc7d874a4346ff3f0cad0e6d6a7f0cc00000000c9c3825db4b9a1751e94ef41634a33e2df66e8f9ddcd56dd435232f48f97fbe82232f01d505db016f9acedd89b3b64aeebe3ee42c618a70940c223b44702d47289706c066001f399911b13e5d900000000ca47540e3e2bbbfc91ad3581df6b5f730ea457841a3544e2ab3c54c245b81e791bfd854cadc0ade4456d2eb225c921545d3c6511771be3e41f96b828e14fb560a4c8d86eab9935b6b3f7dfa0e000000000ceb90097be7a897c47be4752340dab3c394e860cac4f03f7bce60caa86b594ee3dce15b395606f54f5269d69688c38b90958253f6f75897a312849d64f5f991600032a11b4f44162d429a08b9b00000000d4b6e3c3b706bd8941885c8fb46dee63ffbe116888d8892b7f53a0a0da85a9c445b48a8fd3703c240ac3c838f65f78f6208698dc651d1a24ea3f09a72dc43389bea4e65f4576708b39f139b9f100000000e5d8948d2c695de557f1327a8f323fe00ea463ab53d415589456cae5439428bbc401fabb4f3e7c3a6a5bcc139a4ae581645729bd4dee7f272446357cb0c4064ffde38e5eed63720df03259ca7e00000000e7654d577ec30cf6779bb7f025807118c9ee33113ea249fa1ce9490646aee6aa85f79fefcde7fb71a8c880f6474fde2cbfd5cb6d1afe1cec9506fb25b1f8908e1934648898c79dc403f2094d6300000000e78672b7a792c03ffc5e06c6512e0ae64c4b5410a2e41b6b871036e5d3a89228f3c8f7b8cc5080b6721668c5f6ffa0c6b7c7fbd6182e968882e6676a436d47ea673c2ddc83aa6692c44972a6fa000000010832789d4cdff3cc8a63fad668ccac708af7433c42e189ada6c6e5e66e83e592e3320143c10ef29d05f6094f428fbeec17671057917f2bc2f6d71f8151e3c22379c9414e41f568a0dad43a49a2000000013b5860da205d4132c60deedcd2f06f18c77718fc9f96a5473d05e596fab64e26f35b32ed7fcdbf760a3806137ee21208642ee072e3284df4a1f9197b2b2c1036a355d2fc670b37f6d06631195600000001561ac909f7762f03b801661c0ab46943d603d2883b36535ad5f6344cb8a9c57b1671efe72ccf52577b20fdee42c4f93c2098dcce5e0589b4eced2a1403c4834084b950f775a23745c73f85edfe00000001d6bd1fcac1f64325a6a26b0a3a02d1e3b61267d50f855984a873c3d6898c3f90fa3b27af67e8f0b3078169ea2cc61ef13b075fd8e0d2d6a7e83ccf0c59370020e5c753a0ad1a684efcfd68499a00fc00110ab1fc00110ab301fc00110a9c02042001fb0120200000001c17557b0aa6d56b745b60fd4c3c53f2beba8fce58a6a01fc50fce1cd6919fdb493c7492c92651b5b48643001974e9c6c08dc38d201e914672732b7e237f81a9a883cdc12b446548823fc52769011600000024dd142c3b883d9653935780d82dfa760af504be48745a9ccfeb87f95e80fb2822996190c9ebe6ef941f7b9c2cf140117614926c516865791a2713ea6a773751e9753b0ed63849763e435d027d0102000000372aeb94a3ad89154fc41c296b1bfbd2f744934dec354ac9f121a3c2f7ab6d16078b0190e779e516e9119abcc0623d14034dd8cac836d9114239251a0d10a77e498c92db7894d8359ebb8fc628011d00000037608455165b3d7f752e5576bb9e3fdb54af8c9f6aea8c5c39f607ebeb91199e5de7deeb39bf99ff557a5267ee0fc5e4297089e1ce03afbe27d7a4ef75196c6e599e4b15314213368b00c3cee4010b00000037e2a2a37e026777d2ba67371b1dd0c7d49044c5a566f0469be085c16fa184eebcce47f63dae0e2a55a74afbe53b671b6fb9954936fbd17bc890ca3f0e769983b188a22469c394c9bc1dba8a6b011f000000411dd2ec65ed0f979acff00da0df586357e715de8ca3b2d42cd396145795598b486466ed807f4306968b15410d4a55cd1e38f7bc3a489b1056ba8eae9a6dd5e1ed9e59c772cbf5da7e8b8c293e01090000004be4965bcf4d4e63c8250f81c617a58a5a268dc8ea3c3f86de0b3a806d8734df8c4bb9757e5157ef809535296800a14c76a4c925dcc26f74efd78bb45974590efe53d6d12eea41c1cfaaf5dd90011e0000004c4be4ac378bff06fc33e9677589e9cd45fe403dfc27c7874f95d42a6bade14cd45e426734de61d95bb6ffbb1e64e7c3dd3e046d3fc0d39edc28e1f047c07e44ca7fda141356d35119dcea53210119000000504bcfbaaf0684b5f9e5b43925497de07e93444da15568fd67daa3e3cab885843723894347bc0bb59761178e34b5ed29b879e23ce3bf84d60de0fab9e4d2272106f7c83799a1350ed11859df1c01030000005634442336d250bc6f41a1beb3150bf00c4386e29c782c86f64e524af78422c8690ea530d4c1c13d841bbe24ec66d82f1b962ce39241ad45c13a62ba4aec66bc80b9d3ba52642b9ec7d471fe06010f0000005a8b5ca058cba2953dc80aa4485f2acced3922c29d3388b167cf78b357965fd8b4db515a89e27c43dc591d47e343edb967d52fb8f1423fbefaa91b97fadb131b99dbcc28235ff0879dbb6a42df010c00000066677ad0a47afd2836cfd9b29a60f2a5f5b76e27cfc5fadfbd9a56a0d392517556cba9e44f944d656e0bd15062b41d172f9a3ecc7fee1d79909e3dd9929f5120dadb0d6650a92b0ddc4e4d1fd6010a00000097e09e2749e43066a7ec3e08da9786b4597ec68aa764a5b12fa9942094a03cc310e3d46343430851204829272c534ceb7b9bf0b774f8e00148932d1c6d7e9bf4e1616cb943aa44fd6010b147e1011300000099f4ba9b8f567066725e949ae6d15af33124f288930c05f29e5b9c63eda473df3015852e967e3365b140353ce5800e15abdf8c7736e2df5304a779b7e588b7d72423c9901004182809f64008990107000000a8d450eefbf6324878ad6e6203ca409d206772a0e83910352e76e5478eb72a08760cb1af67a0881b13d87f4f746b7e782f9c4dd8f61f7e25ab359fae768a25cbab2004fe9a095e9e97d8fc6f3b0114000000a946faee14ef3fe5b06dde3132766c3edafcae89fdb534c2c2d0be155c822fc04e42baae578281253c438dd9d8611f0bc325b9a9e39a2ec8b952c963401dedf25fa2cbc8ef26c7a5783c2372f80106000000bce166b1ab589a089dcf9ea84bbf00c42f3b2699aa067c53ac6a942ae693025ddc9b3f01449f67864c0b9cc26db0e8526d0c08035ce8151aacdb204b0d0c33aa7b6462a5d09b3b00f1783183b5011c000000cac98a5ab2a2156e2648bc99a6eb514aba8d1a46167cdd21baa114880390c1cbb77a5995d55907bab10d33eaa999219dd3751385d9259dec972208a6789b2ba31e2c254889895508fc077212bd0104000000e2113e90d0ec07975c2aec2c8afe986477d1eba19a7811d5d33b1d4486b9cc6d95122f1c1ccdc7b5d3171427fd2b3de05835649902ace1f73788e4939aee450e72209b9c6d28910eefecb7335e011b000000e3b9c3ac893562d87389c0255c7f95a51db2960302fb8d6c9d829725678b82f0157d4eecdca9a865abccf6ead67a65478b29c4021e15b26210880552bc61cd7762c8203d6b7cac79f6ec11db930112000000e42610cff0fc6648d1cd6d4d54dc3ffcecb374e945db637b7fc7e1094facb1a3b40966809d190d78514794ec2062ac3a567cf878513f8c2793bd555ae2107a1be0e09e4c35029aeb5104d8e5be0117000000e7654d577ec30cf6779bb7f025807118c9ee33113ea249fa1ce9490646b51b3d77bad620570ddfc765e459c508e780168c1e76c2ba6b3312a21a0e9da0b54c7f26331d962c30097ac89f4590dc0118000000e8528886d471e749c483155d887f9c8a50625b0263103e18dd0771d8aa86ece6336903315a8e34688eff6f5534bacd3ab8f6b3364738467a7b26079acca871dded3d3b402cf90f2f9f71375fa70115000000e90fdf133f8cc78262509b2dd44809d0cfce8c8d895145fb76aa729947b20fdbe02732421192ed34d58bbcc7252869c16480638a4d4f95fa35b39ecfc914960b1f883a3503e43ae29913ba8a33011a000000f4fee40e6c8b309743319b89d273476ce3f480adf035ffe6d35680c035a51f0d204efa8aac21d376a7fe892d270ac5ac1d8b6bb2f2633c358937ebc950a120acfa13d51358e2edf9d31099b5090108000001027d7fd3b22fb92e73d2148ce965d2e3684a7dd241215bd01be457649491c2b79dcb3d7493c35b41838867fc468d5c691c8835f643acb2a75eb438d8fe64d44ecafe51373514f2b2bdb8c1e55e010e000001082689584968c870268b47d0d3d3c7ae0655fd1ab678ed72d359cf1a678b44174aada80c6112c7d703a4e60a76a837432a45142f02eaab5f5b7ca558e5bef1c82f7554af04394201960fa7ec0c010100000133375fb619887caee8dfe8c764a3ccfb10a2896075d79b55e00833182f8f11d173cd8faa2a60f2160205ac5a327c62b5b0796eb5f479eeb08873039c52c619d5066f30625bf757f01ec4885b4c01110000013337cca3c54b9ee0d086cf98c4ad8fbf2912a8281d31b5bb675b9ce1e789a581df737b98b4ee8329a7ca0c38684dd6c6bbdfdeaa415dd7f26251b0571f9a33f25d9e83e55661918ec38fc752ad010d00000135fec3b0a50d647054092ac6dbdf51f4b86bcfb108cbba6d6f3deec300ae5fa9750ead0aecee2ed5ab68056870a6cc8ba46e9580080325a8c418eb1e747bc165e504beb9ddc5ed4ec168516ad30110000001d60371889ab189c71d65fab144450f460ca502c1fc0236947a11e697158f00f47f5a43d0c0f1f3c34ed98e9570b2db010ea6586e49b72bf68060b926ffdbef76c2bc4fcd53116a26c02bbc3ed00105000001d6bd1fcac1f64325a6a26b0a3a02d1e3b61267d50f855984a873c3d689a51f3fcd0dbcfb1a8283e2e476a24dd722da031ad8c800ae359757c57ec4f939cf1562f5337c6863140b862d7aed3eb80100012000000003b8ac2b8c34bb5c5e581b140305c9213f8e269d075f7c3ce350586577938107a9ea8b35489dde14f2d2107fe95a9c6a6aebf73f4133a5e8a7896434fd44f8770d6ca3901938ba36bc244079d801100000000ebfb3fd8682d13b42d76227518da219365299bf25f60e060228c3c4f088234afd114926aa4b1e7c279f29bd6b929b332025998236811a4afc1a64a8bf319580bcab4d21f0281c090583122352010b0000000efb7bdfeab3aa6b9a7aade1624bfe5139dc053648fde77414e5d0d26a82a519cc0363d0b7525fc99c81ab531a06d4008d1371e9b9bfb0326a39a35250e71c6f546d48502e529a9904afe1f8de010900000015c1b422d89b76d662e8878f1e898e0e52bf1c7e4c8b5a5d84819e58bd9585750dd1e0e508b8cb449030845947a2cc2ba0fe61ab0d0d42cd4d3369789d9baa599618886ccf46d672ca96fa0177010a000000239040f5760172bf089991bdd423d77fe12ed94c6d6cce4e4ebaeea240b1804746481f8b92b0f9031caabccc24ac90f83d050208a6d634a6e91612627c7ebd6862ee169b010e66c139c92192190116000000251c6293f36145e149a75179d723b88d675332f8efd1667cf871d246719452257af9160aae311e167e55120f056c1ecaab2d83c920e5ad61904c7d308eb7309b207e91ab891a211ee4170b7d77010000000027d6c573e287f6815e8d549b7533b43d565f194fa4707c2c452c5efd719992d9ae0daec52bd07358f00829c9e3146e1e43aa093670a89793feefee6668526097480e2840781f18e35565a106a601010000002864d8f7a309572aa28f644fe14b35996a6e4a277b7e2d4a61c869df6e8a37b3962e6a9bceb12c0456e65fbcdc8bbc1ce74a93f3be699c0608253a3674a8a4b6581576b57e288082732ceeba1501110000002f841c6f9980ac707036873109f38a5dea30d9b7b4440b5f39da05a699a13ced5397b305ffb410d814d7a13d1f2d9e4cb246d2a9c1b67c6d00abd8fbd8ebc3a95255b3878366fce78f8446bf62011900000038975f7c98f3b1d4520cff75e2cd2fa8cdc1b2ae5ec173e8e3526fbf3ea2f847e67c532dd711760aacb2ab1014655c197abb1969d2a35906fbcdc1df36f4653d0867a8ba0245f377a30d49c30f01120000003fc35bec19e30621f4df1807cdbdd46e7c2ee5fa7e3d16373604222b6999ef5fee5370fa30abb6aebddf9d70fcaccb586405ec9b0db02d068bdba05aff6d31a00cb7327a98df9b43543fb7b4990105000000568e1d35844bf5d087f1e09cfba371602447652743af5405fbd011418c892f812b0354223bfd407a021e7ddada119fad9a78577ab35f7470b296b1447f813782c20cba5f7704f25c860601cd8d010300000058d4f48f9b03d5f56a1bfeac784020bec3fb8a158d5db64edbe3ec1d23b261c3f2146141eb69446088de98875b7de7fd24b33bd411ea0bc2b1ae81057503afc3680af273dda36bc16e0c009cfa01130000005daaf8a7fdd8cf47fe818294ee93ffc2f3152bdb8d3cbf6defdbdc42eeb9428acd63393effd14cafebe45395dd1fd1fa629760b9865dcb2e439d18c1624a3b0e4275ea86ef397078442866f9a501020000005f1c7c759087736e3790693baeed92291652f555159fca5df6ead3e3e4b66abbb198f79e638f60a65b2e8fa5d16b69fd86745aade4f1646d3ef6b9310a143cfc9f2d34f74185e01ad49b859a3101060000006c001fa7195e51d929c1007cb5529543fc5bd3e5e5f3d04fa580a118cb8c7271e6b940b60ee8779d1e17f9e4af1cbfe4002ec3f56485d1e126862d0bd67a30fedf00b79d1f7c33b2b9c6928f31011c0000007672f63d6d54737b0dc862fe00a4c146100e922c39e2b8349a48088d52a14bcb0c1c0ba486a22e7f949c5d2001bb19574d61c7978e7652ee0b87579836cea127d01f2b30cf13a468cdcc9e56a30118000000923d006513e9f6f37a420a38601150bc26d58e5fc2fa90ef3de096ad6faabfe8dfc0aaf0f181eb03d5e6a8f3582fe0e87bcd0a6058c60ea4087a3f30bb71254212b5bce14217812204b58dc2500115000000a61f54580c3b3aedfadbdb39930754eb59740e06878c4b21e077b17794a3133fb93de26128c7bc8558c07a701dfd34a8e7fd27c314e8200b84b90a3b8a51b90f028fa19c9b968494f1dc2a7897010d000000a7e630c41fc945da3e67a106656547bd01bb26a94664cfd9fa939f5b2189c5b215e5fec1fe83d2981940189f99f0bc5b4ba486061b76ac78d3eadd91fd75b4fff44af75302c889c6f05d3ecb080114000000a8995453aa34952a7b6a36d6668b30a5a60c552463546daf9fbac737b3afa30a9e33607a758b18ea83bf64da1564f374e6c92860bfaaaf9951489bacd7dc1e939cf8ec833a58b5f5d9e606c98a011a000000a900df280c8aae91f937784f000311185df27d367735d38819e417f272848e2ce2f08bd3b353728ccad3b745f1ce0ad43a9bf09fa84197777b874d8cbfdb6d5281e478835e656b1c25aa294306011f000000a98c40586e7e085eb8d9c5cff72b242266ed2c422950e03b3b6324c15f95a2759d436fbd36219acc6ad722cb88cda15acb23452bfc80adff6d81501ac7c2d6699fd7f19c60baf141a545fdf65e010f000000ab19860011844cbc2b934da040a0905e91cd35c37704ff8ceee8d08235a87362c64e1d3e7a56a82005512bfa53ead93ec50cbd20b316708a2e826524138a4d31cc3c156027608079226de7246a010e000000b88bba6c313f883b01ce114e6ec70d6c4e41846d16eb44e06e49d543a294b6e8291c5a475ed15351e29b983b396ed28e67e6c6e3d9bbd0c82b99aabd1bbd4522d664ab75172bf1b1dfe2d784bd0108000000e8a99b7e41ab9e02d32c6753100a2dea5017a9779637ca7130a977a957ac1f0e94b8813aa30abad4706d95bece76775b64d7969a4dc2f2e5c483768b2e8e3ca4eadca1bae00413c8a285612ab2010c000000eaf3661e56b8cec97c193a3ad4e3d5f8cb37d705a1c174c978b416d7de8117dd50ff24ec61c520e41613735160802fa2152243a6a4d5a639a236b68ab731b7b9bea06a030ae060a865135ee66e011e000001027c75a5e4f11e783325731c111a76d945df2f5614291c703b67dcfa2c917b41386bf28e1a947006a1ecafcf6e6fcb0f59214095d78c070e75feeaf63b9f12b71aa2daf423f4bb5cd47b1c1ee4010400000104ff1afc8929aa90902f74f8b84959f56f53bf85e8274d590d3793118c82b15f8072faec35371f7b62f5ef89a67de7504aff13f1a6b3928da68f276ee2b38a7e1a0697dfc2eb8e418b8ac3d7c6011b00000105ab5699c9f8fe76ddf1926a37c5f6b3e51be4eeb193a8eb2d4c28504ea1ce4ac97fdfffd7eaa24438995b6c9e47309c2170aff3521fa1bd3da88eaf651d4f6a66918ec46cf9789562160c251c01070000010a27199898d02e56af922c456e32c4a919c21c33816cbedeba92630dc6a2a6d644970fd77c8ac18fcd70530c956686f7e97ac99eb155232df3b65467fac075bf22d480eb18cb723dc43d056cd5011d00000139d670e3c5a70b07b89fa3ee670b7ba3211c8c61ba8b1cb07d0039861e81038507c58da0174ca63f45e8fa7eeb1c1529883ba24046ca56948de5172fd0e86f3b50d3ee4795a1684aa95b305be60117fc001109c7fc001109ca01fc001108aafb020c00850daffb0c2c6d85e766cd1540ab6384ef345187201df1fce9f6392abb152f00002000850daffb0c2c6d85e766cd1540ab6384ef345187201df1fce9f6392abb152f2030fcd315cee833f41272d6285560c7e738c6c0b267061d1d8e3ee7387221a09101ab35421915e3ea320ee07071957cf4cd0ecd8a0100000000005fb3bd75fb752ffc000977ff0001fc0009785300d36a190c0296d43164e19fa84c5e07b099800160b278c771d9cadb83d08cbd822125e04bf704f547b14cd2568f910b8f00de48144592d8ec9dbc809130027b568db397773d473e1e7c5a06af5254ea184be9e0e648f96969c662fb10eb6d559fcfc9ddc7ab8649e360d7db6e59000000000139ef5468acdc98c786a23397a0abc167110f46bf7a33cba29de48f7597cded0000200139ef5468acdc98c786a23397a0abc167110f46bf7a33cba29de48f7597cded20edcd97758fe49da2cb337abf460f1167c1aba09733a286c798dcac6854ef39010014315246edc109d76d15bcc5e24da55d453931860000000000ae22e971fb4e1ffc000cf03e01fc000cf13601fc000cf6cb00fad60b7fee893ef0b8a4602a2250ffdedaad6dd3ce7f101b7f075273c892063b1b8571311737a5767f95c0f808aff27883260bfaf9cfe2b84519a6b2300d4b5e1f48d7a77746676f09e2b995389d0f1c18601a6f909a4b542fccce87d9f5f30695d078a9181e142602d2e93f8f0000000001bbb58bd974fb622e39f7cf717d8942e210a84534ef9561087339e79181299200002001bbb58bd974fb622e39f7cf717d8942e210a84534ef9561087339e79181299220a3262f49c21c338fda802a6ac34fe12156d45e83bfc153b96d1631eb8b7c8ba300d5ce05217d6eb331ee3567e65e0229b5ea0d20510000000000235acda9fb4e1ffc000bb3b40001fc000bc76b0026a40a8e5da5d14302d09c58ac9ace45b54b1c5a26a40a8e5da5d14302d09c58ac9ace45b54b1c5a1ec5c66e9789c655ae068d35088b4073345fe0b030048a9403592bfa7ff82749de976c5e67a36c9d6b00a6665ae7281ec87572cd4643f15e78daa4cc251d5f2dd4611e37da0000000001f023a48ba1d046f980800d8c39b239e21d04855876700421f36e716a91f9fa00002001f023a48ba1d046f980800d8c39b239e21d04855876700421f36e716a91f9fa2026da1ea7d012875ece7ceb8e7b0f0beeb31c79a0ce9d97a2da25a2a6a7c5277b0008d98f95a7cf2eb4acf392bd81733e94c3f61dea000000000036bcc146fb4e1ffc0006567a0001fc000bd99b00b8fc46281e0f858dca3ba911af267d0ba2145249b8fc46281e0f858dca3ba911af267d0ba21452491ec5c66e9789c655ae068d35088b4073345fe0b0308f2ad27c0cb7b64b6e1aa5205f78e466b70ef61c6d529202c7b7d8ca9450d08d46234fc8aed1bb6594525d300ee931cd00000000021d46a532f0610618aa12d1dca47921623ec9db0b6397b90abe63967551bb3e000020021d46a532f0610618aa12d1dca47921623ec9db0b6397b90abe63967551bb3e20d83d93971aabeb80314062415c801838c3476d30e88a185a8fc621f45cd3c780009fb125d219bc182a771e7f3b7a910fd2c0cb5c0f000000000047c6dc84fb4e1ffc000722600001fc000722ab0057124732477195239cee3a968c4923f5f8adb96157124732477195239cee3a968c4923f5f8adb961c2610f8892172b3d1cb171d0c9bae78576b38379301135af6f4c73cd6f45513a9bdbf919fc9dcf76b18c0a3256b4aee0ed48360fa88637cd113502e4f6027232c2ed5de3b8000000000264e34848ae0fffb92a5f0fb446468fcd4c18014f66212529f2a3c585709b1a0000200264e34848ae0fffb92a5f0fb446468fcd4c18014f66212529f2a3c585709b1a206cac8d4777288a5504b95c30030aab85079cbbb9dbc106b0817459c66ee4f745015b5de31b03ba63480ddd09689f9eb5a33bdb78d4000000000012eca4cbfb4e1ffc000bb3b40001fc000bd233009260f93ba7145509852239781f4f83e02fe7d3ba9260f93ba7145509852239781f4f83e02fe7d3ba1ec5c66e9789c655ae068d35088b4073345fe0b0309532b2b80bbf0241d4e35a803eee7a70a1f6c016be57daa0602d180b7969409e8518d860ae8b9c403a36dfc821fbc12d00000000037db07b953e2196d659075376e7ba9d85baebed5c49577a898c0ace2515c1ca000020037db07b953e2196d659075376e7ba9d85baebed5c49577a898c0ace2515c1ca20661dc5aa428875848e4d049e053010747c592204575036a2505345b34dd3e0bb006cae25f986f4a1e14498c3f5a8517606a0b2b8da000000000080c763bffb4e1ffb5f7e0001fc00011b13008fa9e72582f9dc7882e0e40c932d98d3026765918fa9e72582f9dc7882e0e40c932d98d3026765916cae25f986f4a1e14498c3f5a8517606a0b2b8da308f3afb0dbbfec8610efdb4089f1b163e7f55325f6c0503470e8d49ecf439c848ff9448749e0a383980824994aa5dc50d000000000428147f6fe14b66e31c953141e884b5f7075adeea7bb8d1ec85297e594dd8b10000200428147f6fe14b66e31c953141e884b5f7075adeea7bb8d1ec85297e594dd8b120d2fa36682b5c4f47ac2f5b75ad137997110f677329e8b66cfccd06df324ad897010e421caec046e5b6106f222d32d987b094441a6c000000000040b0c6a1fb4e1ffc0010ddf70001fc0010de2b0022e16c08c8f80616d040b0dc6cc6ec9bc04b467aa2c6189093918db0942b8ad5c215989cef4d367cf440eb4f521312677cf98771dc52789eb9039fc3308510cbaaeb8d82f2cf1fe1c6e6d3e7fe3d9e6ef58a5cf1c135a0d39194c457fbc8921dbcda07fce72e6aef5b54f9b06000000000044b879c7014a715eb1bd98c79e6137f45011a0cfe3d21b24edee3c1650eabd9000020044b879c7014a715eb1bd98c79e6137f45011a0cfe3d21b24edee3c1650eabd920a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e182c84bc3be703bce7915fd9e65780589f11d9e708000000000023a59c9ffb4e1ffc000ccadd000000cc93037f5cdf14ebd273fc3d4999b9cdf81865d9cc93037f5cdf14ebd273fc3d4999b9cdf81865d964f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730002a2e19ac4b986e20f55ddb19cdfa69cbd5f76c5e2d66ac6d9c8418aa1f0836e61b643bf48eeb004ccf3f3f0f03b82a00000000045678f95d95679868cc84d96299a0b58e123e9c94088e10ae9fb54ec93bf20a000020045678f95d95679868cc84d96299a0b58e123e9c94088e10ae9fb54ec93bf20a200af23bc94eb59fae108e08949c3e128eb5a09962d984cc689867955df978560401457e250622793189bce9372839a4be7c32717f42412000000045454445fb07cffc0010644801fc0010645001fc001064630013cfc3d991d28803909680da446febc9d5b51c74542a58cb756c3edab85a715297c77ff4e02c9bcf42b5c40299408be68d22cca757ef58cf74f77c9f3085a8e547858c3772041317eac7dcd53f61fca75a5595870b44081a6bb83e78d28c397222c3c2b3015e651e163f62880b000000000569ce8b1a5fddf85850b5415b0435c46e198a8f146b1344bd618c8fc6e9e5410000200569ce8b1a5fddf85850b5415b0435c46e198a8f146b1344bd618c8fc6e9e54120027869aab3935227b4fb89499f881af9bc48c20157d1d897866e21eb4b1c3a210168688f2bafcec3f41d3c087722fc60e45a7dc96700000000010000000000000000000000000000000000fc0001653b01fc0001653c01fc00022f9b007dbc4d6ed0c5a83f528d03638e7fd3ff633a8e4d5a3086c1c6e57c19d3613870421059d308d5b16fd7c588a531c364e9462b46397e5dca10aa10dd9d300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea800012005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea820593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c093de7795dfedb896cb65547535ed92f27489d8df3000000000034187ca2fb4e1ffc000cf99e000000ec83a5f23ec17737f590153eb7eed16f7b2f1327ec83a5f23ec17737f590153eb7eed16f7b2f1327c69a0bda7daaae481be8def95e5f347a1d00a4b43080f8efb42f65ed9650078785be5d13e6e90eb9df87a99261d4de34df2b4b79a9c9b8c5e1aec7ac068ebef14636ceac4c00018feb00404d6f765856c95e587b2523a365bc725801fb8f3001fb05a30631c61e2ebf3d2f3b5022022b304492e935dfa25f9f52d13a45b448a61dea4d0000200631c61e2ebf3d2f3b5022022b304492e935dfa25f9f52d13a45b448a61dea4d2057468a144f4909b986f268cb90e353e7ab55b2c5ae55718362760a3afcb2f7e4002c89477d74bbf943461baf67ad023440a6c585ba000000000074cbc507fb4e1ffc0002d62e0001fc0002d7d400383f1034f0693df2fc8b166d242b00917b7fec07383f1034f0693df2fc8b166d242b00917b7fec072c89477d74bbf943461baf67ad023440a6c585ba30186053ffd90c84db8fb369e1178492b3a0a3941d33c43cd84b839d92668203b6501c786486083eff2b229cec3e0a190d00000000063b57f59d1ff9847f08a7f06d14a5dde1686cb43b6269e2500b2445f83aea7d000020063b57f59d1ff9847f08a7f06d14a5dde1686cb43b6269e2500b2445f83aea7d20112c24c30b2452394fb6ab5c0f9102813f19bc4e47066079329c150b567bfcd3019e735807e679a83188b4ec1b3b65192c62d4bf0000000000002d4dde3cfb4e1ffc000615a50001fc000615fb00766423d2a57121314b7b8dbea06fb83e5bb32d57555ac4d7829d25f1fb6c3abb84a180f5cf746f3e9e735807e679a83188b4ec1b3b65192c62d4bf00300c1c54b5377e920076f2fec26824a5d15ff6144dc106185a614e60fd9722d7577609ae202168a02a50ec45e01f5b7e6b0000000006a45723cb72c6dac0d839223ffb9a9ebba95d257a92537dcb7baada7fa744b300002006a45723cb72c6dac0d839223ffb9a9ebba95d257a92537dcb7baada7fa744b320a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e40841087a740cb6221d73791c04f925366d62815ad0000000000235ac1a9fb4e1ffc000ccadd000000eee87111a02be65095125160059b010ac7ca3d30eee87111a02be65095125160059b010ac7ca3d3064f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300e9855b2ee991f988e446b60dcd637f33a782baf1e755785ca058f0398133bf3a95e4e77d4168c13c47d7e3fb1e3ecfc0000000006ae5ed69b8a8eee0cd37f7b642989834cd1e139d1aa9de23db9a627c2fb95ad00002006ae5ed69b8a8eee0cd37f7b642989834cd1e139d1aa9de23db9a627c2fb95ad20ef3191fca4f21577e7acf2af43a36ad7f2fc0112c86ecc24e9985136201cf8b100a84773e6457d1e33d424b397108e9f462aed85cf000000000034287e22fb4e1ffc000bb3b40001fc000bc76b003db48f21a053984465132097e8e9e8b049a3d0133db48f21a053984465132097e8e9e8b049a3d0131ec5c66e9789c655ae068d35088b4073345fe0b03019bfb0fe221451734fa025e4c778fce35e56f89a1595df9cb6c0f94b76deafc6ec438c83834c9e9cf3363ee48d749c23000000000742f64ec887a0ca73a4bfbce78eb34845cee638ab574921ca260f8e218f34d10000200742f64ec887a0ca73a4bfbce78eb34845cee638ab574921ca260f8e218f34d1209602ae8d8c7e8d90259c444837e3f7bb39a5e6b4f1b2cc2b963fd42cd6b23d6f018125767a2e37003a592c97e8c4522269989e236900000000004d173304fb4e1ffc000ca6e001fc000cb48f01fc000cb5a30071a28ebfc5b60e77b6e5b853f8e0e47dfd21bb719fadaadbe9448ec9a703912e80e3b90f36519de2b802ee81026bdd6abe5b6296b993c8b4c02cbd153012271e7f58e6f7d3e2b7bf724729808642a16369b4ad22de438ed38df62b415a92bdcbe7923a858532eeedb44bf12c120000000007d22e8dadd5aa686a7b3bf833eb9bdddf4aad71a79992cbb99bf52f1e42609c00002007d22e8dadd5aa686a7b3bf833eb9bdddf4aad71a79992cbb99bf52f1e42609c204dea6406996a98efea88a66bddbe7f9568093185b08c865b1b664ae0e594c7be09eaeb400fc58666b81179de7c181cea9c63ba55f400000000010000000000000000000000000000000000fc000cf6350001fc000cf8890086a16b7ebc0c836151f6fcd1d21594cd050180bc86a16b7ebc0c836151f6fcd1d21594cd050180bcc69a0bda7daaae481be8def95e5f347a1d00a4b430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867e1018f1de184690af3586fc3b4e17cf61614cd926532cc13f9ecf12445230000200867e1018f1de184690af3586fc3b4e17cf61614cd926532cc13f9ecf124452320ba2a81e3cc15c2f44ba26ed842c034219c7070a07e03ad29f6177bf1afa0f3bb0171cc985fc2a69592a7be596af81beded7b914ad00000000000a516d595fb4e1ffc00025b4601fc000266ac01fc00040524006de6137f220482eab495340caf21f19261b1e8416de6137f220482eab495340caf21f19261b1e84186cf2c5c943a6d1d8364fc87e8d859f86de1524030881cec3eab18eaeb916d3f234fae24363b68faa705f51a6efb06f83adef70f73fe28ee70bf4c8300ec4f77f017dbf7f00000000009214af325b2129b52873d9e42fc94ac127aa14da17b1e579d0bee746739136c00002009214af325b2129b52873d9e42fc94ac127aa14da17b1e579d0bee746739136c20aeb90c01cdc9753256874b7e3c8dcd88388b4f5a180608b6a84fb4b5304ea69f0091e45b373304666fd45136542848ca9264f1be72000000000036d4e686fb4e1ffc000bb3b40001fc000bce5b0075400fca445584e71127ad1393fd82a37a82b60a75400fca445584e71127ad1393fd82a37a82b60a1ec5c66e9789c655ae068d35088b4073345fe0b0308d42f142045c5ab515ccc12f2ebbb43f84c822cdd8f98eb5e707d3b334c45018e40b1e2701fcd42ee1189bba2d1d8894000000000ae71d42a6b2956f22a11d20e12dbe309a20fec575aa6023b983fe1b8976ac530000200ae71d42a6b2956f22a11d20e12dbe309a20fec575aa6023b983fe1b8976ac5320eb475a0049470e4629de778010cfc0b305e70d7c5ff6e6731398e26b8fa9ff98018caf465181f5759bf9aa46aa56d8acc5666e460100000000000d3be7c5fb2715fc0003a9520001fc0003a9d300b0bd96751e06b5f3f3bb00dbbeab1576fc941f5fb0bd96751e06b5f3f3bb00dbbeab1576fc941f5f0af0fa3c6b4cfb31f4667e98c4441ec4a72c635e301438959163472114ebd0f4e72e984527894a871063cefbc8cc492593a7afbf4214538c0618ff8477590f40a3b2155aee000000000b4b33aadb8095af383a8c9c5e63750b8ef4abb5d9c091360d788cf18267fe9e0000200b4b33aadb8095af383a8c9c5e63750b8ef4abb5d9c091360d788cf18267fe9e2032048e6d7e2751d4029bfddd77d06ea72c07fffb2d2a67b73ac1cc499fd10cf9010363c23a16386411774051c4dcfd52af186bfe1e000000000091efeb11fb4e1ffc000153460001fc000241bb009e1a38143b4dffb85126ea5a1d78f957327ddde69e1a38143b4dffb85126ea5a1d78f957327ddde62588a17ab3f917f19afeb8c32fa7c486ab4105a33011d05fff5f406fd207bc8984188894b6bbd32098e58244136519a51c183c70db3d713a33c9a55f8d6993f644fb34ff2d000000000b53cea62f79dbd8b43ef803b9eb1d47a1dec3611f460dba83ba9dc32483f9c60000200b53cea62f79dbd8b43ef803b9eb1d47a1dec3611f460dba83ba9dc32483f9c620eb2272deb86efc72e1f06244693d51f169c565fd32bf3d84125ce3f6b5df327000a1d87fa55ec32af91687a166746b992beff2c41000000000005fb3fbb6fb4e1ffc0004c8340001fc00052d9300eaa8b45af937c2eefe766f3bc3ab753329aa4438eaa8b45af937c2eefe766f3bc3ab753329aa4438382477245731a85b4a1b2ca6af9e904517d07e973090403255a5c2aef92a899cf01080a78446f07e0a25fe391a81791c37eddba6e82aee9b8b86b7aa4f44129637146221c9000000000bb4178501da3646c2ac908c25dc6d890bcee788bde6b8391ccde7c6486075900000200bb4178501da3646c2ac908c25dc6d890bcee788bde6b8391ccde7c648607590204e98d6d8591e28eff43f5b3d7b8577a632df86aa7b9705eede76fdde90544c5c0141307e80a8d668b0bf3cc98a52f8d85ec8cf5ae2000000000074ca448efb4e1ffc0001fe8b0001fc0002ab7b00408fea2918afc5688ce5093b789cf08823a57ae1408fea2918afc5688ce5093b789cf08823a57ae1c0a84112810ea249524c9060518b76dbee8b86cd308ef072018a444bc1f30885a199087d2e2200ea31acc4659eb0c05cca30f83e4bd940ed27873458fb605c92556883933b000000000c807e5e4c96d56008c2e3de266027c7232d070710868e6751c2ff907a4dba970000200c807e5e4c96d56008c2e3de266027c7232d070710868e6751c2ff907a4dba972087b9b1f14a8ab17354e7504b46b9b654a7e21975f37d4bd3cdad9b6f58a1beb9010c45984a63e92bc430d99a4ecfd2e715b56b8e6a00000000006b9679d9fb4e1ffc0001939c0001fc000194ab00d3f9cdef09c63434024f1da8554f5d0ea8f2c0200df5db4ce6161b24565f0e90a154cb4e38751eebaf5f151f150e533b675c159dda83d2cd6b22c89030088f0bea4590c29e0a8657faea9d5f2e0f79cbe8f1cae3cf9111e84ecace1443ed8dfe136c539019684d9511d1bba807000000000c90176ebed8489ad010c0429751dd46ec7463589ae9023795cc49f98274f8520000200c90176ebed8489ad010c0429751dd46ec7463589ae9023795cc49f98274f852200237cc9e407352476436f36492b64e09d13d7d6acd6725965f5b368fdd55d13c01308e3fe247704d2b44831bfe98d6421c6880e5d241a0000000cebd93f0fb4e1ffc0007675301fc00076a8001fc000af0bb009ce9b000c1432c3b5ad66db07c99e97cec08e568e1668a2c23b7a257d3e1acfe926e7fb5d64b24ea022d6bcddcd53b3ce77c5afe910cad2e92c3cce4300128cccd87ee9fa75531c9d8db129ecdec0931b57d3d521d35df8af82f6972bbca75f3861faecd3b701bf4aa678b18e5017fcbdbc8ad21929157bc68c6ce50170f41bbcc5d0000000cb486a3f478e2baccb3bc755f87b241e9ffe05dd693ba92e4777dd2175b5a160000200cb486a3f478e2baccb3bc755f87b241e9ffe05dd693ba92e4777dd2175b5a1620165a5b17d27d77e492ba93d65de0ffe941b2875f75bcb3ccbae278f4a386b40c00da952b3b45775c0af85fbe2e2ab21549d86beb0a41000000010000000000000000000000000000000000fc000541050001fc0005410700864b42ecaf278c146420dd46bb2c4914328b38827200be0fcbcb2c10e968ea0b5508bc3424c9c68bda952b3b45775c0af85fbe2e2ab21549d86beb0a30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cee39f44c73a6e829fe53ee34a37ee4358ae31c2bbbae2877949ae8729276020000200cee39f44c73a6e829fe53ee34a37ee4358ae31c2bbbae2877949ae87292760220a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e1a2dd7c9995b2e03f9795f30ba18c95833f6ec3eba000000000036bd7debfb4e1ffc000ccadd000000b73068d00c048915c175450c366478f783bc455bb73068d00c048915c175450c366478f783bc455b64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730880f24b5e040dcbf86c3f468dd28bf45d9e41fbcd127fad56669d9afe358dcdc26e42f0f8b19997b1741dbb99c553aa6000000000d20e20e6a7ed1999b25f2dee0a53893a462e92170bc13a8b321f25c87d997280000200d20e20e6a7ed1999b25f2dee0a53893a462e92170bc13a8b321f25c87d99728202897d9875cf221b3a813bc7021e962a49338a5e0def2259b99d17e6a0ee2200d019bec606b655f5b5bbd68207755e614a79dbf4db300000000009f4145f5fb4e1ffc000129d80001fc00012a74008442f1717c0be09dd835dcf2e7383c9f1bff46c93e6504110505f16171693fa5f8582c03d7e0450a9bec606b655f5b5bbd68207755e614a79dbf4db33014bf71456476fa02cfe3de9735eaa10513e943db4576667128051f34692ce042c90cbb9dbb268d3ebf89205e5c8e2afc000000000d685a3c70d983d5668e63e80c3a756b10e19228d943fc478bcb9e2e37f97ee20000200d685a3c70d983d5668e63e80c3a756b10e19228d943fc478bcb9e2e37f97ee220cfafd40a2b9ad8fd3ace89a7a408dfe19b93696d6ced7957c2b424937849540000b1317409f33b2b7166f3e3f0651d0c0b93c0e86000000000002359990ffb4e1ffc000bb3b40001fc000bc7b3000d0cc1e8d68b1d6dc7b746ca1dae2a99a5e252760d0cc1e8d68b1d6dc7b746ca1dae2a99a5e252761ec5c66e9789c655ae068d35088b4073345fe0b030989e7cc1586c9cdc8c55cdcf122ef91481fa3d344fb313c1909d3a70e675cdc805378116b48829d287c8e27792c7ea68000000000d862fc048631f81cabda9446c5f94c8c9a559d2107db383379697381816d66a0000200d862fc048631f81cabda9446c5f94c8c9a559d2107db383379697381816d66a20818115fe0e0e7d78b05f07f774480a6e1e7cc609f071e3aa4d7ce41ba05a7a5e01eae7576cf57e066d9a46c1fafd95b339698687ff000000000074cbcc78fb4e1ffc00044ea30001fc0004c97300a86191b01824b41f452f494a6d62026fcfc373f7a86191b01824b41f452f494a6d62026fcfc373f7eae7576cf57e066d9a46c1fafd95b339698687ff30028f3d9ff027351da67047d78254333d5430c022f800ce5530835d1f048721a82d87bfe959b74aa447908e3c3cacb63a000000000e5ed7d2e33f2e0b221648c3f99735afd6762270ff6a35978df389a7f82976d90000200e5ed7d2e33f2e0b221648c3f99735afd6762270ff6a35978df389a7f82976d920a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e6ff44b8561fe1997ac3bd7d42baa68bc1e2d22e77f000000000036d48a4bfb4e1ffc000ccadd0000007d0138cea5135b7e0d5ff96c57483eb5c155f1447d0138cea5135b7e0d5ff96c57483eb5c155f14464f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73001f24418ec73b09b00514dba8fb18d6d8af1dc2ff93d594bf987911f3b98d659eb43286cd450b7e1ee5978b361660d73000000000e72e0c50a6516ce833427d6100a83eb6f3e0e80234e126fdacf96aa669e206c0000200e72e0c50a6516ce833427d6100a83eb6f3e0e80234e126fdacf96aa669e206c2059902572f2a755ca1892ad551bb5444b4de7be0df294e2dc7f2884940d5f21eb008c7a89bc1f8f97177251dbc8aa45a53e83f7734a0000000000ae22e970fb4e1ffc000cf03e01fc000cf16701fc000cf6e30060800eb548f8267927a424fbcc75e67aad0653bfce7f101b7f075273c892063b1b8571311737a5767f95c0f808aff27883260bfaf9cfe2b84519a6b2308d29637a7883deac9d725e72cc5a1c366ea0dea49bb61dc118d2c2afe7f0916ac7b2516a4ad4bdbe7dfe68533867a866000000000ecf23a896fc8062fc373acbe0dc218c508e3e6fb0bf6d3ac8cbb3f09edd3e4f0000200ecf23a896fc8062fc373acbe0dc218c508e3e6fb0bf6d3ac8cbb3f09edd3e4f20dda17bc4e0a6ddb04f8a833c1fe9fb3aae484bc435452fd8db27cc90d0ae2511016de8fd61834a14f28d1981f188901bca0c6150a3000000000036be1b70fb4e1ffc000bb3b40001fc000bd20300e3ffb4d81895df6f9c29b45115faa19327a44d18e3ffb4d81895df6f9c29b45115faa19327a44d181ec5c66e9789c655ae068d35088b4073345fe0b03085960dddf69493f1302342857508ae1d2f02441ce7d43336d5829fa868e80ed94d77a0008ffe76b16354067952aa5b2e000000000fbea7792604319890cf39e6afed9e0866f33c38bb56424cba1cc27ff462f9470000200fbea7792604319890cf39e6afed9e0866f33c38bb56424cba1cc27ff462f9472047f962f47fc21cba4c4256bb383cf366089eedafe639cf909831042679a7be0f01527cd9e5065a523e44a8e9135c9274a6af6fe19600000000010000000000000000000000000000000000fc0001a34c01fc0001a34d01fc0001c81900ddba67c250a9c4121d546702cc9d29f65007c855ddba67c250a9c4121d546702cc9d29f65007c8558602cef7812c9171873346962583e161da2a263b30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001123e20847f3690fdd917393ce5fe60a64e3f5900cb167ca31a605683d06e70d0000201123e20847f3690fdd917393ce5fe60a64e3f5900cb167ca31a605683d06e70d202bd1a8ceda027ded8260ba896392d67b5cce6d04f0c9c717e560b5d72335816c004551586144b293cb01564f408f51f778a92730ac00000000003695858ffb4e1ffc0006567a01fc0006c05c01fc000bd9b400309f13210e37d13d130867462ed770f7a6957d8a309f13210e37d13d130867462ed770f7a6957d8a1ec5c66e9789c655ae068d35088b4073345fe0b030154fc5a23ca644b5d085ba1fd39eb6d18e070e14a703de84dcdd54bb37746461f5db2f0c949cddd6e3b225029a0342ad00000000113f86cd2940e9638cf59e9e06e9a73aa132b73c78b8b39c28ae2544ab765979000020113f86cd2940e9638cf59e9e06e9a73aa132b73c78b8b39c28ae2544ab765979202ad2e62e05e11789b21b735f21cf420f5410c0e51b163ac218a0ce6620f5a43400d0047699d8198a6066f90ea2f04011d359289e94000000000012e76fdbfb4e1ffc000113a001fc00012e7d01fc00013fec004daf7ca1ba224384b1a8d0ec83d87513ef08b120caca93fb8cc121ec6183f5cb288779a519cff814b2334b22379811352d9988876a6e586d975e7329309273016bb92b9101798bdbaf656bb14f47120241ff9c76d2650da9e399edb4f7bde8238b260a3bd935609e15e2a7c4790000000011de79269062f95fcf9f5185e33736819af5d1f83ff06589016e7992f9a76e0400002011de79269062f95fcf9f5185e33736819af5d1f83ff06589016e7992f9a76e04203363eea84b7a41211f93a8ea4fe121740ff396ad1a8c91ffe36e350930bbc3b1003623e2c434132d7cc18a2473ef9633c9b814f8cf000000000012ec4499fb4e1ffc0006568001fc000b9be201fc000bd4a30068c9612622050d25168f8ffe4f6b6819f7e4817768c9612622050d25168f8ffe4f6b6819f7e481771ec5c66e9789c655ae068d35088b4073345fe0b03002986699f0f7767bd666ae5087aa0c128b41d2e883c46ddef6e4abe8cb7ea470a2dba2a67e93274818d75839a9e631010000000012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a200012012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a2206793cf0a4aff111f1d61a13002686c066afbfe5da974cc7dec8cb4cef736dd8000542bd8c9d87e1cdd3db777d29c35e9903b17727a4120000000d4186795fb4e1ffc0010903d0000006e52a40d2dc4dea0ae7ff2b299283de0f2798b0a12deb4ca2b5a05b6eb2ab25bb5fee75d3287b3df0d5bcbeeb459af40f97fcb4a98e9d1ed13e904c8308a3dbdeee728fdec9cea3508c19ece8d2e8330b666e25666b1766ed5f44609dc8674dab4163e8574f4adf2e936a209d501c623e2d926af5eb52dcc2b931993d3e52714511801c1161c96de3dae28cd7f20ff8c2aa7b94b866d7601fb8f3001fb05a3138195ab6034f5bb94cb48fd7d46406025e17e49f41df40efa13aa0c40cc945a000020138195ab6034f5bb94cb48fd7d46406025e17e49f41df40efa13aa0c40cc945a205a94cc400caa13fa0ef41df4497ee1256040467dfd48cb94bbf53460ab95811301dd55cf012dea9a2f7ebf0237de0b9221cbdc4026000000000023e6538efb4e1ffc0008e9e701fc0008eb4e01fc0009b06300a8f3150f40bb0cabcfae79e98faa3d9d855d9f27a8f3150f40bb0cabcfae79e98faa3d9d855d9f276da7526423ec9db134526f944a3dc9a050d347ee300d554f8bc61403a96326c47b95797ff0ca91971a73f50b9c95837b912d8f0c191a85792f7ae6106fbff7e51d50818b180000000013b50c43c05e0841efa73ed52a2e5e7fc4790bffed05733243927bca596dd7d700002013b50c43c05e0841efa73ed52a2e5e7fc4790bffed05733243927bca596dd7d720b2a32448a7b0ce9868b350e12c6d0bc2ac0869659c31c8e3b1408ec253b6678e00d2962bb5abd70b77f3f33e3ec87f9684c0a0688b000000000036ca6038fb4e1ffc000bb3b40001fc000bcbaa0088b9b93ab35e81bf4152890bd22abfee38fe60fb88b9b93ab35e81bf4152890bd22abfee38fe60fb1ec5c66e9789c655ae068d35088b4073345fe0b030199cca14db47c035d175e38902dc1e3a25d52bc4ca982e4d6aa380337ab683c941842d01e436f66a746c1da20168da9600000000143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113000120143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f11320593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c13838ddf0c05bbc0edebee7e368f4dc6306d524af2000000000023a417f5fb4e1ffc000cf99e0000007395853c0be5fb0f0348aff8128979368f52b0ee7395853c0be5fb0f0348aff8128979368f52b0eec69a0bda7daaae481be8def95e5f347a1d00a4b430b928fa4e127214ccb2b5de1660b5e371d2f3c9845077bc3900fc6aabe82ddd2e61530be3765cea15752e30fc761ab7300001b5f25f8f70cf8d05c2d2970bdf186c994431d84e01fb8f3001fb05a314bd7ee89d452d76d524dbfc31b6f2526d7c904a8d7bc1cc70d9e3e0b3d47cce00002014bd7ee89d452d76d524dbfc31b6f2526d7c904a8d7bc1cc70d9e3e0b3d47cce20a1e78087eb631164b217b6efe4fbd23722765c2ddcab903537722d183b12610a00a444ea8d94ff116c8c8363a70aac7c27a224da9e000000000022de350dfb4e1ffc000bb3b40001fc000bcbaa00fad0b3a1008363b74993501effde3aa3760ab6e4fad0b3a1008363b74993501effde3aa3760ab6e41ec5c66e9789c655ae068d35088b4073345fe0b03017288f1886c1f8dcf1d1ca73d4586fc143b1a8abd1f438a3f592b17f35f942de3ca9acc93f18cb3f4ba82b12d6313cc20000000014f2f481ca295a5bdb3e3d7f50ff87f205230609c53989da809420b874a17f3400002014f2f481ca295a5bdb3e3d7f50ff87f205230609c53989da809420b874a17f3420d8c62e2deee0738b5f0f896655ea8acc3f8c0cdb486831d94cf221a13caad545010f3771e69d7faf4ef340696fe5074743a262a6c900000000009f59898ffb4e1ffbc4230001fc0001950c009b5722d68e5dae3988ab71e01497235c79f96196a2b7623bf2c1186d629fd3234b1d058a1ae5b372b2334b22379811352d9988876a6e586d975e7329300871c91beabf5c3b98cdb1009763d03f62550e676d20b54c3fde7e50ba97e54b1cd7bf83909932697fba7627a8e583e50000000015d1b166ff3603d1a583f028e9a0b5334a48db7f3272ea2e4d101306e353f74800002015d1b166ff3603d1a583f028e9a0b5334a48db7f3272ea2e4d101306e353f748208e8e515f7025352e7c608479e413beacf0d95cbb964b47e4a98fd27b6b6b628a5be2e173478997f5d3a3289c84783714de82779cd10000000000369ad3f2fb65a6fc0005e6990001fc0006573c006b78d97d6d777cdadb430c72745d53aa169eed8f6b78d97d6d777cdadb430c72745d53aa169eed8fe2e173478997f5d3a3289c84783714de82779cd13018e4c1013002f690ead979628cecef981034bf9277813035637c376ce9dd04b1b379c4abd45bc5ea969a894fa0d0ebc200000000160120d0aa01ae90e2abb2791a313af326274536f930c95e393959598f29c636000020160120d0aa01ae90e2abb2791a313af326274536f930c95e393959598f29c63620a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e192d7ae4aac5e298584fc2e2eddcf2522ac3b8e3b5000000000036cabeb5fb4e1ffc000ccadd000000ae2c14ab7113b1aea921177e509bc59048556b97ae2c14ab7113b1aea921177e509bc59048556b9764f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730066d57a6451b7800c1c2a6c6e04fe73ec2e1c95e492bacae760ad2f79ca3c30727ec9bf0daea43c08ff1ad6c2cf07612000000001645a3ebdeff58bb478421fe8e33119d10f22f238c9270a1e80ad46fcaa188a40000201645a3ebdeff58bb478421fe8e33119d10f22f238c9270a1e80ad46fcaa188a4207bb3153777f087f2d3c88debb4372f695aed7e3dfd3efca720e8cf4ef14cfd3e0079e8a0e8b5ad86975702bbd7f192c9cac1104292000000000068f8872cfb4e1ffc000628210001fc00062e1300dec4f1bdf91c23a8ed56738a32f2795855bc9827dec4f1bdf91c23a8ed56738a32f2795855bc98270e5c35f6bd12cc355ab5cf466721bb948e46afb9300a5c47983c44aa99ce5f04b32cfbdff42e7f92b1410558559dcbff3ca8aacc3c2fcaf05db6f021a9f335ba05b9af4c5200000000164730f2cb1a5e6660e77d03c2a4fbf4e9dd23a0798fa7697bcd0aae145ec3b0000020164730f2cb1a5e6660e77d03c2a4fbf4e9dd23a0798fa7697bcd0aae145ec3b0200e1d20e176856da05c1af552bb3d15182d45e15962bbba97702537dfaa8b51b00179f83ea215fcf6ad17a7d147199dca75723dacb600000000005350e2ebfb4e1ffc0006b25b01fc000723fa01fc00074c4b00ed358f1398a3cf37e1b3131e7c492161d6892789d593063ca9a226192be390d6841d9fc28f33818c9602f50d8a498a04e95c35af3c2545ffb074865030874a5fe9d0a2d7ec3ce741fa441e2f9a2f1726fbd2d09a000a6dd4828bd4951a82b0bef934716a40d0ff36e4641f9378000000001659e06c825212c9b11325760a18f6ea06194ec4efd603f03d8704f23d818a6f0000201659e06c825212c9b11325760a18f6ea06194ec4efd603f03d8704f23d818a6f206f8a813df204873df003d6efc44e1906eaf6180a762513b1c91252826ce0591601c274b44875713f1f7107b98c82ec14a3738e36d041300000010000000000000000000000000000000000fb36460001fb364b01140b2fea5ae1aa7e6b8ee68a11d2727663397163595d9f40d00a7ea5cca2502a1c5bc47706688c42c0ee80d8e78d59877e5ca6fa6d071f2bbf3037e6300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017013c34733cdafc4feb7f317587cbb891b1027ded099e2dc2e8e1da05ad0f4200002017013c34733cdafc4feb7f317587cbb891b1027ded099e2dc2e8e1da05ad0f42208e8e515f7025352e7c608479e413beacf0d95cbb964b47e4a98fd27b6b6b628a21492077ea3f2aae501b0dfa814c61c5626c09a614000000000034d41347fb65bafc0005e6990001fc0006576c005caf3605e05011b3abef72e467ab5334e74d68635caf3605e05011b3abef72e467ab5334e74d6863492077ea3f2aae501b0dfa814c61c5626c09a61430836747d419d09200e404aa3500fc5d51f044fc01fd1a9f452324c8c14ab90ccd75887b6bae1599cdd458e738a53587f20000000017454490f2e0d86c39e8d0981b1d1b67354a96915a5866c527ba06fa08b43dcd00002017454490f2e0d86c39e8d0981b1d1b67354a96915a5866c527ba06fa08b43dcd2059e4a4ffb2097f50e8636da1d9fb7b58400563bb19ffe74555b42f7581cc2b74006fb36a0176a614d53ec1402019421234316f9d83000000000036b8f747fb4e1ffc000bb3b40001fc000bcbaa00babd4d5499f8186f8b73cba064eb0cfc4deff4f6babd4d5499f8186f8b73cba064eb0cfc4deff4f61ec5c66e9789c655ae068d35088b4073345fe0b0308fd6de82030e06682e2e65de0fe7efe2edde83f5f96c3446716278d240e0bffb9bf33df3d64d36b9cc6649da7bb0b41b00000000188b4f3700c029d93de43a0e865b3e2e800c3bc67718f8d213dd111a9e401cc2000020188b4f3700c029d93de43a0e865b3e2e800c3bc67718f8d213dd111a9e401cc22068cae611582070c7859ca4ff173baee189eae61bcdd27be131df62a3a630d34901d13ab9ef967f44ff97748303c21e421a7f80974a0000000000761f230dfb4e21fc0003c37c0001fc00044d830039935d16dd5f12eb27272a4190608370e212224fa7755e80caba03e54606c89f955d1d4b9b85d91cdbfeb2a85d70b0a32d9cbc6f4b8f1ba6e375065d30831193814d5cddb0268d276281ff7356b9cbe560bbcb6c9c55f12a53b0dfdb60ed5570c9c4bdd39d8a0728dfb2b0596f000000001910a0aa60c10475397dfc5507a1d765070f96efa15e7a4c6ee559461b23ec8d0000201910a0aa60c10475397dfc5507a1d765070f96efa15e7a4c6ee559461b23ec8d201cee1e4ff907fed96b4079561103d57bda553019cca81d84d0f749c60a5da59c0170f9622bdffd2cf2aa9d2e54ca97ae74ff19b54200000000005350cc76fb4e1ffc000ba06001fc000bbb2d01fc000bbb6b00a2e7118000386185b278ec3d5304db462f23cc55a2e7118000386185b278ec3d5304db462f23cc5590cc3f0be1a150f59168adb0236005438c282f9d3090a2a532b28ceb661521902ada94853f1b90c1a7d13d8ce8a40ebec6c7a62a4e22fe5c1019e278750fc93f6808f410d3000000001a5889046c1a29a03a8a40bbe26da1539d1abf53f9b846857c7fede4d5e3926b0000201a5889046c1a29a03a8a40bbe26da1539d1abf53f9b846857c7fede4d5e3926b20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e70f6e92e766ee782976b3a25db2143060fd0e69c5d000000000036c8dc69fb4e1ffc000ccadd0001fc0011055b00a5c9f61e9276d9a8471b75beae8d0b91b5b1cbb9a5c9f61e9276d9a8471b75beae8d0b91b5b1cbb964f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300406e459bfd155c81f9103a1fe076f1261ee7513275d744c133c5d5dfa956b1449f173bd110bbc03673f376593f32a27000000001b34fcc8306280449bae2eda2361fd372380b9b630b272fc44f55105c58f16110000201b34fcc8306280449bae2eda2361fd372380b9b630b272fc44f55105c58f161120eb748acc6851ad16efe38875924bc04b4c3451ac244e1c979217ecc42b2f90460075fb7f518ebf31fc70855f607f7a092e8bef53cf000000000036cb869dfb4e1ffc000656a80001fc00066e7c00e922c71d669bf4aa1fe543345d67d0be170b91eae922c71d669bf4aa1fe543345d67d0be170b91ea1ec5c66e9789c655ae068d35088b4073345fe0b0301622ef0d7145ce02babddc8762f170f46d5d55c151218ffc12aab3ea9faf90dc97bf158a0fe37a3d8c1fc416bf01bffd000000001b8466759e68ad97c55c8c96a24a060a839baf8a014a7ec897ab6fee410e66e60000201b8466759e68ad97c55c8c96a24a060a839baf8a014a7ec897ab6fee410e66e620e6660e41ee6fab97c87e4a018aaf9b830a064aa2968c5cc597ad689e7566841b0138c25763a87e0036a3f5dab27aca1c85bea508e8412000000023f70440fb4e1ffc00081f780001fc00087abb0046d82dfecb82e98abd5b694ffa54558168fa593c46d82dfecb82e98abd5b694ffa54558168fa593c6ba9df01752f7015bb150fb432f598a91f8b22e3300b0a6390cd90308c8b7adc4374fee6d4c1d0f467d543dec6e306922e7e78d06ddff70e6adf6b2410cdaaf0d7fbab39ba000000001ba9b400a99c8ab19e2681db0e868814aa273e8eaa13615979a14c50bbd53f4c0001201ba9b400a99c8ab19e2681db0e868814aa273e8eaa13615979a14c50bbd53f4c204c3fd5bb504ca179596113aa8e3e27aa1488860edb81269eb18a9ca900b4a91b017c706d1b78fadb609fd92ff5929901a706c55877000000000058162c0bfb08aefc000cf9830001fc000cf99b00f74034f58c080be74bec51165c5ffe60ed1a615f96375e263814e1d54fc3297fe893dfb5a9c1a9eb6443411c39e405d2520567d4f6b041c5c550086230b006ed30975f322c830001d1b3c2e2f14a4ef35445431356f1c5b93c2eedd9c7ea24c4429d27d45f2fd701733ffd65540001f2dbd9b0a1f541a7c44d34a58674d0262f5feca501fb592501fb59261be5730f3876206a58161fa0db37e54389324519b2ffbe53a18910d63e5f74db0000201be5730f3876206a58161fa0db37e54389324519b2ffbe53a18910d63e5f74db2075fc3c877547021a42f8a7f69212d570e4b1c261d7ccbd13a46a0e4cd6661de000d1297438fe58cf5cfbba6dae5cca982c28d8e1460000000000235b74e0fb4e1ffc000bb3b40001fc000bce4300dbf20e7b2d642daebba0567c14cda3d4363ba372dbf20e7b2d642daebba0567c14cda3d4363ba3721ec5c66e9789c655ae068d35088b4073345fe0b0300c03388550cdb5148a63bd3f4ba937b05845748773dfd1adf509ab94d5c525e57f8654b723abadd85d2b650f14a8b9cd000000001bf9d1c02dd94bf4784aa6c1b959942ef6acf0ab1a8579be428b01b5fb87bc8a0000201bf9d1c02dd94bf4784aa6c1b959942ef6acf0ab1a8579be428b01b5fb87bc8a20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e0b14169d588590a243f1ca0618dd35474b06d08daf000000000032703a72fb4e1ffc000ccadd01fc00107aeb01fc00107b130083564ef2fc85085dc7f2a155a64fb5d14d89dadc83564ef2fc85085dc7f2a155a64fb5d14d89dadc64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73014e81203caa5c0cc305b5e0f3ae7a388b974a629358e4e83e50a25b2c2a387e3d114c7c82e2b23c25b65585220e63c99000000001c692349b501682aa983907516959bd6a0148c23ff9b8cbd178e1e07fd9275660000201c692349b501682aa983907516959bd6a0148c23ff9b8cbd178e1e07fd92756620a3ff4c5428133a31449bde462aabfbc9c65ac5044e832ca0900819c8a7feb17d01f32dc6faea0264ec91432ffc25183c63b695ab1f00000000002cf298cbfb4e1ffc000b16820001fc000b17d3000bdc4306178f7c576e5904ed9c0643f2faad4ae3a164232c5ce6f1a1448084d628145eedb09f01472567856cdf62ed7325c44bd7b7557e1acb330a63300923d28fcb1fb8b90bf8281f2f50b6a109f2f5b17a4e1653e193ae58980a03b3538ceb82c6b4e1e986ad40d08c63e330000000001ce233bc4e4b8104def542c9ca2929cc95b42a3bff03ce5c3035dc04cc71bbcb0000201ce233bc4e4b8104def542c9ca2929cc95b42a3bff03ce5c3035dc04cc71bbcb20f8607030e04bafa10d798515b6877c0a599fe907b1737cd0db970c8d144e82f000307a1f9ad73350c1489d17a35ceced0d0405aae8000000000023a51841fb4e1ffc000bb3b40001fc000bce4300d5b08c823b75db3900a75e36c0504619e8a47ecbd5b08c823b75db3900a75e36c0504619e8a47ecb1ec5c66e9789c655ae068d35088b4073345fe0b030880423a2ded94f06b02b66e22219495c386733a27f1ebf1d5aea6017cfe510d6d0e0479d2a5acbf410e4d6e85d7d10f7000000001d0adeaf787ed8f6f73fa936c6313ddfa2dd33ea693a2de22bc346c1b73a4a020000201d0adeaf787ed8f6f73fa936c6313ddfa2dd33ea693a2de22bc346c1b73a4a0220a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e3c6c8d7e6bc5c0d0f84af28da5ef358d40f058ba81000000000022dcaf1dfb4e1ffc000ccadd00000068a589741e0d3d06e5aae5ae008f2a8b11426a8c68a589741e0d3d06e5aae5ae008f2a8b11426a8c64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7308b7c76ec03f7ae0dc9be41fb9168906ef0d0d4de74f0ad8c5cf0a30483879b5203ae5d7c6aeee5b92998444bc10f68ec000000001d808b8e69cf109e2b25bb87e40e76593d385bec2ef26e9b0672a3c69418c0f70000201d808b8e69cf109e2b25bb87e40e76593d385bec2ef26e9b0672a3c69418c0f7202fa3b3c49a569e0b5d61aeb0dce73c34d2b267de6c03f81dc4509c1ca6d3f7d300337dde5fe7ce3f75adbda925932e38c456e59e8b000000000022aada88fb4e1ffc000bb09201fc000bb20e01fc000bb2230091755d751fafdbf3c4d1e1dc94c2bc198f7b5bb591755d751fafdbf3c4d1e1dc94c2bc198f7b5bb5a683e40cf2b717576d777fd4a81660ac6c7d939c309687b4c357c8faa53e6733e83b77b94e92d2b528047e2e4cad325810b5e4856b7ffabfdf97c825d224992838d7435d75000000001f1443d9f38273f6437fe37eb34c30033fcd51c7e7f563504c8809906e711de30000201f1443d9f38273f6437fe37eb34c30033fcd51c7e7f563504c8809906e711de3209e3bd9b71a626baac323ec5a6216882496eefb8d70c6a1ef95ee01d57659aa39012ef68619350d67f5e1269aeb7d0459317ee69f3700000000010000000000000000000000000000000000fc0001a89d01fc0001a8a101fc00022899000733464b2d4975e9739512fd74cd6747495adf2f4d532ed2827d7bea5c49ac0e1cf57d6dabe11e06219c4fe7634649826ed14bb206cf90cd20d5bc1130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f3ead0b52a6e6e289794c0e84dfe988bd88605fb987a919ea4e3956dc4791240000201f3ead0b52a6e6e289794c0e84dfe988bd88605fb987a919ea4e3956dc4791242046867d5c2d93ac83e7ad8a5079e609902a62f394b4c1858324fa459a652837f60137c49591bb612183440470cfa5065e4090d31e290000000000344820cffb4e1ffc000bdf300001fc000bf28b0048022a40c99c1a58ee5371a2cfc1079df5715aa3e1aea521fd5d9c90c17704c6a7b653c6fdd42ce8264726481a36d7c39125bf90457cd47190718d5f301641b24598bd24e49c4c2c59d027567d89f2e7315e53fabafb508e48a93b48f32525fd9dd9266b0ca4bef5d08b9605af0000000020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c00012020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c117663ee06b0b159308edf41150954372a730aa6a50000000000235515b3fb4e1ffc000cf99e00000004d65ec5142719f58e31f4510dda3c810a84364204d65ec5142719f58e31f4510dda3c810a843642c69a0bda7daaae481be8def95e5f347a1d00a4b430b6e979f20241cbb73de7451779e8e059d9cb75a74b72ea6862d7ac703dc2ac07d86cec39b6e8923b55fd54dbc6177c3a000135d9eb76397d05b43b5cd8da7ccfa8408bc89ab301fb8f3001fb05a3207d97711f4c60a23f5ba1a79bf4b86adceb51bdfc25ce25172c8a311147bce8000020207d97711f4c60a23f5ba1a79bf4b86adceb51bdfc25ce25172c8a311147bce820cb2fc1a392bb538ebcc5d73250eccafe08c96e6e7e209185f6e73ee8ffd84074001738f719112c8fb6fb5e9d66f9b011c24219177a000000000034286568fb4e1ffc0006568001fc000b9be201fc000bd4aa00caa5590bf043919888c4bc0c739482e84d51030dcaa5590bf043919888c4bc0c739482e84d51030d1ec5c66e9789c655ae068d35088b4073345fe0b0301956c264759bd857f9d78d04cc67e42b39e5296bb15f16d0350d741b026ac4a7fa79985eb63c487d91b7ac250dea3afd000000002344c8196ab9a4becdfb3a287a511278581d784b9afda234be289c85463219ad0000202344c8196ab9a4becdfb3a287a511278581d784b9afda234be289c85463219ad20e79944387083c27fe76eed01599c5c4921f40cff7a45e6b62624b97b748730ed005b224c407e486ad5d944af0e7344fd0dc3a20e05000000000022dc4a30fb4e1ffc0006567a0001fc000bdc0b00a988a44ae537e9365e8199cbfe84c453714bf3aaa988a44ae537e9365e8199cbfe84c453714bf3aa1ec5c66e9789c655ae068d35088b4073345fe0b0300d85038bf7b6e4365042c33610afbd181c0729f2107bb7e3e229daa870007757e1851a077e252405ff35373e780815d7000000002356f75f3f35322a81e5b8a37bf6ec59388408f8faa6468075ee5f4026ee0f930000202356f75f3f35322a81e5b8a37bf6ec59388408f8faa6468075ee5f4026ee0f932015842c095193a92bfc68c7b66dce922a9c3a119721ea0f0131727a1633bb982f01cba75a1c4d696337d08874fd92650aae0b7f8226000000000023ac3458fb4e1ffc0003844b0001fc00048ffb00dfeb04f9a4566f877926da380ff6cd983f693747e37b26efc667299ef749a8ffb5a2a64bc48c5236315fddab967ae28ddfb91ddd515c7b89bfeaf2ee3005d35fb7ea96c707d0bb6a9185f575596285d3578af73d43d2940e6ba7a39a60ad5d3a6f5df16449e4f5ba1cbd8306f60000000023dfd9ad3215287b8e08973b049a55a3024058390e1e9c338c98c967e6de38f900002023dfd9ad3215287b8e08973b049a55a3024058390e1e9c338c98c967e6de38f920b6f6b4620ced1393cbbd57400b11c84142d66c9ab6553cc5dd4b21e6add8c96801a62279c8b16cc1c8e38faadd5c7d146e67e5bf3a000000000022db3f31fb4e1ffc000b9ba201fc000ba67d01fc000bd4a30078ef25845ce006d5f5fc3be9773e2f57282f4bdb78ef25845ce006d5f5fc3be9773e2f57282f4bdb1ec5c66e9789c655ae068d35088b4073345fe0b03014e98c3260409c144f2ef15607ca1677c6eecdf723e3f7c99b25e0f561d4a315d25b702e9153524446b0a2514bb09adb0000000023f239d376d072dfcc083c6e012b1aa149a3ab66cb8bd524c2a00fd534a5d26100002023f239d376d072dfcc083c6e012b1aa149a3ab66cb8bd524c2a00fd534a5d26120a83c3da02e42ee3c9c13e27ec391c97a43f6fbb59ca6dab3086f6f6f2180565601f2b65c96c7febf32ea46461feb1b1c0d00516b6e000000000050f0182cfb4e1ffc0006d4c101fc0007015b01fc000701ab0091cf245e465930b748480cf54da8da800e8b49591516fc10404fc6199c750577dabb9f26800c86525748d29ccddd0db9317ce1f8c3f4b8ac69731c4d3094b3e11094b8781908d100194fa8b47659c2ee17720200f9fcdc2804c557d219e87eb68fb0e6db97822f1f73ab7f846d00000000246b31866af114ef8f6d7146a68bf15004c1dbcc7229accd1ad81078547b4d96000020246b31866af114ef8f6d7146a68bf15004c1dbcc7229accd1ad81078547b4d9620904bca9accaa1c0120066b43889cde3737f885679baecd956cb34caa1523842f012aec349ad1f39b61c6116b419d98d1ebfa980fa2000000000022d934eefb4e1ffc000bb3b40001fc000bce2b0057fc65161b69a4d3fadc9c4e75850d5b4ae0256757fc65161b69a4d3fadc9c4e75850d5b4ae025671ec5c66e9789c655ae068d35088b4073345fe0b03017b350c9c4d8b39af2ce0e3fd8d7cb9539a6da30533f8fa7c2aa1c4f6b976f625c6b68e86d95e79bf9c758076569c35d00000000254739a1dfbf7795267e64686dd07cd61c6f87e665efd52e15910fa29b3da3bd000020254739a1dfbf7795267e64686dd07cd61c6f87e665efd52e15910fa29b3da3bd2068d9641221273796f8fbe1d920832c88a3b5b4b95463206485182f648dd3fa670096345fddfd53f65ef43487849a6f469c9eb64136000000000047c6dc82fb4e1ffc0006f4d10001fc0006f51b00eafc007af0360da4457b92cbb8ad08650f20ea4ceafc007af0360da4457b92cbb8ad08650f20ea4c19c2c7d2ac04ffda699922b0d78957ee839ebffa3090f7f3a97069a5090c885a85aa7e8c970b5d3982718dc4394e2de8ecc2d1c38c8ef51a322e6a5e9660eb794af6c404740000000025b1e2cc3dec589720bafa5769d16437e2e5073d63df9659d05199fe22366b0900002025b1e2cc3dec589720bafa5769d16437e2e5073d63df9659d05199fe22366b0920d73d548e5f6c1b4f19114e39bf27e78530faa14c6fd4f019c589805c624556c4014e63b061493879a21b61e49607d988ce43449eed000000000012ec855ffb4e1ffc000bb3b40001fc000bce43001c544de6c1eaa3cbaa78ebceeb76f1c9d9d799941c544de6c1eaa3cbaa78ebceeb76f1c9d9d799941ec5c66e9789c655ae068d35088b4073345fe0b03083cc6e11edd346dcb19cd422faeb218e37568f66ef70656c93d6d43bbd2eb8715a99af27323d075f6b31d955ccb303e400000000262f95031d76363e3fad8c110694a8894077ca0ae98acffc94200b16cba997b4000020262f95031d76363e3fad8c110694a8894077ca0ae98acffc94200b16cba997b420abf84695101d7649a8be1488b7173bcd83a050c4d4735974b6f08c997f1fffa201feadb5e4467d54029de5820c960b2932ba61b58b000000000003e25369fb4e1ffc000607de0001fc00065754000348d6a81e71ebb94c607c7c79d9500f2d689869f98d462531cb02fdc829890da5d5f248c81f961958b2b6e9982851794782fc7102ceffef076d4c15308a50a9ec0042d293ca23c941142561632df2f182445a96d693b70079a085dc35073092d00761156f88a1f269a2d87e7f000000002695fed97527f712995a207d278a1cb7fea614effd3f6d3cacf58052af020b8c0000202695fed97527f712995a207d278a1cb7fea614effd3f6d3cacf58052af020b8c208e8e515f7025352e7c608479e413beacf0d95cbb964b47e4a98fd27b6b6b628a46ba4f939d4efc43e1a17deec2b9695271bd162d14000000000034d41347fb65a2fc0005e6990001fc0006578400c33d559a563e9c22c95585c0f556727c6c5195f4c33d559a563e9c22c95585c0f556727c6c5195f4ba4f939d4efc43e1a17deec2b9695271bd162d143091c5a9a2513c46543acad374e11f69e63df9583e74e511e619355f2cb7c1b9cd7b4c1ddf3f33c28a8c046658958c3a1000000000271b3eaea9e4fa8717b42dc04a257bf689d56e400683d608ff7cec3a34ad7115000020271b3eaea9e4fa8717b42dc04a257bf689d56e400683d608ff7cec3a34ad711520a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e428d9aaf516d9d692b3476014c6f0790a8c609991b000000000022d21a5dfb4e1ffc000ccadd0001fc0010b6cb00476fca90e883f3fa6116515e120c7e4c1b33d302476fca90e883f3fa6116515e120c7e4c1b33d30264f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73012730062f122f937b29f69536db3ad36980b88004eadc2ca341425d432723d67e53a4f55786c54017d77c1bd1df6b31000000000274ae6ab38ea0f3b8fe726b3e52d998443ba0d77e85d88c20d179d4fecd0b96e000020274ae6ab38ea0f3b8fe726b3e52d998443ba0d77e85d88c20d179d4fecd0b96e20a096901dffaa36cab6566f3a7028c1cb81ab8906b6804a12132666cfb240301301bceb142ede41aa52eed6c38b326e7df12226e01c000000000086d1e74ffb4e1ffc000335940001fc00052b840074f9875462d0f10d60acafc3f64ca89e86e491977f0dddb29235681f498bb64f7bdcee4bee1f4c98bceb142ede41aa52eed6c38b326e7df12226e01c300db6da5d8ee9fb8925f0818df7553062bf35ec9d62114144bc395980c29fcd06b738beca63faf265d7480106fc6cceea00000000289b8c9733345bd0c9855f933d947192f566a6d6bd5ca694d3ae0b5e9d3882f6000020289b8c9733345bd0c9855f933d947192f566a6d6bd5ca694d3ae0b5e9d3882f620a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e1b2f17f1892888740eff564e5925560fedfee93f7e000000000022d254a3fb4e1ffc000ccadd0000001c6031c212e840f9756b8f08e3801cca20b38a621c6031c212e840f9756b8f08e3801cca20b38a6264f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300e2825781a496023c8be61f2bf352ad1094afd6e4f84c4ef331bc727bc149a6dd7e23d78944b8b047c03da44eef1c79600000000298bb1ffac5832d9bad4339c93948f449a2aaeb2d66f685836b6bdf4275b6d6d000020298bb1ffac5832d9bad4339c93948f449a2aaeb2d66f685836b6bdf4275b6d6d206d6d5b27f4bdb63658686fd6b2ae2a9a448f94939c33d4bad93258acffb18b2901dbc9cf11f6b96f87c6435430e66384b80d674c380000000000ae22e976fb4e1ffc000c225401fc000cf06901fc000cf6cb0031471f3f5be089945132a63168b2e4feb2cc5893ce7f101b7f075273c892063b1b8571311737a5767f95c0f808aff27883260bfaf9cfe2b84519a6b230925d20af1a6d0ccd3890f0aead4a05a59be22e005b6d732f855311915b351a9153b2c83d84611b2c9958f806c93f7b5f000000002ab90c655fce7462791fd57049fd3477460cf45aec3483dd8f92ac76cbb5b65f0000202ab90c655fce7462791fd57049fd3477460cf45aec3483dd8f92ac76cbb5b65f20ff005bf96c06ff60140f082130050e2c3231178769c841f5d2e7c8936c53214301491707fcd2969c5f8ece1e0102d6f8425336700100000000009fcb1514fb4e1ffc0001aa940001fc0001ab14009406f3c3f3e20632e58e419a5107a5db669cb4209406f3c3f3e20632e58e419a5107a5db669cb420491707fcd2969c5f8ece1e0102d6f842533670013006b2e598c2a16e7394cff63bb9939e8bec49849f2520f97d8de70ed9336625ea0582889be68007e93663685d03d6996b000000002ab9d8594ed6b96aad7e0d89e739e15f43540da076265f22f1f2be892b9af9ba0000202ab9d8594ed6b96aad7e0d89e739e15f43540da076265f22f1f2be892b9af9ba2031b660b28d594534ac630a8e9739ec2d87f054298223188a66f7ab813007545901653e5576338dd6a629c58b7bed6fada76b62919b00000000003ada3c2afb4e21fc0003b80f0001fc0004053b006672b178caabeecb6cbe108c960367333fd237f778a2c01c623373d2761103791484d3ad1164c06d22ee55a30f4a11a8c3fbd3eb1ec76d9ca8ff4ff73004eda2a8c31489e17463ea27c0c39473afe2c9153641028de360eee8ce213d36a14ef8f8b4f85fb2cd70815a9c1f56db000000002bcdbb54e0eba24d0a83a339436d84c916947205535f755f21cc4843ea3d2cf10000202bcdbb54e0eba24d0a83a339436d84c916947205535f755f21cc4843ea3d2cf120d7c8b2f884a83fecc4227138495333e0db8b7125f2d9a306218176604a30f48600481565d75de04c111a345dd844afde2b9a54220b000000000022dca522fb4e1ffc000bb3b40001fc000bc79c0008b5cf180aa32a061e3ad75bc37908a4ff705ce808b5cf180aa32a061e3ad75bc37908a4ff705ce81ec5c66e9789c655ae068d35088b4073345fe0b0300d450032d437d4a3ce7b62b4fcf70599c467722d2a3ec10844d4cedbe6783d39b7180fa294e7b3f819c4b4c293437770000000002bd7d5200b9a5e22d5c95c2c19923e9cff64ed36a1f736372b87d82b2383926c0000202bd7d5200b9a5e22d5c95c2c19923e9cff64ed36a1f736372b87d82b2383926c20451a8c759ac8fd8f333e230268f26808131fc02a734a1fe98b234ddbae4b1375019263a05cc87500b6bd59287c7665e0c84f210c9f000000000022dc8cccfb4e1ffc000bb3b40001fc000bd21b00eca70167cf9b64e7daa3bbefa9fdafb213f5016beca70167cf9b64e7daa3bbefa9fdafb213f5016b1ec5c66e9789c655ae068d35088b4073345fe0b0301066424f46c8c13274c1aa17df6a3fc1ca4fe80d9dac09525ae40670c5a6ca193854ef663940ddf64740fcaf7b83bac3000000002c8126dfa695f9c0da6183451834b6ada03adc05c54c72594187bbf65d8591f30000202c8126dfa695f9c0da6183451834b6ada03adc05c54c72594187bbf65d8591f32095cfedb09499fd9459f4cb839f6fc086a7ab10762181108913f996689914d050019f9db9aeabf86561085372a2ba98078afc0ef278000000000036bd713efb4e1ffc000bb3b401fc000bbd8501fc000bd21b00b2a4ee6e3d9d40899ab18ae6f737c85278d907f4b2a4ee6e3d9d40899ab18ae6f737c85278d907f41ec5c66e9789c655ae068d35088b4073345fe0b0301095623aca38c0609bf75ce889406d896b2d06763728796d1d9e154392e74e16e41716c1dae79d1e321a47ce2e4eac7a000000002cb309db9b7c22b337a7c24aca6a2d730030bef2f3a7c5f104d6c9ffd9ee64d00000202cb309db9b7c22b337a7c24aca6a2d730030bef2f3a7c5f104d6c9ffd9ee64d020d0cdca3ceae80c1da9521a82711b05c63a82a6821b2c1ba4e9d2a529f645bd61003d1eb245b39df4983715e8579b8053ae088176cc00000000007217368dfb4e1ffc000606a50001fc0006072b005871467000cb7d7144ece56406a6d0f8e97360395871467000cb7d7144ece56406a6d0f8e97360393d1eb245b39df4983715e8579b8053ae088176cc30903a0f90f0ee9ee05c0d567eaae8ca9aab5bf0d5d1e0240494f40e4bf954201e48585c5a2897ed76697b4fb95dd993f5000000002cc0a073e9fadb5cea5cc3303b8f85ed603dc6de043f0ec06edab72d886c57cd0000202cc0a073e9fadb5cea5cc3303b8f85ed603dc6de043f0ec06edab72d886c57cd20f2645684284391532fda7db234d517365631647782fcdfae42d5d7ebca78f3cc013c56bfe3279092a8afe0a282c66f1c68c6a331a100000000005fd8ae98fb4e1ffc0002ddc90001fc0002df8400c5871227ddeef90af4d9e891170c4407a5957ca0c5871227ddeef90af4d9e891170c4407a5957ca03c56bfe3279092a8afe0a282c66f1c68c6a331a1308dd3ff4dfb358ca5c5c58f5c163d73482caf44427b62751b18255a456b8edb175f887db87b3b214753045f631db58475000000002d3394ece5ebfb9e2f369fae0c663b01b978f946dfa06fe938f2c292661c94990000202d3394ece5ebfb9e2f369fae0c663b01b978f946dfa06fe938f2c292661c94992005987511f1162441ccd624fae51f48274da77bd4a6a103de7b767a963e06280e00bbae8d6f3091b51bb8bd2e948907ee11744e6616000000000050f017c7fb4e1ffc0005329d0001fc0005340c008c5f76e0794a0729c41142e619663b77948748ab8c5f76e0794a0729c41142e619663b77948748abc66ab236698c66f559ac918689cadae4c8aff0f6301260b9b40d6a39c14c5f52763ef6e98094a6d41ed35660ba24334c50b60cbf18a524aec8bd4d0203c3257e70e193fd30000000002e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb0001202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0101e19b30edacc8bd047a72d6b12b79b3f1b2babd0000000000369521a7fb4e1ffc000cf99e00000063f16c50b9cd1dccd8465e1802749bd00dd49a2d63f16c50b9cd1dccd8465e1802749bd00dd49a2dc69a0bda7daaae481be8def95e5f347a1d00a4b430943a88959611417f9e8ce4e664e1d9c6a839daae14f54ae8e78bc5ef6ec1524d116efca49ecd5c57dce31d90015a51ff00011ffbf1d32541dcb8f5555305295704a9ff9adc2401fb8f3001fb05a32f4bf68bcd9f4fe5171f8111a7f007f76d1298c1124b8a85174e64e057a2522d0000202f4bf68bcd9f4fe5171f8111a7f007f76d1298c1124b8a85174e64e057a2522d202c4f5235e6615104fa3709900b96bfc192e6264d8edfbc24f7af6f1d9b2508e900e5ec4a87e9bd6276f5954a87ddbae45e398bba5c00000000003694d7a1fb4e1ffc0006567a0001fc000bd99b0031e5d66a6457e3181b3dc060f5a278bb61a54aba31e5d66a6457e3181b3dc060f5a278bb61a54aba1ec5c66e9789c655ae068d35088b4073345fe0b030978c2c6ad4f75b983efe0be4ff9d9fd5c70645dfe27b4aadbb33ea857e63ae59f7907a9e65850000d968af60e264370c0000000030110b4643c2d8c7521f27ccc2a6a70579bc859087fb95facbb831b3a3d107c700012030110b4643c2d8c7521f27ccc2a6a70579bc859087fb95facbb831b3a3d107c720fbcd42341652da33e977bab8bbef42d0f053f93e9e2748f3f39881d11e28910c017798d43ef1f85193b1a0e5a7ab7853a39d27f0334060000000a6469a72fb4e1ffc000f01930001fc001046630057656569e143ae0cc0419020708c8ce5f4c776e452bfa12608d37422d52423c3a71f9574ffa8267f535e571f5fb89e31f634da8b91769ea4dd252e19308cf6a03c7a0bd8c38c1fc536a013f93afc8224cbfc79d8b0157c7080117ec9c1c60198c3fb3886ec472aeaf80bd5fffc0001c3f93922e89f4bb3869da0c18d8e30dd91019bb101fb669601fb2710302ba9134d9d734e0a76599c9cddfdd1ea2231ff6c152fd5a95c9ec38aa66d02000020302ba9134d9d734e0a76599c9cddfdd1ea2231ff6c152fd5a95c9ec38aa66d02203114c3b632de2d7ece96a92ea26b83b4ea213a9db1eb4fdfc2dcfa84e7cc500900c437a1e129915fbc02e98bca6d8e8fb8d08001c60000000000a5e33fdffb4e1ffbc40f0001fc000196140036c7c737a21e3e6227791978495ea6516da151c9cea287fadf53be3891e7d421908b9a64a5ef3147b2334b22379811352d9988876a6e586d975e732930083997ad0a7d12c5038242eb54f0aa3952ede09814c57b7392adc4db58f4070dc0b44431c20be0636a21ec238436fafb00000000306c038de5c583febcb09b55f527eaffe177acd9d118e8076f61349a305e902c000020306c038de5c583febcb09b55f527eaffe177acd9d118e8076f61349a305e902c208e8e515f7025352e7c608479e413beacf0d95cbb964b47e4a98fd27b6b6b628a0e1e7fc490e774db8c9100bd196291d79699001e24000000000034d41347fb6598fc0005e69901fc0005f6b801fc0006573c0077d7ce66a12ce0c43ee6b3b9116649dba376cbeb77d7ce66a12ce0c43ee6b3b9116649dba376cbeb1e7fc490e774db8c9100bd196291d79699001e2430052abb8468545b0593010c326d358cec47a3079a36c6f5002b2c36fb45aeaa6ef00746d0e73697fef01704d51d8704940000000030bd48a0fe09f6d72a94df8ca9d58e1c9015dc218685f17e2f711a1c8fd3c3fa00002030bd48a0fe09f6d72a94df8ca9d58e1c9015dc218685f17e2f711a1c8fd3c3fa20ade9aaa50015e14f1e50cb83348552efacd55d5f4198c837d8b6e01af95e510501bc1b78aed1c8dde1141a1880702373d656b7e7420000000000235a9f29fb4e1ffc000bb3b40001fc000bd20300941e9b03a9e4597551f4335ad9b6bd400313e19a941e9b03a9e4597551f4335ad9b6bd400313e19a1ec5c66e9789c655ae068d35088b4073345fe0b0300e2f8770da14ae4c8a45692c8939addbeed7a91b3006e827def586f427cc4deba43db8f89cffc5d2ab9196763671c1cf0000000030db7910ec759ca0b32c3ab934092fe50b1fe9af6fbb76fd5efd7a47eab53b7600002030db7910ec759ca0b32c3ab934092fe50b1fe9af6fbb76fd5efd7a47eab53b7620a4bd1cd4f0ade45f968839d7a0f661d603f7c02d2a1c6f659e6685d67d8d7e3b00358bb3c78aa69792b91f6e14efc4dac13b46d557000000000022d1ecfafb4e1ffc000bb3b40001fc000bc79c00a52289f61d0ba312a086112ba5fee4cf65057ccfa52289f61d0ba312a086112ba5fee4cf65057ccf1ec5c66e9789c655ae068d35088b4073345fe0b0300729c8e764d6566a66b65ab3b4467b5e463984c8841d6a93a869848958a052e1acea53bec6cfb00de6f2e0b8cb0491180000000030eded4041e2c494c3e5ae391331b4ea1dc464d50a34d76178d20fe9904d041d00002030eded4041e2c494c3e5ae391331b4ea1dc464d50a34d76178d20fe9904d041d204809ea7f6bb2e840e7a71c40e435edfb9618c79f822165c721dce537b7ce52c601f44f02a47f3e123e3fdbeddf59307407d1b272870000000000a747dfd4fb07cffc000241e10001fc0002433b008d2aefc27102e8b3f7615e419a61bc394fe83ba4ac1a700d32a6ab3f00aebf68573e26613e62a825d458f5157d91f4832e66eb8630ab3dbff95551d8300d731903ca090050801af45465c96d1248532819959a5a97eacb1ce518dcd5c5a21f20676d7c893f81ba672fcfb0f8050000000030fb0b68444a03b7a3a7f079f1445cab153962fdebaf77d9752cd1c08c816c4800002030fb0b68444a03b7a3a7f079f1445cab153962fdebaf77d9752cd1c08c816c4820a2805906f085aa712b452f8f05002dd3ae71648511dc6a88fe742bdf1990edf1006b827aec87ef146557c8528760f9240e747a8b96000000000022d3f475fb4e1ffc0006567a0001fc000bd99b007ab77c02d06ed94aeb677fbafdeaf0f6c0da49c57ab77c02d06ed94aeb677fbafdeaf0f6c0da49c51ec5c66e9789c655ae068d35088b4073345fe0b0300610fa6d1e213d65b653302ee8ea682b7c454e2117939ca77ee122a5cd8a387cc199ed1bc01d18641a05aa1e7ffe74300000000031a74f4cfe217fd8504e6b210fcdf12243828a67191448b649b648f7397da08d00002031a74f4cfe217fd8504e6b210fcdf12243828a67191448b649b648f7397da08d20520e51c4633d678e5ae07dcdeb878c950195be4f521e76a8e8efb802490bc7540105dbe6edec2480181164c7d62edf45068cc3e5a800000000008b3bf941fb4e1ffc0005e2fe01fc0005ef9701fc0005efbb0005d6c86082462b374e1eedaf7f53bd44e95a1f68c522817f1747a9922db608af9f16503bff07798005dbe6edec2480181164c7d62edf45068cc3e5a83082f48df5b39fac4fe299c0741cdf675eb53aa0b936ea147d4883b650596887142e4fecf91087799de85312aa47c6d60100000000324443f3ffc7b3cc689194e0a0acbbcb943482010e6ebe895e3ccaec58525922000020324443f3ffc7b3cc689194e0a0acbbcb943482010e6ebe895e3ccaec585259222018929b9319a3c5f73c75d7696fb45a41da8842a9a1df4a94b6c7ea5ce5e4696200e405f89a110cceae2689f59d7eee20122e7b23d50000000000235a73befb4e1ffc000bb3b40001fc000bcba300c04ced284f6d465e579d8e64e9eab9c0852c0766c04ced284f6d465e579d8e64e9eab9c0852c07661ec5c66e9789c655ae068d35088b4073345fe0b03007cbeec33e4aacfe4a2b4a29b60a7b702bf3735bf48fbb86a2ca883c949c0d2c84b26cffd564411041ee5218f551ce2b0000000032f66942ac8ad4e5d6552e1c22d990c8663deedee1b0f79783ab4ab395f5652c00002032f66942ac8ad4e5d6552e1c22d990c8663deedee1b0f79783ab4ab395f5652c2034ba66b442a95a29eb695c36e912dc00d958f0a7f2ea178d8f8081115c0af1b6004ee9a0820126e33f0b27f53b37fec69d0322eb86000000000022dda8affb4e1ffc000bb3b40001fc000bcbaa009eebe57e4f2f24ec1aa880e2ea00513ab416e7339eebe57e4f2f24ec1aa880e2ea00513ab416e7331ec5c66e9789c655ae068d35088b4073345fe0b0301368e69be7748d2e13f6e6addd0a775062a856a9333dd25a1ca0662decf7bb98a2f3181fa53598fd387da63b5704250500000000339358bbca4d00397e0b4fa1fce5b7af195a8e8e14e79e75a91dc54ca34fd2c8000020339358bbca4d00397e0b4fa1fce5b7af195a8e8e14e79e75a91dc54ca34fd2c820b8ef3ff343c38e2a71c8be729700db41bfeeb0df9e57b48534227c44f6d53db600038ac68f188a776526681ef676fb5d6404d78b4d000000000022ddef7afb4e1ffc000bb3b40001fc000bcbaa0073f6d493ef502c02f82678f82b2d834cb361254d73f6d493ef502c02f82678f82b2d834cb361254d1ec5c66e9789c655ae068d35088b4073345fe0b03083415bb44cad9fc44854254a6bba65b7b34f1226bc3e844685e7e62cd6f53e7a6dc7b12d1fffbad7fe0c135101408d320000000033c82292c562fca8cd876144b725bfab4be9975cd54a5f7903663c2ee60d49fe00002033c82292c562fca8cd876144b725bfab4be9975cd54a5f7903663c2ee60d49fe20e597f8e67bfb6955354448b6d50e77ede36dadef2c313f79cd42274fa195eea001a7283956624e1d51147b90106872fe169291f4e50000000000235b9986fb4e1ffc000bb3b40001fc000bce2b00607f9501a1545d0aae13127aa475a3f25c6d8458607f9501a1545d0aae13127aa475a3f25c6d84581ec5c66e9789c655ae068d35088b4073345fe0b0308800a5f9efc7684c4fce24f11c103b04634b52d008e0272d89d9105d57e6fd8c4079e6a8331f2cc2b8f36b28c4afe3f90000000033ef407d7aa49e2e929285bdbd1dc6e4b8e2e423e0e0f2b28328ae8a8ffbeaea00002033ef407d7aa49e2e929285bdbd1dc6e4b8e2e423e0e0f2b28328ae8a8ffbeaea2084b5cee14786065b3efe381a9f7e0619548c5fe19e68d20532a00b262f8c72e3013b4bdf5074ad4c48e2669cff6b8b5bc260919178000000000088f471a6fb4e1ffc0007e4d20001fc0008df3b00f019d6736feb8fa148524c0b3fa3af0da39ae5aa4f9406e645e1d2a24f68a29124a5ed91782c9208598120ebfed5f9197261ee352b5029f9cacd5983300032db28dfb209566356ae396255132f8f8e412d6a59dd5cde82ca347f4fb2a4713d8a49dd2dd9b8019bc2dd3a62745a0000000034f19e4ac7e1b2abbded7fe0d19991cde34eb7797d8e81fe01d6e73db209718000002034f19e4ac7e1b2abbded7fe0d19991cde34eb7797d8e81fe01d6e73db209718020cafd1d29a6bfb5294fb789c8226d61a2f4b641964f2d2483fe880ebb5d6a506f0176a4e499430b47be702257744898bb3d95e06799000000000003144612fb2713fc0003ac100001fc0003b5eb001dc640b7e408921b2c99d18ec5bfee69e61d85b61dc640b7e408921b2c99d18ec5bfee69e61d85b64217790c6c0655795f7c3d47e42d94c9dae99d4b300fb7164d86058e2b22c4a6f6917714dfa4a2cb4d54bebbf3c9300ebfe1759b33d15b0b68e32999aae19bf0dd92341e400000000036c99a74a4cfec77b2a7438558a8ec53ee09c11833597c1b601c5b00c93e37d600002036c99a74a4cfec77b2a7438558a8ec53ee09c11833597c1b601c5b00c93e37d62002b0140755817c6d71787ea5004a1342bcf6f1ea8626eee46ab8affd15a5fe6901c9d30aa841c8e37e16f8095f20aaeac9869d26d9000000000023af3e6afb4e1ffc0001e72f01fc0003707201fc0004053b0052b7f1604d249547c79a4056b2969ef98e816aba7509e1003c6e1b4f64a954ba6297e4554f3e7359b508db53f0a3f072b00f579a86e813d6af2856f3308f2caf4cf1e01130aa6bcf27784bb36a2b4daea4ada3be553c9b709afcc752d0f34a0c35e3301e8f6a2fb3ca44656be20000000038f8cc9f9bbfc0ea0b35880a727940037849db6f717f146392a2bc3e971a6f6100002038f8cc9f9bbfc0ea0b35880a727940037849db6f717f146392a2bc3e971a6f6120a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e4790853e3887a8aba03562d217ed6db4fd74aefe82000000000022d21ac3fb4e1ffc000ccadd000000ea1e4a53ffa1572af733c63b530860885f9c8ad8ea1e4a53ffa1572af733c63b530860885f9c8ad864f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730897fc76b69f1ff4b06535e7a4bc7396fb66b33194effbb72214dbefc2c7cd3220ab6cc39fe4630a513879f9f8dca27e300000000393936246926976b4135b6dca4295f45dcf95c875422b70be451f2d51293c7d4000020393936246926976b4135b6dca4295f45dcf95c875422b70be451f2d51293c7d42096e4d1ef906cdfa4084e2a8dfe662116ad8fdf25b395ec355602edc0d72eb8ea001feec80a8a9f80fbb419cd7e118c67524156f51e00000000005fb3a457fb4e1ffc000532300001fc000533f400e8ca11e6c7d6a9e15b9676b534663298040b88b7e8ca11e6c7d6a9e15b9676b534663298040b88b7c66ab236698c66f559ac918689cadae4c8aff0f630847383710ac1786f020769809abad8f93018338eb855c103f5239d75dc2767770eb45709c895c99c0c86d375ddbe478d000000003971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be10001203971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be120926c6d0e0ce17a51dadcdc5be4f4cce0175d8d7a147e294580e3080d6a22f96d00e5cae595965e89fa9f94152f57b315ca504ee1b300000000005c3fb0cafb4e1ffc0011098b000000b29a8f14049a111260586f489d72cfea1ed8ee5d492df4065de3d5d44692934635d826255f7a60f80e7e48253baecd886fd539601fd5e95efd61534d30b92d4ef819fe283a307e6bcd500d8cd35e9a7b779dbca59bd3bc77b3bb3611c370258aa6dec13d0781e0b53c911bde08000161c274080f47a95be5372ef8c69bb60ab1d4ca8201fb8f3001fb05a339741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a00012039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0826c998cd53845caec6858f3121e5d3a88df6c7a3000000000023a390e6fb4e1ffc000cf99e000000bd9857229d4c0509c753afc85d264fe2e4f344a3bd9857229d4c0509c753afc85d264fe2e4f344a3c69a0bda7daaae481be8def95e5f347a1d00a4b430b6693296894820bdc3c0ae76f357e544847f10a68f0046f53745370dbe861d57e194ddaf7ff7d5e73cc3f240515c448e0001ec7bf3b9bc72eda38c80bb7cf16e294e763e56b401fb8f3001fb05a33979cfb79c4562e819aca69ffae2ea84b9b8f29bd89bdc68be67b88c6f31bf990001203979cfb79c4562e819aca69ffae2ea84b9b8f29bd89bdc68be67b88c6f31bf992067a0592b5510496cb42f2d784cc3b933a0156b10c8b54e440673bb87c57dbb01011353eea2d4fbc06aedc288e493b70de32b3e977f0000000000adc777f2fb4e1ffc000d5e0f0001fc000d5e4b00d8155dce6238737a6af04e068bd92048e68a7f51212e07f7407be541b585ff0a8225fa1afbcc9ac8dc82946c9cee9ab3e8fef5a5d641a57bdf1523c030a73d8c1e640d29e2257042a39bbbac8d867f69ae252e146884816b98ab0d0526ed4992d9cff22ef04878423f66583382000171b5c04007f6af71d99893478feb52df0f5a770101fb592501fb592639a1339d9bf26de701345beecc5de75a690bc9533741a3dbe90f2fd88b8ed46100002039a1339d9bf26de701345beecc5de75a690bc9533741a3dbe90f2fd88b8ed461209b9054ff7839b940277b8eb8211570b2f16850ef729ee635e24d722fbc4a462301852d4f5bcc34685e3583dbbdc92e9bedd3e985a60000000000c6c74af1fb4e1ffbfb1e01fc000107bb01fc000134f400891cbc8a94fa7fea64ca9994870dca0f75bbd075359c348a574176c210c37a25d4ffd917866fb0a3e54445646929fac8b7d6c71715913af443249784300efda51589f86e30cc2305e7388c01ce0309c19a182cf37bced97c7da72236f660c0a395e765e6e06962ecff5a69d7de0000000039b88e537c795f0b093c951539695fd4819a91a542b247ebd3a0ddd6a4c1c43900012039b88e537c795f0b093c951539695fd4819a91a542b247ebd3a0ddd6a4c1c43920bb600d779c7be93a83b9d7878fb38b0b1b7ff1390b231c5da8136b674cde822f01fd9cd0a5165717d4b3a17afddc669f3fd14efbb5000000000082a2e172fb4e1ffc000ddfee0001fc000e0d6b00f5cd552d14676526ef325757eddcfa285b15ac34bf951db34349385992e0303f21fd7240e44e4b0222319c7fcaf88f86259ffd3fa8430e4665f2e1f53090d98ff5c2f2970197ce80ca8cba9431f7dd7cff5d9fc9c4e99c2ed06e598f273d31dad8d8d05655c8b04599495cee2300018e976c7a2f79745d70e41aab1e61cb5f4db4323c01fb682001fb01bb39ec834a6c7ac5ebf5fd885a271e2149099e87e89a9ea30f573b4b699b9399c600002039ec834a6c7ac5ebf5fd885a271e2149099e87e89a9ea30f573b4b699b9399c6203eee0b9d7239564719e9ece229505909d518b38defcf16aa286871b5d6afae03007e345d48c4d9a24dfed5f23ce04963868ae7bc3e000000000086d10280fb4e1ffbc4260001fc0001962b008b7355042f324a44995bb21f9b68d63e4ae3ca6b959ccc5ac3cb8830eec83a7f15d433ac5452d425b2334b22379811352d9988876a6e586d975e7329300617fffba2681e4712782d97b84cb41b722d56089c3f3b3978b8724cb02baf0f67a57e8d1e2f8227d21700f7b10230c4000000003a3e75555ef79cb77c55684587b65a9ef728efcbb443b46fe2e7ed3e660c4a660000203a3e75555ef79cb77c55684587b65a9ef728efcbb443b46fe2e7ed3e660c4a66202cbbc61af11fd5c13e19c53fe37aafb9ec1793a6682273ac1c639ebdb605d36101f8bf45c29243a614283bcb7e6ba1995124d670ce000000000067507615fb4e1ffc0007ca830001fc0007cac3006dfb5ed0a495b0082f54056634d8bc1431d4f00f0aeea2780fdcce25eb1ff50c0edafd09e0397ec1201d032a4c937947e7d6469d39b2092dfcaa0b723087a55d353f1c76f34d45486140b3242762e03d9f688b7be28be4389f552b7a057e3a014f7f654cf7da7260b5ec1c15e5000000003a541549d161a0e134f54db0afaee615530bb6d84e353b82afc9af76a9a393290000203a541549d161a0e134f54db0afaee615530bb6d84e353b82afc9af76a9a3932920fd9f12dc7a00babfb75867303b9e99bed0d2ad149074350c4659612c0b88cb5b00d488c9d5bc5de3c5b9190fec92c5b37e705ce3f700000000008b3b2314fb4e1ffbc8a50001fc0001197c00abbbe06cd2bdb3615599a7576dacf0cc3cad128728c20f725ddcc44c5d6c728b05b886805ca125afd488c9d5bc5de3c5b9190fec92c5b37e705ce3f7300a97f109f81f15cc0b6af0a57ec93cf9f201789fd28494baf1840594d4bb233cb790f4ba434c49ecb6a1ebba61beec03000000003a80d01eee0c4b79f9de8393f0260fe859677b6bda207a21fc3217a9ae4b5a030000203a80d01eee0c4b79f9de8393f0260fe859677b6bda207a21fc3217a9ae4b5a0320035a4baea91732fc217a20da6b7b6759e80f26f09383def9794b0cee1ed0803a00cb3b7402b0dcee772112cfae17e12cda1eae0dd600000000010000000000000000000000000000000000fc000194d001fc000194d201fc0001a33d00e3f6150f12df79d8bf1fa5513edcc000b93d388ae3f6150f12df79d8bf1fa5513edcc000b93d388a2c0be6e924cf853fa531434308f0c389449ec73930000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003aa33cbad1659ba0bdf6530b5ba543592e2f30c5a35cd89fac77604317cff0f10000203aa33cbad1659ba0bdf6530b5ba543592e2f30c5a35cd89fac77604317cff0f1201927dfd5c8e7396db11536e478f4ccba1a05c7cbde3fcd5c2c98eee94178916d01cfc20de0654c5bb2318915c8f9a3bc3395f84e64000000000074cbc88bfb4e1ffc00035a160001fc00052a63002576863b75bc6a1861ac0a2f0e18ab0d373986b5e5abcfb8f638610b4b5ea0b23d82db8e7560b4003b9fac2da702d7161a178f359f98f0276d9556b1308130957c5939cc5aa59a9d7ebb88a03c8e60175230f87927f9485d452f6c844454148d8efdeb9e3216600b7f6645ecb8000000003ada735b7fb780232ed20e0a96d293385a0793ab7c5c360dd356c98192cc290a0000203ada735b7fb780232ed20e0a96d293385a0793ab7c5c360dd356c98192cc290a20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e3154cf88c4f4815dbbf2a3912e55b1bd7d84fd8a800000000000235b9d1efb4e1ffc000ccadd0000004c58fc64d6bf36b4cd655f04a3e35ddb1ed7a48b4c58fc64d6bf36b4cd655f04a3e35ddb1ed7a48b64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7308c290b31d2e878c2d7235efb0c61f423aa37742a31318e61f8bb0bd6c110a892dc244512fec12a8b0fe7cbb08e12be28000000003b056202a743c16d86aff2f8ef6cf5d402e312f70740b9ae20ae92e47f1de1740000203b056202a743c16d86aff2f8ef6cf5d402e312f70740b9ae20ae92e47f1de17420a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e2945dcbb68ad19e70cbbd741c61b2267e08ba65182000000000022de150efb4e1ffc000ccadd00000042d81ce6e9a394d9a408d1fa828a8bb7bf84d17342d81ce6e9a394d9a408d1fa828a8bb7bf84d17364f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300d9ee7b7e66124c4b047e1f93aed5a764ed7384292737ea17f3a7e429ce3f24d602d54b97f72d181b6f093da9b3ad3f5000000003bed128ba5c04b627627cf5d9f1dec0622caef4725d8d9d4c37c65642dce92ff0000203bed128ba5c04b627627cf5d9f1dec0622caef4725d8d9d4c37c65642dce92ff20ff92ce2d64657cc3d4d9d82547efca2206ec1d9f5dcf2776624bc0a58b12ed3b01cf2d268921dbfa2c604c708275f79623d67b0e6c0000000000ae22e973fb4e1ffc000cf13801fc000cf17501fc000cf6e3009c543dbc00467b9451f2e47e7c6f01f7695c0451ce7f101b7f075273c892063b1b8571311737a5767f95c0f808aff27883260bfaf9cfe2b84519a6b2308c9c5c77fe321ff0a115d1ba5bf7462063ef21a82ba796415f4ee538bf9e8a6a49707530c72cbb6b60026c46ff1b9443000000003c7e5634f8fd8af476905ba2e94db5d6b46c41b22445382bf949a71cd16fc18f0000203c7e5634f8fd8af476905ba2e94db5d6b46c41b22445382bf949a71cd16fc18f20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e15241e1813fbd233ceb15a094365a689154d9b9a0d000000000022ddfcb3fb4e1ffc000ccadd000000055d0c3a48dbbfab9fe7e77aaff5818e4d5a0ef2055d0c3a48dbbfab9fe7e77aaff5818e4d5a0ef264f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7301130b42d6eb505e811dfb18ff87c4bcacde56b76a7d47a8db88ca26e75f5c2eebdd767d440f375784f9d1f127f57c977000000003c99840d0c2ebb37b76a6a9dce2b876822ef969f7c2dabe67f0e7f071f2b03180000203c99840d0c2ebb37b76a6a9dce2b876822ef969f7c2dabe67f0e7f071f2b031820a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e448fa93403837002c7b2d0de6c44892051489928ac000000000022dd6633fb4e1ffc000ccadd000000c682e285e7a7bd65e9268c1bc695091eb4ce5a8cc682e285e7a7bd65e9268c1bc695091eb4ce5a8c64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730121adeaff038746afb470b84fb3a58f1a3bf304cac771d16980845c4902e5da34d366394c8e84a46d8bc0c0a1da23cc6000000003dbb7de94e219e8f7eaea4f3c01cf97d77372e10152734c1959f17302369aa490000203dbb7de94e219e8f7eaea4f3c01cf97d77372e10152734c1959f17302369aa4920b23e38fe428255d0068cc218c2c831e3bfc87c8249f3cba941e126053fd73b8a017aebdd020a3c7d9accde7db5d32c6a06d4c8ee9f000000000034244094fb4e1ffbfb9d01fbfe0d01fc0001195600ecb1486be55e4301c45b87cbad94daa8c5d17fdd6cc4a7bb877a80c11ae06b988d98305773f93b9856bcf3cac49235537d6ce0fb3214d8850a6db77730139b654f0b1c031e1cf2b934c2d895178875cfe7c6a4f6758f02bc66eea7fc292d0040701acbe31f5e14a911cb061a2f000000003ecdbedf3d9a13822f437a1f0c5ea44f290ab90f7c3bb42c1b5fd785b5f9596a0000203ecdbedf3d9a13822f437a1f0c5ea44f290ab90f7c3bb42c1b5fd785b5f9596a2072f157ae4a1ecfc6aceedf008abd5679ec9731abfa05dca49eba50b1c0b6ba860021a6e0e4828963d5f39e3129bbd9e1af873671e700000000006c3dc02ffb4e1ffb1c6501fc0001f46401fc000532f5001bba3b56ededb76c1834f3b3e02c159aba4777a61bba3b56ededb76c1834f3b3e02c159aba4777a6415e1236ed7df54649a880d353acb6f9ccdc622c300634f8b926631cb2b14c81720c6130b3f6f5429da1c9dc9c33918b2474b7ffff239caa9b59c7b1a782565052232d052a000000003f43ff3539e5a4fbcc88c7f031a544fe7e62557b5963cb7e43157ef73abfb13d0001203f43ff3539e5a4fbcc88c7f031a544fe7e62557b5963cb7e43157ef73abfb13d20476ad8662b3be5582b98569b76f66d2eecb59a943e9fb28bcbd23a10d53817bb01127e174ed242c758d4db9b7d5b19c1e0743728960000000000b29d5bbcfb4e1ffc000de50401fc000def0c01fc000e366a008ee38b4c9c407b21612862db1ac4e98a6edacb4b62026629f37f587b1dc70ccbc6732225803db4e3ecc3795b4c3e8c5b840dbfa092df1395237f2f8a30980213c5fa8031aff096b8a3eddeefd0584a0e5c2492f631ef67941e082763250e2615975db1f1bfae631f80d41d839a000100120432e9d299caad204ff1ec0c515babddc28601fb8f3001fb05a33f669abeefbe8527a5ca342037f8f97f5e6c8a65f559936abe546601efdab6030000203f669abeefbe8527a5ca342037f8f97f5e6c8a65f559936abe546601efdab60320106da0d689007410d07536c59586b62f5507aec775cc2a9cb4b73de8b7681cca0091c213cd9929a245bcfc03a9add339a210101ea3000000000022d17c70fb4e1ffc0006567a01fc0006c05c01fc000bdc0b0012e05b745751ccacdbc852c12ab9c3b9feb5b77412e05b745751ccacdbc852c12ab9c3b9feb5b7741ec5c66e9789c655ae068d35088b4073345fe0b0308c6eabbfad80e5acfbaa7a4fc148317f52d80d4249b62b9c3b23ae8592cb7306e798cda7c90dd366ced083618fe2bb8c000000003f960fd8d414906a260cd07db16f743f65306823355b61b5d3ad4bdcf91845490000203f960fd8d414906a260cd07db16f743f65306823355b61b5d3ad4bdcf9184549209c8946bb69fa334913c78c08bcc2ce898861e57a316b6edf4b3f4d6d8de49d33013f7a3f24310795b901908ce57d40dae9d09dc59100000000010000000000000000000000000000000000fc000196f301fc000196f401fc00022899007118238bc3182204c634d9035a968e9b59cd11971db884e38658de13612ec46d636c67f26d3c43ab771e413eefaafeea2aa4c0ecf2fad265164e83f330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003fe25a5d51edc1942b3e68170fd693bf8068968ca6e1be3a1721bfe5ac8416420000203fe25a5d51edc1942b3e68170fd693bf8068968ca6e1be3a1721bfe5ac84164220cedb19ac5ae1a42eff8e7bc39aa68803f6828db1549bf1f17f041816c961f8cf0163df30d171377fbf7611b741436a40d70969a98a000000000086d15a70fb4e1ffc0001aa9401fc0005f08501fc0005f34b00d71dc86bda7e222f78c9e45f22deae9437028650d71dc86bda7e222f78c9e45f22deae94370286501bc18ed01b8e3a9f78a209e7eb7f07edcdacb0ff3091386d3acee0bf9044cce40a07515289589b68fc9b8c8e5d184471ed7982106b1e11587af4c9e983883baec00b67e473000000004008a18371798ba28da7c9a581daf0aa92c4ac0b980c3438936823274f64dfef0000204008a18371798ba28da7c9a581daf0aa92c4ac0b980c3438936823274f64dfef20efdf644f2723689338340c980bacc492aaf0da81a5c9a78da28b797183a10840019bec606b655f5b5bbd68207755e614a79dbf4db30000000000a5e30a44fb4e1ffc000123a90001fc000123e300207d0b14af27f5a735cc27f37c29428f99fdc25c463b7729308cbc30c9c199ccee5a77921bb0ace59bec606b655f5b5bbd68207755e614a79dbf4db330121af4d4c49a65e1439a27ce0f39a2eca5ff751e9998c0fea7a3c2b13731cfa47fc6a56a313a38b448f3792fb60dc11700000000400c7f8990e6f8a3993b7d5900ea0b58e18bf86ba9b147bdefcd0df4cda1887b000020400c7f8990e6f8a3993b7d5900ea0b58e18bf86ba9b147bdefcd0df4cda1887b2017808983e70240144c4c811a1c3404d9d2f1395dc937dd761dc437d80e07928401d45a97fcf480feb7b262a80eda5b78a2a1a0621600000000005911296afb4e1ffb392101fc000124ed01fc00013d4b00724befff5e89d92cbad3cb0cc8281020b0243bd8724befff5e89d92cbad3cb0cc8281020b0243bd8d45a97fcf480feb7b262a80eda5b78a2a1a0621630848bfbe1bf50debe1322e14c9115adb3b96e5b8a3ae96beb7e2161281d9e56c30e43478d6f39835e3533a1c54377258b0000000040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d00012040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c02024eb44eadf4a67de93988f1400bfd5fd6fdbf830000000000340ae50bfb4e1ffc000cf99e000000f37ebd7e83f4185ccc5fb617a7ac9e09c11ffc12f37ebd7e83f4185ccc5fb617a7ac9e09c11ffc12c69a0bda7daaae481be8def95e5f347a1d00a4b43082f60dad4b7b498379d1c700da56d4927727eab4387a793b861a96df47bdabe5666c270acf04b5b842ab54045bbf102a00013e8b10646ee9d6c28d75c280b357dd3a9ae9f96201fb8f3001fb05a34106bef7acd1243652495260325ec3baf5bba47bb6e5d934c67b96bb24e3af1c0000204106bef7acd1243652495260325ec3baf5bba47bb6e5d934c67b96bb24e3af1c206658709bcdba4349bbf6d9fad0c66006993521ad1b989113855bf751a5ca1ff301f153617d41645e0e25985e35c09f98960f1863dc0000000000c3c91328fb4e1ffc00044ff60001fc0004c9730032b8da1c9e22be858fa29f61e92d6d48eb84e27032b8da1c9e22be858fa29f61e92d6d48eb84e270f153617d41645e0e25985e35c09f98960f1863dc3098e7dca1b8dbcfdc54faff65b94f81f2e3fce6440bb10848d434a96ebe30ccbb33aa586a2d0ddce112e38cb09bbf13c70000000041c4a6b724a0d25cb089ef946b7c1985a2815bc6a4e45f15bbcbd445b6d10b7900002041c4a6b724a0d25cb089ef946b7c1985a2815bc6a4e45f15bbcbd445b6d10b7920a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e172c58166b1f9c8d9f67b86e3812f98d4bfd86404b000000000022dcbbe9fb4e1ffc000ccadd0000008164fcd1a488ebde9344cbd205ce705bbe3121808164fcd1a488ebde9344cbd205ce705bbe31218064f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73007df25a28955c903cc19f836a4daa0842d203cfc0dc5ae9b57b8246a4787ee4c98ea3f2586203315d61f4e77b6c80dc50000000041e41c6b6e1b1c43e73c7644ea36eb622bee149ab05693ea487e784614e524fc00002041e41c6b6e1b1c43e73c7644ea36eb622bee149ab05693ea487e784614e524fc207a644e33e16840030e5170f7e07877c4f992de0d330c7ba1568a651edc3c4cbe012c72148f57b165ac7a3a23d0a28ee3baa6675b8f000000000095f8331efb4e1ffc00021d3d0001fc00021deb00df7e1106ceb6cbdd287af2c99fad3d0d9181ff127efda5f8279fc8c7490aa37ed57903870a1f4ee1fd5780dec499c5f53a4222c6e0a5e3bd74097a043099567cfb20c6bed5d20638c31e7e512aedda02649e82f2b955ecd3e34f73c2229b350069f6e74a4304acedddd87997fe0000000041fb85bb67981f4e1fe41e0f7d520bf6df2167c9ced5e51fae33343f98d9cc9900002041fb85bb67981f4e1fe41e0f7d520bf6df2167c9ced5e51fae33343f98d9cc9920cc86f090d7505156acdb61b8b997eac5cbc5c77e72fd3c04ccc0a01a77183f210104b4bd6b5d6e830b55249ec9858328a1a1f504090000000000019f8febfb4e1ffc0002f8cd0001fc0002fa840040374e1c147337992d41ef2dfc974f928bd2d5a607ee5dd8d1e99e4bc8e015d94346580d7cfb1c44aeba71ea426d63532121268dec246f833444bb33308e53b8ab39fcc259aa22b93d1ab4e333353e6d56b9bd4d194985a59e0de5060c1225588a256569848ea421725223711b00000000422456a81d1601f5aab4494d935919058905ffe2dff342e8be1345f5e5b46c51000020422456a81d1601f5aab4494d935919058905ffe2dff342e8be1345f5e5b46c5120f9cdc515389213075782c4f03fad8a5010b7aa4165b804fbb1caae54c1c0f15701e1e77f1b5b7d2696a2836aee5e97b0eaaafe9fd000000000009b8aefd9fb4e1ffc000533b001fc00053d0d01fc00053fdc003d88e6f4cd4c285f48dadba815f581acc2e2df7c3d88e6f4cd4c285f48dadba815f581acc2e2df7cda952b3b45775c0af85fbe2e2ab21549d86beb0a3014f9192c3986e589f919f428c43770c3eca5c4ff3722d967d8f0d4b69ec3ec02fd876737fb06880a54566f5639389972000000004289460073f565eebd310b303cbc14fcee17c4df56a3b09e42888ded565599640000204289460073f565eebd310b303cbc14fcee17c4df56a3b09e42888ded5655996420d0407f4f9a7f087c1dd689e30783aa29dc3ed7da4b1b571dd314adac9baaa61e003b79244bcba351a570b19909002352062aa889ab0000000000235a990afb4e1ffc000bb3b40001fc000bce2b00f039342be55b7297da4170afd2df995d185f699bf039342be55b7297da4170afd2df995d185f699b1ec5c66e9789c655ae068d35088b4073345fe0b0309349d9598c25eb5aa9bc9d29c5c82fdbeefc73d1902ab2eee457b9898933a782f7db5676929c1cf3041db9322c06cbdd000000004292028ae9eb69f51d35a8a0f1cdd625f6dfee2a9ebc7bd4d9b7cb99ecc43f9b0000204292028ae9eb69f51d35a8a0f1cdd625f6dfee2a9ebc7bd4d9b7cb99ecc43f9b20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e6ef29d62543892b99ae4398060c478dccfc4ce432f0000000000235afc03fb4e1ffc000ccadd000000ecd8bcbf77d0dae7f59c750bf68d5d33a45ddfa2ecd8bcbf77d0dae7f59c750bf68d5d33a45ddfa264f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7308f70ff352844250e267b31c0ddb83dffd4cac43532194bd47cbabf410ca29fa7f1ecec08c8fde8c0d13910e903016d5a00000000429e8599b012fb642220d2308c8747d148f14fd3d92e169e5a5bce329853ef40000020429e8599b012fb642220d2308c8747d148f14fd3d92e169e5a5bce329853ef402003bdcb9deb0c0f2f807aabe0edf471a0bdaa803cf56fe0e855c2e60c119ee86a011574764041f46b7e8b0a3e77991a49c39f2f47f900000000003419c8a3fb4e1ffc000bb3b40001fc000bd23300f9c8a5855606a8895a4e3efaa42d987b2b7aeb0ff9c8a5855606a8895a4e3efaa42d987b2b7aeb0f1ec5c66e9789c655ae068d35088b4073345fe0b030814562b9c96db22a34d86e5c8db1fa30cf322fc3ccf743d5253f37e1cf09fb6347cc57bdbf221f076bf7c818caeffc430000000042a6958a544309799f965d193372baad8f38120a117e3700ad2d62ded1ed440800002042a6958a544309799f965d193372baad8f38120a117e3700ad2d62ded1ed440820c3448a2225a03a273f6a972bedb320c0eda40dfc46a11cdca62edb64212e1f3e005f813b236a6fbe45983588d7851c9344abe32d9a000000000023a67a3dfb4e1ffc000bb3b40001fc000bcba3009b6fde4a7f45246abc4d043aeab7c7d35934580e9b6fde4a7f45246abc4d043aeab7c7d35934580e1ec5c66e9789c655ae068d35088b4073345fe0b03091b5adb32d0031219fb93e5e8b20219b07b8a7860770e7d8935fcaa32ec36d75458180b71fcbd20a808373a16dfe972b0000000042f67134f85223da03fd3a670e68802d959ec1236fc6317b855d7133df4ee59400002042f67134f85223da03fd3a670e68802d959ec1236fc6317b855d7133df4ee59420a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e3054331ff5356c8a834bc40ec241aacfae8bf5c54e00000000003424147bfb4e1ffc000ccadd000000bb34d97e1f0a6406ea00f10eaced5e3ef227a5cabb34d97e1f0a6406ea00f10eaced5e3ef227a5ca64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300bde30ce81e7c6396e334eb1bd788b683535eefe9911286bb42662c46e3712ddb5c7c24d7998118ae089e804e14efee500000000431514b6af73d8a20f06ce90b838acc055d749d77762adfb29a918dbe7611352000020431514b6af73d8a20f06ce90b838acc055d749d77762adfb29a918dbe761135220319b982bf533a97290333d1a2dbdc0e5d516bd1c2add8c0eaa6d248fd26d732d007a4bcc5bcf61fabd62a57eae55f427a8a1fb8800000000000022d8f465fb4e1ffc000bb3b40001fc000bc7cb00e921c4edd1f6b892477f9b5eb39a324aa6e5839ee921c4edd1f6b892477f9b5eb39a324aa6e5839e1ec5c66e9789c655ae068d35088b4073345fe0b030981f8a7f20ae3ff84c15f27a7157dc2e4935e956ed25166035e012ecd7f0885d961564111704303642151aa6fbdf34f000000000436f16038374090405c95464197b0a756aa8ec72137ddbd21161fcc6fc3c61f5000020436f16038374090405c95464197b0a756aa8ec72137ddbd21161fcc6fc3c61f52025ca852a8da0b2ff4aac4af3ae4088c7ae49c0656371511c187f4de7f1f3b524018bbebe630cc30eee2942c1f398fdcd8ec7ccc8cd000000000003d8c6fbfb4e1ffc000b21600001fc000b42ab006eb2e3cb6be0a0244121fcd374a5dd38e4e0ec33e7cbf5568870f2e301ec84dd720ce2d71d2ef6db3a840c9fab8a7618147fb2f3060fd847cf86f08f3007bab9e0cfd301779007735cfcd14445ef09191df5a8ac39aa177abcd56d20e46f7aff4286ca6ff02f4747c0534dae9a000000004393fb7ebb6fa9df7073cfa5bdd241f420520e1a50e6f3b6f9c436d578bb26e20000204393fb7ebb6fa9df7073cfa5bdd241f420520e1a50e6f3b6f9c436d578bb26e220910cf7ec24b21aa8582d11d9a17fc912cb0f9688e4426100fb96a7e08d3a712c0017c0398111d8169fa33a3eebfaeb34ac7b82109c0000000000235b320cfb4e1ffc000bb3b40001fc000bc783002fa548f62b9105adc27c7c69f93e32b395009dfd2fa548f62b9105adc27c7c69f93e32b395009dfd1ec5c66e9789c655ae068d35088b4073345fe0b03006e17d8852c49d0bf9ca9cb2aa16aadc523dcba6af2db6d774b3092f8522595b72564f777a8d60ad8ea79fa1c817068c0000000043e49c1f2735906dc298e133e1d22e8fe4a2a4b23e05e871deb6e99dd6a924cd00002043e49c1f2735906dc298e133e1d22e8fe4a2a4b23e05e871deb6e99dd6a924cd20e0afab253c2a299493acab401cb0ff85bde56b38d310e86627713c849fea165f0066ca67531d6cf56218281080a0a9903032bb0edb00000000003429c6f2fb4e1ffc0006567a0001fc000bd99b00bcb01d935cf0b393aea40d7f0b39f24f27f364f5bcb01d935cf0b393aea40d7f0b39f24f27f364f51ec5c66e9789c655ae068d35088b4073345fe0b0300c33a73d7e9ef598da0b1b9ad04b12f98da67f75d66f1237866fa64f4586a4b156a83e8c79b38139d32f452dee313bf600000000444d4d1e9850cf19adcf3aa6e01e8a198779eecc8d55fe8bc9715726efc58987000020444d4d1e9850cf19adcf3aa6e01e8a198779eecc8d55fe8bc9715726efc58987203cbfe25dc4f982ee3ce537123108745285809ce3d8e5f71c6049b1b328356808015ee12a27a3bdbea28f50b697200e612dbd4a249d0000000000cf9af29dfb4e1ffc0001167d01fc00011b9701fc00011d0b003cc1fe7d3423d6a9a847723ecdee0368320171ad3cc1fe7d3423d6a9a847723ecdee0368320171ad5ee12a27a3bdbea28f50b697200e612dbd4a249d30958adbe9f954ec23983c4be5788e86e0df30fed1d6852136376b49c1a24e0fe1da1178b23dec4ea098b9e355aba8de0b00000000445e313b262961a5244f30e02946445dfcb52420767688db8aaa6cb5f382052c000020445e313b262961a5244f30e02946445dfcb52420767688db8aaa6cb5f382052c20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e4184248712d2e21cddf89379ad490e99dafabeccc20000000000235971c3fb4e1ffc000ccadd0000000a2d318258cf9455a414d2fbe30c69f5ce8d09290a2d318258cf9455a414d2fbe30c69f5ce8d092964f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73012fa57a5676925e8dfe3b340df2132f5844ad9f89594b04efa28fb4fb884fe21f411fa49120ed7a60ce9381a54232a1000000000446395517d8dc7a2fe06ffc2dcb5300c248a324b9bd5bd91532acd77eabb5d69000020446395517d8dc7a2fe06ffc2dcb5300c248a324b9bd5bd91532acd77eabb5d6920e51b139b1838d2b9b4bc77080544cd03c11eeb0c5b70f5af44f33fc940de433901a38211dfb24c64aedfd08760984fee730d6e60cf00000000010000000000000000000000000000000000fc0002ddd70001fc00033e4c016af70254b26589b80f06011b3de26f7fbf715b8e6af70254b26589b80f06011b3de26f7fbf715b8ea38211dfb24c64aedfd08760984fee730d6e60cf3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447962fd8a1e759aea5e00d0272df10c38deab7fd410c916a2b77eee7276b047000020447962fd8a1e759aea5e00d0272df10c38deab7fd410c916a2b77eee7276b047207ebcb8e4c5a9e6837e65e818f89ccd6063c1c5c3604b073ab60015b7ea7f41fe002c491d6e81334e057e3a1fbf1bb18ef2b90fa19d000000000022ddbfaafb4e1ffc000bb3b40001fc000bcba30075c6a48d5a612acd4bd3feebe0f6da422f685de775c6a48d5a612acd4bd3feebe0f6da422f685de71ec5c66e9789c655ae068d35088b4073345fe0b0308d3a62107f6534da1933eae8fae34d5b2c7fce2a39672e9c4473323f90dd9cfb333cc4d39b45cb220460b63c1d11009b0000000045a9800145a0abd2b8f4fe1fed333f712091bc46b4c1a4ed4c21390ec2ddeab600002045a9800145a0abd2b8f4fe1fed333f712091bc46b4c1a4ed4c21390ec2ddeab620410c3c13c2080484354a44116a425a0582bca2873f9ad8e9e914eaa9962baf6e006fa76977109534ddafa6eef7bb017d4c3a882222000000000036da6255fb4e1ffc000bb3b40001fc000bcba300ddf3baa5c5a1d3992213b6780d5bb228d54c2928ddf3baa5c5a1d3992213b6780d5bb228d54c29281ec5c66e9789c655ae068d35088b4073345fe0b030808963d5165e95a9c68094c7ddf16300ce59f127e4555633603efa4e776b026819e534ec54357e25ab467c9859e2a14d000000004636ed7acbacbc76aba60aa7a1011688fe9ad5fd701d0bf8fc42a502ea3e65430000204636ed7acbacbc76aba60aa7a1011688fe9ad5fd701d0bf8fc42a502ea3e654320cebdbed894cf5595b08368bcaafa6112fa743ac8bf50ec4788f5ae60e7783ac0007733a403791a61f42a529fd3281758a248195249000000000086d10594fb4e1ffbc4110001fc00019493006a6434babd99215b4f98316b3f701ecb7cca0aa2a820f49ed49d977621b499c9fc344f28a9b1c0cbb2334b22379811352d9988876a6e586d975e73293083a6548569b0c410d7e1dec3f4f5a18a0790723a991d3b9477a9e062c660959bdbe5b3c1d231195801b9072ae94279660000000046ce2b4b45b41f52b9e634ebc3e8b37c3e1685dcf53092521050884a2dff406d00002046ce2b4b45b41f52b9e634ebc3e8b37c3e1685dcf53092521050884a2dff406d2013f4687763666394944279985ab891c698a9bffc567be7751a80488f98f0cd210189e26bbc182969b51b8d729c0196c0f7b29811d4000000000036caf173fb4e1ffc000bb3b40001fc000bd21b00f07a6a479a2cd5a6e130d51d128a8ca998d1b209f07a6a479a2cd5a6e130d51d128a8ca998d1b2091ec5c66e9789c655ae068d35088b4073345fe0b030870b84b1994be69b0dcfee35aa1e5d1042ab1407b1eb5622eef0fa248e562220695ca423ef6a41abdeff3d802d1ca2440000000046dbd118b9d9b138a5be20446ae3448e8c41acc8c28411848fc85f563090b19600002046dbd118b9d9b138a5be20446ae3448e8c41acc8c28411848fc85f563090b1962094aa08aaeaa7f1581edad08db7bccb4cb24055fe20dd3c783df878e8f12a0042001bc18ed01b8e3a9f78a209e7eb7f07edcdacb0ff0000000000a516e93bfb4e1ffc0002925d01fc0002aaf501fc00052cd300ad0d1c7493405ae2836390ada4ad0227c8278f39e3bbcadcc1f89ed98a2ada3473bde7dc618cf3a763df30d171377fbf7611b741436a40d70969a98a3097adf3867ae5155b18345e44e277ab26b9a497c7d0cf9b53bdc42362dff3642c922d1d10e277ce6bd407f48bfabac68b00000000484c56b2f30e7a223d5a633d19bb54100bf9bc8a1a6ed1e72ba86c9758558d19000020484c56b2f30e7a223d5a633d19bb54100bf9bc8a1a6ed1e72ba86c9758558d19205b016215386c035a42042a93736befccdb87c30cb90adc3b1279da58ac57cc1401112c35b14433e8a28f70889c6d8ca99095bf0a91000000000036b99e7cfb4e1ffc000cf8b101fc000cf93601fc000d049300f6dfd96165379ea02d0e5650085cbc5765d22df2f6dfd96165379ea02d0e5650085cbc5765d22df2c69a0bda7daaae481be8def95e5f347a1d00a4b43093b18f6658a9d0830057a2a0513c2f4bc70eb0c41df4346fc849170fe0b1374716d0d1ea24726fdce68636fe713ef44a00000000485d33cc5a823b6ed0ac345b93438ecbfc44aea7964ca95cfd998dbfaa16ec76000020485d33cc5a823b6ed0ac345b93438ecbfc44aea7964ca95cfd998dbfaa16ec7620a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e4c9d7137cc2ba84ef788209f51340daf53f40a2437000000000023594254fb4e1ffc000ccadd000000192cc27d195d1a06bd813765887587824d036b25192cc27d195d1a06bd813765887587824d036b2564f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73015f9da603c572257802a689964ca8f4d96f9b94f33ab75968c9cb6c730a28d50b7bb72ac2cfceee6ab0755ead9cb53cd0000000048c29275ad2ba66954b3ed4d58a29c799da0abcfbbd38da9646079e94610c8cc00002048c29275ad2ba66954b3ed4d58a29c799da0abcfbbd38da9646079e94610c8cc20d3ca56e9eb70d7e9a43a93f27446d29c9017bd3225905e50b1d56daaa6c515c10089ffce4da0663d5e5ae1a930ca9f919b8e7500da000000000088f459e2fb4e1ffc0005e0ee0001fc0005e26b004188469fff56b20349d06ab783d8e44b7e698a734188469fff56b20349d06ab783d8e44b7e698a73776e544e9097c2457f74dd5bf1ee545643d2ceb23090dfa669abbc6504966bf8cc2b4971db18a5052b70475fdd5e6f427349635ccd6b9c7869b52ff3133c5661412ea5ec130000000048eb1b545d87e712edb1382d8bee300aa0bae80bfd0c347920f4afcd0ea34b0b00002048eb1b545d87e712edb1382d8bee300aa0bae80bfd0c347920f4afcd0ea34b0b2093e40ad62d5fad58ff996065d66ba1adde1f4c1d47ab9407614c98f8523d95ff00c8b1d47b6f0a98d16aadcfa32910b454024fb63a000000000023a84ebffb4e1ffc0002199b01fc0005007901fc000607bc0098bbc48b046bf66975aaec4bc7a1d9224d75c75e27ab63981bb3d5f5b0375ebd3c709b95174ec67a253cae727106faa4bf76b0b4f8375091889f671530051b1a638ba22cba300ba0836304586ba5572a525622c4dd49e7178214985277eebad66a371253163e35e93d3b44081b00000000493422474d55896888a6eb24804cf3af1d7479956d6706a44ed80aa5cde12af7000020493422474d55896888a6eb24804cf3af1d7479956d6706a44ed80aa5cde12af72054d645b1fba1e7adff0e213c3fb1de352e6f806fc7c5f9d0b716599b66c7261a01c940f123afaf075e70ab25bc4cbf59248e37e7e400000000002358395afb4e1ffc000bb3b40001fc000bd20300d40244c9f7115897ec1afb80fca9e5c7cbffa2e2d40244c9f7115897ec1afb80fca9e5c7cbffa2e21ec5c66e9789c655ae068d35088b4073345fe0b03007e428808a71ba6201f8bb0a3dd71be6de31816eeafb1108b3710e956db7ef5bcf2fb8bc9976a20799077a24fa847d660000000049f9818da1c1948ffbd964d593b7ef590031b794617e62587d984f61f2fbe20e00002049f9818da1c1948ffbd964d593b7ef590031b794617e62587d984f61f2fbe20e20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e2339ebe0fa295b303b5b8aadfd91a64d75e46740590000000000235bef4bfb4e1ffc000ccadd000000ec97fc04493eb004db432813f88f3ce6e730baf5ec97fc04493eb004db432813f88f3ce6e730baf564f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7308c1cc0f5e0a5aea680a170ec945074f5b83d83db4d208854204f57c0de220ceb63b0121bd2a7bdb214228338c575ff6f000000004a7d3e011dcbe58192a8bee91d366c6f3720d8247a7dd586b8a50a0159eec9370000204a7d3e011dcbe58192a8bee91d366c6f3720d8247a7dd586b8a50a0159eec9372026dc073174dba917c013e7e0751c19e58fb1e7f86fcca485b2e96d2933096ae400986b9daca0805a7096a6c63e7873b66f6f49c055000000000022d149d0fb4e1ffc0006567a01fc0006c05c01fc000bd4aa00f2ccd30a71c62243bc1b85b0a7346be5b0365febf2ccd30a71c62243bc1b85b0a7346be5b0365feb1ec5c66e9789c655ae068d35088b4073345fe0b0308979c7c3f2f5778e536fa1136af3a024021cd7be5c6dcfc2d51e84091783a5b512b7f6a2c5851be08437be08d17199f1000000004ac3d41c3b2fb88c4e4c33b465ec1150b43522985fe221f18c4b91b5f7b43cdf0000204ac3d41c3b2fb88c4e4c33b465ec1150b43522985fe221f18c4b91b5f7b43cdf207523a0aad3ec9005879e0066cc09b41e57f3b9fd6110f99de7d485ad8f1f192b0143c1ba3eb8658a4a88acfc9842eef008612bb8a242c8000000b93e96c3fb2711fc000152b90001fc000155c4009b977ce8fb19c58e12c2da268990d358df102721208d9e4d63aa7667b7b67bebf81d9e58e2f4d464b88b7859dca0971128eca01438c8a22d7ff13b5f308ebffc014c8b97d9da8841464d3c7cd09b9f679471a068666c217ec13524ad7ccafa50eb18126c99edcb43fb74e290b901b88b7859dca0971128eca01438c8a22d7ff13b5f0000004ba9ca59a188bca15df2ede79db16e72f427d2f8b6f6786d82d4c64319411e230000204ba9ca59a188bca15df2ede79db16e72f427d2f8b6f6786d82d4c64319411e2320a9fee48733f80aec8d5fa07e467748169501c42f39b051f970827b977e4c68c501f74cd1f9e2fa05c4244dd2489fc836825e9f10d800000000000343bb9bfb4e1ffc000b2b630001fc000b2d1b00dc02c3b908e77a84a09427aaaf15c5256f5b458e1f69134183fab7568ebf7eef6c97f80b3ed603aeab2f3158075540dbf499033592d803e7fa3675a2308b7381340a3e266498248137c146a3c82e36c27c196bac05772dd7b22132912bcfdc1263e2761245b6871b47dba982a6000000004bba47ad7330a358cafe2890f1578f874006a68bdc7b786a7c1d440823e683d40001204bba47ad7330a358cafe2890f1578f874006a68bdc7b786a7c1d440823e683d420ca7dbad69767b30fe851c08c80df2cc8398bcc8c33df2d03bcb810485f3d8d31006e6c9189021b6e38326dff6886104054a110990d00000000005fd916b6fb4e1ffc0010871f0001fc0010874300bd8b7dede4dab5e22b84ee0f3dace1c1021add92c9924137fa318dbfca7cabf3a1127fc358acc74d6e6c9189021b6e38326dff6886104054a110990d308ebfddfa72f3140798b6c0d89190164c4dc569ffdd95bd1dd43e7f54f1405c1927b37b499623b4c806ea396bea40a84d0001b98306c317875b12fae8a85c85eb23269168981801fb682301fb01c14d13a8912d3119f1a9eea95d70a546bc449307af3521dd532c0ecb1ee5a494d70000204d13a8912d3119f1a9eea95d70a546bc449307af3521dd532c0ecb1ee5a494d7203df27e67f50cb6875d7b692c594939cf46afb84f80c3a483181a3235532c325a01c329e938e558a6f1a348468050a6a0a48f8468d1000000000036c8c8e4fb4e1ffb66b70001fb69fa00e855484a6e6f72f6f4793b80cafc202a981fe8c1e855484a6e6f72f6f4793b80cafc202a981fe8c14fc445e107964acb8baf2e91cc87acc92ec7fa6c3009ca23af93ce00a95bfefe790ffca791e093a8c0e79675b103b2a4d06f930433b3f6b15c83f4e2c4b5118fe0c27ca13a000000004d159f983d445130fff5ade93b05e01172ee4c56ee3c5b252277615ac10c4c8f0000204d159f983d445130fff5ade93b05e01172ee4c56ee3c5b252277615ac10c4c8f20313e02ee0e20e1cdbca93d89490c8c9caaba06e6558670cacd259f1c8814007b01e0464a5d60141aeb8650b95a88f576c86ad8230200000000003425a9c4fb4e1ffc000bb3b40001fc000bd23300f062a34a0fb6489242d4679a98a4b853087d6903f062a34a0fb6489242d4679a98a4b853087d69031ec5c66e9789c655ae068d35088b4073345fe0b030848d62d66f87f7de6ad828ffbfbd1432dbc983ce86bba885cabf1114835f6de4614d3cf293d6daa92d98e5e1ca36d26e000000004d5087a16a45ee3434db18ba9be18b627794ea9fcc2ade4411ab0745c587c16a0000204d5087a16a45ee3434db18ba9be18b627794ea9fcc2ade4411ab0745c587c16a20486494877c77a3dd5d80aea481a1dd6821d00eb7785d7c5b0646dfe9cc7c01b901a610254a55a28d50033f2df6b34baf904c3132e3000000000041152056fb4e1ffc000c329401fc000cc8b801fc000ce9c300336788df1ce1418edfb0b8321db1611264010a7b336788df1ce1418edfb0b8321db1611264010a7b7ad529c7f0f78a1f5a4ee5c4f8855dad34d7c535308162401aae703d5bb3f53a7b9c5b65b9a94dbd1c207a8da8f1350200a960d1607e89e50b365afb14cf3b700662342a4c000000004d5fe9da329316db465fb3f4925cd5604dd61335c32f0b7d79bdcc98e71880d20000204d5fe9da329316db465fb3f4925cd5604dd61335c32f0b7d79bdcc98e71880d220a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e50a4cbeb2381d842c9d9e0221395627f391d1581a200000000003422fad6fb4e1ffc000ccadd0000004bd7db8a067386d8bda99986fd6661186757bf954bd7db8a067386d8bda99986fd6661186757bf9564f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73087be789e5b798cf3a40ff5dc22b0384dc690acadd614067c0f7e6a933b8f0c72c67b3f4b3e666e6fc48369a8161b04e6000000004e440fd1740b4ad578af9d5f11667830eaf8f422898c00d891e3f3cd075ea6130000204e440fd1740b4ad578af9d5f11667830eaf8f422898c00d891e3f3cd075ea61320b1e914db9a6663500db9ff75eba0c6717a9fec4abd9abe995897ca5cd84ec20e00beb09ba540e70a97843006e392a012cb8cbdc70900000000005fd916b6fb4e19fc00108b3f0001fc00108b7b000586047cd6cfc021d742ed07f331cc5e41b6b76d21be19b26057cba9acdd22fabf0d3643e8440b65beb09ba540e70a97843006e392a012cb8cbdc7093090e7cc61a596c1cae0c431f22e92ad1ea142558e6e2fdfd8cba033040a4bc56e58f44ccb3380d10ce89246fb6f1c52bb000000004ee1227ac0f4be1fe27ec0d00601287cbcd3182d3b10db952fec225d68f717b90000204ee1227ac0f4be1fe27ec0d00601287cbcd3182d3b10db952fec225d68f717b920037c32c262a9f798855661033c70a485c9efbab9379458ebd2bc3dce1f2cbf48011f6a174996c5075c827596ea0bfc10a97a071dd100000000010000000000000000000000000000000000fc00067ac70001fc00067af3016398e2e031739ca5378d8b64d33340a99d1317260258f7afa5a4ec575f6781fb2d91fd59f8a409d63e28db34964d56b44c53996dd85877e69c9453ef30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004f4cdd55a71a68183cd6ceb8da6e95c9526e259ce0d243e297ecbeaae0f93ef70000204f4cdd55a71a68183cd6ceb8da6e95c9526e259ce0d243e297ecbeaae0f93ef720b711c40f6d1eb02fff2b03c35a759fa63b3eedc2b47e59191b7e1d0353b814cd0072235a751c82d0d01ab336190bdfd4eceebf4a6e0000000000b23e5de2fb4e1ffc00022f9b01fc000266ac01fc00052bcb00a97f2ca1f2953b0ad3dbc58b12fde33f39a4fbeee0cabfbceeb716b5b558739f218f9516c16918d272235a751c82d0d01ab336190bdfd4eceebf4a6e3093a5eb4a6fb84c13bba4d597a6f9d37f565048a384c94d3b81630c6965a023eb3748b6fed0ebc224f051eb23f50d9ff300000000500bde7398a2ef46b93994f34d3607875321076ee3ef975d5477c3d06b0c1659000020500bde7398a2ef46b93994f34d3607875321076ee3ef975d5477c3d06b0c1659200a73fb35537392612450d065440abe6b192373607da402843c78ceddccb3cca201f958e2271fac8498a057a0f4715f46ecae3993bd0000000000a763b737fb4e1ffc00051ba001fc00052fc601fc00053183003a442deb895344b8c98d1f96db46d73aec73149334e4669b580af3248979acd2db51c30d0794c76ef958e2271fac8498a057a0f4715f46ecae3993bd30822967c827427a4ea722459a6a5d007c5a14e1da4b6fd52417914cdac7dfbc9233dd046cda0c2980d1936cfa8b22920000000000507e64b697d351d57308e00312cb269564502e07fb3a05c501952de3972f059a000020507e64b697d351d57308e00312cb269564502e07fb3a05c501952de3972f059a2034fe0ea681d38ede04970088cdd82161c09e03c24f08d62c08bbecfcdc62ec1b00979be1258712fc0292ed17304a2aa2f05ae762e6000000000036cb2ac0fb4e1ffc000bb3b40001fc000bc79c00491b2884357e499e86dad5fc363b951305570ace491b2884357e499e86dad5fc363b951305570ace1ec5c66e9789c655ae068d35088b4073345fe0b03081baf71805fd63ca4357d12c6b77cd04b70846abd99d8dfa9e8b4469c2d167909399b2efcb32ec817e7fe75324151c080000000051172935cfc699e312ec12338e14d12fd54a5fb4065922055980d8206ded70ec00002051172935cfc699e312ec12338e14d12fd54a5fb4065922055980d8206ded70ec20ca564761a2aae2a77d104426a7843a92995d2d94f7e951d792bb78fc22be0d5c00636bf0d4a97d772962f96c66675629bd3e6578ff000000000022d0be82fb4e1ffc0006567a0001fc000bdc2300587cd605573d22f879d8f02b4fc6901ffa1ce1df587cd605573d22f879d8f02b4fc6901ffa1ce1df1ec5c66e9789c655ae068d35088b4073345fe0b03005e41c9c5f3e90a39f01b6a6723d505378fb3a25e19c0b7915303a1e7da89a19ed0a1c5ea765a6ed2efb3710de56f19b0000000051238bb9e2b68fc822e8eb15d415e97ebc86f769a72c15e0a6e25d9ea8d3847500002051238bb9e2b68fc822e8eb15d415e97ebc86f769a72c15e0a6e25d9ea8d384752073663de296744bdf1a11ef3f43d64e249644ea7499e54a8848baed56d716fc3e002b7856de53d4c1823090c98f8ad79862842c09b54120000000b23ecbf9fb4e1ffc0006b1f900000091448a07a2696b4d310761442aa07e3f2021cb731341a33990289395b5659a4cb30cc07ba002b505288e0340106fb37e4cba12e21c2af87e965ebb8b30ace65ce6933fbafc8686ea9e8ba72bc98f3d07905b4ccfb83162db440308e9255f708ce4f2623b27f9fc04fe11cf605700000000518ebe3158701e981095522cab5941883e56240c8ce9ddd79247fc5efa00af3d000020518ebe3158701e981095522cab5941883e56240c8ce9ddd79247fc5efa00af3d20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e162ad150d5b108c42779d7e62869b5c32c2352498b000000000022dc764ffb4e1ffc000ccadd00000081a5a6e113fbb398b5dd1a3817a4cd66b955b58881a5a6e113fbb398b5dd1a3817a4cd66b955b58864f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73096594c4eedb5183b0a4e1e96e45bbe8a042904abea4ece4619cc4c3c70073036adb8eb9130a672481eef6a2143b8761c00000000520c7377bf695cde36a0dc0ddd9aea060ce4a4cdce59022e7d74f501e5fa71c0000020520c7377bf695cde36a0dc0ddd9aea060ce4a4cdce59022e7d74f501e5fa71c020a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e62dab139056dee908016c56f7676e18f04666c4937000000000036bf9289fb4e1ffc000ccadd00000033fe2817ece26659df352c7abdf87f8cb7dde58b33fe2817ece26659df352c7abdf87f8cb7dde58b64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730842d732a03847819b1e2675ac48b9af4a1c92b310ecacc42c428ff902099cc47d08ecd4616da55d185463855aee99f7900000000521e7d6a4b937cb19dc62371436f1805c2337a772a5e3884097088b23cb39c9a000020521e7d6a4b937cb19dc62371436f1805c2337a772a5e3884097088b23cb39c9a2016bfb58979d90f27253d7a052b620631266a3f35e1e46fc40ff6481f2acebe40000ba3bc9b96c628693877db3bfeebe29b3ac1b1ae000000000023596403fb4e1ffc000bb3b40001fc000bc76b000fe161af74ed12af85556bae73fd1d3af6a01ea40fe161af74ed12af85556bae73fd1d3af6a01ea41ec5c66e9789c655ae068d35088b4073345fe0b0308d51215f8e1c1f68fc8db92517650a76251c8ee8800de92b97c7f4d29c50eda699c82a7f671b597eb52fe08cad760d6400000000528b059c0430be26babd893fce8850ef5f10ba1b166331aa66de0f58f1bd5cb9000020528b059c0430be26babd893fce8850ef5f10ba1b166331aa66de0f58f1bd5cb920778ce40a708f33b1ed5239b14edeae85497eef97146cbbb8ca62b37873abdb07002300d33f550b325773744b9f8843a65151388644000000000022d1a62afb4e1ffc0006567a0001fc000bd983009678d36b05e068a7aefc08edf11353d6db33253d9678d36b05e068a7aefc08edf11353d6db33253d1ec5c66e9789c655ae068d35088b4073345fe0b03080a3e42e4ef0c3f27fcc7b70edb253590af1ae9865bc936210f0b68f8e7c0690b6ba65daec04e9da61da85ec8865244f000000005346dd62f6d0d846ca8b37cad7e4438d1effa1a61a63f8d55ba93069f560949b0000205346dd62f6d0d846ca8b37cad7e4438d1effa1a61a63f8d55ba93069f560949b20ef27728a1bfbf13abcf7420e3118cae96ca0184ff1d0a796b90c51a543202b0001a01a6124dd32d31434325f8b39e3133ca643b8c3000000000034348bbafb4e1ffc00013b0a01fc00014e4301fc0001517300692ac6d2aff4da4de4a815b41b58369de627380f692ac6d2aff4da4de4a815b41b58369de627380f69a9e3015032f43608f55847cfac26a1926ace9b30847178ed08f0f5728dfe39ba9e3a43555b4c5e8100d825d91bf452bb7dad7bce7e8224fb665abc59cfc74d3bd1e040e10000000053572db6934dd429546362bd33dd18aed1a49b96dd9a8bf0ce1936975991b6b200002053572db6934dd429546362bd33dd18aed1a49b96dd9a8bf0ce1936975991b6b220b2b69159973619cef08b9add969ba4d1ae18dd33bd62635429d44d93b62d5753013ee3c4a4a092ba275cdff0c03b912eb1d83c5e8c0000000000ae22e975fb4e1ffc000cf13c0001fc000cf6cb000d432b7c544c11176c8b543613cc395f4b1bbcf8ce7f101b7f075273c892063b1b8571311737a5767f95c0f808aff27883260bfaf9cfe2b84519a6b23007f818e5c2330ac4e7f0ef820f337addf8ab28b07c9d451304d807feda1d764c7074bccbbd941284b0d0276a96cf5e7f0000000053bb55e972ab4f796aae8c7eed34d09adc55241edeead6c7171c2ada2769c68f00002053bb55e972ab4f796aae8c7eed34d09adc55241edeead6c7171c2ada2769c68f208230f90a0fa0e758f70dcee360ab25c46f3c43e674fe277b60ca7764c5f420840076e959b03bac123bf2ced68c6705fe4fd4e280f441700000002269201dfb4e1ffc0008836d0001fc0008844b00df18a921f89745939ee3f00b9dfc07a167f4061fc291f09365d25227523575b9f07683a28c205a30de9aea4685986edd2c37ee8a3245d8886e63fc663008af8fcaaef14df7bc8ddfae8fbcb1f239040be0ac89d43ce0f27ea3f7a00d1685ffc1075614144e70f02df385a996f7000000005557273f5922d9925e2327908ddb128bcf8e055a04d86e23431809bedd0770600000205557273f5922d9925e2327908ddb128bcf8e055a04d86e23431809bedd0770602011980a810803e9264875774c7b736eafc40e3c0c6d86b719f2e54143874d0299011485ab410c60ed103eb5a0bae666add00978a88140a00000005fde193cfb4e1dfc0004a2b30001fc0004a34c00b0e606ec0ec732170fada5204ef8ef5d1dcf73948fd1a9502c58ab103792693e951bf39f10ee46a9cb4b5cb5765cfbfbc3ae17aeb48f8533bd5391ee3008b66151b81bd6a08bad2e68810ea07014012d6d804859219958a7fbc293689aa902bd0cd6db7a4699c9e88a4ae8c2c00000000055cd64d8a3d53fde1faeb46de639a7478b4559aa9040d37b2b19a28a7c029cf100002055cd64d8a3d53fde1faeb46de639a7478b4559aa9040d37b2b19a28a7c029cf12071f2bf95b4d52ba83c2fac722efd30723f3e99ccd83849006df4045760bc919e002e7e345d77cab6d1ec5e81f17b98f1e4d0ebc4984120000000c1758ec8fb4e1ffc000ac3160001fc000ac34300d2f955d617b4c5687619d9030ff1b9bc39a7fb4ad2f955d617b4c5687619d9030ff1b9bc39a7fb4abb42031cbd012787b56d53dff7a46c1d0b66ff77300a1442ae1b122649814bd8354b4daee4a289220eea514988d6cc93ec6302e346bdc77236c91967ff86362d81b18b1c7c00000000568a820b27ca755a2dbd072d68d0a8bb19ff486b472aca350290ca30ac7a934d000020568a820b27ca755a2dbd072d68d0a8bb19ff486b472aca350290ca30ac7a934d204d937aac30ca900235ca2a476b48ff19bba8d0682d07bd2d5a75ca270b828a5601ae69c3808753ea7dd0e2e3d1565ded12d8eadb9e000000000004030201fb4e1ffc0007581001fc0007586401fc000758930094c7496c719925d805ad2f0a75c837fd9abc52c794c7496c719925d805ad2f0a75c837fd9abc52c754de5d26228df57289545787fa448a7c9f7ebe2c30983bd995f3e1280858f37e33edabbd8ca4d90605e26cb6dce824a2c03f83dd498180085db4168f9e6b4df0b46a7f4f54000000005725d47a054dc1b4d34f719c4f9a5a75b52f08b59b0ba5ad788c1e29bbca0ca50000205725d47a054dc1b4d34f719c4f9a5a75b52f08b59b0ba5ad788c1e29bbca0ca5200e2bea11a7d2fa54cfab488d4cb0e7e5c28d8fb1f17b89b3a5346bdec9b53fd900e4f9a674bedaa1272b51355d8efad13d6fe7653f000000000036bb2f47fb4e1ffc000bb3b40001fc000bcb8b00482738ebae2e214d55bbcd03d7d0e81a7130f955482738ebae2e214d55bbcd03d7d0e81a7130f9551ec5c66e9789c655ae068d35088b4073345fe0b0308397590e589e42728f349a499466c06a7dbc797a07787b79145d6e18ef9859e0b07e64a665a3e1c2b54663ee8dca6bd500000000574a8a1c55a14ef27fbc1cbc52545d9e94944984c1201fba3aeacc309a63660b000020574a8a1c55a14ef27fbc1cbc52545d9e94944984c1201fba3aeacc309a63660b205fd493a731389488c69e721fbe31f8996395311728f8393c97648970b1c3f0af0033cfb3f4008a512c56a47174b23d40700065161700000000003422e1c6fb4e1ffc000bb3b40001fc000bce1300175b30c912de7bbb1a71fb1766ca91eaaab6e8b0175b30c912de7bbb1a71fb1766ca91eaaab6e8b01ec5c66e9789c655ae068d35088b4073345fe0b03009637af6c8533b5329eee8457477bf89386af20149a7f4ad3a76dc74876907cae2672324e816d70b9160e27e335f1bc0000000005855f045dc4db4213f0bd153adf6ce3a02e59a06a3887cf01ff552f81e580cc10000205855f045dc4db4213f0bd153adf6ce3a02e59a06a3887cf01ff552f81e580cc120e75569a4dfbbd1fd45e5f54f03642caba755b5ff7d1e2919f71c069cdb9266d90012da5021d6ab01854ecf7510d834d6ae89cead96000000000012edcc99fb4e1ffc000656800001fc000bd4aa005b7fffe5a92fb181e91ab6fa5cbdff30266c86d25b7fffe5a92fb181e91ab6fa5cbdff30266c86d21ec5c66e9789c655ae068d35088b4073345fe0b03018ea4f800b55d185f2abf9b0df7aee48cdca7089178e1b1ed212f2b561eb2f66d638c64e9a3dec12490c04a4deac6faf00000000585674740dac63692bbb0ea4ee899c575f9883e91fb5ba5ebf26b5b2fb66f21b000020585674740dac63692bbb0ea4ee899c575f9883e91fb5ba5ebf26b5b2fb66f21b202bba3595a323203f3baaf14c9e656a2db305b371f974fd2c08d63559dcb356380181949e154a2d3e19abaadccd78998f419f86075e000000000034dc8558fb4e1ffc00012b5f0001fc0001305c00c1eab1a29d98db4b44708a6db97dfeae5fb123c60e03a8899ae0f3a5771fa41ee75752713e920fd85aad5c1b35da17982597334b504c22752cd6319e3093dac0f5d028eeddeaf4257919511991872523675ab24d1d971af3ab1900f27fc617d1d53a846c32abe1ef52a2cb26ee0000000058eac04dafeed9c30b3397c527714c273323fa036a0ccfe5aa71d5c4fdcc270800002058eac04dafeed9c30b3397c527714c273323fa036a0ccfe5aa71d5c4fdcc2708205529d4297a7587a2a915070b9b6f53eacdb4350d118e5af99b6a2abc8b500029005127e6f29037d8849f2a3be369dd9989e383016d00000000000b7a212cfb4e1ffc000607b20001fc0006087b0044c8afafbb5c35b797e7a8876f8932829f99c6c044c8afafbb5c35b797e7a8876f8932829f99c6c05127e6f29037d8849f2a3be369dd9989e383016d30046e3d8efdf54e1cf182c8eb894c4bc1a2845fd3e8e20a383a80435dd131e34e69ee562cc7f31628960e1ad57fdc538a0000000059d45830e45260a043fdd196f966679f1a63f1b6c28f04563738226bd654865800002059d45830e45260a043fdd196f966679f1a63f1b6c28f04563738226bd654865820a042308e7ee24af38a5afdd588c33e007a0ff9168bc6cdbd7ad29836488c64c6006b4ca496710b456df19d9f8f7bbda99d4a9bbfe4000000000036da68c2fb4e1ffc0006567a0001fc000bd99b00717fb4495269642bdd0e16cbc60d15e31a2802aa717fb4495269642bdd0e16cbc60d15e31a2802aa1ec5c66e9789c655ae068d35088b4073345fe0b0308ba4d80404dae1a9a1b3aa7bb7173ba161b87f3212cc4566bc22ff9cb1253376d8f9edfaab3db702a32741b1bd902016000000005a5b3a5da96d5ee8ec30e9cfe76cf0c407ef040836d2dcedd94c4315c9f07b590000205a5b3a5da96d5ee8ec30e9cfe76cf0c407ef040836d2dcedd94c4315c9f07b5920597bf0c915434cd9eddcd2360804ef07c4f06ce7cfe930ece85e6da95d3a5b5a016cc8146b2b970595fbf4e267afcfc3212002584c410000000012de6f46fb4e1ffc0005418b0001fc000543b40010b27fac0d3106227397fb1cb91eabba630c0a31f0c742302a89db49217e328e18811d0ab1904ac5da952b3b45775c0af85fbe2e2ab21549d86beb0a3080f8dfef131ac329d428504e7cb89974f188f07caef0668df1daa4ca8fc5f50f6c5945f020271292dc220ce313c00f16000000005a608427d3cb472597fe47ed7f9c4b430961bff0e7fd3bbe3a4553375cf2e4ab0000205a608427d3cb472597fe47ed7f9c4b430961bff0e7fd3bbe3a4553375cf2e4ab20abe4f25c3753453abe3bfde7f0bf6109434b9c7fed47fe972547cbd32784605a01118b5a615cdde7e435bb8bd1ee15a7f4c490d21e0000000000ae22e977fb4e1ffc000c225301fc000cf06701fc000cf6cb00c1ad3af209f75deaeb9216fc8339fd48d376f9b0ce7f101b7f075273c892063b1b8571311737a5767f95c0f808aff27883260bfaf9cfe2b84519a6b2308a0ede82d78a0a8f4c2332d431c7be496c3aa09349ed3b2db30f7eb7dcc7b6e580a9d71f7d76bdaca1b3670e0cf4cd3c000000005a6d674367f4fad9883595d74d6eb628c59495a3af0732d24db983359cb7127f0000205a6d674367f4fad9883595d74d6eb628c59495a3af0732d24db983359cb7127f20de14b280405beaa7359475326e337d7fe322e550a612c188c8c33f1ec05ffc7a01b1ec17072d731ed30edac35422f49fc43c6117d50000000000b9c313d4fb4e1ffb89660001fb89da00a6c4b0ce143aed43b6665e086fdabc05f6797a2aa6c4b0ce143aed43b6665e086fdabc05f6797a2a486c5d35a36a1cc86cb1c8946be6c3095b79a544308f53fb19c3be85ce00e96d634221f20a06a3a50942998193004264075a70422a3305f57c0c478a70ad69f1112e2f9993000000005b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a230001205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2320774441a2d4ff6133747a8bb1b5e4a9a21bb73c4b77cf31e85bda68f898949db0013f978f2c099e310cac9e854b99bc981c8fdcade2000000000023a5327efb4e1ffc000cfb4d000000ebb7d8141ecbdf2abcdc3ebe25420b9425745293ebb7d8141ecbdf2abcdc3ebe25420b9425745293c69a0bda7daaae481be8def95e5f347a1d00a4b430b44cee83a79fa151527e527f3f4f5ba022e73ae8b0d913c4185a45c2a129aef935a585a7a725edcb36ece72a957586880001f460a07a2b0dc932e1d8ff2dee2b984ac415dceb01fb8f3001fb05a35b5e74eaa81cf214241dc38fda186e7782243b77f112bd61c3e4e83f49f27a270000205b5e74eaa81cf214241dc38fda186e7782243b77f112bd61c3e4e83f49f27a27201059a0d6de258ea8455e3b995cfc62aa2773a3bafd6e1fcc00e9c4c5b8bb9a7d01433d10cc55f8c79b2dc5909099ee24ae9d3f56590000000000037c8ecdfb34a1fc000d6e440001fc000d6e9b001c2ce317e6977a829188866e9d4f82b53b82ac0c90d6c5ee0763ec84de95ae93cdabd1155d9d8f4e972364013299903de8c3a8c504669542ce20fd04308119fe1f9f05f7222f62c4b22a05880a89e4d8b3b8fd3011661df80e46da3ccb2222598129e3e67998883ede2bfe1143000000005be5a28138a658a802a1e871d7bb4a5e8a167effe9e665b4a2ecaa559d01734e0000205be5a28138a658a802a1e871d7bb4a5e8a167effe9e665b4a2ecaa559d01734e20439873740ad2b64a21becf94198b3d570250c8230b4a0ece9e0b78a9035c189b0096fee7f21ab31bda8471cec48b23e87b029d42d7000000000022de6689fb4e1ffc0006567a0001fc000bdbf30028a6d0e9738eb5ac91e4e5e5e715f0b16631396728a6d0e9738eb5ac91e4e5e5e715f0b1663139671ec5c66e9789c655ae068d35088b4073345fe0b0300dd55240db07aa6079e3b84af0d86acf307411f6a99d9570eebec93b6e7e5890db40e31efdca4d5d7bcee1f105e80ea4000000005c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4360001205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef43620593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0f62555d44fc8d089674bab5d090a48825bea701b700000000002cef2799fb4e1ffc000cf99e0000007ef7c15840f96c603fcd29409a70f77f878d25d87ef7c15840f96c603fcd29409a70f77f878d25d8c69a0bda7daaae481be8def95e5f347a1d00a4b43086d0a2ca6f434eaa47ff6919ecafa4fc3b012b89c62a04835a24c00faf62c3d30d3f8755c33a7abc595e96fb5b79594a0001972a33056d57359de8acfa4fb8b29dc1c14f76b801fb8f3001fb05a35c6d5b4d2567346b2ada40d2dabbc907cf8a53c352593333e7d1fa8a635572080000205c6d5b4d2567346b2ada40d2dabbc907cf8a53c352593333e7d1fa8a63557208205b016215386c035a42042a93736befccdb87c30cb90adc3b1279da58ac57cc14046094547209833dca44803c3a5b039a038be4034c000000000012eddee4fb4e1ffc000cf8b101fc000cf93501fc000cf95300bfa25fb4ed44c385e69d5d8369a0a7b90d68b4f7bfa25fb4ed44c385e69d5d8369a0a7b90d68b4f7c69a0bda7daaae481be8def95e5f347a1d00a4b43096f1efdb9fbe12961b7f113de6a5e57e6f547a3b27b4b8941a5265ddc51de7b6dfa7eb52ef96fef6503b4a729884ef12000000005cd86ed16f87819dca7b6e4e3d24947b1a6328ed8cc4c9aec7af35fa2b1622200000205cd86ed16f87819dca7b6e4e3d24947b1a6328ed8cc4c9aec7af35fa2b16222020fbae7f5db70dfecd69081854b27514ec0b29f4bab86717174e0220bd7bb9584700b9dd1b5f9c18e8260fd7e7f9f1d9503709f9168b000000000044b7a710fb4e1ffbc4230001fc000195cc0025c8d7361af14d912026940701c3d5d440ae6913069efe06c4c2d7ac2a8c61f961f686a13423467cb2334b22379811352d9988876a6e586d975e73293018af4d035eed23d30eb02808af0c133d9879c0fb82c72329ab2ed208ebc1631641ca42bbf462239d151f4e84d8dcde7b000000005d49c93481f99c7e1d85cde715697762973d9c49d6facf50131e11b2c14c78130000205d49c93481f99c7e1d85cde715697762973d9c49d6facf50131e11b2c14c781320a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e1120959bed4177d7abcdbb412bd8b8e1f920bb623a000000000022d93a9efb4e1ffc000ccadd000000079a7d38b11c6a3e040e4e665150768b8a5faec4079a7d38b11c6a3e040e4e665150768b8a5faec464f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730826cbf63d989916d252cfc2cf827f34314c32c64acc0c252f1c3d42019589650c3ecb098655ba153dbc04211a1a73e88000000005d906997d8b370d37f813ed55c664457fc98acabfbf5e5602952f710b54bd4e50000205d906997d8b370d37f813ed55c664457fc98acabfbf5e5602952f710b54bd4e520a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e3d6ca51bdcb6817cb4f722a45a7646fa5070ee902800000000002357ee76fb4e1ffc000ccadd000000431c84baf52eb97d5546ed1ee44872c30772a30a431c84baf52eb97d5546ed1ee44872c30772a30a64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730155b2a1aa71cbb3b5fc81b00242805a6d573826679a2b6a5c49bec714829322efe8af0c1640ba3b59811c70e17b488a5000000005dbd3e1adcef3a9e61ea1c8d0d3bed643ab3a36872ad78905b009cd6dbde6df50000205dbd3e1adcef3a9e61ea1c8d0d3bed643ab3a36872ad78905b009cd6dbde6df5208e8e515f7025352e7c608479e413beacf0d95cbb964b47e4a98fd27b6b6b628a275615f5efe0555e81f7799ff3e1017eed0f5d8160000000000034d41347fb65a7fc0005e6990001fc0006579c00d0a7d804064376431fc57385721270a55fd99154d0a7d804064376431fc57385721270a55fd991545615f5efe0555e81f7799ff3e1017eed0f5d816030119d599048331efb5bd38ea0506ac51765eaddf396114dcf14fbbbab70b7a929c9227f8ec980851ad79f502d2fd1750a000000005dd021fc25cffa8a8fcc138726d3771d7a11ed67826ef92f8cce1deeeb8994cd0000205dd021fc25cffa8a8fcc138726d3771d7a11ed67826ef92f8cce1deeeb8994cd207d3a61ee47e7406247f3c530c94eca04fb61215407084d494fe341e0bd6e6dfb00e64dbdd97978ca06825948e22965eaf261f75e3e0000000000b2077c28fb4e1ffc000732760001fc00073283006d40952f2f57e3d63ad144d4171de75dbad6871c6d40952f2f57e3d63ad144d4171de75dbad6871c3b8fed059edc3b85af8bc75de109566b89aef260300cacf46c91a350240272bcf66d48eafd77c78ab71185ca41769621116c8dae8b29732fb998cb6547f3fb27b556c660ed000000005f8457a7640a8e99840193865a971146d9e25a97d8dfd6f0f1f73b18fd962c440000205f8457a7640a8e99840193865a971146d9e25a97d8dfd6f0f1f73b18fd962c4420e77f5d18d3565f6130ef095290517a91b9591ae927defeafd6875daade6ee39601609b88d96948cb06b59241d773a085b72f416caf3f80000000b951a487fb4e1ffc0007d1f4000000d45e1d0d83cae06f0c68b0dfba62807d59214bc0fbe729266f43adfcdf3ede4f478c7a0ef915cd460d5bcbeeb459af40f97fcb4a98e9d1ed13e904c83097d5f022c3b6c314bde5171ead1616e4c27f0e9a48a9a9dc3a7227a62d42213b93c8a4c32af18bd8ff931b7732782e0901c623e2d926af5eb52dcc2b931993d3e5271451180000006029fadf3355a31c6f841570e76bcdf5636378c65ff1da8f580806602752694b0001206029fadf3355a31c6f841570e76bcdf5636378c65ff1da8f580806602752694b203e14ea3daa62c03d9ed56e8895b5d98188711c49818cd0add43d37fe512c93d1012a5d83dcce0edae361a62d8bc2a308a87e29a49b000000000059a9ab6afb4e1ffc001079fe01fc00107c0e01fc00108203001119c437dbe2c3aeb4a3c7d1e29380738e3372433e443eba6ce82ca15b203d10117c653f26944256cb505749178fb4f731643d9aa56c54e504f9cc6e30a4adf9fa35bc975e52e3f667e48ff3ed7ce71f8ecb85d5ec728596f7fee735c2f857fae1569c8b4c6839ca849cba42d1000197ed64c04be77ef571fd5624c0f7705192630e3a01fb8f3001fb05a36071df1e3bf80ba6cb9795bb2a82ef426cf559b7711e555af45fd8da7fb629b80001206071df1e3bf80ba6cb9795bb2a82ef426cf559b7711e555af45fd8da7fb629b820387368b816ed3599d758185ae60d943afc22201e94e06ffb3dad30a3ddc6756b0005ccc78c0358f7b71d254b28c7287da9b39b81f400000000002d20db70fb4e1ffc000d05b30001fc000d05cb00434dcdb7115427657cf2936248b62a97b9969795ff1266f2c8aa7b1f93a15b8882013af424d7d9e805ccc78c0358f7b71d254b28c7287da9b39b81f430b4e545a909b1916959139eaea845262b0aadec1c5cf555922bb6e6d1804343e6490428a382a0c01832fc70c50438fea6000152cdd176257544a263ecadb986ed72375589a8a401fb682001fb01bb610f8f8dd4cae7aec25116ce7104742254ec559baa67b27ab471ece2a2aa7803000020610f8f8dd4cae7aec25116ce7104742254ec559baa67b27ab471ece2a2aa780320a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e264345f7c30d3267da06c6f685ac42770abc5b0ab8000000000036ba9112fb4e1ffc000ccadd000000bec1b55112fe6dee11593a3ec19e9d7128555218bec1b55112fe6dee11593a3ec19e9d712855521864f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73090ea47f22be1644834d8756793f2308f2c5b40afd16ebb98d29a3bd37e437990d4d5930ccfa56c1ea0b4e51d05a49f2300000000617d72f6941af02ef5f2ceaa2ac0315ed5db0979c45391398f74b0fadc100ca6000020617d72f6941af02ef5f2ceaa2ac0315ed5db0979c45391398f74b0fadc100ca620a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e69eaa58fb3c117406b24cb6bce3b818f582ea7647e000000000023587acafb4e1ffc000ccadd00000017acdf555cdcf9dec1b41f2b44511123917d299817acdf555cdcf9dec1b41f2b44511123917d299864f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730067ec5f7cb5511ba2bf10aa09eac4107d76fd53edeb2fd94edef4555171dbe3ed7dc6cfe37b087390af61a6aa269182b0000000061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb00012061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c15888380d6096d829d6864cf6eec66812266839e0d0000000000340cb05afb4e1ffc000cf99e000000b5b414e1a68e36a25df214ac6eba35782a0437dab5b414e1a68e36a25df214ac6eba35782a0437dac69a0bda7daaae481be8def95e5f347a1d00a4b430a6a63376eb861bda6afa09e28e39ba40cdfb877ee6f9aace10eaccd4caafe8d9243f2f2c0ef982a0766347073cc199bb00017ada3e486409b39c94a0833c8d782f35bc24e96a01fb8f3001fb05a36213059ec1749bcbb42e7b0ee5205b88df03ea2fb1a73d6c4ee10c9d3de9345c0000206213059ec1749bcbb42e7b0ee5205b88df03ea2fb1a73d6c4ee10c9d3de9345c203ad8c08b05fcd0c0dd9cdd85ffceb21c25366f4f32b81f6a0cc009e774987154006d2ceb670b5e0484285fd83d0d13177f608641a5000000000055d1f304fb4e1ffc0010173e0001fc0010175300da8d49b6e91746c548bbd0de25fdb62bbed5b872a43561ee4583153f4b18ea92e8fdcb3a602e84fc482551fcc51ba10000202e7d6a7938cba1cd28ef3013b9b565d5772aeb5080dc5bdc91a319dc33b4a2fca52d3998d6561a043b51bca50eea4dd8e8510239af01fcd6312f050000000063115def57591ee9abad23b796cff8cf63b7c1e9878ab77ce8e354c38803501600002063115def57591ee9abad23b796cff8cf63b7c1e9878ab77ce8e354c38803501620c72e50fdd7acc0be5942e53d2e5a616f7e86c4b4ae675b8099e4f8a1caef049f0018d49a0f47500900fc886294ab346b7c02c7a9d800000000002d4db010fb4e20fc000374ad0001fc00037a330079cd5958432147b2cafde22aad47375e690a9a4d79cd5958432147b2cafde22aad47375e690a9a4d83ee938aaaf0e18dbe7bdf40e639fd2d2dc188d93002ede7bba4f6330aa85b22f2d20167cb529ac1334125ec439f873c0cd7d54e7c07b65bca725799f8292564af4296f0600000000063dc5ee3b0ae326b1d590c1253aceb6b50982721e6d8b20e862433a2a6438c6000002063dc5ee3b0ae326b1d590c1253aceb6b50982721e6d8b20e862433a2a6438c6020a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e6bee55061de10219326c570d2c39cd051ef00d2c5e0000000000235bc5dafb4e1ffc000ccadd000000b190542b5c7522f4db19e48033d17c34afd71845b190542b5c7522f4db19e48033d17c34afd7184564f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73013f411bb160a34b3d8254e7c537e1300afed010d4a245e376b81d889020854fb999fe9cbb7430ddee0faf2fe5e711ebb0000000065d8d0b30932771009cd7f022fa796da3ef4c1268728843ba71b5ca8c6c4374a00002065d8d0b30932771009cd7f022fa796da3ef4c1268728843ba71b5ca8c6c4374a204a37c4c6a85c1ba73b84288726c1f43eda96a72f027fcd0910773209b3d0d86500bce5e6c41e6658bf2a5738b7fcac02c520e391be000000000023a155eafb4e1ffc000b942c0001fc000b9d53008e9431059fc57f8c0c1a9625506b80589feb7fd6faab53c3c104da464745c096b8c79c91f47b835ef9cdba10be63d3e13607d4f420bb6b8013af2f7d308b98c8e6620c7893f7c26acc50d4e335b74f9cc866019ff0b6af497407fd0ebdb33c2cba0a6f2c4ea9a8aee85f22bf5f000000006691b5981eb27314fdd2c2eedf58a0571da48ee074600449eb825c485a17ea7c0000206691b5981eb27314fdd2c2eedf58a0571da48ee074600449eb825c485a17ea7c20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e13229a05ff3504b016eafada8216af6f4a4170e2b4000000000036bf1c2cfb4e1ffc000ccadd000000f719327671f37c8f4dca62dba332ba17ba42e7e2f719327671f37c8f4dca62dba332ba17ba42e7e264f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73000a2e66a810493a91b5ed1a8ef8ac4be41543598f5b4765a6f5d6339078ab88030817dc9c9bdb60c7c7a02d7787d6f2e00000000672830015f3330a96d5aa74d43b6dd2f6896821d8caed7fdad6427c74b7a7e2c000020672830015f3330a96d5aa74d43b6dd2f6896821d8caed7fdad6427c74b7a7e2c208e8e515f7025352e7c608479e413beacf0d95cbb964b47e4a98fd27b6b6b628a4ac20bcbf3e1989bd3da763af41bfd39b45b130e11000000000034d41347fb65f3fc0005e6990001fc0006573c000fb0af93f68351ac5e92ff99c982c664da1697020fb0af93f68351ac5e92ff99c982c664da169702c20bcbf3e1989bd3da763af41bfd39b45b130e1130151436dee05a55afb36dfcc21afcd193ec0852d2f2b27d86f3ce8c05e7e4d4af4e0023d0089b0ef3d41bcdaf4556b1fe0000000067491f0cb0874d179d8ece6f3ff25f721b2eb016ab5768bfabdc5e6ca614aaf900002067491f0cb0874d179d8ece6f3ff25f721b2eb016ab5768bfabdc5e6ca614aaf9200b469b5bc9057f1869e277e9abc139e8a7fa9cbf98f3bf4592a740249834d5a001cf333b39b37c22e1bcbfb2cfb9e98e85c622f08200000000005bbe7d85fb1a0bfb4ab40001fb701200de6d2589b9cd1d134c8aee733d9ecf70a21d3347de6d2589b9cd1d134c8aee733d9ecf70a21d3347a618f8434a31c9d45afc5d99aa253bdf1319f9413091e633b72726091f58e3bd1ede3a21de66abb2456c2f669be8bdcf76f3ab76aa2d75f7d03cf2f7d5761ab15e62e006130000000067636d7c7516e0eba85e2950cfa2c4d14e89b0aeb6d1700cb1c9f1bfdb4bb8ec00002067636d7c7516e0eba85e2950cfa2c4d14e89b0aeb6d1700cb1c9f1bfdb4bb8ec20bf0cdd7af7085c9e845a46ffd4fb3f460b73ab18af5ab9d7c76c1a8f13f63f210029aebc9994e27800397664c85b8d7c3c19ab788000000000003427fc58fb4e1ffc000bb3b40001fc000bc79c00a32c3c54a801798f6c7e4e579dcca4d55b9f6ddfa32c3c54a801798f6c7e4e579dcca4d55b9f6ddf1ec5c66e9789c655ae068d35088b4073345fe0b030071b53468e6124803ed05bb4961177a9e5207744ce04e742c6397e70c3bab2c4161838ce8a7284a043f7d1ab1f18d025000000006802ed5074a42b84a99b5fb6da29d04c2c80e6c9dc437203acd698ade36c6eee0000206802ed5074a42b84a99b5fb6da29d04c2c80e6c9dc437203acd698ade36c6eee20ee6e6ce3ad98d6ac037243dcc9e6802c4cd029dab65f9ba9842ba47450ed026801eaf63db1bbed2ccc65ff8763bf9cabf44b8d6dce000000000022e09864fb4e1ffc00017ebb0001fc0001aa6c00c924a295c5c6c72c2a650224eaf345293a9c18050c5f490d930fd36cd578b0f71c053b488b42c4edf32bb66d6fdcd07b1268d21a3e021c9c95445293308d6bea256f36d8b92071b66fa64f4023737cbd1b5dac7c1c9bf514cae400c332a1091df0ba8cd007d641a92507d9cbbf00000000682b3e58e283081c51f2e8e7a7de5c7312a2e8074affaf389fafcc39c4805404000020682b3e58e283081c51f2e8e7a7de5c7312a2e8074affaf389fafcc39c48054042090e2875a5147dd4d0c167017ddc3050be5a0c8690348ceb20567f5f9b8dc55490144d0e04d397a70492557046f0416c70765363f6c000000000040c13ecefb4e1ffb1bde0001fb37d200f4aa6fd6b27d9649267b4ae48e3be5399c89d63af4aa6fd6b27d9649267b4ae48e3be5399c89d63ace33dbd25c0eca0572668b263e170a70de199dac3005f2269374676476f00068b7cb168d124b7b780a92e8564e18edf45d77497abd9debf186ee98001a0c9a6dfccbab7a0a0000000068512af99ba954cba495e96651a8d730880e21437a873fd9309b54ea9e3b53cc00012068512af99ba954cba495e96651a8d730880e21437a873fd9309b54ea9e3b53cc207459dbe6d9b1930f8d6bf4d0872b2ed6af58baa2f0effe608e6e2ab0c98c148501f30f8dc6c5b956089b30b3dc91867a3b72620b2f0000000000b92f8494fb4e1ffc000faa6501fc000fcdc401fc000fcdec0044b7348492de6612c17d0aff5a3f6fb5f338d57ab2f70938b1cfaba9eab8eee718a48f292e1d5180d86df99cea20e4fadf223310df529ce645f0db2330a28a648ac2b271105426f11a070d3f4854f812c3fd0241860afd511a7ac76e681210505ed41121b141e377a73faaedde0001e33c1f9be807b975c0f5e1c0e3c63175d9e55ea901fb8f3001fb05a368fa216e06d6eded3afecfe2c4b1320a20652972a006f85bc024d8f46dbe8d8800002068fa216e06d6eded3afecfe2c4b1320a20652972a006f85bc024d8f46dbe8d8820f526a08420ddb3e2613d4b76068f9ab4e1fddf144ed69a02e8db33eb66b653d601eda9e9c11e82f102204cff0c4002e701b3f5cd1100000000009f45480cfb4e1ffc000504b10001fc000514d40086e21949f0e591e8803504f5245bef823d701997f07b6cfed0116e02792156cfa9f595b52a3d87c82d08e955f84b217d4dde65a6519ab77800c7954730039715a9bc06634ab10b432e3a9d446d436b4584f65c19aef93c69d07802690df0b51d81da6ff9a8de1542c40edb0b1a00000000697c2c82e72c2adb8909de0659da51fd64cca28f8e3bda7edd8db0d0653d4e2f000020697c2c82e72c2adb8909de0659da51fd64cca28f8e3bda7edd8db0d0653d4e2f20dd94d2653996e56e93e922e2dee824f6bab41274f86b183fc7312eedb229840700840a5c486b762696e25eae2bc9ff85b0d44011f50000000000235c0934fb4e1ffc000bb3b40001fc000bcbaa006aa4bdc44241524d580524e2623576169a0ab5616aa4bdc44241524d580524e2623576169a0ab5611ec5c66e9789c655ae068d35088b4073345fe0b030947b7beffebce3bdee5bba609a5c4491711f9c8c42d25fa02ed7da12f2fd7342762ef913986f1df8cc13c0a4381d1e1d0000000069d69bae567a8184b2b254ca9a5c4b8732daef78788a3b722f931f74df08f9e400002069d69bae567a8184b2b254ca9a5c4b8732daef78788a3b722f931f74df08f9e420b90bf3823ec4c4c6b4e0283d7ddb9ec00f99797471d585a93c0cf29f9bc98fb000cdd609cf68a00b4c13b040736aca0237a41d3006000000000022d78201fb4e1ffc000bb3b40001fc000bcba3001e009a2934acb4c1bf40a84eb29cb251d18e8fb31e009a2934acb4c1bf40a84eb29cb251d18e8fb31ec5c66e9789c655ae068d35088b4073345fe0b03084c5c9186e0d8efb404f4806218c2a5bc711396f445c27b0cdc8d31246ac7cf42d4b38ffe62340570711e446651569cb0000000069f156c10220991da1f4e8d692a582ea686a028d532b037f29684610fdb60d2600002069f156c10220991da1f4e8d692a582ea686a028d532b037f29684610fdb60d26208e8e515f7025352e7c608479e413beacf0d95cbb964b47e4a98fd27b6b6b628a409a9ff9309062608aa8b3124cb264fd29810bfbe4000000000034d41347fb65e6fc0005e6990001fc000657240076a035432f549ce35f39ae28b45f19965340d82a76a035432f549ce35f39ae28b45f19965340d82a9a9ff9309062608aa8b3124cb264fd29810bfbe4308e72ce4ecb7e37c0ba5376c77ec364606b796eccd05d80583a36da42d57421c21d3ccc3b3105ab18f87901e03ce09a000000000069fea9883dea2a9a962965e56322afc4f22484c3289726708fc760110804abc900002069fea9883dea2a9a962965e56322afc4f22484c3289726708fc760110804abc920ae65c812772f699dfef8c267595bcd8989043245ffd5a478953f4ff6bafb6af401a7749b674b1a7a60ef4e659d00e285c83dffdeef000000000022e180e4fb4e1ffc000607e90001fc00062e5b002c191f6fe901a5475f2a87fc3aaa12502057e97cf573287084ca8cd1ca8ab21ff5436945022466c2c9d30aa841c8e37e16f8095f20aaeac9869d26d93018d5da073c85f04213bf2cbc10eaab55f3a2779c0f347e2fb9c869024f30afa57c7054ed6b69f2a03ce928bc9683ecad000000006bb76b085315ed584034979fc0df5d8c09abf056299dfbab264a82f57b7245ae0000206bb76b085315ed584034979fc0df5d8c09abf056299dfbab264a82f57b7245ae20a0fcf7abd47df5bc7389ce1562d3b36d08d13ccfce876241191ffc269a4ba76b00885df61c52dd658243170bcb804fd4437895c8c0000000000023a48665fb4e1ffc000bb3b40001fc000bc79c005fd714f8f797e38f44abc6bf6ee6a17a932b68e65fd714f8f797e38f44abc6bf6ee6a17a932b68e61ec5c66e9789c655ae068d35088b4073345fe0b0308552bfb82f92fc63648ab91ea38925f889da4e349a2fe50e07b06beb1d15668e0e6fcee57dd80ad932459dbe6c8ecbbb000000006c397ecdbcf1a9b5901d871dd908ecac4a132391989bbfe0f75251eddd6fa21a0000206c397ecdbcf1a9b5901d871dd908ecac4a132391989bbfe0f75251eddd6fa21a20741e45b4f21dcb9bc4c1395a714685c225b50ffffe403bc369da656127e31167001a63f648d47bd04707df3fdc4ebe860990625393000000000022de80e0fb4e1ffc000bb3b40001fc000bcba300fbcff1cbe6c28765f774e51a53601d2687c831c4fbcff1cbe6c28765f774e51a53601d2687c831c41ec5c66e9789c655ae068d35088b4073345fe0b0300befed2efcc28f3b82a25c59d2ae163d3940801f2ac4f36afbd372d6c1f6c02a8a5214a29aac39d2059ffe6ac8217925000000006cca50b04c9816b07a8a831ebec34866f1f0fe836047890dce4f1c46f9e8a3c00000206cca50b04c9816b07a8a831ebec34866f1f0fe836047890dce4f1c46f9e8a3c020a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e102031ace81ec2e17de17e57c69f3c3eead8334423000000000036bc4559fb4e1ffc000ccadd00000094d596c0f06812174b31eb104a44cb1c9456307394d596c0f06812174b31eb104a44cb1c9456307364f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300ad4f577d067630f6fd15f4d2aefdb9456d648b71cb7253d47511acc81dd5ddb69a03c848322aa11e5242f66afde5a2a000000006ced683bb70cfb82159b08d68a9b6bf2069b328e3bd028a441574fdbb0f9d9a70000206ced683bb70cfb82159b08d68a9b6bf2069b328e3bd028a441574fdbb0f9d9a720a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e5dcef7f4fc2d4474828e84e85ddaafe52f606d7a3f000000000022d7abedfb4e1ffc000ccadd000000ad8cd8652d70a94aed1d6802bcfe9858f7c8a079ad8cd8652d70a94aed1d6802bcfe9858f7c8a07964f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730118081d1c248d74a0737f36e5bd40aa71b512c6be6f68e3664723849ac47a62fc743c4dc7234694bda1b7701f33d2e81000000006d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209660001206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e5286332096620593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c18a93e60c572add22525a10a5554e6f6a4feca49fe00000000002ce4f2b5fb4e1ffc000cf99e000000f3a83d259634fbfc3e3c4ed50cdcab6598fce20bf3a83d259634fbfc3e3c4ed50cdcab6598fce20bc69a0bda7daaae481be8def95e5f347a1d00a4b430b8a2161c64bfdc7d621df51de569911a219f718bad4d6058dcca9bddf6696d43ddc4c1e3cf91640c93f820e5680efac30001c374f016ea61e76aab79b8bb95a1ba0e6e3eee6f01fb8f3001fb05a36d6eb7a108fef471947d245e9189e47284d9a720f95aab0127adb9bc6459557a0000206d6eb7a108fef471947d245e9189e47284d9a720f95aab0127adb9bc6459557a20a159f4eb744960b4d191a95585db3f17384e36e5f1cf8c7ceae4f13a1dc46505016c8a0d99a474b91b9119b0b6bfc4da988491ec0300000000005fd91a87fb49c8fc0004e25101fc0005345d01fc000536ab00fb38720e8317dce4ccfc1174da29f071077dd371387b6ba2b25346e89278b4fae874858a8c09960f6ebb7dea2d0ff4054af20815296dbcb9e0cfe2ba30955368e9fb5cce100a0ce6df64bcf624355222e19032cff0c80cbc75140173c2eb47863b189d2423b64af6544226bb50000000006da069138e905fcf845d2e92979086e2bf89ba25d50e1c59799cbf4d2f2a9d010000206da069138e905fcf845d2e92979086e2bf89ba25d50e1c59799cbf4d2f2a9d012055f820fe0081c55c139ebd9eb6d053aadb85d441a7e8eae8dfde4f4bddb3f1ac00777742af1e086c95ad279e2173e6e04937d9206f000000000036bf0f03fb4e1ffc000656800001fc000bd4aa006c0659d3417e8b51836885241a09ac204e87c55c6c0659d3417e8b51836885241a09ac204e87c55c1ec5c66e9789c655ae068d35088b4073345fe0b0308ea05dfec6d5186476b3096e34f6777c221cf0bbce352daf402bb182e2d94297521ffe8c3d09e3e430376fc5c147fe64000000006e736990d9bd8b9b1c0164b8634a07c0da1a2bce1543e7620513b5c95fe288490000206e736990d9bd8b9b1c0164b8634a07c0da1a2bce1543e7620513b5c95fe2884920db520fffbbe239dbebf8301c7ce3bc55a891e467cb3dafe3479fc4e97072d84700ca6b25bd815213810f685818fa28dfb0760b07c8000000000036b856cdfb4e1ffc000bb3b40001fc000bcb8b00a0efde49999335db44bcaeac0af934a4759ad34aa0efde49999335db44bcaeac0af934a4759ad34a1ec5c66e9789c655ae068d35088b4073345fe0b0308c74753516550b53c30a89f5d0c5e08cdc0145d1be5e45d8db75597745346ff4aacc04c1de1f31aa42e43e3fba15ec6b000000006e84dcf6f2ddcf4444bec6dc070d9cbc52c3ef6681a14238b2e1390a77a6435e0000206e84dcf6f2ddcf4444bec6dc070d9cbc52c3ef6681a14238b2e1390a77a6435e202208e9b3635f0fcc623f88c9f45256d6557744d5aa12f126adc3d07ed43a2e8d0192ad947d47ae5f960ea418954db0f96dda7572d60000000000175b61d3fb4e1ffc00025be10001fc00025c4400aff050dc4d29cd0413c1890c6d8db9e8372b4cd38d83de554dcaf4e9c01608497bf4b6bc63210142a4687a0e78a9b3a071ad6ce8e33b008ab5cb7dca300064583f3f5dbb756708aa405572d2eaf3349ec2d9048c93f21a2d1e5a0da7ae1675d27d626035ce0754de1898d5cc30000000006ebfbf45a7e6f5e4d25ba315f1e1a44178f6961271b23925a2871d0c5b9e132e0000206ebfbf45a7e6f5e4d25ba315f1e1a44178f6961271b23925a2871d0c5b9e132e20a06518e3c9374e778a185bf5a4d056b1816719feb626112da42d4a065fdf5e90000b22ca74c045f776efd482aca95f692d3551dd6500000000002d3dbaf5fb4e1ffc000c6da10001fc000c6deb0035d5591040d1158f08d837b59f0b57b6912560cd75246a92185e0f116ef70707a58be008da5ce1680b22ca74c045f776efd482aca95f692d3551dd65300f57b0dd5947df31adba9480eda73a2282aeee0bace77680da718af1b91a05f878e433e8455ad56a38918b5aa262be09000000006fbe7935a362d6c08e5d10af09398ac4ebd2edcd1f5d657816c4f0982da6999b0000206fbe7935a362d6c08e5d10af09398ac4ebd2edcd1f5d657816c4f0982da6999b2051352f9cdd2b3bed963c98435f57a9c2c868773e4aa0ac4e3b8d07afd2da0b3a004b1eda1e91bd4d5907b65f8755c4e3e0e12453d70000000000a5e3146ffb4e1ffbc4110001fc00019d0400fa2440f3ed05121bcc2463ed00d1664946b68b120f4dbff3f157e6fbdf65169a1c1a26fedf178dfdb2334b22379811352d9988876a6e586d975e7329300dc936ac5a2e0e0e81a682afbf1d5a4b6c761d265c944b7065cde7c0009b103b6e163441eab78460b0aa6951477123a0000000006fc2e949a1bb5bff22ac494c3434d2db20a61bc91c9f8a3e57048292abd33f780000206fc2e949a1bb5bff22ac494c3434d2db20a61bc91c9f8a3e57048292abd33f7820c73a0b3cce7ca6c5b5370ac2311140cdc30315ddb718f8c46bc2149894da68d80194970c5f6511cf4757972c8c723ca5e097d0999f0000000000c2100205fb07cefc00040bcd01fc000468e101fc00046af300e565047bbe00199e47400db3a356034373647fe7c8a4cfec45b3e5793f8413968d3bd6aa7c6bfffd9a5ff3a72145e4bae41ff7842782f8e851d4275b30032bfab78f78c968f4a1e7fb87d9b3bd75dd2a49e18b7592e4274322660c27f213b898442eb41f5db42291a2172508b600000000712c0edad9b39de087a2422aae59cbee77b63aef06de6db44b2b8287303620ef000020712c0edad9b39de087a2422aae59cbee77b63aef06de6db44b2b8287303620ef2078d4881f8591d4de1be992256cb869064f8a1778c71815e1854c8258f505a3fe01087514e6edcdb460ec2ec30cd6479db40659f0900000000000c9100205fb07cefc00046a5f0001fc0004709400b0c562adbfdb889b2e9cc84e0858209799bbe16857ac5622d91ea4b76a62b0e4d0a47bfc4a1fc03c9d2a53910bb9aaf740ddcea71e896e5fc5aa5239300ec57774146e447ac6cf131a40fb37664ed5f9ff45b59d22cc68f2aa9f4659cef42235b63c3f2c3ed36f8b2344399d2f000000007135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70190001207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701920593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1063c03764190123b001e65fd3aa12c030df5bde82000000000036bda427fb4e1ffc000cf99e000000b920a2229f777e360b7da76885a556bb439533bfb920a2229f777e360b7da76885a556bb439533bfc69a0bda7daaae481be8def95e5f347a1d00a4b4309472710b11e34dd5f6fa0d43cdde23ddb33558be1539cc7275cf06ba2d82c6ba0c712e7022752843f411e6702eaa736d0001f9956e70daffa263e8cf29fa6557b7b630a595a801fb8f3001fb05a3714874684cfabe0cca907ff0e61bde28c2fc1a8840c485fa14ba5660bfad5e2c000020714874684cfabe0cca907ff0e61bde28c2fc1a8840c485fa14ba5660bfad5e2c201bbc52c48482f1e6f57e1eab3d8dc53904d5a16f9bbdabee5724578a8bf897560194cbdd7f7e53872cc579e60314867dcdeccea50f0000000000b6327d55fb4e1ffc000218db0001fc0002192400efeb6789243fa23cbf6b5137aa5d4dea847830e33f309e73b02fc83f88a0bf28f87d715a48678ea6e3c8d9b74f3cacd7ab94430574b9816e5047b9033011b8a3cdbf872f868b08b211878ef11a0f6f7a7ebd55533864aa98e53e194faa159ae2d13a7625384a3fd1572f68deb4000000007161d8618826c76aad36d8b59bc4c1fabb1d8299115f8314e74d7854fc3ef6660000207161d8618826c76aad36d8b59bc4c1fabb1d8299115f8314e74d7854fc3ef666202ae863fa61ba16e37e3dad6fc5c07939b8caf322da44272eeea7f645c447234b0049ec22c09c3152674ae7af85ee7e747d08ec387900000000010000000000000000000000000000000000fc0004bea80001fc0004c8e5019676669d0daf4a6ac06239eae91b43b4469cecb49676669d0daf4a6ac06239eae91b43b4469cecb449ec22c09c3152674ae7af85ee7e747d08ec38793000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000717a502e11bfa52d11a10635536205d60934f6f2d0ac64d7fc0f1808a5aaff01000020717a502e11bfa52d11a10635536205d60934f6f2d0ac64d7fc0f1808a5aaff012014d197a4d96ac8c0895b28bfa5ba04c094fdb7a9e073407a499b07b391d3cb980147a99e2ca7487d874d547e887d3f457175ae5897000000000040b032a7fb4e1ffc000d08f40001fc000d091300b7fc053090e0f10f64d962b36ef797ae608f4851b6e879f9bd59a349caa9d490f0bd51988bb1fc341f9162e004553e9fa0d415cfc38431bddd799a6230a90fce30ea814b244dc767b5d29bf227842226705a0bd2e8589e776a4dd113ed3dada52c6a07f55be90173d6431d8f340000000071d1eee72379edada11d464bcee475b37371e4d907db5848c3f50e0bed00a45600002071d1eee72379edada11d464bcee475b37371e4d907db5848c3f50e0bed00a45620e86078d3a9106a2cf3762064b7326edfcf99ac4e1dd76d6e80c9b94bd766737b01c34bf769f46fcc5ba593c2f3a4009c02e6e0cac000000000010000000000000000000000000000000000fc0002d5880001fc0002d5f10159b1ebf04d63af3ef87391a0a4a7b47f5f5e791159b1ebf04d63af3ef87391a0a4a7b47f5f5e7911c34bf769f46fcc5ba593c2f3a4009c02e6e0cac0300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000071e6b3fc43cbb7a04eac2799d8f98f76f3b0ac867a8b8c82caf876cd0737ac9800002071e6b3fc43cbb7a04eac2799d8f98f76f3b0ac867a8b8c82caf876cd0737ac98208e8e515f7025352e7c608479e413beacf0d95cbb964b47e4a98fd27b6b6b628a51ce81fb48d349c7ac0e09a8a5d152475b586f4275000000000034d41347fb65f1fc0005e6990001fc0006579c000883903918c1154fb2b589d80caed855a157b1240883903918c1154fb2b589d80caed855a157b124ce81fb48d349c7ac0e09a8a5d152475b586f427530975c482384c7bd4cfd5930fabac11646121d420e31883673dfb6e6e3bfa273da73a2a91b4b69cc108eff9619fdbb4cf4000000007228951470758be7eecda8126c7a23fe8ad019e67f3fdd5507003bf0d2d4159d0000207228951470758be7eecda8126c7a23fe8ad019e67f3fdd5507003bf0d2d4159d209d15d4d2f03b000755dd3f7fe619d08afe237a6c12a8cdeee78b75701495287201e0e440d4c365236c93f5fbe402336cba2c5a506242c80000003feee5bafb270efbeb250001fbec0200ad045f8cfda05187e5dd3f59cdc7f7692816320a5fb5dd519d994f5e5706b4047d65ba1b873d9ffc818d7b316758b285e41c565599c9168da68592913088d719278eef605d9c19037366910b59bc28d437de4a8db4d76fda6d6985dbdf10404fb9bb5cd0e8c22f4a914a6c55660000000072ee70fa75262781a17d1eb69a6c3e97328208be98b59d5530164f31e481d3aa00002072ee70fa75262781a17d1eb69a6c3e97328208be98b59d5530164f31e481d3aa20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e60d38405d40979e4834a09345b8c7398e0ef14293b0000000000235bd038fb4e1ffc000ccadd000000889e8cd2ab0cc70e36e566648e265c7536a8fcaf889e8cd2ab0cc70e36e566648e265c7536a8fcaf64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73091f9052f62561db112ddca7df3d914d546866b130124eccb2ae1e8419563e51f239b2efec3d1b3fd388072610939d6940000000073091b5bc227073da93ca7c25ffee4f9c9e8b3f77b935c99e30e71268704f5ff00002073091b5bc227073da93ca7c25ffee4f9c9e8b3f77b935c99e30e71268704f5ff204cf1e357dc63a5335aa184c8ff929e4db36e83072425065c0655e09f072fea560000899ddc10954edc1ea1398edfd31b0621e5982d00000000008d47264efb4e1ffc000b3c090001fc000b3c630094ced88d9bd5cd2ec75faf451a5e3bb46f5eca6f90614a6e4cf57a7381bd81839ebce238cca8f9f1349317eb79cf1748fda1de3ea69a777d4272c2ee300fa3db9b808db89b49f91f6136cfb966288a56d731c9afd44dc8c4819ae5c286d08dc0572249f41dc919f888d562340100000000731ddb4dace693a27ac91c696685bf3e01440e2f5d57b53e2ed57059f6a33e0d000020731ddb4dace693a27ac91c696685bf3e01440e2f5d57b53e2ed57059f6a33e0d200064d134104e9a09e6e469e442e305ee542d1b5136a7dece41a2b812e3d89a2a00a4ee8867262e7b96728c873c15ae6d983a9e2478000000000036bfed34fb4e1ffc0006567a0001fc000bd98300cf3908c18dbc7d817330d948866a29f69ca15a75cf3908c18dbc7d817330d948866a29f69ca15a751ec5c66e9789c655ae068d35088b4073345fe0b0301213e8a0f73b54c388c26dcf85c158dad87ce9889f45a38bc330d1da4d73a6c02a8d9f6cdf60cdeeadf084c2749fa47d00000000737cba5a656579e1d2becfee2d92f6c7ae3b84a8ecef02c6f53764a6499a8c79000020737cba5a656579e1d2becfee2d92f6c7ae3b84a8ecef02c6f53764a6499a8c7920931fa180adaccb45deeea0a6a7dd618beea65f600ac6fe734e871f97e4476691004b1a70c1e0e8bfe39a5879c943a850f21875508f000000000012ecc7e8fb4e1ffc0006567a0001fc000bd983000eb5e37e0ff88007604e4ebdb28c3beb8120d5fb0eb5e37e0ff88007604e4ebdb28c3beb8120d5fb1ec5c66e9789c655ae068d35088b4073345fe0b03017de44da9886d130629436db995acc9d5f0ef849ff32c4f57b65674f19420dfe8e583dd2c5f37f88edee1ca119f0e8be00000000753f4ae544d5a43787502bda92bf3f635143a0953b31a62c2f61cf8c7df4345c000020753f4ae544d5a43787502bda92bf3f635143a0953b31a62c2f61cf8c7df4345c20141a04d46e28743a8ab8367ab44f05114161e45f3799c2b9f822d8f9895365ac001309f03f9235a96efbe29a9ca62e8fc600208c3c000000000022de04c5fb4e1ffc000bb3b40001fc000bcbaa008186bacf6b22c42e8a63e48c2b2e1ac614bf92db8186bacf6b22c42e8a63e48c2b2e1ac614bf92db1ec5c66e9789c655ae068d35088b4073345fe0b030147039e55cada215fe076a972b046224b43198c9f8d4ddd55db4dc38e4168ec1bcae3cad84f0bb2d9f3db9688561c84000000000754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e000120754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c19ad66f3780f47e83479e1846ecca44d71ba5a902f00000000002ce92c5ffb4e1ffc000cf99e000000e65f1647a5477a20d178b12c509738d7a35ff312e65f1647a5477a20d178b12c509738d7a35ff312c69a0bda7daaae481be8def95e5f347a1d00a4b43099b9f0fbeea3822cdc5b3654dea52103b3d9d5f01db4201955ea3689074d37da4711d8f313d4b5458eef3395aa75bfc7000146d938862af6d9a291e26c0048177db2892a710b01fb8f3001fb05a37551fe264f2ccc4e714195d2ffb79eea7ebd47517a7164c69653569b10f51fc30000207551fe264f2ccc4e714195d2ffb79eea7ebd47517a7164c69653569b10f51fc320c14b73c62e6c0b2df561e37a65ab15e2813a4fbbaa182eae0bb87e3506d4bd9b01b96ce21a90ba65c455609913a18eb7ff20ad55c70000000000a1bd4319fb4e1ffc000376690001fc00038a9c00abf73c421d3d73583ebcd9fdf55fe8b3013a8223abf73c421d3d73583ebcd9fdf55fe8b3013a8223fa34940e957a62dc7177dcf44e74e39828a2a371300becd48c0d44ca6fbff3825f55c35a6f70024f2b8f4f939260d40b5b51c11cdfff85f7d0444a1a9cb8fc45bacd237b310000000075adf981e3a77630507882a9a41d551ee1e5b8ed570e61a855008ca293e615ad00002075adf981e3a77630507882a9a41d551ee1e5b8ed570e61a855008ca293e615ad207a80d77b707fba35384adf0c231ce60d32273de39c9afa9ffc3edf9a2605fa7101828af5d4e701d9c3869a22f2417110f518f364fb0000000000a7636e3bfb4e1ffb9f600001fbeeea0082242bff3c046e018b795b7bc3bb8667628dc02b82242bff3c046e018b795b7bc3bb8667628dc02b69abc168964f63618f587649cb25ddecfb20fcca300fd87b62bf91162008451c1f00a1d7bd65ef581e88c153d105970ab30e451378966b6e4141e68024b3976461605e84020000000075aec7fff319c066890515c7d626166cdd3a28c9bbcd5d949027e5aec46dcbad00002075aec7fff319c066890515c7d626166cdd3a28c9bbcd5d949027e5aec46dcbad20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e3f7100e7a52bc4a9c2bf5ba1bed4da45153e0f52de0000000000235ad9d0fb4e1ffc000ccadd00000036e3ce4c7f353ef721fc1754406cf534bab728b036e3ce4c7f353ef721fc1754406cf534bab728b064f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730124aaa5688cb7220be4600211257ae054554583ad9233e8ca0d58abafe317129dcca9e34a1b9bbfa175b88d9fb31b55e0000000075e5c254c195ef04d5bd91294b78211263726c3bc0bf5d4f92690144f65660b600002075e5c254c195ef04d5bd91294b78211263726c3bc0bf5d4f92690144f65660b620052fc2a04f75b150e4ab7c5981bd24532a49805ee42167b6058b832e3b0c2b5300a9b4fc06befaf833456c54d913154f8f115b412b000000000023573001fb4e1ffc000bb3b40001fc000bc7cb00cf3023e2146c3765ae4218f86e605ac503019d63cf3023e2146c3765ae4218f86e605ac503019d631ec5c66e9789c655ae068d35088b4073345fe0b0300100ed63b1fc72b11ffaac5471ec57d9c9a79214f936932e6a59ebef5938be6190ec7de6b98cf6ae92964d2c7a03cb0d0000000075f082ddd488b36e46fcfe4c5284898d3139ea58f9effa9b70fa12b25619890b00002075f082ddd488b36e46fcfe4c5284898d3139ea58f9effa9b70fa12b25619890b20070280de80a8c5f34f7eb94dc35d847530f7ef5a9a6d43d840b2256829e297aa00c4fca50e9f87d5a53b57d8a678b4fc048c7e475000000000010000000000000000000000000000000000fc000ff1b40001fc000ff220013baaeba63dfa6ee2fd67021647213b024f30d9593baaeba63dfa6ee2fd67021647213b024f30d959c4fca50e9f87d5a53b57d8a678b4fc048c7e4750300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000076476a2678d5c1e9ea4951cdd00babd50f6c53f91427ba8dc8fe49f5dc1f5c9700002076476a2678d5c1e9ea4951cdd00babd50f6c53f91427ba8dc8fe49f5dc1f5c9720ebd8732e4738756b96dee3c0e3e60a0027e3b31c3fb0804ef78d46182a84e81c01e03b915271e6dfe5b91126e4bc7b8a981c7459fd000000000034dc3d58fb4e1ffb34f501fb355701fb81fa006dddbc8e0c2bf0803d236fcba6cc32a8123ef43e6dddbc8e0c2bf0803d236fcba6cc32a8123ef43e49d0dcb6162703c2544068536b0b1813c459dff83010142d44041c90621d111283fe46fd8b2450d4b9bebad194290fce09ba080679c748b1ba70e3959623f127af0d2bc9c400000000766c3edf3c134fc0b5ede4fb57b15564819caad310b1929cb5b57251114d64e5000020766c3edf3c134fc0b5ede4fb57b15564819caad310b1929cb5b57251114d64e520b07dc210a205645699a1c7d92d55b55dddedc6fb6c9a7265d1588320a024736501f09070f51717b8bc2800781c21d9b10733d912ec00000000010000000000000000000000000000000000fc0001904201fc0001904301fc00021efd0096b5ec297ab7b977f1f3318291a77ffad070259d8fce46d5cc1aec576dbf5ba0ada049a2c2c64fb3655d3f8b0d7ac259ce9244933bb35544a1341a7d30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42900001207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be429020593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1feea83c4756a349e76b9077636dd04b3306bac60d00000000002ce3894dfb4e1ffc000cf99e000000c0e3581e5165c63790a2b8d2670fb4a1917cd4b8c0e3581e5165c63790a2b8d2670fb4a1917cd4b8c69a0bda7daaae481be8def95e5f347a1d00a4b430b675a1940be872b6a0d4e1696bb39ea38179933a1bae02ae1eaf4b47f625bd939482f8791eb38925af47f73be027a64c00010498ade3c80045c2a7520e921180ae1c39da5c5701fb8f3001fb05a3777dffee76d4ac2b3c9222e6d3ce285527a16281b1d22d511fdfedde4e46ee70000020777dffee76d4ac2b3c9222e6d3ce285527a16281b1d22d511fdfedde4e46ee702079a698f19126f940710af2e89919bf10587c5e9de50451d2f53e76f05ece62a60032b089976a177c7b080b8bdc40d5f387113ed2c8000000000022d73700fb4e1ffc0006567a0001fc000bdc0b000f39e252e534cfd876389ce5770a92ab1d3454ab0f39e252e534cfd876389ce5770a92ab1d3454ab1ec5c66e9789c655ae068d35088b4073345fe0b03089fb9bc6b79eb7b71f8b0dd60c2eb5e0298124b9b10ee29c85415f245c67f4a3d7a8b57573e36110c85fbfedea7129110000000077fcca4a0e43f6e0b96687a87b4272eb8523315c8f2a176d0a2df549a869f3af00002077fcca4a0e43f6e0b96687a87b4272eb8523315c8f2a176d0a2df549a869f3af20460c7a309c739da005bea72bfbf0e74767da84a28f8524f8f5b328518ef147cd0177947714219c0af2be7af73357d3b65ffb6513c800000000008b9fce4cfb4e1ffb5df50001fb97a200f2d2bd8ce0dcf0434c3cf661c2045c6fdd22ba57f2d2bd8ce0dcf0434c3cf661c2045c6fdd22ba5795e13b9a85676df4a1c90dfe0be9725ed714828d30914aa95d1c7d7c39e0a3b213b6497f5c8624d4f476b8043b22c4f30cd05bc037c80d02b42625d743c6a18d0562aeb579000000007838259f0ed6819c5325b663499299319c7e882353c922a11c8ad517a0df99a70000207838259f0ed6819c5325b663499299319c7e882353c922a11c8ad517a0df99a720f3f696aaa2fcab176b1032150d96afaf982b58e24faa35b0c842ede6c9953d6300acb39ddb2ca2a929b3fcf215b699fd2459072ca4000000000022dbd200fb4e1ffc000bb3b40001fc000bce430070a68f83c21da5efaf550eaf261357e8fbbbe4b370a68f83c21da5efaf550eaf261357e8fbbbe4b31ec5c66e9789c655ae068d35088b4073345fe0b030854c69a40b8e3d4209fa88590a9119fb6274d3270618bbb0bee5bd22c801185369babdaf658d5bc6946f55d3e5e14f60000000007893b72d36e71a7b83a1fff61e4fbbe1400b11f12bfb349923397a2df3a9ff4f0000207893b72d36e71a7b83a1fff61e4fbbe1400b11f12bfb349923397a2df3a9ff4f2008ea185caab7f5f289c78dee4563bad2e103b12f662fd23eae770e5a04c48c44016922eb5a8a9b1d41b93076ad1e0a908fc6c5bc01000000000036ecd608fb4e1ffc0003842f0001fc000607bc0069d9f48f92fcc82ac6b04a2b303fb420c500f78643497f4ae216cc6f837b4d82ca8e6cd348b636b1f32bb66d6fdcd07b1268d21a3e021c9c954452933092427cdb8c9694e0c6ba086ed7c00dd9f52ca18e335f65de8a839a378b1e040b279c05e3822e7c2fbd57fa8852d04cf40000000079d1d6276e486ab033dd0984a1da33470b6ef293e19492f459cfba43e703f5f300002079d1d6276e486ab033dd0984a1da33470b6ef293e19492f459cfba43e703f5f320a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e55b4c00cc8352c3dc490b5fd1554666a1c90240a840000000000235d97bcfb4e1ffc000ccadd000000e7378cfcf68e9645d0d0ecbabbeaeb48af9a5ddbe7378cfcf68e9645d0d0ecbabbeaeb48af9a5ddb64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73092cafe1870e043973b2f1fded8de3d5a66dac5ade46aa0995157077efee92d852857bc7f03ed69c92723a58f8bd2926e000000007a1ae04de7582262d9dea3f4d72bc24a474c6f71988066b74a41f17be55526520001207a1ae04de7582262d9dea3f4d72bc24a474c6f71988066b74a41f17be555265220593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1cc1d71953a4a45bd11d458683bbf2ef794d6d6e3d000000000023a612a6fb4e1ffc000cf99e0001fc0010f2fb0063c8d3ed082eb5d476a0940ef9c3fadafc4c5d2c63c8d3ed082eb5d476a0940ef9c3fadafc4c5d2cc69a0bda7daaae481be8def95e5f347a1d00a4b43093943908436a934c08582583b08cbcc50b4478bb79b7718789c25eb0ad2f3e5713ad4c152d4b1fd13cfd12bf896072e600017478cfd163788e3bbe09645776cf59642f28e37901fb8f3001fb05a37abe11022a30fb9e614725880e035fb48a8438d3885a3762cc53b2c3cffa38240000207abe11022a30fb9e614725880e035fb48a8438d3885a3762cc53b2c3cffa3824200c66ca577eb357cbbf6b8e64aabf19a07ac6876fb673547b44f6fe65a0e1adc10143af4ad2582f518ac45af4604ebb893c30a198ee0000000000128891a5fb4e1efc00012b310001fc00012d8b0028895ba824b3989b308b4062cb93c22a842e885ad6f5f660f9cf13ff1ff56a13042be5cdb214c1c114da731fe63359a29148e3f59d4235d5bd261c53308edd5cbdd7b381c92ac7de638440bb1ad417af0e82fece69432f36930a6defd3faa0d53d79bc3347ef684eb1e470abbc000000007ace7f64afc3f78ba5dcabc7f384a1a01ebd4d147f8ef629a968df09885db2770000207ace7f64afc3f78ba5dcabc7f384a1a01ebd4d147f8ef629a968df09885db27720a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e0a122072fe97d1a974045569ff2ed7743096099716000000000036d4597ffb4e1ffc000ccadd000000139d5a4134c30bebba6a178a1c8cf91d8bc47b33139d5a4134c30bebba6a178a1c8cf91d8bc47b3364f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730826fc7f30c49215b98d5cb47a350f888a306c52fa42c77e765b55288e622f03859273cae7e1cac99e67f7a9a96a6aa2c000000007ad29bc543761bfa9ee6a8be1f32bf5bbbc4f979d036676835b4717f8abb92110000207ad29bc543761bfa9ee6a8be1f32bf5bbbc4f979d036676835b4717f8abb92112039a506efedb5d184475201e06dec512e3216b1e42b1d7c0d6f8b0440e6e6f69601c51cb65f93928d010a18197b6c8631c41edf55cd00000000010000000000000000000000000000000000fc0002d5820001fc0002d5f301224cc410b74ac6206018520cac60988122bb337a224cc410b74ac6206018520cac60988122bb337ac51cb65f93928d010a18197b6c8631c41edf55cd30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007bf37a9b228fa18b95fe74186ebfd2f16a15b970fb0ce68c43fe7dd3ca1924470000207bf37a9b228fa18b95fe74186ebfd2f16a15b970fb0ce68c43fe7dd3ca19244720472419cad37dfe438ce60cfb70b9156af1d2bf6e1874fe958ba18f229b7af37b0133c019d4b8dcd9ba7a78607bf0a8f3c86bba886e000000000009080706fb4e1ffc000763f60001fc0007641b00e6dd610e8d417424f55f90b5c468011307051ecae6dd610e8d417424f55f90b5c468011307051eca02216766b853b1e605f1e7ffb5f50c61278ef9ca30897af9fdc7920426089efaabbae8aacd61ea4306c0a2c89b140c9d3a69a56084dabcea352d2e1ff8e1f3ae127313e989000000007c124a4c83e1947d0474b005dd388928970147153d2d6ac4a5d3ac7a56a88dd90000207c124a4c83e1947d0474b005dd388928970147153d2d6ac4a5d3ac7a56a88dd9208ed933b32509d96770e36575cb341bfadd20d512271caae9816fc65e0c4d50da0081c33ea64d832d50287c2769407fbab4e9487941000000000036f46ccafb4e1ffc000bb3b40001fc000bce2b008e4a45ffd92c0a560ae047a37ae10ae6082acac98e4a45ffd92c0a560ae047a37ae10ae6082acac91ec5c66e9789c655ae068d35088b4073345fe0b0300cf64b243bc58bb385cb911efa5aa0675e9a05d582e9a9aa9bec875931bd11e82c652a7523e37c945be068f3a5af5002000000007cbb7c6b65f9360c3ef908ccf93ef438a449938acf05c743b7b92647ab3ad2640000207cbb7c6b65f9360c3ef908ccf93ef438a449938acf05c743b7b92647ab3ad26420534d653b186b8ab60b401e8572d1f8da42eb274441c955f65c59f0fe3d275158018da8375dd317a277a3f946077e1c970a1d8ccdc8000000000068f85c62fb4e1ffbca950001fbe5d200f46b2001f6dd71cf0fa69aea9f5a71ff61423024f46b2001f6dd71cf0fa69aea9f5a71ff61423024709834244eb07040d585e826f04d8d26b016555130136de56a265eb21c006bd312a0353c7c3eed46f4f63c301c348fb5d5de8f965c9b60ac6a4ae805d0d241e4942821ed9a000000007cc4df7db9cf413c897452820cd2625afffc89711f0a26eefa7cb08f8806a1720000207cc4df7db9cf413c897452820cd2625afffc89711f0a26eefa7cb08f8806a17220f6b63b050d5a90a14e3d59047050495646ec5e1242ba53b62ce81cdafbeef24900e2a84d616dc589856872cf05535d435c81f4cd190000000000235b1690fb4e1ffc000bb3b40001fc000bce2b00cec1c86cf65d548313f4401d83ac2ecd67b89a35cec1c86cf65d548313f4401d83ac2ecd67b89a351ec5c66e9789c655ae068d35088b4073345fe0b03009c21792725c0c58038362caec9e4c73f02fbdbf2244404d91b39b3788360139178a60e16e9094af50c71df853c5d2c1000000007e065c97170d9ca4aff3f9815a989c45a81bd7cb2d691fb32b3282ef6e9ccf8a0000207e065c97170d9ca4aff3f9815a989c45a81bd7cb2d691fb32b3282ef6e9ccf8a200c7bc19d6b2acdb1f6f33f065a8c4e1522af8f036e65cae356be2ddaed7f1b9e004062160cb5c4f52f266ba4c0318d365450c9137100000000003695f949fb4e1ffc000bb3b40001fc000bcbaa00817a4306a27d64e71528a625310b5f347d55d180817a4306a27d64e71528a625310b5f347d55d1801ec5c66e9789c655ae068d35088b4073345fe0b03099b0d7b98000098120aab913482266dde9ce62412767f2771bb4b51036a59f3f93d65ab54b583641dd565e47132abac0000000007e1d6bdfbe135910f32160c96a38469c52e0c8c3af6c489dfbbca6b187e978490000207e1d6bdfbe135910f32160c96a38469c52e0c8c3af6c489dfbbca6b187e97849207c4283aaa1bcca10b1358405b9a9758b2dc48b90cc7847af63fe78f08e96f262016740b901d43493fde55958720fbe004747d1c7cc00000000002d4db010fb4e1ffc000374860001fc0003795b002226272b80f5aa9fce78cc60704f1dbcf81715012226272b80f5aa9fce78cc60704f1dbcf8171501b624b6528c6d0ffdd4993a76a23d06016cdefd73300d5a850d41302b179b9009a4969537c5cbf7f0145c94de4306a4e09115ec00248cb1aa76cf04249e2a5104b5cfa86879000000007e56cc8c37501f3db794a554deb4287ac61c83635a0dec6d0f8e0b54ab14f8cd0001207e56cc8c37501f3db794a554deb4287ac61c83635a0dec6d0f8e0b54ab14f8cd2095f18528a48b7308195ec8201220efaafecfbf4df55cc2c8ab6b518733c22d63010e3edcfe65ca42dccfb1cb826562a46097c6f044412000000022df662bfb4e1ffc001066880001fc00108203006afebaad117b22669d50cf8bffc7863662b1d7e16afebaad117b22669d50cf8bffc7863662b1d7e16c671d1b8ae658d8102e47f0bb3f795482a6e215308156eebd6b52f4146a5b3f9686b9712f48980dfa4e8f17b514ba185a31e8d5fa7568c69aa79d9533fa6efd380c27b0c00001390fef6518c3b4b95551fe1707e0f0c398d5580801fb682001fb01bb7f3eea026e3a3bbc8552525a653de7ad02256e664dc6a0dd5e85b6a4aa5386da0000207f3eea026e3a3bbc8552525a653de7ad02256e664dc6a0dd5e85b6a4aa5386da204dea6406996a98efea88a66bddbe7f9568093185b08c865b1b664ae0e594c7be08b1dce6de276ab51d6d1e36be38a3bb1908438b0d000000000036c96174fb4e1ffc000cf6350001fc000d08b30013b0b76a88de761e2de68dd590fb9b636aa288f613b0b76a88de761e2de68dd590fb9b636aa288f6c69a0bda7daaae481be8def95e5f347a1d00a4b43094916711f20db42a7a62118260a70fedcf09443a263ef1891a0744601315b81b03b68fceff6a505581dedcb794a164cd000000007f771a55bf8d18d1ec8c60e61494546e5b9ea1d0639369aa5d09cb3ec7d531440000207f771a55bf8d18d1ec8c60e61494546e5b9ea1d0639369aa5d09cb3ec7d5314420a56ba768ccfa43f27b401cc24a58c43bc067da2b413ea55538d03d322de2e75c01e5ca81c3110acfa3ac727a1bd05453d6cf06bceb41200000002f4b449afb4e1ffc0001c4110001fc0001c61400ba437071f332909dad28d293eadd2d532700e8a1f0a5dd8f973cec456a2423da87b5f1aa97f282e02f8c9d8ff7ef2ad45047238e6bc187d8c124247f30842b8e5b5cc0841de193f440d5fa3e0b4a34df7fffa798fb8c3df46fa31187162cc3b3ecf929689ae35e04cbac6e069f00000000802811a147502b6982e3b863c43b6cbe305cec9929ef3bef5674122ce17cf1dc000020802811a147502b6982e3b863c43b6cbe305cec9929ef3bef5674122ce17cf1dc208c47b1a602d9a9b72807b5c193807b04179fea1d2bbbe6ba2ea6fe36e6c5896e001a135a0120585004a87405b40ed844252aaf6bab000000000012edd9b2fb4e1ffc000bb3b40001fc000bc7b30000f9c0ee13e710b556c5abb7dba04252cff9525600f9c0ee13e710b556c5abb7dba04252cff952561ec5c66e9789c655ae068d35088b4073345fe0b0300b53e680359dcb0decea5bbbdc65576c6a03efc22d93347f19e635feb55fe0cdff6c0b9685dbc999d889f8eed8833fdb00000000807b6948d2bf213b63f7fb1af6175692b6df4629a6c83d59d933ca0c744a0007000020807b6948d2bf213b63f7fb1af6175692b6df4629a6c83d59d933ca0c744a00072007004a740cca33d9593dc8a62946dfb6925617f61afbf7633b21bfd248697b80007dd6b299910d521be585a9288ca0c7b20c9ca26f00000000002ce28ea0fb4e1ffc000b94c70001fc000b9cf300b5d77242ba975cfd47ebb7c1c6f991a868622f1867d64f06bd6c80af5a0ce510c05488c6b605f5b27dd6b299910d521be585a9288ca0c7b20c9ca26f3091ecae225a25f252b7acb8e79173ab1eebd850c6415019b7ba8d11510a48591c2d4d863ba8b716fe38f248fbe8a1f06a0000000083977cb9a12a31f510641cf6bf09190ebe245b167d9b455cd0437a197933dfcf00002083977cb9a12a31f510641cf6bf09190ebe245b167d9b455cd0437a197933dfcf2073839439e285bc285f129f2439f8f1d6f01092909bd405c318e10b1d68d5af2501eb95c9099b7ea9dcf7d12eab52c964628d99901500000000003695bb4efb4e1ffc000b9bb30001fc000bd21b00c4cb4d2d29e56d01ad22d35a7e9cb0b1bb694ca5c4cb4d2d29e56d01ad22d35a7e9cb0b1bb694ca51ec5c66e9789c655ae068d35088b4073345fe0b03091aa06ab2cf470a4265fbde61c153eabe3bd5efca205dc5de54c42f0041b163cee67b72f3b1da2962a5dee3096cfb580000000008458fbd557903692f8e27b4639421db21b0f90469d310bc9221ef592519cb3250000208458fbd557903692f8e27b4639421db21b0f90469d310bc9221ef592519cb32520a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e66e4dc94aa0f3fc1bca598bcc432424bc69ddf4de6000000000036b87e19fb4e1ffc000ccadd0001fc0010e78b00158c9bc3beedd2fae2f1a25b954f315c4fa44f6e158c9bc3beedd2fae2f1a25b954f315c4fa44f6e64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300935576848f6ab7e27fff34b671953672012352e36f5147181926b8bbc9e8b43b98458704666df25d36f37d41eb7c6940000000084bb939170f4714be54d6217cffa5a3818a1c521115d45141b4df642b1dbc5ac00002084bb939170f4714be54d6217cffa5a3818a1c521115d45141b4df642b1dbc5ac20fc2b411dcc940c02c50ba66566ebc630687c29da1c8c6797c24a101118202d2801b4b492aad7a4e1697be9c6c24f6b4ae07b46190300000000006d61d62bfb4e1ffb8be60001fb8c3200dd52f6e013f0cff9cda0dae34d43317bcb66edfadd52f6e013f0cff9cda0dae34d43317bcb66edfa976b7ff055f5ce7ed9315f6bba901f6064495822300f4002936319c495d9557ac1bd514bc760cb8db72dd99d5d20af93dd5a7570974d75e5761fc494de28127ae02413819c0000000084cb17f8193558315fbb5acb6b285f80c3727489f3f167380189c73751ee99ec00002084cb17f8193558315fbb5acb6b285f80c3727489f3f167380189c73751ee99ec2049c551c2b1b3c0a0e8c90be10c5847f49f7573ba6038dfe56dde66127bada0b3001b35584083c3b6032acef150d939f606bdfcbfeb00000000010000000000000000000000000000000000fc0004bea80001fc0004c8e50197726f02d3aa3114065784a38c5b0c7dd66811d897726f02d3aa3114065784a38c5b0c7dd66811d81b35584083c3b6032acef150d939f606bdfcbfeb300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084d181ca2e1afd3fb416c71f62c2f5370a1e7f54c3400faadde30563e62f731800002084d181ca2e1afd3fb416c71f62c2f5370a1e7f54c3400faadde30563e62f7318204d00207605a792d8f6a528dadf5169b89982dbe9614f11224f70c4b03d45cb4301f3ce2464a6f42e28bdd570214f656bc226992fc200000000008e5d284ffb4e1ffc0001aa950001fc0001abbc00a4e27301bbacc1c42b5e2268bc2b4400599edcf1a4e27301bbacc1c42b5e2268bc2b4400599edcf1f3ce2464a6f42e28bdd570214f656bc226992fc23005b69b964d581a7659f5fcf2cf4a50a75e9cacccebc4e18d27364225eb3f9886de5472cfffbf9cf029f81b49037e27a20000000085412e8586e7e2015db1d2e9b4dd380e89251ed812e40bf8d5e220ee40bc18a000002085412e8586e7e2015db1d2e9b4dd380e89251ed812e40bf8d5e220ee40bc18a020da0c7a3d5af8a813d69d33357370066a2f5e1f7aa6fd6672090f355b81c3d566014c70d3eeab48b3455b85cfd354c9b4de7c267e3e3c23d70a00a747dfd4fb4e1efc00024da90001fc00025d63000835d0e8b7da48d8880e8d3420b7c8351c7a31d84b682e8847992b8e9a2531cef5a3169ea5b80c58d458f5157d91f4832e66eb8630ab3dbff95551d83080b7defb6341399f9e9b4ed7c2d627fc828d0eff9c168165b75b24e5fc6c3f5bc8a9eeaee2bc655fdaa58c0d2f3b1b940000000085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82400012085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82420593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1aba3f43f7376b9025296fa73a30c07ccf5266eed8000000000036c92083fb4e1ffc000cf99e0000000f89b9ac5ac8f31255f692a3eb0283d0ef3be4360f89b9ac5ac8f31255f692a3eb0283d0ef3be436c69a0bda7daaae481be8def95e5f347a1d00a4b430ac3026b3e3023db1db9ec8e3b7678761820a2a6e96e7a5d9a39b1894170f9cea7765d3d131d60fa9d17492ba560fb1f9000168c506d43816d1a8389c860c1d162be44d1e777c01fb8f3001fb05a38627ed5599adf01d97427316b0589c2e97ba6418916a9bde5b2585e1c9c4f6250000208627ed5599adf01d97427316b0589c2e97ba6418916a9bde5b2585e1c9c4f62520aafe6abef33b368787d302dc54f71cd0a619d4f988d3263aecc745238871bd0d01deaeccbae07a6664dc82067b7cfff4ff84c09c1b000000000022d0d181fb4e1ffc000bb3b40001fc000bd203008b582cf224fbd769b14e7bab26bdb4e0c9ca5f038b582cf224fbd769b14e7bab26bdb4e0c9ca5f031ec5c66e9789c655ae068d35088b4073345fe0b0301261d7939ba80738dd1ca4ed73829488159433938e37256803daebcd7042f1963a66a2eb58622a87cc91aee8225a464e00000000869b6700423da629920dc2101ec88e894f450f66aa751879dce0468945e04179000020869b6700423da629920dc2101ec88e894f450f66aa751879dce0468945e04179200c0397f81c000328a2de9d047105f8e01d0ef36fd900ad13691aeec8c536595501352b6ca5a0485762fbe87165aaeed5c05ed4882700000000010000000000000000000000000000000000fc000192350001fc00021efd00e049e560af6d16e85a90ec84285dabca4e44514e011b1a772ead943d16af20c36c7255e18ea51027c0f5b027f3497c6e3151b44b63e43776d34c3b62300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086b8061fb7fe866b492b84e85aa0548f68ff376c4cbc5893e46ae361a5e5724100002086b8061fb7fe866b492b84e85aa0548f68ff376c4cbc5893e46ae361a5e572412085accdf9c5e5c660057521c0001e313efd673a38d30be926546f897d5b71fdd901e0d22538c2de001eb6fc6c2444c442e944e888e500000000006deb4738fb4e1ffb1c3401fc000132f901fc000378e300c8270f9d208c75006659cedd927f04ccf829242cc8270f9d208c75006659cedd927f04ccf829242c39ec59af37fd69ca39664fea97c3a5d3758f3b17308d1412ff39045ef39c2e19a75cb3ad986afc14c3139ed0a3392b41d471558676029a8137f95b0ba0e7315bf11c497f0f0000000087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891800012087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891820593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c071594bae6e759f13fbc246c11fbd8d97d68911241000000000023a79195fb4e1ffc000cf99e000000762e689e7bfecbe16bfd0e6138eea642ee0513c5762e689e7bfecbe16bfd0e6138eea642ee0513c5c69a0bda7daaae481be8def95e5f347a1d00a4b430a7afe7674de986aff5e2e0a173be8c29abed8b5d6f878389ea18be0d43c62ad1ba66a59e9e8d8453aa0ed1a69697675800019b9cdbfe3568cc0b37f136b00a634c75653f05e301fb8f3001fb05a3870c6a346d863f0963e4a5f251dcd712b0a8bd8ef6aa8f63c7ccfdf981810705000020870c6a346d863f0963e4a5f251dcd712b0a8bd8ef6aa8f63c7ccfdf98181070520634482f1393532816bd77ece32a84a17a334ac110e47184574d16d8b772261c9007d4af03527d7d34738eefa6bef126718c5e4edc50000000000235667d3fb4e1ffc000bb3b40001fc000bc783006d8404dcefe34e6d52bdb4350026dc8ce574b05e6d8404dcefe34e6d52bdb4350026dc8ce574b05e1ec5c66e9789c655ae068d35088b4073345fe0b03001715f72f5b165d307bac41c2f933aff79265d1b3b7fbcea31e1cf842ff4955b8ec9f510391659eb05282aaf7434b4b500000000874c44b97f12d2ab126377cacdeab45e3fff8c78267c71b1ad051a714d58e6d5000020874c44b97f12d2ab126377cacdeab45e3fff8c78267c71b1ad051a714d58e6d520a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e4da1130bbd7061d88f984d3ec1507026ba9b2493b3000000000023552198fb4e1ffc000ccadd00000001ecf043431973b9cff69b82f15ac7f6a6eb15cd01ecf043431973b9cff69b82f15ac7f6a6eb15cd64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73015a577f51dc6fd7fa4621f0a4601e48fd65418a89c2af2afef725fb4f053a8ee5841cd3fdae39ebdf5a202e0c4deca230000000087c23375674218932c768502d4ed00794fa327b0a95f3fd07e3366021284a8ff00002087c23375674218932c768502d4ed00794fa327b0a95f3fd07e3366021284a8ff20e7b95bea480d82316911dec49a09e8ab6a65a40fd4fdd93f11372737636de4cb019dd617c523be40d62d6fe6c8099a2731bb8f64b200000000000353f0dcfb07cefc0001d4d40001fc0001d7830041abf15cda4f87c47836fa95b0e6909449272a4af2b29900381739339a74d57fdbc677a6ef249f1c040683a4f0f1c3abb09335c41cba814d8f1a24a3308074793934715bde7630f4f267a9647955ac45400792369bd3e5f88e2b9d6c809251b79428e3a8ec07bdbb7364e3c2990000000087c5a82f46522a809f60943985bdbbe6ab131f49bc4b35602c0b2ed34dab354d00002087c5a82f46522a809f60943985bdbbe6ab131f49bc4b35602c0b2ed34dab354d20ae0e04e42fd5e99597eeca25834c5eacb8c990957a179f2873cf4b913b97af9d019723404c2622b84de329f7bc2459cc224eec9ba03c23d70a009de62866fb4e1dfc00025ea30001fc0002847c008a8dfe8a388fbef15d0035c320ebefd5ac5ae2463305078857e34417e861260119603fc23c67d221d458f5157d91f4832e66eb8630ab3dbff95551d83084fb8f4119d367a2336982fecdcf326c56b7c09c0911994720ebe2a657d5d95252be1871889b13f81cdd16d49e15a7d30000000087d21608895b8148fdb2c846d5401158720c3721dc07c4fa0981f2bb25ae52d600002087d21608895b8148fdb2c846d5401158720c3721dc07c4fa0981f2bb25ae52d6201e4a5c4121ca8d8f8e51946d9fc42b510937cc7e0a0b9ff1b353aa316ce8a4fc017433ee61219aace0ffab939271e77c28e1290556000000000044b7a536fb2714fb6a490001fb6aa200419483f32fe1e48e4fb5ae37cb31cd39247ed46a419483f32fe1e48e4fb5ae37cb31cd39247ed46a6428ac0c44a1383f70c2fe1f13b588e2dd3b14dc30974b7b4e608007f22ece8fb933fc18d66cf35cc0e5a7977279a092976b501786d4ab9108c7fda681e23978bf54b7709a00000000880ddeceb54dfaa8c4750e03f69d38c06dcb2f8ffa9dafe9b3f7a08d28d45e99000020880ddeceb54dfaa8c4750e03f69d38c06dcb2f8ffa9dafe9b3f7a08d28d45e9920a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e63dbebe4f6a661367d4a83b8f988b5759628d7f66f000000000022dc5551fb4e1ffc000ccadd000000a9cab48330c4f2058fc7d331b9355b91056c68e1a9cab48330c4f2058fc7d331b9355b91056c68e164f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730111a30e0a5f2f5135dcc5f09498e4ba5de22c7680f396599f7f29b91ac569c3d4336bc157443cf8c06682bfb5abb22710000000088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f00012088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c03090aa69c8d1a95839e017d1b2b53d3499fa0a9aa000000000034211c2ffb4e1ffc000cf99e0000000799f054652c1cef10d2994fb83d012d559a1faf0799f054652c1cef10d2994fb83d012d559a1fafc69a0bda7daaae481be8def95e5f347a1d00a4b430af9cd8567923fea3f6e6bbf5e1b3a76bf772f6a3c72b41be15c257af50533b32cc3923cebdeda9fce7a6bc9659123d530001711fd9548ae19b2e91c7a9b4067000467ccdd2b501fb8f3001fb05a3886622da5d1f1b025f69e4cd924fc1928ea35d8312b807d8b50d63107fbd9a16000020886622da5d1f1b025f69e4cd924fc1928ea35d8312b807d8b50d63107fbd9a1620afdc274a214d9cffbd84cca49182cdd43ad3abf0aadb1546dc88cfe6c0a754ac0008dcd60f55257d858dca51e0ab3b65e4680cf572000000000022de0637fb4e1ffc0006567a0001fc000bdbf3000fa716254623b29b7651b989fbada389aafe097a0fa716254623b29b7651b989fbada389aafe097a1ec5c66e9789c655ae068d35088b4073345fe0b030162563fec3d0cae18031294dd0f6a4bbcd153bc1c087b18a7438a95650a2225926347ed3f7cb4723972ad97251b6b35d000000008917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2340001208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f23420593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c21fe8d862d5042691749e866af337e50e599e64fdc0000000000340d8492fb4e1ffc000cf99e00000018d9316618b1f55977af250cc5d8783617084aac18d9316618b1f55977af250cc5d8783617084aacc69a0bda7daaae481be8def95e5f347a1d00a4b43087d25769002af2a4f050127c73fff03a24935e48f34fecaacd69410787d0e6384b345c78e81b1cb397b43dcd635568b600015bdbf34a0dad860c6ec71523ae39373325225cc101fb8f3001fb05a3892048b276a248b44e0e0c498fe0133e19a9a19ff03d2a6201779759a9e597fc000020892048b276a248b44e0e0c498fe0133e19a9a19ff03d2a6201779759a9e597fc205b016215386c035a42042a93736befccdb87c30cb90adc3b1279da58ac57cc14035a6f7ff4fd5aeedd90b2d4a9a746d07039afe6e3000000000022dbcd67fb4e1ffc000cf8b101fc000cf99801fc000d04c300db6568bf9cb89a725c973fffccd4baf12b4bcb82db6568bf9cb89a725c973fffccd4baf12b4bcb82c69a0bda7daaae481be8def95e5f347a1d00a4b430a7676e9a8ef4eaafcf47451801388500aaa1c1994c5df1619eb3b54b83dfab28c7969b262454c0397fe6fc14dc8c62d9000000008ab9b419adde6c292a0376f1b010293252bbb70b7d1ac3e08a843cf7c1d1ec390000208ab9b419adde6c292a0376f1b010293252bbb70b7d1ac3e08a843cf7c1d1ec3920b7ced6bdbb2bd4be7c03c89225aa80a21fa0f189164195d6b38e852a9f615a66000abaa849176e61dab40c075e5a1e80e0f5dc8133000000000022d18d8cfb4e1ffc000bb3b40001fc000bcbaa00a3b6ec8347384c53813aa4eec3f5b4608434ad71a3b6ec8347384c53813aa4eec3f5b4608434ad711ec5c66e9789c655ae068d35088b4073345fe0b0309226928f9d21053e24678f1aea92d7668e8c8b6f75c07519a32a40491428908dd31fcc8c7c630d92eb1255592169b8ab000000008ad0ad3c5d5e607a7978ba3f026240beb079a186a784e2034b41fffe917c46fd0000208ad0ad3c5d5e607a7978ba3f026240beb079a186a784e2034b41fffe917c46fd20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e458fbc9d5e0fa407cd7238155ef388b400bdb7aeba0000000000235cdb7cfb4e1ffc000ccadd0001fc0010e77400cfbd1e90f25b6978cc09db70685726fd4469de39cfbd1e90f25b6978cc09db70685726fd4469de3964f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7308ea71272ac9a9c891f0987a75e2200a44fc063bca92892c0a174cff4c0a524935e0b870bd091329836e43ca7d7c87e7f000000008b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08150001208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e081520593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0b3fe432c394e3e96e8804a8e059b1887afc913012000000000034229032fb4e1ffc000cf99e000000b802f02882ed36279ba95674e7e190e86bd6458db802f02882ed36279ba95674e7e190e86bd6458dc69a0bda7daaae481be8def95e5f347a1d00a4b430a1749fecb407bb0e0ab9d6df65ea068dba5dc03e14dcb36abe5cb2b5c6e424683f715ff09ce290d035dbb31add0c01800001a0a0e17bfe82a484fefe348b7569a6d77d29d2c201fb8f3001fb05a38b971ef085c168cae87c3ef20dcdebb23a9a26eb7d47a4f793aa2353bed4018e0000208b971ef085c168cae87c3ef20dcdebb23a9a26eb7d47a4f793aa2353bed4018e20506cc8538b9cda4631382a1226a65d86a77ee7ca6fdf7d649c06a104c956903b00e91bdc77d4faecb8481e9d54c7e69a74c98d664c000000000023a63971fb4e1ffc000656800001fc000bd4aa000466dd0bf8e08e82a49b9d1e42872510886ab7630466dd0bf8e08e82a49b9d1e42872510886ab7631ec5c66e9789c655ae068d35088b4073345fe0b0300d82df2de7cad8263357f244c3c20824b450e7ad24c6ab0e264a0936b7f737e9402144c5205d4e38507dc90226ab97f6000000008ba8c6867b46bb40408022696bab30719990806d6e5eeebebe8e5377228b3ac70000208ba8c6867b46bb40408022696bab30719990806d6e5eeebebe8e5377228b3ac720dc964f0dba071a3102960a4848d57042e6397a041568e0d8f988d79202fcab780186f37c9afcf2222c2e1846e6aca7cc3075cbbf81000000000022d2f6b9fb4e1ffb7a1501fb868501fc000119c3007dc8a7ab041ff32acaee3dcfcac1e36bbc126cd2b2ea896299dd86bc7c3353a40d354be43ca263727eb0a0af302dd9ff95daf9e98d2f1f2c5d764f74308b5d53516c0c7134efabc77f5f7d19b6e289b5e8befc35ca5d77626a252e659888fdd09a7c9bb286dd9fc4d73025bcd7000000008bcd5c2b4956f890f454d07300fbc2bd5ec291f9f68c5ab4f44af8073a5fbd8b0000208bcd5c2b4956f890f454d07300fbc2bd5ec291f9f68c5ab4f44af8073a5fbd8b20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e59c3439bb3f8a5f9106af32c1c8cc8d730bbbd8e9e00000000003646f303fb4e1ffc000ccadd0001fc0010e84b00365a8a65e5270895c8e0a3557b1bb425c8efd7da365a8a65e5270895c8e0a3557b1bb425c8efd7da64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730183e7c881c6c556701b21eb3f837e2661ad4ae1ad5b9f11faf6cb1246daf99157f3da6491b8dca8517b33b32abce82a3000000008bf18698fd403d18f976fc5f89d79db263fb354a63781a512e2d48faa17190f10000208bf18698fd403d18f976fc5f89d79db263fb354a63781a512e2d48faa17190f12051d89c906e2bddf572717e4806a4be5db96b544b5c9425a069351a0e218c9c2d01e973eded63a3abfb7f48eb28c27469e5da76a01e000000000017f0e8c3fb4e1ffc0001ca240001fc0001ca940039f55c68417e332cb9d56879392d0d34b8858df704dbf4531a1c3aa937a63bb4d5a67f13a335d5c3b1605918c84d18613d2c487619ae380f36282ec8308041404bfd1cd4b71416116af92b7a17f42c47bf3dbc2294369fe1691eccb9ba851183a0e85a4fd728c946a582d006a7000000008c15296dda100476466c2af9f2d212097c0dad634c47894e34e89b0772a7ef6a0000208c15296dda100476466c2af9f2d212097c0dad634c47894e34e89b0772a7ef6a202dd418858077835bf0cee0935325099557a492a8de9117e9477c520eb8349d5c013db931950d15afac53606bc3191ea0ceb8f1a0380000000000340ce25efb4e1ffc000b9bb30001fc000bd24b00bda32a6923c976abd03cf593ee3eca92f44213e0bda32a6923c976abd03cf593ee3eca92f44213e01ec5c66e9789c655ae068d35088b4073345fe0b030858aa595f574ea2a3c76a01d3de5ae733932304d08be169583c75df7879dff27232b0aae832aaa25f318c38794b9f670000000008c754a2bdd2ace903ed98aae9f52f481e7a6949ccf422f4297e0ba9a500ca2740000208c754a2bdd2ace903ed98aae9f52f481e7a6949ccf422f4297e0ba9a500ca27420a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e51a502e87250d362827c252cbf2a4b54bc793b34670000000000340c3659fb4e1ffc000ccadd0000004bbca9fd6c162000d1042f510196c4d069bb05f94bbca9fd6c162000d1042f510196c4d069bb05f964f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73014eabcb82f2b0b9cda8eaa3cecd39f0058b418cb7a25795f597a811895bfcc23643bb25ae8432a52804dfb53575b649e000000008d4d1bfc7e6667a370e072079dc70b3e3268f71a32a54371487339429aa475360000208d4d1bfc7e6667a370e072079dc70b3e3268f71a32a54371487339429aa4753620431d3dbca48a3392be9c41a68961f2d1cf3d5e5b93151b2b1e47f635e03ba2b6001d70b39a95401ae5dd407a846e9a775a92513f5941700000002d3f6868fb4e1ffb544c0001fb669a00752afd96dceb969687676e32c4cd3116b76a5c84571ac9b0061529d85a340440e6fd38a3ad5633c847b71db162f3f607a3fde13909f0df2e296a72703005e588704a6f6d703617081d8328c006b1173d60aa26cfe44b954f1279a1ba9a042bddc5b3a00cbc8180676d12060d620155ecbd72e31176702506fd6219751a8ae1a6c4310000008de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc40001208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc420593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1dd08fdbbe79813bc43a306740d2182674141d76de0000000000342b56e7fb4e1ffc000cf99e000000300904176cc6023370b2462964c12c5979b9f411300904176cc6023370b2462964c12c5979b9f411c69a0bda7daaae481be8def95e5f347a1d00a4b4309502bb884b3437d65c0e025e49fb00ff6ea9f55d5bcdc36330b46c8bd18be9126b7a6d7f35f558ef8040f2c2284500a50001337b7fb5d2c531825c3e0123ac3354018085b30201fb8f3001fb05a38e0c95f8f71cd450abe7495077ecb431068da7821ca4e38af735565ec630deeb0000208e0c95f8f71cd450abe7495077ecb431068da7821ca4e38af735565ec630deeb20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e375f7056751bb5796fd2d228ed85f5c88b053e6443000000000036be8308fb4e1ffc000ccadd000000d28ef7142aa96b23b44a0e7a5294dc2152e5f53fd28ef7142aa96b23b44a0e7a5294dc2152e5f53f64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73094a0bd3671bf20ef2a75c2e1723eda50a4d7566ceb0f5e018af7c576e11b1320b4b370e703afd4a7220a7c5688414040000000008e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c00001208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c020593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c20f53e3ff160dab7ec3cc2a6b0afa6dd8d36e38794000000000034599a30fb4e1ffc000cf99e0000000063eb51fcfd121e6c3eae23b90b26cd1100217b0063eb51fcfd121e6c3eae23b90b26cd1100217bc69a0bda7daaae481be8def95e5f347a1d00a4b4308160877a911d8bb7d1e75e2320e98cc3233c1f6972cb642424bfcec7c182c56d2c0ebb59e45f788f4d5dbfa2ebff3e3a00016d57707c196e06487d326094c964f258f5b77c3501fb8f3001fb05a38e7a3cbb99a9ce89685175ce3b3b5efe33498f22ddb539a2c66190390ff9e37e0000208e7a3cbb99a9ce89685175ce3b3b5efe33498f22ddb539a2c66190390ff9e37e20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e325baf1be4d6ff7516aa41a0c9947396f5dba016a70000000000235a2a40fb4e1ffc000ccadd00000072ed00fe080bf542275abf350c2922a8a2ff119672ed00fe080bf542275abf350c2922a8a2ff119664f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730082cbd9118474316f40b800e43f94a121928f256fd340098ff0ad81a902c4326dda4b42737d52739482f2baa80c487cc000000008eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f0001208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0e55b79902ab8dc5c126e61ebd5bdc2ec98d80836600000000003644ebc9fb4e1ffc000cf99e000000983259ad7ed51267fb83a8e41bbaa5ab55c632e1983259ad7ed51267fb83a8e41bbaa5ab55c632e1c69a0bda7daaae481be8def95e5f347a1d00a4b430b942e2e50c5cf9d9fe81119cc5379057c05fe15134f85847356b5d1f6a21f29f4a53f61f03338d056edc15a8c63fbbe80001c075993a8336f93a13bb7bbb7e0e89928be4aafb01fb8f3001fb05a3900618389dd73377e2b33b021d2e8b0e7c51f8f5c1d871af15886e3cd6e6d6ae000020900618389dd73377e2b33b021d2e8b0e7c51f8f5c1d871af15886e3cd6e6d6ae20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e3a699566abcaa3fe7f3568b95e28dec3bb11537726000000000022dcc2fdfb4e1ffc000ccadd000000e7b23e56a97aec080890987ca187cc902a4efe21e7b23e56a97aec080890987ca187cc902a4efe2164f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300dc75e865b89e96560b38fae96f1d0a5438795778e68b705a506046245ca5dbbedb09e2379eea4c9bde0d0fd4fe0508000000000902c18f9e7451f382b6a41e96b766ac3754e792a31e75c8ca0f2da5bda93c708000020902c18f9e7451f382b6a41e96b766ac3754e792a31e75c8ca0f2da5bda93c708203ad39dbb8bfdfb4a46d3f8b1e5b328c4724acac30b82034349a6b831070b8dbe0008cfb189e4df6f2fee5f9c756a0cd23b3c871067000000000053e97783fb4e1ffc000aa0540001fc000ad2eb00747d38fd242d8f1114f47fa24a233831b5305962747d840bce00916fa12947def52684f03a37618b08cfb189e4df6f2fee5f9c756a0cd23b3c87106730198e877839e3a29d8e1e0f0f8db6d9e533902dac30db36ab1330fc4e1e45427b658fac866dd8bb65b0c68b263ebc695f00000000904132db5c8718123233252283268bd908f1585a7a8db92f997c03694914f0d7000020904132db5c8718123233252283268bd908f1585a7a8db92f997c03694914f0d7208e8e515f7025352e7c608479e413beacf0d95cbb964b47e4a98fd27b6b6b628a20484569a0b078f0dcb21a0253aff10ec06b1aaf01000000000034d41347fb65e1fc0005e6990001fc00065754006efa257a906f0adf9b184b0738a187a5b775df686efa257a906f0adf9b184b0738a187a5b775df68484569a0b078f0dcb21a0253aff10ec06b1aaf0130962c65927aa1616e3783ae7cdf8c3d19b4c26b477686a9f146cd9ae40eb7c0e01a1580d5df8c32d1f4c43a52f62ff5e00000000091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d00012091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1eea45a388d248dcd7433c8c8113d5d0966069413500000000003428db29fb4e1ffc000cf99e000000cf83406065cb65ce74100f3c35a0324bfc92dcb0cf83406065cb65ce74100f3c35a0324bfc92dcb0c69a0bda7daaae481be8def95e5f347a1d00a4b43081ad0f9be5a88ae62ff54fe938dfceea71be03bd4c6a7aebf75896e8d495d310acc4146aa4820bc0e5f5b06579dedea5000102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd901fb8f3001fb05a39212f5312730c7881b882b9fb7864dc686fa5a585b7a93253ccf1ce87ee593310000209212f5312730c7881b882b9fb7864dc686fa5a585b7a93253ccf1ce87ee59331203193e57ee81ccf3c25937a5b585afa86c64d86b79f2b881b88c7302731f5129201eaf63db1bbed2ccc65ff8763bf9cabf44b8d6dce00000000006418ef40fb4e1ffc00017eae0001fc0001eef4009f804e8f9cea38d4380e1e4600d4e16bd49ac9d695dc83d7059a8aeca9996d6c5436db3f8c9924fff32bb66d6fdcd07b1268d21a3e021c9c95445293301931bdfa94f15b64ed9d09d210db9998dfa068332fee19d8e1ba4872c0acc3efc723e2fd04a64ef2da473caa4471c69e0000000092b5bbdfcd2d46938c23f5d48ac6dbc2fb041172766455fbd8863cf81e8bc9df00002092b5bbdfcd2d46938c23f5d48ac6dbc2fb041172766455fbd8863cf81e8bc9df20bfbd6a521797bda7e2a5219db241c335870a521037815380e7ac2bca5be84948017bfd226583bc3ca0a3547672f9d264fa04a9d9c200000000006a0c494afb4e1ffc0002fbd50001fc000377ac0007ec0bbe822a5aa140229c9a460489563a7b6a77bb9bd2501e88903aa50a1eb8f36a5eb1fd0a29e250299c1357baa7e34f19a5be2a225eb65f5dd9993007cff9e4c50da82722bf41fa5da01ca4bdb238d8d53fef085a56c34a432f6994c79e5bf754898499ec4dbe91eec0d00a0000000092e1ab09f73e703c196eea46780a14e8eefa5b5e1c0ee31be05718056e020af200002092e1ab09f73e703c196eea46780a14e8eefa5b5e1c0ee31be05718056e020af22020904a313c770af35f380bd22f3f7a1891a7f368e4594de5889adb9beae26911003306e27f0719a83ffd6ebd35183d8dd714991b39000000000012ec7145fb4e1ffc000bb3b40001fc000bc7cb004c6cab39e8742edc7d062b3ec2c51aee9342e8dd4c6cab39e8742edc7d062b3ec2c51aee9342e8dd1ec5c66e9789c655ae068d35088b4073345fe0b03011b5a1fc5f84431ab1546dd7189b7ce61eb9a0615a96e4467819a4af04a633627aca3494cf5636f2376228bbf7e91b470000000094044c070f9ce6bdd05c2b655ad2383c8402a74c10e0a9a3099d759b33cb763000002094044c070f9ce6bdd05c2b655ad2383c8402a74c10e0a9a3099d759b33cb76302081dbccc2d89066db311d0d2ca068436e6d98ffce705abfd0ecf69d70f7206ba401b542c265e3f41425380ee61edfec8a5dea7fda0600000000006c3dbd90fb4e1ffc00023acd0001fc000529a4003c7b27ea1137b6aa8714ebf68d9c54fd7fe23b414915c7d1e335096ed8afa549bd4b52c6491d0df912b3c0f5799b64529486fff598dc276c4897154630996f5888a81b9668c16a12c87134536e3616c929a7b67b37aa06d3eb7d7e405e3d3148ce7a072128c9063e1a8042eccd000000009427f6cbb0807d4783d74927eaf1a70e9c19339ac47ac7be1dd80b0ca4ec28350000209427f6cbb0807d4783d74927eaf1a70e9c19339ac47ac7be1dd80b0ca4ec283520a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e438df2a5d0be49659e711d7ee517481e23107fd25e000000000022d1eee4fb4e1ffc000ccadd000000de39cdda2efe7dde604c1965fa539df01785bccade39cdda2efe7dde604c1965fa539df01785bcca64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730959f6f2d48d283390b246a55b19a267f8ada326c8eb67f217839d5d1cc55377d8c1a2962cd5e80b892577454390c36b800000000957acb5bb59e253059da86924b5bbd94c1daf5b0fcd313bdb78e43bdc7cad000000120957acb5bb59e253059da86924b5bbd94c1daf5b0fcd313bdb78e43bdc7cad00020176deee4e53c297f44029a7db294451139901bb49f33a2a0ac8bd1b9e744fee201c406356d37513ea70f93868797061aec981337a700000000002d87b4aafb4e1ffc00102b8501fc0010594501fc0010598300cf0ea50da406da09dd78689abaa7c44aad428e3f37f1afe5852c1aece552ed1be61dc898a8db05f06e0e8a6ca912d408dc8369365e947a41d9d0a9d83098fc5928355798aa9237b107935ba606bd749e16f2922d8c4eb6b6c2cbbb4210f3bad09fe7d199aa3884fae3fce0120d0001a5bf8ff04bf1be7f1d98cb952f1b49f8d162d8a301fb682001fb01bb961e7fe42fe63f21e6e21556d2b4cc8c0423c1e176873efed3a14136dcbcf887000020961e7fe42fe63f21e6e21556d2b4cc8c0423c1e176873efed3a14136dcbcf887206fe932a6b6385b29bcd78378e71a727bcff83226945744019035493b24003e5301892f0612c075706dadccef0848d67a8ff5b8446f4120000000a7637017fb4e1ffc000899e301fc0008a30d01fc0009093b00a656c3104b5aa2a042680aef3494b62eb3ac3e7ea656c3104b5aa2a042680aef3494b62eb3ac3e7e52e70333f9bcad1e0b5c60777fbc3a17bf23e1d830804fadcd7b5dade6f9f577fe663cdf86f1483b71e6fd8e7c5cc4b981c0ee086412b16c796ce8fa3f7b6445fbee8666400152e70333f9bcad1e0b5c60777fbc3a17bf23e1d80000009693e443a6820038ad1160ae01311a85b4573965ca4480317611d5b6e048aa2d0000209693e443a6820038ad1160ae01311a85b4573965ca4480317611d5b6e048aa2d20b7b7b143980f65ade8556b431882dcab54ac9387fef544e8581d709e53d19a000052fc8bcf6fea0c7ac216d544308afa9d8920774900000000003695fc92fb4e1ffc0006567a0001fc000bdc0b005e66b53e3569ba6d1dff160ed56d074dc63f96c35e66b53e3569ba6d1dff160ed56d074dc63f96c31ec5c66e9789c655ae068d35088b4073345fe0b0309058f3873b1b4fcde2ee8c817d04626cad7de91c972988a4288d4548d2585074c11f29e270d094a9ed95f8618ab8ed54000000009712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df540001209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df5420593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1277e135a613d9797db4d7a9d2e51bfe8599d3650200000000002352c5c5fb4e1ffc000cf99e00000020c7f1991e06d09b1f067b049fe6d0af0a20f79c20c7f1991e06d09b1f067b049fe6d0af0a20f79cc69a0bda7daaae481be8def95e5f347a1d00a4b430a8dbccb130522909dc710a65728006732c18441757f12a338cf4a6d8cbd5baf1a484537a6a0542f51bb686e6e546f1a00001ed1131823bcea23ac78af8c01e4d24683d6ecf8801fb8f3001fb05a39767a4cafa9d1057b48de795ea834a15664b58a79d75a4f826299ce1ba11842c0000209767a4cafa9d1057b48de795ea834a15664b58a79d75a4f826299ce1ba11842c20cfc9ca7becc69990bce0fdcf42c6d7ab1317281effbb2bef1deb457d226f3c1c012a566509d67f0566a01c5bc8c19b455095a52eb000000000010000000000000000000000000000000000fc000170b801fc0001b6f301fc0002289400f3fab21f5d1e86919c2e57fb4561244688c773aa25df60b3535787ed34aa614aeeea9f99236ea994f0e4fe2e70afb072ea5c2d06f5cf8503068add46300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209600012098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209620593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c178b5541d75eaaa98f8ad22355a122c55741f339f200000000002ce8c406fb4e1ffc000cf99e000000caf6f1b9916245ce300a63fa2254ada25e0423d6caf6f1b9916245ce300a63fa2254ada25e0423d6c69a0bda7daaae481be8def95e5f347a1d00a4b430b6175b59aba8cc0477d4fff78bd90294f31ebd385c39bc254c7995a5dd3ccb8dc1d8869e247bf63bef8ec79317f479a90001d6ece912cbf02627a4efc3dd37e6833cf367155101fb8f3001fb05a3995d7facdd36d2db5a0e3621ea50678ce494149b4d2dece73d4a7fa2e095ac1c000020995d7facdd36d2db5a0e3621ea50678ce494149b4d2dece73d4a7fa2e095ac1c206a963e1d05f10a5a744a8429a7d5ee8f482c4f6e7c4093a2c60c124f4ae2717001683eda694e5f2b0e9edd6f281eaac015f59790500000000000cff66169fb4e1ffc0002055a01fc0002099e01fc00020beb00f05505af7fce03ad669a45ee34ffcdba84636ca2373eabed3a46c91e10415d8a7e0b36c2867b92f96baeb84347272b9450cfad36524806f5f8135952308c26812d38faf159f811a09c1462e07e40d6b44881114358cb5390b65778ee437018c5879fbf935fd78955899b67633e000000009a37c6dc3e32f3c52d3f3af8b4d46b773e01d3bf27817bf609b60631c620b5900000209a37c6dc3e32f3c52d3f3af8b4d46b773e01d3bf27817bf609b60631c620b59020a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e2b481b3ac3d0ca22240b01de36b235aa1eaf0b05a3000000000022d4a1bafb4e1ffc000ccadd000000fd47aa98b58734af1453cdbbe5ef9396716775f8fd47aa98b58734af1453cdbbe5ef9396716775f864f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300aeb5c2757211202b3afd2033ec1b4ef2dfe376ba5c6c07b45e6a7460afa4086423c4a704eb9a781514fbc513e190a62000000009a7f3e66905a2588695023cb6638bac294aa7ba4fc332737062398a173447f4e0000209a7f3e66905a2588695023cb6638bac294aa7ba4fc332737062398a173447f4e206c4add138ec5499b898d5d712924cf027be42e67c94174caebf143030cf15bd401d544504a737db17be4b9bcbe091cb419c8dbe3f000000000000de4d231fb4e1ffc00092bc20001fc000b4a5b0092d2b72ce01caa349e82d0490990e20b88bea135fcec2b5f013e92232ebfdc4f814ac10eb533a25ea5aa7b99f9638528d9186dd57d008654a3abc7a8300517910047a316c354423fedf0402dde38c90fb376dfb680e6b2b430addea140d0b6c795d90ca17f1df658a5d401c9da000000009adf02049b965817cf6fb5b675c17dbc00df7e2fbf68cf3377adfe30e3ed0bca0000209adf02049b965817cf6fb5b675c17dbc00df7e2fbf68cf3377adfe30e3ed0bca205e09a967f881113c81812102e3d365e6573b7269ff1613c7110d058e24ea123601800f683c47564b0cf20428c9abbc735e96c6a49941200000004e2eb95efb4e1ffc0005a5ef0001fc0005a6d500a7889dad2c33e1f6b8b68aa5cbb7392d9e96bdeea7889dad2c33e1f6b8b68aa5cbb7392d9e96bdee27aec5b42d8d74dd11d216bd2628111c4d9fccda300df074095e5498c6f1b76508c3ae700484d8b0d5cd12a990f3dd54e35b47d6fc943af4223d390ddaf8989d883c84b284000000009b135e3d6365e6acc8c0eeb513a3c8cfb68525e6d4719645fdb3fb3340caadc90000209b135e3d6365e6acc8c0eeb513a3c8cfb68525e6d4719645fdb3fb3340caadc920c9cf125e893ba997d1e05decc65ca4ae5c3c658df9b693f1c3b8ca6a14c2157800279480b2aaabcef3c8f4d073724dfffdf6696d13000000000012ec1e46fb4e1ffc000af11f0001fc000af13300d89c5ba79b9553a13f783b50673e15283eff3a3bd89c5ba79b9553a13f783b50673e15283eff3a3b49fd7c9727399a9d1d592b68eb09583bfbbe9ca73088ec95047130c4b310db3b6585c2fbe9453c7f5ff43ee5fe844e74c25766488fae8ad62052ec76a6c2b584029e1b1b04000000009bd4945c016d11b08f5c137900df9fd5472726e002fd7531ffdb4b25bb3c9d330000209bd4945c016d11b08f5c137900df9fd5472726e002fd7531ffdb4b25bb3c9d33208a2bba7feee4b42f3f0d1bf6dec1a3360ea7f61d3352af8bf3a37cfa9a2281ad0077398906f47400c2223db65c6d6b6aff09e0dd2c000000000036c83f2afb4e1ffc000bb3b40001fc000bce8b000a641ffc2886d96fc0d6739f2877e0cb81fe075a0a641ffc2886d96fc0d6739f2877e0cb81fe075a1ec5c66e9789c655ae068d35088b4073345fe0b0301964cfb5518ae0d35f2d02dd5c402351c318b79de1c5ee407811fa950b0ea2ca9f794a8d07ce9cc30fb76fb4e9ca3799000000009cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c0001209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1bbb948d5d33120f51f2ca02c77a0b69761b719f07000000000022d63044fb4e1ffc000cf99e000000c54ac69739bf492d4328f1bf0d49581ce0b10d41c54ac69739bf492d4328f1bf0d49581ce0b10d417ea623bdf8c5607f0390c85586d83d473fa6a1c630b6ee48c7a71a9d8e0813e68ca09846245fa155285f24a62b0ce9cb0102b1994ec58af8ba2a01c09363bdcc395d41f3df000162e960a3f6b650feed98a266b3ccdf6e363562cf01fb8f3001fb05a39f1e242390cde84d67d9e2caeb1fc042a6bf0c85c8393026733ef5543fb0bd2e0000209f1e242390cde84d67d9e2caeb1fc042a6bf0c85c8393026733ef5543fb0bd2e20428e2f87d85de3d5b6a5a86ea5863d35b08e9c514460cda44dcb7e199bb769350083f05c3c1667334c68c95ededade304e08b756ca0000000000369550c1fb4e1ffc0006567a0001fc000bdc0b00cbc9ac9fd1bebaf88433e4ffbf3199ba365153bacbc9ac9fd1bebaf88433e4ffbf3199ba365153ba1ec5c66e9789c655ae068d35088b4073345fe0b03005987ec3ce6dac84c1b2cbb4753e5f361fd2217ca4251211d4eb0d82ec729b1ca540da4d8649c74b3a82e8a6e4fdafa8000000009f4f9f83ecbcd5739d7f1479ee14b508f2414d044a717acba0960566c4e6091d0000209f4f9f83ecbcd5739d7f1479ee14b508f2414d044a717acba0960566c4e6091d20ae21919b512cc68554ca16c583688865967f5375d107bbfdcfd79da5cccf772a01bfe3d321e667dfd5d7f5922c1d6bafaea45caf4e00000000002d20d39bfb4e1ffb1be20001fc0001850300a2dbf2c2b6149412562f306841959b9cac234b73a2dbf2c2b6149412562f306841959b9cac234b735cadeb631ebd16a92cbe6cac1be92247e95b51463008e37b3fcba972fe0c2c0ea15f8285c8bfb262ad4d8a6741a530154f1abc4edd367a22abd0cb1934647f033913cca58a000000009fcf7b15b9c7ce71c11b7577e05edd1ea922125b9ee8fed7d0d8ff21d530a33b0000209fcf7b15b9c7ce71c11b7577e05edd1ea922125b9ee8fed7d0d8ff21d530a33b20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e2f5380d6cae296849f7444e27f8ccba243332d0bd8000000000012edaa20fb4e1ffc000ccadd000000f1b18d69579c40dc8292842f02ff5f511e61609df1b18d69579c40dc8292842f02ff5f511e61609d64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300b04bcb5cf6d2d6df5979234611da42854a5e69374a29e0c85128caedb53d9c818042613d2f30f3ef782ed37bd8ce161000000009fe2f8d43c11c61b5a545f451d5f9ffb89bed5bd91f43988eb97ce9a336922810000209fe2f8d43c11c61b5a545f451d5f9ffb89bed5bd91f43988eb97ce9a33692281200e7a78c30d54bc56f44597f4369f988aa213df3bb910776ba9940e048e37bb9f00e06459f7aafb271dfbfd7ed7dd16fe623589a9ef00000000004e2ea116fb4e1ffc0002dcf40001fc0002dd8c007ec334a85c5cf331176646c2c357732ec06eba397ec334a85c5cf331176646c2c357732ec06eba39e06459f7aafb271dfbfd7ed7dd16fe623589a9ef3080174252e0f66a71b7e53f8b32dea5f97a6b39dfc1479c6e355daa415b1ff7733a4bea6bbe3fdf412fed0fb60e5b71d700000000a052764f93c4edb6c4bad2de10f9328738aef20bbcf3185dee993853a746c097000020a052764f93c4edb6c4bad2de10f9328738aef20bbcf3185dee993853a746c097204dea6406996a98efea88a66bddbe7f9568093185b08c865b1b664ae0e594c7be04692f66e4d117895e7a587976901020ee0bb57dd1000000000036bf4419fb4e1ffc000cf6350001fc000d08cb00cfdabb52d6248b141eb688cdb12f8f07641c3e94cfdabb52d6248b141eb688cdb12f8f07641c3e94c69a0bda7daaae481be8def95e5f347a1d00a4b4300f6c077a09de24df2cc17b64543bb12955632f52bb9525df7686f61c5c86d820ef6d71e9e333ecc869e71418cad80cb000000000a07dffc303cc8c8305380d7d1076d4a0b49bf8ea06352751a1480dd40bf806b0000020a07dffc303cc8c8305380d7d1076d4a0b49bf8ea06352751a1480dd40bf806b0205b016215386c035a42042a93736befccdb87c30cb90adc3b1279da58ac57cc1402276e8dda7b00c16f6cb09751662b1ad26766fff0000000000036bc2e26fb4e1ffc000cf8b101fc000cf93401fc000d08b30083abe51882a96d3c10cbe4a277aec4e0cfbe39cc83abe51882a96d3c10cbe4a277aec4e0cfbe39ccc69a0bda7daaae481be8def95e5f347a1d00a4b430818b1f2d7341dbe7d236945a76a2798da654c792e1311a92736ba4de810af25f1b305ce9acb314eafddca5489f1db88800000000a2313686a6daf92c85bf10c45876b257aaa710b6767d60850c78e33905be433b000020a2313686a6daf92c85bf10c45876b257aaa710b6767d60850c78e33905be433b203b43be0539e3780c85607d76b610a7aa57b27658c410bf852cf9daa6863631a20171d7b555e8a999afba6cb76fd165477520839400000000000068ec34d6fb4e1ffc00065b2b0001fc00065b450050b0f07133bb2fecd59710ae0a4baef7223aceba83c1f4c02bce59c4775cec76c6ca37241429c4e2967023bde3c52aa6bca87686da2c8d5f6cbda76e30915b61f2b726d5409a26a41bb3f350c1e4bbeb5e07e808f9f68361d70ac7fc2fc33178ac9639ae7ef484a427d326f24600000000a3b3e4b3d98c934f056a2e76ec8ff07ef8473b87f559295ece2254b3820e54f0000020a3b3e4b3d98c934f056a2e76ec8ff07ef8473b87f559295ece2254b3820e54f02071ec8af2ff6a68c9fe83db26214dc6cfa49f7e48e20099bb676bc08a26e5691801c81d0059d50a9da36b88ec6e8d69cecf84b567d63dcccccd00d25ad25afb4afffc000446080001fc0004713b002ee6bd87c06f15d21562672548ebb844c5877d5bd641c8b61a2c1d3a3bd4e4c850daccffc59a4ef4c5591200b21667500e76c560dde632b87998d67c3081bc001c31c71b0d4d4f9ecfb205e914fd9cdaab4e7dbaf0b320d40f0bd5b193d1be809ca34eb4979d661f487b21124b00000000a3c1bd9b636f0ddfd72bf99f48c516050085973cd2d30dd637a55bf7178af9f5000020a3c1bd9b636f0ddfd72bf99f48c516050085973cd2d30dd637a55bf7178af9f520a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e5ac5bad801f3318192b2d124eae58e0e24cf32b76a000000000022db991efb4e1ffc000ccadd00000080a52baea6d3b53815a8daab24bb7229c3c6288d80a52baea6d3b53815a8daab24bb7229c3c6288d64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73094a637afe3810d73e3402b5d6a398e45222ba846a339f1c3570aa8e3f7f5b9d7acef08ac234cce4f706671498330a59900000000a430cff6d81721057000ace8eec27abbb70d223a6bd565126337ed69493e56d0000020a430cff6d81721057000ace8eec27abbb70d223a6bd565126337ed69493e56d02056475cf5f3827ba09e0307be6d1374b9e5fa9e9cc8dccfc96168be082f335031018f67a58864ad617560e1c9e6b181d0305d3b537800000000008a440d6efb4e1ffc000a7e7701fc000a818a01fc000b4a8b00f89615731050212b9a50c9a6039059397601920484a12f2ef1a65969f60c6d2e2b2974c36cb309d0f629010378393c23e3d0e1382099f8c7f3c2157e308e845bfce2651b80e95f37e231301260449d1d89aad58729398208007ee430fc8137c323857bc75cd9bda7334838181300000000a4d877cee62f82868034fb678436d87afbb13330d2b66a24ae1d357f0de55c68000020a4d877cee62f82868034fb678436d87afbb13330d2b66a24ae1d357f0de55c6820fc211290b15b583a7a8b55990bdab4493a1fe73cfd96c238a205a93b9ca23f080160859bf00fe1859bd038ccb54f7def625334914500000000005350e5d5fb4e1ffb35df0001fb51fa00d0669e929f06ac80c05365d9558ad79cbb78f2c0d0669e929f06ac80c05365d9558ad79cbb78f2c068189a3fea9999f9897f4542a7a0170679a3c3713016415af54406658be9ea44d82b6b502bb90d93e32997484533a8a71a4ed98d12cea3709d84a5835b6ad8ed48d310163300000000a565c913052a586db0d5a000007ff981ff3b59982e662e02ac6d45e37bf8f0e6000020a565c913052a586db0d5a000007ff981ff3b59982e662e02ac6d45e37bf8f0e620589799b1d3a737137c9aca1650ad98fe415cc3c035618c9f0f01b60725c2e156014cbf5b172cbd72849fa68c6fab1041a618599868000000000091efeb10fb4e1ffc000153440001fc0002426400d2a33a64d0e54ed860973f6c22ad36aebba1dc9ed2a33a64d0e54ed860973f6c22ad36aebba1dc9e2588a17ab3f917f19afeb8c32fa7c486ab4105a33001e584b5723fec78495744b68b971fd654f16b016d676ffdbac01b2c64f319675eda577f5eaa5cf5379e95418c61ab1000000000a671f057d9937b97c9d256e4eca70318cf51f7259fed49b9ab441f13cc1b12d0000020a671f057d9937b97c9d256e4eca70318cf51f7259fed49b9ab441f13cc1b12d020a8bbae719937bb8bbad2f4067a16377a022dd411f2a676d49815482084d1d235000ba82bccdd17d425113f03d098dbe9a7285cfa01000000000068f8da17fb4e1ffbc4110001fc000194c300bd605f715f78f4639ee2cb9894f6750526c952da61110603fcbf3d2a30482e4901612318b34602cdb2334b22379811352d9988876a6e586d975e732930898839eeb51c078a7785efeed45b73db7e97138eb950b84302f2f13d6b33e6f8e58eb14e52c4a9c168edf50f35d0a4cc00000000a690051e69de6e36eeba664bff34e017f973d27ce91c1f2247120e8ce586b1f1000020a690051e69de6e36eeba664bff34e017f973d27ce91c1f2247120e8ce586b1f120f1b186e58c0e1247221f1ce97cd273f917e034ff4b66baee366ede691e0590a601aba486210cd648afc5ebb8842b543da323eace1341200000002d4da7f7fb4e1ffb509701fc000b9e8901fc000bdf0b009de28ef58bce6c501541a589eadc9900dbecc7dd4d31414b558eff2b3b489b6128ac6852e0fdb85c5a375814e9caf5b8575a8221be246457e5c5c28d308b165f653a3970a17f432f6c3abb8b681c71a3775f998fff322341d2994767c167c8a43b1b4661b9c01ef637763d4d8100000000a776b3114d2137d1eedb0908aecef3c35ef001166bf3644d8c9f149b3843fde3000020a776b3114d2137d1eedb0908aecef3c35ef001166bf3644d8c9f149b3843fde320a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e3967f8bdf103c99ddc20f32961a22dcc88fe23b014000000000022d3acd4fb4e1ffc000ccadd000000127b867e4c2d040cedaff979c39220c717011dab127b867e4c2d040cedaff979c39220c717011dab64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73009f8a06bd95c1be3cfdcd2516fabc0858c611d63c76da3a5beaa007b9d7c895aa63c0b2887bd584a76892db417a6683f00000000aab7b2ed5bc2fa962dca591440e22b47ce41bcd2b79394d53dfac5173a3f97bc000020aab7b2ed5bc2fa962dca591440e22b47ce41bcd2b79394d53dfac5173a3f97bc20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e53b1be8daa1cafd2685237f3e5652da5d0aee9eaec000000000022dcf318fb4e1ffc000ccadd000000853fd590bbfa10868687b7c648238857248adfb7853fd590bbfa10868687b7c648238857248adfb764f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730018a6d23ae53d6231f7dd73a058f125340e92f6e97897f017d9d9d4e6671bbd92241170dfcdd5a4ab8ef47ef12ddcad500000000aace03a9c75c17bfb8ed760974e5dd8c94f13234cf03a76123b667caf2b71bbb000020aace03a9c75c17bfb8ed760974e5dd8c94f13234cf03a76123b667caf2b71bbb20b78304bdd6f104cf06b25c94e1de8cd1bc493b801983af667840129fa996dccc007e145aa6ecceb9581d21fe84b2c9f536f31ee0af000000000012ec8031fb4e1ffc0006567a0001fc000bd9b4008b8f48a17ec07a3e313369919447fd44560798a18b8f48a17ec07a3e313369919447fd44560798a11ec5c66e9789c655ae068d35088b4073345fe0b03019f3ddb941f0abfa5195a679846217c55a4a9830e73a97d0b93848928378dedb7a416f875525e6f16b2587abda624d4f00000000ab51b2ba4dca27658e13fea81c0764167c1466aa2d92050c67e4490ce7623da0000020ab51b2ba4dca27658e13fea81c0764167c1466aa2d92050c67e4490ce7623da02042b5315bf35d6f493d885fd156c7a9200cdf5e1aa08b27a035bdcd8058f0fb6401c7aca57d5af87880188266cc82fb2e0306d1af200000000000a763a43cfb4e1ffbc40f0001fc0001949300f769eb159cd4004c2546a757e50efced82fa88d7682f324019f53145cfdee3eb63d2dcdc151a5f6ab2334b22379811352d9988876a6e586d975e7329308072ac9a55d1cf5bf9c4262d49e2ef1ffcd716b8983ffdc62b940fec6cb4179d6275f8b68316f29c6c2ad540db32925800000000ab60639a6f7bb2c6c67fa5a65060fa94d3edc1868e8dd16457945f35caee57a9000020ab60639a6f7bb2c6c67fa5a65060fa94d3edc1868e8dd16457945f35caee57a9206a135dfa33b83c7d1afddef6dcfae0a0ff5e6c7cf6cc8f1d07451e251b0d4d8a00766e47227b7aed504a1ef568f67b059d07b67a53000000000012ed802efb4e1ffc000656800001fc000bd4aa007ad999d1a421e1d109569aeb5969d30283e68ce47ad999d1a421e1d109569aeb5969d30283e68ce41ec5c66e9789c655ae068d35088b4073345fe0b030125e7412707146bae96346cdcf3f7ed773646e5547ba57e318078051893e45b0e88ad1a6ae0fcdd89a93bc009e22075a00000000ac5b22cc7947409cd806908ac78a0a600fc6cac2a9a2eeb4a77d8915933696f1000020ac5b22cc7947409cd806908ac78a0a600fc6cac2a9a2eeb4a77d8915933696f120c7ee263d7818e4d18c578e2be6e4858c9631d303131205f9f3a43a6a4df16eeb0020a0d68a349226cc5ff472d2d6ed5cd288856ed5000000000036c81f99fb4e1ffc000bb3b40001fc000bcbaa00abee7c29b0755392bbe29c42ae94823da8025876abee7c29b0755392bbe29c42ae94823da80258761ec5c66e9789c655ae068d35088b4073345fe0b030081d223cb560a023f279a41df68f22478636932932c5e8ea6fbe56b534d4c09603587bbdd2f68a8d6e4f36838030483000000000accd3915d6756cd44d0334a6f753082cd62e723408f02c52ecd7b74280cd3fbd000020accd3915d6756cd44d0334a6f753082cd62e723408f02c52ecd7b74280cd3fbd202b9cfba78ebe0e26d1318e56bdcc2f26a896a166cb7479088558a550ebc86ab400ba7dcabb1a39ea0e8d19419f6b249eadd48352a200000000010000000000000000000000000000000000fc0004bea80001fc0004c8e50154e91ab69c8979d6f2b5f476f666dd09a07f099c54e91ab69c8979d6f2b5f476f666dd09a07f099cba7dcabb1a39ea0e8d19419f6b249eadd48352a23000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aceff858918e60e1afb3f7418dfac7b05ebe4f5402687a7b31ad0c1f70c615e1000020aceff858918e60e1afb3f7418dfac7b05ebe4f5402687a7b31ad0c1f70c615e12042fa8da0fee62ef58885385a220ba2b8ba2d7a88eadd23137b03c8a3c9c1a92d0025b9f391c4357fd53d01c5e83916a18ad24868be000000000023a36314fb4e1ffc0006567a0001fc000bd9b4002d499b03a1f4cf6ccf3491629430440c885a399d2d499b03a1f4cf6ccf3491629430440c885a399d1ec5c66e9789c655ae068d35088b4073345fe0b0300fb1e1939b4b6e7da5bc51c8ac931736cf02e21b96c8a57e6db35e62c702745d7a838cfb50a87d1acec4a52f6b8a893100000000ad9ae35caf7548cf3df6343dede0e585702eb5cf80306e76b65db2c603baa0ac000020ad9ae35caf7548cf3df6343dede0e585702eb5cf80306e76b65db2c603baa0ac20de3daf0213196f7d5138276d9a81318e2a6f2ff27781089cafc3d3817d8f211800c45bbf7b65fec374b69de7b5585a301558adacda00000000010000000000000000000000000000000000fc0004bea80001fc0004c8e5018a366a03dfaa43d112376f878b171f8df72896008a366a03dfaa43d112376f878b171f8df7289600c45bbf7b65fec374b69de7b5585a301558adacda3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ae6f0501ba42aa004525f41ffb59ca39f85170e69a241b69cc493118ab745b31000020ae6f0501ba42aa004525f41ffb59ca39f85170e69a241b69cc493118ab745b3120790e6b01db05c42af47508ae009a24e8e0ae633aaaac9afaac23580d0b3e744e002a3b1c1fca3044d3a94b0b264c7ce60e0df75347000000000023a5bb26fb4e1ffc000bb3b40001fc000bc7b3005721268dd22359aae9210eb45596b00ba85de9ca5721268dd22359aae9210eb45596b00ba85de9ca1ec5c66e9789c655ae068d35088b4073345fe0b0308e9a07b8e11d3941637f74c58e60a917e0ae9327bfde9f2b9f1586b52416f4abce50e2c577ff1bdfc0a5d59e094be47b00000000aea2c0ad3c65b374731f81c1c3b9d08ada064798f788cd8346315eab076f6057000020aea2c0ad3c65b374731f81c1c3b9d08ada064798f788cd8346315eab076f6057209bf6470c04b9f1bcbf9c3cb2ff4d5b633101fbb5352f2aded8df1cde62867bea01066c33e3367b1047bdbad8fdcfb3fcd8daa62046000000000074cb570cfb4e1ffc00044c040001fc0004c92c00a17349d2777d28f0cc7d39fda9cace46c23036a0a17349d2777d28f0cc7d39fda9cace46c23036a0066c33e3367b1047bdbad8fdcfb3fcd8daa620463095234e6e7d476318b4811f1daaa7e887fad24b1499b3472a3a7decdd88e8bdd14551b7b67b22ab896adb298600aee96f00000000aedce7a4ed26b9f1975d071c46d6b8792c96e618215b1e3086da5d94543f2ad6000020aedce7a4ed26b9f1975d071c46d6b8792c96e618215b1e3086da5d94543f2ad620a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e0c1b9fe116e4b5263c75a13b5a3b078c30c9a2a6ac000000000012eda5f2fb4e1ffc000ccadd000000996eefc4c3da0c2c59fceec99aac79122c44d632996eefc4c3da0c2c59fceec99aac79122c44d63264f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730007b1f3f16835ebfba6f505f43c6de757bb22ecf27a89703e90e43aedafea3df353a5bd1915b27e8db397d53f0a23f6000000000aee65248d2955c6954334ada761dd15cb67a58f919e13a41f45d2cb19a35ad26000020aee65248d2955c6954334ada761dd15cb67a58f919e13a41f45d2cb19a35ad262008ac0860ca2a3ddf7ffd7568e37bf192ef8bc83345d12510300fb2cf0150400a015c768ab3ddc84e3d35cb1e9e7daf17a359379a2c000000000036bbef0dfb4e1ffc000bb3b40001fc000bce2b006448d9ce86668d353b6cdef19b1c6523e42f08d46448d9ce86668d353b6cdef19b1c6523e42f08d41ec5c66e9789c655ae068d35088b4073345fe0b03010f6ffb8deec0cbaec7f1284b6cca9c1a46dbb59133c32d58d79490488fce662a9e54d2e9256f394b167ff12b15fb82700000000af33ec874b37177f0ff404564837ad74930b21eca87727b27c2494cf76f580bb000020af33ec874b37177f0ff404564837ad74930b21eca87727b27c2494cf76f580bb20568ac2cbf4c913be67e97440d1666ae9f284a195eaaeb5d6cc088f02c6a40fd8015c6ed0d12929502d6632482c6dc079b38ed1096e000000000034182d1ffb4e1ffc000b9ba201fc000ba67d01fc000bd4aa00c637ae108ab48b62a5c6353f8fdae3578e63e6d3c637ae108ab48b62a5c6353f8fdae3578e63e6d31ec5c66e9789c655ae068d35088b4073345fe0b03018fd8f5cb1579c5a3358126df2a4c0670029ecf97ec95ab2e41e3786bfa9b2c7da308953cb1ea3aebf42910ffbd00f5a00000000af39e406e48c5fac9cd44da1a84541e74f968766bf403718854f8ad2c4f3a1fe000020af39e406e48c5fac9cd44da1a84541e74f968766bf403718854f8ad2c4f3a1fe2035095f3703e5379b03644ff25063c3fc1433144657864d06904b8c4c81235ab8001980cf5e5a4b2e6008ca1f834e297a1a550bb6e7000000000022d111c9fb4e1ffc000bb3b40001fc000bc79c00d3735099e625828d21cd2495e700d8e5fc696bc0d3735099e625828d21cd2495e700d8e5fc696bc01ec5c66e9789c655ae068d35088b4073345fe0b03090680ace6a8f09953a47344b83911d1a1b2c8628d4c712589a9814a04272b70842c9c7cacd1ff5cb19c97e88c67ebec500000000af879b5cbf2bfc94e1a2af602159930146caf7a91e7d9bb08272b82be03137ac000020af879b5cbf2bfc94e1a2af602159930146caf7a91e7d9bb08272b82be03137ac20ac3731e02bb87282b09b7d1ea9f7ca460193592160afa2e194fc2bbf5c9b87af01e31328e1bc246922c2954f8e93562c1e96b9b8ac0000000000ae22e974fb4e1ffc000cf13b0001fc000cf6cb0020c3d21ea834c65e7584f4d3a9270c70297f04d9ce7f101b7f075273c892063b1b8571311737a5767f95c0f808aff27883260bfaf9cfe2b84519a6b230932f6fc90c9dcaacdf9d836a2a7e60d090fe5e55b0b02f5a4f608a4b8235ba5aa7abc4e05f9387d1d942adc57c87f5b700000000b00179bd307619645399361abddcb07287ecd406301fdf405d9a82c8e333aa03000020b00179bd307619645399361abddcb07287ecd406301fdf405d9a82c8e333aa032060c6085ff3174d7f715fe6160822a1ec9a5182e6a6fa7603cdf6759db9726ad90116cb1e8f2ee25a6e24d3bdf0ec74b68635e822410000000000c38d8f31fb4e1ffc00010db90001fc0001854c00307e6b1e1ebb35dc358870ed74feb6563617e40d307e6b1e1ebb35dc358870ed74feb6563617e40dc7bb875d7fd38c672ce10427e7e172735c827f0330878386a8d07cf79e1dc6963d4cdcd7a4af6ef7e350cad3e1373e45fb86fdd9390a77366ccffda6ebe1470c45b0f7591000000000b00c8c773b22a9aa8364340a901a7538459ee38c7a68926e3996be85f6cc0d25000020b00c8c773b22a9aa8364340a901a7538459ee38c7a68926e3996be85f6cc0d252022c561566ca492327efaee43f294f42c95f87499c302dbdeeaf0bfe29ee2d0b00179fef4f73db8737c12eb3b5cbd44882d442c80170000000000ae22e96efb4e1ffc000cf03e01fc000cf12b01fc000cf6cb00d47c40c18e5a783a9277314480c9c0512a8fe825ce7f101b7f075273c892063b1b8571311737a5767f95c0f808aff27883260bfaf9cfe2b84519a6b230926eed90600b93cd05453899e96db8dfa36d2c71c3209e1660738c6b3af11473b5169c8f8dfacd89ad1bc92a481978f700000000b037d52073d1e445bc2fd41e35be1c52426e00152e49ffa55b6fc20f33b28483000020b037d52073d1e445bc2fd41e35be1c52426e00152e49ffa55b6fc20f33b28483208384b2330fc26f5ba5ff492e15006e42521cbe351ed42fbc45e4d17320d537b0014e6de0e472aa530261d5fbd3801d6d777aa7338e00000000010000000000000000000000000000000000fc0001e7020001fc0001e7100052254c6cd12c657c27876bc3c0a7b82aef45305fbf9ef9d3fee586e471698a3f70eaff9dcc96ba84a58bd603afbd1d6198ee831cefe1380b073a24d53009a5e37e3b9e556a7d7fe7cda1b54682351d4d1f6ecd331d98816db0696a5389c4a09bfc57f66f0a27120302ceadb07800000000b0447996025ff084c1fa1e0fc755b32d540143fed28b89791789fde2464f9f2e000020b0447996025ff084c1fa1e0fc755b32d540143fed28b89791789fde2464f9f2e20502fdd2e5de1a8c6ba9b4bfcbd14bb30743353814ee50e33f80c2e063a4ec6ef0045cf243bace96dcc31b4311405a12153630969330000000000235868cffb4e1ffc000bb3b40001fc000bc78300692790b0e670372748d3029fce2bdeb14816c27e692790b0e670372748d3029fce2bdeb14816c27e1ec5c66e9789c655ae068d35088b4073345fe0b03019f2c10770cebad591eefa4fa1e71d2baa7213f7bfea0d7cf6fc9313df3a6095f480b7eedb63ce8aabe16dfb418a9f0000000000b09c47d39537078986e4639420ce87b32039b17d80ff4eb88238c27fcfa1abd3000020b09c47d39537078986e4639420ce87b32039b17d80ff4eb88238c27fcfa1abd32040b9e1633d6a6c0a38ef14d5590c5cba47ea35c13fcdb2b1b86d08f2297a9a0400d8a0974e7667d17dd9a12a9fcfb313a13c918ce7000000000023a97188fb4e1ffc0002198f0001fc0002fd2400c7ddc0f64cab219e4119020d7a9c0ffea17b9ed0dc7ad6d9a56d9e5370352a41c4b9b55601009064253cae727106faa4bf76b0b4f8375091889f6715301848a0024f4a1b85e18552105a7d397714bb9d16a392a29b5d6d18bba91fc880a6b20be09f1400dfe58de3ea87f919ba00000000b0aee43d5964ae06a7ce63c03332d9f1af46386b91738cbbfdf42f67db488c5f000020b0aee43d5964ae06a7ce63c03332d9f1af46386b91738cbbfdf42f67db488c5f2046674ef4c6ad3a94ca837fdda85dcacd4e685f2722cd1b33c26505a95faad46e00976899eaa0087e8b7daf0d688fdaaf2197da58c4000000000022e99becfb4e1ffc000384320001fc000608030014cc95cebcd011e38ee7a83fb6ea445ff8ed0550177f797c6205c1997ff1ffaaf6aac98c13d865ddf32bb66d6fdcd07b1268d21a3e021c9c954452933090ea99287802a44836309be934ed63933b423580626adeb428026acde6bdb283f370ff19bb37f81b0e4775187ad006a300000000b0f7021cd2662eb74b1802ba34fef476d176e815569aadd4931bd4288f5256a8000020b0f7021cd2662eb74b1802ba34fef476d176e815569aadd4931bd4288f5256a8201b6c893a523e3fc81e071e645926300e1a37d71f02e1bbc3aaf75ee1961bb56700a445f904cfb88572a605f98fe2826aacf9bcf268000000000022d91746fb4e1ffc0006567a01fc0006c05c01fc000bdc0b001a238d7bcdd356d52831c991b56beb9a50a986541a238d7bcdd356d52831c991b56beb9a50a986541ec5c66e9789c655ae068d35088b4073345fe0b0309247cd1a65f03a854cf5c9d7ef6c606d5a8789ddcfa7e2f04ec03d6c93b365a01d2f302f1c93aff66f33d55fddc721ed00000000b149c50e97a1411b76b2e26ca20b9a6a317d0afe19df2b78b967f0b94aef1f38000020b149c50e97a1411b76b2e26ca20b9a6a317d0afe19df2b78b967f0b94aef1f3820595c1fb1f5d3ec30b832c9c3cd68e19b4dc85334d0dbf734671e3c38844c8513011fdcb249be6d1f0896ffd3c5965cac5f087864d0412000000034235351fb4e1ffc0001991e01fc0001fa4501fc00038bec002adba90fd804d6d89438ea6729608d5276687fbc2adba90fd804d6d89438ea6729608d5276687fbc44fdc27a48f627d31adb54f482d59e535c226de0308f60f80538f335ba0f9f5452f02d7f5527652671da80c3d1c10e31e040f9b901a53b476a9ce02b507958bc8a65acd7b0018b3277a4f4a3667225def8a4f83000c086719cd9000000b1b3f7b8e4ae179563fc3cf3bf51148644cf9e38256a06d73d31050ebaf486e4000020b1b3f7b8e4ae179563fc3cf3bf51148644cf9e38256a06d73d31050ebaf486e420945e0ef94323e11ae3c6348c22d0106e35d724c00bc81c70956bd98d42a46074009b3193d314bfd2e375084a1d45eb689ccad9c2dc00000000006ca0877ffb4e1ffc0006fcd40001fc00070ca3002986dbc41a156ebc9c49fdf1d1842a76f21044b7c61ae923d66d3e7a9a82b85fe5eb375e966b109103650c94f0e6f7a84dac1089fd0f6dac2aa7b4ea300d7a075032c423dfd82adaba63256db7c7a0ab10eecc99544fd628e76840759ce5fc0f27ad83197f464371a1b353095200000000b1d373e438cf455c8297ff3d8fd1b27a1be7365dc55bdc963d0c02930338a519000020b1d373e438cf455c8297ff3d8fd1b27a1be7365dc55bdc963d0c02930338a519206a67f98d40507765c2142f4d70d3133a428859b1d4eb7f7c702d82781350b7b8016cfeef7175b7dd90412dc38d3cbb55a5da930fd9000000000034281b0efb4e1ffc000bb3b40001fc000bd23300ae5ae49de2bf939a61037d1ab3c9aac1528a8034ae5ae49de2bf939a61037d1ab3c9aac1528a80341ec5c66e9789c655ae068d35088b4073345fe0b030874adb6d0e5b65105e507f97944c24c90c5120d804ee0f36c7079c7c7c2f86aec079d13392b583e0553b699dcfab799400000000b27a788d5106178e1e365336ba2a53d6f0e4a48b76eab2faf3aac12123473740000020b27a788d5106178e1e365336ba2a53d6f0e4a48b76eab2faf3aac1212347374020a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e3b6b2d6b24f4fb4800563a0c581278ba501dd5b46b0000000000235b8659fb4e1ffc000ccadd0000002d0ac80af443e477060c785066014d561253d22d2d0ac80af443e477060c785066014d561253d22d64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73000eb80b32b60db5d7b03559f6e9205beac8d047689904bdda0bc50987d5f208d39b78ed90a34af7e1e9d44495ca1eb4200000000b2f62d6812c31f4f46265267da924e38395274e12148d979e4b4759035b26072000020b2f62d6812c31f4f46265267da924e38395274e12148d979e4b4759035b2607220a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e06083c6d6b80dea08171cdbe3134fa90e5dc9711c1000000000022de5512fb4e1ffc000ccadd0001fc0010df0300a3efa844b6dc22d05e802ebd5d1eb02cca122c25a3efa844b6dc22d05e802ebd5d1eb02cca122c2564f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730075b907b6d6c12aa111da0e102186b9d06f4e065969b60732207f18c2c5d0deb8ecba47cb4c0929647db0e2fae6f08ca00000000b3004b53adce8cdf983830857449bb18787178023971a621d988d360b703e529000020b3004b53adce8cdf983830857449bb18787178023971a621d988d360b703e529204dea6406996a98efea88a66bddbe7f9568093185b08c865b1b664ae0e594c7be010eac161c360c57015ce83107d781b9ed935d3edf000000000008090a0bfb4e1ffc000cf63501fc000cf87a01fc000cf893008a69e5fe65c9a67e214d84a116b441abd5f9aad38a69e5fe65c9a67e214d84a116b441abd5f9aad3c69a0bda7daaae481be8def95e5f347a1d00a4b4308fed7a63ded7f5de0bfee9808589940f1148f47656d017a1fa77642352b5348ee318af4ac3fd63fff3b4e5c55ac1624b00000000b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f000120b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1689fa69f20934cc3ede9dff4589af59c19a14a3f70000000000342b0d5cfb4e1ffc000cf99e000000d57dc73bca0753cbd47bb33f68362ac13e6daeadd57dc73bca0753cbd47bb33f68362ac13e6daeadc69a0bda7daaae481be8def95e5f347a1d00a4b430816ab3f50007333bcb40445130cd0e82139f8c68b592001cd686efc15e303206491fada6cf90af8f24a28b81a9b59ccf000141b308f737ca9e39f67b553158903198a88c516e01fb8f3001fb05a3b42fd6e07095c8b1c88ac52a22cd97d8ebb051ba7adf401896d8aebf04db1080000020b42fd6e07095c8b1c88ac52a22cd97d8ebb051ba7adf401896d8aebf04db108020a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e71fd01a6dcb1e645d921f8e714b2181c90b94e1a24000000000022dc861efb4e1ffc000ccadd000000b4fb462bdbb65e1dc1380a1d4723220a09f3b4ddb4fb462bdbb65e1dc1380a1d4723220a09f3b4dd64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730088905cc3f99e76b3a1abf714a55978d9930c2abdc77a21bd809e452e8c47c35d38e318ec3118e1944cf1a4a8df907c100000000b43dadbd485e4d1e1d202ea5180f0ad4e8e7f05e97a7e566a764ed714356bd1f000020b43dadbd485e4d1e1d202ea5180f0ad4e8e7f05e97a7e566a764ed714356bd1f205c71e5f46d35196e33b45c5d59d3fd2dc84381942064cae21744fb717412c1ac010f673549b55f956f58bd209f0cda6e0af0d65b2d00000000002f6fb5cffb4e21fc0003c5f80001fc0003c6840099e9dff4cd5a0abc61b5287a0ba48c0553d6358829dcf16f7a66b832d3b84dbab400a1e9eb7f30ac955410003527bf2b360a7a390b9ff14b9106c6323090c0e9ec9dc5f08b1d4d0211920fe5d96a225c555a4ba7dd7f6cb14e271c925f2fc72316a01282973f9ad9cf1e39e03800000000b4ba4ab73c3757ba9cc6b6fb98020b854228be7de4704ceb7da02e7c6a2ad741000020b4ba4ab73c3757ba9cc6b6fb98020b854228be7de4704ceb7da02e7c6a2ad74120bdfda6f0bbcffdd7aa32a0b762eb6506cd719d88cf5f272d1ced2485a6bcc9ca0149ffc6acbf7ea405fb117bfaea252f885c6b6ba300000000010000000000000000000000000000000000fc0001b1ab01fc0001b1b001fc00021efc0064cf453213924a7f394eb5ff3be693174b8d0d983db6e109e8d2e2f052216a47568b8881f7df245bd8acf473f417dbb62954adab796af04a646847b13000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b4ef45b7d0b716ffa761809326697a6420365e1d137b52d7d275e7f326280ac1000020b4ef45b7d0b716ffa761809326697a6420365e1d137b52d7d275e7f326280ac1201eda6d2f8839ac6331393c4c9e2c97ab17fbd99ee5bf9f02b3ab288d60aeed4101c829eedbb02f90bd3a33dcbd225256ac75e2298c412000000050d1e860fb4e1ffc0007d1da00000064cb3ef38948917a58eca6dcaf03c4d94a3219011546085b56803db4366c2059d4755c8a28796ca30d5bcbeeb459af40f97fcb4a98e9d1ed13e904c8300450dbbbe82df6808151b83a46f8c531cb240eccfe65f8f0b49f3717056da7268c14e45f0dd14fff8daed28fd353c1b401c623e2d926af5eb52dcc2b931993d3e527145118000000b4f9de65ae676b63f84f2865317b8b512a12516c4459f2f59ca2626c71f7dda3000020b4f9de65ae676b63f84f2865317b8b512a12516c4459f2f59ca2626c71f7dda320a3ddf7716c62a29cf5f259446c51122a518b7b3165284ff8636b67ae65def9b401f9a85a965fd3f6ea024aa1af9af585b3993c2882000000000001010101fb4e1ffbed7c0001fbedb2002e57d3d0f052b955f247a5c1d4a41266cf5bd93c6960122148b84c5f044a812c35d5380281a0f02e88a052d5925781c116dff6be4f04739113c0f9a430016a16472319f62f71bb60e38038aa8cb93a301ff6c3727f75f4d770428d71d032fdbd27c5d03dc56ef1d658fefe795400000000b55a74503e30b3f3066ef0d94ddce16cc7f87831a4b782764b588e5575382a88000020b55a74503e30b3f3066ef0d94ddce16cc7f87831a4b782764b588e5575382a88200b18bab21b495a6bd4d872e3fa0f87e5ec27effa90d3c58cca27843d9d96da4f010f4af69185db513ed69f7538a80cdf50cbf6ce2f0000000000235902aefb4e1ffc000bb3b40001fc000bce4300b6bc771fdb7d72115152872d2809ff854a16c4cab6bc771fdb7d72115152872d2809ff854a16c4ca1ec5c66e9789c655ae068d35088b4073345fe0b0309489f888b6bb2b9aea1dc7580c45a7e38d3d3f197ab688c48962ef102588017558d6bc1ad8bec667892b2436e64ba50f00000000b5706630cf1c631b5f95edf39d0fa1fcdaba9d34459b0b392e3f28eb59ae90f6000020b5706630cf1c631b5f95edf39d0fa1fcdaba9d34459b0b392e3f28eb59ae90f620f690ae59eb283f2e390b9b45349dbadafca10f9df3ed955f1b631ccf306670b5016c87be22108a3287243c4bfd060433101cff516f00000000009de6137ffb4e1ffb602001fb626c01fc0001195600d157ab8fe5436f4c7a475be8a35079b3aca6c5fbd157ab8fe5436f4c7a475be8a35079b3aca6c5fb6d4c795644ca86f717628ea27f0af13b0ea70eb730874b17058e37c39f770188dfe8e699959654d723e62e28b2760900e5284f63f6b70e077a6ea9803714bdf62d083b1d9e00000000b5c0d248eac5f19d665159412f357073359d0d643930adee1d071f02e9ad0a1f000020b5c0d248eac5f19d665159412f357073359d0d643930adee1d071f02e9ad0a1f201f0aade9021f071deead3039640d9d357370352f415951669df1c5ea48d2c0b501ab386459f5642306e5993f9f7584fb744de7076300000000010000000000000000000000000000000000fc00025b7301fc00025b7d01fc00026ef0008923f5540c3cde8ff5f57178422303c469510c488923f5540c3cde8ff5f57178422303c469510c484deccc4867afa6d1f8e500e66da4f136e46638b83000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b5d5c145d244a98b81cc9b5fa2f841cb6689e7cab76566fdc66ba16a82db95a5000020b5d5c145d244a98b81cc9b5fa2f841cb6689e7cab76566fdc66ba16a82db95a520dd55abceed2198b21aa5486f47bd0715607d41c79b75aa3e3ce3091b57b46f020159b77252b432ccfd639e3d1286a82a8700f91a4b0000000000336b0426fb4e1ffc000386690001fc00052bfb002e1496064dd3a7a8c0a5cda78f3b4a4073ffa2392e1496064dd3a7a8c0a5cda78f3b4a4073ffa239a6a050bffabcdf986e775567e1ba53dddf578ca1308f4fed7576bd1e31d45225788c1c96836dbc85b3ece3b77fbe4ede0f5f784f138ef6b32884e3345915a758364d1e582300000000b698b5e762f0d11faa437d55b16ca54722ba8ddb0b3eef0256ff80354f0c8d83000020b698b5e762f0d11faa437d55b16ca54722ba8ddb0b3eef0256ff80354f0c8d8320cb53246d5a57694cf7e19868540214769b2d7fad12f824c47130244873204e8c00a80186b44321096c4c5997ee6358e220bfb3d6ce000000000012c3324efb4e1ffc000d62c20001fc000d62fb0023142164ea1319cf4ad34e8fbd273c5502d5dc352e3252f64967541fc0092b78aac3dfbb7fdfa8d2a90c41d69e6e6132b5433b45a661b5f2187458a130a90febb8c2b031ae7ca222debc10f12fa0a71fcef84e2d92f13c1ad192c42e371324bbb66c86e24434754e2864ba14ce00000000b7c7c32bc7f34cb18da6b4b3fa53d8a6125d6f6dec3f7849e728bc8f89eae495000020b7c7c32bc7f34cb18da6b4b3fa53d8a6125d6f6dec3f7849e728bc8f89eae49520e7365918822860b9120091cdf14e16507de20bb5dcdb6784b16352c2b66ba700008f6273f09406792bb9b717499634ecd4446db449000000000036cb0d93fb4e1ffc000bb3b40001fc000bce5b00563f03e344dc17a7849e6320f56c13b0b5c32cb7563f03e344dc17a7849e6320f56c13b0b5c32cb71ec5c66e9789c655ae068d35088b4073345fe0b030011bc68f6561d4a7d5f7c1e6fe4742d8ce2bfec24576e40c8eaec56b3759bdb5be5e6b9234c77475c74be1b0466ad9e400000000b7f0ada8d395f428a1a72db04b76caa042f7020b2f90641fcd1499be6c37fc9e000020b7f0ada8d395f428a1a72db04b76caa042f7020b2f90641fcd1499be6c37fc9e20a3b41298f1b62474eaf528e96815202beebb6eb5751f0b495a7ea49ec6aa04df0029ab2ca57c2c3d3a756db61eefa71cd784a7533f000000000022d536e7fb4e1ffc000bb3b40001fc000bc7e300538584030db46ef33cafa5765401d48e0b9fe6b9538584030db46ef33cafa5765401d48e0b9fe6b91ec5c66e9789c655ae068d35088b4073345fe0b0301802f2a1951734dff2eaf714cb8de115a8df7bbae8da6a1e1bfc9c0f020908cf68cfb2f5efaa4412fea5116db12b569100000000b9e4c7189d01f8da6eb8bb5f4b8f8c2a0a24293d0f6e900aa0371bc32ec6021d000020b9e4c7189d01f8da6eb8bb5f4b8f8c2a0a24293d0f6e900aa0371bc32ec6021d205ab2eb7a853640b8282676a50464bd24596d3094fbe40afa6d2159a6ea64488500db4c10c95bbf83225e49ec3967653007708d8d8b00000000008b3b5692fb4e1ffc0001167b01fc00011b9701fc00011c1b00fc8511ca8de4f660ed57620e4537737e55622bd9fc8511ca8de4f660ed57620e4537737e55622bd9db4c10c95bbf83225e49ec3967653007708d8d8b3098bae0f71cbb77fff1560f45680ada9492ec4c9f779df777754b54bfb3474729c269399bd3cdfc736866364d3fb011d100000000b9eeb35f00d10ebde45a23db94875bed007b94eb03cd0317ff721e24dd5363c8000020b9eeb35f00d10ebde45a23db94875bed007b94eb03cd0317ff721e24dd5363c820f9ada33272169ea08ff6161000b9fee6eb81785cc491b284a2acbb87738a330f0139387c3d869b645b7700d9e16011681c0971cbf63c23d70a009de62866fb4e1cfc000283a70001fc0002ad4400caf26da61833c492453bc2d74c6dce3d91e2c38fda5ea047322750daebfc463a87ec042108d63ce9d458f5157d91f4832e66eb8630ab3dbff95551d8308f420a082c56b30c9bd8492394d83066a8d03628a7c8e3eac27486377e2648bdb3cebcc4fdd16cb4cab1341e480fa43900000000b9fab136129b05d86ccfeee5298f207ab2d76131af41987baccf55fea5efb4c1000020b9fab136129b05d86ccfeee5298f207ab2d76131af41987baccf55fea5efb4c120a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e2542293a57d22c1f9064bb876ef27b3f4a9e5824f5000000000023a21274fb4e1ffc000ccadd000000289d0729f182f703f2df4990b51e2b103515a32b289d0729f182f703f2df4990b51e2b103515a32b64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300fa5377eb256323aace31b45c3e48ea110404b053cb80e8043bd1e44de1705130548e4ab28738816251ea57a7fc1032400000000ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216000120ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421620593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1488164ceb25e5c05e3192511d2be4a5ac103cc5f70000000000342aca80fb4e1ffc000cf99e000000ca94dd35b74cb251457e475dd7507055eaf1b4e1ca94dd35b74cb251457e475dd7507055eaf1b4e1c69a0bda7daaae481be8def95e5f347a1d00a4b430acec7bbead86221590f132810b8262cf98c91b338927907b86bf48baa54dd1912bfc1f6fccd069052cc8c79eb9e8ed2c000162e0104ce0aafc1f06bde37c73702fe84b307f0501fb8f3001fb05a3bac184b9f1e4eb098d1f8df0b07af6af8919c60c1f60e31ba29c2f39f395ff22000020bac184b9f1e4eb098d1f8df0b07af6af8919c60c1f60e31ba29c2f39f395ff22207186875d6669311c046bc6052538390054e2cebd21b2eaa908af5a273602fe1a00d97799fa72f75b2cab264f40eae80856f27f6f10000000000003dd1d17fb4e1ffc00021c2901fc00021c3c01fc0002712c003da6a63a5f595ab15da44601749453c0ac0b8b7d5519b11029baf89428cad6fd4e70e3bb09f356f1d97799fa72f75b2cab264f40eae80856f27f6f10308bf25d66d63197e3144f6fa17ad92ae38cc11b143027fb91dcf5c20fde6e52bde7f46f2789e6fa84573197d8085389dd00000000bad4dcdc0ec1f274f70f87a3f4509096e7ba517adef56a4121a20f665d5e8e7c000020bad4dcdc0ec1f274f70f87a3f4509096e7ba517adef56a4121a20f665d5e8e7c2076a391457a0942b72645223669feb8e22db6e8ec7d9056eb5149f5689cc3e0c40054a71d0e91f24c449a09b22c0f77e6540261a5500000000000235ae333fb4e1ffc000bb3b40001fc000bc7b300a14dca43f5ef41a8a4340a62787f0901e54e8adfa14dca43f5ef41a8a4340a62787f0901e54e8adf1ec5c66e9789c655ae068d35088b4073345fe0b030848001b4004d5e5eb6782bcf3a3b62c2d14f237af0be67c10d70d84be1a28142bd5edcf4d90de08af31f8381510ff61600000000bb889ccdc43531f927eee1dbf095a5367ea314eb44818be2277476617af7d35a000020bb889ccdc43531f927eee1dbf095a5367ea314eb44818be2277476617af7d35a205ad3f77a61767427e28b8144eb14a37e36a595f0dbe1ee27f93135c4cd9c88bb0176e71a262cca9f6667bd35b19f182ba67b44c9cb000000000059280381fb4e1ffc001094df00000059ba7af9e92023a6b1160a0a45aad2dec70e7cd703815c232820445f311d1192f578077c1cdd3b540d5bcbeeb459af40f97fcb4a98e9d1ed13e904c830b529e500f236ee90a3e7c274dd51ad91310561f10d066560b0f28922634fbf67f50660e317f3f4c06441fa5ca98775d900000000bba99873df74a78b6fd5150907b216eafe16816006225a4912affea3ffb41e00000020bba99873df74a78b6fd5150907b216eafe16816006225a4912affea3ffb41e00207b744d5c91d46c013969caef13e72e56c6ae7bc89588edee53cf4ceb6973a2f50120120c7dfc6f165a4f2c104d6febd11c496069c000000000006b16c782fb4e1ffc000607dc0001fc00062e430047c6566a13ba6a7f8c6a3cb8872664c2f8f4ee27dd3b064ca33829ca65c37e911259da50d3490ef3b508db53f0a3f072b00f579a86e813d6af2856f3301059c4fdcdc32d831534403f7e6587555d74dc1624f6e2bcdba10a099e6c4f8d5f31d4c270231180ded264a009387e6c00000000bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8000120bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb820593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c060d8235767cb55972a30d653eb9dd10f51b3c46ec0000000000235231c4fb4e1ffc000cf99e000000f9b93e179a0c22afd92523427341b5e0b2c2a102f9b93e179a0c22afd92523427341b5e0b2c2a102c69a0bda7daaae481be8def95e5f347a1d00a4b43095c89af86eeacfe403684306c98173c2a59198047a778787887d34ad6b0c9b787d689a7c3cd9e9dd5d103cba70f3855f0001dbbebbc52a5bae21b818e0487311041c91b2683b01fb8f3001fb05a3bc77a5a2cec455c79fb92fb683dbd87a2a92b663c9a46d0c50d11889b4aeb121000020bc77a5a2cec455c79fb92fb683dbd87a2a92b663c9a46d0c50d11889b4aeb12120a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e5fd2b74b9987e80fcdd3aebe95721c6c4709724ee6000000000036d55ed8fb4e1ffc000ccadd0000002878a638db0682d49249ff8ca872f16653a84f912878a638db0682d49249ff8ca872f16653a84f9164f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730174de56654f2bb6417e15ff06361ea0becc00bd72a3eba0f83b60feac860570769fbf28482a706f10906a1e96dae4a8f00000000bc9479593e38ab280b75dc76bb4d10483b1b341c2e792d7dd278c21d202d2b93000020bc9479593e38ab280b75dc76bb4d10483b1b341c2e792d7dd278c21d202d2b9320e9d3abf500bd0cba0f374490d4e0b3adf1dcd865da1ab04e8bef255e4a24ff630041796bb0563ff119ced9d76be68c0d5898bad86e000000000036da55d2fb4e1ffc000bb3b40001fc000bc7b300422b11d7511cab020721d07fa2d011bb1b7ae433422b11d7511cab020721d07fa2d011bb1b7ae4331ec5c66e9789c655ae068d35088b4073345fe0b0308f6e3e0e34f5afcbf9eb7077a3f0e5ddbc2902f5610447b9bbf871fd0065c8f156b514bc5180d579bad722d6112f1a3800000000bdd08cc998cc494d2e008405bd71d5917a64adde6216339d74be4d379c90ff19000020bdd08cc998cc494d2e008405bd71d5917a64adde6216339d74be4d379c90ff1920d5b7bf68c3d573cb8c592b4fca527b753ada034710ae8b5eeec83c426ab00dec01673a5871f70c41403b9fcbdcb7a7e2b734f3cf130000000000951ccbbefb4e1ffc0006592e01fc00065b0801fc00065e350047d2c552db05fdbee9a78f346a8bfbdfbbeaa5a068eb72f005d366e18db38f638716d97bf60d53c7673a5871f70c41403b9fcbdcb7a7e2b734f3cf133003d325fdc665db2900c24c0736b927b7fa7ba7068c9595991e6cfaaa0f8e1269a31f6d1da2b85fd922186a9979872cff00000000be563f5793f34f16e6653efd9060c4042b492cbf676cdc66f9d68836f078b71f000020be563f5793f34f16e6653efd9060c4042b492cbf676cdc66f9d68836f078b71f206a0871d1bd82667b5df31b0c09861a71061f9fb1f0df3c2a8ad0aa11710100410109c927a4a7a41ffdd8cfe3f780f5108a6ffa1c514248000000c3c925fffb4e1ffc00062ecd0001fc00062f6300c5775227677d9c67fb4c13795a2bf9d80ea231c9304c46d5f01a600ba66e3dbbd8bf6dc23e8c5297aabc8c5bbac24daa81a5f2425983dde53230cc203093612d652fabcdc0052e5bde98d276e49ea71d050a323b98c368a06742fd964d21f567e16fbda2c17b00adc470f6f61400000000be89ade2107051d4f50cbf1d99338d42b33fa7efb079e14d906ed9b518768d36000020be89ade2107051d4f50cbf1d99338d42b33fa7efb079e14d906ed9b518768d3620f2cacab8a192994c64ca14bf7a9d1c045a8234e615dcc6764219af3b0705adc000e6996e06f219509dce93957d76e2fde11a5958380000000000341bc6f6fb4e1ffc0006568001fc000a68af01fc000bd4aa004d0684329ab95dd4ee2c0d275ef313bc0e0adaa24d0684329ab95dd4ee2c0d275ef313bc0e0adaa21ec5c66e9789c655ae068d35088b4073345fe0b03016c6904fbceb7584e75ef553b85ca20ec8cbcb1ac49d985b0cb77760107753205415c4d5cffe3be0a10219d0dea98e2200000000be8d0533c692cf23e3d3eeb3957422b5a98acd82aadbf7baef255edb2f491b82000020be8d0533c692cf23e3d3eeb3957422b5a98acd82aadbf7baef255edb2f491b8220821b492fdb5e25efbaf7dbaa82cd8aa9b5227495b3eed3e323cf92c633058dbe01c428ff31ec6308043a7b282eed63d1d8920c2d8300000000010000000000000000000000000000000000fc000293b401fc000293b801fc0002b6e70091b4363730ea1c02de53aaade78508ee41c38f9c91b4363730ea1c02de53aaade78508ee41c38f9cc4097f46f9eb0990bc7e22d3bb29af6eb76d94d03000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c08b723b79a7139fa7097bb85b4d0dc387097cf2ea66ad34992b60e1fdb5df1e000020c08b723b79a7139fa7097bb85b4d0dc387097cf2ea66ad34992b60e1fdb5df1e20c0785da69e10c38185460b8c938566484f113a1bd42feed2e03b8a76567f6b820024ecdc76f0781a35a9a47762313f63c5e21ac0fc000000000022dd41a3fb4e1ffc000bb3b40001fc000bc78300a7afe89589507a716dfcd88009d108734edddeb7a7afe89589507a716dfcd88009d108734edddeb71ec5c66e9789c655ae068d35088b4073345fe0b030169fd77b3f11dd8f82c03ed8b79c1d986fa1445e6f726b0c1b556bb884c83890339733b2521630b8ae57c1428d0ba12c00000000c0aae8ab24aab988cc84385d16af7ffcfd365d0e016f5799759e0525a435a617000020c0aae8ab24aab988cc84385d16af7ffcfd365d0e016f5799759e0525a435a61720a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e355f1d75bff42c098ef3598a9a5fdf2aefd216ef66000000000036be3d46fb4e1ffc000ccadd000000ec74aec7dcccccfaec4c5fe65166a2d5ce0e3268ec74aec7dcccccfaec4c5fe65166a2d5ce0e326864f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730892a3de6fe305d39d81ecc9dbc7c85bc6eb57434618903f45ac8996aecfa9a7945e2cc48c40c1540172096229780519e00000000c0dc1876eca746f08e401c7873260e277baf0096a0b19e519e6298b649dd23bb000020c0dc1876eca746f08e401c7873260e277baf0096a0b19e519e6298b649dd23bb2025ab3aaf757e9002b95d75ddc9f2ff18ae237e53a8e10a93dc47fc163bc91d120128c20f725ddcc44c5d6c728b05b886805ca125af0000000000b280576ffb4e1ffbc9de0001fc0001196300febd730bedac1010a2943dff1c796cc544609f7cfebd730bedac1010a2943dff1c796cc544609f7c477a52436b944f3e9223ac8404a7717d4176fa533003f959fdcb3eefebe409ee7044748f71ec8cba18a7a73df9d55d118e170d7ec2540d5c08a4cadc4bdeff3f7886265ac100000000c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8000120c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba820593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c040cb28bcdc1d1a970b6255a04138f84c0ebfa52b6000000000036d5cc55fb4e1ffc000cf99e000000ec040cc1866da3e55c8ae6c0f739cafabe3f5cbaec040cc1866da3e55c8ae6c0f739cafabe3f5cbac69a0bda7daaae481be8def95e5f347a1d00a4b430aa910b9552857a7712d54b468dfcbb7d9e27f26a49e06fb1f0fb00dd0f5a1bf926863c25ad03fd49c56b62065ecd06e70001fdae7cdf38811659ce9481975b326a5d07236bc501fb8f3001fb05a3c1df04cbbc1c77ae3157c4d6b50eac093068c1acccccd1f6206fc6bb892e8bc8000020c1df04cbbc1c77ae3157c4d6b50eac093068c1acccccd1f6206fc6bb892e8bc82015bbe1f1af1bc27cff5a355b82d0c0aaaa5bb19a634fae26671416b39c92630f007a36078fcf52a03235ec5b11dcf012eb7beb356f000000000022da4cb3fb4e1ffc0006568001fc000b9be201fc000bd4aa000eaa20f14a3447fe10315f6891d24da0e44ac1940eaa20f14a3447fe10315f6891d24da0e44ac1941ec5c66e9789c655ae068d35088b4073345fe0b030181387e11f86685b42d5030cf61959e3005d1c328556c83637e4a0acaeb62046847d6260c968ab433c9c6c946d170ef800000000c226d6e2c423eee0bf233ec020c8012b6ccfc1bd5430a02c55613eede35e9107000020c226d6e2c423eee0bf233ec020c8012b6ccfc1bd5430a02c55613eede35e910720bfcb8e882baba43c6975d87daca9b5223c9f8e6ca0ac9e2965c06ead3d89a08200c3063b19c638a44112f5f75c1d066261a497223c000000000022dc8349fb4e1ffc000bb3b40001fc000bce5b0001b9d16bb8176bc52aa900abd93b3613e5e91ca901b9d16bb8176bc52aa900abd93b3613e5e91ca91ec5c66e9789c655ae068d35088b4073345fe0b03017ccfcb2e59e9efd15cd4096192fd937119581523caacb1320afe058b2784b0668e4831bf6e8e79954cd2118d1b0e45700000000c2a54c1ad133acbf3366aba2534ed6c1f01728553a7e877ac2a22c98be085c68000020c2a54c1ad133acbf3366aba2534ed6c1f01728553a7e877ac2a22c98be085c6820bf623c10780b9dcf9e60e181c82b093884f950faeef2c50c9b268342b182b6d301b528aa08346d887417ad542b2dcaba998abb900600000000009de66e56fb4e1ffc00011b610001fc00011d6b0007b48a04d0a73deac14da9df36ca49ffb142339107b48a04d0a73deac14da9df36ca49ffb14233916d4c795644ca86f717628ea27f0af13b0ea70eb73085f01c97f8e6d601ed269d4fd1d33b456c5c940aecc45b084c0f8d9ddac26d6fb7c5cc1eb817a41bca401e5c9c4ff85600000000c321458ad5e9517e64583facbe4ee3d0694ab856377fe216ab2f4bca85cc2f76000020c321458ad5e9517e64583facbe4ee3d0694ab856377fe216ab2f4bca85cc2f7620762fcc85ca4b2fab16e27f3756b84a69d0e34ebeac3f58647e51e9d58a4521c3003e9257ce8103b6a3836bd1e6eb938ea1c04efb480000000000ae22e972fb4e1ffc000cf03e01fc000cf13701fc000cf6cb0044e7c4cde18464d480d28b52fd7d23ffa72d128bce7f101b7f075273c892063b1b8571311737a5767f95c0f808aff27883260bfaf9cfe2b84519a6b23017a49cea05ca2e18f74af110c5ab52c89a43ced4e056a8af7ca8973401494bdaba26d1c56b46b018091d0dd64f24475000000000c36584a1242574644c1a1620703c55200cc0158de276dc388ffa9815ec328c31000020c36584a1242574644c1a1620703c55200cc0158de276dc388ffa9815ec328c3120c6db6a114efbdf794abc8a68954f6005393aa508ff4ba392eb913aca117c8509016dcc6dfbd52edfa0d3cb1b5d503c5c7b00f05d83412000000023a3e220fb4e1ffc000197ca0001fc00019a0300f4c0fe75eec22907d6b043edb0df74ccc7b85a45f4c0fe75eec22907d6b043edb0df74ccc7b85a456dcc6dfbd52edfa0d3cb1b5d503c5c7b00f05d833008b4c1a8b9c1402ea84afe7c47f7e98d657df873b9747a0e4a497120ec62c81f314ad91a6f3384648e7e60f2734554f700000000c367704082306916bf8d0dd2dfabf778c701ca6006a55b56de4e55a0ed9e2f02000020c367704082306916bf8d0dd2dfabf778c701ca6006a55b56de4e55a0ed9e2f0220a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e4b9b98f6b2dadc95391afc16b570bf7e3c706d796c000000000036f54b2ffb4e1ffc000ccadd000000df89a7a4e97a87e090c06cc44cdf6f596632e62cdf89a7a4e97a87e090c06cc44cdf6f596632e62c64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73016ca29d03ef4897a22fe467bb58c52448c63bb29534502305e8ff142ac03907fae0851ff2528e4878ef51bfa3d5a1f2200000000c3f559e803f09bb261a5f94a5c020816a4ca04627d1969819c32026d46004816000020c3f559e803f09bb261a5f94a5c020816a4ca04627d1969819c32026d46004816200525bd19daef243898853c4ba419ecdd8e493fa1db91277e6e4de61697438d2900c9a47526781022a84b503301b47c4c277d0d7d700000000000340c2f56fb4e1ffc0006567a01fc0006c05c01fc000bdc2300072732cc8d834a9c3cce0d05deffb324874388ee072732cc8d834a9c3cce0d05deffb324874388ee1ec5c66e9789c655ae068d35088b4073345fe0b0309757e077c72c5dfc02197ea345b361d66f861a16a3d506b5a99493929b7b42d2af420fa73b5c3728b8995d19b5952c0400000000c43b8e35d23d9cb0a088b5153414a204f436683298ad311c9cf2643cb9e482db000020c43b8e35d23d9cb0a088b5153414a204f436683298ad311c9cf2643cb9e482db209795d0f8c2ebc027150b12624db495b54580e283674c062f680b136e6477683801e8588af19dc9a7724451f1ff8a506b30cd18ff8000000000008d47264ffb4e1ffc0009235801fc0009a50701fc000a95e300c42520f12ca094d0c840ec18eaaf497adda92995c42520f12ca094d0c840ec18eaaf497adda9299521fb41623befdb80651c8eb65b8dfa90f1f507993081ace6ff9442d477f7eb80ebdaa666804cd0c1d6cb131838847f75cd83540eace2c501484adf0333b847ddaa6c087a8600000000c4b4329ea9e95851296c2c59d395399e36e2f0a6436d3a03cec8de73f35dd121000020c4b4329ea9e95851296c2c59d395399e36e2f0a6436d3a03cec8de73f35dd12120a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e2d4ec0d7b93616ff664078c9308e0bec4c8284cfec0000000000235c8f07fb4e1ffc000ccadd0001fc0010b8340020b99d09dfcc0f9b69fa97738487f20cc6c5786820b99d09dfcc0f9b69fa97738487f20cc6c5786864f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300196970badc74d068ec1226ffd4a656313decef59d792237a32e6ff56cd4e43030c436025831a4a3d0306a616f03381000000000c54b7009fd21294b6bd144e1d8b12492cdb0d2fe3b78007aa29142a84bd2e5d7000020c54b7009fd21294b6bd144e1d8b12492cdb0d2fe3b78007aa29142a84bd2e5d7204dea6406996a98efea88a66bddbe7f9568093185b08c865b1b664ae0e594c7be0238c1a1bec916b5169f94d1600c9062c9e44b62d6000000000036b95180fb4e1ffc000cf6350001fc000d08cb001e8e94abc60514536d80abdcbd1f252523eeb1941e8e94abc60514536d80abdcbd1f252523eeb194c69a0bda7daaae481be8def95e5f347a1d00a4b4300946837d177bd2b042cf1fe665aee99844afcd270601fdc4860231b9cc97909ccc214adbd2406ab38045d4465e3d1d5e00000000c582fbac1ab54ae7b5c89bd0bd92fdcb5e604bde4805e8ca5a61629cba7ef8d6000020c582fbac1ab54ae7b5c89bd0bd92fdcb5e604bde4805e8ca5a61629cba7ef8d6206ab54c4c60a06c2b59c05ce53c8a7939a128e0b8840d37132f13c3b84d203d11010625d7198a11ff1b8b2fdc69bc709657c2a1f7f80000000000035aa743fb4e1ffc0007b74b0001fc0008ac9b00bd63760f50bda0f3d8db2aeff88bc9eaa88596c3ffc45339be50b5953200438ba8c71ebabe9575e9ef0605d9bc9d3b3e7207258797498daded9527f63096153a0fb857c1da0f6bb1ce2e569bebfa14e6e1f532139f9dcb720d481db17999cbcd8eb66a5ab4c0fd20c5f9695fb100000000c6b291a26712b3f789a6f9379d55029d78f895fe3372c701dd5ef0a597be3b69000020c6b291a26712b3f789a6f9379d55029d78f895fe3372c701dd5ef0a597be3b692061f246afa7628f4c86905fc4f9063dba843830d5e5b9f069a6fd7981bb2c34bb01334f24c69a36c9adf8c9c644f9650da7a6655c3800000000002e65f354fb4e1ffc00053c1d01fc0005ad3a01fc0005b1f30033d78a9b138826acab6c464a74f84b9fa5cb23db5d068e0fe2b3fd8bf7983a2d806e797c522b75a9334f24c69a36c9adf8c9c644f9650da7a6655c383083152e6489f210094f5dd558373a1ce9abf36bb8001d4f35b3dea74f7ae74baf859abd22238c682ac94cab82eeb58aab00000000c6eee81fd38e6db24cb5e847794cefca7f3f8f95a066028bb8dfd6f36fb92921000020c6eee81fd38e6db24cb5e847794cefca7f3f8f95a066028bb8dfd6f36fb929212026101299b476b793ac0d19aee60267b583d670c5dae71755decbaab175c8afdd00c9f0eac27fa56e424e669e9205194fc9b173fdbb000000000068f8f27efb4e1ffb5ffe01fbc39901fc000119630038130b3e02c119f53aba29a12de6be40f0c6596f38130b3e02c119f53aba29a12de6be40f0c6596f6d4c795644ca86f717628ea27f0af13b0ea70eb730050f3a743867bf78d2e9a3906d15d8400d8d58255771d12828922386e8685f8aeccb8d9d81153f9c2d7da0436a71fe5500000000c7290309328d48982f4a265566615083ad72ae2e7cca5fdde599371762cd105a000020c7290309328d48982f4a265566615083ad72ae2e7cca5fdde599371762cd105a20c48677c8c69a59d52c2136a85090d3184e46f0c149bb319ffc2bc23d41e39009011a5f40c458858c685001ce69f201d3790b48a88e000000000036f4e7e6fb4e1ffc000bb3b40001fc000bd21b00a0d72e1d1296d2303c68aa6e148064a03e30dea4a0d72e1d1296d2303c68aa6e148064a03e30dea41ec5c66e9789c655ae068d35088b4073345fe0b0300422f6f4b6fb939bad0c5eced0d0085a9cdffe158b7fa0f5a4d83a2e311f080d92346f11764a2a8212196157d83a640b00000000c81c26dda720ccca323cca9a675257c9ea50c4aaf40cb1a4c2e931435f160fb8000020c81c26dda720ccca323cca9a675257c9ea50c4aaf40cb1a4c2e931435f160fb82066f6464e611b519b7abe070b67794d606b844fdfc365560468eca287bb381763014f6a74e089ab620cd7289a8a46a6564092782bb6412000000036bead17fb4e1ffc0004ee4b0001fc00052a3400e614deca3fce7919013e4e440fd3d4721ad3465de614deca3fce7919013e4e440fd3d4721ad3465da91a0b2b6a951742b8766f9a9554c313f29e86d83010d9901c0aa8f9b3e789a1413e731ff07b9b58d4f53925f53a1502f00e6ccf056dc86ffa5595a1ca5c02cbdfb38b1cb800000000c87218fb9d031f4926c22430c69b4edf1f0fb80c331c1a79e3b1b3873407c0ac000020c87218fb9d031f4926c22430c69b4edf1f0fb80c331c1a79e3b1b3873407c0ac20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e3e709e0d0819c27bba7eb754839e873e9aae580b74000000000036b94585fb4e1ffc000ccadd0000005c0c201c793d6cb7265b6897058b0b1e75fdf5285c0c201c793d6cb7265b6897058b0b1e75fdf52864f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730842c53c3aa11ae4b985a52ae6a3170bdb58f88ec04c62013f9322bd5fda4417939836b6f41741dd864c348103a1155d300000000c940d40d2849fe70baeffa8e343024d01dc80380f38b2a015798f503cba26d3f000020c940d40d2849fe70baeffa8e343024d01dc80380f38b2a015798f503cba26d3f20ab742c3f5293d67a1834b2506f41b1a36d58b09d713389e35d48beba6c145f620112521c58f53340f2c9569bf9e7d9c04f1b625a390000000000cf9afaaffb4e1ffbcc580001fbe61a008fe94ff326b3d3f9986fe97fb2eefa9a365629198fe94ff326b3d3f9986fe97fb2eefa9a36562919a86ff169d2789750a0bb4a5adecf343dbd10987230069dd3113d6320397e9674ba3595f46dacd562e013e9e80a2e7d1095525f35134d4a8c19f4cd4a19d3886edf6032875500000000c95f78ad5dab4ceaa98ff2d9d60d6d69e741f554b3ff876998dd832b2255a5c1000020c95f78ad5dab4ceaa98ff2d9d60d6d69e741f554b3ff876998dd832b2255a5c120c013351de51a56f7b39f2c10f3840e3fe943a174af4860f8e8665bb78247951501fdb9e309b9b441317475ef6c6bc6c1ea892d6a8c00000000002d2056e7fb4e1ffc0001a3c60001fc0001c433000e06d6f85fbf739967d628e48d87300c4bfa93e565b4b2bd9e302d32234a9bb205db6e51c08767ed1086f7c42d054d120f9ec84739e2211a19866e3d30128e20333b8b51fb8c72c2d5acafa049758b53279bf78f10a1f32995bd05d4f6313b2bd67fbc48379455d89ef869fa6e00000000ca0d0910002aedb97fb303e97b1db11583be62b3db8b6147ffa84b98309fce71000020ca0d0910002aedb97fb303e97b1db11583be62b3db8b6147ffa84b98309fce7120a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e4893f68af96d322ebc11029150d446a551042bcedb000000000036d45b94fb4e1ffc000ccadd000000b7e99fc3ee4cf3d64c4438fc2a61cba12c0e7319b7e99fc3ee4cf3d64c4438fc2a61cba12c0e731964f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73092823797ad456d53ce1e6bde84e8a19164ff88a73ccd242ec48d9c6a479f2a049e214c7e8ec2243b7ea74ca6144ab2c500000000cc02c1be8ef00540856c769f77bca1afc593d3c40cdaf5ca033e462f1c43fc52000020cc02c1be8ef00540856c769f77bca1afc593d3c40cdaf5ca033e462f1c43fc5220a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e1423146e911e2951e98aadb67f0c40c8a21ed6bf79000000000023a1de4afb4e1ffc000ccadd0001fc0010d993001d92da27f8fd00226f85d9e1c2ae33f2d57b84361d92da27f8fd00226f85d9e1c2ae33f2d57b843664f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73013146b3252f408f1cffc875b12b61f56c1ae02113b24c0b5aaedcda4a9b509332c8c4587450074f3e0906aaf3ceca75400000000ccc3668156451b3e10ac5c97d60e2c20fadf88c6266e3b2a9afb0e33e658734e000020ccc3668156451b3e10ac5c97d60e2c20fadf88c6266e3b2a9afb0e33e658734e20f9cdc515389213075782c4f03fad8a5010b7aa4165b804fbb1caae54c1c0f15700034ce75a5b9ab22d285c7876ccf1ea1ec4bcfdd300000000009b8ae253fb4e1ffc0005336e01fc00053d0d01fc00053e2c00d144786581a774e12dacc4aa155eb7d6d73869dfd144786581a774e12dacc4aa155eb7d6d73869dfda952b3b45775c0af85fbe2e2ab21549d86beb0a30057b3b0190261b1ded22b9c58550f7bf17a150de6a755a5478988b58e32bb7a53e7e6f9981bdbf416324e75ddd9853b800000000cd2963744e83eb775912b47e751f825f7fc8319db11f7ad4aa8e0f8831d12e09000020cd2963744e83eb775912b47e751f825f7fc8319db11f7ad4aa8e0f8831d12e0920f8659149d6af2d9b210531475f23dc5de3bfa2c35b45b4e54dcc471ab1b7222f0149343c1994d094b8ca7e095671e7aa7ce5cc141300000000002d200ceafb4e1ffc0006f1390001fc0006f1a300f6cdfba67f9b6228a325c80d5723557d8a2006d8f6cdfba67f9b6228a325c80d5723557d8a2006d849343c1994d094b8ca7e095671e7aa7ce5cc14133004ed653b556ea9d8b8391dc59ce49796b15c118e37daa2eb42326f72571b195cf21e814f93338ac9488000dc3d8b4d5500000000cd3fbcf015bb8071f253c07a4c5511e4759db5f655e2d198e4e2042e3986e828000020cd3fbcf015bb8071f253c07a4c5511e4759db5f655e2d198e4e2042e3986e82820dbad65a4c4cdae2325f1cf0f399a16a978c433a81e38987b8d9a5992087607e7019e5d4165c421b666fa97b17b6202fb4a3c34ed4941f00000003ccdda05fb4e1ffc0007663c0001fc0009419300742612cedde82b7e8d1f49ecc96cbd3b3c65372c7fffc5375fa606d4066bfd9f4fd211b3c5d59a955cffda7bd45f324d8b3b96059c999ac2d95044903091da7eb4d0d0f78e4aa5379d45c779105a0d809a04497186d53743876e31874d663f965507339259ce2b99fd3ea4c275015cffda7bd45f324d8b3b96059c999ac2d9504490000000ce09b01abb1fdadc8c04db6f8e9141187b034ae536776134e01156196fd595ed000020ce09b01abb1fdadc8c04db6f8e9141187b034ae536776134e01156196fd595ed20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e64e01963565d4e45dd2c88567cbf3f1ba813737203000000000022d9bfa4fb4e1ffc000ccadd0001fc0011087300c826f62669213156ccf082dc70087b8e68ff4c58c826f62669213156ccf082dc70087b8e68ff4c5864f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730068631f31e13e1c29c739619b2cb58adf73724dd8c6227ab1b8f45c08c5d6934338365ed45c795e4117ddf79f1e5037000000000cf774e2a4bcab3c7e7d2d934cd2977b090fc1e414d26dce53e16cf2cc5971ccd000020cf774e2a4bcab3c7e7d2d934cd2977b090fc1e414d26dce53e16cf2cc5971ccd20e91b3aa22e4f2d8326a68f0400a8ab92d2ec4b4af9beb3abebba5ed8127b8cc0005b156c7020f5322d482e14d95a666d0b36d9b8c100000000009f416929fb4e1ffbc4230001fc0001949300beb0ac49dd993a3841c7f91fc63faf17e32ef6edd1c380a3095e1088aae13a699aa83f4dd1bc0fd9b2334b22379811352d9988876a6e586d975e732930002decf89a99afc7bfddbac08c6c25a028e58f0c7863b7fa6811ff84afcefb933b510b78df6551f844eb2221b0c0bb5300000000cfa6f7b58c78f827c15e8f1b6a5a2a3a92140101719006d8226a363e2c0c8e5c000020cfa6f7b58c78f827c15e8f1b6a5a2a3a92140101719006d8226a363e2c0c8e5c201f44f17b876717517c7d133c9128abf51bb6733c87b0ec7ef06ccb96478e8aec01559cd372f02cbd4b52375512d9d55e153a3a873300000000008a442d76fb4e1ffbc39e0001fc000194dc00fd42c918654ccfaef1b1c70efb20d3f4f6b50b65eb294d05b014930dccd16d4878159584189e77c0b2334b22379811352d9988876a6e586d975e7329308ff05fb385c08528b762683c2ab6864ab1ac031146d9be0df597961625c9538e0bb03ae6a759d66e1717e879ebaad41c00000000cfcddb737317b86698faef84734e9e655fcc2899ee449d13ff70b014419b6c4d000020cfcddb737317b86698faef84734e9e655fcc2899ee449d13ff70b014419b6c4d206716b03191d4b9c5e813998018f03105ad3a5a0a7de1a62efc94339fa84afe9601bf58e573242232de98f1bee4b787f64252361cc000000000003415087cfb4e1ffc00021c240001fc0002fdcc00cba37b8b60880605abd3ca81294ca6b6e725a4038b7f823b0acb2fce829b7434a720075572ce6dd69a1a33fb82e27f0405303a4a4183199a5f2fcab830009a876325699d6979757ac10d6b37eb7f6690a40447f6473779eb9130975998d3a9fd6e9ada19559730bc017843ce1200000000d00a073a9de7c2efe78c712aaea77fa1a6c0ed00b55ed2289cf763763eb32a43000020d00a073a9de7c2efe78c712aaea77fa1a6c0ed00b55ed2289cf763763eb32a4320a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e2e5167565f0e750fbe3b6b7baf519c5dca2be263e6000000000036d63baefb4e1ffc000ccadd000000bae896aae3de540d18e5ea8573182860471082f9bae896aae3de540d18e5ea8573182860471082f964f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73013dac269908111b8b091edbda123d5884f4d47d21225fa319d344b350762a85c6cdbe21804ef9b2cc53a878c72a001d600000000d0b3fda32eacb51f9bf25e533344e144245d629cb1decc05eef2781a658f4ede000020d0b3fda32eacb51f9bf25e533344e144245d629cb1decc05eef2781a658f4ede205d054509583f78aefb625c44e87477878cad43c597a0f169ff8450a1abcc313e004490108b0958d28e47e691abeb21bddee8d08cef000000000022dcaf58fb4e1ffc000bb3b40001fc000bce2b008f4c05bb6a71e94abccfc1c722494ce77ed0a3418f4c05bb6a71e94abccfc1c722494ce77ed0a3411ec5c66e9789c655ae068d35088b4073345fe0b030031eb004643118075e2e22389b29d78e797ca7dc18edf201a2c324658b261803e8d162b172fb00822da1fe4283f8863a00000000d0c37ae5ff62e92d9f065b453c79bdd8b967a7e7e5e3753e94e0f2929065579a000020d0c37ae5ff62e92d9f065b453c79bdd8b967a7e7e5e3753e94e0f2929065579a203432a97c8b76efce888ae94aab39a57465f1e833f89364e8a4d13bf657c24cfa010dcb7083110afca0bb2af934af50512b0bda0d6600000000008c520f8ffb4e1ffc0006b0b601fc0006b32d01fc00071acb000b5424d01a3096f1a61dded02a329caaed8300d16150352212815041fa5dc70a94c7dfd507f4861975f49a2ef947f1f126a241add5de9e0965d20c483010ac5b643b6dfa29989103ad74641e5fa27626492f08b8337a8415b598ebf2bc6676c73621905a71a15d7bf9f92d6efd00000000d1ce9c61c04501fdade45632d83ba14b76b8cd89de369e7ba9594731e21a8c97000020d1ce9c61c04501fdade45632d83ba14b76b8cd89de369e7ba9594731e21a8c9720df179634db5c8c4cfedca1271ed90c3615ef15757d5c7d6fabbd9e18e8752f5201afe98cb66e8326b286b5eb9dd53b0f3043cbcc21000000000044b7c45dfb4e1ffbf08d0001fc0001195600227ac0c292b7d209dc75272563f6e3e40bcd4b66227ac0c292b7d209dc75272563f6e3e40bcd4b666d4c795644ca86f717628ea27f0af13b0ea70eb7300c49037992160cb8d7f6ad7e13d778fbbfb5d10230b456bb3aca1c044e79fb15c3b1fcef7efac59899eccbd190bdc40e00000000d2148afa283037e255d65a3acc82428d6a712215003963a60c6e015aaaa4bff0000020d2148afa283037e255d65a3acc82428d6a712215003963a60c6e015aaaa4bff0207a296529680d98fe988f25841cefd74be42dc27ca52ef6f46421c200f477525301c1e0f105b18897e33ed0d0636a1841c38e3ea826000000000003140e8ffb2712fc00035e2401fc0003cdd701fc0003ce6400bc0daad062fd3cff45c9494fc80bee6a0ad1ef904e818207ce6a7e9752c006ae4328b26c14af2a955e7e959febf6f6f5e42de569815cc416d06032ea308de1a5d67b291f75e87e20eb4b9fa7246dff5bcf4030ae26c321b1845609d50d04b240cc51862b4a7b3dc9be4aff050f00000000d23a37ad5fc04ff18955da1ea1cec8975fa03c525104f9553b3cacd36045b6ea000020d23a37ad5fc04ff18955da1ea1cec8975fa03c525104f9553b3cacd36045b6ea20347d39a27538a8a7819cb8d3aa5e7484b6ceb2ebb18de76970cbadc12837b98700eaf1ecf2a52c4b15b1f29ae0776532a4fab56025000000000036da7f80fb4e1ffc0006568001fc000ba7e201fc000bd4aa00af19744774b258e0ebf2a01006ee507c6a368f27af19744774b258e0ebf2a01006ee507c6a368f271ec5c66e9789c655ae068d35088b4073345fe0b0308b2ae1b6528eb36f1d87d61e763e5d5d26f6eacbfc6b91305eb30d4d4136e7edaf3bcf2fd07f8a91cdef268465f5085400000000d23e1b9f3cb6ed89beb1f11ac96f61c0011655c6cd02c600c6a671cf92c9f070000020d23e1b9f3cb6ed89beb1f11ac96f61c0011655c6cd02c600c6a671cf92c9f07020a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e5bc7da1882838f4aecbe1de16036780bc6dbb5d48c000000000023a7a5e0fb4e1ffc000ccadd0001fc0010a8eb008496f3b53ff1854c310cec50faaed0a3980374dc8496f3b53ff1854c310cec50faaed0a3980374dc64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7309291debc5e6c56a9e1a9b77cb980115c36a4d3d584826e62fc4b6ad7834cfc21e7c80226d46e90f4fda7771b4511152600000000d2467a06e67cfe57ce8723f565c296f97abb663380ce87bb8d5e72989e3301d1000020d2467a06e67cfe57ce8723f565c296f97abb663380ce87bb8d5e72989e3301d120da822286edec580e48efe91cf1129ece56530d16667549522d6bcc6d3e3b09910022de1a923e40b1fd9f13fb4f076b69d9ee94e0b3000000000068ee9c6dfb4e1ffbd50c0001fbd68a006bf6187199e0d3b146d1daeb844abed61dde51215d63ccb848f51351e6623f5841dd00e057e4633722de1a923e40b1fd9f13fb4f076b69d9ee94e0b330145a212f37b991a6c050cfaaad7e83f1347486984174e8f446e59fa6c225691ea679f70613d829f536bb1a311d812cb800000000d304e1e869e1a9aee1952f06bfd8dd43f8a4d12231c5d43641a31f89a53eca2c000020d304e1e869e1a9aee1952f06bfd8dd43f8a4d12231c5d43641a31f89a53eca2c2054be51b0a5708936a13e637645dc0c002a2d79282d4f5f2e89aefdfc4c49c8ac0141307e80a8d668b0bf3cc98a52f8d85ec8cf5ae20000000000904c4214fb4e1ffc0001b6a60001fc0003eb43006f39ee8ed58b56b0fdecdbf64cc71b75041ac7716f39ee8ed58b56b0fdecdbf64cc71b75041ac771c0a84112810ea249524c9060518b76dbee8b86cd3009591bf26ea6f179457440d73ebc70c44310ea56dad7539a93be903e28788cac013b646e3ed4198ca74a8325d8a721c200000000d3a0e645c1830de00ca370761d0db7a75a408b9322ca571fe26b7f8cc5a0ecc4000020d3a0e645c1830de00ca370761d0db7a75a408b9322ca571fe26b7f8cc5a0ecc420c4eca0c58c7f6be21f57ca22938b405aa7b70d1d7670a30ce00d83c145e6a0d300b0adcebc8b989c5d9248b195d5b3a3b1a57a855800000000010000000000000000000000000000000000fbaa690001fbaa69001e88661c273d73b44bbf942d3f1cfc145539969d1e88661c273d73b44bbf942d3f1cfc145539969d05b1290b6787444d5ddfdf30f732ee620dadda063005b7d7aee629c25efc5604104a3a9af1e23663464e0505a057e68cf12317834160597fcf80287a94e98f171a8c79a2a900000000d625ce5bfbadaeae3ea778ba16d871e6b61ec07faea80403dd51a9d28df8deea000020d625ce5bfbadaeae3ea778ba16d871e6b61ec07faea80403dd51a9d28df8deea20862bff54719c5747b08e2b5b646efc0e1ae8527b72e6526554e8b1db8655c5b400c315ac9f0d1a78172378ccf1dbe786b01ee7764b000000000055d1f301fb4e1ffc0010173e0001fc0010176b00b80018523ca775bdcf9f5b35b31aec7974cf3b15b80018523ca775bdcf9f5b35b31aec7974cf3b1517c1532d16104848a1cc23893816c93d5559beac3089b278c3322e9e5193d133bd49d958d05383835371944dca113bae75a3c741a61202a7d3f99447f7521708b308028b1200000000d73cc0f5964b94a5c72bf9457ea1681a4dc61940f75e991492b669697a392ffe000020d73cc0f5964b94a5c72bf9457ea1681a4dc61940f75e991492b669697a392ffe20024f7b3d5ef9e0a82cb75799a1589f8bf5d988e1bc342ac533a5aa94f32fb38401a8b2af0c1699023cd662f648d477e7b52bcdffd3000000000036f40a18fb4e1ffc000bb3b40001fc000bd21b00e433c14f7b979d60aa65bdd41a61793a80cb4af9e433c14f7b979d60aa65bdd41a61793a80cb4af91ec5c66e9789c655ae068d35088b4073345fe0b03008591f0c86bab284e3e43d622ebf60c6f2e508d574fce16bec8cf35a04f69fe667a65072dc7e0ebdc78c0a2f82d5d4a000000000d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89000120d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f8920593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0d47eb59e9a49b3794acf272f1bfff17f228291daf00000000002cf06266fb4e1ffc000cf99e0000007334f54da07d3b9e177f6e57c64f97bb0f982caf7334f54da07d3b9e177f6e57c64f97bb0f982cafc69a0bda7daaae481be8def95e5f347a1d00a4b43086108e551691da2642f37b68bcfbc5bbe9984ca51aca15ee24b6fa9b8690ed62c6ed722d091e04ef617cfc99341fd35800017034f0d3853c5351fb8e0ffd3c1daf12c51c2d8901fb8f3001fb05a3da0a60d91a09d34a39ba34e4175d2efca738ebb409e3fbb0546d41a24e83a722000020da0a60d91a09d34a39ba34e4175d2efca738ebb409e3fbb0546d41a24e83a72220a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e57bfc4a68510d0df6c7f9b006df5845a8468b5f390000000000036443095fb4e1ffc000ccadd0001fc0010efea009c14a51ad09e0eedf4d49b11a779aebe5755a4e89c14a51ad09e0eedf4d49b11a779aebe5755a4e864f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7301099dcddc6560d1039b0edb91bd700e5deae0cba43163fa289a80c2bd22335b5b0e7a1fb8f5494c0e6360e73a12fe0a800000000da21ca075f0b1b6c29df0391165030d85a8d5e7474c6358d9edbd3dd270de78e000020da21ca075f0b1b6c29df0391165030d85a8d5e7474c6358d9edbd3dd270de78e20d77e2ba2a4cd96a0cffe43117209beaa0bcca463d583c02ecd118a3e04e5ddfb007caf7956015e9404896b6492227b8517c679a02d000000000036b807b8fb4e1ffc0006567a01fc0006c05c01fc000bdc0b00f5a25e1acba9dae504fb92b2b7f4f8c776b450b8f5a25e1acba9dae504fb92b2b7f4f8c776b450b81ec5c66e9789c655ae068d35088b4073345fe0b0309760a3bdbe28cbc5c64b7426b7b59aa84f6ad6c4fdbe040a9158c359e39feeae4b4168d6231d636eb4024f072b4d465500000000db3158d303d9634fc0a4772452707e4f6154aabedcce40d60e7932137ca52efa000020db3158d303d9634fc0a4772452707e4f6154aabedcce40d60e7932137ca52efa208e8e515f7025352e7c608479e413beacf0d95cbb964b47e4a98fd27b6b6b628a19379812a735584751c27ae8d47205e7048ad8afb7000000000034d41347fb65b0fc0005e6990001fc0006584400f312f66e9433c75b461b481f0576d3acd398c223f312f66e9433c75b461b481f0576d3acd398c223379812a735584751c27ae8d47205e7048ad8afb730989f584df6e5a359bc469a4975baccda2bc6a3fc3e89721c639f5567db7abef79f31ddeb4832b95418d49322419d3eb000000000dbe6cc582f7b5c0eeeab18c03d651274a36a26e5222e9e6ab5dbeef9590c3d40000020dbe6cc582f7b5c0eeeab18c03d651274a36a26e5222e9e6ab5dbeef9590c3d4020a94e29c854f2cf4113be2e8b61faa8bc4749778dffa3edefc112d01de9a677a701bbac279c1e96b87d49a7da69df88948d81d5043c000000000023a39c47fb4e1ffc000b9ba201fc000ba67d01fc000bd4aa0099b35d5698744965f753a627926c0d59b1821c5199b35d5698744965f753a627926c0d59b1821c511ec5c66e9789c655ae068d35088b4073345fe0b030811536feb53c015c2aa7e518611a2f6609fe3362d64b225dd26ec2becf55100402e561aff014fa31ee0ab41e53d437ff00000000dc1a51970c343e17706bf77aa4309149613f7a69650f274b6a9fa1c6dd1c4f87000020dc1a51970c343e17706bf77aa4309149613f7a69650f274b6a9fa1c6dd1c4f87205b016215386c035a42042a93736befccdb87c30cb90adc3b1279da58ac57cc1407eeccb10d4e73ed1650cd3fcb2dd3cf4c2f7347420000000000235adf83fb4e1ffc000cf8b101fc000cf98d01fc000cf9fb00f49a8758b606e7ecf90fda27c30efdd71ab8be9ef49a8758b606e7ecf90fda27c30efdd71ab8be9ec69a0bda7daaae481be8def95e5f347a1d00a4b430846e41a6e970b78fdcf39e3348689944de461e961a0c5dae123c3b7c4d985bbfb0eae2da56b6600dcf82f196df258ee600000000dc2e02ac95ce4ccc9843c38de7bdaf32f2a1d5966c054127a3f4ca4f4bbd5991000020dc2e02ac95ce4ccc9843c38de7bdaf32f2a1d5966c054127a3f4ca4f4bbd599120a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e2239379b568d6e941d8e551204c4a13b38a8313155000000000023576903fb4e1ffc000ccadd00000032eb51df8032392d44594907e5032d23df570b2d32eb51df8032392d44594907e5032d23df570b2d64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300db85a27cd589d225beff9977aa0ac32551d15bd906a899bc1ef33458d7c979118f92bf1de4ddb55144acc2f7cf6d85400000000dcbcf8311e414aaafac3650f3f61326dce386eee3d1a53da86e4c9925af48d9d000020dcbcf8311e414aaafac3650f3f61326dce386eee3d1a53da86e4c9925af48d9d209d8df45a92c9e486da531a3dee6e38ce6d32613f0f65c3faaa4a411e31f8bcdc01c939bc570a54556243cc0386615fd4f77fc3a3950000000000b23e440afb4e1ffb66900001fc0001193400d930d39369c43d62ef0fa29c85a349673712f597d930d39369c43d62ef0fa29c85a349673712f597c939bc570a54556243cc0386615fd4f77fc3a3953089277d2620e48dcf8456cc8815aa18ad3587bbf40cf0d1718696bd126e19791bb600b22f1063d4e5e8efe85fab8f90c800000000ddb33a8e1dc94f0d2c78faf99f2209c5a6304924675ee639b237e00051e5adbd000020ddb33a8e1dc94f0d2c78faf99f2209c5a6304924675ee639b237e00051e5adbd20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e020173018c4450e8125fd37bc507fb4feeeec09d49000000000022de527ffb4e1ffc000ccadd00000017a7876ff09a4592bf27959546c02232a48d49f117a7876ff09a4592bf27959546c02232a48d49f164f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730882aed1df01917097a5502ff541a800d268967ab39c8f841ed62c5387eb46459d6f6959166cafec148dcae03830e83a500000000deaaf275e9e384f3e7b190cb4e779d200a8c22dd968e6eaee0bf0a2900ac93b7000020deaaf275e9e384f3e7b190cb4e779d200a8c22dd968e6eaee0bf0a2900ac93b720a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e080dbf942f2afe5fc96072af6ae4599720d1e88c3f000000000022db21e7fb4e1ffc000ccadd00000076c44d67639aaa8fb877f1db08d5e582b570c25d76c44d67639aaa8fb877f1db08d5e582b570c25d64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73017f78abcee6d2ed68bf2c82afbf56ef9af67313e2eb655ea5178850907cb3057cae0bb5a1d09f161057bf62f9d4890c600000000df770657631b27b71aa97f295c8c345df6f73617f2cc48f5d414955094a4d2ab000020df770657631b27b71aa97f295c8c345df6f73617f2cc48f5d414955094a4d2ab20eb25924c31ced9ab50bb1efa43f51e7f9e3a883b0668b1aca170731b2c73876f0116464c645e265c1dc215d0da895a91cf33c53f720000000000a123e12efb4e1ffc0006b45c0001fc0006b4cb0069c4cac4ececac7282dac6b8a9198772ce3f72995603402752878f5c76e9f40a3091b748a731beea16464c645e265c1dc215d0da895a91cf33c53f7230865e0561715f28e996d2c63e1ed462c82d403ad9300369529cc8932f02a8ecd6bf5c5b316130997f2c1ad1df700ea2fb00000000dfab7fd7e6f141d1ad7ff9fcaf8dafaf85b05dafc9058b376a33c6f4ee1da607000020dfab7fd7e6f141d1ad7ff9fcaf8dafaf85b05dafc9058b376a33c6f4ee1da6072032048e6d7e2751d4029bfddd77d06ea72c07fffb2d2a67b73ac1cc499fd10cf90210837fd9d5cba10bb91fc24c4faa5c7f591f4289000000000091efeb12fb4e1ffc000153490001fc0002427c004c90d0d2b49179ba1311496241623928b4e9bfc64c90d0d2b49179ba1311496241623928b4e9bfc62588a17ab3f917f19afeb8c32fa7c486ab4105a3300b4282cdfe1cd639e60b6c58b2f210bfe6b57f8f247cc5b55673d188ef458270c7314f7128b286a3326b9ab6109bd2ff00000000e0e5e51a1d6c471289fa4dde52bf5de747e1238a478a7fad107427a485921dea000020e0e5e51a1d6c471289fa4dde52bf5de747e1238a478a7fad107427a485921dea20c476e128117f5b8573cdedca3abdad1e49bc2d1ccbc8d536286a10c14c4bfbe9012aff26638de9d67c2ff76983669a27a5369f1146000000000002030405fb4e1ffc000834c30001fc000834e3003a8be94ab784cc8472ac6739fc763589673af28152b3089828ccd5c5e2929bb45057829bf2cd9900194748ff7e003ab02fd6964087130588b6c71c743019224c48bde28c061c99ca2a641ed1f695546fb6f1d103e93b4d8aa5164f5fdced8073ee239baa885cf377c8c173016500000000e0ef260e49c9f2139825cc98504c536397595e05813cc1de5dff2eb793aeb5ef000020e0ef260e49c9f2139825cc98504c536397595e05813cc1de5dff2eb793aeb5ef20aaa6c559704660301f5d58d95bba0be1df90ac849a60e537a7e1895e3a90d354016582f71a9a070fc634378449053280e8b5a64a0200000000008e5da342fb4e1ffb92e801fb93eb01fb96fa005d3a8bd28dc7d0ea750f976b89991482da5ef8bf5d3a8bd28dc7d0ea750f976b89991482da5ef8bf8e9c7503df018ff14c7f28047d833d1dda31efe5300dda9adbc22cdf89c04e8ee714da7d80dd5620c1d14e30780668d3b782b2f0acac9f00a556be1548733c1ad1abdd96ff00000000e1051e900f3f13c6cf79e1734ae1c65683c627982c5ddeb30f8afaa85116ab4e000020e1051e900f3f13c6cf79e1734ae1c65683c627982c5ddeb30f8afaa85116ab4e204dea6406996a98efea88a66bddbe7f9568093185b08c865b1b664ae0e594c7be06aec4b5523c900755019a250cd5922349690a448c00000000010000000000000000000000000000000000fc000cf6350001fc000cf889002a5b7ea1a484ccab3250dc7656ca99f7bc1cd21c2a5b7ea1a484ccab3250dc7656ca99f7bc1cd21cc69a0bda7daaae481be8def95e5f347a1d00a4b43000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e11bc5514ce9e362112fe4bc2356d68a63dd62b3834e320726709bb707564510000020e11bc5514ce9e362112fe4bc2356d68a63dd62b3834e320726709bb70756451020a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e499644ab02bf96193c58f4421e41886319036b09c60000000000235a35b4fb4e1ffc000ccadd00000002b43db3b33d56022be0be0abcd8a470f3624c8602b43db3b33d56022be0be0abcd8a470f3624c8664f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73017596d7a72b65531fffd5f610752422d6e286c975f30d026092f7900f8015073bd6f6d1b85dd3981814c093910e7dac600000000e220b3b30879a4e489a99f265f00aeafaab0fbedd0ec3fa194befc03fe93ac30000020e220b3b30879a4e489a99f265f00aeafaab0fbedd0ec3fa194befc03fe93ac302049104fbd6215a0f0642bb38f73f479a8694ab35111093a57d07464b7224857e70060494598e236442ea115c2fd4772c8ef4881c0c00000000000951c7f08fb5207fc0004f3ab0001fc0004f3eb0027ac0bbb97d398cc78587b58ea40d92039f6a27527ac0bbb97d398cc78587b58ea40d92039f6a2754a0ba964dc2701ea622ef904633191f9444a5fce30127147f0cd5bc3ec7c8c5704924e855d46dac21de72e2de112f7dee7c9c3f9c40d4474c0d9ae36a56b800659af62c16d00000000e341b4207f799d7b216593303c5705c97825331805f32cf54188dd05a7e9940a000020e341b4207f799d7b216593303c5705c97825331805f32cf54188dd05a7e9940a20ed0a3741f44d013b11c389c282f6ba4b53abd15f4b8b7d2b08ac06ccb7a923f401844e2264660076d8db9477d915f43ee0c68d228c0000000000369d0891fb4e1ffc000384570001fc00044423000ee3064c60e85c3f9e8175b2a4d748a2fa3138949dbb34ad2ac21a13371e4212a67150bbc0320b2ff28f590dc3a245b02f545deca4b8d37217444def30029d0298b3ab58f541f566ba5ddd40e8e1e711dca26b1757fd1b707baea16ce77aaf8a836232809a5e1d301a36f2045800000000e44e528f46f8338398e514570b715cb77f2e001bed967bf0012f99a81be34d9b000020e44e528f46f8338398e514570b715cb77f2e001bed967bf0012f99a81be34d9b20cbfd47c5be15b98099bde2b2d79a1b71ab29e9f70fe74b9a41d3ad87bd1b33f900a51180fa46b6e0e6763d1ec58803d676fddd4a3f0000000000235590e7fb4e1ffc000bb3b40001fc000bcba300c830435c4611335accf4d70344a9512e4af1cf82c830435c4611335accf4d70344a9512e4af1cf821ec5c66e9789c655ae068d35088b4073345fe0b0300c07de8f27328b0e1dfd46c77a183f153ef4179971b08597e3206b97b7ebd80a6d0fd81ae6d69fd9f1c2425952e6636f00000000e461d74c2d6f83e032068bf1f8bc5e019f220187c74ce90625ffff2fb0622a48000020e461d74c2d6f83e032068bf1f8bc5e019f220187c74ce90625ffff2fb0622a48204d5e955db2aa6907ad086e36d6e596554d9fe90df258edb34c1db83dbe05bded00c82b198d97a2b96efc25645a104f3de3f25ae4dd000000000036c81bcefb4e1ffc000bb3b40001fc000bcbaa0095745dc68d45784cfcba71fd18c5b0b0e2ed4f7e95745dc68d45784cfcba71fd18c5b0b0e2ed4f7e1ec5c66e9789c655ae068d35088b4073345fe0b03092110df65b98e79912f6b80aed1eda6e66c55da2549472aa7a089a003efdd5244b39c208acf902198701f623fac145b300000000e52d2f726c9d7fe66a042564fcde9d4189180b7f9debb60ae3241872338b8e9f000020e52d2f726c9d7fe66a042564fcde9d4189180b7f9debb60ae3241872338b8e9f2091cd1bffaa50fef228069e113b7935af4b78c904a32ed0e7984b1086478373020199f5f489bbf74630e2aa67714aa7596510133be5000000000036cad177fb4e1ffc000bb3b40001fc000bd21b009017184ce5f2e988321891515465de3330af413c9017184ce5f2e988321891515465de3330af413c1ec5c66e9789c655ae068d35088b4073345fe0b03010487fb44636ebee88be5e76841d80b2710c25717d82d4ded913ca5c9c9a5d85f80268687b237632cac812518a2464cb00000000e558c21609f13196f38a0e135c8a56ee4632ea1681a9dedd5d65ae8031b34be1000020e558c21609f13196f38a0e135c8a56ee4632ea1681a9dedd5d65ae8031b34be1208e8e515f7025352e7c608479e413beacf0d95cbb964b47e4a98fd27b6b6b628a07082bf9bc77c34eaaf9c9cf4b1b8cd01f1768bab0000000000034d41347fb6596fc0005e6990001fc0006579c0018fdd71cb9d2d0a4cd75e08191dff37fbdf4465018fdd71cb9d2d0a4cd75e08191dff37fbdf44650082bf9bc77c34eaaf9c9cf4b1b8cd01f1768bab030005d1f334fabccd08847756effff3116eece973c077e3acd1aa936f4e51293fa8753de661dc7a03edde24714eb7acdcd00000000e58b99ba67999559acc105b139ad7c0f75e4b88b64ec8e9e3f91d19b18a02fa5000020e58b99ba67999559acc105b139ad7c0f75e4b88b64ec8e9e3f91d19b18a02fa520b4863351e597af3a020f3a1bdcfcca49c63059d3a2769c3bc5628f2c580d988d006156c9f4174e1544f07c378dc4c20b5fff8877ee000000000022ddabc6fb4e1ffc000bb3b40001fc000bc78300b42b27cc27998975c7ebebbbcc18c98c097b60aab42b27cc27998975c7ebebbbcc18c98c097b60aa1ec5c66e9789c655ae068d35088b4073345fe0b030067ff22ce46ff515d5869ef672ace862c7afe2e81a6820d39098419322ad2858a3305f03601a9a85f76333be38b65c4300000000e6595f88f935fef934a6d51dc0a1fd43e65de1adfacc2c99851a69d80cd26493000020e6595f88f935fef934a6d51dc0a1fd43e65de1adfacc2c99851a69d80cd26493208e8e515f7025352e7c608479e413beacf0d95cbb964b47e4a98fd27b6b6b628a3273c764874df7a0f6d7b1c77ae924dde0e3affe430000000000369ad3f2fb65d8fc0005e6990001fc0006575400ca9f4452a8988619c535d28f0b25aaf2c34b5d13ca9f4452a8988619c535d28f0b25aaf2c34b5d1373c764874df7a0f6d7b1c77ae924dde0e3affe43308f72e69ac2373a62f14b7b1d99fb24eafdc87b74247af42a591aef0989c9a3e152197736dbc266b2535c4b4b53d8ec4a00000000e780a06795b6c316aa84451acf07e0f11f9565e256a59057717fbcf0008ac254000020e780a06795b6c316aa84451acf07e0f11f9565e256a59057717fbcf0008ac25420e06631f4da3659b5efefa7eda26e82d9f30427da7c63c0943aa4e6a5a03079c900d1f5e6e6661ec2fbbd62e961da89d2d9fcf11099000000000022dc5846fb4e1ffc0006567a01fc0006c42101fc000bd4a3007d1c61a5a5d33cf6b75aad99d80d90e6f6585dfb7d1c61a5a5d33cf6b75aad99d80d90e6f6585dfb1ec5c66e9789c655ae068d35088b4073345fe0b03007f707431f05ae863a756854d6a8e6c5c37d071f5dc9e3debd2057c36106eaf8102b3313d1b369f3dfddefbc1394639400000000e9126eafb8f62f5a4e8b4d4f2419f4377a8dd14635fc749f9ca2636ffa93815e000020e9126eafb8f62f5a4e8b4d4f2419f4377a8dd14635fc749f9ca2636ffa93815e20cea979a463cdaf780c42b7a196049c04fb8466bf35b0618814e0759fb702c3cd01e0ce79910a4636b0e6a1d9695cee5aada92ee76e00000000003695cfc1fb4e1ffb699601fb868d01fc0001194c00b2ea896299dd86bc7c3353a40d354be43ca26372b2ea896299dd86bc7c3353a40d354be43ca263727eb0a0af302dd9ff95daf9e98d2f1f2c5d764f74308ad9500ef26ae510e0dd8cf0568b2a89d1234697873db2fcdd11674a73caba91cd416f9ac701f4f7807d8db102bc4a3900000000e995e4b4ba9fb3fc8cbc7c779b8b933367c54166175c3cf507aa92d0667ba7b3000020e995e4b4ba9fb3fc8cbc7c779b8b933367c54166175c3cf507aa92d0667ba7b320a5fa769a80bb95a3901423e38b27a4708f7ea2719b1e4bd01aa4a5b8ec9eadb300d33fa6c54b097be5bdc537d894e2d2f144f9847b0000000000ae22e96ffb4e1ffc000cf03e01fc000cf17501fc000cf6e30007f79cc14feaf70775dfd89cdaabc42f9d5a3416ce7f101b7f075273c892063b1b8571311737a5767f95c0f808aff27883260bfaf9cfe2b84519a6b2300620124f5dbe95b93bbcbab48452ba0cc47beaaf554e63db5deef90c10ca79c1e83c08a43d4316105419bccf6595802300000000eaaf0220c44e4e049b5899f162e7adf2da1e7946a2272489f304fe3df5247349000020eaaf0220c44e4e049b5899f162e7adf2da1e7946a2272489f304fe3df52473492050f57d34e7aceac2e5ac132c091ae69842d484ab382d59ac5459a9c8c3efdd4b01fac33d28f64870ce06e55c632d3ce829c9aa8e4e00000000009fcb2263fb4e1ffb641e0001fb64420016c792ef93229ad52721ad5b08249eac743fb74f16c792ef93229ad52721ad5b08249eac743fb74ffac33d28f64870ce06e55c632d3ce829c9aa8e4e300452f32ac367f352d6ef53f984667db9ad658bf940292eae2440024e5af9445f7a7a618d536c4743c9de4c3e07b6a5f900000000ead18f6dabac93c3fa0df238e992fabbecfd75b28dfbbcbcd0ac4bd4dc89a255000020ead18f6dabac93c3fa0df238e992fabbecfd75b28dfbbcbcd0ac4bd4dc89a25520ae5c3b488065fb736209d417e87458b953d6ac9b7bee596447ac119f68f3a287008ff714a271165a679a084036555ef7ea685a458a000000000022d743e0fb4e1ffc0006567a01fc00068cf701fc000bd99b00c9adf3d64cbd87212f093e52caace7296c89fe68c9adf3d64cbd87212f093e52caace7296c89fe681ec5c66e9789c655ae068d35088b4073345fe0b030023bdd31086c9f2de87f380a0c24fd3e7d699a2a43f87bc8d5a395c0eb3f8e19d82af15542302c129c981f352a3e890900000000ec6e4e052c3b28d77c13ccc5072b5f5c185e1a53a6ffaedbb1de9739c0d31489000020ec6e4e052c3b28d77c13ccc5072b5f5c185e1a53a6ffaedbb1de9739c0d31489206fe7864bc5e0241a306eb3adac70d56ba305b520ed44b6917981be5862ac7c76011172bfbafd8ddfbb947170ff69ebc2bc1a7c16680000000000c380664bfb4e1ffc0004bc490001fc0004be7b00cebc041331aa21d5fdce3e44b4a2a520889d4ba4cebc041331aa21d5fdce3e44b4a2a520889d4ba4382477245731a85b4a1b2ca6af9e904517d07e97301926b68942b544b4e17347c5e0d28ba91453984294c7679965f3a1d3cdcd9f5bf80f2c28a48b503f301bada54479896800000000ed1caa0e3a8c97dffb71fd26d6aa03a4d52347d8da71709220b0b4357e2a7236000020ed1caa0e3a8c97dffb71fd26d6aa03a4d52347d8da71709220b0b4357e2a7236207027e327b827fa7edc0fbd17b85900f2787d210c76a3ea06182088249d157679008e7e021f47d1e9425609af4dd695253fd8a9a0760000000000235a0070fb4e1ffc000bb3b40001fc000bce430039e05a296f11c657770a6161ea00a72b625d1de439e05a296f11c657770a6161ea00a72b625d1de41ec5c66e9789c655ae068d35088b4073345fe0b0300583a5fb61d625bb0640bbd1dbec505e8747dee734bd9dcda0c62fffeb13e24bc8cf3475e1535f8f8700fc48f177569100000000ed8575335b7e0b420b09b4b8c530711b98aa472504d91bbca9745873a106cb0c000020ed8575335b7e0b420b09b4b8c530711b98aa472504d91bbca9745873a106cb0c2092ebd7ca076b40f4012ca7e115e04bc2b1baab1be5289f8c975d580d64848769019aa6ac346d95f15724c602b262b8178333646dcd00000000008b3b51aafb4e1ffc0001aaae0001fc0001aae4009f9695e95af100e56314bd08680812a0f6256e119f9695e95af100e56314bd08680812a0f6256e119aa6ac346d95f15724c602b262b8178333646dcd308dd3b8d006c8ea260bc6158daf0680c5cc7cf4936458024b51ea2036a800ec6563d75135004055d94743b8341b70135800000000edc1fe5456b869747a4f41f92ab8bb8b10c1f43bbbd97957a16698783baa0d2a000020edc1fe5456b869747a4f41f92ab8bb8b10c1f43bbbd97957a16698783baa0d2a20a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e335e9d6b2065deb3d586152f44f0578cb0d51a5e74000000000022dc9b03fb4e1ffc000ccadd0000000e42f45a86824089891f17af573e84512f00d8850e42f45a86824089891f17af573e84512f00d88564f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73006e81b2ac08c3ba6308868ced5075f366013ee8598961bc84150d8dfe9085fdceafc082fd18d3a7bb1338b74584048fc00000000edfb29497dd86e1bcbe72cce1cca1adbc1d9a991d3384c0a1a83d35808cbf5a4000020edfb29497dd86e1bcbe72cce1cca1adbc1d9a991d3384c0a1a83d35808cbf5a4206deb6528ee95044163f5e417053b8b43f32ebf26fad8d9e47e1222d611f7cd1c00ff84a8ead83fb486d9321ea63b356b287c2c569600000000000b7a212dfb4e1ffc000607a70001fc000608330035d72ae28122e666401fbc5f914da502815aedd335d72ae28122e666401fbc5f914da502815aedd3ff84a8ead83fb486d9321ea63b356b287c2c5696308d052595c653122cccb964230a5404399634e7cc6b3fa9314b54678c28d2f9c4854baa7be02845937bb0de35e43cfbd400000000ee12a4658170bf28f8ae6eacbc48fbe62d009582bafe6714f630484b14474944000020ee12a4658170bf28f8ae6eacbc48fbe62d009582bafe6714f630484b14474944206d945b3976197533a8283ecf24a1f1b86c51eaaaa28b4556e6fac59a0d21875f0108bd9dfcf61ed79b051ac428f69328463aab0001000000000034ce62c4fb4e1ffc000a4a8e0001fc000a4a9b0025a3f54d7d674aa11d94a1a7d4f40d618f8aff3a9a870b5d4ccfe0068e92a6cb4cd35915ef94df9c3a840c9fab8a7618147fb2f3060fd847cf86f08f30121a1cade221b1eadcc0c7a02a03508551dfb97b959ae1511d4cae47b503b39ba0fb37b984e4010164378513edfaf07200000000ee733db5519c987496eb3b871d5fa543ddb19db3e848f2fbb0af01585fc76af5000120ee733db5519c987496eb3b871d5fa543ddb19db3e848f2fbb0af01585fc76af520f56ac75f5801afb0fbf248e8b39db1dd43a55f1d873beb9674989c51b53d73ee0191be18196047ed60fca300e6fdca0b7bea81beac00000000000238d45dfb4e1ffc000de7c001fc000de9f801fc000f13a3000bf9547a7b4d12def0019da71e989821a60d9c915b44dc4b3f0ed26a8243afa46bada49c18da6b2a21eca01872dbfce4bf20886a004f6caaa69c1ff730b695a4757d60c472f67a7807def81ab7a52dec3bc64aa1c4188d02a4768ac3a862b404f0656ed395f1eb6470dca7bca400018355913e3791438c18b5ac50fe03784df789424101fb8f3001fb05a3eeb8cb773673c77f664501bc68b813206e9cd0920a11cb74cc918897804bee24000020eeb8cb773673c77f664501bc68b813206e9cd0920a11cb74cc918897804bee2420ded1303c7551bf04f34b3b61a00d142d46f2329ed8137295b51c89f613f5b62f01df33af9d739271f406b1c31d11a2f570c524e9dd0000000000030d2293fb2711fc0003abff0001fc0003b6940087de47ade017f67b717616f8bd4f5fc3005dbe8587de47ade017f67b717616f8bd4f5fc3005dbe8567918cbbd6928be3a8e76c1a8d89717c2e3d08ce3004cab5bc1d73f5f8299feeecc0bee2d76f27c3b2a56a7e2fc1f927e495ac9b2a0560b7d82fd06fa8fce4af69d0fcb10b00000000efb3f539ad844bf34f9529602480e504885915b42b10102b9be38c4db31eb1b1000020efb3f539ad844bf34f9529602480e504885915b42b10102b9be38c4db31eb1b1200ce06bc2b322337c43a1d3befe252ff366f81600bee06a14c07ac462e17498e00020eba3616392708db9c3a971924380b6080bd17e000000000022db5eb2fb4e1ffc0006568001fc000b9be201fc000bd4aa0086cd7c93e15658bbce6b175c320e67aad70c8cc686cd7c93e15658bbce6b175c320e67aad70c8cc61ec5c66e9789c655ae068d35088b4073345fe0b0300abc2b9eab7faedd46b321ef733583d1edf73112492b5a84f8d61bb83801f1269878d663ba0f037752792ff5226b02b700000000efd6717fe659d2b949955f2c01985d4ff36848c96e425c6bea4780e2ab0ff2d9000020efd6717fe659d2b949955f2c01985d4ff36848c96e425c6bea4780e2ab0ff2d920c8c64c21433a191413a465619ed9255bec0027a8f938e34af2846a3ef764d87101719ad3711be4ac4c4d3e916a78bf59fa8b486d1e000000000022e0950afb4e1ffc000bdcae0001fc000bdccc00e88bf8b114ce7d91ae8968eaba14be60d05491579d39d1cb8cd5844cb453cdb1a62b73e0ea6cde7b43e505b33b6e189d0f3c9f598a1e551fcd953cd6301560ff0ddb3c1e8bad9f2e237b3ad39c37ba804fc09d4ccd928362ee874308b29e827ea60c21b3c04787d771a16e732100000000f0e0387783674bd818ebae2fb6b5c20659cfcd5c68a2f8a1f03b03ae3004724c000020f0e0387783674bd818ebae2fb6b5c20659cfcd5c68a2f8a1f03b03ae3004724c2049106aa9cb4165261f6af3c21680cc16effd3449f9f73ac5e765c2e2380587ee01e02dac43c4d57aa2a821a9b0b25068f5f5edfa3200000000002be54d2efb4e1ffc0009c59901fc000c0e8a01fc000c13aa00e53909416dd7f61cdabae76c20347cabeec8a21ca6986dc7a8d22b1ec6edc799608163d63eb92ff6e02dac43c4d57aa2a821a9b0b25068f5f5edfa323088aef910c408df03f396e0f92411de096d08d4ea727fb3abf45541685d0327ee1e8d5b5a5057c92fa2360d9c0abbd11f00000000f129a2035414a54881224bb0926390bef90b8bfcc63fd2757ae95f07fc9cb381000020f129a2035414a54881224bb0926390bef90b8bfcc63fd2757ae95f07fc9cb381202d618978b20c66d63c97dbcc2f064fccbc03d2403baae27322c43315b1543391017f5372f19a541e9afb85c443c3645ad95a37f15d0000000000a747dfd4fb4e1ffc00023d3b0001fc000242030026cfdbcfd54646d88cd9fe62da04f5e70eba5ce6e21d3baa7509a95b0a9d741549047c2e90ed8aa785512acdbe7b71cba4d29a25df44193d6e950c063084657bff1dbf81b2aa50e385d01549f9c3683994ab0b16d5b7e3ede8efe95992bb621ec221c5003d2f9f26fa190ffb2a00000000f14c9af014af86568a4ae2582c3ffcf6602920ee4155b8a08b1054cbf31536c1000020f14c9af014af86568a4ae2582c3ffcf6602920ee4155b8a08b1054cbf31536c120a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e6df28cf902610e816bd509758353005ba3ee418fa0000000000023593580fb4e1ffc000ccadd0000001cffef89d1917166a4e3d2443411f6cd1032bf291cffef89d1917166a4e3d2443411f6cd1032bf2964f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7300ea46d70601eb45319ab495e2462f981debc8316df2bb1a679ae3525c7f517e535b69a02052844374c887a9312a4798400000000f2382c75e2009f5ce32df63933aa700a05239dde4f2df94a40ba2234b8e777f2000020f2382c75e2009f5ce32df63933aa700a05239dde4f2df94a40ba2234b8e777f2200c69789a95af40ef45beaa00faff26487428af61cefe1f64b4099f4a90583bbc015d58fd558edd7f6e2ed85b5fa134648f477d32f30000000000342ad593fb4e1ffb783b01fb868c01fc0001196300c3bd25702c4c5cabd642d5498f118ec73134c534c3bd25702c4c5cabd642d5498f118ec73134c5347eb0a0af302dd9ff95daf9e98d2f1f2c5d764f743016d49c42cf506d5687c4035fc8ea37c2bc293761412b8c28a73f674df9d3983581f53a8eeb7f1c7b6382bb0485df381400000000f2b2cda32fe9ab9a29ad463e878bc4061e3fd74bd30508c53a214333f8b58839000020f2b2cda32fe9ab9a29ad463e878bc4061e3fd74bd30508c53a214333f8b58839203988b5f83343213ac50805d34bd73f1e06c48b873e46ad299aabe92fa3cdb2f201e0e440d4c365236c93f5fbe402336cba2c5a506242c800000022d1d386fb4e1ffbed4e0001fbf1ea003e58db4338161895653ffe307a9fd3567d7b3c3bba7c694196934a70e11ed92a56db5766131968cc365b70e557479d57b35b99598327dfbd0bf9291330195b44e1d553d160abfcf70b8ccfaf24480ad34fa7917fb87675f712f0795a23dd0107f5f3e39c07474697e95b15170d00000000f311a4630250c2c2fe0f6121d7214b1e962d2e7385e78cdc3ff694c9cfc0cbe8000020f311a4630250c2c2fe0f6121d7214b1e962d2e7385e78cdc3ff694c9cfc0cbe82090d0e59ebc9e022b3074f6eb4a31650a7d41f7e2d4a97a1956577ab903a5afe801794b99b1cd0a4f69ee1072b041560edd584e1d1a41a00000006a334e46fb4e1efc0003a9ef0001fc0003aaf4006171861fc24ad0c91cf01b5950b00dfd2b0e65e757f73d89afcfbd3c34ff42e19f32af77dfd7a8990fdbf7aed02a6e0d546fa6c8abb8d7e1f65743d03001841a16adc73f0224e6544d0cc57057ee2508c906706307ef8561908bd476594ff1e825798faac54c8f8a66583a3dba00000000f39722e1e9d02ddb49512b16674868a865bae2a912401bb6b006b09a74186beb000020f39722e1e9d02ddb49512b16674868a865bae2a912401bb6b006b09a74186beb2047d6aaf3ee8ba77263837e9720492e7b57d59345881f5443442861f43fbd0f68017583afdc80db725044af4e20f5a892f4a60770fb0000000000030d2293fb2717fc0003ab450001fc0003b66300bc97efd5f5716cff0af50478f0d383052635c7ebbc97efd5f5716cff0af50478f0d383052635c7eb0740696a1602a31eda2d6bbd49303ad3c665a3c63096395d8ca159e5ca66eae7685beb6766a6c0ae50b4569809c4ecca3e101a1f210bc35637473b5afd5e71bfbbc976277d00000000f3eeb1461780dc6c62c5793df607e23f55153945b17ee029b3404dce7450ca84000020f3eeb1461780dc6c62c5793df607e23f55153945b17ee029b3404dce7450ca8420a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e6aee197c209560b451adf796ae802f30ef1375183a000000000022ddc467fb4e1ffc000ccadd0001fc0010dcca003ecf5e66d9c0373f20f86d3fefdce2165c19c7be3ecf5e66d9c0373f20f86d3fefdce2165c19c7be64f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73090051db915bd86bd938746c14440b11ee3b2801cbc6d6c1c912e8b41ea5eb1d8f852abf220ae91ecdb6da094846c1ba800000000f5e25c2dc6aedeff586b26a5fef15bfeb332963bd32fa02d1e8e1b0b74784c7e000020f5e25c2dc6aedeff586b26a5fef15bfeb332963bd32fa02d1e8e1b0b74784c7e207d6e5caedcfca225cb8da762d52bcd3d73b2b3ce2c7f8fa3f900bf0b6c75460b01c106d71f6a7402065c35fda833c7148623179b56000000000022cb31a3fb4e1ffc000a4aaf0001fc000a4afb0015b1012a3f35f6b6873a144ed87b5711f467030601878fc5b0bde020f35fd7dab0709c0faacba8fe3a840c9fab8a7618147fb2f3060fd847cf86f08f3099cec23c58cf89081e39d8862912ecd50a18b44dbe92af0378ef2a3bbbdf4a6a11a76af5b70db205cfd31323391ee64000000000f5ff9fbf1daf5db3539c7e307d9d50b12bb58a491b2f684c123256fd8193aa22000020f5ff9fbf1daf5db3539c7e307d9d50b12bb58a491b2f684c123256fd8193aa2220693022de7fb65f12cc990c6c3db7b02488cfa0d222ad3ce8ce8970dcd945666e01feac00c4a5ee38b2a8e6857126d5b39c05062c1e00000000010000000000000000000000000000000000fc0001923901fc0001ba5b01fc00021efd00d3f5c934320be62f66647087ee07d9e3b68996165bd941a8832f305921d4f2bdf7946d8ac1b6b379bcfd75be0403b27a8121583a01d004c114f919753000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f60f6c91316fb671bc4887c714f9ff99a836645e69d0a411fd85468602489133000020f60f6c91316fb671bc4887c714f9ff99a836645e69d0a411fd85468602489133200f90ec21220fcd572f8a7361d9b45930be3067834acbb21df32da4f8070d03c701989c8077698d0a9dd2f90be13019eae3a8d13e0600000000002cea7d97fb4e1ffc000b18330001fc000b1a2b00e3ea58a452a6c8d408df64a2f8511642921268034e28cb55a991fc1d6062edd80b6597f7e72d2a922567856cdf62ed7325c44bd7b7557e1acb330a633006af52990c96c3d5aa6d8d29ffc118f43a74c12f3dc860825818e70bbdc9548a6b62d680af91772ba9231378cb6d292500000000f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381000120f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba786399038120593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c050d1611e03249023d89c1ac086036cbea392768cc0000000000340dfab6fb4e1ffc000cf99e0000006cc3fca46aae1c44ea1bab81d506e9f0a3ae1d056cc3fca46aae1c44ea1bab81d506e9f0a3ae1d05c69a0bda7daaae481be8def95e5f347a1d00a4b4308f2df81ba65db70eaab625c5fe46f0f5e52a45b25c761686db23b4f18e547cb0d161912dd187302eb6f7c4a9a666a3230001fe2d4798df3e9b41a6823bc0b3f020478e87925d01fb8f3001fb05a3f69c63feb0590c9febd1f76164c44123538f67e4c9fd6f8d6393908f80c01d87000020f69c63feb0590c9febd1f76164c44123538f67e4c9fd6f8d6393908f80c01d87204dea6406996a98efea88a66bddbe7f9568093185b08c865b1b664ae0e594c7be07b165b659c3d7c15bba69e00c837d2a599526c6ec00000000003270c21afb4e1ffc000cf8b10001fc000d0b2300f0d1ca8f807aedfa439ff530b2653ae37bb94e6af0d1ca8f807aedfa439ff530b2653ae37bb94e6ac69a0bda7daaae481be8def95e5f347a1d00a4b43016cfe921690a750621948774a88522d4af9e4167a605797abdc8adb414aa254c2e16c43b95e491c1965eb90c528224a600000000f6f8f1b3377129a483e7c027f8ea7df7d2378de902f0788b132ba87c19c29f2f000020f6f8f1b3377129a483e7c027f8ea7df7d2378de902f0788b132ba87c19c29f2f20970ad5ad9687bcd4e164c49064780b2b2a038c942a81f7f939543dc0447996110031331182f4105cd8a4690b82482ec4c09197f5e9000000000022d91cf8fb4e1ffc0006567a01fc00091ca701fc000bdc0b005964edbb7dea08cb0987faa03a37a2295c19f4105964edbb7dea08cb0987faa03a37a2295c19f4101ec5c66e9789c655ae068d35088b4073345fe0b030167d2ac620df46eb74cb2069f69c30965f6c899a134366ab95e41c894293e0d987a3cb78176fe852a309faf101883bb100000000f718902044925ab8ba5089667a4c2a1e45b855eb4388d21c1b14e1d05bc1991f000020f718902044925ab8ba5089667a4c2a1e45b855eb4388d21c1b14e1d05bc1991f20c3aedb72e0902bd6da0a97cf554bdbe6aa6183fb075b4aa3a13fafd81f430e200150046adb767e71c9cd404518f190faa10ca9b9b800000000002e65348afb4e1ffbe5be0001fc00011beb00a7327f6d42206d3642c4633c4b6b10919202cc8ba7327f6d42206d3642c4633c4b6b10919202cc8b6d4c795644ca86f717628ea27f0af13b0ea70eb7300d2be4cbd0faf7a27695a4f11690ba772a32c9df368f0558998681d697e60888b7127314dfa8495096050638d8507c9200000000f735ca801b3ed2a87a0fe2838a38a56d72239fd0c4e3877e80cc280090c6f8e2000020f735ca801b3ed2a87a0fe2838a38a56d72239fd0c4e3877e80cc280090c6f8e220362c9cd667b23f106f2fe366206f8e1d7353c5185de1426e64fabbc2ebe2856d00a1dbf97a74f90b10f8ebb6d919f21cc2cf9e2a13412000000022da8162fb4e1ffc0001980801fc0001c2de01fc0002787b0065802f3ece78b624b0739a8002fe35327ab85b7065802f3ece78b624b0739a8002fe35327ab85b703864c3d41a45675756b2543a0bd787a1a18fb4d9308cf9b3235f77637f144728584ca13d1d3fd47450ad392a510beb2425e0d88f6a3354f0cbdd26d4e6152d38899c025aa3018b3277a4f4a3667225def8a4f83000c086719cd9000000f773def21e01af33f508b4e978631b99405fd1ad3947984d3bbca5b41b221175000020f773def21e01af33f508b4e978631b99405fd1ad3947984d3bbca5b41b2211752071e06128c6220c4671d4582596eaa9528757fc86bfd42a7e6545314a2271c2c501cfdae7bd25128cbaf6e27f37b9bd0e1024d4d3fd000000000023b9cadbfb4e1ffbe35e01fc00015cf101fc000467dc008a108538dca5b073f24fb8db78f06ab6a0aec27e8a108538dca5b073f24fb8db78f06ab6a0aec27e23baa2294dc2c2f7b6e6fa3717074afef3ef2d783004f1a3407bf953809815243d539d316d2b055a57ff6c5412f31d98f0d5ea84f54511fa9f02ddd6d7f8751505c560eaec00000000f7f3a36e13bd406d5b9c9a19b6c67c5051f7a29e6596c1413326b98c00cad909000020f7f3a36e13bd406d5b9c9a19b6c67c5051f7a29e6596c1413326b98c00cad9092009d9ca008cb9263341c196659ea2f751507cc6b6199a9c5b6d40bd136ea3f3f7001d328264ad882a524f8fdec5cadc094fec10834b00000000010000000000000000000000000000000000fc0001979e01fc000197a101fc0001a33d00954c2b52b2f86d89f81b8eb64b0944a1b1033e38954c2b52b2f86d89f81b8eb64b0944a1b1033e385f9227e2d862ef10a8aed1df196e5267accf22023000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f8293d83dfb38fa7a6c34928e9171fe6a112d5a5b1d07592d59f37a23ed0a00c000020f8293d83dfb38fa7a6c34928e9171fe6a112d5a5b1d07592d59f37a23ed0a00c20e0699697fd9e5d90cf616f1f65e6172be9660e8741e431a48b5b280ec9c54aa001a01a6124dd32d31434325f8b39e3133ca643b8c3000000000034348bbafb4e21fc00014c6b0001fc00014cc400894737fba2d8ab6dd337538735ae0a74b18cd19a8e4960713412ea367f0a11c39808c2e77b83048b69a9e3015032f43608f55847cfac26a1926ace9b30803d3e3a2593dfd56111203f3f7c562d1df639d57376d1994aff17260cfbfa576bfed870eedf234bec169e2f8e6c44da00000000f82d3b1184dc6c6f444bea666c1b0da5e0d58a4a29b036e6c21d9e26ec349b44000020f82d3b1184dc6c6f444bea666c1b0da5e0d58a4a29b036e6c21d9e26ec349b442048ba30ad4c27e9c0e3b495b609c15987832ab0f4f22d138dbde025c25e500dcf00d5918187a24fbec74eba87813da01d4977383bf90000000000037ffd56fb4e1bfc000d63490001fc000d640300336fd9a1efbd7983dfc291e482862541dd50af197d354fb6b06f9f41e73aef311024f576db99e6c365af4ce6e6ba9ae427611b7164d92adeddc6c7dd308458274be8fddb6b8685d753bb151ebe32a9021fab91228611a81c3c70b287b607a81388b46aabb16518494f9127776600000000f8ef5516cb8f36418e42dc9e078b26b0c4b1b9ad810019974686fb9a6dc88206000020f8ef5516cb8f36418e42dc9e078b26b0c4b1b9ad810019974686fb9a6dc8820620a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e12220b8c3cf751fb6bcf3b11f12e6406cee717c1ad0000000000235a9dcefb4e1ffc000ccadd000000baee5acad0f663430ff83c4e9b9fcb0122789520baee5acad0f663430ff83c4e9b9fcb012278952064f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730015ae7a4f88fd79e4659c4b24b32f24d1e92106b867a2c23d1d084cfedd0e2766edd3f0a77f274acd4d1d53fb1ff021800000000f94177aabacd11c12c92b1d5ec28b8ee9f1c07b220ab783cbf8a1a21cf6a5f55000020f94177aabacd11c12c92b1d5ec28b8ee9f1c07b220ab783cbf8a1a21cf6a5f55202048b7ea90f351d942342361942f53cc52eac2b6d2df7aa5cde9ca4f832e699401ad1d4e86ad3a26c56694ad85fc4e14bb01a0244700000000009de6f7dbfb4e1ffbc8190001fc0001195600365a7fa9a52936ee5272729a4011c8a00c0351d3365a7fa9a52936ee5272729a4011c8a00c0351d3ad1d4e86ad3a26c56694ad85fc4e14bb01a02447309993c900fc49b020d4050981a45281cc71274196c57c9405f7ea8d82823b2cb36c04a2aa363111d74e383bdf9fdfe25400000000f9b4e4b1c35b8890d0ef29ee2c8ba7e600ba9acee68b100d24f4c30f190f07b6000020f9b4e4b1c35b8890d0ef29ee2c8ba7e600ba9acee68b100d24f4c30f190f07b620a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e52b046b8be830ef6606eb16136766fb8f5a378f4ce000000000022dcab9cfb4e1ffc000ccadd000000e148cd41cb7a2aa954707c3a5846ea7927d7c835e148cd41cb7a2aa954707c3a5846ea7927d7c83564f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d7308d4afa904198af1607c56fd3a1e8fa546dd2940e603c87fd64905a5eb86334046a7eb8638e36a2dbdb6ca59fa8e6886400000000fa6350305c1ce0de594787f20ff7ddd0c35a4cbdf10c8a9956d833ab6fdcd225000020fa6350305c1ce0de594787f20ff7ddd0c35a4cbdf10c8a9956d833ab6fdcd22520a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e030254e4408d72c5c1ccad797bc8c1bfd869d91c24000000000023a44db1fb4e1ffc000ccadd0001fc0010e71300ea33f7129398e7e2436a712ab55fa95a2c0e4cc6ea33f7129398e7e2436a712ab55fa95a2c0e4cc664f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73000ea87eef15f38c1a844d77348e687794c601277011c933026cdfdb649524632b055feea3539abc48472cb447d281d6500000000fb1f0a8cd13a1ed6e11d83d906cf3cd42114e36a762e214e04f6f0bfa698dbc2000020fb1f0a8cd13a1ed6e11d83d906cf3cd42114e36a762e214e04f6f0bfa698dbc220a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e1d32db872659af4d0bd7c6f8f7e40f40564c4fcea1000000000022d3c081fb4e1ffc000ccadd000000083a4e9632bcb5c6490a92b3c3b05979bcc866f5083a4e9632bcb5c6490a92b3c3b05979bcc866f564f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73002ce863d0843ca66b4a64d94c0d84ec15980ea04e4444ac4d4188f38cc0da4d6d2360b8a2046725b682862255af6a48c00000000fbdcb8ebb8b7b0536b8af0bd89b5f973fedb880b51d03434767eaf9ea7443bb6000020fbdcb8ebb8b7b0536b8af0bd89b5f973fedb880b51d03434767eaf9ea7443bb620a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e4a999c0b640e64f1d95e90b4e6b75651cd9581d92c000000000036cae7c3fb4e1ffc000ccadd000000982169553d0e618637a1cc6847b185baa50a2ae4982169553d0e618637a1cc6847b185baa50a2ae464f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d73017f2a4f37de1f78a0d356835de99c7639d8daf824b0d432b2a7c01a921f6a8cd4028272e2962f7d04abf9bfd5a77ab8e00000000fc07e381f05476042949b584f41fabd582e6a54d70657b8ff39fce58af62eb53000020fc07e381f05476042949b584f41fabd582e6a54d70657b8ff39fce58af62eb5320a8e7d1287b0354408fda5a65427a636c7c5854a957b94c5f993d727450ffe34e2a473290be126b36c0ebbc0ea853721bc67ea994a80000000000235b9622fb4e1ffc000ccadd0001fc0011030a0087e9edf19d1998903bf17a10a954872f429ced8287e9edf19d1998903bf17a10a954872f429ced8264f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d730090f1ca955443740346b5b4b0bfb8251f040074b5a2feb77e54add831bf34aaf1d84207691f6f5aa5e702152a496fadc00000000fc196382366234f4645215261ca7e62f53499345ec1def69289e47c0c388dc6d000120fc196382366234f4645215261ca7e62f53499345ec1def69289e47c0c388dc6d20151b4f6fbc7351efba1dd1c36c733978a184561af7497b25b4a8a3e0afec0e7f016608134feb91cb878b26b977f1d7983a2f14452a4248000000258b0cf7fb4e1ffc000df5420001fc000df56b00c346a8ffbdcc80462cb69a6f524388a5f496fc6ec9a9263ee8c8c606c449959c48978ba70d4a097bfc86e599d56c282377dd9510ee62c55fefa553b1308d0651a04f9c243872f613901a1eeb2fa86f3e9a65168bc39941790783d9189a9a7876cedb0c6d7ff7d49fbc88a7191100011348d8f97063cf6ff602c14bf59b5ff501c8bbf401fb8f3001fb05a3fcc330b0afdf27d07997b93277a3942e28f7cf4fd043b7ee64b6b5c16173c936000020fcc330b0afdf27d07997b93277a3942e28f7cf4fd043b7ee64b6b5c16173c9362036c97361c1b5b664eeb743d04fcff7282e94a37732b99779d027dfafb030c3fc003d2324a9cadcb2ea6579a7348ab70aa933472bfa41000000000381198efb4e1ffc000541190001fc000541d400e73be15c24f67457c2337a8c99ca1e58aa68598d7200be0fcbcb2c10e968ea0b5508bc3424c9c68bda952b3b45775c0af85fbe2e2ab21549d86beb0a3089aaf743d70a26ecd18aae71d8e2ff0bfc98a51511f83c8acda856e3f5d7c61c21ff4e19a56f02ecfb6ee014097945e300000000fcdeb237fae2e669a85a86e8077e608c6939ef0f4f9e49a44e5ed6795572e6a8000020fcdeb237fae2e669a85a86e8077e608c6939ef0f4f9e49a44e5ed6795572e6a820d3a8d64ff151b1ba13683b26008256b24aacec6f9da5c0066ca64c10a73517ce012c3e80b009a279f6b8cd5db9fb3206f14676366000000000002356861dfb4e1ffc000b9bb301fc000ba63001fc000bd21b0047618a2082ca728a4d9397643a7578a735a44d1b47618a2082ca728a4d9397643a7578a735a44d1b1ec5c66e9789c655ae068d35088b4073345fe0b0308341875737a85768a19cfe8c6c220b594bb18131adfd2fb44e386f7b31253aeeb48140170e29db98507489c7b1f792de00000000fd21cf50c8f2f7e475b7092a5f136129b12d30e9ec98b03614ea0788fae2f888000020fd21cf50c8f2f7e475b7092a5f136129b12d30e9ec98b03614ea0788fae2f88820a8e027adb039814f1d9a37963c233d9d768e2fbe810c79c0818a5fe103a2505c00582f33bc9bb2587d4d87dfbb37d44b1d1c201fe7000000000022dfe2e0fb4e1ffc0006567a01fc00068cf701fc000bd9830055f851335398fd598265dcc41dcbefbc307b609955f851335398fd598265dcc41dcbefbc307b60991ec5c66e9789c655ae068d35088b4073345fe0b030046fe8b4fa7dd4fb52ac2a77b4ef7dcd3f4ee6c940789144504c95390d556eab1ed97db4d9de695796fc0bdbf0543cf700000000fdb15344c0b81fa9204adadf4fbb285a8e57c6079071c1e6134ef1a28ff23630000020fdb15344c0b81fa9204adadf4fbb285a8e57c6079071c1e6134ef1a28ff23630205b016215386c035a42042a93736befccdb87c30cb90adc3b1279da58ac57cc1406928d5d3df4acda874f594b59a88a38052478f10d000000000036b87f1cfb4e1ffc000cf8b101fc000cf98701fc000d0493000453c5b78e603d51a58a56e7a3b6a4bcfa5b1bca0453c5b78e603d51a58a56e7a3b6a4bcfa5b1bcac69a0bda7daaae481be8def95e5f347a1d00a4b4308a1a6b956acbb6cc1c4fc3713ae482d84ac9d3e00ec86ffe25a56a717b748564128c97f38e99bfe7292fd4737ce5299c00000000fef106ff6420f9c6638c9676988a8fc655750caafb506c98cb5ff3d4fea99a41000020fef106ff6420f9c6638c9676988a8fc655750caafb506c98cb5ff3d4fea99a41203933d2e77a9b59df4215597e381942291a23aa6765386dbabb04117c1018988001d5faf54e1d7675b61cd63f569ee38bfaee9501b800000000002d30a810fb4e1ffb3e6401fc000b253301fc000b322c00ce2342a602ce6bd150809591377ecf31971558cace2342a602ce6bd150809591377ecf31971558ca05ea03a6c9dfa67e1837b3c14965ba3cb53bce7230842476e8d82327adfb9b617a7ac3f62868946c0c4b6b0e365747cfb8825b8b79ba0eb1fa62e8583ae7102f59bf70c7c700000000ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9000120ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac920593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0c456ce31778e3778c88a87ac36a1a8bd4aa5bdbe9000000000036bb0ee8fb4e1ffc000cf99e000000b14f661da8227a41acef9f8096df2afd2a192aafb14f661da8227a41acef9f8096df2afd2a192aafc69a0bda7daaae481be8def95e5f347a1d00a4b430967796952922dcc5208a3848ab85a787e4592df2d8ce36a29369b0b3a9576073651075039e1377873aa8c67514ad2726000167e05b1b52c7c896adf20035036fe1d30dcefc9c01fb8f3001fb05a33005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea800012005b687978344fa2433b2aa99d41f643e2d8581a789cdc23084889ceca5244ea820593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c093de7795dfedb896cb65547535ed92f27489d8df3000000000034187ca2fb4e1ffc000cf99e000000ec83a5f23ec17737f590153eb7eed16f7b2f1327ec83a5f23ec17737f590153eb7eed16f7b2f1327c69a0bda7daaae481be8def95e5f347a1d00a4b43080f8efb42f65ed9650078785be5d13e6e90eb9df87a99261d4de34df2b4b79a9c9b8c5e1aec7ac068ebef14636ceac4c00018feb00404d6f765856c95e587b2523a365bc725801fb8f3001fb05a312de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a200012012de3ea6678dadb1db529b7fa98762160625055de2aa34e757c93c136233f4a2206793cf0a4aff111f1d61a13002686c066afbfe5da974cc7dec8cb4cef736dd8000542bd8c9d87e1cdd3db777d29c35e9903b17727a4120000000d4186795fb4e1ffc0010903d0000006e52a40d2dc4dea0ae7ff2b299283de0f2798b0a12deb4ca2b5a05b6eb2ab25bb5fee75d3287b3df0d5bcbeeb459af40f97fcb4a98e9d1ed13e904c8308a3dbdeee728fdec9cea3508c19ece8d2e8330b666e25666b1766ed5f44609dc8674dab4163e8574f4adf2e936a209d501c623e2d926af5eb52dcc2b931993d3e52714511801c1161c96de3dae28cd7f20ff8c2aa7b94b866d7601fb8f3001fb05a3143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113000120143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f11320593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c13838ddf0c05bbc0edebee7e368f4dc6306d524af2000000000023a417f5fb4e1ffc000cf99e0000007395853c0be5fb0f0348aff8128979368f52b0ee7395853c0be5fb0f0348aff8128979368f52b0eec69a0bda7daaae481be8def95e5f347a1d00a4b430b928fa4e127214ccb2b5de1660b5e371d2f3c9845077bc3900fc6aabe82ddd2e61530be3765cea15752e30fc761ab7300001b5f25f8f70cf8d05c2d2970bdf186c994431d84e01fb8f3001fb05a31ba9b400a99c8ab19e2681db0e868814aa273e8eaa13615979a14c50bbd53f4c0001201ba9b400a99c8ab19e2681db0e868814aa273e8eaa13615979a14c50bbd53f4c204c3fd5bb504ca179596113aa8e3e27aa1488860edb81269eb18a9ca900b4a91b017c706d1b78fadb609fd92ff5929901a706c55877000000000058162c0bfb08aefc000cf9830001fc000cf99b00f74034f58c080be74bec51165c5ffe60ed1a615f96375e263814e1d54fc3297fe893dfb5a9c1a9eb6443411c39e405d2520567d4f6b041c5c550086230b006ed30975f322c830001d1b3c2e2f14a4ef35445431356f1c5b93c2eedd9c7ea24c4429d27d45f2fd701733ffd65540001f2dbd9b0a1f541a7c44d34a58674d0262f5feca501fb592501fb592620107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c00012020107ec50e81880dca18178bb7e53e2d0449c0734106a607253b9af2ffea006c20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c117663ee06b0b159308edf41150954372a730aa6a50000000000235515b3fb4e1ffc000cf99e00000004d65ec5142719f58e31f4510dda3c810a84364204d65ec5142719f58e31f4510dda3c810a843642c69a0bda7daaae481be8def95e5f347a1d00a4b430b6e979f20241cbb73de7451779e8e059d9cb75a74b72ea6862d7ac703dc2ac07d86cec39b6e8923b55fd54dbc6177c3a000135d9eb76397d05b43b5cd8da7ccfa8408bc89ab301fb8f3001fb05a32e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb0001202e48651a2e9c0cb4f2fb7ab874061aa4af0cd28b59695631e6a35af3950ef6fb20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0101e19b30edacc8bd047a72d6b12b79b3f1b2babd0000000000369521a7fb4e1ffc000cf99e00000063f16c50b9cd1dccd8465e1802749bd00dd49a2d63f16c50b9cd1dccd8465e1802749bd00dd49a2dc69a0bda7daaae481be8def95e5f347a1d00a4b430943a88959611417f9e8ce4e664e1d9c6a839daae14f54ae8e78bc5ef6ec1524d116efca49ecd5c57dce31d90015a51ff00011ffbf1d32541dcb8f5555305295704a9ff9adc2401fb8f3001fb05a330110b4643c2d8c7521f27ccc2a6a70579bc859087fb95facbb831b3a3d107c700012030110b4643c2d8c7521f27ccc2a6a70579bc859087fb95facbb831b3a3d107c720fbcd42341652da33e977bab8bbef42d0f053f93e9e2748f3f39881d11e28910c017798d43ef1f85193b1a0e5a7ab7853a39d27f0334060000000a6469a72fb4e1ffc000f01930001fc001046630057656569e143ae0cc0419020708c8ce5f4c776e452bfa12608d37422d52423c3a71f9574ffa8267f535e571f5fb89e31f634da8b91769ea4dd252e19308cf6a03c7a0bd8c38c1fc536a013f93afc8224cbfc79d8b0157c7080117ec9c1c60198c3fb3886ec472aeaf80bd5fffc0001c3f93922e89f4bb3869da0c18d8e30dd91019bb101fb669601fb27103971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be10001203971dab9691efac06e4ce7a5483131373e84726458924fe48b7d541791693be120926c6d0e0ce17a51dadcdc5be4f4cce0175d8d7a147e294580e3080d6a22f96d00e5cae595965e89fa9f94152f57b315ca504ee1b300000000005c3fb0cafb4e1ffc0011098b000000b29a8f14049a111260586f489d72cfea1ed8ee5d492df4065de3d5d44692934635d826255f7a60f80e7e48253baecd886fd539601fd5e95efd61534d30b92d4ef819fe283a307e6bcd500d8cd35e9a7b779dbca59bd3bc77b3bb3611c370258aa6dec13d0781e0b53c911bde08000161c274080f47a95be5372ef8c69bb60ab1d4ca8201fb8f3001fb05a339741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a00012039741ad83dd791e1e738f19edae82d6c0322972e6a455981424da3769b3dbd4a20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0826c998cd53845caec6858f3121e5d3a88df6c7a3000000000023a390e6fb4e1ffc000cf99e000000bd9857229d4c0509c753afc85d264fe2e4f344a3bd9857229d4c0509c753afc85d264fe2e4f344a3c69a0bda7daaae481be8def95e5f347a1d00a4b430b6693296894820bdc3c0ae76f357e544847f10a68f0046f53745370dbe861d57e194ddaf7ff7d5e73cc3f240515c448e0001ec7bf3b9bc72eda38c80bb7cf16e294e763e56b401fb8f3001fb05a33979cfb79c4562e819aca69ffae2ea84b9b8f29bd89bdc68be67b88c6f31bf990001203979cfb79c4562e819aca69ffae2ea84b9b8f29bd89bdc68be67b88c6f31bf992067a0592b5510496cb42f2d784cc3b933a0156b10c8b54e440673bb87c57dbb01011353eea2d4fbc06aedc288e493b70de32b3e977f0000000000adc777f2fb4e1ffc000d5e0f0001fc000d5e4b00d8155dce6238737a6af04e068bd92048e68a7f51212e07f7407be541b585ff0a8225fa1afbcc9ac8dc82946c9cee9ab3e8fef5a5d641a57bdf1523c030a73d8c1e640d29e2257042a39bbbac8d867f69ae252e146884816b98ab0d0526ed4992d9cff22ef04878423f66583382000171b5c04007f6af71d99893478feb52df0f5a770101fb592501fb592639b88e537c795f0b093c951539695fd4819a91a542b247ebd3a0ddd6a4c1c43900012039b88e537c795f0b093c951539695fd4819a91a542b247ebd3a0ddd6a4c1c43920bb600d779c7be93a83b9d7878fb38b0b1b7ff1390b231c5da8136b674cde822f01fd9cd0a5165717d4b3a17afddc669f3fd14efbb5000000000082a2e172fb4e1ffc000ddfee0001fc000e0d6b00f5cd552d14676526ef325757eddcfa285b15ac34bf951db34349385992e0303f21fd7240e44e4b0222319c7fcaf88f86259ffd3fa8430e4665f2e1f53090d98ff5c2f2970197ce80ca8cba9431f7dd7cff5d9fc9c4e99c2ed06e598f273d31dad8d8d05655c8b04599495cee2300018e976c7a2f79745d70e41aab1e61cb5f4db4323c01fb682001fb01bb3f43ff3539e5a4fbcc88c7f031a544fe7e62557b5963cb7e43157ef73abfb13d0001203f43ff3539e5a4fbcc88c7f031a544fe7e62557b5963cb7e43157ef73abfb13d20476ad8662b3be5582b98569b76f66d2eecb59a943e9fb28bcbd23a10d53817bb01127e174ed242c758d4db9b7d5b19c1e0743728960000000000b29d5bbcfb4e1ffc000de50401fc000def0c01fc000e366a008ee38b4c9c407b21612862db1ac4e98a6edacb4b62026629f37f587b1dc70ccbc6732225803db4e3ecc3795b4c3e8c5b840dbfa092df1395237f2f8a30980213c5fa8031aff096b8a3eddeefd0584a0e5c2492f631ef67941e082763250e2615975db1f1bfae631f80d41d839a000100120432e9d299caad204ff1ec0c515babddc28601fb8f3001fb05a340784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d00012040784f3f9a761c60156f9244a902c0626f8bc8fe003786c70f1fc6be41da467d20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c02024eb44eadf4a67de93988f1400bfd5fd6fdbf830000000000340ae50bfb4e1ffc000cf99e000000f37ebd7e83f4185ccc5fb617a7ac9e09c11ffc12f37ebd7e83f4185ccc5fb617a7ac9e09c11ffc12c69a0bda7daaae481be8def95e5f347a1d00a4b43082f60dad4b7b498379d1c700da56d4927727eab4387a793b861a96df47bdabe5666c270acf04b5b842ab54045bbf102a00013e8b10646ee9d6c28d75c280b357dd3a9ae9f96201fb8f3001fb05a34bba47ad7330a358cafe2890f1578f874006a68bdc7b786a7c1d440823e683d40001204bba47ad7330a358cafe2890f1578f874006a68bdc7b786a7c1d440823e683d420ca7dbad69767b30fe851c08c80df2cc8398bcc8c33df2d03bcb810485f3d8d31006e6c9189021b6e38326dff6886104054a110990d00000000005fd916b6fb4e1ffc0010871f0001fc0010874300bd8b7dede4dab5e22b84ee0f3dace1c1021add92c9924137fa318dbfca7cabf3a1127fc358acc74d6e6c9189021b6e38326dff6886104054a110990d308ebfddfa72f3140798b6c0d89190164c4dc569ffdd95bd1dd43e7f54f1405c1927b37b499623b4c806ea396bea40a84d0001b98306c317875b12fae8a85c85eb23269168981801fb682301fb01c15b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a230001205b246080ba64350685fe302d3d790f5bb238cb619920d46230c844f079944a2320774441a2d4ff6133747a8bb1b5e4a9a21bb73c4b77cf31e85bda68f898949db0013f978f2c099e310cac9e854b99bc981c8fdcade2000000000023a5327efb4e1ffc000cfb4d000000ebb7d8141ecbdf2abcdc3ebe25420b9425745293ebb7d8141ecbdf2abcdc3ebe25420b9425745293c69a0bda7daaae481be8def95e5f347a1d00a4b430b44cee83a79fa151527e527f3f4f5ba022e73ae8b0d913c4185a45c2a129aef935a585a7a725edcb36ece72a957586880001f460a07a2b0dc932e1d8ff2dee2b984ac415dceb01fb8f3001fb05a35c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef4360001205c6542766615387183715d958a925552472f93335fa1612880423e4bbdaef43620593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0f62555d44fc8d089674bab5d090a48825bea701b700000000002cef2799fb4e1ffc000cf99e0000007ef7c15840f96c603fcd29409a70f77f878d25d87ef7c15840f96c603fcd29409a70f77f878d25d8c69a0bda7daaae481be8def95e5f347a1d00a4b43086d0a2ca6f434eaa47ff6919ecafa4fc3b012b89c62a04835a24c00faf62c3d30d3f8755c33a7abc595e96fb5b79594a0001972a33056d57359de8acfa4fb8b29dc1c14f76b801fb8f3001fb05a36029fadf3355a31c6f841570e76bcdf5636378c65ff1da8f580806602752694b0001206029fadf3355a31c6f841570e76bcdf5636378c65ff1da8f580806602752694b203e14ea3daa62c03d9ed56e8895b5d98188711c49818cd0add43d37fe512c93d1012a5d83dcce0edae361a62d8bc2a308a87e29a49b000000000059a9ab6afb4e1ffc001079fe01fc00107c0e01fc00108203001119c437dbe2c3aeb4a3c7d1e29380738e3372433e443eba6ce82ca15b203d10117c653f26944256cb505749178fb4f731643d9aa56c54e504f9cc6e30a4adf9fa35bc975e52e3f667e48ff3ed7ce71f8ecb85d5ec728596f7fee735c2f857fae1569c8b4c6839ca849cba42d1000197ed64c04be77ef571fd5624c0f7705192630e3a01fb8f3001fb05a36071df1e3bf80ba6cb9795bb2a82ef426cf559b7711e555af45fd8da7fb629b80001206071df1e3bf80ba6cb9795bb2a82ef426cf559b7711e555af45fd8da7fb629b820387368b816ed3599d758185ae60d943afc22201e94e06ffb3dad30a3ddc6756b0005ccc78c0358f7b71d254b28c7287da9b39b81f400000000002d20db70fb4e1ffc000d05b30001fc000d05cb00434dcdb7115427657cf2936248b62a97b9969795ff1266f2c8aa7b1f93a15b8882013af424d7d9e805ccc78c0358f7b71d254b28c7287da9b39b81f430b4e545a909b1916959139eaea845262b0aadec1c5cf555922bb6e6d1804343e6490428a382a0c01832fc70c50438fea6000152cdd176257544a263ecadb986ed72375589a8a401fb682001fb01bb61d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb00012061d33f478933797be4de88353c7c2d843c21310f6d00f6eff31424a756ee7dfb20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c15888380d6096d829d6864cf6eec66812266839e0d0000000000340cb05afb4e1ffc000cf99e000000b5b414e1a68e36a25df214ac6eba35782a0437dab5b414e1a68e36a25df214ac6eba35782a0437dac69a0bda7daaae481be8def95e5f347a1d00a4b430a6a63376eb861bda6afa09e28e39ba40cdfb877ee6f9aace10eaccd4caafe8d9243f2f2c0ef982a0766347073cc199bb00017ada3e486409b39c94a0833c8d782f35bc24e96a01fb8f3001fb05a368512af99ba954cba495e96651a8d730880e21437a873fd9309b54ea9e3b53cc00012068512af99ba954cba495e96651a8d730880e21437a873fd9309b54ea9e3b53cc207459dbe6d9b1930f8d6bf4d0872b2ed6af58baa2f0effe608e6e2ab0c98c148501f30f8dc6c5b956089b30b3dc91867a3b72620b2f0000000000b92f8494fb4e1ffc000faa6501fc000fcdc401fc000fcdec0044b7348492de6612c17d0aff5a3f6fb5f338d57ab2f70938b1cfaba9eab8eee718a48f292e1d5180d86df99cea20e4fadf223310df529ce645f0db2330a28a648ac2b271105426f11a070d3f4854f812c3fd0241860afd511a7ac76e681210505ed41121b141e377a73faaedde0001e33c1f9be807b975c0f5e1c0e3c63175d9e55ea901fb8f3001fb05a36d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e528633209660001206d1b185ba036efcd44a77e05a9aaf69a0c4e40976aec00b04773e5286332096620593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c18a93e60c572add22525a10a5554e6f6a4feca49fe00000000002ce4f2b5fb4e1ffc000cf99e000000f3a83d259634fbfc3e3c4ed50cdcab6598fce20bf3a83d259634fbfc3e3c4ed50cdcab6598fce20bc69a0bda7daaae481be8def95e5f347a1d00a4b430b8a2161c64bfdc7d621df51de569911a219f718bad4d6058dcca9bddf6696d43ddc4c1e3cf91640c93f820e5680efac30001c374f016ea61e76aab79b8bb95a1ba0e6e3eee6f01fb8f3001fb05a37135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf70190001207135069642e1a72807a383fb5a14b9af6758292fee53fe2a7f7ac6f528bf701920593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1063c03764190123b001e65fd3aa12c030df5bde82000000000036bda427fb4e1ffc000cf99e000000b920a2229f777e360b7da76885a556bb439533bfb920a2229f777e360b7da76885a556bb439533bfc69a0bda7daaae481be8def95e5f347a1d00a4b4309472710b11e34dd5f6fa0d43cdde23ddb33558be1539cc7275cf06ba2d82c6ba0c712e7022752843f411e6702eaa736d0001f9956e70daffa263e8cf29fa6557b7b630a595a801fb8f3001fb05a3754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e000120754b89dae8db20fc4cee5e3adb07b146d7efe508a66fa0a8e1094675b9daa35e20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c19ad66f3780f47e83479e1846ecca44d71ba5a902f00000000002ce92c5ffb4e1ffc000cf99e000000e65f1647a5477a20d178b12c509738d7a35ff312e65f1647a5477a20d178b12c509738d7a35ff312c69a0bda7daaae481be8def95e5f347a1d00a4b43099b9f0fbeea3822cdc5b3654dea52103b3d9d5f01db4201955ea3689074d37da4711d8f313d4b5458eef3395aa75bfc7000146d938862af6d9a291e26c0048177db2892a710b01fb8f3001fb05a37718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be42900001207718edad371e46d20fad30086e4acf4a05c2b660df6ae5f2a684aebdf1be429020593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1feea83c4756a349e76b9077636dd04b3306bac60d00000000002ce3894dfb4e1ffc000cf99e000000c0e3581e5165c63790a2b8d2670fb4a1917cd4b8c0e3581e5165c63790a2b8d2670fb4a1917cd4b8c69a0bda7daaae481be8def95e5f347a1d00a4b430b675a1940be872b6a0d4e1696bb39ea38179933a1bae02ae1eaf4b47f625bd939482f8791eb38925af47f73be027a64c00010498ade3c80045c2a7520e921180ae1c39da5c5701fb8f3001fb05a37a1ae04de7582262d9dea3f4d72bc24a474c6f71988066b74a41f17be55526520001207a1ae04de7582262d9dea3f4d72bc24a474c6f71988066b74a41f17be555265220593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1cc1d71953a4a45bd11d458683bbf2ef794d6d6e3d000000000023a612a6fb4e1ffc000cf99e0001fc0010f2fb0063c8d3ed082eb5d476a0940ef9c3fadafc4c5d2c63c8d3ed082eb5d476a0940ef9c3fadafc4c5d2cc69a0bda7daaae481be8def95e5f347a1d00a4b43093943908436a934c08582583b08cbcc50b4478bb79b7718789c25eb0ad2f3e5713ad4c152d4b1fd13cfd12bf896072e600017478cfd163788e3bbe09645776cf59642f28e37901fb8f3001fb05a37e56cc8c37501f3db794a554deb4287ac61c83635a0dec6d0f8e0b54ab14f8cd0001207e56cc8c37501f3db794a554deb4287ac61c83635a0dec6d0f8e0b54ab14f8cd2095f18528a48b7308195ec8201220efaafecfbf4df55cc2c8ab6b518733c22d63010e3edcfe65ca42dccfb1cb826562a46097c6f044412000000022df662bfb4e1ffc001066880001fc00108203006afebaad117b22669d50cf8bffc7863662b1d7e16afebaad117b22669d50cf8bffc7863662b1d7e16c671d1b8ae658d8102e47f0bb3f795482a6e215308156eebd6b52f4146a5b3f9686b9712f48980dfa4e8f17b514ba185a31e8d5fa7568c69aa79d9533fa6efd380c27b0c00001390fef6518c3b4b95551fe1707e0f0c398d5580801fb682001fb01bb85f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82400012085f15a31d3838293a9c1d72a1a0fa21e66110ce20878bd4c1024c4ae1d5be82420593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1aba3f43f7376b9025296fa73a30c07ccf5266eed8000000000036c92083fb4e1ffc000cf99e0000000f89b9ac5ac8f31255f692a3eb0283d0ef3be4360f89b9ac5ac8f31255f692a3eb0283d0ef3be436c69a0bda7daaae481be8def95e5f347a1d00a4b430ac3026b3e3023db1db9ec8e3b7678761820a2a6e96e7a5d9a39b1894170f9cea7765d3d131d60fa9d17492ba560fb1f9000168c506d43816d1a8389c860c1d162be44d1e777c01fb8f3001fb05a387075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891800012087075234ac47353b42bb97ce46330cb67cd4648c01f0b2393d7e729b0d67891820593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c071594bae6e759f13fbc246c11fbd8d97d68911241000000000023a79195fb4e1ffc000cf99e000000762e689e7bfecbe16bfd0e6138eea642ee0513c5762e689e7bfecbe16bfd0e6138eea642ee0513c5c69a0bda7daaae481be8def95e5f347a1d00a4b430a7afe7674de986aff5e2e0a173be8c29abed8b5d6f878389ea18be0d43c62ad1ba66a59e9e8d8453aa0ed1a69697675800019b9cdbfe3568cc0b37f136b00a634c75653f05e301fb8f3001fb05a388251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f00012088251bd4b124efeb87537deabeec54f6c8f575f4df81f10cf5e8eea073092b6f20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c03090aa69c8d1a95839e017d1b2b53d3499fa0a9aa000000000034211c2ffb4e1ffc000cf99e0000000799f054652c1cef10d2994fb83d012d559a1faf0799f054652c1cef10d2994fb83d012d559a1fafc69a0bda7daaae481be8def95e5f347a1d00a4b430af9cd8567923fea3f6e6bbf5e1b3a76bf772f6a3c72b41be15c257af50533b32cc3923cebdeda9fce7a6bc9659123d530001711fd9548ae19b2e91c7a9b4067000467ccdd2b501fb8f3001fb05a38917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f2340001208917bb546318f3410d1a7901c7b846a73446311b5164b45a03f0e613f208f23420593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c21fe8d862d5042691749e866af337e50e599e64fdc0000000000340d8492fb4e1ffc000cf99e00000018d9316618b1f55977af250cc5d8783617084aac18d9316618b1f55977af250cc5d8783617084aacc69a0bda7daaae481be8def95e5f347a1d00a4b43087d25769002af2a4f050127c73fff03a24935e48f34fecaacd69410787d0e6384b345c78e81b1cb397b43dcd635568b600015bdbf34a0dad860c6ec71523ae39373325225cc101fb8f3001fb05a38b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e08150001208b8d1193afd22e538ce0c9fb50fee155d0f6176ca68e65da684c5dce2d1e081520593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0b3fe432c394e3e96e8804a8e059b1887afc913012000000000034229032fb4e1ffc000cf99e000000b802f02882ed36279ba95674e7e190e86bd6458db802f02882ed36279ba95674e7e190e86bd6458dc69a0bda7daaae481be8def95e5f347a1d00a4b430a1749fecb407bb0e0ab9d6df65ea068dba5dc03e14dcb36abe5cb2b5c6e424683f715ff09ce290d035dbb31add0c01800001a0a0e17bfe82a484fefe348b7569a6d77d29d2c201fb8f3001fb05a38de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc40001208de8b12952f7058d827bd04cdff1c2175d87bbf89f28b52452a637bc979addc420593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1dd08fdbbe79813bc43a306740d2182674141d76de0000000000342b56e7fb4e1ffc000cf99e000000300904176cc6023370b2462964c12c5979b9f411300904176cc6023370b2462964c12c5979b9f411c69a0bda7daaae481be8def95e5f347a1d00a4b4309502bb884b3437d65c0e025e49fb00ff6ea9f55d5bcdc36330b46c8bd18be9126b7a6d7f35f558ef8040f2c2284500a50001337b7fb5d2c531825c3e0123ac3354018085b30201fb8f3001fb05a38e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c00001208e11eb784883d3dc9d0d74a74633f067dc61c408dfdee49b8f93bb161f2916c020593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c20f53e3ff160dab7ec3cc2a6b0afa6dd8d36e38794000000000034599a30fb4e1ffc000cf99e0000000063eb51fcfd121e6c3eae23b90b26cd1100217b0063eb51fcfd121e6c3eae23b90b26cd1100217bc69a0bda7daaae481be8def95e5f347a1d00a4b4308160877a911d8bb7d1e75e2320e98cc3233c1f6972cb642424bfcec7c182c56d2c0ebb59e45f788f4d5dbfa2ebff3e3a00016d57707c196e06487d326094c964f258f5b77c3501fb8f3001fb05a38eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f0001208eca4bcbb3a124ab283afd42dad3bdb2077b3809659788a0f1daffce5b9f001f20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0e55b79902ab8dc5c126e61ebd5bdc2ec98d80836600000000003644ebc9fb4e1ffc000cf99e000000983259ad7ed51267fb83a8e41bbaa5ab55c632e1983259ad7ed51267fb83a8e41bbaa5ab55c632e1c69a0bda7daaae481be8def95e5f347a1d00a4b430b942e2e50c5cf9d9fe81119cc5379057c05fe15134f85847356b5d1f6a21f29f4a53f61f03338d056edc15a8c63fbbe80001c075993a8336f93a13bb7bbb7e0e89928be4aafb01fb8f3001fb05a391bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d00012091bbce94c34ebde0d099c0a2cb7635c0c31425ebabcec644f4f1a0854bfa605d20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1eea45a388d248dcd7433c8c8113d5d0966069413500000000003428db29fb4e1ffc000cf99e000000cf83406065cb65ce74100f3c35a0324bfc92dcb0cf83406065cb65ce74100f3c35a0324bfc92dcb0c69a0bda7daaae481be8def95e5f347a1d00a4b43081ad0f9be5a88ae62ff54fe938dfceea71be03bd4c6a7aebf75896e8d495d310acc4146aa4820bc0e5f5b06579dedea5000102aa69f8ef6666e7cad6d9323755a0ef3c1b6bd901fb8f3001fb05a3957acb5bb59e253059da86924b5bbd94c1daf5b0fcd313bdb78e43bdc7cad000000120957acb5bb59e253059da86924b5bbd94c1daf5b0fcd313bdb78e43bdc7cad00020176deee4e53c297f44029a7db294451139901bb49f33a2a0ac8bd1b9e744fee201c406356d37513ea70f93868797061aec981337a700000000002d87b4aafb4e1ffc00102b8501fc0010594501fc0010598300cf0ea50da406da09dd78689abaa7c44aad428e3f37f1afe5852c1aece552ed1be61dc898a8db05f06e0e8a6ca912d408dc8369365e947a41d9d0a9d83098fc5928355798aa9237b107935ba606bd749e16f2922d8c4eb6b6c2cbbb4210f3bad09fe7d199aa3884fae3fce0120d0001a5bf8ff04bf1be7f1d98cb952f1b49f8d162d8a301fb682001fb01bb9712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df540001209712e85d660fa2f761f980ef5812c225f33f336f285728803dcd421937d3df5420593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1277e135a613d9797db4d7a9d2e51bfe8599d3650200000000002352c5c5fb4e1ffc000cf99e00000020c7f1991e06d09b1f067b049fe6d0af0a20f79c20c7f1991e06d09b1f067b049fe6d0af0a20f79cc69a0bda7daaae481be8def95e5f347a1d00a4b430a8dbccb130522909dc710a65728006732c18441757f12a338cf4a6d8cbd5baf1a484537a6a0542f51bb686e6e546f1a00001ed1131823bcea23ac78af8c01e4d24683d6ecf8801fb8f3001fb05a398ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209600012098ef58c338a0a68e4f2f1d1ee9eb05fcafbb9177d192dac0f698d3d9ba09209620593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c178b5541d75eaaa98f8ad22355a122c55741f339f200000000002ce8c406fb4e1ffc000cf99e000000caf6f1b9916245ce300a63fa2254ada25e0423d6caf6f1b9916245ce300a63fa2254ada25e0423d6c69a0bda7daaae481be8def95e5f347a1d00a4b430b6175b59aba8cc0477d4fff78bd90294f31ebd385c39bc254c7995a5dd3ccb8dc1d8869e247bf63bef8ec79317f479a90001d6ece912cbf02627a4efc3dd37e6833cf367155101fb8f3001fb05a39cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c0001209cb04f271ba050132c00cc5838fb69e77bc55b5689f9d2d850dc528935f8145c20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1bbb948d5d33120f51f2ca02c77a0b69761b719f07000000000022d63044fb4e1ffc000cf99e000000c54ac69739bf492d4328f1bf0d49581ce0b10d41c54ac69739bf492d4328f1bf0d49581ce0b10d417ea623bdf8c5607f0390c85586d83d473fa6a1c630b6ee48c7a71a9d8e0813e68ca09846245fa155285f24a62b0ce9cb0102b1994ec58af8ba2a01c09363bdcc395d41f3df000162e960a3f6b650feed98a266b3ccdf6e363562cf01fb8f3001fb05a3b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f000120b3b5748571b60fe9ad112715d6a51725d6e5a52a9c3af5fd36a1724cf50d862f20593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1689fa69f20934cc3ede9dff4589af59c19a14a3f70000000000342b0d5cfb4e1ffc000cf99e000000d57dc73bca0753cbd47bb33f68362ac13e6daeadd57dc73bca0753cbd47bb33f68362ac13e6daeadc69a0bda7daaae481be8def95e5f347a1d00a4b430816ab3f50007333bcb40445130cd0e82139f8c68b592001cd686efc15e303206491fada6cf90af8f24a28b81a9b59ccf000141b308f737ca9e39f67b553158903198a88c516e01fb8f3001fb05a3ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e254216000120ba8ce1dc72857b4168e33272571df7fbaf84c316dfe48217addcf6595e25421620593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c1488164ceb25e5c05e3192511d2be4a5ac103cc5f70000000000342aca80fb4e1ffc000cf99e000000ca94dd35b74cb251457e475dd7507055eaf1b4e1ca94dd35b74cb251457e475dd7507055eaf1b4e1c69a0bda7daaae481be8def95e5f347a1d00a4b430acec7bbead86221590f132810b8262cf98c91b338927907b86bf48baa54dd1912bfc1f6fccd069052cc8c79eb9e8ed2c000162e0104ce0aafc1f06bde37c73702fe84b307f0501fb8f3001fb05a3bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb8000120bbfd0ac1977011267a7032641ef5487fe15a4de798faa485b156fb3b7eb0acb820593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c060d8235767cb55972a30d653eb9dd10f51b3c46ec0000000000235231c4fb4e1ffc000cf99e000000f9b93e179a0c22afd92523427341b5e0b2c2a102f9b93e179a0c22afd92523427341b5e0b2c2a102c69a0bda7daaae481be8def95e5f347a1d00a4b43095c89af86eeacfe403684306c98173c2a59198047a778787887d34ad6b0c9b787d689a7c3cd9e9dd5d103cba70f3855f0001dbbebbc52a5bae21b818e0487311041c91b2683b01fb8f3001fb05a3c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba8000120c11c1168dcf9479475cb1355855e30ea75c0cdda8a8f9ea80591568dd1c33ba820593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c040cb28bcdc1d1a970b6255a04138f84c0ebfa52b6000000000036d5cc55fb4e1ffc000cf99e000000ec040cc1866da3e55c8ae6c0f739cafabe3f5cbaec040cc1866da3e55c8ae6c0f739cafabe3f5cbac69a0bda7daaae481be8def95e5f347a1d00a4b430aa910b9552857a7712d54b468dfcbb7d9e27f26a49e06fb1f0fb00dd0f5a1bf926863c25ad03fd49c56b62065ecd06e70001fdae7cdf38811659ce9481975b326a5d07236bc501fb8f3001fb05a3d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89000120d9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f8920593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0d47eb59e9a49b3794acf272f1bfff17f228291daf00000000002cf06266fb4e1ffc000cf99e0000007334f54da07d3b9e177f6e57c64f97bb0f982caf7334f54da07d3b9e177f6e57c64f97bb0f982cafc69a0bda7daaae481be8def95e5f347a1d00a4b43086108e551691da2642f37b68bcfbc5bbe9984ca51aca15ee24b6fa9b8690ed62c6ed722d091e04ef617cfc99341fd35800017034f0d3853c5351fb8e0ffd3c1daf12c51c2d8901fb8f3001fb05a3ee733db5519c987496eb3b871d5fa543ddb19db3e848f2fbb0af01585fc76af5000120ee733db5519c987496eb3b871d5fa543ddb19db3e848f2fbb0af01585fc76af520f56ac75f5801afb0fbf248e8b39db1dd43a55f1d873beb9674989c51b53d73ee0191be18196047ed60fca300e6fdca0b7bea81beac00000000000238d45dfb4e1ffc000de7c001fc000de9f801fc000f13a3000bf9547a7b4d12def0019da71e989821a60d9c915b44dc4b3f0ed26a8243afa46bada49c18da6b2a21eca01872dbfce4bf20886a004f6caaa69c1ff730b695a4757d60c472f67a7807def81ab7a52dec3bc64aa1c4188d02a4768ac3a862b404f0656ed395f1eb6470dca7bca400018355913e3791438c18b5ac50fe03784df789424101fb8f3001fb05a3f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba7863990381000120f6496d3c0ac1ad94ff5e3aab2edcabc1c8ba3fbfea0ef3026e90ba786399038120593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c050d1611e03249023d89c1ac086036cbea392768cc0000000000340dfab6fb4e1ffc000cf99e0000006cc3fca46aae1c44ea1bab81d506e9f0a3ae1d056cc3fca46aae1c44ea1bab81d506e9f0a3ae1d05c69a0bda7daaae481be8def95e5f347a1d00a4b4308f2df81ba65db70eaab625c5fe46f0f5e52a45b25c761686db23b4f18e547cb0d161912dd187302eb6f7c4a9a666a3230001fe2d4798df3e9b41a6823bc0b3f020478e87925d01fb8f3001fb05a3fc196382366234f4645215261ca7e62f53499345ec1def69289e47c0c388dc6d000120fc196382366234f4645215261ca7e62f53499345ec1def69289e47c0c388dc6d20151b4f6fbc7351efba1dd1c36c733978a184561af7497b25b4a8a3e0afec0e7f016608134feb91cb878b26b977f1d7983a2f14452a4248000000258b0cf7fb4e1ffc000df5420001fc000df56b00c346a8ffbdcc80462cb69a6f524388a5f496fc6ec9a9263ee8c8c606c449959c48978ba70d4a097bfc86e599d56c282377dd9510ee62c55fefa553b1308d0651a04f9c243872f613901a1eeb2fa86f3e9a65168bc39941790783d9189a9a7876cedb0c6d7ff7d49fbc88a7191100011348d8f97063cf6ff602c14bf59b5ff501c8bbf401fb8f3001fb05a3ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac9000120ff261d2c1c76907a2ad8aeb6c5611796f03b5cbd88ae92452a4727e13f4f4ac920593aaec65459ca9a97bd34b2657c8201ae83952d062715ba3af0d4255e54e86c0c456ce31778e3778c88a87ac36a1a8bd4aa5bdbe9000000000036bb0ee8fb4e1ffc000cf99e000000b14f661da8227a41acef9f8096df2afd2a192aafb14f661da8227a41acef9f8096df2afd2a192aafc69a0bda7daaae481be8def95e5f347a1d00a4b430967796952922dcc5208a3848ab85a787e4592df2d8ce36a29369b0b3a9576073651075039e1377873aa8c67514ad2726000167e05b1b52c7c896adf20035036fe1d30dcefc9c01fb8f3001fb05a301fb037f01" +}); diff --git a/packages/rs-drive-abci/tests/strategy_tests/masternode_list_item_helpers.rs b/packages/rs-drive-abci/tests/strategy_tests/masternode_list_item_helpers.rs index c9dbe379d11..8ce224c0073 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/masternode_list_item_helpers.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/masternode_list_item_helpers.rs @@ -35,16 +35,7 @@ impl UpdateMasternodeListItem for MasternodeListItem { 1 => self.state.voting_address = rng.gen::<[u8; 20]>(), 2 => self.state.payout_address = Some(rng.gen::<[u8; 20]>()), 3 => { - let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(rng) - .expect("expected to generate a private key") - .to_bytes() - .to_vec(); - let private_key_operator = BlsPrivateKey::from_be_bytes( - &private_key_operator_bytes - .try_into() - .expect("expected the secret key to be 32 bytes"), - ) - .expect("Core fixture secret key must decode"); + let private_key_operator = BlsPrivateKey::random(&mut *rng); let pub_key_operator = private_key_operator.public_key().to_bytes().to_vec(); self.state.pub_key_operator = pub_key_operator; } @@ -94,16 +85,7 @@ mod tests { let mut rng = StdRng::seed_from_u64(0); let i = 0; let pro_tx_hash = ProTxHash::from_byte_array(rng.gen::<[u8; 32]>()); - let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(&mut rng) - .expect("expected to generate a private key") - .to_bytes() - .to_vec(); - let private_key_operator = BlsPrivateKey::from_be_bytes( - &private_key_operator_bytes - .try_into() - .expect("expected the secret key to be 32 bytes"), - ) - .expect("Core fixture secret key must decode"); + let private_key_operator = BlsPrivateKey::random(&mut rng); let pub_key_operator = private_key_operator.public_key().to_bytes().to_vec(); let masternode_list_item = MasternodeListItem { node_type: MasternodeType::Regular, diff --git a/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs b/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs index 10b786ded31..dd3acf8fd5c 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs @@ -229,16 +229,7 @@ pub fn generate_test_masternodes( } for i in 0..masternode_count { - let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(rng) - .expect("expected to generate a private key") - .to_bytes() - .to_vec(); - let private_key_operator = BlsPrivateKey::from_be_bytes( - &private_key_operator_bytes - .try_into() - .expect("expected the secret key to be 32 bytes"), - ) - .expect("Core fixture secret key must decode"); + let private_key_operator = BlsPrivateKey::random(&mut *rng); let pub_key_operator = private_key_operator.public_key().to_bytes().to_vec(); let pro_tx_hash = ProTxHash::from_byte_array(rng.gen::<[u8; 32]>()); let masternode_list_item = MasternodeListItem { @@ -373,16 +364,7 @@ pub fn generate_test_masternodes( } for i in 0..hpmn_count { - let private_key_operator_bytes = bls_signatures::PrivateKey::generate_dash(rng) - .expect("expected to generate a private key") - .to_bytes() - .to_vec(); - let private_key_operator = BlsPrivateKey::from_be_bytes( - &private_key_operator_bytes - .try_into() - .expect("expected the secret key to be 32 bytes"), - ) - .expect("Core fixture secret key must decode"); + let private_key_operator = BlsPrivateKey::random(&mut *rng); let pub_key_operator = private_key_operator.public_key().to_bytes().to_vec(); let masternode_list_item = MasternodeListItem { node_type: MasternodeType::Evo, From c2f93f2867432d234b39c777a898bd2279753ab3 Mon Sep 17 00:00:00 2001 From: "Claudius the Magnificent AI, on behalf of lklimek" <8431764+Claudius-Maginificent@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:47:47 +0100 Subject: [PATCH 13/26] build!: upgrade Tenderdash to v2.0.0-dev.2 (#5836) Co-authored-by: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- Cargo.lock | 42 ++++++------ packages/dapi-grpc/Cargo.toml | 2 +- .../configs/defaults/getBaseConfigFactory.js | 2 +- .../configs/getConfigFileMigrationsFactory.js | 25 ++++++++ packages/dashmate/docker-compose.yml | 3 +- packages/dashmate/docs/config/tenderdash.md | 2 +- .../dashmate/src/config/configJsonSchema.js | 2 +- .../platform/drive/tenderdash/config.toml.dot | 7 +- .../tenderdashImageMigration.spec.js | 64 ++++++++++++++++--- packages/rs-drive-abci/Cargo.toml | 2 +- .../src/abci/handler/verify_vote_extension.rs | 63 +++++++++++++++++- packages/rs-drive-proof-verifier/Cargo.toml | 2 +- .../transition/asset_lock_submission.rs | 4 +- 13 files changed, 175 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d3f3b9ca61..b98fe562b21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1252,7 +1252,7 @@ version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -2740,7 +2740,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -3895,7 +3895,7 @@ dependencies = [ "libc", "percent-encoding", "pin-project-lite", - "socket2 0.6.4", + "socket2 0.5.10", "system-configuration", "tokio", "tower-service", @@ -4139,7 +4139,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -4926,7 +4926,7 @@ version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -5801,8 +5801,8 @@ version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03da047801ff44bb6a4d407d4860c05fd70bb81714e6b2f3812603d5b145b042" dependencies = [ - "heck 0.5.0", - "itertools 0.14.0", + "heck 0.4.1", + "itertools 0.10.5", "log", "multimap", "petgraph", @@ -5823,7 +5823,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" dependencies = [ "anyhow", - "itertools 0.14.0", + "itertools 0.10.5", "proc-macro2", "quote", "syn 2.0.117", @@ -5836,7 +5836,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" dependencies = [ "anyhow", - "itertools 0.14.0", + "itertools 0.10.5", "proc-macro2", "quote", "syn 2.0.117", @@ -5952,7 +5952,7 @@ dependencies = [ "quinn-udp", "rustc-hash 2.1.2", "rustls", - "socket2 0.6.4", + "socket2 0.5.10", "thiserror 2.0.18", "tokio", "tracing", @@ -5991,7 +5991,7 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.6.4", + "socket2 0.5.10", "tracing", "windows-sys 0.59.0", ] @@ -6805,7 +6805,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -6864,7 +6864,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -7695,13 +7695,13 @@ dependencies = [ "getrandom 0.4.2", "once_cell", "rustix 1.1.4", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] name = "tenderdash-abci" -version = "1.8.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v1.8.1#eebfc46cc64b27022ccbbb3924604dd87a10c340" +version = "2.0.0-dev.2" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v2.0.0-dev.2#80b946ee9c52913608e0423e9cd885a1b76d25bf" dependencies = [ "bytes", "futures", @@ -7721,8 +7721,8 @@ dependencies = [ [[package]] name = "tenderdash-proto" -version = "1.8.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v1.8.1#eebfc46cc64b27022ccbbb3924604dd87a10c340" +version = "2.0.0-dev.2" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v2.0.0-dev.2#80b946ee9c52913608e0423e9cd885a1b76d25bf" dependencies = [ "bytes", "chrono", @@ -7741,8 +7741,8 @@ dependencies = [ [[package]] name = "tenderdash-proto-compiler" -version = "1.8.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v1.8.1#eebfc46cc64b27022ccbbb3924604dd87a10c340" +version = "2.0.0-dev.2" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v2.0.0-dev.2#80b946ee9c52913608e0423e9cd885a1b76d25bf" dependencies = [ "fs_extra", "prost-build", @@ -9140,7 +9140,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] diff --git a/packages/dapi-grpc/Cargo.toml b/packages/dapi-grpc/Cargo.toml index 811ba42861c..84b70e44ddf 100644 --- a/packages/dapi-grpc/Cargo.toml +++ b/packages/dapi-grpc/Cargo.toml @@ -57,7 +57,7 @@ serde = ["dep:serde", "dep:serde_bytes", "tenderdash-proto/serde"] mocks = ["serde", "dep:serde_json"] [dependencies] -tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v1.8.1", default-features = false } +tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v2.0.0-dev.2", default-features = false } prost = { version = "0.14" } futures-core = "0.3.30" diff --git a/packages/dashmate/configs/defaults/getBaseConfigFactory.js b/packages/dashmate/configs/defaults/getBaseConfigFactory.js index c563a92402d..ad7fca223eb 100644 --- a/packages/dashmate/configs/defaults/getBaseConfigFactory.js +++ b/packages/dashmate/configs/defaults/getBaseConfigFactory.js @@ -379,7 +379,7 @@ export default function getBaseConfigFactory() { tenderdash: { mode: 'full', docker: { - image: 'dashpay/tenderdash:1.8', + image: 'dashpay/tenderdash:2.0.0-dev.2', }, p2p: { host: '0.0.0.0', diff --git a/packages/dashmate/configs/getConfigFileMigrationsFactory.js b/packages/dashmate/configs/getConfigFileMigrationsFactory.js index 3edc76275e5..c39baecf0ac 100644 --- a/packages/dashmate/configs/getConfigFileMigrationsFactory.js +++ b/packages/dashmate/configs/getConfigFileMigrationsFactory.js @@ -1899,6 +1899,31 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs) return configFile; }, + // Sorts after every 5.1 prerelease key, so it runs for configs stamped by any 5.1 + // prerelease build. Configs stamped 5.1.0 skip any 5.1 prerelease key added later. + '5.1.0': (configFile) => { + Object.entries(configFile.configs) + .forEach(([, options]) => { + const tenderdash = options.platform?.drive?.tenderdash; + + if (tenderdash?.docker) { + tenderdash.docker.image = base.get('platform.drive.tenderdash.docker.image'); + } + + // Tenderdash 2.0 validates the P2P section on start and refuses to run + // with an empty packet payload or more outgoing than total connections. + const p2p = tenderdash?.p2p; + if (p2p?.maxPacketMsgPayloadSize === 0) { + p2p.maxPacketMsgPayloadSize = getDefaultConfigByNetwork(options.network) + .get('platform.drive.tenderdash.p2p.maxPacketMsgPayloadSize'); + } + if (p2p?.maxOutgoingConnections > p2p?.maxConnections) { + p2p.maxOutgoingConnections = p2p.maxConnections; + } + }); + + return configFile; + }, }; } diff --git a/packages/dashmate/docker-compose.yml b/packages/dashmate/docker-compose.yml index c81076900b9..74c990060a1 100644 --- a/packages/dashmate/docker-compose.yml +++ b/packages/dashmate/docker-compose.yml @@ -131,7 +131,8 @@ services: volumes: - drive_tenderdash:/tenderdash - ${DASHMATE_HOME_DIR:?err}/${CONFIG_NAME:?err}/platform/drive/tenderdash:/tenderdash/config:ro - stop_grace_period: 10s + # Longer than Tenderdash's 30s --shutdown-timeout, so cleanup can finish before SIGKILL. + stop_grace_period: 40s profiles: - platform diff --git a/packages/dashmate/docs/config/tenderdash.md b/packages/dashmate/docs/config/tenderdash.md index 21f1fbd4d0c..0a8eb49161d 100644 --- a/packages/dashmate/docs/config/tenderdash.md +++ b/packages/dashmate/docs/config/tenderdash.md @@ -18,7 +18,7 @@ Tenderdash can operate in different modes depending on the node's role in the ne | Option | Description | Default | Example | |--------|-------------|---------|---------| -| `platform.drive.tenderdash.docker.image` | Docker image for Tenderdash | `dashpay/tenderdash:1.8` | `dashpay/tenderdash:latest` | +| `platform.drive.tenderdash.docker.image` | Docker image for Tenderdash | `dashpay/tenderdash:2.0.0-dev.2` | `dashpay/tenderdash:latest` | ## P2P diff --git a/packages/dashmate/src/config/configJsonSchema.js b/packages/dashmate/src/config/configJsonSchema.js index 66cddade75a..0185e381014 100644 --- a/packages/dashmate/src/config/configJsonSchema.js +++ b/packages/dashmate/src/config/configJsonSchema.js @@ -1169,7 +1169,7 @@ export default { }, maxPacketMsgPayloadSize: { type: 'integer', - minimum: 0, + minimum: 1, }, sendRate: { type: 'integer', diff --git a/packages/dashmate/templates/platform/drive/tenderdash/config.toml.dot b/packages/dashmate/templates/platform/drive/tenderdash/config.toml.dot index 220f84df843..9a5194a6e7b 100644 --- a/packages/dashmate/templates/platform/drive/tenderdash/config.toml.dot +++ b/packages/dashmate/templates/platform/drive/tenderdash/config.toml.dot @@ -541,14 +541,9 @@ unsafe-vote-timeout-delta-override = "{{= it.platform.drive.tenderdash.consensus # Options: # 1) "null" (default) - no indexer services. # 2) "kv" - a simple indexer backed by key-value storage (see DBBackend) -# 3) "psql" - the indexer services backed by PostgreSQL. -# When "kv" or "psql" is chosen "tx.height" and "tx.hash" will always be indexed. +# When "kv" is chosen "tx.height" and "tx.hash" will always be indexed. indexer = ["kv"] -# The PostgreSQL connection configuration, the connection format: -# postgresql://:@:/? -psql-conn = "" - ####################################################### ### Instrumentation Configuration Options ### ####################################################### diff --git a/packages/dashmate/test/unit/config/configFile/tenderdashImageMigration.spec.js b/packages/dashmate/test/unit/config/configFile/tenderdashImageMigration.spec.js index c93aa55fa9e..f460523d587 100644 --- a/packages/dashmate/test/unit/config/configFile/tenderdashImageMigration.spec.js +++ b/packages/dashmate/test/unit/config/configFile/tenderdashImageMigration.spec.js @@ -1,29 +1,36 @@ import fs from 'fs'; import path from 'path'; import getBaseConfigFactory from '../../../../configs/defaults/getBaseConfigFactory.js'; +import getLocalConfigFactory from '../../../../configs/defaults/getLocalConfigFactory.js'; import getConfigFileMigrationsFactory from '../../../../configs/getConfigFileMigrationsFactory.js'; +import InvalidOptionError from '../../../../src/config/errors/InvalidOptionError.js'; import getConfigFormatVersion from '../../../../src/config/configFile/getConfigFormatVersion.js'; import migrateConfigFileFactory from '../../../../src/config/configFile/migrateConfigFileFactory.js'; import { PACKAGE_ROOT_DIR } from '../../../../src/constants.js'; describe('Tenderdash image migration', () => { const { version } = JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT_DIR, 'package.json'), 'utf8')); - const base = getBaseConfigFactory()(); - const defaults = new Map(['base', 'mainnet', 'testnet'].map((name) => [name, base])); + const getBaseConfig = getBaseConfigFactory(); + const base = getBaseConfig(); + const local = getLocalConfigFactory(getBaseConfig)(); + const defaults = new Map([ + ...['base', 'mainnet', 'testnet'].map((name) => [name, base]), + ['local', local], + ]); const getMigrations = getConfigFileMigrationsFactory(null, defaults); const migrateConfigFile = migrateConfigFileFactory(getMigrations); - it('should use the floating 1.8 tag for new configurations', () => { - expect(base.get('platform.drive.tenderdash.docker.image')).to.equal('dashpay/tenderdash:1.8'); + it('should use the Tenderdash 2.0.0-dev.2 image for new configurations', () => { + expect(base.get('platform.drive.tenderdash.docker.image')).to.equal('dashpay/tenderdash:2.0.0-dev.2'); }); - for (const fromVersion of ['4.2.0-dev.1', '4.2.0-beta.3']) { + for (const fromVersion of ['4.2.0-dev.1', '4.2.0-beta.3', '5.0.0-rc.3', '5.0.3']) { it(`should migrate pinned images from config format ${fromVersion}`, () => { const configFileData = { configFormatVersion: fromVersion, configs: { - mainnet: { platform: { drive: { tenderdash: { docker: { image: 'dashpay/tenderdash:1.8.0' } } } } }, - testnet: { platform: { drive: { tenderdash: { docker: { image: 'dashpay/tenderdash:1.7' } } } } }, + mainnet: { platform: { drive: { tenderdash: { docker: { image: 'dashpay/tenderdash:1.8' } } } } }, + testnet: { platform: { drive: { tenderdash: { docker: { image: 'dashpay/tenderdash:1.8.2' } } } } }, withoutPlatform: {}, withoutDocker: { platform: { drive: { tenderdash: {} } } }, }, @@ -33,7 +40,7 @@ describe('Tenderdash image migration', () => { for (const name of ['mainnet', 'testnet']) { expect(migrated.configs[name].platform.drive.tenderdash.docker.image) - .to.equal('dashpay/tenderdash:1.8'); + .to.equal('dashpay/tenderdash:2.0.0-dev.2'); } expect(migrated.configs.withoutPlatform).to.deep.equal({}); expect(migrated.configs.withoutDocker).to.deep.equal({ @@ -46,4 +53,45 @@ describe('Tenderdash image migration', () => { expect(migrateConfigFile(migrated, migrated.configFormatVersion, version)).to.equal(migrated); }); } + + describe('P2P settings Tenderdash 2.0 refuses to start with', () => { + function migrateP2p(configs) { + return migrateConfigFile({ configFormatVersion: '5.0.3', configs }, '5.0.3', version).configs; + } + + function p2pConfig(network, p2p) { + return { network, platform: { drive: { tenderdash: { docker: {}, p2p } } } }; + } + + it('should reject a zero maxPacketMsgPayloadSize', () => { + const config = getBaseConfig(); + + expect(() => config.set('platform.drive.tenderdash.p2p.maxPacketMsgPayloadSize', 0)) + .to.throw(InvalidOptionError); + }); + + it('should reset a zero maxPacketMsgPayloadSize to the network default', () => { + const configs = migrateP2p({ + mainnet: p2pConfig('mainnet', { maxPacketMsgPayloadSize: 0 }), + local: p2pConfig('local', { maxPacketMsgPayloadSize: 0 }), + custom: p2pConfig('testnet', { maxPacketMsgPayloadSize: 4096 }), + }); + + expect(configs.mainnet.platform.drive.tenderdash.p2p.maxPacketMsgPayloadSize).to.equal(10240); + expect(configs.local.platform.drive.tenderdash.p2p.maxPacketMsgPayloadSize).to.equal(1024); + expect(configs.custom.platform.drive.tenderdash.p2p.maxPacketMsgPayloadSize).to.equal(4096); + }); + + it('should cap maxOutgoingConnections at maxConnections', () => { + const configs = migrateP2p({ + above: p2pConfig('mainnet', { maxConnections: 20, maxOutgoingConnections: 30 }), + equal: p2pConfig('mainnet', { maxConnections: 30, maxOutgoingConnections: 30 }), + below: p2pConfig('mainnet', { maxConnections: 64, maxOutgoingConnections: 30 }), + }); + + expect(configs.above.platform.drive.tenderdash.p2p.maxOutgoingConnections).to.equal(20); + expect(configs.equal.platform.drive.tenderdash.p2p.maxOutgoingConnections).to.equal(30); + expect(configs.below.platform.drive.tenderdash.p2p.maxOutgoingConnections).to.equal(30); + }); + }); }); diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index bd7ecc81a38..082df27f017 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -51,7 +51,7 @@ tracing-subscriber = { version = "0.3.22", default-features = false, features = "registry", "tracing-log", ], optional = false } -tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v1.8.1", features = [ +tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v2.0.0-dev.2", features = [ "grpc", ] } time = { version = "0.3", optional = true, features = [ diff --git a/packages/rs-drive-abci/src/abci/handler/verify_vote_extension.rs b/packages/rs-drive-abci/src/abci/handler/verify_vote_extension.rs index ce15941e3ae..2a14e9df7e0 100644 --- a/packages/rs-drive-abci/src/abci/handler/verify_vote_extension.rs +++ b/packages/rs-drive-abci/src/abci/handler/verify_vote_extension.rs @@ -8,7 +8,9 @@ use tenderdash_abci::proto::abci::response_verify_vote_extension::VerifyStatus; /// transactions this node built for the same block. /// /// Tenderdash asks about every non-nil precommit of another validator at the height it is -/// deciding, whatever the round, and drops the vote when it is rejected. +/// deciding, whatever the round, and drops the vote when it is rejected. It also asks about a +/// commit's threshold-recovered extensions, with an empty `validator_pro_tx_hash`, after +/// `process_proposal` of the committed block; a rejection there halts block replay and sync. pub fn verify_vote_extension( app: &A, request: proto::RequestVerifyVoteExtension, @@ -136,6 +138,27 @@ mod tests { .status } + /// A commit's extension vector, as Tenderdash sends it after `process_proposal` of the + /// committed block: no validator, the commit round, only threshold-recoverable extensions. + fn verify_commit( + app: &FullAbciApplication, + round: u32, + block_hash: [u8; 32], + vote_extensions: Vec, + ) -> i32 { + let request = proto::RequestVerifyVoteExtension { + hash: block_hash.to_vec(), + validator_pro_tx_hash: vec![], + height: HEIGHT as i64, + round: round as i32, + vote_extensions, + }; + + verify_vote_extension::<_, MockCoreRPCLike>(app, request) + .expect("verification answers with a status") + .status + } + /// Round 0 accepted at `HEIGHT`, at `ROUND_0_CORE_HEIGHT` fn accept_round_0(app: &FullAbciApplication) { app.unsigned_withdrawal_txs_by_round @@ -348,4 +371,42 @@ mod tests { VerifyStatus::Reject as i32 ); } + + /// Tenderdash verifies a commit's extensions before it finalizes the block, also during + /// block sync and replay, and halts on a rejection. + #[test] + fn should_accept_the_extensions_of_a_commit_of_an_accepted_block() { + let platform = platform(); + let app = FullAbciApplication::::new(&platform.platform); + accept_round_0(&app); + accept_round_1(&app); + + assert_eq!( + verify_commit(&app, 1, ROUND_1_BLOCK, round_1_extensions()), + VerifyStatus::Accept as i32 + ); + assert_eq!( + verify_commit(&app, 0, ROUND_0_BLOCK, round_0_extensions()), + VerifyStatus::Accept as i32 + ); + assert_eq!( + verify_commit(&app, 1, ROUND_1_BLOCK, round_0_extensions()), + VerifyStatus::Reject as i32 + ); + } + + #[test] + fn should_accept_the_empty_extensions_of_a_commit_without_withdrawals() { + let platform = platform(); + let app = FullAbciApplication::::new(&platform.platform); + app.unsigned_withdrawal_txs_by_round + .write() + .unwrap() + .insert(HEIGHT, 0, ROUND_0_BLOCK, vec![]); + + assert_eq!( + verify_commit(&app, 0, ROUND_0_BLOCK, vec![]), + VerifyStatus::Accept as i32 + ); + } } diff --git a/packages/rs-drive-proof-verifier/Cargo.toml b/packages/rs-drive-proof-verifier/Cargo.toml index 03a7fb1fad1..25a03e7b684 100644 --- a/packages/rs-drive-proof-verifier/Cargo.toml +++ b/packages/rs-drive-proof-verifier/Cargo.toml @@ -34,7 +34,7 @@ dash-context-provider = { path = "../rs-context-provider", features = [ bincode = { workspace = true, features = ["serde"] } platform-serialization-derive = { path = "../rs-platform-serialization-derive", optional = true } platform-serialization = { path = "../rs-platform-serialization" } -tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v1.8.1", features = [ +tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v2.0.0-dev.2", features = [ "crypto", ], default-features = false } tracing = { version = "0.1.41" } diff --git a/packages/rs-sdk/src/platform/transition/asset_lock_submission.rs b/packages/rs-sdk/src/platform/transition/asset_lock_submission.rs index 457250c8a45..1c534048795 100644 --- a/packages/rs-sdk/src/platform/transition/asset_lock_submission.rs +++ b/packages/rs-sdk/src/platform/transition/asset_lock_submission.rs @@ -259,8 +259,8 @@ fn encoded_len(proof: &AssetLockProof) -> Option { /// Each retry bumps `settings.user_fee_increase` so the resubmitted ST /// hashes differently — Tenderdash caches rejected ST hashes for ~24h /// on mainnet/testnet (`keep-invalid-txs-in-cache = true`), so an -/// identical-bytes resubmit would be silently dropped before reaching -/// Platform's CheckTx. +/// identical-bytes resubmit would get the cached CheckTx rejection back +/// without reaching Platform's CheckTx again. /// /// **Retry scope.** This wrapper retries ONLY consensus code 10506 /// (CL-height-too-low). Every other `Error` — including From e2785b6df53315b20e8c528e5caebcb83e58b64f Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Fri, 13 Nov 2026 11:34:57 +0100 Subject: [PATCH 14/26] chore: pin rust-dashcore to dev with the collateral lock merged Moves the pin from the branch of rust-dashcore#1391 to `dev` at d659dcd1, which carries #1391 and #1400 (public `masternode_collateral` and `holds_coin`). The pin is no longer on a PR branch. Co-Authored-By: Claude Fable 5.2 --- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 16 ++++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d23d0a1e9b..2e414e072d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1776,7 +1776,7 @@ dependencies = [ [[package]] name = "dash-network" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" dependencies = [ "dash-params", "grovedb-bincode", @@ -1787,7 +1787,7 @@ dependencies = [ [[package]] name = "dash-network-seeds" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" dependencies = [ "dash-network", ] @@ -1961,7 +1961,7 @@ dependencies = [ [[package]] name = "dash-spv" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" dependencies = [ "async-trait", "bip324", @@ -2008,7 +2008,7 @@ dependencies = [ [[package]] name = "dashcore" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" dependencies = [ "anyhow", "base64 0.23.1", @@ -2034,7 +2034,7 @@ dependencies = [ [[package]] name = "dashcore-crypto" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" dependencies = [ "base58ck", "bitcoin-crypto", @@ -2056,12 +2056,12 @@ dependencies = [ [[package]] name = "dashcore-private" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" [[package]] name = "dashcore-rpc" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" dependencies = [ "dashcore-rpc-json", "hex-conservative 1.3.0", @@ -2074,7 +2074,7 @@ dependencies = [ [[package]] name = "dashcore-rpc-json" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" dependencies = [ "dashcore", "grovedb-bincode", @@ -2089,7 +2089,7 @@ dependencies = [ [[package]] name = "dashcore_hashes" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" dependencies = [ "bitcoin_hashes 1.2.0", "dash-pow", @@ -3188,7 +3188,7 @@ dependencies = [ [[package]] name = "git-state" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" [[package]] name = "glob" @@ -4416,7 +4416,7 @@ dependencies = [ [[package]] name = "key-wallet" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" dependencies = [ "async-trait", "bip39 3.0.0", @@ -4437,7 +4437,7 @@ dependencies = [ [[package]] name = "key-wallet-manager" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e#2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" dependencies = [ "async-trait", "dashcore", diff --git a/Cargo.toml b/Cargo.toml index e8ae7b198c1..1bb21e55696 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,14 +70,14 @@ grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb grovedb-version = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb7cdc19f5977d64f20f93107f62844b1" } grovedb-epoch-based-storage-flags = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb7cdc19f5977d64f20f93107f62844b1" } grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb7cdc19f5977d64f20f93107f62844b1" } -dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } -dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } -dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } -key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } -key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } -dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } -dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } -dashcore-crypto = { git = "https://github.com/dashpay/rust-dashcore", rev = "2cdb0d6f6bc3a402a9fee475bccd59a05b8ddd8e" } +dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } +dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } +dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } +key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } +key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } +dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } +dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } +dashcore-crypto = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } tokio-metrics = "0.5" # Size-tuned profile for the iOS `rs-unified-sdk-ffi` staticlib, which From e0f5d97bea3b7cacadc54a4398984ef3f0bc2771 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Fri, 13 Nov 2026 11:34:58 +0100 Subject: [PATCH 15/26] refactor(platform-wallet): use key-wallet's collateral helpers Drops the local copies of `masternode_collateral` and `holds_coin` now that key-wallet exports them. The wallet's own rule also counts a coin kept aside as spent, so a tracked collateral whose spend a fork drops is recognised as held. Co-Authored-By: Claude Fable 5.2 --- .../src/wallet/outpoint_locks.rs | 35 +++---------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs index 528a3e052af..56d2ace0372 100644 --- a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs +++ b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs @@ -62,10 +62,10 @@ use std::collections::{BTreeMap, BTreeSet}; use std::sync::Arc; -use dashcore::blockdata::transaction::special_transaction::TransactionPayload; use dashcore::{OutPoint, Transaction, Txid}; use key_wallet::managed_account::transaction_record::TransactionRecord; use key_wallet::transaction_checking::account_checker::TransactionCheckResult; +use key_wallet::wallet::managed_wallet_info::masternode_collateral; use key_wallet_manager::WalletManager; use tokio::sync::RwLock; @@ -73,23 +73,6 @@ use crate::changeset::{CoreChangeSet, PlatformWalletChangeSet, PlatformWalletPer use crate::error::PlatformWalletError; use crate::wallet::platform_wallet::{PlatformWallet, PlatformWalletInfo, WalletId}; -/// The collateral `tx` registers when it is a ProRegTx: the outpoint its -/// payload names, or, when that names a null txid, the ProRegTx's own output -/// at that index. `None` for any other transaction, and for an own-output -/// index past the outputs (such a registration names no coin). -pub(crate) fn registration_collateral(tx: &Transaction) -> Option { - let Some(TransactionPayload::ProviderRegistrationPayloadType(registration)) = - &tx.special_transaction_payload - else { - return None; - }; - let named = registration.collateral_outpoint; - if named.txid != Txid::all_zeros() { - return Some(named); - } - ((named.vout as usize) < tx.output.len()).then(|| OutPoint::new(tx.txid(), named.vout)) -} - /// The collaterals that the masternode registrations among `records` keep /// out of coin selection. /// @@ -103,7 +86,7 @@ pub fn registered_collaterals<'a>( records .into_iter() .filter_map(|record| { - let collateral = registration_collateral(&record.transaction)?; + let collateral = masternode_collateral(&record.transaction)?; let creates_it = collateral.txid == record.txid; (creates_it || record.is_confirmed()).then_some(collateral) }) @@ -238,7 +221,7 @@ impl PlatformWalletInfo { pub(crate) fn track_collaterals(&mut self, collaterals: &BTreeSet) -> Vec { let mut held = Vec::new(); for outpoint in collaterals { - if self.tracked_collaterals.insert(*outpoint) && self.holds_coin(outpoint) { + if self.tracked_collaterals.insert(*outpoint) && self.core_wallet.holds_coin(outpoint) { held.push(*outpoint); } } @@ -265,7 +248,7 @@ impl PlatformWalletInfo { let arrived: Vec = self .tracked_collaterals .iter() - .filter(|outpoint| outpoint.txid == txid && self.holds_coin(outpoint)) + .filter(|outpoint| outpoint.txid == txid && self.core_wallet.holds_coin(outpoint)) .copied() .collect(); for outpoint in arrived { @@ -277,16 +260,6 @@ impl PlatformWalletInfo { } } - /// Whether a funds account of this wallet holds `outpoint` as an unspent - /// coin. - fn holds_coin(&self, outpoint: &OutPoint) -> bool { - self.core_wallet - .accounts - .all_funding_accounts() - .iter() - .any(|account| account.utxos.contains_key(outpoint)) - } - /// Lock `outpoints`, mirror the balance to the UI when any lock was /// added, and return the ones that were not locked before. fn lock_and_publish(&mut self, outpoints: impl IntoIterator) -> Vec { From e603d8a371481b4f1432f0a107dfbe3f60275121 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Fri, 13 Nov 2026 18:00:14 +0700 Subject: [PATCH 16/26] fix: move mobile document erase decisions into the Rust wallet (#5907) --- Cargo.lock | 1 + .../kotlin-sdk/KotlinExampleApp/TEST_PLAN.md | 2 +- .../ui/contracts/DocumentActionsScreen.kt | 95 +- .../ui/contracts/EraseAndDescribeTest.kt | 145 +- .../dashfoundation/dashsdk/FfiSmokeTest.kt | 12 + .../dashsdk/documents/DocumentEraseOutcome.kt | 64 + .../dashsdk/documents/DocumentTransactions.kt | 43 +- .../dashsdk/ffi/TransactionsNative.kt | 18 +- .../dashsdk/queries/DocumentHistory.kt | 2 +- .../dashsdk/queries/PlatformQueries.kt | 5 +- .../documents/DocumentEraseOutcomeTest.kt | 73 + .../document_erase_outcome_from_native.json | 1 + .../rs-platform-wallet-ffi/src/document.rs | 387 ++++- .../src/document/erase_tests.rs | 241 +++ packages/rs-platform-wallet-ffi/src/error.rs | 3 + packages/rs-platform-wallet/src/error.rs | 3 + .../src/wallet/identity/network/document.rs | 2 +- .../wallet/identity/network/document_erase.rs | 1454 +++++++++++++++++ .../identity/network/dpns_marketplace.rs | 1 + .../identity/network/identity_handle.rs | 3 + .../wallet/identity/network/key_selection.rs | 4 +- .../src/wallet/identity/network/mod.rs | 5 + .../src/wallet/identity/network/payments.rs | 3 + .../src/wallet/platform_wallet.rs | 1 + packages/rs-sdk-ffi/src/document/erase.rs | 49 +- .../src/document/queries/history.rs | 32 + packages/rs-sdk/src/error.rs | 2 +- packages/rs-sdk/src/platform/query.rs | 52 +- packages/rs-unified-sdk-jni/Cargo.toml | 5 +- .../rs-unified-sdk-jni/src/transactions.rs | 181 +- .../FFI/PlatformQueryExtensions.swift | 15 + .../FFI/StateTransitionExtensions.swift | 97 -- .../PlatformWallet/DocumentEraseOutcome.swift | 62 + .../ManagedPlatformWallet.swift | 75 +- .../SwiftExampleApp/Views/DocumentsView.swift | 97 +- .../Views/TransitionDetailView.swift | 96 +- .../swift-sdk/SwiftExampleApp/TEST_PLAN.md | 2 +- .../DocumentHistoryLifecycleTests.swift | 33 + .../scripts/test_document_erase_preflight.py | 178 +- 39 files changed, 2851 insertions(+), 693 deletions(-) create mode 100644 packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/documents/DocumentEraseOutcome.kt create mode 100644 packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/documents/DocumentEraseOutcomeTest.kt create mode 100644 packages/kotlin-sdk/sdk/src/test/resources/document_erase_outcome_from_native.json create mode 100644 packages/rs-platform-wallet-ffi/src/document/erase_tests.rs create mode 100644 packages/rs-platform-wallet/src/wallet/identity/network/document_erase.rs create mode 100644 packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/DocumentEraseOutcome.swift diff --git a/Cargo.lock b/Cargo.lock index b98fe562b21..8203d55cf02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6679,6 +6679,7 @@ dependencies = [ "log", "platform-wallet-ffi", "rs-sdk-ffi", + "serde_json", "zeroize", ] diff --git a/packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md b/packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md index 9f3a6548066..0a276aa692c 100644 --- a/packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md +++ b/packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md @@ -211,7 +211,7 @@ Most Platform actions have hard preconditions. Establish these fixtures before s | DOC-13 | Aggregation — sum of a numeric property | Platform | Uncommon | 🧪 | | **Sum / Average Documents** screen (op selector → **Sum**) → `dash_sdk_document_sum`. | | DOC-14 | Aggregation — average of a numeric property | Platform | Uncommon | 🧪 | | Same screen (op selector → **Average**) → `dash_sdk_document_average`. | | DOC-15 | Document transfer / purchase across wallets | Platform | Uncommon | ✅ | multiwallet | A creates + lists a document (`DOC-02`/`DOC-06`); B transfers/purchases it (`DOC-05`/`DOC-07`). | -| DOC-16 | Erase a deleted keep-history document's revisions | Platform | Thorough | 🧪 | | **Browse Documents** → document → **Actions…** → **Erase Document…** (or the **Erase Document** catalog entry) → `DocumentTransactions.erase` → `platform_wallet_document_erase`. Needs a `documentsKeepHistory` type with `canBeErased: true` and a document already deleted via `DOC-04`; the first erase must be signed by the owner, later ones by any identity, each removing up to 100 revisions. Not driven on a device; no such type exists on testnet yet. | +| DOC-16 | Erase a deleted keep-history document's revisions | Platform | Thorough | 🧪 | | Route: **Browse Documents** → document → **Actions…** → **Erase Document…** (or the **Erase Document** catalog entry). The erase form calls the Rust wallet read/decide/select/submit/observe operation through `platform_wallet_document_erase_and_observe`. Rust loads the real contract, rejects ineligible types, skips ACTIVE/ABSENT, and submits nothing when the preflight/ownership read is unavailable. DELETED requires the newest retained revision's owner; ERASING accepts any submitting identity. Keys are selected in Rust using the actual requirement, contract bounds, expiry and supplied signer. A closing-read failure remains a submitted result with unavailable progress; outcome-unknown errors require reading history before any manual retry. Each call submits at most one chunk and never retries automatically. Display skipped/submitted reasons, remaining revisions and cautious progress wording. Needs an erasable keep-history type; not driven on a device or a live provider. | ### 4.8 Tokens — `Domain=Token` diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/DocumentActionsScreen.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/DocumentActionsScreen.kt index fdccdbda59f..3d78aea35cf 100644 --- a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/DocumentActionsScreen.kt +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/DocumentActionsScreen.kt @@ -35,14 +35,14 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavHostController -import kotlinx.coroutines.CancellationException import kotlinx.coroutines.delay import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.jsonObject +import org.dashfoundation.dashsdk.documents.DocumentEraseOutcome +import org.dashfoundation.dashsdk.documents.DocumentEraseNotSubmittedReason +import org.dashfoundation.dashsdk.errors.DashSdkError import org.dashfoundation.dashsdk.persistence.entities.IdentityEntity -import org.dashfoundation.dashsdk.queries.DocumentLifecycle -import org.dashfoundation.dashsdk.queries.DocumentLifecycleState import org.dashfoundation.dashsdk.queries.describeEraseProgress import org.dashfoundation.example.di.LocalAppContainer import org.dashfoundation.example.di.LocalAppState @@ -63,7 +63,7 @@ import org.dashfoundation.example.util.truncateMiddle * Owned-document actions for one document — the DOC-03 replace / DOC-04 * delete / DOC-05 transfer flows the iOS document ops menu ships, plus the * erase (`ManagedPlatformWallet.replaceDocument` / `deleteDocument` / - * `eraseDocument` / `transferDocument`). Reached from a document row's + * `eraseDocumentAndObserve` / `transferDocument`). Reached from a document row's * "Actions…" button and from the document replace/delete/erase/transfer * transition-catalog entries. * @@ -501,10 +501,9 @@ fun DocumentActionsScreen( } // ── Erase ───────────────────────────────────────────────────── - // A deleted document is invisible to the probe above, so the - // erase cannot be ownership-gated here; consensus refuses a - // first erase from anyone but the owner (a paid rejection) and - // accepts later ones from any identity. + // The probe above is for presentation. Rust checks the newest + // retained owner before starting erasure of a deleted document; + // any submitting identity may continue an erasing document. FormSection(title = "Erase") { Text( "Remove the retained revisions of a document that has already " + @@ -676,23 +675,25 @@ fun DocumentActionsScreen( fail = { error = it }, scope = scope, ) { - val (wallet, mgr, signingKeyId) = resolveSigning(container, signer) - val docIdB58 = Base58.encode(docIdBytes) - eraseSuccess = eraseAndDescribe( - readLifecycle = { - sdk?.documents?.lifecycle(contractIdBase58, typeName, docIdB58) - }, - ) { - mgr.documentTransactions.erase( - walletHandle = wallet, - ownerId = signer.identityId, + val mgr = container.walletManagerStore.activeManager.value + ?: throw IllegalStateException("Wallet manager not active") + val wallet = signer.walletId?.toHex()?.let { mgr.wallets.value[it] } + ?: throw IllegalStateException("Identity has no loaded wallet linkage; cannot erase document history") + val outcome = try { + mgr.documentTransactions.eraseAndObserve( + walletHandle = wallet.handle, + submittingIdentityId = signer.identityId, contractId = contractIdBytes, documentType = typeName, documentId = docIdBytes, - signingKeyId = signingKeyId, signerHandle = mgr.signerHandle, ) + } catch (e: DashSdkError.PlatformWallet.TransactionBroadcastUnconfirmed) { + throw IllegalStateException( + "Erase outcome unknown; do not resubmit automatically; read history first.", e, + ) } + eraseSuccess = describeEraseOutcome(outcome) } }, modifier = Modifier.testTag("eraseDocument.confirm"), @@ -707,51 +708,19 @@ fun DocumentActionsScreen( ErrorAlertDialog(message = error, onDismiss = { error = null }) } -/** - * Submit the erase, then say what it achieved, from the lifecycle read before - * it and the one read after. Extracted from [DocumentActionsScreen] so the - * failure split is unit-testable. - * - * An ACTIVE or ABSENT lifecycle read returns without invoking [erase]. ABSENT - * means no retained revisions exist; it does not establish a completed erase. - * - * Only [erase] decides whether the submission succeeded. The erase result - * itself observes only that the document is absent from ordinary reads, which - * it already was, so the lifecycle is the account of what was removed — but it - * is an observation of an already-broadcast, already-confirmed transition. A - * read that fails therefore leaves the erase successful and merely unreported; - * surfacing it as a failure would invite a second, fee-bearing erase. A - * [CancellationException] still propagates so structured concurrency is intact. - */ -internal suspend fun eraseAndDescribe( - readLifecycle: suspend () -> DocumentLifecycle?, - erase: suspend () -> Unit, -): String { - suspend fun observe(): DocumentLifecycle? = try { - readLifecycle() - } catch (e: CancellationException) { - throw e - } catch (_: Exception) { - null - } - - val before = observe() - if (before?.state == DocumentLifecycleState.ACTIVE || before?.state == DocumentLifecycleState.ABSENT) { - val progress = if (before.state == DocumentLifecycleState.ABSENT) { - "No retained revisions exist." - } else { - describeEraseProgress(before, before) - } - return "Erase not submitted. Lifecycle: ${before.state}. $progress" +/** Display the Rust outcome without making another submission decision. */ +internal fun describeEraseOutcome(outcome: DocumentEraseOutcome): String = when (outcome) { + is DocumentEraseOutcome.NotSubmitted -> "Erase not submitted. " + when (outcome.reason) { + DocumentEraseNotSubmittedReason.ACTIVE -> "The document is active." + DocumentEraseNotSubmittedReason.ABSENT -> "No retained revisions exist." + DocumentEraseNotSubmittedReason.NOT_NEWEST_OWNER -> + "The newest retained revision belongs to ${outcome.owner}. Select that identity." + DocumentEraseNotSubmittedReason.PREFLIGHT_UNAVAILABLE -> + "Lifecycle or ownership could not be read; read history before retrying." } - erase() - val after = observe() - return "Erase submitted; document absence observed. " + - if (after != null) { - describeEraseProgress(before, after) - } else { - "Lifecycle not read; query the document history to see what remains." - } + is DocumentEraseOutcome.Submitted -> "Erase submitted; document absence observed. " + + (outcome.after?.let { describeEraseProgress(outcome.before, it) } + ?: "Lifecycle not read; query the document history to see what remains.") } /** The owner + current field values [DocumentActionsScreen]'s probe reads. */ diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/contracts/EraseAndDescribeTest.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/contracts/EraseAndDescribeTest.kt index 6ecaeaf8604..a172e5fc238 100644 --- a/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/contracts/EraseAndDescribeTest.kt +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/contracts/EraseAndDescribeTest.kt @@ -1,145 +1,52 @@ package org.dashfoundation.example.ui.contracts -import kotlinx.coroutines.CancellationException -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runTest +import org.dashfoundation.dashsdk.documents.DocumentEraseOutcome +import org.dashfoundation.dashsdk.documents.DocumentEraseNotSubmittedReason import org.dashfoundation.dashsdk.queries.DocumentLifecycle import org.dashfoundation.dashsdk.queries.DocumentLifecycleState -import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test -/** - * Pins the failure split in [eraseAndDescribe]: the erase decides the - * submission, the lifecycle reads only describe it. - * - * A failed lifecycle observation must not report a broadcast as failed or - * invite another fee-bearing submission. An ACTIVE or ABSENT observation - * before the broadcast must instead explain why no submission is needed. - */ -@OptIn(ExperimentalCoroutinesApi::class) +/** Presentation tests consume Rust decisions; they never simulate submission policy. */ class EraseAndDescribeTest { - - private fun lifecycle(state: DocumentLifecycleState, remaining: Long) = DocumentLifecycle( - state = state, - remainingRevisions = remaining.toULong(), - deletedAtMs = if (state == DocumentLifecycleState.DELETED || state == DocumentLifecycleState.ERASING) { - 1_700_000_000_001uL - } else { - 0uL - }, - erasingStartedAtMs = if (state == DocumentLifecycleState.ERASING) 1_700_000_000_002uL else 0uL, - erasingFromTimeMs = if (state == DocumentLifecycleState.ERASING) 1_700_000_000_000uL else 0uL, - erasingFromRevision = if (state == DocumentLifecycleState.ERASING) 7uL else 0uL, - ) - @Test - fun activeOrAbsentLifecycleSkipsThePaidErase() = runTest { - for (state in listOf(DocumentLifecycleState.ACTIVE, DocumentLifecycleState.ABSENT)) { - var erases = 0 - var reads = 0 - val message = eraseAndDescribe( - readLifecycle = { reads++; lifecycle(state, 0) }, - erase = { erases++ }, - ) - assertEquals("no erase is needed for $state", 0, erases) - assertEquals("no post-broadcast read is needed", 1, reads) - assertTrue(message, message.startsWith("Erase not submitted")) - assertTrue(message, message.contains(state.name)) - if (state == DocumentLifecycleState.ABSENT) { - assertTrue(message, message.contains("No retained revisions exist")) - assertFalse(message, message.contains("Erasure complete")) - } - } + fun unavailablePreflightDoesNotClaimSubmission() { + val message = describeEraseOutcome(DocumentEraseOutcome.NotSubmitted( + DocumentEraseNotSubmittedReason.PREFLIGHT_UNAVAILABLE, null, null, + )) + assertTrue(message, message.startsWith("Erase not submitted")) + assertTrue(message, message.contains("read history before retrying")) } @Test - fun lifecycleReadFailureAfterBroadcast_stillReportsSuccess() = runTest { - var eraseCount = 0 - var reads = 0 - - val message = eraseAndDescribe( - readLifecycle = { - reads++ - if (reads == 1) { - lifecycle(DocumentLifecycleState.DELETED, 150) - } else { - throw IllegalStateException("DAPI timeout") // after the broadcast - } - }, - erase = { eraseCount++ }, - ) - - assertEquals("the erase must have been submitted exactly once", 1, eraseCount) + fun closingReadFailureDoesNotReportSubmissionFailure() { + val message = describeEraseOutcome(DocumentEraseOutcome.Submitted(null, null)) assertTrue(message, message.startsWith("Erase submitted")) assertTrue(message, message.contains("Lifecycle not read")) } @Test - fun lifecycleReadFailureBeforeBroadcast_stillSubmitsAndDescribes() = runTest { - var eraseCount = 0 - var reads = 0 - - val message = eraseAndDescribe( - readLifecycle = { - reads++ - if (reads == 1) throw IllegalStateException("DAPI timeout") - lifecycle(DocumentLifecycleState.ERASING, 50) - }, - erase = { eraseCount++ }, - ) - - assertEquals(1, eraseCount) - assertTrue(message, message.contains("Erasure in progress: 50")) - } - - @Test - fun eraseFailureIsNotDressedUpAsASubmission() = runTest { - var reads = 0 - val thrown = runCatching { - eraseAndDescribe( - readLifecycle = { reads++; lifecycle(DocumentLifecycleState.DELETED, 150) }, - erase = { throw IllegalStateException("broadcast rejected") }, - ) - }.exceptionOrNull() - - assertTrue("the erase's own failure must reach the caller", thrown is IllegalStateException) - assertEquals("the closing read must not run after a failed erase", 1, reads) + fun absentSkipIsNotReportedAsCompletedErasure() { + val message = describeEraseOutcome(DocumentEraseOutcome.NotSubmitted( + DocumentEraseNotSubmittedReason.ABSENT, null, null, + )) + assertTrue(message, message.contains("No retained revisions exist")) + assertFalse(message, message.contains("Erasure complete")) } @Test - fun cancellationIsNotSwallowedByTheReadGuard() = runTest { - var eraseCount = 0 - val thrown = runCatching { - eraseAndDescribe( - readLifecycle = { throw CancellationException("screen disposed") }, - erase = { eraseCount++ }, - ) - }.exceptionOrNull() - - assertTrue( - "cancellation must propagate so structured concurrency is intact", - thrown is CancellationException, - ) - assertEquals("a cancelled read must not go on to submit the erase", 0, eraseCount) + fun ownerRefusalNamesTheIdentityRustReported() { + val message = describeEraseOutcome(DocumentEraseOutcome.NotSubmitted( + DocumentEraseNotSubmittedReason.NOT_NEWEST_OWNER, "owner", null, + )) + assertTrue(message, message.contains("belongs to owner")) } @Test - fun completedErasureIsDescribedFromTheLifecycleReads() = runTest { - var reads = 0 - val message = eraseAndDescribe( - readLifecycle = { - reads++ - if (reads == 1) { - lifecycle(DocumentLifecycleState.DELETED, 100) - } else { - lifecycle(DocumentLifecycleState.ABSENT, 0) - } - }, - erase = {}, - ) - - assertTrue(message, message.contains("Erasure complete")) + fun submittedProgressUsesTheClosingObservation() { + val after = DocumentLifecycle(DocumentLifecycleState.ERASING, 50uL, 1uL, 2uL, 3uL, 4uL) + val message = describeEraseOutcome(DocumentEraseOutcome.Submitted(null, after)) + assertTrue(message, message.contains("Erasure in progress: 50")) } } diff --git a/packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/FfiSmokeTest.kt b/packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/FfiSmokeTest.kt index 419de77c636..4895db7b6bd 100644 --- a/packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/FfiSmokeTest.kt +++ b/packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/FfiSmokeTest.kt @@ -8,6 +8,7 @@ import org.dashfoundation.dashsdk.ffi.DashpayNative import org.dashfoundation.dashsdk.ffi.NativePersistenceBridge import org.dashfoundation.dashsdk.ffi.NativeLoader import org.dashfoundation.dashsdk.ffi.SdkNative +import org.dashfoundation.dashsdk.ffi.TransactionsNative import org.dashfoundation.dashsdk.ffi.SignerNative import org.dashfoundation.dashsdk.ffi.WalletManagerNative import org.dashfoundation.dashsdk.persistence.DashDatabase @@ -31,6 +32,17 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class FfiSmokeTest { + @Test + fun documentEraseAndObserveBindsAndRejectsInvalidInput() { + NativeLoader.ensureLoaded() + val error = assertThrows(DashSDKException::class.java) { + TransactionsNative.documentEraseAndObserve( + 0L, ByteArray(32), ByteArray(32), "note", ByteArray(32), 0L, + ) + } + assertEquals(1003, error.code) + } + @Test fun nativeLibraryLoadsAndReportsVersion() { NativeLoader.ensureLoaded() diff --git a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/documents/DocumentEraseOutcome.kt b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/documents/DocumentEraseOutcome.kt new file mode 100644 index 00000000000..332e9a02793 --- /dev/null +++ b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/documents/DocumentEraseOutcome.kt @@ -0,0 +1,64 @@ +package org.dashfoundation.dashsdk.documents + +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.JsonNull +import kotlinx.serialization.json.JsonObject +import kotlinx.serialization.json.jsonObject +import kotlinx.serialization.json.jsonPrimitive +import org.dashfoundation.dashsdk.queries.DocumentLifecycle + +/** A Rust decision about whether to submit the requested erase. */ +enum class DocumentEraseNotSubmittedReason { ACTIVE, ABSENT, NOT_NEWEST_OWNER, PREFLIGHT_UNAVAILABLE } + +/** The paid operation and its observations are separate facts. */ +sealed class DocumentEraseOutcome { + data class NotSubmitted( + val reason: DocumentEraseNotSubmittedReason, + val owner: String?, + val before: DocumentLifecycle?, + ) : DocumentEraseOutcome() + + data class Submitted( + val before: DocumentLifecycle?, + val after: DocumentLifecycle?, + ) : DocumentEraseOutcome() + + companion object { + internal fun fromJson(json: String): DocumentEraseOutcome = try { + val root = Json.parseToJsonElement(json).jsonObject + fun observation(key: String): DocumentLifecycle? { + val value = requireNotNull(root[key]) + if (value == JsonNull) return null + val obj = value as? JsonObject ?: error("invalid observation") + return requireNotNull(DocumentLifecycle.fromLifecycleObject(obj)) + } + val before = observation("before") + val after = observation("after") + val reasonValue = root.getValue("reason") + val reason = if (reasonValue == JsonNull) null else + DocumentEraseNotSubmittedReason.valueOf( + requireNotNull(reasonValue.jsonPrimitive.takeIf { it.isString }).content, + ) + val ownerValue = root.getValue("owner") + val owner = if (ownerValue == JsonNull) null else + requireNotNull(ownerValue.jsonPrimitive.takeIf { it.isString }).content + when (root.getValue("kind").jsonPrimitive.takeIf { it.isString }?.content) { + "NOT_SUBMITTED" -> { + requireNotNull(reason) + if (reason == DocumentEraseNotSubmittedReason.NOT_NEWEST_OWNER) { + requireNotNull(owner) + } + NotSubmitted(reason, owner, before) + } + "SUBMITTED" -> Submitted(before, after) + else -> error("unknown outcome") + } + } catch (e: Exception) { + throw DocumentEraseResultUnreadableException(e) + } + } +} + +/** An OK native result could not be decoded; it is unsafe to infer submission failure. */ +class DocumentEraseResultUnreadableException(cause: Throwable? = null) : + IllegalStateException("Erase result unreadable; read history before retrying.", cause) diff --git a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/documents/DocumentTransactions.kt b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/documents/DocumentTransactions.kt index 16223d93864..d32623766c4 100644 --- a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/documents/DocumentTransactions.kt +++ b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/documents/DocumentTransactions.kt @@ -222,49 +222,24 @@ class DocumentTransactions internal constructor( } } - /** - * Erase + broadcast a chunk of the retained revisions of the already - * deleted [documentId] on [contractId]'s [documentType] — signed via - * [signerHandle] with key [signingKeyId] of [ownerId]. Mirrors Swift - * `ManagedPlatformWallet.eraseDocument`. Only valid for a keep-history - * type whose schema sets `canBeErased`, and only after the document has - * been deleted; the first erase must be signed by the document's owner, - * later ones by any identity. One call removes a bounded chunk of - * revisions. - * - * A return means the transition was broadcast and Platform proved the - * document absent from ordinary reads — which it already was before the - * erase — so it observes the affected state rather than proving that - * this erase removed a revision. Read `Documents.lifecycle` (or - * `Documents.history`) for the current state and the exact number of - * revisions still retained, and erase again while there are any. - * - * @return the document's 32-byte id whose absence was observed. - */ - suspend fun erase( + /** Rust owns eligibility, key selection, submission and lifecycle observations. */ + suspend fun eraseAndObserve( walletHandle: Long, - ownerId: ByteArray, + submittingIdentityId: ByteArray, contractId: ByteArray, documentType: String, documentId: ByteArray, - signingKeyId: Int, signerHandle: Long, - ): ByteArray = gate.op { - require(ownerId.size == 32) { "ownerId must be 32 bytes" } + ): DocumentEraseOutcome = gate.op { + require(submittingIdentityId.size == 32) { "submittingIdentityId must be 32 bytes" } require(contractId.size == 32) { "contractId must be 32 bytes" } require(documentId.size == 32) { "documentId must be 32 bytes" } - require(signingKeyId >= 0) { "signingKeyId must be non-negative, got $signingKeyId" } - mapNativeErrors { - TransactionsNative.documentErase( - walletHandle, - ownerId, - contractId, - documentType, - documentId, - signingKeyId, - signerHandle, + val json = mapNativeErrors { + TransactionsNative.documentEraseAndObserve( + walletHandle, submittingIdentityId, contractId, documentType, documentId, signerHandle, ) } + DocumentEraseOutcome.fromJson(json) } /** diff --git a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/TransactionsNative.kt b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/TransactionsNative.kt index 5f8e979746c..564442c8341 100644 --- a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/TransactionsNative.kt +++ b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/TransactionsNative.kt @@ -181,25 +181,15 @@ internal object TransactionsNative { signerHandle: Long, ): ByteArray - /** - * Erase + broadcast a chunk of the retained revisions of the already - * deleted [documentId] on [contractId]'s [documentType], signed via - * [signerHandle] with key [signingKeyId] of [ownerId]. Bridges - * `platform_wallet_document_erase` (Swift - * `ManagedPlatformWallet.eraseDocument`). The first erase of a document - * must be signed by its owner; later ones may be signed by any - * identity. Erase returns no document body, so this returns the erased - * document's 32-byte id for confirmation. - */ - external fun documentErase( + /** Bridges the Rust wallet's single read/decide/submit/observe operation. */ + external fun documentEraseAndObserve( walletHandle: Long, - ownerId: ByteArray, + submittingIdentityId: ByteArray, contractId: ByteArray, documentType: String, documentId: ByteArray, - signingKeyId: Int, signerHandle: Long, - ): ByteArray + ): String /** * Transfer + broadcast [documentId] on [contractId]'s [documentType], diff --git a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/queries/DocumentHistory.kt b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/queries/DocumentHistory.kt index 80a4ff29265..1d5adb36b46 100644 --- a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/queries/DocumentHistory.kt +++ b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/queries/DocumentHistory.kt @@ -71,7 +71,7 @@ data class DocumentLifecycle( null } - private fun fromLifecycleObject(obj: JsonObject): DocumentLifecycle? { + internal fun fromLifecycleObject(obj: JsonObject): DocumentLifecycle? { val state = obj["state"]?.jsonPrimitive?.takeIf { it.isString }?.content ?.let { name -> DocumentLifecycleState.entries.firstOrNull { it.name == name } } ?: return null diff --git a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/queries/PlatformQueries.kt b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/queries/PlatformQueries.kt index e10a6c0650a..7cd50efbbef 100644 --- a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/queries/PlatformQueries.kt +++ b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/queries/PlatformQueries.kt @@ -933,8 +933,9 @@ class Documents internal constructor(private val sdk: Sdk) { /** * Read where a keep-history document stands right now: its lifecycle * state and the exact number of revisions still retained. A current - * observation, not the outcome of any particular transition; the erase - * result itself only observes absence (see `DocumentTransactions.erase`). + * observation, not the outcome of any particular transition. The wallet's + * erase-and-observe operation returns its submission decision together + * with the lifecycle observations before and after submission. */ suspend fun lifecycle( contractId: String, diff --git a/packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/documents/DocumentEraseOutcomeTest.kt b/packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/documents/DocumentEraseOutcomeTest.kt new file mode 100644 index 00000000000..fdc100c1ff2 --- /dev/null +++ b/packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/documents/DocumentEraseOutcomeTest.kt @@ -0,0 +1,73 @@ +package org.dashfoundation.dashsdk.documents + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertThrows +import org.junit.Test + +class DocumentEraseOutcomeTest { + private val lifecycle = """{"state":"ERASING","remaining_revisions":18446744073709551615,"deleted_at_ms":1,"erasing_started_at_ms":2,"erasing_from_time_ms":3,"erasing_from_revision":4}""" + + @Test + fun submittedWithUnavailableClosingReadRemainsSubmitted() { + val outcome = DocumentEraseOutcome.fromJson("""{"kind":"SUBMITTED","reason":null,"owner":null,"before":$lifecycle,"after":null}""") + as DocumentEraseOutcome.Submitted + assertEquals(ULong.MAX_VALUE, outcome.before!!.remainingRevisions) + assertNull(outcome.after) + } + + @Test + fun unavailablePreflightIsAnExplicitNotSubmittedReason() { + val outcome = DocumentEraseOutcome.fromJson("""{"kind":"NOT_SUBMITTED","reason":"PREFLIGHT_UNAVAILABLE","owner":null,"before":null,"after":null}""") + as DocumentEraseOutcome.NotSubmitted + assertEquals(DocumentEraseNotSubmittedReason.PREFLIGHT_UNAVAILABLE, outcome.reason) + assertNull(outcome.before) + } + + @Test + fun malformedObservationIsNeverTreatedAsUnavailable() { + for (json in listOf( + """{"kind":"SUBMITTED","reason":null,"owner":null,"before":{},"after":null}""", + """{"kind":"SUBMITTED","reason":null,"owner":null,"before":null}""", + """{"kind":"UNKNOWN","reason":null,"owner":null,"before":null,"after":null}""", + """{"kind":"NOT_SUBMITTED","reason":"UNKNOWN","owner":null,"before":null,"after":null}""", + """{"kind":"NOT_SUBMITTED","reason":"NOT_NEWEST_OWNER","owner":null,"before":null,"after":null}""", + )) { + val error = assertThrows(DocumentEraseResultUnreadableException::class.java) { + DocumentEraseOutcome.fromJson(json) + } + assertEquals("Erase result unreadable; read history before retrying.", error.message) + } + } + + @Test + fun submittedStillRejectsUnknownOrMissingTransportFields() { + for (fields in listOf( + "\"reason\":\"UNKNOWN\",\"owner\":null", + "\"reason\":null", + "\"owner\":null", + )) { + assertThrows(DocumentEraseResultUnreadableException::class.java) { + DocumentEraseOutcome.fromJson("{\"kind\":\"SUBMITTED\",$fields,\"before\":null,\"after\":null}") + } + } + } + + @Test + fun decoderDoesNotReimplementTheSubmissionDecision() { + for (reason in DocumentEraseNotSubmittedReason.entries) { + val outcome = DocumentEraseOutcome.fromJson("""{"kind":"NOT_SUBMITTED","reason":"${reason.name}","owner":"11111111111111111111111111111111","before":$lifecycle,"after":null}""") + as DocumentEraseOutcome.NotSubmitted + assertEquals(reason, outcome.reason) + } + } + @Test + fun nativeLifecycleFixtureDecodesThroughTheSharedParser() { + val json = requireNotNull(javaClass.getResource("/document_erase_outcome_from_native.json")).readText() + val result = DocumentEraseOutcome.fromJson(json) as DocumentEraseOutcome.Submitted + assertEquals(ULong.MAX_VALUE, result.before!!.remainingRevisions) + assertEquals(ULong.MAX_VALUE, result.before!!.erasingFromRevision) + assertNull(result.after) + } + +} diff --git a/packages/kotlin-sdk/sdk/src/test/resources/document_erase_outcome_from_native.json b/packages/kotlin-sdk/sdk/src/test/resources/document_erase_outcome_from_native.json new file mode 100644 index 00000000000..23eac5bff53 --- /dev/null +++ b/packages/kotlin-sdk/sdk/src/test/resources/document_erase_outcome_from_native.json @@ -0,0 +1 @@ +{"kind":"SUBMITTED","reason":null,"owner":null,"before":{"state":"ERASING","remaining_revisions":18446744073709551615,"deleted_at_ms":1,"erasing_started_at_ms":2,"erasing_from_time_ms":3,"erasing_from_revision":18446744073709551615},"after":null} diff --git a/packages/rs-platform-wallet-ffi/src/document.rs b/packages/rs-platform-wallet-ffi/src/document.rs index 726cff61cae..3a8c9d5055e 100644 --- a/packages/rs-platform-wallet-ffi/src/document.rs +++ b/packages/rs-platform-wallet-ffi/src/document.rs @@ -5,9 +5,13 @@ use std::os::raw::c_char; use std::ptr; use std::slice; +use dash_sdk::drive::query::document_history_drive_query::DocumentHistoryState; use dpp::document::{Document, DocumentV0Getters}; use dpp::prelude::Identifier; use dpp::serialization::ValueConvertible; +use platform_wallet::wallet::identity::network::{ + DocumentEraseNotSubmittedReason, DocumentEraseOutcome, DocumentLifecycleObservation, +}; use platform_wallet::PlatformWalletError; use rs_sdk_ffi::{SignerHandle, VTableSigner}; @@ -388,79 +392,170 @@ pub unsafe extern "C" fn platform_wallet_document_delete_by_values( PlatformWalletFFIResult::ok() } -/// Erase + broadcast a chunk of the retained revisions of the already -/// deleted `document_id` on `contract_id`'s `document_type_name`, signed -/// via the external `signer_handle` with key `signing_key_id` of -/// `owner_identity_id`. -/// -/// Goes through `IdentityWallet::erase_document_with_signer`. The first -/// erase of a document must be signed by its owner; the erases after it -/// may be signed by any identity, so `owner_identity_id` is the signing -/// identity rather than necessarily the document's owner. On success the -/// document's 32-byte id is written to `out_document_id`: the transition -/// was broadcast and Platform proved the document absent from ordinary -/// reads, which it already was before the erase, so success observes the -/// affected state rather than proving this erase removed a revision. -/// Erase returns no document body, so there is no JSON out-param; the -/// lifecycle state and the number of revisions still retained are read -/// from the document's history. +/// The operation populated an outcome only after all Rust work succeeded. +#[repr(u8)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] +pub enum DocumentEraseOutcomeKindFFI { + #[default] + Unset = 0, + NotSubmitted = 1, + Submitted = 2, +} + +#[repr(u8)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] +pub enum DocumentEraseNotSubmittedReasonFFI { + #[default] + None = 0, + Active = 1, + Absent = 2, + NotNewestOwner = 3, + PreflightUnavailable = 4, +} + +#[repr(u8)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] +pub enum DocumentLifecycleObservationTagFFI { + #[default] + Unavailable = 0, + Active = 1, + Absent = 2, + Deleted = 3, + Erasing = 4, +} + +/// Unavailable has no lifecycle fields; observed tags preserve every u64 exactly. +#[repr(C)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] +pub struct DocumentLifecycleObservationFFI { + pub state: DocumentLifecycleObservationTagFFI, + pub remaining_revisions: u64, + pub deleted_at_ms: u64, + pub erasing_started_at_ms: u64, + pub erasing_from_time_ms: u64, + pub erasing_from_revision: u64, +} + +/// Caller-owned output, with no allocations to free. `owner` is present only +/// for NotNewestOwner. `after` is an observation only for Submitted. +#[repr(C)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] +pub struct DocumentEraseOutcomeFFI { + pub kind: DocumentEraseOutcomeKindFFI, + pub reason: DocumentEraseNotSubmittedReasonFFI, + pub owner: [u8; 32], + pub before: DocumentLifecycleObservationFFI, + pub after: DocumentLifecycleObservationFFI, +} + +impl From for DocumentLifecycleObservationFFI { + fn from(value: DocumentLifecycleObservation) -> Self { + let DocumentLifecycleObservation::Observed(lifecycle) = value else { + return Self::default(); + }; + let state = match lifecycle.state { + DocumentHistoryState::Active => DocumentLifecycleObservationTagFFI::Active, + DocumentHistoryState::Absent => DocumentLifecycleObservationTagFFI::Absent, + DocumentHistoryState::Deleted => DocumentLifecycleObservationTagFFI::Deleted, + DocumentHistoryState::Erasing => DocumentLifecycleObservationTagFFI::Erasing, + }; + Self { + state, + remaining_revisions: lifecycle.remaining_revisions, + deleted_at_ms: lifecycle.times.deleted_at_ms, + erasing_started_at_ms: lifecycle.times.erasing_started_at_ms, + erasing_from_time_ms: lifecycle.times.erasing_from_time_ms, + erasing_from_revision: lifecycle.times.erasing_from_revision, + } + } +} + +impl From for DocumentEraseOutcomeFFI { + fn from(value: DocumentEraseOutcome) -> Self { + match value { + DocumentEraseOutcome::NotSubmitted { reason, before } => { + let (reason, owner) = match reason { + DocumentEraseNotSubmittedReason::Active => { + (DocumentEraseNotSubmittedReasonFFI::Active, [0; 32]) + } + DocumentEraseNotSubmittedReason::Absent => { + (DocumentEraseNotSubmittedReasonFFI::Absent, [0; 32]) + } + DocumentEraseNotSubmittedReason::PreflightUnavailable => ( + DocumentEraseNotSubmittedReasonFFI::PreflightUnavailable, + [0; 32], + ), + DocumentEraseNotSubmittedReason::NotNewestOwner { owner } => ( + DocumentEraseNotSubmittedReasonFFI::NotNewestOwner, + owner.to_buffer(), + ), + }; + Self { + kind: DocumentEraseOutcomeKindFFI::NotSubmitted, + reason, + owner, + before: before.into(), + ..Default::default() + } + } + DocumentEraseOutcome::Submitted { before, after } => Self { + kind: DocumentEraseOutcomeKindFFI::Submitted, + before: before.into(), + after: after.into(), + ..Default::default() + }, + } + } +} + +/// Run one Rust-owned preflight/select/submit/observe operation. An unreadable +/// preflight does not submit. An unavailable closing read stays Submitted. +/// Submission errors (including code 20, whose outcome is unknown) leave +/// `out` at Default; callers must read history before considering a retry. +/// The caller retains the signer and output for the duration of this call. /// /// # Safety -/// `owner_identity_id`, `contract_id`, and `document_id` must each point to -/// 32 readable bytes. `document_type_name` must be a valid NUL-terminated -/// string. `signer_handle` must refer to a live signer whose callbacks and -/// context remain valid for this blocking call. `out_document_id` must -/// point to 32 writable bytes. The buffers must not be mutated concurrently -/// and the output buffer must not overlap any input. +/// Identifier pointers address 32 readable bytes and the type is a readable +/// NUL-terminated UTF-8 string. The signer and its callbacks remain live for +/// this blocking call. `out` is aligned, writable, and does not overlap an +/// input. Inputs and output are not concurrently mutated. #[no_mangle] #[allow(clippy::too_many_arguments)] -pub unsafe extern "C" fn platform_wallet_document_erase( +pub unsafe extern "C" fn platform_wallet_document_erase_and_observe( wallet_handle: Handle, - owner_identity_id: *const u8, + submitting_identity_id: *const u8, contract_id: *const u8, document_type_name: *const c_char, document_id: *const u8, - signing_key_id: u32, signer_handle: *mut SignerHandle, - out_document_id: *mut u8, + out: *mut DocumentEraseOutcomeFFI, ) -> PlatformWalletFFIResult { + check_ptr!(out); + *out = DocumentEraseOutcomeFFI::default(); check_ptr!(signer_handle); check_ptr!(document_type_name); - check_ptr!(out_document_id); - - let owner_id = unwrap_result_or_return!(read_identifier(owner_identity_id)); - let contract_id_value = unwrap_result_or_return!(read_identifier(contract_id)); - let document_id_value = unwrap_result_or_return!(read_identifier(document_id)); - - let document_type_str = - unwrap_result_or_return!(CStr::from_ptr(document_type_name).to_str()).to_string(); - + let submitter = unwrap_result_or_return!(read_identifier(submitting_identity_id)); + let contract = unwrap_result_or_return!(read_identifier(contract_id)); + let document = unwrap_result_or_return!(read_identifier(document_id)); + let document_type = + unwrap_result_or_return!(CStr::from_ptr(document_type_name).to_str()).to_owned(); + let identity_wallet = unwrap_option_or_return!( + PLATFORM_WALLET_STORAGE.with_item(wallet_handle, |wallet| wallet.identity().clone()) + ); let signer_addr = signer_handle as usize; - - let option = PLATFORM_WALLET_STORAGE.with_item(wallet_handle, |wallet| { - let identity_wallet = wallet.identity().clone(); - let result: Result = block_on_worker(async move { - let signer: &VTableSigner = &*(signer_addr as *const VTableSigner); - let erased_id: Identifier = identity_wallet - .erase_document_with_signer( - &owner_id, - &contract_id_value, - &document_type_str, - &document_id_value, - signing_key_id, - signer, - ) - .await?; - Ok::<_, PlatformWalletError>(erased_id) - }); - result + let result = block_on_worker(async move { + let signer = &*(signer_addr as *const VTableSigner); + identity_wallet + .erase_document_and_observe_with_signer( + &submitter, + &contract, + &document_type, + &document, + signer, + ) + .await }); - let result = unwrap_option_or_return!(option); - let erased_id = unwrap_result_or_return!(result); - - let bytes = erased_id.to_buffer(); - let dst = slice::from_raw_parts_mut(out_document_id, 32); - dst.copy_from_slice(&bytes); + *out = unwrap_result_or_return!(result).into(); PlatformWalletFFIResult::ok() } @@ -683,6 +778,7 @@ pub unsafe extern "C" fn platform_wallet_document_purchase( #[cfg(test)] mod tests { use super::*; + use crate::platform_wallet_ffi_result_free; use dpp::document::DocumentV0; use dpp::platform_value::Value; use std::collections::BTreeMap; @@ -784,4 +880,177 @@ mod tests { assert_eq!(result.code, PlatformWalletFFIResultCode::ErrorNullPointer); } } + #[test] + fn should_initialize_erase_outcome_before_rejecting_invalid_inputs() { + let id = [1; 32]; + let name = CString::new("note").unwrap(); + let signer = ptr::NonNull::::dangling().as_ptr(); + for (owner, contract, doc, type_name, signer, expected) in [ + ( + ptr::null(), + id.as_ptr(), + id.as_ptr(), + name.as_ptr(), + signer, + 10, + ), + ( + id.as_ptr(), + ptr::null(), + id.as_ptr(), + name.as_ptr(), + signer, + 10, + ), + ( + id.as_ptr(), + id.as_ptr(), + ptr::null(), + name.as_ptr(), + signer, + 10, + ), + ( + id.as_ptr(), + id.as_ptr(), + id.as_ptr(), + ptr::null(), + signer, + 3, + ), + ( + id.as_ptr(), + id.as_ptr(), + id.as_ptr(), + name.as_ptr(), + ptr::null_mut(), + 3, + ), + ( + id.as_ptr(), + id.as_ptr(), + id.as_ptr(), + name.as_ptr(), + signer, + 98, + ), + ] { + let mut out = DocumentEraseOutcomeFFI { + kind: DocumentEraseOutcomeKindFFI::Submitted, + ..Default::default() + }; + let mut result = unsafe { + platform_wallet_document_erase_and_observe( + 0, owner, contract, type_name, doc, signer, &mut out, + ) + }; + assert_eq!(result.code as u32, expected); + assert_eq!(out.kind, DocumentEraseOutcomeKindFFI::Unset); + assert_eq!( + out.before.state, + DocumentLifecycleObservationTagFFI::Unavailable + ); + unsafe { + platform_wallet_ffi_result_free(&mut result); + } + } + let mut result = unsafe { + platform_wallet_document_erase_and_observe( + 0, + id.as_ptr(), + id.as_ptr(), + name.as_ptr(), + id.as_ptr(), + signer, + ptr::null_mut(), + ) + }; + assert_eq!(result.code as u32, 3); + unsafe { + platform_wallet_ffi_result_free(&mut result); + } + } + #[test] + fn should_marshal_every_erase_outcome_without_losing_observation_fields() { + use dash_sdk::drive::query::document_history_drive_query::{ + DocumentHistoryLifecycle, DocumentHistoryLifecycleTimes, DocumentHistoryState, + }; + use platform_wallet::wallet::identity::network::{ + DocumentEraseNotSubmittedReason, DocumentEraseOutcome, DocumentLifecycleObservation, + }; + assert_eq!(std::mem::size_of::(), 136); + assert_eq!(std::mem::align_of::(), 8); + for (state, tag) in [ + (DocumentHistoryState::Active, 1), + (DocumentHistoryState::Absent, 2), + (DocumentHistoryState::Deleted, 3), + (DocumentHistoryState::Erasing, 4), + ] { + let lifecycle = DocumentLifecycleObservation::Observed(DocumentHistoryLifecycle { + state, + remaining_revisions: u64::MAX, + times: DocumentHistoryLifecycleTimes { + deleted_at_ms: 1, + erasing_started_at_ms: 2, + erasing_from_time_ms: 3, + erasing_from_revision: u64::MAX, + }, + }); + let out = DocumentEraseOutcomeFFI::from(DocumentEraseOutcome::Submitted { + before: DocumentLifecycleObservation::Unavailable, + after: lifecycle, + }); + assert_eq!(out.kind, DocumentEraseOutcomeKindFFI::Submitted); + assert_eq!( + out.before.state, + DocumentLifecycleObservationTagFFI::Unavailable + ); + assert_eq!(out.after.state as u8, tag); + assert_eq!(out.after.remaining_revisions, u64::MAX); + assert_eq!(out.after.erasing_from_revision, u64::MAX); + assert_eq!( + ( + out.after.deleted_at_ms, + out.after.erasing_started_at_ms, + out.after.erasing_from_time_ms + ), + (1, 2, 3) + ); + } + for (reason, tag, owner) in [ + (DocumentEraseNotSubmittedReason::Active, 1, [0; 32]), + (DocumentEraseNotSubmittedReason::Absent, 2, [0; 32]), + ( + DocumentEraseNotSubmittedReason::NotNewestOwner { + owner: Identifier::from([7; 32]), + }, + 3, + [7; 32], + ), + ( + DocumentEraseNotSubmittedReason::PreflightUnavailable, + 4, + [0; 32], + ), + ] { + let out = DocumentEraseOutcomeFFI::from(DocumentEraseOutcome::NotSubmitted { + reason, + before: DocumentLifecycleObservation::Unavailable, + }); + assert_eq!(out.kind, DocumentEraseOutcomeKindFFI::NotSubmitted); + assert_eq!(out.reason as u8, tag); + assert_eq!(out.owner, owner); + assert_eq!( + out.after.state, + DocumentLifecycleObservationTagFFI::Unavailable + ); + } + assert_eq!( + PlatformWalletFFIResult::from(PlatformWalletError::DocumentEraseBusy).code as u32, + 6 + ); + } } + +#[cfg(test)] +mod erase_tests; diff --git a/packages/rs-platform-wallet-ffi/src/document/erase_tests.rs b/packages/rs-platform-wallet-ffi/src/document/erase_tests.rs new file mode 100644 index 00000000000..02e250e9b2e --- /dev/null +++ b/packages/rs-platform-wallet-ffi/src/document/erase_tests.rs @@ -0,0 +1,241 @@ +use super::*; +use crate::platform_wallet_ffi_result_free; +use std::sync::Arc; + +use dash_sdk::dapi_client::mock::MockResult; +use dash_sdk::dapi_client::transport::{TransportError, TransportRequest}; +use dash_sdk::dapi_client::{DapiClientError, DumpData, ExecutionError, ExecutionResponse}; +use dash_sdk::dapi_grpc::platform::v0::BroadcastStateTransitionResponse; +use dash_sdk::dapi_grpc::tonic::Status; +use dash_sdk::platform::documents::document_history_query::{ + DocumentHistoryFilter, DocumentHistoryQuery, +}; +use dash_sdk::platform::documents::transitions::DocumentEraseTransitionBuilder; +use dash_sdk::platform::transition::broadcast_request::BroadcastRequestForStateTransition; +use dash_sdk::query_types::{ + DocumentHistory, DocumentHistoryLifecycle, DocumentHistoryState, IdentityContractNonceFetcher, +}; +use dash_sdk::{RequestSettings, SdkBuilder}; +use dpp::address_funds::AddressWitness; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::factory::DataContractFactory; +use dpp::identity::identity_public_key::v0::IdentityPublicKeyV0; +use dpp::identity::signer::Signer; +use dpp::identity::{IdentityPublicKey, IdentityV0, KeyType, Purpose, SecurityLevel}; +use dpp::platform_value::{platform_value, BinaryData}; +use dpp::version::PlatformVersion; +use dpp::ProtocolError; +use key_wallet::wallet::initialization::WalletAccountCreationOptions; +use platform_wallet::events::{EventHandler, PlatformEventHandler}; +use platform_wallet::wallet::persister::NoPlatformPersistence; +use platform_wallet::PlatformWalletManager; +use tokio::task::block_in_place; + +#[derive(Debug)] +struct Signing(bool); +#[async_trait::async_trait] +impl Signer for Signing { + async fn sign(&self, _: &IdentityPublicKey, _: &[u8]) -> Result { + Ok(vec![7; 65].into()) + } + async fn sign_create_witness( + &self, + _: &IdentityPublicKey, + _: &[u8], + ) -> Result { + unreachable!() + } + fn can_sign_with(&self, _: &IdentityPublicKey) -> bool { + self.0 + } +} +struct Events; +impl EventHandler for Events {} +impl PlatformEventHandler for Events {} + +fn save(directory: &tempfile::TempDir, request: &R, response: &MockResult) { + let dump = DumpData::new(request, response); + dump.save(&directory.path().join(dump.filename().unwrap())) + .unwrap(); +} + +#[tokio::test(flavor = "multi_thread")] +async fn should_preserve_signer_unavailable_and_unknown_submission_through_the_erase_export() { + let version = PlatformVersion::latest(); + let contract = Arc::new( + DataContractFactory::new(version.protocol_version) + .unwrap() + .create_with_value_config( + Identifier::from([1; 32]), + 1, + platform_value!({ + "note": { "type": "object", "documentsKeepHistory": true, "canBeErased": true, + "properties": {"message": {"type": "string", "maxLength": 64, "position": 0}}, "additionalProperties": false } + }), + None, + None, + ) + .unwrap() + .data_contract_owned(), + ); + let owner = Identifier::from([3; 32]); + let document = Identifier::from([2; 32]); + let key: IdentityPublicKey = IdentityPublicKeyV0 { + id: 1, + purpose: Purpose::AUTHENTICATION, + security_level: SecurityLevel::HIGH, + key_type: KeyType::ECDSA_SECP256K1, + data: vec![7; 33].into(), + ..Default::default() + } + .into(); + for available in [false, true] { + let build_sdk = || { + SdkBuilder::new_mock() + .with_version(version) + .with_time_tolerance(None) + .with_settings(RequestSettings { + retries: Some(0), + ..Default::default() + }) + .build() + .unwrap() + }; + let mut sdk = build_sdk(); + sdk.mock() + .expect_fetch(contract.id(), Some(contract.as_ref().clone())) + .await + .unwrap(); + sdk.mock() + .expect_fetch( + DocumentHistoryQuery { + data_contract_id: contract.id(), + document_type_name: "note".into(), + document_id: document, + filter: DocumentHistoryFilter::StartAtTime(0), + limit: Some(1), + }, + Some(DocumentHistory { + entries: vec![], + lifecycle: Some(DocumentHistoryLifecycle { + state: DocumentHistoryState::Erasing, + remaining_revisions: 3, + times: Default::default(), + }), + }), + ) + .await + .unwrap(); + sdk.mock() + .expect_fetch::((owner, contract.id()), None) + .await + .unwrap(); + if available { + let mut signing_sdk = build_sdk(); + signing_sdk + .mock() + .expect_fetch::((owner, contract.id()), None) + .await + .unwrap(); + let transition = DocumentEraseTransitionBuilder::new( + contract.clone(), + "note".into(), + document, + owner, + ) + .sign(&signing_sdk, &key, &Signing(true), version) + .await + .unwrap(); + let broadcast = transition.broadcast_request_for_state_transition().unwrap(); + let wait = transition + .wait_for_state_transition_result_request() + .unwrap(); + let directory = tempfile::tempdir().unwrap(); + save( + &directory, + &broadcast, + &Ok(ExecutionResponse { + inner: BroadcastStateTransitionResponse {}, + retries: 0, + address: "http://127.0.0.1".parse().unwrap(), + }), + ); + let error: MockResult< + dash_sdk::dapi_grpc::platform::v0::WaitForStateTransitionResultRequest, + > = Err(ExecutionError { + inner: DapiClientError::Transport(TransportError::Grpc(Status::unavailable( + "closing stream unavailable", + ))), + address: None, + retries: 0, + possibly_accepted: false, + }); + save(&directory, &wait, &error); + sdk.mock().load_expectations_sync(directory.path()).unwrap(); + } + let manager = PlatformWalletManager::new( + Arc::new(sdk), + Arc::new(NoPlatformPersistence), + Arc::new(Events), + ); + let wallet = manager + .create_wallet_from_seed_bytes( + key_wallet::Network::Testnet, + &[7; 64], + WalletAccountCreationOptions::None, + Some(0), + ) + .await + .unwrap(); + wallet + .wallet_manager() + .write() + .await + .get_wallet_info_mut(&wallet.wallet_id()) + .unwrap() + .identity_manager + .add_identity( + IdentityV0 { + id: owner, + public_keys: [(1, key.clone())].into(), + balance: 100_000_000, + revision: 0, + } + .into(), + 0, + wallet.wallet_id(), + wallet.persister(), + ) + .unwrap(); + let handle = PLATFORM_WALLET_STORAGE.insert(wallet); + let signer = Box::new(VTableSigner::from_native(Arc::new(Signing(available)))); + let name = CString::new("note").unwrap(); + let mut out = DocumentEraseOutcomeFFI::default(); + let mut result = block_in_place(|| unsafe { + platform_wallet_document_erase_and_observe( + handle, + owner.as_bytes().as_ptr(), + contract.id().as_bytes().as_ptr(), + name.as_ptr(), + document.as_bytes().as_ptr(), + Box::as_ref(&signer) as *const VTableSigner as *mut SignerHandle, + &mut out, + ) + }); + assert_eq!( + result.code as u32, + if available { 20 } else { 31 }, + "{}", + if result.message.is_null() { + "No error message".into() + } else { + unsafe { CStr::from_ptr(result.message) }.to_string_lossy() + } + ); + assert_eq!(out.kind, DocumentEraseOutcomeKindFFI::Unset); + unsafe { + platform_wallet_ffi_result_free(&mut result); + } + PLATFORM_WALLET_STORAGE.remove(handle); + } +} diff --git a/packages/rs-platform-wallet-ffi/src/error.rs b/packages/rs-platform-wallet-ffi/src/error.rs index 58194bf7197..94fa448f950 100644 --- a/packages/rs-platform-wallet-ffi/src/error.rs +++ b/packages/rs-platform-wallet-ffi/src/error.rs @@ -1045,6 +1045,9 @@ impl From for PlatformWalletFFIResult { // assigned a dedicated code yet — those still carry the // typed Display rendering as the message. let code = match &error { + PlatformWalletError::DocumentEraseBusy => { + PlatformWalletFFIResultCode::ErrorWalletOperation + } PlatformWalletError::IdentityBalanceUnavailable(_) => { PlatformWalletFFIResultCode::ErrorIdentityBalanceUnavailable } diff --git a/packages/rs-platform-wallet/src/error.rs b/packages/rs-platform-wallet/src/error.rs index f9ed4a5b60f..7b7112803f2 100644 --- a/packages/rs-platform-wallet/src/error.rs +++ b/packages/rs-platform-wallet/src/error.rs @@ -21,6 +21,9 @@ pub use dash_sdk::platform::transition::asset_lock_submission::{ /// Errors that can occur in platform wallet operations #[derive(Debug, thiserror::Error)] pub enum PlatformWalletError { + #[error("An erase for this document is already in flight; read history before retrying")] + DocumentEraseBusy, + #[error("Wallet creation failed: {0}")] WalletCreation(String), diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/document.rs b/packages/rs-platform-wallet/src/wallet/identity/network/document.rs index 773011742b1..8b6868e08ab 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/document.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/document.rs @@ -71,7 +71,7 @@ use super::*; /// `Signer` trait bound on the SDK's `PutDocument` /// extension be satisfied with a `&S` instead of forcing the caller to /// hand over ownership / wrap in an `Arc` per call. -struct SignerRef<'a, S: ?Sized>(&'a S); +pub(super) struct SignerRef<'a, S: ?Sized>(pub(super) &'a S); impl<'a, S: ?Sized> std::fmt::Debug for SignerRef<'a, S> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/document_erase.rs b/packages/rs-platform-wallet/src/wallet/identity/network/document_erase.rs new file mode 100644 index 00000000000..6c5aa2be451 --- /dev/null +++ b/packages/rs-platform-wallet/src/wallet/identity/network/document_erase.rs @@ -0,0 +1,1454 @@ +//! One paid erase attempt, with its eligibility and observations owned by Rust. + +use std::collections::BTreeSet; +use std::future::Future; +use std::sync::{Arc, Mutex}; + +use dash_sdk::drive::query::document_history_drive_query::{ + DocumentHistoryFilter, DocumentHistoryLifecycle, DocumentHistoryState, +}; +use dash_sdk::platform::documents::document_history_query::DocumentHistoryQuery; +use dash_sdk::platform::documents::transitions::DocumentEraseTransitionBuilder; +use dash_sdk::platform::Fetch; +use dash_sdk::query_types::DocumentHistory; +use dash_sdk::Error as SdkError; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::{DocumentTypeV0Getters, DocumentTypeV2Getters}; +use dpp::data_contract::document_type::DocumentType; +use dpp::document::DocumentV0Getters; +use dpp::identity::signer::Signer; +use dpp::identity::{Identity, IdentityPublicKey, KeyType}; +use dpp::prelude::{DataContract, Identifier}; + +use super::document::SignerRef; +use super::{usable_authentication_key, IdentityWallet}; +use crate::error::{preserve_signer_key_unavailable_or, PlatformWalletError}; + +/// A proved lifecycle, or a read that could not establish one. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum DocumentLifecycleObservation { + Observed(DocumentHistoryLifecycle), + Unavailable, +} + +/// Why no paid transition was submitted. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum DocumentEraseNotSubmittedReason { + Active, + Absent, + NotNewestOwner { owner: Identifier }, + PreflightUnavailable, +} + +/// Submission and observations are separate: an unavailable closing read does +/// not turn a submitted erase into a submission failure. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum DocumentEraseOutcome { + NotSubmitted { + reason: DocumentEraseNotSubmittedReason, + before: DocumentLifecycleObservation, + }, + Submitted { + before: DocumentLifecycleObservation, + after: DocumentLifecycleObservation, + }, +} + +#[derive(Debug, PartialEq, Eq)] +enum DocumentEraseDecision { + NotSubmitted(DocumentEraseNotSubmittedReason), + Submit, +} + +fn decide( + before: &DocumentLifecycleObservation, + submitter: Identifier, + newest_owner: Option, +) -> DocumentEraseDecision { + use DocumentEraseNotSubmittedReason as Reason; + let reason = match before { + DocumentLifecycleObservation::Observed(lifecycle) => match lifecycle.state { + DocumentHistoryState::Active => Reason::Active, + DocumentHistoryState::Absent => Reason::Absent, + DocumentHistoryState::Erasing => return DocumentEraseDecision::Submit, + DocumentHistoryState::Deleted => match newest_owner { + Some(owner) if owner == submitter => return DocumentEraseDecision::Submit, + Some(owner) => Reason::NotNewestOwner { owner }, + None => Reason::PreflightUnavailable, + }, + }, + DocumentLifecycleObservation::Unavailable => Reason::PreflightUnavailable, + }; + DocumentEraseDecision::NotSubmitted(reason) +} + +/// Shared by cloned wallet handles, including calls that outlive a host await. +#[derive(Debug, Default)] +pub(crate) struct DocumentEraseGate(Mutex>); + +impl DocumentEraseGate { + fn enter( + &self, + contract: Identifier, + document: Identifier, + ) -> Result, PlatformWalletError> { + if !self + .0 + .lock() + .unwrap_or_else(|e| e.into_inner()) + .insert((contract, document)) + { + return Err(PlatformWalletError::DocumentEraseBusy); + } + Ok(DocumentEraseGuard { + gate: self, + key: (contract, document), + }) + } +} + +struct DocumentEraseGuard<'a> { + gate: &'a DocumentEraseGate, + key: (Identifier, Identifier), +} + +impl Drop for DocumentEraseGuard<'_> { + fn drop(&mut self) { + self.gate + .0 + .lock() + .unwrap_or_else(|e| e.into_inner()) + .remove(&self.key); + } +} + +fn select_erase_key( + identity: &Identity, + document_type: &DocumentType, + contract_id: Identifier, + signer: &impl Signer, +) -> Result { + usable_authentication_key( + identity, + signer, + contract_id, + document_type.name(), + &document_type + .security_level_requirement() + .document_signing_levels(), + &[KeyType::ECDSA_SECP256K1], + ) + .map_err(PlatformWalletError::Sdk)? + .cloned() + .ok_or_else(|| { + PlatformWalletError::InvalidIdentityData("No eligible document erase signing key".into()) + }) +} + +fn observation(history: Option<&DocumentHistory>) -> DocumentLifecycleObservation { + history + .and_then(|history| history.lifecycle.clone()) + .map(DocumentLifecycleObservation::Observed) + .unwrap_or(DocumentLifecycleObservation::Unavailable) +} + +fn validate_erasable_type(document_type: &DocumentType) -> Result<(), PlatformWalletError> { + if !document_type.documents_keep_history() + || !document_type.documents_can_be_erased() + || document_type.find_contested_index().is_some() + { + return Err(PlatformWalletError::InvalidIdentityData(format!( + "Document type {:?} does not permit history erasure", + document_type.name() + ))); + } + Ok(()) +} + +impl IdentityWallet { + /// Fetch/register the contract, establish a free proved preflight, select a + /// usable signer key, and submit at most once. Unreadable preflight fails + /// closed. A deleted document requires the newest retained revision owner; + /// any loaded identity may continue an erasing document. Key selection uses + /// the real type requirement and the supplied signer. An unconfirmed + /// submission is an error whose outcome is unknown; + /// neither that error nor a successful return triggers automatic retries. + /// An unproved consensus refusal after broadcast also has an unknown outcome. + /// When more than one revision remains, deleted histories with gaps or + /// more than 65,536 retained revisions return `PreflightUnavailable` because + /// the newest owner cannot be established. This operation does not walk + /// history pages. + pub async fn erase_document_and_observe_with_signer( + &self, + submitting_identity_id: &Identifier, + contract_id: &Identifier, + document_type_name: &str, + document_id: &Identifier, + signer: &S, + ) -> Result + where + S: Signer + Send + Sync, + { + self.erase_and_observe_with_submit( + submitting_identity_id, + contract_id, + document_type_name, + document_id, + signer, + |contract, key| async move { + let builder = DocumentEraseTransitionBuilder::new( + contract, + document_type_name.to_owned(), + *document_id, + *submitting_identity_id, + ); + self.sdk + .document_erase(builder, &key, &SignerRef(signer)) + .await + .map(|_| ()) + }, + ) + .await + } + + async fn read_erase_history(&self, query: DocumentHistoryQuery) -> Option { + match DocumentHistory::fetch(&self.sdk, query).await { + Ok(history) => history, + Err(error) => { + tracing::warn!(%error, "Document erase lifecycle observation unavailable"); + None + } + } + } + + #[allow(clippy::too_many_arguments)] + async fn erase_and_observe_with_submit( + &self, + submitting_identity_id: &Identifier, + contract_id: &Identifier, + document_type_name: &str, + document_id: &Identifier, + signer: &S, + submit: F, + ) -> Result + where + S: Signer + Send + Sync, + F: FnOnce(Arc, IdentityPublicKey) -> Fut, + Fut: Future>, + { + let _guard = self.document_erase_gate.enter(*contract_id, *document_id)?; + let contract = self + .fetch_contract_arc_for_document_op(contract_id, document_type_name) + .await?; + let document_type = contract + .document_type_cloned_for_name(document_type_name) + .map_err(|e| PlatformWalletError::InvalidIdentityData(e.to_string()))?; + validate_erasable_type(&document_type)?; + + let query = DocumentHistoryQuery { + data_contract_id: *contract_id, + document_type_name: document_type_name.to_owned(), + document_id: *document_id, + filter: DocumentHistoryFilter::StartAtTime(0), + limit: Some(1), + }; + let history = self.read_erase_history(query.clone()).await; + let before = observation(history.as_ref()); + let mut newest_owner = None; + if let DocumentLifecycleObservation::Observed(lifecycle) = &before { + if lifecycle.state == DocumentHistoryState::Deleted { + let newest_revision = lifecycle.remaining_revisions; + if newest_revision == 1 { + newest_owner = history.as_ref().and_then(|history| { + history + .entries + .first() + .map(|entry| entry.document.owner_id()) + }); + } else if newest_revision != 0 { + let newest_query = DocumentHistoryQuery { + filter: DocumentHistoryFilter::Revision(newest_revision), + ..query.clone() + }; + newest_owner = self + .read_erase_history(newest_query) + .await + .and_then(|page| { + if page.lifecycle.as_ref() != Some(lifecycle) { + return None; + } + page.entries + .iter() + .find(|entry| entry.revision == newest_revision) + .map(|entry| entry.document.owner_id()) + }); + } + } + } + if let DocumentEraseDecision::NotSubmitted(reason) = + decide(&before, *submitting_identity_id, newest_owner) + { + return Ok(DocumentEraseOutcome::NotSubmitted { reason, before }); + } + let identity = { + let manager = self.wallet_manager.read().await; + let info = manager + .get_wallet_info(&self.wallet_id) + .ok_or_else(|| PlatformWalletError::WalletNotFound(hex::encode(self.wallet_id)))?; + info.identity_manager + .identity(submitting_identity_id) + .map(|managed| managed.identity.clone()) + .ok_or(PlatformWalletError::IdentityNotFound( + *submitting_identity_id, + ))? + }; + // Signer callbacks may re-enter the wallet; the manager lock is released. + let key = select_erase_key(&identity, &document_type, *contract_id, signer)?; + submit(contract, key).await.map_err(|error| { + preserve_signer_key_unavailable_or(error, |error| { + PlatformWalletError::InvalidIdentityData(format!( + "Failed to erase document: {error}" + )) + }) + })?; + let after = observation(self.read_erase_history(query).await.as_ref()); + Ok(DocumentEraseOutcome::Submitted { before, after }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::error::SIGNER_KEY_UNAVAILABLE_PREFIX; + use crate::wallet::persister::NoPlatformPersistence; + use crate::PlatformWallet; + use dash_sdk::dapi_grpc::platform::v0::GetDocumentHistoryRequest; + use dash_sdk::drive::query::document_history_drive_query::DocumentHistoryLifecycleTimes; + use dash_sdk::platform::Query; + use dpp::document::DocumentV0Setters; + use dpp::identity::accessors::IdentityGettersV0; + use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; + use dpp::version::PlatformVersion; + + fn observed(state: DocumentHistoryState) -> DocumentLifecycleObservation { + let remaining_revisions = if state == DocumentHistoryState::Absent { + 0 + } else { + 3 + }; + DocumentLifecycleObservation::Observed(DocumentHistoryLifecycle { + state, + remaining_revisions, + times: DocumentHistoryLifecycleTimes::default(), + }) + } + + #[test] + fn should_never_pay_without_an_eligible_preflight() { + let submitter = Identifier::from([1; 32]); + let other = Identifier::from([2; 32]); + for (before, owner, expected) in [ + ( + observed(DocumentHistoryState::Active), + None, + DocumentEraseDecision::NotSubmitted(DocumentEraseNotSubmittedReason::Active), + ), + ( + observed(DocumentHistoryState::Absent), + None, + DocumentEraseDecision::NotSubmitted(DocumentEraseNotSubmittedReason::Absent), + ), + ( + DocumentLifecycleObservation::Unavailable, + None, + DocumentEraseDecision::NotSubmitted( + DocumentEraseNotSubmittedReason::PreflightUnavailable, + ), + ), + ( + observed(DocumentHistoryState::Deleted), + None, + DocumentEraseDecision::NotSubmitted( + DocumentEraseNotSubmittedReason::PreflightUnavailable, + ), + ), + ( + observed(DocumentHistoryState::Deleted), + Some(other), + DocumentEraseDecision::NotSubmitted( + DocumentEraseNotSubmittedReason::NotNewestOwner { owner: other }, + ), + ), + ( + observed(DocumentHistoryState::Deleted), + Some(submitter), + DocumentEraseDecision::Submit, + ), + ( + observed(DocumentHistoryState::Erasing), + Some(other), + DocumentEraseDecision::Submit, + ), + ( + observed(DocumentHistoryState::Erasing), + None, + DocumentEraseDecision::Submit, + ), + ] { + assert_eq!(decide(&before, submitter, owner), expected); + } + } + + #[test] + fn should_release_the_in_flight_guard_on_drop() { + let gate = DocumentEraseGate::default(); + let contract = Identifier::from([1; 32]); + let document = Identifier::from([2; 32]); + let guard = gate.enter(contract, document).unwrap(); + assert!(matches!( + gate.enter(contract, document), + Err(PlatformWalletError::DocumentEraseBusy) + )); + assert!(gate.enter(contract, Identifier::from([3; 32])).is_ok()); + drop(guard); + assert!(gate.enter(contract, document).is_ok()); + } + fn key(id: u32, level: dpp::identity::SecurityLevel) -> IdentityPublicKey { + dpp::identity::identity_public_key::v0::IdentityPublicKeyV0 { + id, + purpose: dpp::identity::Purpose::AUTHENTICATION, + security_level: level, + key_type: KeyType::ECDSA_SECP256K1, + data: vec![id as u8; 33].into(), + ..Default::default() + } + .into() + } + + fn bounds( + key: &mut IdentityPublicKey, + bounds: Option, + ) { + if let IdentityPublicKey::V0(key) = key { + key.contract_bounds = bounds; + } + } + + fn contract() -> DataContract { + contract_with_requirement(dpp::identity::SecurityLevel::HIGH) + } + + fn contract_with_requirement(requirement: dpp::identity::SecurityLevel) -> DataContract { + use dpp::data_contract::factory::DataContractFactory; + use dpp::platform_value::platform_value; + DataContractFactory::new(PlatformVersion::latest().protocol_version) + .unwrap() + .create_with_value_config( + Identifier::from([1; 32]), + 1, + platform_value!({ + "note": { "type": "object", "documentsKeepHistory": true, + "canBeErased": true, "signatureSecurityLevelRequirement": requirement as u8, + "properties": {"message": {"type": "string", "maxLength": 64, "position": 0}}, "additionalProperties": false } + }), + None, + None, + ) + .unwrap() + .data_contract_owned() + } + + #[test] + fn should_select_only_usable_erase_keys_for_the_real_type() { + use super::super::signing_key::tests::available; + use dpp::identity::accessors::IdentitySettersV0; + use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeySettersV0; + use dpp::identity::identity_public_key::contract_bounds::ContractBounds; + use dpp::identity::{Identity, SecurityLevel}; + let contract = contract(); + let document_type = contract.document_type_cloned_for_name("note").unwrap(); + let mut identity = Identity::default_versioned(PlatformVersion::latest()).unwrap(); + let mut wrong_contract = key(1, SecurityLevel::CRITICAL); + bounds( + &mut wrong_contract, + Some(ContractBounds::SingleContract { + id: Identifier::from([9; 32]), + }), + ); + let mut wrong_type = key(2, SecurityLevel::CRITICAL); + bounds( + &mut wrong_type, + Some(ContractBounds::SingleContractDocumentType { + id: contract.id(), + document_type_name: "other".into(), + }), + ); + let mut group = key(3, SecurityLevel::CRITICAL); + bounds( + &mut group, + Some(ContractBounds::ContractGroup { id: contract.id() }), + ); + let mut disabled = key(5, SecurityLevel::CRITICAL); + disabled.set_disabled_at(1); + for candidate in [ + key(0, SecurityLevel::MASTER), + wrong_contract, + wrong_type, + group, + key(4, SecurityLevel::CRITICAL).with_limits(None, Some(1)), + disabled, + key(6, SecurityLevel::HIGH).with_limits(Some(100), None), + key(7, SecurityLevel::HIGH), + key(8, SecurityLevel::CRITICAL), + ] { + identity.add_public_key(candidate); + } + let signer = available(&[0, 1, 2, 3, 4, 5, 6, 7]); + assert_eq!( + select_erase_key(&identity, &document_type, contract.id(), &signer) + .unwrap() + .id(), + 7 + ); + let error = select_erase_key( + &identity, + &document_type, + contract.id(), + &available(&[0, 1, 2, 3, 4, 5]), + ) + .unwrap_err(); + assert!(error.to_string().contains(SIGNER_KEY_UNAVAILABLE_PREFIX)); + identity.set_public_keys(Default::default()); + identity.add_public_key(key(0, SecurityLevel::MASTER)); + assert!(matches!( + select_erase_key(&identity, &document_type, contract.id(), &signer), + Err(PlatformWalletError::InvalidIdentityData(_)) + )); + } + + #[derive(Default)] + struct Contracts( + std::sync::Mutex>>, + std::sync::Mutex>, + ); + + impl dash_sdk::platform::ContextProvider for Contracts { + fn get_data_contract( + &self, + id: &Identifier, + _: &dpp::version::PlatformVersion, + ) -> Result>, dash_sdk::error::ContextProviderError> { + Ok(self + .0 + .lock() + .unwrap() + .as_ref() + .filter(|c| c.id() == *id) + .cloned()) + } + fn register_data_contract(&self, contract: Arc) { + let control = self.1.lock().unwrap().take(); + if let Some(mut control) = control { + assert_eq!( + futures::executor::block_on(history_reads( + &mut control, + &contract, + DocumentHistoryFilter::StartAtTime(0) + )), + 0, + "contract registration must precede every history read" + ); + } + *self.0.lock().unwrap() = Some(contract); + } + fn get_token_configuration( + &self, + _: &Identifier, + ) -> Result< + Option, + dash_sdk::error::ContextProviderError, + > { + Ok(None) + } + fn get_quorum_public_key( + &self, + _: u32, + _: [u8; 32], + _: u32, + ) -> Result<[u8; 48], dash_sdk::error::ContextProviderError> { + Err(dash_sdk::error::ContextProviderError::Config( + "no test quorum".into(), + )) + } + fn get_platform_activation_height( + &self, + ) -> Result { + Ok(1) + } + } + + fn history_query( + contract: &DataContract, + filter: DocumentHistoryFilter, + ) -> DocumentHistoryQuery { + DocumentHistoryQuery { + data_contract_id: contract.id(), + document_type_name: "note".into(), + document_id: Identifier::from([2; 32]), + filter, + limit: Some(1), + } + } + + async fn history_reads( + sdk: &mut dash_sdk::Sdk, + contract: &DataContract, + filter: DocumentHistoryFilter, + ) -> usize { + let request: GetDocumentHistoryRequest = history_query(contract, filter) + .query(&sdk.query_settings()) + .unwrap(); + sdk.mock().request_count(&request).await + } + + fn history(state: DocumentHistoryState, owner: Identifier, newest: bool) -> DocumentHistory { + let absent = state == DocumentHistoryState::Absent; + DocumentHistory { + lifecycle: match observed(state) { + DocumentLifecycleObservation::Observed(lifecycle) => Some(lifecycle), + _ => unreachable!(), + }, + entries: if absent { + vec![] + } else { + vec![dash_sdk::query_types::DocumentHistoryEntry { + time_ms: 1, + revision: if newest { 3 } else { 1 }, + document: dpp::document::DocumentV0 { + id: Identifier::from([2; 32]), + owner_id: owner, + revision: Some(if newest { 3 } else { 1 }), + ..Default::default() + } + .into(), + }] + }, + } + } + + #[tokio::test] + async fn should_register_the_contract_before_skipping_an_active_document() { + use super::super::signing_key::tests::{available, wallet_with_signing_keys_on}; + let contract = contract(); + let provider = Arc::new(Contracts::default()); + let mut sdk = dash_sdk::SdkBuilder::new_mock() + .with_version(PlatformVersion::latest()) + .with_context_provider_arc(provider.clone()) + .build() + .unwrap(); + sdk.mock() + .expect_fetch(contract.id(), Some(contract.clone())) + .await + .unwrap(); + sdk.mock() + .expect_fetch( + history_query(&contract, DocumentHistoryFilter::StartAtTime(0)), + Some(history( + DocumentHistoryState::Active, + Identifier::default(), + true, + )), + ) + .await + .unwrap(); + *provider.1.lock().unwrap() = Some(sdk.clone()); + let mut control = sdk.clone(); + let wallet = wallet_with_signing_keys_on(sdk, Arc::new(NoPlatformPersistence)).await; + assert!(provider.0.lock().unwrap().is_none()); + let outcome = wallet + .identity() + .erase_and_observe_with_submit( + &Identifier::default(), + &contract.id(), + "note", + &Identifier::from([2; 32]), + &available(&[]), + |_, _| async { panic!("ACTIVE must not submit") }, + ) + .await + .unwrap(); + assert!(matches!( + outcome, + DocumentEraseOutcome::NotSubmitted { + reason: DocumentEraseNotSubmittedReason::Active, + .. + } + )); + assert_eq!( + provider.0.lock().unwrap().as_ref().unwrap().id(), + contract.id() + ); + assert!(provider.1.lock().unwrap().is_none()); + assert_eq!( + history_reads( + &mut control, + &contract, + DocumentHistoryFilter::StartAtTime(0) + ) + .await, + 1 + ); + } + + #[tokio::test] + async fn should_observe_once_after_submission_and_keep_closing_failure_separate() { + use super::super::signing_key::tests::{available, wallet_with_signing_keys_on}; + for closing_state in [ + Some(DocumentHistoryState::Active), + Some(DocumentHistoryState::Absent), + Some(DocumentHistoryState::Deleted), + Some(DocumentHistoryState::Erasing), + None, + ] { + let contract = contract(); + let mut sdk = dash_sdk::SdkBuilder::new_mock() + .with_version(PlatformVersion::latest()) + .build() + .unwrap(); + let query = history_query(&contract, DocumentHistoryFilter::StartAtTime(0)); + sdk.mock() + .expect_fetch(contract.id(), Some(contract.clone())) + .await + .unwrap(); + sdk.mock() + .expect_fetch( + query.clone(), + Some(history( + DocumentHistoryState::Erasing, + Identifier::from([9; 32]), + true, + )), + ) + .await + .unwrap(); + let mut control = sdk.clone(); + let wallet = wallet_with_signing_keys_on(sdk, Arc::new(NoPlatformPersistence)).await; + let calls = std::sync::atomic::AtomicUsize::new(0); + let outcome = wallet + .identity() + .erase_and_observe_with_submit( + &Identifier::default(), + &contract.id(), + "note", + &Identifier::from([2; 32]), + &available(&[1]), + |_, _| async { + calls.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + control + .mock() + .remove_fetch_expectation::(query.clone()) + .await; + if let Some(state) = closing_state { + control + .mock() + .expect_fetch( + query, + Some(history(state, Identifier::from([9; 32]), true)), + ) + .await + .unwrap(); + } + Ok(()) + }, + ) + .await + .unwrap(); + assert_eq!(calls.load(std::sync::atomic::Ordering::SeqCst), 1); + assert_eq!( + outcome, + DocumentEraseOutcome::Submitted { + before: observed(DocumentHistoryState::Erasing), + after: closing_state + .map(observed) + .unwrap_or(DocumentLifecycleObservation::Unavailable), + } + ); + } + } + + #[tokio::test] + async fn should_check_the_newest_deleted_owner_and_fail_closed_on_unread_preflight() { + use super::super::signing_key::tests::{available, wallet_with_signing_keys_on}; + let other = Identifier::from([9; 32]); + for (state, metadata, newest, owner, owner_read, expected) in [ + ( + DocumentHistoryState::Absent, + true, + true, + other, + true, + DocumentEraseNotSubmittedReason::Absent, + ), + ( + DocumentHistoryState::Deleted, + false, + true, + other, + true, + DocumentEraseNotSubmittedReason::PreflightUnavailable, + ), + ( + DocumentHistoryState::Deleted, + true, + true, + other, + true, + DocumentEraseNotSubmittedReason::NotNewestOwner { owner: other }, + ), + ( + DocumentHistoryState::Deleted, + true, + false, + other, + true, + DocumentEraseNotSubmittedReason::NotNewestOwner { owner: other }, + ), + ( + DocumentHistoryState::Deleted, + true, + false, + other, + false, + DocumentEraseNotSubmittedReason::PreflightUnavailable, + ), + ] { + let contract = contract(); + let mut sdk = dash_sdk::SdkBuilder::new_mock() + .with_version(PlatformVersion::latest()) + .build() + .unwrap(); + sdk.mock() + .expect_fetch(contract.id(), Some(contract.clone())) + .await + .unwrap(); + let mut page = history(state, owner, newest); + if newest && state == DocumentHistoryState::Deleted { + page.lifecycle.as_mut().unwrap().remaining_revisions = 1; + } + if !metadata { + page.lifecycle = None; + } + sdk.mock() + .expect_fetch( + history_query(&contract, DocumentHistoryFilter::StartAtTime(0)), + Some(page), + ) + .await + .unwrap(); + if !newest && owner_read { + sdk.mock() + .expect_fetch( + history_query(&contract, DocumentHistoryFilter::Revision(3)), + Some(history(state, owner, true)), + ) + .await + .unwrap(); + } + let wallet = wallet_with_signing_keys_on(sdk, Arc::new(NoPlatformPersistence)).await; + let outcome = wallet + .identity() + .erase_and_observe_with_submit( + &Identifier::default(), + &contract.id(), + "note", + &Identifier::from([2; 32]), + &available(&[]), + |_, _| async { panic!("ineligible preflight must not submit") }, + ) + .await + .unwrap(); + assert!( + matches!(outcome, DocumentEraseOutcome::NotSubmitted { reason, .. } if reason == expected) + ); + } + } + + #[tokio::test] + async fn should_not_pay_to_erase_gapped_history_as_its_oldest_owner() { + use super::super::signing_key::tests::{available, wallet_with_signing_keys_on}; + let contract = contract(); + let mut sdk = dash_sdk::SdkBuilder::new_mock() + .with_version(PlatformVersion::latest()) + .build() + .unwrap(); + sdk.mock() + .expect_fetch(contract.id(), Some(contract.clone())) + .await + .unwrap(); + let mut retained = history(DocumentHistoryState::Deleted, Identifier::default(), false); + retained.lifecycle.as_mut().unwrap().remaining_revisions = 2; + retained.entries[0].revision = 2; + retained.entries[0].document.set_revision(Some(2)); + retained.entries.extend( + history( + DocumentHistoryState::Deleted, + Identifier::from([9; 32]), + true, + ) + .entries, + ); + // The preflight page exposes only revision 2, before the transfer. + retained.entries.truncate(1); + sdk.mock() + .expect_fetch( + history_query(&contract, DocumentHistoryFilter::StartAtTime(0)), + Some(retained), + ) + .await + .unwrap(); + // Revision-count lookup cannot resolve a gapped history. The missing + // Revision(2) expectation makes that read fail, as Drive would refuse it. + let wallet = wallet_with_signing_keys_on(sdk, Arc::new(NoPlatformPersistence)).await; + let calls = std::sync::atomic::AtomicUsize::new(0); + let outcome = wallet + .identity() + .erase_and_observe_with_submit( + &Identifier::default(), + &contract.id(), + "note", + &Identifier::from([2; 32]), + &available(&[1]), + |_, _| async { + calls.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + Ok(()) + }, + ) + .await + .unwrap(); + assert_eq!(calls.load(std::sync::atomic::Ordering::SeqCst), 0); + assert!(matches!( + outcome, + DocumentEraseOutcome::NotSubmitted { + reason: DocumentEraseNotSubmittedReason::PreflightUnavailable, + .. + } + )); + } + + #[test] + fn should_skip_each_ineligible_key_even_when_the_signer_has_it() { + use super::super::signing_key::tests::{available, identity}; + use dpp::identity::identity_public_key::contract_bounds::ContractBounds; + use dpp::identity::{Purpose, SecurityLevel}; + let contract = contract(); + let document_type = contract.document_type_cloned_for_name("note").unwrap(); + let mut wrong_contract = key(1, SecurityLevel::HIGH); + bounds( + &mut wrong_contract, + Some(ContractBounds::SingleContract { + id: Identifier::from([9; 32]), + }), + ); + let mut wrong_type = key(1, SecurityLevel::HIGH); + bounds( + &mut wrong_type, + Some(ContractBounds::SingleContractDocumentType { + id: contract.id(), + document_type_name: "other".into(), + }), + ); + let mut group = key(1, SecurityLevel::HIGH); + bounds( + &mut group, + Some(ContractBounds::ContractGroup { id: contract.id() }), + ); + for candidate in [ + wrong_contract, + wrong_type, + group, + key(1, SecurityLevel::HIGH).with_limits(None, Some(1)), + key(1, SecurityLevel::MASTER), + ] { + let mut subject = identity( + Purpose::AUTHENTICATION, + SecurityLevel::HIGH, + KeyType::ECDSA_SECP256K1, + ); + subject.add_public_key(candidate); + assert_eq!( + select_erase_key(&subject, &document_type, contract.id(), &available(&[1, 2])) + .unwrap() + .id(), + 2 + ); + } + } + + #[test] + fn should_refuse_a_stored_contested_type_even_when_it_allows_erasure() { + use dpp::data_contract::config::DataContractConfig; + use dpp::platform_value::platform_value; + let version = PlatformVersion::latest(); + let config = DataContractConfig::default_for_version(version).unwrap(); + let document_type = DocumentType::try_from_schema( + Identifier::from([1; 32]), + 1, + config.version(), + "note", + platform_value!({ + "type": "object", "documentsKeepHistory": true, + "documentsMutable": false, "canBeDeleted": true, "canBeErased": true, + "indices": [{ + "name": "byMessage", "properties": [{"message": "asc"}], "unique": true, + "contested": { + "fieldMatches": [{"field": "message", "regexPattern": "^[a-z]{3,10}$"}], + "resolution": 0 + } + }], + "properties": {"message": {"type": "string", "maxLength": 63, "position": 0}}, + "required": ["message"], "additionalProperties": false + }), + None, + &Default::default(), + &config, + false, + &mut vec![], + version, + ) + .unwrap(); + assert!(document_type.documents_keep_history()); + assert!(document_type.documents_can_be_erased()); + assert!(document_type.find_contested_index().is_some()); + assert!(validate_erasable_type(&document_type).is_err()); + } + + #[tokio::test] + async fn should_refuse_contract_types_before_reading_or_signing() { + use super::super::signing_key::tests::{available, wallet_with_signing_keys_on}; + use dpp::data_contract::factory::DataContractFactory; + use dpp::platform_value::platform_value; + for keeps_history in [false, true] { + let contract = DataContractFactory::new( + PlatformVersion::latest().protocol_version, + ) + .unwrap() + .create_with_value_config( + Identifier::from([1; 32]), + 1, + platform_value!({ + "note": { "type": "object", "documentsKeepHistory": keeps_history, + "canBeErased": false, "properties": {"message": {"type": "string", "maxLength": 64, "position": 0}}, "additionalProperties": false } + }), + None, + None, + ) + .unwrap() + .data_contract_owned(); + let mut sdk = dash_sdk::SdkBuilder::new_mock() + .with_version(PlatformVersion::latest()) + .build() + .unwrap(); + sdk.mock() + .expect_fetch(contract.id(), Some(contract.clone())) + .await + .unwrap(); + let mut control = sdk.clone(); + let wallet = wallet_with_signing_keys_on(sdk, Arc::new(NoPlatformPersistence)).await; + let result = wallet + .identity() + .erase_and_observe_with_submit( + &Identifier::default(), + &contract.id(), + "note", + &Identifier::from([2; 32]), + &available(&[]), + |_, _| async { panic!("contract refusal must not submit") }, + ) + .await; + assert!(matches!( + result, + Err(PlatformWalletError::InvalidIdentityData(_)) + )); + assert_eq!( + history_reads( + &mut control, + &contract, + DocumentHistoryFilter::StartAtTime(0) + ) + .await, + 0 + ); + } + } + + #[tokio::test] + async fn should_submit_deleted_only_for_the_newest_owner_and_release_lock_before_signer() { + use super::super::signing_key::tests::{ + available, lock_checking_signer, wallet_with_signing_keys_on, + }; + let contract = contract(); + for no_key in [false, true] { + let mut sdk = dash_sdk::SdkBuilder::new_mock() + .with_version(PlatformVersion::latest()) + .build() + .unwrap(); + sdk.mock() + .expect_fetch(contract.id(), Some(contract.clone())) + .await + .unwrap(); + sdk.mock() + .expect_fetch( + history_query(&contract, DocumentHistoryFilter::StartAtTime(0)), + Some(history( + DocumentHistoryState::Deleted, + Identifier::from([9; 32]), + false, + )), + ) + .await + .unwrap(); + sdk.mock() + .expect_fetch( + history_query(&contract, DocumentHistoryFilter::Revision(3)), + Some(history( + DocumentHistoryState::Deleted, + Identifier::default(), + true, + )), + ) + .await + .unwrap(); + let wallet = wallet_with_signing_keys_on(sdk, Arc::new(NoPlatformPersistence)).await; + if no_key { + let signer = lock_checking_signer(wallet.identity()); + let error = wallet + .identity() + .erase_and_observe_with_submit( + &Identifier::default(), + &contract.id(), + "note", + &Identifier::from([2; 32]), + &signer, + |_, _| async { panic!("unavailable key must not submit") }, + ) + .await + .unwrap_err(); + assert!(error.to_string().contains(SIGNER_KEY_UNAVAILABLE_PREFIX)); + } else { + let outcome = wallet + .identity() + .erase_and_observe_with_submit( + &Identifier::default(), + &contract.id(), + "note", + &Identifier::from([2; 32]), + &available(&[1]), + |_, _| async { Ok(()) }, + ) + .await + .unwrap(); + assert!(matches!(outcome, DocumentEraseOutcome::Submitted { .. })); + } + } + } + + #[tokio::test] + async fn should_not_submit_when_the_preflight_read_fails() { + use super::super::signing_key::tests::{available, wallet_with_signing_keys_on}; + let contract = contract(); + let mut sdk = dash_sdk::SdkBuilder::new_mock() + .with_version(PlatformVersion::latest()) + .build() + .unwrap(); + sdk.mock() + .expect_fetch(contract.id(), Some(contract.clone())) + .await + .unwrap(); + let wallet = wallet_with_signing_keys_on(sdk, Arc::new(NoPlatformPersistence)).await; + let outcome = wallet + .identity() + .erase_and_observe_with_submit( + &Identifier::default(), + &contract.id(), + "note", + &Identifier::from([2; 32]), + &available(&[]), + |_, _| async { panic!("unread preflight must not submit") }, + ) + .await + .unwrap(); + assert!(matches!( + outcome, + DocumentEraseOutcome::NotSubmitted { + reason: DocumentEraseNotSubmittedReason::PreflightUnavailable, + before: DocumentLifecycleObservation::Unavailable + } + )); + } + #[test] + fn should_skip_an_expired_erase_key_even_when_it_is_available() { + use super::super::signing_key::tests::{available, identity}; + use dpp::identity::{Purpose, SecurityLevel}; + let contract = contract(); + let document_type = contract.document_type_cloned_for_name("note").unwrap(); + let mut subject = identity( + Purpose::AUTHENTICATION, + SecurityLevel::HIGH, + KeyType::ECDSA_SECP256K1, + ); + subject.add_public_key(key(1, SecurityLevel::HIGH).with_limits(None, Some(1))); + assert_eq!( + select_erase_key(&subject, &document_type, contract.id(), &available(&[1, 2])) + .unwrap() + .id(), + 2 + ); + } + + #[test] + fn should_prefer_an_unlimited_erase_key_over_an_earlier_budgeted_key() { + use super::super::signing_key::tests::{available, identity}; + use dpp::identity::{Purpose, SecurityLevel}; + let contract = contract(); + let document_type = contract.document_type_cloned_for_name("note").unwrap(); + let mut subject = identity( + Purpose::AUTHENTICATION, + SecurityLevel::HIGH, + KeyType::ECDSA_SECP256K1, + ); + subject.add_public_key(key(1, SecurityLevel::HIGH).with_limits(Some(100), None)); + assert_eq!( + select_erase_key(&subject, &document_type, contract.id(), &available(&[1, 2])) + .unwrap() + .id(), + 2 + ); + } + + #[test] + fn should_use_the_real_document_requirement_and_exclude_master() { + use super::super::signing_key::tests::{available, identity}; + use dpp::identity::{Purpose, SecurityLevel}; + for (requirement, expected) in [ + (SecurityLevel::CRITICAL, 3), + (SecurityLevel::HIGH, 2), + (SecurityLevel::MEDIUM, 1), + ] { + let contract = contract_with_requirement(requirement); + let document_type = contract.document_type_cloned_for_name("note").unwrap(); + let mut subject = identity( + Purpose::AUTHENTICATION, + SecurityLevel::MEDIUM, + KeyType::ECDSA_SECP256K1, + ); + for candidate in [ + key(0, SecurityLevel::MASTER), + key(2, SecurityLevel::HIGH), + key(3, SecurityLevel::CRITICAL), + ] { + subject.add_public_key(candidate); + } + assert_eq!( + select_erase_key( + &subject, + &document_type, + contract.id(), + &available(&[0, 1, 2, 3]) + ) + .unwrap() + .id(), + expected + ); + } + } + + async fn erasing_wallet() -> (Arc, DataContract) { + use super::super::signing_key::tests::wallet_with_signing_keys_on; + let contract = contract(); + let mut sdk = dash_sdk::SdkBuilder::new_mock() + .with_version(PlatformVersion::latest()) + .build() + .unwrap(); + sdk.mock() + .expect_fetch(contract.id(), Some(contract.clone())) + .await + .unwrap(); + sdk.mock() + .expect_fetch( + history_query(&contract, DocumentHistoryFilter::StartAtTime(0)), + Some(history( + DocumentHistoryState::Erasing, + Identifier::from([9; 32]), + false, + )), + ) + .await + .unwrap(); + ( + wallet_with_signing_keys_on(sdk, Arc::new(NoPlatformPersistence)).await, + contract, + ) + } + + #[tokio::test] + async fn should_reject_a_concurrent_erase_while_the_first_submission_is_pending() { + use super::super::signing_key::tests::available; + let (wallet, contract) = erasing_wallet().await; + let submitter = Identifier::default(); + let contract_id = contract.id(); + let document_id = Identifier::from([2; 32]); + let signer = available(&[1]); + let entered = tokio::sync::Notify::new(); + let mut first = Box::pin(wallet.identity().erase_and_observe_with_submit( + &submitter, + &contract_id, + "note", + &document_id, + &signer, + |_, _| async { + entered.notify_one(); + std::future::pending::>().await + }, + )); + tokio::select! { + _ = entered.notified() => {}, + result = &mut first => panic!("first submission must remain pending: {result:?}"), + } + let result = wallet + .identity() + .erase_and_observe_with_submit( + &submitter, + &contract_id, + "note", + &document_id, + &signer, + |_, _| async { panic!("concurrent operation must not submit") }, + ) + .await; + assert!(matches!( + result, + Err(PlatformWalletError::DocumentEraseBusy) + )); + drop(first); + } + + #[tokio::test] + async fn should_release_the_in_flight_guard_when_cancelled_during_submission() { + use super::super::signing_key::tests::available; + let (wallet, contract) = erasing_wallet().await; + let submitter = Identifier::default(); + let contract_id = contract.id(); + let document_id = Identifier::from([2; 32]); + let signer = available(&[1]); + let entered = tokio::sync::Notify::new(); + let mut first = Box::pin(wallet.identity().erase_and_observe_with_submit( + &submitter, + &contract_id, + "note", + &document_id, + &signer, + |_, _| async { + entered.notify_one(); + std::future::pending::>().await + }, + )); + tokio::select! { + _ = entered.notified() => {}, + result = &mut first => panic!("first submission must remain pending: {result:?}"), + } + drop(first); + let calls = std::sync::atomic::AtomicUsize::new(0); + let outcome = wallet + .identity() + .erase_and_observe_with_submit( + &submitter, + &contract_id, + "note", + &document_id, + &signer, + |_, _| async { + calls.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + Ok(()) + }, + ) + .await + .unwrap(); + assert_eq!(calls.load(std::sync::atomic::Ordering::SeqCst), 1); + assert!(matches!(outcome, DocumentEraseOutcome::Submitted { .. })); + } + + #[tokio::test] + async fn should_not_submit_when_the_newest_owner_page_has_a_different_lifecycle() { + use super::super::signing_key::tests::{available, wallet_with_signing_keys_on}; + let contract = contract(); + let mut sdk = dash_sdk::SdkBuilder::new_mock() + .with_version(PlatformVersion::latest()) + .build() + .unwrap(); + sdk.mock() + .expect_fetch(contract.id(), Some(contract.clone())) + .await + .unwrap(); + sdk.mock() + .expect_fetch( + history_query(&contract, DocumentHistoryFilter::StartAtTime(0)), + Some(history( + DocumentHistoryState::Deleted, + Identifier::from([9; 32]), + false, + )), + ) + .await + .unwrap(); + sdk.mock() + .expect_fetch( + history_query(&contract, DocumentHistoryFilter::Revision(3)), + Some(history( + DocumentHistoryState::Erasing, + Identifier::default(), + true, + )), + ) + .await + .unwrap(); + let mut control = sdk.clone(); + let wallet = wallet_with_signing_keys_on(sdk, Arc::new(NoPlatformPersistence)).await; + let calls = std::sync::atomic::AtomicUsize::new(0); + let outcome = wallet + .identity() + .erase_and_observe_with_submit( + &Identifier::default(), + &contract.id(), + "note", + &Identifier::from([2; 32]), + &available(&[1]), + |_, _| async { + calls.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + Ok(()) + }, + ) + .await + .unwrap(); + assert_eq!(calls.load(std::sync::atomic::Ordering::SeqCst), 0); + assert!(matches!( + outcome, + DocumentEraseOutcome::NotSubmitted { + reason: DocumentEraseNotSubmittedReason::PreflightUnavailable, + .. + } + )); + assert_eq!( + history_reads( + &mut control, + &contract, + DocumentHistoryFilter::StartAtTime(0) + ) + .await, + 1 + ); + assert_eq!( + history_reads(&mut control, &contract, DocumentHistoryFilter::Revision(3)).await, + 1 + ); + } +} diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/dpns_marketplace.rs b/packages/rs-platform-wallet/src/wallet/identity/network/dpns_marketplace.rs index f54f1791730..fc346c8d038 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/dpns_marketplace.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/dpns_marketplace.rs @@ -3943,6 +3943,7 @@ mod tests { generation, broadcaster, sdk_writer: Arc::new(super::super::sdk_writer::SdkWriter::new(sdk)), + document_erase_gate: Default::default(), dpns_operation_gate: Arc::new(tokio::sync::Mutex::new(())), dpns_sync_progress: Arc::new(std::sync::Mutex::new(BTreeMap::new())), } diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/identity_handle.rs b/packages/rs-platform-wallet/src/wallet/identity/network/identity_handle.rs index c8e7937b2e6..d89ea04eaee 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/identity_handle.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/identity_handle.rs @@ -526,6 +526,8 @@ pub struct IdentityWallet { /// signer-generic `PutDocument` trait) behind two by-value methods /// so the call sites stay simple. pub(crate) sdk_writer: Arc, + /// Prevents overlapping erase attempts for a document across cloned handles. + pub(crate) document_erase_gate: Arc, /// Serializes DPNS marketplace mutations and sync reconciliation for /// this wallet. Every cloned handle shares the same gate. pub(crate) dpns_operation_gate: Arc>, @@ -560,6 +562,7 @@ impl Clone for IdentityWallet { generation: Arc::clone(&self.generation), broadcaster: Arc::clone(&self.broadcaster), sdk_writer: Arc::clone(&self.sdk_writer), + document_erase_gate: Arc::clone(&self.document_erase_gate), dpns_operation_gate: Arc::clone(&self.dpns_operation_gate), dpns_sync_progress: Arc::clone(&self.dpns_sync_progress), } diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/key_selection.rs b/packages/rs-platform-wallet/src/wallet/identity/network/key_selection.rs index a1cde7283a6..2b21fde4be0 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/key_selection.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/key_selection.rs @@ -55,8 +55,8 @@ pub(crate) fn usable_authentication_key<'a>( /// Whether a key carrying `bounds` may sign a `document_type_name` document of `contract_id`. /// /// A contract group bound is answered by group membership, state the wallet does not hold, -/// so a group-bound key is never chosen here: the DashPay writes this picker serves are -/// signed with an unbound key or one bound to DashPay itself. +/// so a group-bound key is never chosen here. Callers use an unbound key or one +/// bound to the target contract or document type. fn bounds_cover( bounds: Option<&ContractBounds>, contract_id: Identifier, diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/mod.rs b/packages/rs-platform-wallet/src/wallet/identity/network/mod.rs index babb0e9fee1..ac7eba762cd 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/mod.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/mod.rs @@ -37,6 +37,11 @@ mod contract; mod decision_proposal; mod discovery; mod document; +mod document_erase; +pub(crate) use document_erase::DocumentEraseGate; +pub use document_erase::{ + DocumentEraseNotSubmittedReason, DocumentEraseOutcome, DocumentLifecycleObservation, +}; mod dpns; mod dpns_marketplace; mod identity_handle; diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs b/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs index 5060aa6295d..90591b4ab63 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs @@ -13432,6 +13432,7 @@ mod tests { generation: Arc::clone(&real.generation), broadcaster: Arc::new(GatedRejectingBroadcaster { entered, release }), sdk_writer: Arc::clone(&real.sdk_writer), + document_erase_gate: Arc::clone(&real.document_erase_gate), dpns_operation_gate: Arc::clone(&real.dpns_operation_gate), dpns_sync_progress: Arc::clone(&real.dpns_sync_progress), } @@ -13474,6 +13475,7 @@ mod tests { generation: Arc::clone(&real.generation), broadcaster: Arc::new(GatedBroadcaster { entered, release }), sdk_writer: Arc::clone(&real.sdk_writer), + document_erase_gate: Arc::clone(&real.document_erase_gate), dpns_operation_gate: Arc::clone(&real.dpns_operation_gate), dpns_sync_progress: Arc::clone(&real.dpns_sync_progress), } @@ -13530,6 +13532,7 @@ mod tests { generation: Arc::clone(&real.generation), broadcaster: Arc::new(broadcaster), sdk_writer: Arc::clone(&real.sdk_writer), + document_erase_gate: Arc::clone(&real.document_erase_gate), dpns_operation_gate: Arc::clone(&real.dpns_operation_gate), dpns_sync_progress: Arc::clone(&real.dpns_sync_progress), } diff --git a/packages/rs-platform-wallet/src/wallet/platform_wallet.rs b/packages/rs-platform-wallet/src/wallet/platform_wallet.rs index c67a5462f70..8a7edc96b0b 100644 --- a/packages/rs-platform-wallet/src/wallet/platform_wallet.rs +++ b/packages/rs-platform-wallet/src/wallet/platform_wallet.rs @@ -806,6 +806,7 @@ impl PlatformWallet { sdk_writer: Arc::new( crate::wallet::identity::network::sdk_writer::SdkWriter::new(Arc::clone(&sdk)), ), + document_erase_gate: Default::default(), dpns_operation_gate: Arc::new(tokio::sync::Mutex::new(())), dpns_sync_progress: Arc::new(std::sync::Mutex::new(BTreeMap::new())), }; diff --git a/packages/rs-sdk-ffi/src/document/erase.rs b/packages/rs-sdk-ffi/src/document/erase.rs index ded4dbc41bd..4cb58dc3014 100644 --- a/packages/rs-sdk-ffi/src/document/erase.rs +++ b/packages/rs-sdk-ffi/src/document/erase.rs @@ -94,13 +94,13 @@ pub unsafe extern "C" fn dash_sdk_document_erase( let result: Result, FFIError> = wrapper.runtime.block_on(async { // Parse identifiers (base58 encoded) let doc_id = Identifier::from_string(document_id_str, Encoding::Base58) - .map_err(|e| FFIError::InternalError(format!("Invalid document ID: {}", e)))?; + .map_err(|e| FFIError::InvalidParameter(format!("Invalid document ID: {}", e)))?; let owner_identifier = Identifier::from_string(owner_id_str, Encoding::Base58) - .map_err(|e| FFIError::InternalError(format!("Invalid owner ID: {}", e)))?; + .map_err(|e| FFIError::InvalidParameter(format!("Invalid owner ID: {}", e)))?; let contract_id = Identifier::from_string(contract_id_str, Encoding::Base58) - .map_err(|e| FFIError::InternalError(format!("Invalid contract ID: {}", e)))?; + .map_err(|e| FFIError::InvalidParameter(format!("Invalid contract ID: {}", e)))?; // Resolve the contract through the SDK's current context provider. let data_contract = wrapper.data_contract(&contract_id)?; @@ -259,13 +259,13 @@ pub unsafe extern "C" fn dash_sdk_document_erase_and_wait( let result: Result = wrapper.runtime.block_on(async { // Parse identifiers (base58 encoded) let doc_id = Identifier::from_string(document_id_str, Encoding::Base58) - .map_err(|e| FFIError::InternalError(format!("Invalid document ID: {}", e)))?; + .map_err(|e| FFIError::InvalidParameter(format!("Invalid document ID: {}", e)))?; let owner_identifier = Identifier::from_string(owner_id_str, Encoding::Base58) - .map_err(|e| FFIError::InternalError(format!("Invalid owner ID: {}", e)))?; + .map_err(|e| FFIError::InvalidParameter(format!("Invalid owner ID: {}", e)))?; let contract_id = Identifier::from_string(contract_id_str, Encoding::Base58) - .map_err(|e| FFIError::InternalError(format!("Invalid contract ID: {}", e)))?; + .map_err(|e| FFIError::InvalidParameter(format!("Invalid contract ID: {}", e)))?; // Resolve the contract through the SDK's current context provider. let data_contract = wrapper.data_contract(&contract_id)?; @@ -349,6 +349,43 @@ mod tests { use std::ffi::{CStr, CString}; use std::ptr; + #[test] + fn should_classify_malformed_erase_identifiers_as_invalid_parameter() { + let sdk = create_mock_sdk_handle(); + let valid = CString::new(Identifier::from([1; 32]).to_string(Encoding::Base58)).unwrap(); + let invalid = CString::new("not-base58-0OIl").unwrap(); + let name = CString::new("note").unwrap(); + let key = create_mock_identity_public_key(); + let signer = create_mock_signer(); + let mut observed = Vec::new(); + for export in [dash_sdk_document_erase, dash_sdk_document_erase_and_wait] { + for malformed in 0..3 { + let mut ids = [valid.as_ptr(); 3]; + ids[malformed] = invalid.as_ptr(); + let result = unsafe { + export( + sdk, + ids[0], + ids[1], + ids[2], + name.as_ptr(), + ptr::from_ref(key.as_ref()).cast(), + ptr::from_ref(signer.as_ref()).cast(), + ptr::null(), + ptr::null(), + ) + }; + assert!(!result.error.is_null()); + unsafe { + observed.push((*result.error).code); + crate::dash_sdk_error_free(result.error); + } + } + } + destroy_mock_sdk_handle(sdk); + assert_eq!(observed, vec![DashSDKErrorCode::InvalidParameter; 6]); + } + fn assert_erase_uses_current_context_provider(wait_for_result: bool, expected_context: &str) { let contract = create_mock_data_contract(); let contract_id = CString::new(contract.id().to_string(Encoding::Base58)).unwrap(); diff --git a/packages/rs-sdk-ffi/src/document/queries/history.rs b/packages/rs-sdk-ffi/src/document/queries/history.rs index 68b7863b616..5ad3beea888 100644 --- a/packages/rs-sdk-ffi/src/document/queries/history.rs +++ b/packages/rs-sdk-ffi/src/document/queries/history.rs @@ -290,6 +290,38 @@ mod tests { assert!(message.contains("document type not found"), "{message}"); } + #[test] + fn should_classify_invalid_history_limits_as_invalid_parameter() { + let contract = create_mock_data_contract(); + let contract_id = CString::new(contract.id().to_string(Encoding::Base58)).unwrap(); + let sdk = create_mock_sdk_handle_with_current_contracts(vec![*contract]); + let document_id = + CString::new(Identifier::from([2; 32]).to_string(Encoding::Base58)).unwrap(); + let name = CString::new("testDoc").unwrap(); + let mut codes = Vec::new(); + for limit in [11, u16::MAX as u32 + 1, u32::MAX] { + let result = unsafe { + dash_sdk_document_fetch_history( + sdk, + contract_id.as_ptr(), + name.as_ptr(), + document_id.as_ptr(), + 0, + 0, + 0, + limit, + ) + }; + assert!(!result.error.is_null()); + unsafe { + codes.push((*result.error).code); + crate::dash_sdk_error_free(result.error); + } + } + destroy_mock_sdk_handle(sdk); + assert_eq!(codes, vec![DashSDKErrorCode::InvalidParameter; 3]); + } + fn revision_document(revision: u64) -> Document { let mut properties = BTreeMap::new(); properties.insert( diff --git a/packages/rs-sdk/src/error.rs b/packages/rs-sdk/src/error.rs index a142626ec29..ad236dbdacb 100644 --- a/packages/rs-sdk/src/error.rs +++ b/packages/rs-sdk/src/error.rs @@ -29,7 +29,7 @@ pub enum Error { #[error("SDK misconfigured: {0}")] Config(String), /// The request cannot succeed as written on any node: the SDK refused it before sending - /// it, because no node serves it or no answer to it verifies as the requested result + /// it, because its query syntax or bounds are invalid, no node serves it, or no answer verifies as the requested result /// type, or a fresh verified answer showed that the result cannot be returned as that /// type (for example several documents for a single-document fetch). /// diff --git a/packages/rs-sdk/src/platform/query.rs b/packages/rs-sdk/src/platform/query.rs index 74d24fc11e0..bcca377f85c 100644 --- a/packages/rs-sdk/src/platform/query.rs +++ b/packages/rs-sdk/src/platform/query.rs @@ -408,7 +408,7 @@ impl Query for DocumentHistoryQuery { .limit .map(u16::try_from) .transpose() - .map_err(|_| Error::Generic("history limit out of bounds".to_owned()))?; + .map_err(|_| Error::InvalidRequest("history limit out of bounds".to_owned()))?; DocumentHistoryDriveQuery { contract_id: self.data_contract_id.to_buffer(), document_type_name: self.document_type_name.clone(), @@ -416,7 +416,11 @@ impl Query for DocumentHistoryQuery { filter: self.filter.clone(), limit, } - .validate()?; + .validate() + .map_err(|error| match error { + drive::error::Error::Query(_) => Error::InvalidRequest(error.to_string()), + other => Error::Drive(other), + })?; let filter = match self.filter { DocumentHistoryFilter::StartAtTime(time) => Filter::StartAtMs(time), DocumentHistoryFilter::StartAfter { time_ms, revision } => { @@ -1825,6 +1829,48 @@ mod history_query_tests { assert_eq!(result, expected); } + #[test] + fn should_classify_invalid_history_selectors_as_invalid_requests() { + let request_settings = Default::default(); + let settings = QuerySettings { + request_settings: &request_settings, + protocol_version: PlatformVersion::latest(), + verified_protocol_version: 0, + prove: true, + }; + let invalid = [ + (DocumentHistoryFilter::StartAtTime(0), Some(0)), + (DocumentHistoryFilter::StartAtTime(0), Some(11)), + (DocumentHistoryFilter::StartAtTime(0), Some(u32::MAX)), + (DocumentHistoryFilter::Revision(1), Some(2)), + (DocumentHistoryFilter::StartAtRevision(0), Some(1)), + ]; + for (filter, limit) in invalid { + let query = DocumentHistoryQuery { + data_contract_id: [1; 32].into(), + document_type_name: "note".into(), + document_id: [2; 32].into(), + filter, + limit, + }; + assert!( + matches!(query.query(&settings), Err(Error::InvalidRequest(_))), + "{query:?}: {:?}", + query.query(&settings) + ); + } + for limit in [None, Some(1), Some(10)] { + let query = DocumentHistoryQuery { + data_contract_id: [1; 32].into(), + document_type_name: "note".into(), + document_id: [2; 32].into(), + filter: DocumentHistoryFilter::StartAtTime(0), + limit, + }; + assert!(query.query(&settings).is_ok()); + } + } + #[test] fn should_report_oversized_history_limits_as_request_errors() { let request_settings = Default::default(); @@ -1843,7 +1889,7 @@ mod history_query_tests { limit: Some(limit), }; assert!( - matches!(query.query(&settings), Err(Error::Generic(message)) + matches!(query.query(&settings), Err(Error::InvalidRequest(message)) if message == "history limit out of bounds") ); } diff --git a/packages/rs-unified-sdk-jni/Cargo.toml b/packages/rs-unified-sdk-jni/Cargo.toml index 9f5b2413f06..bf80556772e 100644 --- a/packages/rs-unified-sdk-jni/Cargo.toml +++ b/packages/rs-unified-sdk-jni/Cargo.toml @@ -14,6 +14,8 @@ crate-type = ["cdylib"] [dependencies] jni = "0.21" rs-sdk-ffi = { path = "../rs-sdk-ffi" } +dpp = { path = "../rs-dpp" } +serde_json = "1.0" platform-wallet-ffi = { path = "../rs-platform-wallet-ffi" } log = "0.4" zeroize = "1" @@ -26,9 +28,6 @@ dashcore = { workspace = true } # Anchors the cross-language golden-fixture test to the canonical DashPay # contract id, so the mirrored Kotlin constant can't drift undetected. dashpay-contract = { path = "../dashpay-contract" } -# Builds the state-transition fixtures whose parsed blobs are the goldens -# shared with the Kotlin `StateTransitionParserTest`. -dpp = { path = "../rs-dpp" } [features] default = ["shielded"] diff --git a/packages/rs-unified-sdk-jni/src/transactions.rs b/packages/rs-unified-sdk-jni/src/transactions.rs index f00982c1247..e41f025b5ff 100644 --- a/packages/rs-unified-sdk-jni/src/transactions.rs +++ b/packages/rs-unified-sdk-jni/src/transactions.rs @@ -40,11 +40,17 @@ use crate::pubkey_rows::decode_update_pubkeys_blob; use crate::support::{guard, net_from_ord, take_pwffi_error, throw_sdk_exception}; +use dpp::platform_value::string_encoding::Encoding; +use dpp::prelude::Identifier; use jni::objects::{JByteArray, JClass, JString}; use jni::sys::{jboolean, jint, jlong, jstring}; use jni::JNIEnv; use platform_wallet_ffi::handle::Handle; use platform_wallet_ffi::identity_registration_with_signer::IdentityPubkeyFFI; +use platform_wallet_ffi::{ + DocumentEraseNotSubmittedReasonFFI as Reason, DocumentEraseOutcomeKindFFI as Kind, + DocumentLifecycleObservationFFI, DocumentLifecycleObservationTagFFI as State, +}; use rs_sdk_ffi::SignerHandle; use std::ffi::{CStr, CString}; use std::os::raw::c_char; @@ -746,71 +752,102 @@ pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_TransactionsNative_do }) } -/// Erase + broadcast a chunk of the retained revisions of the already -/// deleted `documentId` on `contractId`'s `documentType`, signed via -/// `signerHandle` with key `signingKeyId` of `ownerId` — the JNI bridge -/// over `platform_wallet_document_erase` (Swift -/// `ManagedPlatformWallet.eraseDocument`). The first erase of a document -/// must be signed by its owner; later ones may be signed by any identity. -/// -/// Erase returns no document body, so this returns the document's 32-byte -/// id as a `byte[]` once its absence is observed under a proof (which it -/// already was before the erase; progress is read from the history). -/// Null after throwing on error. +/// Marshal the wallet's single erase operation; selection and submission policy +/// stay in Rust. The caller receives typed-outcome JSON, not an echoed id. #[no_mangle] #[allow(clippy::too_many_arguments)] -pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_TransactionsNative_documentErase( +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_TransactionsNative_documentEraseAndObserve( mut env: JNIEnv, _class: JClass, wallet_handle: jlong, - owner_id: JByteArray, + submitting_identity_id: JByteArray, contract_id: JByteArray, document_type: JString, document_id: JByteArray, - signing_key_id: jint, signer_handle: jlong, -) -> jni::sys::jbyteArray { +) -> jstring { guard(&mut env, ptr::null_mut(), |env| { - if signing_key_id < 0 { - throw_sdk_exception(env, 1, "signingKeyId must be non-negative"); - return ptr::null_mut(); - } - let Some(owner) = read_id32(env, &owner_id, "ownerId") else { + let Some(submitter) = read_id32(env, &submitting_identity_id, "submittingIdentityId") + else { return ptr::null_mut(); }; let Some(contract) = read_id32(env, &contract_id, "contractId") else { return ptr::null_mut(); }; - let Some(doc_id) = read_id32(env, &document_id, "documentId") else { + let Some(document) = read_id32(env, &document_id, "documentId") else { return ptr::null_mut(); }; - let Some(doc_type) = read_cstring(env, &document_type, "documentType") else { + let Some(document_type) = read_cstring(env, &document_type, "documentType") else { return ptr::null_mut(); }; - - let mut out_id = [0u8; 32]; + let mut out = platform_wallet_ffi::DocumentEraseOutcomeFFI::default(); let result = unsafe { - platform_wallet_ffi::platform_wallet_document_erase( + platform_wallet_ffi::platform_wallet_document_erase_and_observe( wallet_handle as Handle, - owner.as_ptr(), + submitter.as_ptr(), contract.as_ptr(), - doc_type.as_ptr(), - doc_id.as_ptr(), - signing_key_id as u32, + document_type.as_ptr(), + document.as_ptr(), signer_handle as *mut SignerHandle, - out_id.as_mut_ptr(), + &mut out, ) }; if take_pwffi_error(env, result) { return ptr::null_mut(); } - - env.byte_array_from_slice(&out_id) - .map(|a| a.into_raw()) + let Ok(json) = erase_outcome_to_json(out) else { + throw_sdk_exception( + env, + 99, + "Erase result unreadable; read history before retrying.", + ); + return ptr::null_mut(); + }; + env.new_string(json) + .map(|string| string.into_raw()) .unwrap_or(ptr::null_mut()) }) } +fn erase_outcome_to_json( + out: platform_wallet_ffi::DocumentEraseOutcomeFFI, +) -> Result { + fn observation(value: DocumentLifecycleObservationFFI) -> serde_json::Value { + let state = match value.state { + State::Unavailable => return serde_json::Value::Null, + State::Active => "ACTIVE", + State::Absent => "ABSENT", + State::Deleted => "DELETED", + State::Erasing => "ERASING", + }; + serde_json::json!({ "state": state, "remaining_revisions": value.remaining_revisions, + "deleted_at_ms": value.deleted_at_ms, "erasing_started_at_ms": value.erasing_started_at_ms, + "erasing_from_time_ms": value.erasing_from_time_ms, "erasing_from_revision": value.erasing_from_revision }) + } + let kind = match out.kind { + Kind::NotSubmitted => "NOT_SUBMITTED", + Kind::Submitted => "SUBMITTED", + Kind::Unset => return Err("missing outcome"), + }; + let reason = match out.reason { + Reason::None => None, + Reason::Active => Some("ACTIVE"), + Reason::Absent => Some("ABSENT"), + Reason::NotNewestOwner => Some("NOT_NEWEST_OWNER"), + Reason::PreflightUnavailable => Some("PREFLIGHT_UNAVAILABLE"), + }; + let owner = if out.reason == Reason::NotNewestOwner { + Some(Identifier::from(out.owner).to_string(Encoding::Base58)) + } else { + None + }; + Ok( + serde_json::json!({ "kind": kind, "reason": reason, "owner": owner, + "before": observation(out.before), "after": observation(out.after) }) + .to_string(), + ) +} + /// Transfer + broadcast `documentId` on `contractId`'s `documentType`, /// from `ownerId` to `recipientId`, signed via `signerHandle` with key /// `signingKeyId` — the JNI bridge over `platform_wallet_document_transfer` @@ -1017,3 +1054,81 @@ pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_TransactionsNative_ca // `success(null)`), so nothing else to release here. }) } + +#[cfg(test)] +mod erase_outcome_tests { + use super::*; + + #[test] + fn should_preserve_not_submitted_reasons_and_all_observation_states() { + assert!(erase_outcome_to_json(Default::default()).is_err()); + for (reason, expected) in [ + (Reason::Active, "ACTIVE"), + (Reason::Absent, "ABSENT"), + (Reason::NotNewestOwner, "NOT_NEWEST_OWNER"), + (Reason::PreflightUnavailable, "PREFLIGHT_UNAVAILABLE"), + ] { + for (state, expected_state) in [ + (State::Unavailable, None), + (State::Active, Some("ACTIVE")), + (State::Absent, Some("ABSENT")), + (State::Deleted, Some("DELETED")), + (State::Erasing, Some("ERASING")), + ] { + let out = platform_wallet_ffi::DocumentEraseOutcomeFFI { + kind: Kind::NotSubmitted, + reason, + owner: [1; 32], + before: DocumentLifecycleObservationFFI { + state, + remaining_revisions: u64::MAX, + ..Default::default() + }, + ..Default::default() + }; + let json: serde_json::Value = + serde_json::from_str(&erase_outcome_to_json(out).unwrap()).unwrap(); + assert_eq!(json["kind"], "NOT_SUBMITTED"); + assert_eq!(json["reason"], expected); + assert!(json["after"].is_null()); + if reason == Reason::NotNewestOwner { + assert_eq!( + json["owner"], + Identifier::from([1; 32]).to_string(Encoding::Base58) + ); + } else { + assert!(json["owner"].is_null()); + } + if let Some(expected_state) = expected_state { + assert_eq!(json["before"]["state"], expected_state); + assert_eq!(json["before"]["remaining_revisions"], u64::MAX); + } else { + assert!(json["before"].is_null()); + } + } + } + } + + #[test] + fn should_match_the_lifecycle_fixture_decoded_by_kotlin() { + let out = platform_wallet_ffi::DocumentEraseOutcomeFFI { + kind: Kind::Submitted, + before: DocumentLifecycleObservationFFI { + state: State::Erasing, + remaining_revisions: u64::MAX, + deleted_at_ms: 1, + erasing_started_at_ms: 2, + erasing_from_time_ms: 3, + erasing_from_revision: u64::MAX, + }, + ..Default::default() + }; + let actual: serde_json::Value = + serde_json::from_str(&erase_outcome_to_json(out).unwrap()).unwrap(); + let expected: serde_json::Value = serde_json::from_str(include_str!( + "../../kotlin-sdk/sdk/src/test/resources/document_erase_outcome_from_native.json" + )) + .unwrap(); + assert_eq!(actual, expected); + } +} diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift b/packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift index b253238d40a..b2a5dc7ed96 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift @@ -226,6 +226,21 @@ public struct DocumentHistoryLifecycle: Sendable { self.erasingFromRevision = erasingFromRevision } + init(ffi: DocumentLifecycleObservationFFI) throws { + switch ffi.state { + case 1: state = .active + case 2: state = .absent + case 3: state = .deleted + case 4: state = .erasing + default: throw DocumentEraseResultUnreadable() + } + remainingRevisions = ffi.remaining_revisions + deletedAtMs = ffi.deleted_at_ms + erasingStartedAtMs = ffi.erasing_started_at_ms + erasingFromTimeMs = ffi.erasing_from_time_ms + erasingFromRevision = ffi.erasing_from_revision + } + /// Words for what an erase achieved, from the lifecycle read before it /// was submitted (nil when not read) and the one read after its absence /// was observed. The erase result itself proves only that the document diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swift b/packages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swift index c25452c7c85..a06225fe9dd 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swift @@ -918,103 +918,6 @@ extension SDK { } } - /// Erase a chunk of the retained revisions of an already deleted - /// keep-history document. The first erase must be signed by the - /// document's owner; later ones may be signed by any identity, so - /// `ownerIdentity` is the signing identity. Returns once the transition - /// is broadcast and Platform has proved the document absent from - /// ordinary reads, which it already was, so a return observes the - /// affected state rather than proving this erase removed a revision; - /// `documentGetLifecycle` reports the state and how many revisions - /// remain. - public func documentErase( - contractId: String, - documentType: String, - documentId: String, - ownerIdentity: DPPIdentity, - signer: OpaquePointer - ) async throws { - let signerBox = SendableOpaque(signer) - let startTime = Date() - print("🧹 [DOCUMENT ERASE] Starting at \(startTime)") - print("🧹 [DOCUMENT ERASE] Contract: \(contractId), Type: \(documentType), Doc: \(documentId)") - - // Select the signing key on the MainActor (KeyManager is @MainActor) - // before dispatching the FFI work off-actor. - guard let signingKey = selectSigningKey(from: ownerIdentity, operation: "DOCUMENT ERASE", signer: signer) else { - throw SDKError.protocolError("No suitable key found for signing") - } - - try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in - DispatchQueue.global().async { [weak self] in - guard let self = self, let handle = self.handle else { - continuation.resume(throwing: SDKError.invalidState("SDK not initialized")) - return - } - - do { - // Prepare C strings - guard let documentIdCString = documentId.cString(using: .utf8), - let ownerIdCString = ownerIdentity.id.toBase58String().cString(using: .utf8), - let contractIdCString = contractId.cString(using: .utf8), - let documentTypeCString = documentType.cString(using: .utf8) else { - throw SDKError.serializationError("Failed to encode strings to C strings") - } - - // Key selection happened on the MainActor before dispatch. - let keyToUse = signingKey - - // Create public key handle - guard let keyHandle = createPublicKeyHandle(from: keyToUse, operation: "DOCUMENT ERASE") else { - throw SDKError.protocolError("Failed to create public key handle") - } - - defer { - dash_sdk_identity_public_key_destroy(keyHandle) - } - - // Call the FFI function with network timing - let networkStartTime = Date() - print("🧹 [DOCUMENT ERASE] Calling dash_sdk_document_erase_and_wait...") - print("🧹 [DOCUMENT ERASE] Document ID: \(documentId)") - print("🧹 [DOCUMENT ERASE] Signer ID: \(ownerIdentity.id.toBase58String())") - - let result = dash_sdk_document_erase_and_wait( - handle, - documentIdCString, - ownerIdCString, - contractIdCString, - documentTypeCString, - keyHandle, - signerBox.p, - nil, // put_settings - nil // state_transition_creation_options - ) - - let networkTime = Date().timeIntervalSince(networkStartTime) - print("🧹 [DOCUMENT ERASE] Network call completed in \(networkTime) seconds") - - if let error = result.error { - let errorMessage = String(cString: error.pointee.message) - let failure = SDKError.stateTransitionFailure( - errorMessage, ffiError: error.pointee, otherwise: SDKError.protocolError) - dash_sdk_error_free(error) - throw failure - } - - let totalTime = Date().timeIntervalSince(startTime) - print("✅ [DOCUMENT ERASE] Broadcast done, absence observed. Total time: \(totalTime) seconds") - - continuation.resume() - } catch { - let totalTime = Date().timeIntervalSince(startTime) - print("❌ [DOCUMENT ERASE] Failed after \(totalTime) seconds: \(error)") - continuation.resume(throwing: error) - } - } - } - } - /// Transfer a document to another identity public func documentTransfer( contractId: String, diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/DocumentEraseOutcome.swift b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/DocumentEraseOutcome.swift new file mode 100644 index 00000000000..d4f768bf3b6 --- /dev/null +++ b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/DocumentEraseOutcome.swift @@ -0,0 +1,62 @@ +import Foundation +import DashSDKFFI + +/// Why Rust did not submit a paid erase. +public enum DocumentEraseNotSubmittedReason: Sendable { + case active + case absent + case notNewestOwner(Identifier) + case preflightUnavailable +} + +/// Submission and lifecycle observation are separate facts. +public enum DocumentEraseOutcome: Sendable { + case notSubmitted(reason: DocumentEraseNotSubmittedReason, before: DocumentHistoryLifecycle?) + case submitted(before: DocumentHistoryLifecycle?, after: DocumentHistoryLifecycle?) + + public var before: DocumentHistoryLifecycle? { + switch self { + case .notSubmitted(_, let before), .submitted(let before, _): return before + } + } + + public var after: DocumentHistoryLifecycle? { + if case .submitted(_, let after) = self { return after } + return nil + } + + init(ffi: DocumentEraseOutcomeFFI) throws { + guard (0...4).contains(ffi.reason) else { + throw DocumentEraseResultUnreadable() + } + func observation(_ value: DocumentLifecycleObservationFFI) throws -> DocumentHistoryLifecycle? { + if value.state == 0 { return nil } + return try DocumentHistoryLifecycle(ffi: value) + } + let before = try observation(ffi.before) + let after = try observation(ffi.after) + switch ffi.kind { + case 1: + let reason: DocumentEraseNotSubmittedReason + switch ffi.reason { + case 1: reason = .active + case 2: reason = .absent + case 3: + var owner = ffi.owner + reason = .notNewestOwner(withUnsafeBytes(of: &owner) { Data($0) }) + case 4: reason = .preflightUnavailable + default: throw DocumentEraseResultUnreadable() + } + self = .notSubmitted(reason: reason, before: before) + case 2: self = .submitted(before: before, after: after) + default: throw DocumentEraseResultUnreadable() + } + } +} + +/// An OK native result could not be decoded; submission failure cannot be inferred. +public struct DocumentEraseResultUnreadable: LocalizedError { + public var errorDescription: String? { + "Erase result unreadable; read history before retrying." + } +} diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift index f1b6599554e..dd76967b2b2 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift @@ -4995,73 +4995,40 @@ extension ManagedPlatformWallet { }.value } - /// Erase + broadcast a chunk of the retained revisions of the already - /// deleted `documentId` on `contractId`'s `documentType`, signed with - /// the explicit AUTHENTICATION + ECDSA key `signingKeyId` of - /// `ownerIdentityId`. Returns the document's 32-byte id once Platform - /// has proved it absent from ordinary reads. That absence predates the - /// erase, so the return observes the affected state and is not - /// evidence that this erase removed a revision; read - /// `SDK.documentGetLifecycle` for the state and the exact number of - /// revisions still retained. - /// - /// Sibling to `deleteDocument`. Routes through - /// `IdentityWallet::erase_document_with_signer` (via - /// `platform_wallet_document_erase`). Only a keep-history document - /// type whose schema sets `canBeErased` can be erased, and only after - /// the document has been deleted: the first erase must be signed by - /// the document's owner, every later one may be signed by any - /// identity, so `ownerIdentityId` is the signing identity rather than - /// necessarily the owner. One erase removes a bounded chunk of - /// revisions; erase again while the lifecycle reports any. Erase - /// returns no document body, so there is no canonical JSON. - public func eraseDocument( - ownerIdentityId: Identifier, + /// Rust owns eligibility, key selection, one submission and lifecycle observations. + public func eraseDocumentAndObserve( + submittingIdentityId: Identifier, contractId: Identifier, documentType: String, documentId: Identifier, - signingKeyId: UInt32, signer: KeychainSigner - ) async throws -> Identifier { - let handle = self.handle - let signerHandle = signer.handle - let ownerBytes: [UInt8] = ownerIdentityId.withFFIBytes { ptr in - Array(UnsafeBufferPointer(start: ptr, count: 32)) - } - let contractBytes: [UInt8] = contractId.withFFIBytes { ptr in - Array(UnsafeBufferPointer(start: ptr, count: 32)) - } - let documentBytes: [UInt8] = documentId.withFFIBytes { ptr in - Array(UnsafeBufferPointer(start: ptr, count: 32)) + ) async throws -> DocumentEraseOutcome { + guard submittingIdentityId.count == 32, contractId.count == 32, documentId.count == 32 else { + throw PlatformWalletError.invalidParameter("Identifiers must be 32 bytes") } return try await Task.detached(priority: .userInitiated) { [self] in - var documentIdBytes = [UInt8](repeating: 0, count: 32) - + var output = DocumentEraseOutcomeFFI() let result = withExtendedLifetime((self, signer)) { - ownerBytes.withUnsafeBufferPointer { ownerBp -> PlatformWalletFFIResult in - contractBytes.withUnsafeBufferPointer { contractBp -> PlatformWalletFFIResult in - documentType.withCString { typePtr in - documentBytes.withUnsafeBufferPointer { docBp -> PlatformWalletFFIResult in - documentIdBytes.withUnsafeMutableBufferPointer { outBp in - platform_wallet_document_erase( - handle, - ownerBp.baseAddress!, - contractBp.baseAddress!, - typePtr, - docBp.baseAddress!, - signingKeyId, - signerHandle, - outBp.baseAddress! - ) - } + submittingIdentityId.withUnsafeBytes { owner in + contractId.withUnsafeBytes { contract in + documentType.withCString { type in + documentId.withUnsafeBytes { document in + platform_wallet_document_erase_and_observe( + self.handle, + owner.bindMemory(to: UInt8.self).baseAddress!, + contract.bindMemory(to: UInt8.self).baseAddress!, + type, + document.bindMemory(to: UInt8.self).baseAddress!, + signer.handle, + &output + ) } } } } } - try result.check() - return Data(documentIdBytes) + return try DocumentEraseOutcome(ffi: output) }.value } diff --git a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift index c5cf986c4de..5970364bc2d 100644 --- a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift +++ b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift @@ -864,16 +864,29 @@ struct DeleteDocumentView: View { // MARK: Erase -/// Erases the retained revisions of a keep-history document that has -/// already been deleted, one bounded chunk per broadcast. The row is still -/// local because the deletion happened elsewhere (another device or the -/// Settings builder). An ACTIVE or ABSENT lifecycle skips the broadcast. -/// -/// The erase result only observes that the document is absent from -/// ordinary reads, which it already was, so the sheet reads the lifecycle -/// before and after each broadcast and shows what that read says. It stays -/// open with the same id so further chunks can be submitted, and removes -/// the local row only once the lifecycle reports the document absent. +/// Display the Rust operation's decision and observations without deciding eligibility. +func describeDocumentEraseOutcome(_ outcome: DocumentEraseOutcome) -> String { + switch outcome { + case .notSubmitted(let reason, _): + let explanation: String + switch reason { + case .active: explanation = "The document is active." + case .absent: explanation = "No retained revisions exist." + case .notNewestOwner(let owner): + explanation = "The newest retained revision belongs to \(owner.toBase58String()). Erase from that identity (Settings → Document Erase)." + case .preflightUnavailable: + explanation = "Lifecycle or ownership could not be read; read history before retrying." + } + return "Erase not submitted. " + explanation + case .submitted(let before, let after): + return "Erase submitted; document absence observed. " + (after.map { + DocumentHistoryLifecycle.describeEraseProgress(before: before, after: $0) + } ?? "Lifecycle not read; query the document history to see what remains.") + } +} + +/// Displays one erase attempt at a time and removes the local row only after +/// a proved observation reports the document absent. struct EraseDocumentView: View { let document: PersistentDocument private let documentIdText: String @@ -901,6 +914,7 @@ struct EraseDocumentView: View { @State private var persistWarning: String? @State private var actionError: DocumentActionErrorBox? + // This hides a button for presentation; Rust re-decides eligibility on every call. private var canSubmitAnother: Bool { guard let lifecycle else { return submissions == 0 } return lifecycle.state == .erasing || lifecycle.state == .deleted @@ -917,7 +931,7 @@ struct EraseDocumentView: View { DetailRow(label: "Revisions retained", value: String(lifecycle.remainingRevisions)) } } footer: { - Text("Removes up to 100 retained revisions of a document that has already been deleted on Platform. The document type must allow erasure, and only the owner may start it. If the initial lifecycle read fails, an erase may still be submitted for an active document; consensus rejects it and still charges a fee. A broadcast only observes that the document is absent from ordinary reads; the lifecycle read after it says what remains. This cannot be undone.") + Text("Removes up to 100 retained revisions of a document that has already been deleted on Platform. The document type must allow erasure, and only the owner may start it. The lifecycle and initial ownership must be read before an erase can be submitted. If either read is unavailable, read history before retrying. A broadcast only observes that the document is absent from ordinary reads; the lifecycle read after it says what remains. This cannot be undone.") } if submissions > 0 || progress != nil { Section { @@ -986,7 +1000,7 @@ struct EraseDocumentView: View { lifecycle = observed } .alert(item: $actionError) { err in - Alert(title: Text("Erase failed"), message: Text(err.message), dismissButton: .default(Text("OK"))) + Alert(title: Text("Erase status"), message: Text(err.message), dismissButton: .default(Text("OK"))) } } } @@ -1004,15 +1018,9 @@ struct EraseDocumentView: View { actionError = .init(message: DocumentActionError.identityNotFound.localizedDescription) return } - let docType = document.documentType_relation - let wallet: ManagedPlatformWallet - let signingKeyId: UInt32 - do { - (wallet, signingKeyId) = try DocumentActionRunner.resolveSigning( - for: owner, documentType: docType, walletManager: walletManager - ) - } catch { - actionError = .init(message: error.localizedDescription) + guard let walletId = owner.wallet?.walletId, + let wallet = walletManager.wallet(for: walletId) else { + actionError = .init(message: DocumentActionError.noWallet.localizedDescription) return } @@ -1020,55 +1028,38 @@ struct EraseDocumentView: View { let signer = KeychainSigner(modelContainer: modelContext.container) let ownerId = owner.identityId let contractId = document.contractIdData - let contractIdBase58 = document.contractIdBase58 let typeName = document.documentType let docId = document.id - let docIdBase58 = document.documentId - let sdk = appState.sdk Task { do { - let before = try? await sdk?.documentGetLifecycle( - dataContractId: contractIdBase58, documentType: typeName, documentId: docIdBase58 - ) - if let before, before.state == .active || before.state == .absent { - await MainActor.run { - lifecycle = before - progress = "Erase not submitted. " + (before.state == .absent - ? "No retained revisions exist." - : DocumentHistoryLifecycle.describeEraseProgress(before: before, after: before)) - isSubmitting = false - } - return - } - _ = try await wallet.eraseDocument( - ownerIdentityId: ownerId, + let outcome = try await wallet.eraseDocumentAndObserve( + submittingIdentityId: ownerId, contractId: contractId, documentType: typeName, documentId: docId, - signingKeyId: signingKeyId, signer: signer ) - _ = signer - let after = try? await sdk?.documentGetLifecycle( - dataContractId: contractIdBase58, documentType: typeName, documentId: docIdBase58 - ) await MainActor.run { - submissions += 1 - lifecycle = after - if let after { - progress = DocumentHistoryLifecycle.describeEraseProgress(before: before, after: after) - if after.state == .absent { + progress = describeDocumentEraseOutcome(outcome) + switch outcome { + case .notSubmitted(_, let before): lifecycle = before + case .submitted(_, let after): + submissions += 1 + lifecycle = after + if after?.state == .absent { persistWarning = DocumentPersistence.applyDelete( - document: document, - modelContext: modelContext + document: document, modelContext: modelContext ) } - } else { - progress = "Lifecycle not read; use Platform Queries → Get Document History to see what remains." } isSubmitting = false } + } catch PlatformWalletError.transactionBroadcastUnconfirmed(_) { + await MainActor.run { + actionError = .init(message: "Erase outcome unknown; do not resubmit automatically; read history first.") + isSubmitting = false + } } catch { await MainActor.run { actionError = .init(message: error.localizedDescription) diff --git a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TransitionDetailView.swift b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TransitionDetailView.swift index 6779a97b78d..fa181e4a401 100644 --- a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TransitionDetailView.swift +++ b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TransitionDetailView.swift @@ -1231,81 +1231,47 @@ struct TransitionDetailView: View { let signingIdentity = identities.first(where: { $0.identityIdBase58 == selectedIdentityId }) else { throw SDKError.invalidParameter("No identity selected") } - - guard let contractId = formInputs["contractId"], !contractId.isEmpty else { + guard let walletId = signingIdentity.wallet?.walletId, + let wallet = walletManager.wallet(for: walletId) else { + throw SDKError.invalidParameter("Identity has no wallet linkage; cannot erase document history") + } + guard let contractText = formInputs["contractId"], + let contractId = Data.identifier(fromBase58: contractText) else { throw SDKError.invalidParameter("Data contract is required") } - guard let documentType = formInputs["documentType"], !documentType.isEmpty else { throw SDKError.invalidParameter("Document type is required") } - - guard let documentId = formInputs["documentId"], !documentId.isEmpty else { + guard let documentText = formInputs["documentId"], + let documentId = Data.identifier(fromBase58: documentText) else { throw SDKError.invalidParameter("Document ID is required") } - - // The selected identity signs and pays. It must own the document for - // the first erase; any identity may submit the ones after it. - let dppIdentity = DPPIdentity( - id: signingIdentity.identityId, - publicKeys: Dictionary(uniqueKeysWithValues: signingIdentity.identityPublicKeys.map { ($0.id, $0) }), - balance: UInt64(bitPattern: signingIdentity.balance), - revision: 0 - ) - - // External-signer pattern (see executeDataContractCreate for the - // architectural rationale). Rust calls back through the - // `KeychainSigner` trampoline when it needs a signature. let signer = KeychainSigner(modelContainer: modelContext.container) - - // The erase result only observes that the document is absent from - // ordinary reads, which it already was; what the erase achieved is read - // from the lifecycle before and after. - let before = try? await sdk.documentGetLifecycle( - dataContractId: contractId, documentType: documentType, documentId: documentId - ) - - if let before, before.state == .active || before.state == .absent { - return [ - "message": "Erase not submitted", - "lifecycle": before.state.rawValue, - "remainingRevisions": before.remainingRevisions, - "progress": before.state == .absent - ? "No retained revisions exist." - : DocumentHistoryLifecycle.describeEraseProgress(before: before, after: before) - ] + let outcome: DocumentEraseOutcome + do { + outcome = try await wallet.eraseDocumentAndObserve( + submittingIdentityId: signingIdentity.identityId, + contractId: contractId, + documentType: documentType, + documentId: documentId, + signer: signer + ) + } catch PlatformWalletError.transactionBroadcastUnconfirmed(_) { + throw PlatformWalletError.transactionBroadcastUnconfirmed( + "Erase outcome unknown; do not resubmit automatically; read history first." + ) } - - try await sdk.documentErase( - contractId: contractId, - documentType: documentType, - documentId: documentId, - ownerIdentity: dppIdentity, - signer: signer.handle - ) - _ = signer // keepalive across the await — see KeychainSigner lifetime contract - - // The erase is broadcast and confirmed by this point, so the closing - // lifecycle read fails on its own terms: an unreadable observation is - // reported as unread, never as a failed erase the user would pay to - // submit a second time. - let after = try? await sdk.documentGetLifecycle( - dataContractId: contractId, documentType: documentType, documentId: documentId - ) - - guard let after else { - return [ - "message": "Erase submitted; document absence observed under proof", - "progress": "Lifecycle not read; use Platform Queries → Get Document History to see what remains." - ] + var result: [String: Any] = ["message": describeDocumentEraseOutcome(outcome)] + let observation: DocumentHistoryLifecycle? + switch outcome { + case .notSubmitted(_, let before): observation = before + case .submitted(_, let after): observation = after } - - return [ - "message": "Erase submitted; document absence observed under proof", - "lifecycle": after.state.rawValue, - "remainingRevisions": after.remainingRevisions, - "progress": DocumentHistoryLifecycle.describeEraseProgress(before: before, after: after) - ] + if let observation { + result["lifecycle"] = observation.state.rawValue + result["remainingRevisions"] = observation.remainingRevisions + } + return result } private func executeDocumentTransfer(sdk: SDK) async throws -> Any { diff --git a/packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md b/packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md index 466ef778879..7b1b08bcbe2 100644 --- a/packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md +++ b/packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md @@ -225,7 +225,7 @@ The app is a full multi-wallet client: `PlatformWalletManager` holds N wallets c | DOC-13 | Aggregation — sum of a numeric property | Platform | Uncommon | 🧪 | aggregation, read-only | **Sum / Average Documents** read view (op selector → **Sum**) → Swift wrapper over FFI `dash_sdk_document_sum` (proof-verified). Total sum is `sums[""]` in the `{sums:{hexKey:i64}}` result; a `where`/`group_by` filter and the required numeric `sum property` are entered in the same view. Needs a contract doc type with a `summable` index on the numeric property. | | DOC-14 | Aggregation — average of a numeric property | Platform | Uncommon | 🧪 | aggregation, read-only | Same **Sum / Average Documents** read view (op selector → **Average**) → Swift wrapper over FFI `dash_sdk_document_average` (proof-verified) → `{averages:{hexKey:{count,sum}}}`; the view divides `sum/count` for display. Needs a doc type with a `summable` index on the numeric property. | | DOC-15 | Document transfer / purchase across wallets | Platform | Uncommon | ✅ | multiwallet | A creates + lists a document (`DOC-02`/`DOC-06`); B transfers/purchases it (`DOC-05`/`DOC-07`). Ownership and credits move between A and B. Transfer half driven end-to-end this session via the production UI: the `card` doc `FgVSYG6sTZZ9…` moved from identity `BjJz3hdmg5Ec…` to a different seed-controlled identity `8267geu4…` (QA2), with ownership re-persisted. Purchase half shares `DOC-07`'s status (a fresh buy needs a counterparty-owned for-sale listing). | -| DOC-16 | Erase a deleted keep-history document's revisions | Platform | Thorough | 🧪 | | Primary route: **Settings → Platform State Transitions → Document Erase** (`TransitionDetailView` → `dash_sdk_document_erase_and_wait`), which takes the deleted document's id as text: an in-app delete (`DOC-04`) removes the local row, so the Browse Documents route below cannot start after it. Secondary route: **Browse Documents** → document → **⋯** → **Erase History…** (shown when the type's schema sets `canBeErased`) → `EraseDocumentView` → `platform_wallet_document_erase` (`IdentityWallet::erase_document_with_signer`), for a row whose document was deleted elsewhere; the sheet stays open for further chunks and removes the row only once the lifecycle reports ABSENT. Both routes read the lifecycle before and after each broadcast (`SDK.documentGetLifecycle` over `dash_sdk_document_fetch_history`) and show that, because the erase result itself only proves the document absent from ordinary reads, which it already was: a still-DELETED lifecycle with the same retained count is reported as "Not established", ERASING with the remaining count as progress, ABSENT as complete. Needs a type with `canBeErased: true` and a document already deleted; the first erase must be signed by the owner, later ones by any identity, each removing up to 100 revisions. Not driven on a device; no such type exists on testnet yet. | +| DOC-16 | Erase a deleted keep-history document's revisions | Platform | Thorough | 🧪 | | Routes: **Settings → Platform State Transitions → Document Erase**; **Browse Documents** → document → **⋯** → **Erase History…**. The erase form calls the Rust wallet read/decide/select/submit/observe operation through `platform_wallet_document_erase_and_observe`. Settings requires an identity linked to a wallet in the active manager; orphaned/import-only identities cannot erase. Rust loads the real contract, rejects ineligible types, skips ACTIVE/ABSENT, and submits nothing when the preflight/ownership read is unavailable. DELETED requires the newest retained revision's owner; ERASING accepts any submitting identity. Keys are selected in Rust using the actual requirement, contract bounds, expiry and supplied signer. A closing-read failure remains a submitted result with unavailable progress; outcome-unknown errors require reading history before any manual retry. Each call submits at most one chunk and never retries automatically. Display skipped/submitted reasons, remaining revisions and cautious progress wording. Needs an erasable keep-history type; not driven on a device or a live provider. | ### 4.8 Tokens — `Domain=Token` diff --git a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DocumentHistoryLifecycleTests.swift b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DocumentHistoryLifecycleTests.swift index f43f620690c..7885bfa87b7 100644 --- a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DocumentHistoryLifecycleTests.swift +++ b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DocumentHistoryLifecycleTests.swift @@ -1,4 +1,5 @@ import XCTest +import DashSDKFFI @testable import SwiftDashSDK /// The lifecycle block is the only authenticated account of what an erase @@ -6,6 +7,38 @@ import XCTest /// a count or a timestamp the user then acts on. final class DocumentHistoryLifecycleTests: XCTestCase { + func testSubmittedEraseWithUnavailableClosingReadRemainsSubmitted() throws { + var value = DocumentEraseOutcomeFFI() + value.kind = 2 + value.before.state = 4 + value.before.remaining_revisions = UInt64.max + let outcome = try DocumentEraseOutcome(ffi: value) + guard case .submitted(let before, let after) = outcome else { + return XCTFail("Rust reported a submitted erase") + } + XCTAssertEqual(before?.remainingRevisions, UInt64.max) + XCTAssertNil(after) + } + + func testUnknownEraseTagsReportUnreadableResult() { + var value = DocumentEraseOutcomeFFI() + value.kind = 255 + XCTAssertThrowsError(try DocumentEraseOutcome(ffi: value)) { error in + XCTAssertEqual(error.localizedDescription, "Erase result unreadable; read history before retrying.") + } + } + + func testUnavailablePreflightIsNotAnAbsentObservation() throws { + var value = DocumentEraseOutcomeFFI() + value.kind = 1 + value.reason = 4 + let outcome = try DocumentEraseOutcome(ffi: value) + guard case .notSubmitted(.preflightUnavailable, let before) = outcome else { + return XCTFail("Rust did not submit the erase") + } + XCTAssertNil(before) + } + /// Parses through `JSONSerialization` the way the query path does: that /// is what bridges JSON booleans and fractional numbers to `NSNumber`, /// which a plain dictionary literal would not reproduce. diff --git a/packages/swift-sdk/scripts/test_document_erase_preflight.py b/packages/swift-sdk/scripts/test_document_erase_preflight.py index 4968ddb3c23..72ed5d73fa3 100644 --- a/packages/swift-sdk/scripts/test_document_erase_preflight.py +++ b/packages/swift-sdk/scripts/test_document_erase_preflight.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""Run the Settings erase route against an offline SDK, without an iOS build.""" +"""Compile the real Settings erase route against a single-operation wallet stub.""" from pathlib import Path import shutil @@ -7,124 +7,140 @@ import tempfile import unittest - -VIEW = (Path(__file__).resolve().parents[1] / "SwiftExampleApp" / - "SwiftExampleApp/Views/TransitionDetailView.swift") +ROOT = Path(__file__).resolve().parents[1] +VIEWS = ROOT / "SwiftExampleApp/SwiftExampleApp/Views" @unittest.skipUnless(shutil.which("swiftc"), "Swift compiler unavailable") class DocumentErasePreflightTests(unittest.TestCase): - def test_should_skip_active_and_absent_without_claiming_an_erase_completed(self): - source = VIEW.read_text() + def test_should_display_rust_outcomes_without_orchestrating_an_erase(self): + source = (VIEWS / "TransitionDetailView.swift").read_text() start = source.index(" private func executeDocumentErase(") end = source.index("\n private func executeDocumentTransfer(", start) - # Compile the actual route, including its reads and broadcast call. - # The stubs isolate presentation behavior from SwiftUI and the FFI. + display = (VIEWS / "DocumentsView.swift").read_text() + display_start = display.index("func describeDocumentEraseOutcome(") + display_end = display.index("struct EraseDocumentView:", display_start) harness = r''' import Foundation enum SDKError: Error { case invalidParameter(String) } -enum LifecycleState: String, CaseIterable { case active, deleted, erasing, absent } +enum PlatformWalletError: Error { case transactionBroadcastUnconfirmed(String) } +enum LifecycleState: String { case active, deleted, erasing, absent } struct DocumentHistoryLifecycle { let state: LifecycleState let remainingRevisions: UInt64 - static func describeEraseProgress( - before: Self?, after: Self - ) -> String { - after.state == .absent ? "Erasure complete: no retained revisions remain." : "Retained revisions remain." + static func describeEraseProgress(before: Self?, after: Self) -> String { + after.state == .absent ? "Erasure complete" : "Retained revisions remain" } } -struct PublicKey { let id: UInt32 = 0 } +enum DocumentEraseNotSubmittedReason { + case active, absent, preflightUnavailable, notNewestOwner(Data) +} +enum DocumentEraseOutcome { + case notSubmitted(reason: DocumentEraseNotSubmittedReason, before: DocumentHistoryLifecycle?) + case submitted(before: DocumentHistoryLifecycle?, after: DocumentHistoryLifecycle?) + var before: DocumentHistoryLifecycle? { + switch self { case .notSubmitted(_, let b), .submitted(let b, _): return b } + } + var after: DocumentHistoryLifecycle? { + if case .submitted(_, let a) = self { return a }; return nil + } +} +extension Data { + static func identifier(fromBase58: String) -> Data? { Data(repeating: 1, count: 32) } + func toBase58String() -> String { "owner" } +} struct Identity { let identityIdBase58 = "signer" - let identityId = "signer" - let identityPublicKeys = [PublicKey()] - let balance: Int64 = 100 -} -struct DPPIdentity { - let id: String - let publicKeys: [UInt32: PublicKey] - let balance: UInt64 - let revision: UInt32 + let identityId = Data(repeating: 1, count: 32) + var wallet: WalletLink? = WalletLink() } +struct WalletLink { let walletId = Data() } struct ModelContext { let container = 0 } -struct KeychainSigner { - init(modelContainer: Int) {} - let handle = 0 -} -@MainActor final class SDK { - let initialState: LifecycleState? - var reads = 0 - var broadcasts = 0 - init(_ state: LifecycleState?) { initialState = state } - func documentGetLifecycle( - dataContractId: String, documentType: String, documentId: String - ) async throws -> DocumentHistoryLifecycle { - reads += 1 - if reads == 1 { - guard let initialState else { throw SDKError.invalidParameter("Read unavailable") } - return DocumentHistoryLifecycle(state: initialState, remainingRevisions: 0) - } - return DocumentHistoryLifecycle(state: .absent, remainingRevisions: 0) - } - func documentErase( - contractId: String, documentType: String, documentId: String, - ownerIdentity: DPPIdentity, signer: Int - ) async throws { - broadcasts += 1 +struct KeychainSigner { init(modelContainer: Int) {} } +struct SDK {} +@MainActor final class Wallet { + let outcome: DocumentEraseOutcome + var calls = 0 + init(_ outcome: DocumentEraseOutcome) { self.outcome = outcome } + func eraseDocumentAndObserve(submittingIdentityId: Data, contractId: Data, + documentType: String, documentId: Data, signer: KeychainSigner) async throws -> DocumentEraseOutcome { + calls += 1 + return outcome } } +@MainActor struct WalletManager { + let loaded: Wallet + func wallet(for: Data) -> Wallet? { loaded } +} +''' + display[display_start:display_end] + r''' @MainActor struct SettingsRoute { let selectedIdentityId = "signer" - let identities = [Identity()] + let identities: [Identity] let formInputs = ["contractId": "contract", "documentType": "note", "documentId": "doc"] let modelContext = ModelContext() - func run(_ sdk: SDK) async throws -> [String: Any] { - try await executeDocumentErase(sdk: sdk) as! [String: Any] + let walletManager: WalletManager + func run() async throws -> [String: Any] { + try await executeDocumentErase(sdk: SDK()) as! [String: Any] } ''' + source[start:end] + r''' } @main struct Main { @MainActor static func main() async throws { - var failures: [String] = [] - func require(_ condition: Bool, _ message: String) { - if !condition { failures.append(message) } - } - let states: [LifecycleState?] = [.active, .absent, .deleted, .erasing, nil] - for state in states { - let sdk = SDK(state) - let result = try await SettingsRoute().run(sdk) - let label = state?.rawValue ?? "unreadable" - if state == .active || state == .absent { - require(sdk.broadcasts == 0, "\(label): must not broadcast a paid erase") - require(sdk.reads == 1, "\(label): no closing read without a broadcast") - require(result["message"] as? String == "Erase not submitted", "\(label): explain the skip") - require(result["lifecycle"] as? String == label, "\(label): show the observed lifecycle") - require(result["remainingRevisions"] as? UInt64 == 0, "\(label): show retained revisions") - let progress = result["progress"] as? String ?? "" - require(!progress.isEmpty, "\(label): show progress") - if state == .absent { - require(progress.contains("No retained revisions exist"), "absent: describe the observation") - require(!progress.contains("Erasure complete"), "absent: an observation does not prove an erase completed") + let erasing = DocumentHistoryLifecycle(state: .erasing, remainingRevisions: 50) + let deleted = DocumentHistoryLifecycle(state: .deleted, remainingRevisions: 50) + let outcomes: [DocumentEraseOutcome] = [ + .notSubmitted(reason: .active, before: nil), + .notSubmitted(reason: .absent, before: nil), + .notSubmitted(reason: .preflightUnavailable, before: nil), + .notSubmitted(reason: .notNewestOwner(Data()), before: erasing), + .submitted(before: deleted, after: nil), + .submitted(before: erasing, after: .init(state: .absent, remainingRevisions: 0)), + ] + for outcome in outcomes { + let wallet = Wallet(outcome) + let route = SettingsRoute(identities: [Identity()], walletManager: .init(loaded: wallet)) + let result = try await route.run() + precondition(wallet.calls == 1, "host must call the single Rust operation") + let message = result["message"] as! String + switch outcome { + case .notSubmitted(let reason, let before): + precondition(message.hasPrefix("Erase not submitted")) + if case .absent = reason { precondition(!message.contains("Erasure complete")) } + if let before { + precondition(result["lifecycle"] as? String == before.state.rawValue) + precondition(result["remainingRevisions"] as? UInt64 == before.remainingRevisions) + } else { + precondition(result["lifecycle"] == nil && result["remainingRevisions"] == nil) + } + case .submitted(_, let after): + precondition(message.hasPrefix("Erase submitted")) + if let after { + precondition(result["lifecycle"] as? String == after.state.rawValue) + precondition(result["remainingRevisions"] as? UInt64 == after.remainingRevisions) + } else { + precondition(message.contains("Lifecycle not read")) + precondition(result["lifecycle"] == nil && result["remainingRevisions"] == nil, + "a submitted erase must not display its stale preflight lifecycle") } - } else { - require(sdk.broadcasts == 1, "\(label): continue the requested erase") - require(sdk.reads == 2, "\(label): describe the result after broadcast") - require(result["message"] as? String == "Erase submitted; document absence observed under proof", - "\(label): preserve submission status") } } - if !failures.isEmpty { - failures.forEach { print($0) } - exit(1) + let wallet = Wallet(outcomes[0]) + var unlinked = Identity(); unlinked.wallet = nil + do { + _ = try await SettingsRoute(identities: [unlinked], walletManager: .init(loaded: wallet)).run() + fatalError("orphaned identity must not reach Rust") + } catch SDKError.invalidParameter(let message) { + precondition(message == "Identity has no wallet linkage; cannot erase document history") } - print("Five erase preflight controls passed") + precondition(wallet.calls == 0) + print("Six typed outcomes and wallet-linkage control passed") } } ''' with tempfile.TemporaryDirectory() as directory: - source_path = Path(directory) / "ErasePreflight.swift" - binary = Path(directory) / "erase-preflight" + source_path = Path(directory) / "EraseRoute.swift" + binary = Path(directory) / "erase-route" source_path.write_text(harness) compiled = subprocess.run( ["swiftc", "-parse-as-library", str(source_path), "-o", str(binary)], From 5b73d83b50d721d008d638cbcea265f526b19f22 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Fri, 13 Nov 2026 18:43:04 +0700 Subject: [PATCH 17/26] chore(release): update changelog and bump version to 5.1.0-dev.1 (#5912) Co-authored-by: Claude Opus 5.5 --- CHANGELOG.md | 451 +++++++++++++++++- Cargo.lock | 104 ++-- Cargo.toml | 2 +- package.json | 2 +- packages/app-connect-contract/package.json | 2 +- packages/bench-suite/package.json | 2 +- packages/dapi-grpc/package.json | 2 +- packages/dapi/package.json | 2 +- packages/dash-spv/package.json | 2 +- .../configs/defaults/tenderdash-seeds.json | 146 +++--- packages/dashmate/package.json | 2 +- packages/dashpay-contract/package.json | 2 +- .../decision-proposals-contract/package.json | 2 +- .../document-history-contract/package.json | 2 +- packages/dpns-contract/package.json | 2 +- packages/js-dapi-client/package.json | 2 +- packages/js-dash-sdk/package.json | 2 +- packages/js-evo-sdk/package.json | 2 +- packages/js-grpc-common/package.json | 2 +- packages/keyword-search-contract/package.json | 2 +- .../package.json | 2 +- .../moderation-charters-contract/package.json | 2 +- packages/platform-test-suite/package.json | 2 +- .../checkpoints/testnet.json | 8 +- .../data/checkpoint-evidence-testnet.json | 21 +- packages/token-history-contract/package.json | 2 +- packages/token-market-contract/package.json | 2 +- packages/wallet-lib/package.json | 2 +- packages/wallet-utils-contract/package.json | 2 +- packages/wasm-dpp/package.json | 2 +- packages/wasm-dpp2/package.json | 2 +- packages/wasm-drive-verify/package.json | 2 +- packages/wasm-sdk/package.json | 2 +- packages/withdrawals-contract/package.json | 2 +- 34 files changed, 621 insertions(+), 167 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 347de635e13..06bcd638d67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,455 @@ -## [Unreleased] +## [5.1.0-dev.1](https://github.com/dashpay/platform/compare/v5.0.3...v5.1.0-dev.1) (2026-11-13) + + +### ⚠ BREAKING CHANGES + +* upgrade Tenderdash to v2.0.0-dev.2 (#5836) +* **platform:** a data contract holds a bounded number of patterns of bounded compiled size (PV15) (#5879) +* **platform:** delete and erase lifecycle for keep-history documents (#4657) +* **platform:** charge a processing fee for a multiple choice proposal (PV15) (#5897) +* **dpp:** compile document-schema patterns when first used (#5891) +* **platform:** dashpay contact requests carry an encrypted shielded address (PV15) (#5892) +* **contract:** describe a multiple choice proposal by a document, a url or both (PV15) (#5895) +* **platform:** multiple choice proposals take their description from a moderated text (PV15) (#5851) +* **platform:** one vote poll per contest for index values sent in different forms (PV15) (#5886) +* **platform:** multiple choice decision proposals, voted on as a contest among documents (PV15) (#5848) +* **drive:** write no entry in an expired time range bucket on insert (PV15) (#5877) +* **drive:** preserve composite document history across protocol activation (#4652) +* **dpp:** native document validation rules at protocol version 15 (#5871) +* **platform:** either-kind targets and slot conditions for document-named references (PV15) (#5850) +* **drive:** estimate summable index entries with their sum items, and other PV15 fee estimate follow-ups (#5858) +* **platform:** keys with a budget or an expiry sign no data contract create or update (PV15) (#5861) +* **platform:** document references whose target the document names (PV15) (#5849) +* **drive-abci:** follow operator payout changes and repair operator keys at protocol 15 (#5775) +* **dpp:** hold only instant asset lock proofs to the input cap (PV15) (#5825) +* **platform:** hand stored bytes to the owner a document update names (PV15) (#5829) +* **platform:** a private type's update may only add properties after its existing ones (PV15) (#5807) +* **platform:** dashpay contract v3 declares private contact requests (PV15) (#5804) +* **platform:** append private document entries paid from the shielded pool (PV15) (#5799) +* **platform:** dashpay contract v3 declares the checks of its data triggers (#4933) +* **drive-abci:** check the IdentityCreate identity id in basic structure (PV15) (#5770) +* **platform:** update rust-dashcore past the FFI removal (#5729) +* **drive-abci:** re-enable the voter key of the address a masternode returns to (PV15) (#5768) +* **sdk:** let wasm-sdk and evo-sdk opt into the verified quorum context provider (#5721) +* **dpp:** refuse a contest keyed by a nested or system property (PV15) (#5761) +* **drive-abci:** emit version 2 asset unlocks once Core V24 is active (PV15) (#5634) +* **sdk:** move the KeyWallet helpers to platform-wallet (#5727) +* **platform:** decide a contest by its index values (PV15) (#5744) +* **sdk:** decide from the version tables which networks serve a document query (#5636) +* **drive-abci:** record Core fork activation in state (PV15) (#5681) +* **platform:** token marketplace escrow trees and token market contract (PV15) (#5526) +* set zero consensus evidence budget at protocol 15 (#5489) +* **platform:** generatedFrom sys.tokens.decimals generates a token's decimals (PV15) (#5604) +* **platform:** update rust-dashcore to dev 7329126e (#5726) +* **platform-wallet:** report a freshly built asset lock's outpoint to the caller (#5476) +* **drive:** estimate a batch's fee the same whatever its operations' order (PV15) (#5688) +* **drive:** create the store of a private document type, and refuse document queries on one (PV15) (#5703) +* **dpp:** refuse a document type schema naming a key twice (PV15) (#5702) +* **platform:** private document types, declared with the `private` keyword (PV15) (#5689) +* **platform:** decision proposals open masternode yes/no polls (PV15) (#5684) +* **platform:** yes/no votes name their poll by id, and polls carry a typed purpose (PV15) (#5680) +* **platform:** delete a consumed document from what its lookup read (PV15) (#5360) +* **platform-wallet:** sign a DashPay contact payment before broadcasting it (#5465) +* **platform:** yes/no masternode vote poll kind with supermajority and minimum voting power (#4899) +* **platform:** refuse a token config update on a read-only contract (PV15) (#5632) +* **sdk:** refuse document requests no node can answer instead of banning nodes +* **drive:** store contracts compiled from protocol version 15 (#5579) +* **sdk:** report active group config update proposals as success (#5584) +* **dpp:** stored contract format with compiled document types (#5578) +* **dpp:** check document schemas natively at registration from protocol version 15 (#5538) +* **dpp:** validate documents natively at protocol version 15 (#5533) +* **sdk:** read how many times a masternode has voted on a contested resource (#5312) +* **platform:** tradeable tokens (PV15) (#5524) +* **platform:** dpns contract v3 checks name registration with schema keywords (PV15) (#5337) +* **swift-sdk:** start SPV off the main thread (#5512) +* migrate Platform cryptography to rust-dashcore dev (aca02026) (#5514) +* **platform:** update rust-dashcore to dev 280b3f2c (#5493) +* **drive-abci:** refuse IdentityUpdate added key proof failures without charging the identity (PV15) (#5494) +* **drive-abci:** leave chain locks signed by quorums Platform does not hold to Core (PV15) (#5454) +* **swift-sdk:** drop the signed-attempt archive and activity reconciliation host support +* **platform-wallet:** complete drains from Platform's verdict instead of a signed-attempt archive +* **platform-wallet:** summarize dApp state transitions in platform-wallet and address review findings +* **sdk:** Swift ManagedPlatformWallet.ParsedTokenPurchaseTransition and the two-case ParsedStateTransition enum are removed; parseStateTransition returns the new struct. + +Co-Authored-By: Claude Fable 5.1 +* **platform-wallet-ffi:** PARSED_STATE_TRANSITION_KIND_TOKEN_DIRECT_PURCHASE, ParsedTokenDirectPurchaseFFI and ParsedStateTransitionFFI.token_direct_purchase are removed; a direct purchase is a Batch row with action DirectPurchase. + +Co-Authored-By: Claude Fable 5.1 +* **platform-wallet:** `get_quorum_public_key` errors for unverified quorums, +and `PlatformWalletError` gains the `QuorumNotVerified` variant. + +🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent + +Co-Authored-By: Claude Opus 5.5 +Claude-Session: https://claude.ai/code/session_01PSi8cX229kW2fmLxKW6ir4 +* **platform:** update rust-dashcore (incl secp256k1 0.33) (#5307) +* **dashmate:** Debian package filenames and versions change shape. A rebuild +of an already published version needs DASHMATE_DEB_REVISION, and re-releasing a +version published under the old scheme needs DASHMATE_DEB_EPOCH. + +Test would have caught this in CI: 4 of the new specs fail before the fix. + +Co-Authored-By: Claude Opus 5 + +### Features + +* **contract:** describe a multiple choice proposal by a document, a url or both (PV15) ([#5895](https://github.com/dashpay/platform/issues/5895)) +* **dapi:** add getOwnerTransactionsInBlock and getBlocks queries ([#5815](https://github.com/dashpay/platform/issues/5815)) +* **dashmate:** show what a DKG-safe stop waits for and how long ([#5843](https://github.com/dashpay/platform/issues/5843)) +* **dpp:** check document schemas natively at registration from protocol version 15 ([#5538](https://github.com/dashpay/platform/issues/5538)) +* **dpp:** contract corpus test and typed validation schema for document types ([#5486](https://github.com/dashpay/platform/issues/5486)) +* **dpp:** stored contract format with compiled document types ([#5578](https://github.com/dashpay/platform/issues/5578)) +* **dpp:** validate documents natively at protocol version 15 ([#5533](https://github.com/dashpay/platform/issues/5533)) +* **drive-abci:** check the IdentityCreate identity id in basic structure (PV15) ([#5770](https://github.com/dashpay/platform/issues/5770)) +* **drive-abci:** emit version 2 asset unlocks once Core V24 is active (PV15) ([#5634](https://github.com/dashpay/platform/issues/5634)) +* **drive-abci:** record Core fork activation in state (PV15) ([#5681](https://github.com/dashpay/platform/issues/5681)) +* **drive:** create the store of a private document type, and refuse document queries on one (PV15) ([#5703](https://github.com/dashpay/platform/issues/5703)) +* **drive:** preserve composite document history across protocol activation ([#4652](https://github.com/dashpay/platform/issues/4652)) +* **drive:** store contracts compiled from protocol version 15 ([#5579](https://github.com/dashpay/platform/issues/5579)) +* fetch an identity's public keys without reloading the managed identity ([#5715](https://github.com/dashpay/platform/issues/5715)) +* **kotlin-sdk:** bind fund_from_asset_lock_external (Core → third-party Platform address) ([#5797](https://github.com/dashpay/platform/issues/5797)) +* **kotlin-sdk:** bridge the adaptive context provider and build it by default ([#5884](https://github.com/dashpay/platform/issues/5884)) +* **kotlin-sdk:** partial-amount platform-address withdrawal ([#5830](https://github.com/dashpay/platform/issues/5830)) +* **kotlin-sdk:** send, receive and accept DashPay private contact requests ([#5813](https://github.com/dashpay/platform/issues/5813)) +* per-contact shielded address index and a payment reference memo kind ([#5893](https://github.com/dashpay/platform/issues/5893)) +* **platform-wallet-ffi:** decode any state transition kind in parse_state_transition +* **platform-wallet:** delete an index-only document by its values ([#5419](https://github.com/dashpay/platform/issues/5419)) +* **platform-wallet:** derive application encryption keys with the DIP-13 rotation level ([#5649](https://github.com/dashpay/platform/issues/5649)) +* **platform-wallet:** derive DashPay Connect keys at the DIP-13 sub-feature paths, closes [dashpay/dips#191](https://github.com/dashpay/dips/issues/191) +* **platform-wallet:** expose the BIP-44 account 0 xpub ([#5756](https://github.com/dashpay/platform/issues/5756)) +* **platform-wallet:** fresh shielded addresses and an own-address check ([#5888](https://github.com/dashpay/platform/issues/5888)) +* **platform-wallet:** invitation claim status for the invitee, idempotent claim ([#4997](https://github.com/dashpay/platform/issues/4997)) +* **platform-wallet:** persist the Orchard recipient of a shielded asset-lock funding ([#5762](https://github.com/dashpay/platform/issues/5762)) +* **platform-wallet:** register limited keys as version 1 keys in creation, closes [#4811](https://github.com/dashpay/platform/issues/4811) +* **platform-wallet:** report a freshly built asset lock's outpoint to the caller ([#5476](https://github.com/dashpay/platform/issues/5476)) +* **platform-wallet:** send, receive and accept DashPay private contact requests ([#5810](https://github.com/dashpay/platform/issues/5810)) +* **platform-wallet:** sign a DashPay contact payment before broadcasting it ([#5465](https://github.com/dashpay/platform/issues/5465)) +* **platform:** a private type's update may only add properties after its existing ones (PV15) ([#5807](https://github.com/dashpay/platform/issues/5807)) +* **platform:** append private document entries paid from the shielded pool (PV15) ([#5799](https://github.com/dashpay/platform/issues/5799)) +* **platform:** charge a processing fee for a multiple choice proposal (PV15) ([#5897](https://github.com/dashpay/platform/issues/5897)) +* **platform:** dashpay contact requests carry an encrypted shielded address (PV15) ([#5892](https://github.com/dashpay/platform/issues/5892)) +* **platform:** dashpay contract v3 declares private contact requests (PV15) ([#5804](https://github.com/dashpay/platform/issues/5804)) +* **platform:** dashpay contract v3 declares the checks of its data triggers ([#4933](https://github.com/dashpay/platform/issues/4933)) +* **platform:** decision proposals open masternode yes/no polls (PV15) ([#5684](https://github.com/dashpay/platform/issues/5684)) +* **platform:** delete and erase lifecycle for keep-history documents ([#4657](https://github.com/dashpay/platform/issues/4657)) +* **platform:** document references whose target the document names (PV15) ([#5849](https://github.com/dashpay/platform/issues/5849)) +* **platform:** dpns contract v3 checks name registration with schema keywords (PV15) ([#5337](https://github.com/dashpay/platform/issues/5337)) +* **platform:** either-kind targets and slot conditions for document-named references (PV15) ([#5850](https://github.com/dashpay/platform/issues/5850)) +* **platform:** generatedFrom sys.tokens.decimals generates a token's decimals (PV15) ([#5604](https://github.com/dashpay/platform/issues/5604)) +* **platform:** introduce protocol version 15 ([#5043](https://github.com/dashpay/platform/issues/5043)) +* **platform:** multiple choice decision proposals, voted on as a contest among documents (PV15) ([#5848](https://github.com/dashpay/platform/issues/5848)) +* **platform:** multiple choice proposals take their description from a moderated text (PV15) ([#5851](https://github.com/dashpay/platform/issues/5851)) +* **platform:** price storage refunds at the storing epoch's rate and drop the fee history map ([#5798](https://github.com/dashpay/platform/issues/5798)) +* **platform:** private document types, declared with the `private` keyword (PV15) ([#5689](https://github.com/dashpay/platform/issues/5689)) +* **platform:** read and prove the entries of a private document type's store (getPrivateDocumentEntries, PV15) ([#5708](https://github.com/dashpay/platform/issues/5708)) +* **platform:** token marketplace escrow trees and token market contract (PV15) ([#5526](https://github.com/dashpay/platform/issues/5526)) +* **platform:** tradeable tokens (PV15) ([#5524](https://github.com/dashpay/platform/issues/5524)) +* **platform:** yes/no masternode vote poll kind with supermajority and minimum voting power ([#4899](https://github.com/dashpay/platform/issues/4899)) +* **platform:** yes/no vote poll state and masternode answer queries ([#5651](https://github.com/dashpay/platform/issues/5651)) +* **platform:** yes/no votes name their poll by id, and polls carry a typed purpose (PV15) ([#5680](https://github.com/dashpay/platform/issues/5680)) +* **sdk-ffi:** read a contract group's information with a proof +* **sdk:** add dash-sdk-cxx, a C++ binding of dash-sdk for Dash Core ([#4633](https://github.com/dashpay/platform/issues/4633)) +* **sdk:** add opt-in verified HTTP context provider ([#5523](https://github.com/dashpay/platform/issues/5523)) +* **sdk:** add protocol compatibility checks and write admission +* **sdk:** back SPV up with the trusted quorum service in Auto mode ([#5882](https://github.com/dashpay/platform/issues/5882)) +* **sdk:** DashPay Connect key derivation and decode-any-kind parsing in Swift and Kotlin +* **sdk:** decide from the version tables which networks serve a document query ([#5636](https://github.com/dashpay/platform/issues/5636)) +* **sdk:** decision proposal helpers in rs-sdk, wasm-sdk and js-evo-sdk ([#5700](https://github.com/dashpay/platform/issues/5700)) +* **sdk:** decision proposals in rs-sdk-ffi, Swift and Kotlin ([#5704](https://github.com/dashpay/platform/issues/5704)) +* **sdk:** expose the document erase and history lifecycle on mobile and FFI ([#4660](https://github.com/dashpay/platform/issues/4660)) +* **sdk:** let wasm-sdk and evo-sdk opt into the verified quorum context provider ([#5721](https://github.com/dashpay/platform/issues/5721)) +* **sdk:** move DashPay profile create, update and fetch into rs-sdk ([#5470](https://github.com/dashpay/platform/issues/5470)) +* **sdk:** move the DashPay invitation link codec and claim into rs-sdk ([#5471](https://github.com/dashpay/platform/issues/5471)) +* **sdk:** persist the owner balance a DashPay profile write's proof carries, closes [#5409](https://github.com/dashpay/platform/issues/5409) [#5470](https://github.com/dashpay/platform/issues/5470) [#5409](https://github.com/dashpay/platform/issues/5409) [#5409](https://github.com/dashpay/platform/issues/5409) [#5409](https://github.com/dashpay/platform/issues/5409) +* **sdk:** prove a state transition's outcome, and add getRecentStateTransitionStatus ([#5823](https://github.com/dashpay/platform/issues/5823)) +* **sdk:** read how many times a masternode has voted on a contested resource ([#5312](https://github.com/dashpay/platform/issues/5312)) +* **sdk:** refresh the embedded quorum-proof checkpoints on every release ([#5669](https://github.com/dashpay/platform/issues/5669)) +* **sdk:** refuse a private document type too small for its payload ([#5805](https://github.com/dashpay/platform/issues/5805)) +* **sdk:** route DAPI connections through a SOCKS5 proxy ([#5160](https://github.com/dashpay/platform/issues/5160)) +* **sdk:** seal and open private document entries in the standard envelope ([#5806](https://github.com/dashpay/platform/issues/5806)) +* **sdk:** send, scan and read DashPay private contact requests ([#5809](https://github.com/dashpay/platform/issues/5809)) +* **sdk:** verify Core quorum proof chains (DIP 175) ([#5521](https://github.com/dashpay/platform/issues/5521)) +* **sdk:** verify the block proofs of getBlocks and getOwnerTransactionsInBlock ([#5834](https://github.com/dashpay/platform/issues/5834)) +* **swift-sdk:** default SDK to the adaptive context provider in Auto mode ([#5883](https://github.com/dashpay/platform/issues/5883)) +* **swift-sdk:** expose when each DPNS contender submitted its request ([#5718](https://github.com/dashpay/platform/issues/5718)) +* **swift-sdk:** read a contract group's owner with a proof +* **swift-sdk:** send, receive and accept DashPay private contact requests ([#5812](https://github.com/dashpay/platform/issues/5812)) +* **swift-sdk:** use SPV-synced quorums for Platform proof verification ([#3417](https://github.com/dashpay/platform/issues/3417)) +* **wallet:** reserve DashPay payout addresses without Core funding +* **wasm-sdk:** seal and scan DashPay private contact requests ([#5811](https://github.com/dashpay/platform/issues/5811)) + + +### Bug Fixes + +* **dapi:** meter token pool transitions in the shielded proof failure budget ([#5801](https://github.com/dashpay/platform/issues/5801)) +* **dapi:** stream every instance of a re-signed asset unlock ([#5832](https://github.com/dashpay/platform/issues/5832)) +* **dashmate:** fail the deb repack when the version was not rewritten +* **dashmate:** give Debian packages versions apt can order +* **dashmate:** keep dev builds below beta and rc in the Debian version +* **dashmate:** key the protxinfo whitelist migration to 5.1.0-dev.1 ([#5844](https://github.com/dashpay/platform/issues/5844)) +* **dashmate:** publish the debs without oclif's apt index +* **dashmate:** refresh quorum-server seeds and complete node identities ([#5290](https://github.com/dashpay/platform/issues/5290)) +* **dashmate:** report a missing dpkg before downloading anything to compare +* **dashmate:** stop masternodes safely around DKGs on Core 24 ([#5841](https://github.com/dashpay/platform/issues/5841)) +* **dashmate:** stop the GitHub release lookup throwing and validate its version, closes [#4283](https://github.com/dashpay/platform/issues/4283) +* **dashmate:** use complete DKG membership for safe stops ([#5231](https://github.com/dashpay/platform/issues/5231)) +* **dashmate:** wait out the previous lego container's removal in ssl obtain ([#5602](https://github.com/dashpay/platform/issues/5602)) +* **dpp:** compile document-schema patterns when first used ([#5891](https://github.com/dashpay/platform/issues/5891)) +* **dpp:** cut long platform value text on a character boundary when displaying it ([#5434](https://github.com/dashpay/platform/issues/5434)) +* **dpp:** hold arrays to the maximum schema depth in validate_max_depth v2 ([#5881](https://github.com/dashpay/platform/issues/5881)) +* **dpp:** hold only instant asset lock proofs to the input cap (PV15) ([#5825](https://github.com/dashpay/platform/issues/5825)) +* **dpp:** native document validation rules at protocol version 15 ([#5871](https://github.com/dashpay/platform/issues/5871)) +* **dpp:** read a refersTo as dynamic only where protocol version 14 cannot read it ([#5887](https://github.com/dashpay/platform/issues/5887)) +* **dpp:** refuse a contest keyed by a nested or system property (PV15) ([#5761](https://github.com/dashpay/platform/issues/5761)) +* **dpp:** refuse a document type schema naming a key twice (PV15) ([#5702](https://github.com/dashpay/platform/issues/5702)) +* **drive-abci:** apply masternode list diffs as v0 and v1 always have ([#5455](https://github.com/dashpay/platform/issues/5455)) +* **drive-abci:** follow operator payout changes and repair operator keys at protocol 15 ([#5775](https://github.com/dashpay/platform/issues/5775)) +* **drive-abci:** leave chain locks signed by quorums Platform does not hold to Core (PV15) ([#5454](https://github.com/dashpay/platform/issues/5454)) +* **drive-abci:** re-enable the voter key of the address a masternode returns to (PV15) ([#5768](https://github.com/dashpay/platform/issues/5768)) +* **drive-abci:** refuse IdentityUpdate added key proof failures without charging the identity (PV15) ([#5494](https://github.com/dashpay/platform/issues/5494)) +* **drive-abci:** stop key-adding identity updates from taking the shielded proof verifier ([#5854](https://github.com/dashpay/platform/issues/5854)) +* **drive:** drop the argument [#5798](https://github.com/dashpay/platform/issues/5798) removed from add_document_for_contract in a proof plan test ([#5821](https://github.com/dashpay/platform/issues/5821)) +* **drive:** estimate a batch's fee the same whatever its operations' order (PV15) ([#5688](https://github.com/dashpay/platform/issues/5688)) +* **drive:** estimate summable index entries with their sum items, and other PV15 fee estimate follow-ups ([#5858](https://github.com/dashpay/platform/issues/5858)) +* **drive:** look up a single document at a block time (PV15) ([#5838](https://github.com/dashpay/platform/issues/5838)) +* **drive:** prove decision proposal creates as plain documents, found by a new strategy test ([#5696](https://github.com/dashpay/platform/issues/5696)) +* **drive:** verify a single document that may be contested (PV15) ([#5835](https://github.com/dashpay/platform/issues/5835)) +* **drive:** write no entry in an expired time range bucket on insert (PV15) ([#5877](https://github.com/dashpay/platform/issues/5877)) +* **kotlin-sdk:** keep parsed state transition amounts unsigned +* **kotlin-sdk:** release contact request handles after a sync ([#5814](https://github.com/dashpay/platform/issues/5814)) +* **kotlin-sdk:** report an unreadable parsed state transition blob as a DashSdkError +* move mobile document erase decisions into the Rust wallet ([#5907](https://github.com/dashpay/platform/issues/5907)) +* **platform-wallet-ffi:** null the payout-address out-param before the signer check +* **platform-wallet-ffi:** refuse invalid document-type bounds in the identity update parser +* **platform-wallet:** admit wallet drains on inline-committing persistence only +* **platform-wallet:** apply the drain persistence admission on every resume path +* **platform-wallet:** cap a wallet drain at the asset-lock input limit, not the standard-tx limit, closes [dashpay/rust-dashcore#1191](https://github.com/dashpay/rust-dashcore/issues/1191) +* **platform-wallet:** charge every detail byte to the budget and report witness-signed transitions as signed +* **platform-wallet:** check the drain's consumption verdict before recording activity +* **platform-wallet:** close drain cancellation and restore gaps +* **platform-wallet:** complete a drain only when the proof attests full consumption +* **platform-wallet:** confirm rejected-drain absence freshly and republish without a proof +* **platform-wallet:** escape and bound the details of a state transition summary +* **platform-wallet:** finish rejected-drain cleanup and republish deferred completion +* **platform-wallet:** gate drain completion on a dedicated proven status +* **platform-wallet:** hydrate durable drains and honor inline commits +* **platform-wallet:** keep the cached identity in step with the chain around updates ([#5487](https://github.com/dashpay/platform/issues/5487)) +* **platform-wallet:** keep the typed cause of a payout-reservation store failure +* **platform-wallet:** leave summary details as the escaped Debug output +* **platform-wallet:** let a shielded sync pass observe cancellation ([#5743](https://github.com/dashpay/platform/issues/5743)) +* **platform-wallet:** make drain recovery and history durable +* **platform-wallet:** owe a chain truncation's cursor to the DashPay backfill record ([#5484](https://github.com/dashpay/platform/issues/5484)) +* **platform-wallet:** poll the asset-lock resume FFIs on a big-stack thread ([#5585](https://github.com/dashpay/platform/issues/5585)) +* **platform-wallet:** publish drain outcomes without cancellation gaps +* **platform-wallet:** refuse a fixed-amount asset lock over the input cap before broadcast ([#5712](https://github.com/dashpay/platform/issues/5712)) +* **platform-wallet:** refuse invalid document-type bounds on an identity update's added keys +* **platform-wallet:** refuse to resume an asset lock over the input cap ([#5759](https://github.com/dashpay/platform/issues/5759)), closes [#5714](https://github.com/dashpay/platform/issues/5714) +* **platform-wallet:** reject conflicting persisted drain operation IDs +* **platform-wallet:** reject zero-amount shielded spends before reserving notes ([#5570](https://github.com/dashpay/platform/issues/5570)) +* **platform-wallet:** release committed rejections and bound drain retries +* **platform-wallet:** reopen a latched quiesce gate when a sync loop starts ([#5663](https://github.com/dashpay/platform/issues/5663)) +* **platform-wallet:** rescan DashPay contact accounts from the contact request height ([#4740](https://github.com/dashpay/platform/issues/4740)) +* **platform-wallet:** retry an oversized InstantSend asset-lock transition with a ChainLock proof ([#5460](https://github.com/dashpay/platform/issues/5460)) +* **platform-wallet:** retry unpublished drain checkpoints +* **platform-wallet:** return only verified SPV quorum keys for proofs +* **platform-wallet:** select available signing keys across identity operations ([#4764](https://github.com/dashpay/platform/issues/4764)) +* **platform-wallet:** show a contract create's group declarations in its summary +* **platform-wallet:** stop concurrent shielded syncs from duplicating commitments ([#5564](https://github.com/dashpay/platform/issues/5564)) +* **platform-wallet:** summarize v5.0-dev's shielded-pool token rows and renamed token payment accessor, closes [#4932](https://github.com/dashpay/platform/issues/4932) [#4760](https://github.com/dashpay/platform/issues/4760) +* **platform-wallet:** use the non-deprecated secp256k1 secret-key constructor in the drain fixture +* **platform:** a data contract holds a bounded number of patterns of bounded compiled size (PV15) ([#5879](https://github.com/dashpay/platform/issues/5879)) +* **platform:** decide a contest by its index values (PV15) ([#5744](https://github.com/dashpay/platform/issues/5744)) +* **platform:** hand stored bytes to the owner a document update names (PV15) ([#5829](https://github.com/dashpay/platform/issues/5829)) +* **platform:** keys with a budget or an expiry sign no data contract create or update (PV15) ([#5861](https://github.com/dashpay/platform/issues/5861)) +* **platform:** one vote poll per contest for index values sent in different forms (PV15) ([#5886](https://github.com/dashpay/platform/issues/5886)) +* **platform:** point PLATFORM_V15 at query versions V2 after v4.2 merge ([#5212](https://github.com/dashpay/platform/issues/5212)) +* **platform:** read back compiled contracts without compiling their contested regexes ([#5678](https://github.com/dashpay/platform/issues/5678)) +* **platform:** refuse a token config update on a read-only contract (PV15) ([#5632](https://github.com/dashpay/platform/issues/5632)) +* **rs-sdk-ffi:** return the proved identities contract keys ([#5491](https://github.com/dashpay/platform/issues/5491)) +* **sdk:** address protocol observation and broadcast review findings +* **sdk:** ban a node that fails a block query, but not one that is busy ([#5839](https://github.com/dashpay/platform/issues/5839)) +* **sdk:** bump dashcore-lib to 0.26.1 to parse Core V24 data +* **sdk:** check document windows and ranked indexes before sending ([#5638](https://github.com/dashpay/platform/issues/5638)) +* **sdk:** follow chain reorgs in SPV header sync and keep its memory bounded ([#5701](https://github.com/dashpay/platform/issues/5701)) +* **sdk:** honor explicit regtest addresses in the JS DAPI client ([#5291](https://github.com/dashpay/platform/issues/5291)) +* **sdk:** let wasm-sdk build without its default features ([#5612](https://github.com/dashpay/platform/issues/5612)) +* **sdk:** pass the platform version in the address nonce broadcast tests ([#5667](https://github.com/dashpay/platform/issues/5667)) +* **sdk:** preserve uncertain submission outcomes through shared broadcast ([#5556](https://github.com/dashpay/platform/issues/5556)) +* **sdk:** preserve unconfirmed identity address top-ups +* **sdk:** preserve unconfirmed submission errors across ffi +* **sdk:** preserve unconfirmed wallet presentation +* **sdk:** preserve verified waits across combined submission helpers +* **sdk:** query compacted address balances when the recent proof has no boundary ([#5572](https://github.com/dashpay/platform/issues/5572)) +* **sdk:** recognize prefixed DAPI processing refusals +* **sdk:** refresh the testnet DAPI address whitelist +* **sdk:** refuse a vote recovery whose proved vote differs from the submitted one ([#5755](https://github.com/dashpay/platform/issues/5755)) +* **sdk:** refuse document requests no node can answer instead of banning nodes, closes [#5618](https://github.com/dashpay/platform/issues/5618) +* **sdk:** report active group config update proposals as success ([#5584](https://github.com/dashpay/platform/issues/5584)) +* **sdk:** retain broadcast ambiguity across retry attempts +* **sdk:** retry address nonce skew on another node ([#5562](https://github.com/dashpay/platform/issues/5562)) +* **sdk:** retry an InstantSend asset lock proof refused for too many inputs with a ChainLock proof ([#5845](https://github.com/dashpay/platform/issues/5845)) +* **sdk:** send wasm DAPI requests to a single-slash path ([#5611](https://github.com/dashpay/platform/issues/5611)) +* **sdk:** stop banning nodes for proofs the SDK's context provider cannot verify ([#5769](https://github.com/dashpay/platform/issues/5769)) +* **sdk:** stop header sync errors from crashing the process or hiding their cause ([#5697](https://github.com/dashpay/platform/issues/5697)) +* **sdk:** validate SPV header difficulty exactly as Dash Core does ([#5699](https://github.com/dashpay/platform/issues/5699)) +* **sdk:** verify quorum proofs without blocking the executor ([#5720](https://github.com/dashpay/platform/issues/5720)) +* set zero consensus evidence budget at protocol 15 ([#5489](https://github.com/dashpay/platform/issues/5489)) +* **swift-sdk:** keep drain status authoritative in Rust while a call is in flight +* **swift-sdk:** preserve empty epoch query results +* **swift-sdk:** run identityGet and dpnsGetUsername off the main actor ([#5862](https://github.com/dashpay/platform/issues/5862)) +* **swift-sdk:** start SPV off the main thread ([#5512](https://github.com/dashpay/platform/issues/5512)), closes [#5535](https://github.com/dashpay/platform/issues/5535) +* **unified-sdk-jni:** overwrite the JVM copy of a connect key when marshalling fails +* **wallet:** drain Core balance with authenticated shielded recovery +* write the FFI headers to the profile directory under Cargo 1.100 ([#5898](https://github.com/dashpay/platform/issues/5898)) + + +### Performance Improvements + +* **platform:** delete a consumed document from what its lookup read (PV15) ([#5360](https://github.com/dashpay/platform/issues/5360)) +* **swift-sdk:** batch address-pool persistence lookups into chunked fetches ([#4392](https://github.com/dashpay/platform/issues/4392)) + + +### Continuous Integration + +* **dashmate:** bind published hashes to names, and order the baseline by publication +* **dashmate:** let release runs set the Debian revision and epoch +* **dashmate:** make releases verifiable and safe to hold a signing key +* **dashmate:** overwrite the package artifact when a release job is re-run +* **dashmate:** re-check for a signature immediately before replacing checksums +* **dashmate:** stop the release token outliving the step that needs it +* deploy isolated PR Hygiene engine on v4.3 +* link the contract viewer on pull requests that add or change a system contract ([#5552](https://github.com/dashpay/platform/issues/5552)) +* lint and test JS packages in fewer jobs ([#5757](https://github.com/dashpay/platform/issues/5757)) +* pin the remaining mutable third-party action refs to commit shas +* PR Hygiene is the merge gate; CODEOWNERS carries no rules ([#4840](https://github.com/dashpay/platform/issues/4840)) +* re-pin PR Hygiene ([#4936](https://github.com/dashpay/platform/issues/4936)) +* re-pin PR Hygiene ([#4946](https://github.com/dashpay/platform/issues/4946)) +* re-pin PR Hygiene ([#4976](https://github.com/dashpay/platform/issues/4976)) +* re-pin PR Hygiene ([#4980](https://github.com/dashpay/platform/issues/4980)) +* re-pin PR Hygiene ([#4990](https://github.com/dashpay/platform/issues/4990)) +* re-pin PR Hygiene ([#5017](https://github.com/dashpay/platform/issues/5017)) +* re-pin PR Hygiene ([#5024](https://github.com/dashpay/platform/issues/5024)) +* re-pin PR Hygiene and wake it on a hand-over ([#5021](https://github.com/dashpay/platform/issues/5021)) +* re-pin PR Hygiene engine to 3b98772 +* re-pin PR Hygiene for one name for the author limit ([#4903](https://github.com/dashpay/platform/issues/4903)) +* re-pin PR Hygiene for state labels and /skip-bots ([#4862](https://github.com/dashpay/platform/issues/4862)) +* re-pin PR Hygiene for the checklist in the description ([#4889](https://github.com/dashpay/platform/issues/4889)) +* re-pin PR Hygiene so a bot line says everything about that bot ([#4892](https://github.com/dashpay/platform/issues/4892)) +* re-pin PR Hygiene so it can verify access granted by the organisation ([#4805](https://github.com/dashpay/platform/issues/4805)) +* re-pin PR Hygiene so its runs queue instead of cancelling ([#4774](https://github.com/dashpay/platform/issues/4774)) +* re-pin PR Hygiene so the sweep reaches every pull request ([#4771](https://github.com/dashpay/platform/issues/4771)) +* re-pin PR Hygiene to ask a flaky read once more ([#4895](https://github.com/dashpay/platform/issues/4895)) +* re-pin PR Hygiene to clone this repository only on its sweep ([#4786](https://github.com/dashpay/platform/issues/4786)) +* re-pin PR Hygiene to read each pull request once ([#4779](https://github.com/dashpay/platform/issues/4779)) +* re-pin PR Hygiene to require a green build before asking a human ([#4796](https://github.com/dashpay/platform/issues/4796)) +* run change detection on the light runner pool ([#5748](https://github.com/dashpay/platform/issues/5748)) +* run platform-wallet-storage tests named "shield" on the full workspace path ([#5407](https://github.com/dashpay/platform/issues/5407)) +* run PR Hygiene's engine from master ([#5248](https://github.com/dashpay/platform/issues/5248)) +* run the dash-platform-queries tests in PR CI, closes [#5624](https://github.com/dashpay/platform/issues/5624) +* run the runner-select gate on the light runner pool ([#5747](https://github.com/dashpay/platform/issues/5747)) +* wake PR Hygiene only for a comment that can change the answer ([#4783](https://github.com/dashpay/platform/issues/4783)) + + +### Miscellaneous Chores + +* add layer ownership skill ([#5488](https://github.com/dashpay/platform/issues/5488)) +* address review of the v5.0-dev forward merge +* **dashmate:** run Dash Core 24 by default ([#5842](https://github.com/dashpay/platform/issues/5842)) +* **platform:** update rust-dashcore (incl secp256k1 0.33) ([#5307](https://github.com/dashpay/platform/issues/5307)) +* **platform:** update rust-dashcore past the FFI removal ([#5729](https://github.com/dashpay/platform/issues/5729)) +* **platform:** update rust-dashcore to dev 280b3f2c ([#5493](https://github.com/dashpay/platform/issues/5493)) +* **platform:** update rust-dashcore to dev 7329126e ([#5726](https://github.com/dashpay/platform/issues/5726)) +* **sdk:** preserve existing observer result type under clippy +* **skills:** rename review-prs to prs ([#4788](https://github.com/dashpay/platform/issues/4788)) +* **swift-sdk:** freeze App Store schema 4.0.0 ([#5785](https://github.com/dashpay/platform/issues/5785)) + + +### Documentation + +* **dashmate:** delete every superseded deb after a rebuild, not only revision 1 +* **dashmate:** delete superseded debs only after the rebuild is attached +* **dashmate:** describe how a DKG-safe stop decides ([#5878](https://github.com/dashpay/platform/issues/5878)) +* **dashmate:** explain how to rebuild a published deb +* **dashmate:** install the package that was downloaded, not every match +* describe asset unlock payload version 2 as a Core fork record consumer ([#5772](https://github.com/dashpay/platform/issues/5772)) +* describe how drive-abci reads Dash Core and records Core fork activations ([#5754](https://github.com/dashpay/platform/issues/5754)) +* make layer-ownership catch implementation details leaking to clients ([#5642](https://github.com/dashpay/platform/issues/5642)) +* **platform-wallet:** state the contact-payment gate's handle-sharing contract +* **platform-wallet:** state which connect key sub-feature and purpose pairs derive +* **platform:** note that fee version numbers must stay contiguous ([#5765](https://github.com/dashpay/platform/issues/5765)) +* require checking Rust changes against the coding conventions ([#5474](https://github.com/dashpay/platform/issues/5474)) +* **sdk:** describe the testnet DAPI whitelist as a snapshot, closes [#2816](https://github.com/dashpay/platform/issues/2816) +* **sdk:** drop signed-attempt persistence from the drain parity entry + ### Tests +* **contract:** expect only the first schema violation of a document at protocol version 15 +* cover every served protocol version in the non-unique lookup tests, closes [#5515](https://github.com/dashpay/platform/issues/5515) +* cover protocols 13 and 14 in the incoming document proof tests, closes [#5560](https://github.com/dashpay/platform/issues/5560) [#5559](https://github.com/dashpay/platform/issues/5559) +* **dashmate:** build the repack fixtures with oclif's real control file +* **dashmate:** pin zero, devnet and failing command line versions +* **dpp:** pin the bytes protocol version 15 stores contracts in ([#5880](https://github.com/dashpay/platform/issues/5880)) +* **drive-abci:** activate protocol version 14 in the credit pool backfill strategy tests ([#5735](https://github.com/dashpay/platform/issues/5735)) +* **drive-abci:** assert total supply drops by the destroyed frozen amount ([#5554](https://github.com/dashpay/platform/issues/5554)) +* **drive-abci:** guard chain lock, masternode list replay and version table invariants ([#5831](https://github.com/dashpay/platform/issues/5831)) +* **drive-abci:** name the fault in the check_tx refusal assertions +* **drive-abci:** pin the check_tx consensus error for an IdentityUpdate adding malformed ECDSA/BLS key data, closes [#5464](https://github.com/dashpay/platform/issues/5464) +* **drive-abci:** pin the nullifier batch guard characterization at protocol 15, closes [#5411](https://github.com/dashpay/platform/issues/5411) +* **drive-abci:** stop pinning the latest protocol version in the v0 shield-from-asset-lock refusal test ([#5298](https://github.com/dashpay/platform/issues/5298)) +* **drive:** regenerate grovedb structure snapshot after the v5.0-dev merge, closes [#4760](https://github.com/dashpay/platform/issues/4760) [#5154](https://github.com/dashpay/platform/issues/5154) +* **drive:** track latest protocol version in grovedb structure snapshot ([#5154](https://github.com/dashpay/platform/issues/5154)) +* **kotlin-sdk:** build the unknown-kind parse blob with the u32 name and complete flag +* **platform-wallet-ffi:** refuse trailing bytes through the public parser; drop orphaned test docs +* **platform-wallet-storage:** require unique, contiguous migration versions ([#5553](https://github.com/dashpay/platform/issues/5553)) +* **platform-wallet:** keep the missing-wallet drain regression reaching the durable read +* **platform-wallet:** pass the built-lock observer in the input-cap test helper ([#5734](https://github.com/dashpay/platform/issues/5734)) +* **platform-wallet:** pin the contact-payment gate's snapshot ordering +* **platform:** freeze historical storage and signing vectors ([#5359](https://github.com/dashpay/platform/issues/5359)) +* **sdk:** configure browser lifecycle context provider +* **sdk:** fill the verified protocol version in identities contract keys query tests ([#5571](https://github.com/dashpay/platform/issues/5571)) + + +### Code Refactoring + +* **dashmate:** move the release packaging scripts next to the package +* **dashmate:** name the packaging scripts by the module system they use +* migrate Platform cryptography to rust-dashcore dev (aca02026) ([#5514](https://github.com/dashpay/platform/issues/5514)) +* **platform-wallet-ffi:** reserve the payout address outside the registry guard +* **platform-wallet:** check a converted evonode address map with rust-dashcore's Core rules ([#5817](https://github.com/dashpay/platform/issues/5817)) +* **platform-wallet:** complete drains from Platform's verdict instead of a signed-attempt archive +* **platform-wallet:** derive connect keys with key-wallet's DIP-13 application paths, closes [rust-dashcore#1049](https://github.com/dashpay/rust-dashcore/issues/1049) +* **platform-wallet:** list every transition kind when deciding whether it is signed +* **platform-wallet:** localize drain settlement and narrow recipient API +* **platform-wallet:** own the TXO reconcile policy in the wallet ([#5796](https://github.com/dashpay/platform/issues/5796)) +* **platform-wallet:** summarize dApp state transitions in platform-wallet and address review findings, closes [#4931](https://github.com/dashpay/platform/issues/4931) +* **platform-wallet:** wake SPV readiness wait on events instead of polling, closes [#5307](https://github.com/dashpay/platform/issues/5307) +* **platform:** read a consumed document through generation 0's lookup and test the PV14 consume path ([#5874](https://github.com/dashpay/platform/issues/5874)) +* reject legacy BLS storage formats ([#5323](https://github.com/dashpay/platform/issues/5323)) +* **sdk:** check document requests with Drive's own request-only planning before sending ([#5774](https://github.com/dashpay/platform/issues/5774)) +* **sdk:** drop the `key-wallet-ffi` dependency ([#5728](https://github.com/dashpay/platform/issues/5728)) +* **sdk:** make protocol observations advisory +* **sdk:** move the KeyWallet helpers to platform-wallet ([#5727](https://github.com/dashpay/platform/issues/5727)) +* share one bincode config constant ([#5586](https://github.com/dashpay/platform/issues/5586)) +* **swift-sdk:** drop the signed-attempt archive and activity reconciliation host support + + +### Build System + +* fix the stale dash-core-proof version that fails every --locked build on v5.1-dev ([#5650](https://github.com/dashpay/platform/issues/5650)) +* make the workspace lockfile vendorable again ([#5473](https://github.com/dashpay/platform/issues/5473)) +* pin rust-dashcore to dev at 626c91d1, closes [#1169](https://github.com/dashpay/platform/issues/1169) [#1168](https://github.com/dashpay/platform/issues/1168) +* pin rust-dashcore to the payload serde variant-order fix, closes [rust-dashcore#1156](https://github.com/dashpay/rust-dashcore/issues/1156) +* point every publishable package at the repository it lives in +* upgrade Tenderdash to v2.0.0-dev.2 ([#5836](https://github.com/dashpay/platform/issues/5836)) + +### Notes + +#### Tests + * **platform:** freeze historical BLS, GroveDB/checkpoint, transaction signing, DashPay encryption, and FFI node-ID compatibility vectors, with a script to reproduce them through ignored tests on a pinned historical checkout. -### Fixed +#### Fixed - **dpp:** require a WASM-compatible `blst` version for BLS signatures and Core message/quorum verification, including external consumers with older dependency lockfiles. @@ -20,7 +465,7 @@ `ContextProviderError::QuorumSourceUnavailable`. `get_quorum_public_key_with_status` still returns the key with its status. -### Changed +#### Changed - **swift-sdk:** `SDK(network:)` builds the adaptive context provider in Auto mode instead of the trusted one (`contextProvider` defaults to `.adaptive`). An SDK that no diff --git a/Cargo.lock b/Cargo.lock index 8203d55cf02..d91622cb559 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -172,7 +172,7 @@ checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" [[package]] name = "app-connect-contract" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "base58", "platform-value", @@ -1065,7 +1065,7 @@ dependencies = [ [[package]] name = "check-features" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "toml", ] @@ -1626,7 +1626,7 @@ dependencies = [ [[package]] name = "dapi-grpc" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "bytes", "dash-platform-macros", @@ -1718,7 +1718,7 @@ dependencies = [ [[package]] name = "dash-async" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "futures", "thiserror 2.0.18", @@ -1729,7 +1729,7 @@ dependencies = [ [[package]] name = "dash-context-provider" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "arc-swap", "dash-async", @@ -1744,7 +1744,7 @@ dependencies = [ [[package]] name = "dash-core-proof" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "blst", "hex", @@ -1826,7 +1826,7 @@ dependencies = [ [[package]] name = "dash-platform-balance-checker" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "anyhow", "clap", @@ -1841,7 +1841,7 @@ dependencies = [ [[package]] name = "dash-platform-macros" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "heck 0.5.0", "quote", @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "dash-platform-queries" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "dapi-grpc", "dash-context-provider", @@ -1876,7 +1876,7 @@ dependencies = [ [[package]] name = "dash-sdk" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "arc-swap", "assert_matches", @@ -1925,7 +1925,7 @@ dependencies = [ [[package]] name = "dash-sdk-cxx" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "async-trait", "cxx", @@ -2087,7 +2087,7 @@ dependencies = [ [[package]] name = "dashpay-contract" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "platform-value", "platform-version", @@ -2097,7 +2097,7 @@ dependencies = [ [[package]] name = "data-contracts" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "app-connect-contract", "base58", @@ -2166,7 +2166,7 @@ dependencies = [ [[package]] name = "decision-proposals-contract" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "base58", "platform-value", @@ -2314,7 +2314,7 @@ dependencies = [ [[package]] name = "document-history-contract" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "platform-value", "platform-version", @@ -2336,7 +2336,7 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "dpns-contract" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "platform-value", "platform-version", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "dpp" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "anyhow", "assert_matches", @@ -2417,7 +2417,7 @@ dependencies = [ [[package]] name = "dpp-json-convertible-derive" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "proc-macro2", "quote", @@ -2426,7 +2426,7 @@ dependencies = [ [[package]] name = "drive" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "arc-swap", "assert_matches", @@ -2469,7 +2469,7 @@ dependencies = [ [[package]] name = "drive-abci" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "arc-swap", "assert_matches", @@ -2536,7 +2536,7 @@ dependencies = [ [[package]] name = "drive-proof-verifier" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "dapi-grpc", "dash-context-provider", @@ -4321,7 +4321,7 @@ dependencies = [ [[package]] name = "json-schema-compatibility-validator" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "assert_matches", "json-patch", @@ -4430,7 +4430,7 @@ dependencies = [ [[package]] name = "keyword-search-contract" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "base58", "platform-value", @@ -4620,7 +4620,7 @@ dependencies = [ [[package]] name = "masternode-reward-shares-contract" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "platform-value", "platform-version", @@ -4809,7 +4809,7 @@ dependencies = [ [[package]] name = "moderation-charters-contract" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "base58", "platform-value", @@ -5366,7 +5366,7 @@ checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" [[package]] name = "platform-encryption" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "aes 0.8.4", "cbc", @@ -5379,7 +5379,7 @@ dependencies = [ [[package]] name = "platform-serialization" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "grovedb-bincode", "platform-version", @@ -5387,7 +5387,7 @@ dependencies = [ [[package]] name = "platform-serialization-derive" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "proc-macro2", "quote", @@ -5397,7 +5397,7 @@ dependencies = [ [[package]] name = "platform-value" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "base64 0.22.1", "bs58", @@ -5416,7 +5416,7 @@ dependencies = [ [[package]] name = "platform-value-convertible" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "quote", "syn 2.0.117", @@ -5424,7 +5424,7 @@ dependencies = [ [[package]] name = "platform-version" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "grovedb-bincode", "grovedb-version", @@ -5434,7 +5434,7 @@ dependencies = [ [[package]] name = "platform-versioning" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "proc-macro2", "quote", @@ -5443,7 +5443,7 @@ dependencies = [ [[package]] name = "platform-wallet" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "arc-swap", "async-trait", @@ -5485,7 +5485,7 @@ dependencies = [ [[package]] name = "platform-wallet-ffi" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "anyhow", "async-trait", @@ -5514,7 +5514,7 @@ dependencies = [ [[package]] name = "platform-wallet-storage" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "apple-native-keyring-store", "argon2", @@ -6473,7 +6473,7 @@ dependencies = [ [[package]] name = "rs-dapi" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "async-trait", "axum 0.8.9", @@ -6528,7 +6528,7 @@ dependencies = [ [[package]] name = "rs-dapi-client" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "backon", "chrono", @@ -6559,7 +6559,7 @@ dependencies = [ [[package]] name = "rs-dash-event-bus" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "metrics", "tokio", @@ -6592,7 +6592,7 @@ dependencies = [ [[package]] name = "rs-sdk-ffi" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "async-trait", "bs58", @@ -6627,7 +6627,7 @@ dependencies = [ [[package]] name = "rs-sdk-trusted-context-provider" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "arc-swap", "dapi-grpc", @@ -6661,7 +6661,7 @@ dependencies = [ [[package]] name = "rs-unified-sdk-ffi" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "platform-wallet-ffi", "rs-sdk-ffi", @@ -6669,7 +6669,7 @@ dependencies = [ [[package]] name = "rs-unified-sdk-jni" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "android_logger", "dashcore", @@ -7396,7 +7396,7 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] name = "simple-signer" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "async-trait", "base64 0.22.1", @@ -7517,7 +7517,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strategy-tests" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "dpp", "drive", @@ -7928,7 +7928,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "token-history-contract" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "platform-value", "platform-version", @@ -7938,7 +7938,7 @@ dependencies = [ [[package]] name = "token-market-contract" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "base58", "platform-value", @@ -8746,7 +8746,7 @@ dependencies = [ [[package]] name = "wallet-utils-contract" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "platform-value", "platform-version", @@ -8889,7 +8889,7 @@ checksum = "a8145dd1593bf0fb137dbfa85b8be79ec560a447298955877804640e40c2d6ea" [[package]] name = "wasm-dpp" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "anyhow", "async-trait", @@ -8913,7 +8913,7 @@ dependencies = [ [[package]] name = "wasm-dpp2" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "anyhow", "async-trait", @@ -8932,7 +8932,7 @@ dependencies = [ [[package]] name = "wasm-drive-verify" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "base64 0.22.1", "bs58", @@ -8987,7 +8987,7 @@ dependencies = [ [[package]] name = "wasm-sdk" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "async-trait", "base64 0.22.1", @@ -9513,7 +9513,7 @@ dependencies = [ [[package]] name = "withdrawals-contract" -version = "5.0.3" +version = "5.1.0-dev.1" dependencies = [ "num_enum 0.5.11", "platform-value", diff --git a/Cargo.toml b/Cargo.toml index ae9ae03aa37..8551a00ae14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -161,5 +161,5 @@ opt-level = 3 [workspace.package] -version = "5.0.3" +version = "5.1.0-dev.1" rust-version = "1.98" diff --git a/package.json b/package.json index abefb730c72..36651a172d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/platform", - "version": "5.0.3", + "version": "5.1.0-dev.1", "private": true, "scripts": { "setup": "yarn install && yarn run build && yarn run configure", diff --git a/packages/app-connect-contract/package.json b/packages/app-connect-contract/package.json index 6d0f82ceba8..35da78bf478 100644 --- a/packages/app-connect-contract/package.json +++ b/packages/app-connect-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/app-connect-contract", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "A system contract for encrypted wallet-to-app login responses", "scripts": { "lint": "eslint .", diff --git a/packages/bench-suite/package.json b/packages/bench-suite/package.json index 520520c6fb1..1833c21859f 100644 --- a/packages/bench-suite/package.json +++ b/packages/bench-suite/package.json @@ -1,7 +1,7 @@ { "name": "@dashevo/bench-suite", "private": true, - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "Dash Platform benchmark tool", "engines": { "node": ">=22" diff --git a/packages/dapi-grpc/package.json b/packages/dapi-grpc/package.json index 84ebb977647..39c7d620480 100644 --- a/packages/dapi-grpc/package.json +++ b/packages/dapi-grpc/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/dapi-grpc", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "DAPI GRPC definition file and generated clients", "browser": "browser.js", "main": "node.js", diff --git a/packages/dapi/package.json b/packages/dapi/package.json index 7e684a83e29..82b425fc3c5 100644 --- a/packages/dapi/package.json +++ b/packages/dapi/package.json @@ -1,7 +1,7 @@ { "name": "@dashevo/dapi", "private": true, - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "A decentralized API for the Dash network", "engines": { "node": ">=22" diff --git a/packages/dash-spv/package.json b/packages/dash-spv/package.json index 5546c214e63..011aa588f14 100644 --- a/packages/dash-spv/package.json +++ b/packages/dash-spv/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/dash-spv", - "version": "6.0.3", + "version": "6.1.0-dev.1", "description": "Repository containing SPV functions used by @dashevo", "main": "index.js", "scripts": { diff --git a/packages/dashmate/configs/defaults/tenderdash-seeds.json b/packages/dashmate/configs/defaults/tenderdash-seeds.json index 4fbd840c165..cbb82a24f0c 100644 --- a/packages/dashmate/configs/defaults/tenderdash-seeds.json +++ b/packages/dashmate/configs/defaults/tenderdash-seeds.json @@ -1,110 +1,111 @@ { "mainnet": { "source": "https://quorums.mainnet.networks.dash.org/masternodes", - "lastUpdated": 1791904502, + "lastUpdated": 1794568989, "seeds": [ { - "id": "00866496450d17a5ed1faabb7a8c1ab6adb4efd6", - "host": "38.242.197.189", + "id": "07c5f4d617b6ab3c8ae49b20e362b2a217680ca9", + "host": "89.35.131.149", "port": 26656 }, { - "id": "0d3c71247defe841a0ed8169788a9aa3a170e3e4", - "host": "173.199.71.83", + "id": "102027f8464faaee7d07bab8b8db72779f6b0bcf", + "host": "132.243.197.250", "port": 26656 }, { - "id": "0fc7db91892879ced156cf7333a207669e7e1a35", - "host": "132.243.197.38", + "id": "18fb6158c159a2014cca687beff9226314675153", + "host": "5.199.166.218", "port": 26656 }, { - "id": "18fb6158c159a2014cca687beff9226314675153", - "host": "5.199.166.218", + "id": "1a872dde6185341cdc5c16f5f5a6b6d2f328ea77", + "host": "66.245.196.52", "port": 26656 }, { - "id": "1c5e9b2467d2ceaa20701a6c3e4ef7d9edb9b4df", - "host": "142.44.136.69", + "id": "2228471bba85f28bfb38388762e417b06c95a5f1", + "host": "151.244.85.114", "port": 26656 }, { - "id": "1eb86c7f3c892d044397b9ff326d81522a2ce190", - "host": "109.199.120.79", + "id": "22be376977d5a19be3b4052380816dc6bee617b2", + "host": "62.171.136.93", "port": 26656 }, { - "id": "24ee75e3bb8b5371a7dc3bc835bb99280c609be2", - "host": "109.199.124.30", + "id": "4d40083c974ecf1599a415d60933e85d74e468d5", + "host": "161.97.91.217", "port": 26656 }, { - "id": "28ae1aed5bf1614d9039443eefc5c26a8ac7f557", - "host": "135.181.110.216", + "id": "5c95e9377e647f374f5b6523b2696f37b79eb2df", + "host": "65.108.4.194", "port": 26656 }, { - "id": "7d09e99c0838ea3154b988dcbcd25700d67c9504", - "host": "213.199.54.35", + "id": "74bcdc79c9a02d59664e91e56fd456b15b4a2cf1", + "host": "185.252.234.238", "port": 26656 }, { - "id": "87d36036fd9629064522aeaf1e8b35bd89f7beb8", - "host": "161.97.88.219", + "id": "7d09e99c0838ea3154b988dcbcd25700d67c9504", + "host": "213.199.54.35", "port": 26656 }, { - "id": "afbaf95e21861f715391bd431c3b9e05eaa7adcd", - "host": "75.119.138.9", + "id": "7eadeaaaf2ea73d0b6a102cc2b4bfb5cdd6b4b4e", + "host": "65.109.114.212", "port": 26656 }, { - "id": "b37eb49173598a331c363d4a6c4034f9bdc0f9f4", - "host": "109.123.244.131", + "id": "a03db234e85dd0649875dd17bfb5a17f38a3701e", + "host": "195.26.254.228", "port": 26656 }, { - "id": "c94ecc1d76974899acbf00be9b842ab9640a6345", - "host": "173.212.196.214", + "id": "a72663930451d8aeeeb2335efb3e61e3453bab3d", + "host": "77.105.61.11", "port": 26656 }, { - "id": "ce03948dd38c60d45da9fac1d24de40173342202", - "host": "49.13.28.255", + "id": "b64b0904848697fb4659080bf3463198f56ec7be", + "host": "37.60.254.205", "port": 26656 }, { - "id": "d6bb7500e69c950bae8e4437adcb3394578371cf", - "host": "88.216.191.113", + "id": "cd5d5675a3d36c2be6b2d6a07ea56dea4e2e91c8", + "host": "31.220.84.93", "port": 26656 }, { - "id": "e78a0b32533115816a01e3b96051ef5a68ada654", - "host": "54.69.95.118", + "id": "d8450a8696dedc04a55396059d394fd588fd4926", + "host": "161.97.102.156", "port": 26656 }, { - "id": "e9c1fc49bde855b6a2688ed59a4828bb86888dd3", - "host": "89.125.209.27", + "id": "decd6ce372d5967b66c048ea4f62a361ce005261", + "host": "132.243.197.40", "port": 26656 }, { - "id": "ea32e674ac35685435a1e0484729bf70c9078e0e", - "host": "149.102.140.101", + "id": "df2f9efb17795814795a9ed2fba50a96cc723e33", + "host": "75.119.156.254", "port": 26656 }, { - "id": "ec38213efe06b8025c342c70488582088c4ac45c", - "host": "132.243.197.252", + "id": "ee9ab93559e6e931d7dbcf269e1ea8446e7068e5", + "host": "149.28.241.190", "port": 26656 }, { - "id": "f1d8034a762e105efaf354b2dd86e099cb54a8bf", - "host": "161.97.88.199", + "id": "eed2f55dd2371540fb6bbc476c4986ad3223aa37", + "host": "37.27.67.154", "port": 26656 } ], "previousSeedSetHashes": [ + "185c462de50f7c468fbb489c84152e707fd334ab1b687215ce66e62d862b10e7", "3d364d2040d1b69cfea53f98e56e8a331c6550c3a9f9fbcaea1e86c382867bce", "52e830a07b2bffe900fddb1296128a4372fe941328c1b5d3203415b935522220", "67bbbf4b10a9a6c2856aa0dfb588f3776bc4a64b8c1d42d4a51c292b6af44586" @@ -112,16 +113,16 @@ }, "testnet": { "source": "https://quorums.testnet.networks.dash.org/masternodes", - "lastUpdated": 1791904335, + "lastUpdated": 1794569245, "seeds": [ { - "id": "0498ade3c80045c2a7520e921180ae1c39da5c57", - "host": "68.67.122.25", + "id": "068f00a6ab7afef0f675dc9bad01e766859fab3f", + "host": "85.209.243.6", "port": 36656 }, { - "id": "068f00a6ab7afef0f675dc9bad01e766859fab3f", - "host": "85.209.243.6", + "id": "0785881ea118c05df7bb9dd2195a78f10cdde0bb", + "host": "68.67.122.4", "port": 36656 }, { @@ -145,38 +146,33 @@ "port": 36656 }, { - "id": "35d9eb76397d05b43b5cd8da7ccfa8408bc89ab3", - "host": "68.67.122.26", - "port": 36656 - }, - { - "id": "3e8b10646ee9d6c28d75c280b357dd3a9ae9f962", - "host": "68.67.122.11", + "id": "530465b012908125960c2737631248a028d3f804", + "host": "87.229.22.126", "port": 36656 }, { - "id": "5192501d94ca7b039afbc0ed6a83aec48614e827", - "host": "68.67.122.3", + "id": "65f60ccafcb05e87142b5c9da3ff13639abd772c", + "host": "85.209.243.7", "port": 36656 }, { - "id": "5bdbf34a0dad860c6ec71523ae39373325225cc1", - "host": "68.67.122.12", + "id": "68c506d43816d1a8389c860c1d162be44d1e777c", + "host": "68.67.122.10", "port": 36656 }, { - "id": "62e960a3f6b650feed98a266b3ccdf6e363562cf", - "host": "68.67.122.1", + "id": "6d57707c196e06487d326094c964f258f5b77c35", + "host": "68.67.122.23", "port": 36656 }, { - "id": "65f60ccafcb05e87142b5c9da3ff13639abd772c", - "host": "85.209.243.7", + "id": "7034f0d3853c5351fb8e0ffd3c1daf12c51c2d89", + "host": "68.67.122.9", "port": 36656 }, { - "id": "68c506d43816d1a8389c860c1d162be44d1e777c", - "host": "68.67.122.10", + "id": "708a8c0939d29bf99998af037fbd4dda9c419468", + "host": "85.209.243.8", "port": 36656 }, { @@ -190,8 +186,13 @@ "port": 36656 }, { - "id": "7ada3e486409b39c94a0833c8d782f35bc24e96a", - "host": "68.67.122.5", + "id": "8feb00404d6f765856c95e587b2523a365bc7258", + "host": "68.67.122.24", + "port": 36656 + }, + { + "id": "972a33056d57359de8acfa4fb8b29dc1c14f76b8", + "host": "68.67.122.16", "port": 36656 }, { @@ -200,25 +201,26 @@ "port": 36656 }, { - "id": "c075993a8336f93a13bb7bbb7e0e89928be4aafb", - "host": "68.67.122.28", + "id": "a0a0e17bfe82a484fefe348b7569a6d77d29d2c2", + "host": "68.67.122.8", "port": 36656 }, { - "id": "c9726746374cc2f90c1fa5af2f845b1bffc0712d", - "host": "85.209.243.5", + "id": "a1f9db49e0e93dd506c0d8485ed93ecfa537b559", + "host": "68.67.122.6", "port": 36656 }, { - "id": "fe2d4798df3e9b41a6823bc0b3f020478e87925d", - "host": "68.67.122.29", + "id": "ec7bf3b9bc72eda38c80bb7cf16e294e763e56b4", + "host": "68.67.122.22", "port": 36656 } ], "previousSeedSetHashes": [ + "3956cd4bfa6796a06d349a0753d543b29606d0b4eed71cf7ae7109abd24c53ce", "8a32b8779d5eae671428ec2cbf413c5ebb1a7cd9103007c03b4c0299bec5a274", "990e93f1fd0831cf839c18c0672e460eb72515efbd78cdfcb5b4a343f8d577aa" ] }, - "version": "5.0.0-beta.2" + "version": "5.1.0-dev.1" } diff --git a/packages/dashmate/package.json b/packages/dashmate/package.json index 7dd002a5d3c..6d8c2d8cbc8 100644 --- a/packages/dashmate/package.json +++ b/packages/dashmate/package.json @@ -1,6 +1,6 @@ { "name": "dashmate", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "Distribution package for Dash node installation", "scripts": { "lint": "eslint .", diff --git a/packages/dashpay-contract/package.json b/packages/dashpay-contract/package.json index 9b7a600aa90..4aaba9f0e6c 100644 --- a/packages/dashpay-contract/package.json +++ b/packages/dashpay-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/dashpay-contract", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "Reference contract of the DashPay DPA on Dash Evolution", "scripts": { "lint": "eslint .", diff --git a/packages/decision-proposals-contract/package.json b/packages/decision-proposals-contract/package.json index 3f1b312f577..f1cd0600216 100644 --- a/packages/decision-proposals-contract/package.json +++ b/packages/decision-proposals-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/decision-proposals-contract", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "A system contract for decision proposals: yes/no questions put to the masternodes", "scripts": { "lint": "eslint .", diff --git a/packages/document-history-contract/package.json b/packages/document-history-contract/package.json index 897644db4b6..93de8d27f0e 100644 --- a/packages/document-history-contract/package.json +++ b/packages/document-history-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/document-history-contract", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "The document history contract", "scripts": { "lint": "eslint .", diff --git a/packages/dpns-contract/package.json b/packages/dpns-contract/package.json index 023d19ef471..746bd73b801 100644 --- a/packages/dpns-contract/package.json +++ b/packages/dpns-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/dpns-contract", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "A contract and helper scripts for DPNS DApp", "scripts": { "lint": "eslint .", diff --git a/packages/js-dapi-client/package.json b/packages/js-dapi-client/package.json index ceb4587ec3e..7daf09737d4 100644 --- a/packages/js-dapi-client/package.json +++ b/packages/js-dapi-client/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/dapi-client", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "Client library used to access Dash DAPI endpoints", "main": "lib/index.js", "contributors": [ diff --git a/packages/js-dash-sdk/package.json b/packages/js-dash-sdk/package.json index 54ce56cdffa..966d9d186b5 100644 --- a/packages/js-dash-sdk/package.json +++ b/packages/js-dash-sdk/package.json @@ -1,6 +1,6 @@ { "name": "dash", - "version": "8.0.3", + "version": "8.1.0-dev.1", "description": "Dash library for JavaScript/TypeScript ecosystem (Wallet, DAPI, Primitives, BLS, ...)", "main": "build/index.js", "unpkg": "dist/dash.min.js", diff --git a/packages/js-evo-sdk/package.json b/packages/js-evo-sdk/package.json index 9aec3f9162d..00bb73942f1 100644 --- a/packages/js-evo-sdk/package.json +++ b/packages/js-evo-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/evo-sdk", - "version": "5.0.3", + "version": "5.1.0-dev.1", "type": "module", "main": "./dist/evo-sdk.module.js", "types": "./dist/sdk.d.ts", diff --git a/packages/js-grpc-common/package.json b/packages/js-grpc-common/package.json index 12b94ecfa37..32a2341477e 100644 --- a/packages/js-grpc-common/package.json +++ b/packages/js-grpc-common/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/grpc-common", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "Common GRPC library", "main": "index.js", "scripts": { diff --git a/packages/keyword-search-contract/package.json b/packages/keyword-search-contract/package.json index 7516fad3835..93981953459 100644 --- a/packages/keyword-search-contract/package.json +++ b/packages/keyword-search-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/keyword-search-contract", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "A contract that allows searching for contracts", "scripts": { "lint": "eslint .", diff --git a/packages/masternode-reward-shares-contract/package.json b/packages/masternode-reward-shares-contract/package.json index 3b2c7fb9b79..7b5c1f36aac 100644 --- a/packages/masternode-reward-shares-contract/package.json +++ b/packages/masternode-reward-shares-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/masternode-reward-shares-contract", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "A contract and helper scripts for reward sharing", "scripts": { "lint": "eslint .", diff --git a/packages/moderation-charters-contract/package.json b/packages/moderation-charters-contract/package.json index 33d8a95f52c..f8e310a3aa4 100644 --- a/packages/moderation-charters-contract/package.json +++ b/packages/moderation-charters-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/moderation-charters-contract", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "A system contract for the charters of elected moderation teams", "scripts": { "lint": "eslint .", diff --git a/packages/platform-test-suite/package.json b/packages/platform-test-suite/package.json index b03809335e6..e71c3e283fe 100644 --- a/packages/platform-test-suite/package.json +++ b/packages/platform-test-suite/package.json @@ -1,7 +1,7 @@ { "name": "@dashevo/platform-test-suite", "private": true, - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "Dash Network end-to-end tests", "engines": { "node": ">=22" diff --git a/packages/rs-sdk-trusted-context-provider/checkpoints/testnet.json b/packages/rs-sdk-trusted-context-provider/checkpoints/testnet.json index f6144c818e6..ff505f7ba58 100644 --- a/packages/rs-sdk-trusted-context-provider/checkpoints/testnet.json +++ b/packages/rs-sdk-trusted-context-provider/checkpoints/testnet.json @@ -1,7 +1,7 @@ { "network": 1, - "height": 1560000, - "block_hash": "00000215d91d5f3cdfda9de376171ce7eebfeb5adbabc012e8d59501ba07a35e", - "masternode_root": "335e0734bf2efdc117e639e0db433d230042a061b5b17da8462429cf3d11dd80", - "quorum_root": "d1a9305a96f477a0f86be90f2ee4af1085027d5305fd769f2c406dd353114a43" + "height": 1590312, + "block_hash": "0000005f9eaa8b84ae9447a208f7907e6bbe6b016a61aa35a6d63a43ba927019", + "masternode_root": "f8de59a4084c14cba9f47af324cce606add3ee5de348c93e9dfb82fe5a4295ed", + "quorum_root": "65f9821d2733d376601d418d97f338319bb314cdd327812943f1cd586ef632d7" } diff --git a/packages/rs-sdk-trusted-context-provider/tests/data/checkpoint-evidence-testnet.json b/packages/rs-sdk-trusted-context-provider/tests/data/checkpoint-evidence-testnet.json index 393af29e14c..10d8142b26e 100644 --- a/packages/rs-sdk-trusted-context-provider/tests/data/checkpoint-evidence-testnet.json +++ b/packages/rs-sdk-trusted-context-provider/tests/data/checkpoint-evidence-testnet.json @@ -1,9 +1,16 @@ { - "header": "00000020f7d6ef3f979b46d113f3abdcc63ddd363778903ce2c5e5893bf883cd200000002ebbe01f8fc668a09da849e138e8ce05969f69529f98d43a995289c4b88134990286b56a165d051e38500700", - "coinbase": "03000500010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff03b84b8c03000000001976a914b489115851ca07a26a5ad8bac3cec3c7dbebd83188ac2ed5fd0300000000016af80da706000000001976a914c69a0bda7daaae481be8def95e5f347a1d00a4b488ac00000000af0300c0cd170080dd113dcf292446a87db1b561a04200233d43dbe039e617c1fd2ebf34075e33434a1153d36d402c9f76fd05537d028510afe42e0fe96bf8a077f4965a30a9d1008c62ca98828c6842f0c2a1a9d904f482c9c20e6cd32239b9912ea93142a26b69420a31ffba488e8850a1eb7c07200d2d02e0d9f6b2d4934f618e420ccb323b312be33e77900c46bf7a1ad799febf6c03fffcd753e77637015d212a7be43a479f5961de996d210000", - "coinbase_path": { - "index": 0, - "count": 1, - "siblings": [] - } + "header": "00000020991d7ee389c64162f65177e9ecbd6ddb0aaf3082c064f7d1a63f0553730000007435fb2366721634c0a4543e5097fa1385713a9271f3d6324f3c7dd75354258fdeb5f56affec001e6d4e0a00", + "coinbase": "03000500010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff0376908c03000000001976a914b489115851ca07a26a5ad8bac3cec3c7dbebd83188ac2ed5fd0300000000016a32dca706000000001976a91464f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d788ac00000000cf040028441800ed95425afe82fb9d3ec948e35deed3ad06e6cc24f37af4a9cb144c08a459def8d732f66e58cdf143298127d3cd14b39b3138f3978d411d6076d333271d82f96500b5e4cc86198a8e837e4eb6d154d4298c39281c7cf2d428cb63621bc2083b48e71e48aeacdf1e892f8fa84ee90b1fe12e091b61d2211e15e57fb78e63099f7c746cd1bfe4cc9aebbe41f87e29f37bc424d01ade4ab1842126eb589ea284d19511fdbb620fcb2200000000000000000000000000000000000000000000000000000000000000000000", + "coinbase_path": { + "index": 0, + "count": 57, + "siblings": [ + "56c27cd93bc0f65d7c98514c4dd369207ba30fa1150c3ff2ab5fc541dc04156c", + "7bd38c6dbcfb7be41ce7dbf9ad9f47c46642874e534dfecf817f1d4e51d85cf5", + "4ffb6a3f935a66c35690c2bdaf64732566397cd12f1fea29b31161a402eedbea", + "8d91942c6a4be4ddab18a2d5f66bfe60034f6e32c1460c2ee89e41e7a089f580", + "fa3afbb74b22d6a68a671dc96942043c16162c9e4d4314bc184cf0fea8841337", + "183e3ff6a59e85786b01b609cea610fa67fb0f3ad34e1aaf75a76811e09392f4" + ] + } } diff --git a/packages/token-history-contract/package.json b/packages/token-history-contract/package.json index d0ef4dc3913..9de1ceeaa9f 100644 --- a/packages/token-history-contract/package.json +++ b/packages/token-history-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/token-history-contract", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "The token history contract", "scripts": { "lint": "eslint .", diff --git a/packages/token-market-contract/package.json b/packages/token-market-contract/package.json index 9dbdbf603be..10bc413e9dc 100644 --- a/packages/token-market-contract/package.json +++ b/packages/token-market-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/token-market-contract", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "A system contract for the open orders of the token marketplace", "scripts": { "lint": "eslint .", diff --git a/packages/wallet-lib/package.json b/packages/wallet-lib/package.json index 8feb0c93787..07f3a6225d1 100644 --- a/packages/wallet-lib/package.json +++ b/packages/wallet-lib/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/wallet-lib", - "version": "12.0.3", + "version": "12.1.0-dev.1", "description": "Light wallet library for Dash", "main": "src/index.js", "unpkg": "dist/wallet-lib.min.js", diff --git a/packages/wallet-utils-contract/package.json b/packages/wallet-utils-contract/package.json index 68f9d606974..9db3e8395b0 100644 --- a/packages/wallet-utils-contract/package.json +++ b/packages/wallet-utils-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/wallet-utils-contract", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "A contract and helper scripts for Wallet DApp", "scripts": { "lint": "eslint .", diff --git a/packages/wasm-dpp/package.json b/packages/wasm-dpp/package.json index 1d6b156ee58..0fbbc305d99 100644 --- a/packages/wasm-dpp/package.json +++ b/packages/wasm-dpp/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/wasm-dpp", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "The JavaScript implementation of the Dash Platform Protocol", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/wasm-dpp2/package.json b/packages/wasm-dpp2/package.json index 4b7266f8b21..ba6dce42f11 100644 --- a/packages/wasm-dpp2/package.json +++ b/packages/wasm-dpp2/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/wasm-dpp2", - "version": "5.0.3", + "version": "5.1.0-dev.1", "type": "module", "main": "./dist/dpp.js", "types": "./dist/dpp.d.ts", diff --git a/packages/wasm-drive-verify/package.json b/packages/wasm-drive-verify/package.json index 29172c566a6..f9a7e724737 100644 --- a/packages/wasm-drive-verify/package.json +++ b/packages/wasm-drive-verify/package.json @@ -3,7 +3,7 @@ "collaborators": [ "Dash Core Group " ], - "version": "5.0.3", + "version": "5.1.0-dev.1", "license": "MIT", "description": "WASM bindings for Drive verify functions", "repository": { diff --git a/packages/wasm-sdk/package.json b/packages/wasm-sdk/package.json index 0e99172d5da..a79951ba75f 100644 --- a/packages/wasm-sdk/package.json +++ b/packages/wasm-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/wasm-sdk", - "version": "5.0.3", + "version": "5.1.0-dev.1", "type": "module", "main": "./dist/sdk.js", "types": "./dist/sdk.d.ts", diff --git a/packages/withdrawals-contract/package.json b/packages/withdrawals-contract/package.json index 919b5029f0e..40a5dae9654 100644 --- a/packages/withdrawals-contract/package.json +++ b/packages/withdrawals-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/withdrawals-contract", - "version": "5.0.3", + "version": "5.1.0-dev.1", "description": "Data Contract to manipulate and track withdrawals", "scripts": { "build": "", From a4980b1f15b9274d394620ea560c2d81a2952318 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Fri, 13 Nov 2026 12:50:47 +0100 Subject: [PATCH 18/26] fix(platform-wallet): store load-time locks only for installed wallets - A load keeps the locks it made on a wallet snapshot only once that snapshot is installed. A snapshot skipped for a wallet already registered, or dropped for a fresh read, no longer writes its locks over the live wallet's. - FFI: `OUTPOINT_LOCKS` is attested only with the wallet list load pair wired too, since that load is where the stored locks come back. - Document that unlocking a masternode collateral lasts for the session: the next load locks it again, as Dash Core does at start. Co-Authored-By: Claude Fable 5.2 --- .../rs-platform-wallet-ffi/src/persistence.rs | 83 ++++++++++++------- .../rs-platform-wallet/src/manager/load.rs | 9 +- .../src/wallet/outpoint_locks.rs | 5 +- 3 files changed, 64 insertions(+), 33 deletions(-) diff --git a/packages/rs-platform-wallet-ffi/src/persistence.rs b/packages/rs-platform-wallet-ffi/src/persistence.rs index 808b862e5ec..f20da30d2b8 100644 --- a/packages/rs-platform-wallet-ffi/src/persistence.rs +++ b/packages/rs-platform-wallet-ffi/src/persistence.rs @@ -204,7 +204,9 @@ pub const PLATFORM_WALLET_PERSISTENCE_CAPABILITY_PRIVATE_CONTACT_REQUEST_SCAN_ST /// are persisted AND restored. Requires the extension trio /// `on_persist_wallet_changeset_outpoint_locks_fn` + /// `on_load_wallet_locked_outpoints_fn` + -/// `on_load_wallet_locked_outpoints_free_fn`, and the host declaring the bit. +/// `on_load_wallet_locked_outpoints_free_fn`, the wallet list load pair +/// (`on_load_wallet_list_fn` + `on_load_wallet_list_free_fn`) that brings +/// the stored locks back, and the host declaring the bit. pub const PLATFORM_WALLET_PERSISTENCE_CAPABILITY_OUTPOINT_LOCKS: u64 = 1 << 16; /// Version of [`PersistenceCallbacksExtension`]. The extension is deliberately @@ -2063,7 +2065,10 @@ impl FFIPersister { { capabilities = capabilities.union(PersistenceCapabilities::TRACKED_MASTERNODES); } - if self.wallet_changeset_outpoint_locks_callback.is_some() + // The stored locks come back while the wallet list is loaded, so + // without that pair there is no restart to attest. + if wallet_restore + && self.wallet_changeset_outpoint_locks_callback.is_some() && self.load_wallet_locked_outpoints_callback.is_some() && self.load_wallet_locked_outpoints_free_callback.is_some() { @@ -15383,36 +15388,56 @@ mod outpoint_lock_tests { } #[test] - fn should_attest_outpoint_locks_only_with_the_whole_trio_declared() { - let declared = PersistenceCapabilities::OUTPOINT_LOCKS; - let wired = FFIPersister::new_with_persistence_capabilities_and_extensions( - PersistenceCallbacks::default(), - declared, - trio(), - ); - assert!(wired + fn should_attest_outpoint_locks_only_with_the_trio_and_the_wallet_list_declared() { + unsafe extern "C" fn no_wallets( + _context: *mut c_void, + entries: *mut *const WalletRestoreEntryFFI, + count: *mut usize, + ) -> i32 { + *entries = std::ptr::null(); + *count = 0; + 0 + } + unsafe extern "C" fn free_no_wallets( + _context: *mut c_void, + _entries: *const WalletRestoreEntryFFI, + _count: usize, + ) { + } + // The wallet list load is where the stored locks come back. + let with_wallet_list = || PersistenceCallbacks { + on_load_wallet_list_fn: Some(no_wallets), + on_load_wallet_list_free_fn: Some(free_no_wallets), + ..PersistenceCallbacks::default() + }; + let attests = |callbacks, declared, extensions| { + FFIPersister::new_with_persistence_capabilities_and_extensions( + callbacks, declared, extensions, + ) .persistence_capabilities() - .contains(PersistenceCapabilities::OUTPOINT_LOCKS)); + .contains(PersistenceCapabilities::OUTPOINT_LOCKS) + }; + let declared = PersistenceCapabilities::OUTPOINT_LOCKS; - let undeclared = FFIPersister::new_with_persistence_capabilities_and_extensions( - PersistenceCallbacks::default(), - PersistenceCapabilities::NONE, - trio(), + assert!(attests(with_wallet_list(), declared, trio())); + assert!( + !attests(with_wallet_list(), PersistenceCapabilities::NONE, trio()), + "the host must declare the bit" ); - assert!(!undeclared - .persistence_capabilities() - .contains(PersistenceCapabilities::OUTPOINT_LOCKS)); - - let without_free = FFIPersister::new_with_persistence_capabilities_and_extensions( - PersistenceCallbacks::default(), - declared, - PersistenceExtensionCallbacks { - load_wallet_locked_outpoints_free: None, - ..trio() - }, + assert!( + !attests( + with_wallet_list(), + declared, + PersistenceExtensionCallbacks { + load_wallet_locked_outpoints_free: None, + ..trio() + }, + ), + "the whole trio is required" + ); + assert!( + !attests(PersistenceCallbacks::default(), declared, trio()), + "without the wallet list load no lock is ever restored" ); - assert!(!without_free - .persistence_capabilities() - .contains(PersistenceCapabilities::OUTPOINT_LOCKS)); } } diff --git a/packages/rs-platform-wallet/src/manager/load.rs b/packages/rs-platform-wallet/src/manager/load.rs index 4d05a8670e4..fe3b2ac98e9 100644 --- a/packages/rs-platform-wallet/src/manager/load.rs +++ b/packages/rs-platform-wallet/src/manager/load.rs @@ -315,9 +315,6 @@ impl PlatformWalletManager

{ load_locks.extend(platform_info.lock_known_masternode_collaterals( &self.tracked_masternodes_service().known_collaterals(), )); - if !load_locks.is_empty() { - load_locks_by_wallet.insert(wallet_id, load_locks); - } // A restored outbound-account marker says the contact's external // account was built from its current xpub, which suppresses the // startup rebuild. It must not vouch for a pool the host kept @@ -506,6 +503,12 @@ impl PlatformWalletManager

{ ))); break 'load; } + // Only the locks of a snapshot that became the live wallet + // are stored: one skipped for a wallet already registered, or + // dropped for a fresh read, says nothing about the live one. + if !load_locks.is_empty() { + load_locks_by_wallet.insert(wallet_id, load_locks); + } let host_cursor = durable_cursors .get(&wallet_id) .map_or(loaded_cursor, |entry| entry.height); diff --git a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs index 56d2ace0372..3b949c5f9f1 100644 --- a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs +++ b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs @@ -335,7 +335,10 @@ impl PlatformWallet { /// /// Unlocking a masternode collateral lets a send spend it, and spending /// it ends the masternode registration. The wallet never unlocks one on - /// its own. Processing the registration again (a rescan) locks it again. + /// its own. The unlock of a collateral lasts for the session: the next + /// load locks the collateral of every masternode the wallet knows again, + /// as Dash Core does at start, and so does processing the registration + /// again (a rescan). Any other outpoint stays unlocked. /// Returns `true` when the outpoint was locked. /// /// Persisted before this returns, like [`Self::lock_outpoint`]. From 3559fe39b444d36f52113240d7c635355199bc59 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Fri, 13 Nov 2026 13:00:27 +0100 Subject: [PATCH 19/26] test(platform-wallet): set the document erase gate in the collateral payment test v5.1-dev added `IdentityWallet::document_erase_gate`; the test that builds the wallet by hand did not compile after the merge. Co-Authored-By: Claude Fable 5.2 --- .../rs-platform-wallet/src/wallet/identity/network/payments.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs b/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs index a72cfa4c209..97d4378aecb 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/payments.rs @@ -15951,6 +15951,7 @@ mod tests { generation: Arc::clone(&real.generation), broadcaster: Arc::clone(&broadcaster), sdk_writer: Arc::clone(&real.sdk_writer), + document_erase_gate: Arc::clone(&real.document_erase_gate), dpns_operation_gate: Arc::clone(&real.dpns_operation_gate), dpns_sync_progress: Arc::clone(&real.dpns_sync_progress), }; From d48b08c7845089eec1e0e1c661320aeabe0bedaf Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Fri, 13 Nov 2026 13:00:27 +0100 Subject: [PATCH 20/26] Revert "refactor(platform-wallet): use key-wallet's collateral helpers" This reverts commit e0f5d97bea3b7cacadc54a4398984ef3f0bc2771. --- .../src/wallet/outpoint_locks.rs | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs index 3b949c5f9f1..22d0eb03ad5 100644 --- a/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs +++ b/packages/rs-platform-wallet/src/wallet/outpoint_locks.rs @@ -62,10 +62,10 @@ use std::collections::{BTreeMap, BTreeSet}; use std::sync::Arc; +use dashcore::blockdata::transaction::special_transaction::TransactionPayload; use dashcore::{OutPoint, Transaction, Txid}; use key_wallet::managed_account::transaction_record::TransactionRecord; use key_wallet::transaction_checking::account_checker::TransactionCheckResult; -use key_wallet::wallet::managed_wallet_info::masternode_collateral; use key_wallet_manager::WalletManager; use tokio::sync::RwLock; @@ -73,6 +73,23 @@ use crate::changeset::{CoreChangeSet, PlatformWalletChangeSet, PlatformWalletPer use crate::error::PlatformWalletError; use crate::wallet::platform_wallet::{PlatformWallet, PlatformWalletInfo, WalletId}; +/// The collateral `tx` registers when it is a ProRegTx: the outpoint its +/// payload names, or, when that names a null txid, the ProRegTx's own output +/// at that index. `None` for any other transaction, and for an own-output +/// index past the outputs (such a registration names no coin). +pub(crate) fn registration_collateral(tx: &Transaction) -> Option { + let Some(TransactionPayload::ProviderRegistrationPayloadType(registration)) = + &tx.special_transaction_payload + else { + return None; + }; + let named = registration.collateral_outpoint; + if named.txid != Txid::all_zeros() { + return Some(named); + } + ((named.vout as usize) < tx.output.len()).then(|| OutPoint::new(tx.txid(), named.vout)) +} + /// The collaterals that the masternode registrations among `records` keep /// out of coin selection. /// @@ -86,7 +103,7 @@ pub fn registered_collaterals<'a>( records .into_iter() .filter_map(|record| { - let collateral = masternode_collateral(&record.transaction)?; + let collateral = registration_collateral(&record.transaction)?; let creates_it = collateral.txid == record.txid; (creates_it || record.is_confirmed()).then_some(collateral) }) @@ -221,7 +238,7 @@ impl PlatformWalletInfo { pub(crate) fn track_collaterals(&mut self, collaterals: &BTreeSet) -> Vec { let mut held = Vec::new(); for outpoint in collaterals { - if self.tracked_collaterals.insert(*outpoint) && self.core_wallet.holds_coin(outpoint) { + if self.tracked_collaterals.insert(*outpoint) && self.holds_coin(outpoint) { held.push(*outpoint); } } @@ -248,7 +265,7 @@ impl PlatformWalletInfo { let arrived: Vec = self .tracked_collaterals .iter() - .filter(|outpoint| outpoint.txid == txid && self.core_wallet.holds_coin(outpoint)) + .filter(|outpoint| outpoint.txid == txid && self.holds_coin(outpoint)) .copied() .collect(); for outpoint in arrived { @@ -260,6 +277,16 @@ impl PlatformWalletInfo { } } + /// Whether a funds account of this wallet holds `outpoint` as an unspent + /// coin. + fn holds_coin(&self, outpoint: &OutPoint) -> bool { + self.core_wallet + .accounts + .all_funding_accounts() + .iter() + .any(|account| account.utxos.contains_key(outpoint)) + } + /// Lock `outpoints`, mirror the balance to the UI when any lock was /// added, and return the ones that were not locked before. fn lock_and_publish(&mut self, outpoints: impl IntoIterator) -> Vec { From 853bbb8d3a310246de7f90a723db080fc88e469e Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Fri, 13 Nov 2026 13:13:25 +0100 Subject: [PATCH 21/26] chore: pin rust-dashcore to the merged collateral lock Pins `dev` at 6b985d1f, the merge of rust-dashcore#1391. The later `dev` commits are left out for now: #1379 makes `verify_data_signature` refuse a high-S signature itself, which changes the error dpp reports for one and needs its own change in dpp. #1400 (public `masternode_collateral` and `holds_coin`) comes after it, so the local copies of those two helpers stay until the pin moves past #1379. Co-Authored-By: Claude Fable 5.2 --- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 16 ++++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4dfececc157..8d60c1b6200 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1756,7 +1756,7 @@ dependencies = [ [[package]] name = "dash-network" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=6b985d1f2a19b2a438392822b505627b989be27a#6b985d1f2a19b2a438392822b505627b989be27a" dependencies = [ "dash-params", "grovedb-bincode", @@ -1767,7 +1767,7 @@ dependencies = [ [[package]] name = "dash-network-seeds" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=6b985d1f2a19b2a438392822b505627b989be27a#6b985d1f2a19b2a438392822b505627b989be27a" dependencies = [ "dash-network", ] @@ -1941,7 +1941,7 @@ dependencies = [ [[package]] name = "dash-spv" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=6b985d1f2a19b2a438392822b505627b989be27a#6b985d1f2a19b2a438392822b505627b989be27a" dependencies = [ "async-trait", "bip324", @@ -1988,7 +1988,7 @@ dependencies = [ [[package]] name = "dashcore" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=6b985d1f2a19b2a438392822b505627b989be27a#6b985d1f2a19b2a438392822b505627b989be27a" dependencies = [ "anyhow", "base64 0.23.1", @@ -2014,7 +2014,7 @@ dependencies = [ [[package]] name = "dashcore-crypto" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=6b985d1f2a19b2a438392822b505627b989be27a#6b985d1f2a19b2a438392822b505627b989be27a" dependencies = [ "base58ck", "bitcoin-crypto", @@ -2036,12 +2036,12 @@ dependencies = [ [[package]] name = "dashcore-private" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=6b985d1f2a19b2a438392822b505627b989be27a#6b985d1f2a19b2a438392822b505627b989be27a" [[package]] name = "dashcore-rpc" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=6b985d1f2a19b2a438392822b505627b989be27a#6b985d1f2a19b2a438392822b505627b989be27a" dependencies = [ "dashcore-rpc-json", "hex-conservative 1.3.0", @@ -2054,7 +2054,7 @@ dependencies = [ [[package]] name = "dashcore-rpc-json" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=6b985d1f2a19b2a438392822b505627b989be27a#6b985d1f2a19b2a438392822b505627b989be27a" dependencies = [ "dashcore", "grovedb-bincode", @@ -2069,7 +2069,7 @@ dependencies = [ [[package]] name = "dashcore_hashes" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=6b985d1f2a19b2a438392822b505627b989be27a#6b985d1f2a19b2a438392822b505627b989be27a" dependencies = [ "bitcoin_hashes 1.2.0", "dash-pow", @@ -3168,7 +3168,7 @@ dependencies = [ [[package]] name = "git-state" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=6b985d1f2a19b2a438392822b505627b989be27a#6b985d1f2a19b2a438392822b505627b989be27a" [[package]] name = "glob" @@ -4396,7 +4396,7 @@ dependencies = [ [[package]] name = "key-wallet" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=6b985d1f2a19b2a438392822b505627b989be27a#6b985d1f2a19b2a438392822b505627b989be27a" dependencies = [ "async-trait", "bip39 3.0.0", @@ -4417,7 +4417,7 @@ dependencies = [ [[package]] name = "key-wallet-manager" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=d659dcd10dd26bfbb41c580355d912b23f58d12e#d659dcd10dd26bfbb41c580355d912b23f58d12e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=6b985d1f2a19b2a438392822b505627b989be27a#6b985d1f2a19b2a438392822b505627b989be27a" dependencies = [ "async-trait", "dashcore", diff --git a/Cargo.toml b/Cargo.toml index 6024bfa2d15..4353108f700 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,14 +70,14 @@ grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb grovedb-version = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb7cdc19f5977d64f20f93107f62844b1" } grovedb-epoch-based-storage-flags = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb7cdc19f5977d64f20f93107f62844b1" } grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb7cdc19f5977d64f20f93107f62844b1" } -dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } -dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } -dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } -key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } -key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } -dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } -dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } -dashcore-crypto = { git = "https://github.com/dashpay/rust-dashcore", rev = "d659dcd10dd26bfbb41c580355d912b23f58d12e" } +dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "6b985d1f2a19b2a438392822b505627b989be27a" } +dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "6b985d1f2a19b2a438392822b505627b989be27a" } +dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "6b985d1f2a19b2a438392822b505627b989be27a" } +key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "6b985d1f2a19b2a438392822b505627b989be27a" } +key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "6b985d1f2a19b2a438392822b505627b989be27a" } +dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "6b985d1f2a19b2a438392822b505627b989be27a" } +dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "6b985d1f2a19b2a438392822b505627b989be27a" } +dashcore-crypto = { git = "https://github.com/dashpay/rust-dashcore", rev = "6b985d1f2a19b2a438392822b505627b989be27a" } tokio-metrics = "0.5" # Size-tuned profile for the iOS `rs-unified-sdk-ffi` staticlib, which From a7e85074a8f6f98e54a1baabcd4600c01406eb26 Mon Sep 17 00:00:00 2001 From: Kevin Rombach <35775977+xdustinface@users.noreply.github.com> Date: Sat, 14 Nov 2026 00:18:13 +1000 Subject: [PATCH 22/26] chore(platform): pin `rust-dashcore` at the `v0.46.0` release (#5914) --- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 16 ++++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d91622cb559..e3097c08145 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1757,7 +1757,7 @@ dependencies = [ [[package]] name = "dash-network" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404#f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" dependencies = [ "dash-params", "grovedb-bincode", @@ -1768,7 +1768,7 @@ dependencies = [ [[package]] name = "dash-network-seeds" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404#f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" dependencies = [ "dash-network", ] @@ -1939,7 +1939,7 @@ dependencies = [ [[package]] name = "dash-spv" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404#f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" dependencies = [ "async-trait", "bip324", @@ -1996,7 +1996,7 @@ dependencies = [ [[package]] name = "dashcore" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404#f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" dependencies = [ "anyhow", "base64 0.23.1", @@ -2022,7 +2022,7 @@ dependencies = [ [[package]] name = "dashcore-crypto" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404#f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" dependencies = [ "bitcoin-crypto", "dash-network", @@ -2043,12 +2043,12 @@ dependencies = [ [[package]] name = "dashcore-private" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404#f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" [[package]] name = "dashcore-rpc" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404#f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" dependencies = [ "dashcore-rpc-json", "hex-conservative 1.3.0", @@ -2061,7 +2061,7 @@ dependencies = [ [[package]] name = "dashcore-rpc-json" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404#f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" dependencies = [ "dashcore", "grovedb-bincode", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "dashcore_hashes" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404#f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" dependencies = [ "bitcoin_hashes 1.2.0", "dash-pow", @@ -3175,7 +3175,7 @@ dependencies = [ [[package]] name = "git-state" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404#f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" [[package]] name = "glob" @@ -4386,7 +4386,7 @@ dependencies = [ [[package]] name = "key-wallet" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404#f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" dependencies = [ "async-trait", "bip39", @@ -4407,7 +4407,7 @@ dependencies = [ [[package]] name = "key-wallet-manager" version = "0.46.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4#c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404#f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" dependencies = [ "async-trait", "dashcore", diff --git a/Cargo.toml b/Cargo.toml index 8551a00ae14..6a6c9e28a9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,14 +70,14 @@ grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb grovedb-version = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb7cdc19f5977d64f20f93107f62844b1" } grovedb-epoch-based-storage-flags = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb7cdc19f5977d64f20f93107f62844b1" } grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "fa92511cb7cdc19f5977d64f20f93107f62844b1" } -dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } -dashcore-crypto = { git = "https://github.com/dashpay/rust-dashcore", rev = "c9aeac0d0dcbd4b91d780a70d61b9bb693199ca4" } +dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" } +dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" } +dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" } +key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" } +key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" } +dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" } +dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" } +dashcore-crypto = { git = "https://github.com/dashpay/rust-dashcore", rev = "f6bb90cbbcae3d401bb3c9ebc4a9a26873a41404" } tokio-metrics = "0.5" # Size-tuned profile for the iOS `rs-unified-sdk-ffi` staticlib, which From 2c0f93cd5ef0f664f6b9fcf8412631d2f5bf99cc Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Fri, 13 Nov 2026 21:21:11 +0700 Subject: [PATCH 23/26] feat(sdk): multiple choice decision proposals in rs-sdk, wasm-sdk and js-evo-sdk (#5903) Co-authored-by: Claude Fable 5.2 --- docs/protocol/decision-proposals.md | 23 +- packages/js-evo-sdk/README.md | 59 + .../src/decision-proposals/facade.ts | 7 + .../multiple-choice-facade.ts | 131 ++ packages/js-evo-sdk/src/sdk.ts | 1 + .../facades/multiple-choice-proposals.spec.ts | 169 +++ packages/rs-dpp/src/decision_proposal/mod.rs | 5 + .../src/decision_proposal/multiple_choice.rs | 275 ++++ .../multiple_choice_proposal_tests.rs | 46 +- .../rs-sdk/src/platform/decision_proposals.rs | 85 +- .../decision_proposals/multiple_choice.rs | 1264 +++++++++++++++++ .../src/platform/documents/contest_fund.rs | 17 +- .../platform/documents/contest_vote_state.rs | 206 +++ packages/rs-sdk/src/platform/documents/mod.rs | 1 + .../dpns_usernames/contested_queries.rs | 46 +- packages/wasm-sdk/src/decision_proposals.rs | 5 + .../src/decision_proposals/multiple_choice.rs | 853 +++++++++++ .../wasm-sdk/src/queries/voting/yes_no.rs | 4 +- .../unit/multiple-choice-proposals.spec.ts | 174 +++ 19 files changed, 3297 insertions(+), 74 deletions(-) create mode 100644 packages/js-evo-sdk/src/decision-proposals/multiple-choice-facade.ts create mode 100644 packages/js-evo-sdk/tests/unit/facades/multiple-choice-proposals.spec.ts create mode 100644 packages/rs-dpp/src/decision_proposal/multiple_choice.rs create mode 100644 packages/rs-sdk/src/platform/decision_proposals/multiple_choice.rs create mode 100644 packages/rs-sdk/src/platform/documents/contest_vote_state.rs create mode 100644 packages/wasm-sdk/src/decision_proposals/multiple_choice.rs create mode 100644 packages/wasm-sdk/tests/unit/multiple-choice-proposals.spec.ts diff --git a/docs/protocol/decision-proposals.md b/docs/protocol/decision-proposals.md index 7918a3e0b60..9cc64feb53a 100644 --- a/docs/protocol/decision-proposals.md +++ b/docs/protocol/decision-proposals.md @@ -406,5 +406,24 @@ A multiple choice proposal and its choices are ordinary documents and an ordinary contest: the SDKs' document create builds both (a `choice` create is given its contest fund like any contested create), and their contested resource queries and masternode vote read and answer the vote, with a choice's document -id wherever they name a contender by an identity id. They have no helpers of -their own yet. +id wherever they name a contender by an identity id. + +The Rust SDK (`dash_sdk::platform::decision_proposals::multiple_choice`) and the +JavaScript SDKs (`sdk.decisionProposals.multipleChoice` in `@dashevo/evo-sdk`, +the `*MultipleChoiceProposal*` methods of `@dashevo/wasm-sdk`) have helpers over +those: + +- build a proposal, its edit and a choice as documents to create or replace; +- give the proposal's processing fee and the fund a choice entered now pays; +- list proposals by owner and by creation time; +- read the vote by the proposal's id: every choice with its tally while it + runs, the result with every choice's final tally afterwards, and the choice + that was kept; +- build a masternode's vote from a choice's document id, abstain, or none of + the choices (a lock), and read the answer a masternode gave. + +The contest a proposal's choices run in is named from the proposal's id alone +(`dpp::decision_proposal::multiple_choice::multiple_choice_proposal_vote_poll`). +The helpers write what they are given: which descriptions, texts and choices +Platform takes is checked by the contract, on chain. The mobile SDKs have no +multiple choice helpers yet. diff --git a/packages/js-evo-sdk/README.md b/packages/js-evo-sdk/README.md index 3eb85e86b09..0660fbd9fd4 100644 --- a/packages/js-evo-sdk/README.md +++ b/packages/js-evo-sdk/README.md @@ -148,6 +148,7 @@ The SDK organises its API into domain-specific facades, each accessible as a pro | [`sdk.encryptedFor`](src/encrypted-for/facade.ts) | Encrypt and decrypt the byte properties a document type declares `encryptedFor`, for any contract | | [`sdk.moderationCharters`](src/moderation-charters/facade.ts) | Read a contract's seated charter, its team, proposals and join requests; build join and resignation requests | | [`sdk.decisionProposals`](src/decision-proposals/facade.ts) | Build, edit, list and read decision proposals; read their polls and vote on them as a masternode | +| [`sdk.decisionProposals.multipleChoice`](src/decision-proposals/multiple-choice-facade.ts) | Build, edit, list and read multiple choice proposals and their choices; read the vote among the choices and vote in it as a masternode | A `wallet` namespace is also exported with utilities for BIP39 mnemonic generation and validation, BIP44/DIP9/DIP13 key derivation (path helpers included), extended-key conversion (`xprvToXpub`, `deriveChildPublicKey`), key-pair generation and import (`generateKeyPair`, `keyPairFromWif`, `keyPairFromHex`), public-key-to-address conversion, address validation, message signing, and Dashpay contact-key derivation. See [`src/wallet/functions.ts`](src/wallet/functions.ts) for the full list. @@ -579,6 +580,64 @@ const answer = await sdk.decisionProposals.masternodeVote(proTxHash, proposal.id `sdk.voting.masternodeVote` also answers a yes/no poll as `sdk.voting.votePollsByEndDate` lists it, with `voteChoice: 'yes' | 'no' | 'abstain'`. +### Multiple choice proposals + +A question with more than two answers is a `multipleChoiceProposal` document of the same contract, and each answer is a `choice` document. The choices contend in a masternode vote that the first choice opens, and the one with the most votes is kept. `sdk.decisionProposals.multipleChoice` builds both for `sdk.documents`, and reads and answers the vote by the proposal's id. A choice is named by its document id, in a vote and in the vote's state: + +```ts +const multipleChoice = sdk.decisionProposals.multipleChoice; + +// Described by a document of an elected-moderation contract, at a url, or both. +// The owner pays the processing fee on top of the fees; the create does not state it. +const fee = await multipleChoice.processingFee(); // 0.2 Dash, in credits +const draft = await multipleChoice.build({ + ownerId: identity.id, + title: 'Which block size?', + descriptionDocument: { id: postId, contractId: forumContractId, documentType: 'post' }, + url: 'https://forum.dash.org/t/block-size', + open: true, // anyone may enter choices; false leaves them to the owner +}); +const proposal = await sdk.documents.create({ document: draft, identityKey, signer }); + +// The title, url and description document can be edited for two hours; `open` never changes +const edited = await multipleChoice.buildEdit(proposal, { title: 'Which block size, then?' }); +await sdk.documents.replace({ document: edited, identityKey, signer }); + +// A choice pays the contest fund, which the create states itself +const fund = await multipleChoice.choiceFund(proposal.id); // 0.1 Dash until the vote holds 250 choices +const choiceDraft = await multipleChoice.buildChoice({ + ownerId: identity.id, + proposalId: proposal.id, + title: 'Double it', + description: 'Twice the size it is today.', +}); +const choice = await sdk.documents.create({ document: choiceDraft, identityKey, signer }); + +// An identity's proposals; every proposal, newest first +const mine = await multipleChoice.byOwner({ ownerId: identity.id }); +const latest = await multipleChoice.byCreatedAt({ limit: 10 }); + +// The vote: every choice with its tally while it runs, its result once it ended +const vote = await multipleChoice.voteState(proposal.id); +for (const [choiceId, { choice: document, voteTally }] of vote.choices) { + console.log(choiceId, document?.properties.title, voteTally); +} +if (vote.result) console.log(vote.result.keptChoiceId?.toBase58()); +const kept = await multipleChoice.keptChoice(proposal.id); + +// A masternode answers with a choice's document id, 'abstain' or 'noneOfTheChoices' +await multipleChoice.vote({ + masternodeProTxHash: proTxHash, + proposalId: proposal.id, + voteChoice: { choiceId: choice.id }, + votingKey, + signer: votingSigner, +}); +const given = await multipleChoice.masternodeVote(proTxHash, proposal.id); +``` + +`multipleChoice.votePoll(proposal.id)` gives the vote as a vote poll for `sdk.voting` and the contested resource queries. + ## Immutable properties (`immutable`) From protocol version 14 a mutable document type can freeze some of its top-level properties with the doctype-level `immutable` list, while the rest of the document stays replaceable. An entry naming a property freezes it at creation. An entry `{ property, when }` freezes it for any replace its condition holds for: the condition takes the grammar of a `propertyConstraints` rule, is judged on the document the replace writes (whose `$updatedAt` is the replace's block time), and reads the stored document through `$old.` paths. diff --git a/packages/js-evo-sdk/src/decision-proposals/facade.ts b/packages/js-evo-sdk/src/decision-proposals/facade.ts index b614a51ce00..efbbfc06850 100644 --- a/packages/js-evo-sdk/src/decision-proposals/facade.ts +++ b/packages/js-evo-sdk/src/decision-proposals/facade.ts @@ -1,17 +1,24 @@ import * as wasm from '../wasm.js'; import type { EvoSDK } from '../sdk.js'; +import { MultipleChoiceProposalsFacade } from './multiple-choice-facade.js'; /** * Decision proposals (protocol version 15): yes/no questions any identity puts to the * masternodes. A proposal is a `proposal` document of the decision proposals system contract; * creating it opens its vote poll, and its owner pays the decision proposal fund, 0.5 Dash. * Nothing acts on a result. Every read is a proved query. + * + * A question with more than two answers is a multiple choice proposal: see `multipleChoice`. */ export class DecisionProposalsFacade { private sdk: EvoSDK; + /** Multiple choice proposals, their choices and the vote among them. */ + public multipleChoice: MultipleChoiceProposalsFacade; + constructor(sdk: EvoSDK) { this.sdk = sdk; + this.multipleChoice = new MultipleChoiceProposalsFacade(sdk); } /** diff --git a/packages/js-evo-sdk/src/decision-proposals/multiple-choice-facade.ts b/packages/js-evo-sdk/src/decision-proposals/multiple-choice-facade.ts new file mode 100644 index 00000000000..2c39fd6f02e --- /dev/null +++ b/packages/js-evo-sdk/src/decision-proposals/multiple-choice-facade.ts @@ -0,0 +1,131 @@ +import * as wasm from '../wasm.js'; +import type { EvoSDK } from '../sdk.js'; + +/** + * Multiple choice proposals (protocol version 15): questions whose answers are the choices + * entered for them. A proposal is a `multipleChoiceProposal` document and an answer a `choice` + * document of the decision proposals system contract. The choices contend in a masternode + * vote that the first choice opens, and the one with the most votes is kept. A choice is named + * by its document id, in a vote and in the vote's state. Every read is a proved query. + */ +export class MultipleChoiceProposalsFacade { + private sdk: EvoSDK; + + constructor(sdk: EvoSDK) { + this.sdk = sdk; + } + + /** + * Builds a proposal to create with `sdk.documents.create`, which returns the stored proposal + * with its final id. Its owner pays the processing fee `processingFee()` gives on top of the + * fees. + */ + async build(options: wasm.MultipleChoiceProposalOptions): Promise { + const w = await this.sdk.getWasmSdkConnected(); + return w.buildMultipleChoiceProposal(options); + } + + /** + * A proposal with a new title, url or description document and its next revision, to replace + * with `sdk.documents.replace`. Platform accepts the edit for two hours after the proposal + * is created. + */ + async buildEdit( + proposal: wasm.Document, + edit: wasm.MultipleChoiceProposalEdit, + ): Promise { + const w = await this.sdk.getWasmSdkConnected(); + return w.buildMultipleChoiceProposalEdit(proposal, edit); + } + + /** + * Builds a choice to create with `sdk.documents.create`, which states the contest fund and + * returns the stored choice with its final id, the id a vote towards it carries. + */ + async buildChoice(options: wasm.MultipleChoiceProposalChoiceOptions): Promise { + const w = await this.sdk.getWasmSdkConnected(); + return w.buildMultipleChoiceProposalChoice(options); + } + + /** What creating one proposal adds to the processing fee of its batch, in credits. */ + async processingFee(): Promise { + const w = await this.sdk.getWasmSdkConnected(); + return w.getMultipleChoiceProposalProcessingFee(); + } + + /** The fund a choice entered now for a proposal pays, in credits. */ + async choiceFund(proposalId: wasm.IdentifierLike): Promise { + const w = await this.sdk.getWasmSdkConnected(); + return w.getMultipleChoiceProposalChoiceFund(proposalId); + } + + /** A proposal by id, or undefined when there is none. */ + async get(proposalId: wasm.IdentifierLike): Promise { + const w = await this.sdk.getWasmSdkConnected(); + return w.getMultipleChoiceProposal(proposalId); + } + + /** One page of an identity's proposals, by creation time. */ + async byOwner( + query: wasm.DecisionProposalsByOwnerQuery, + ): Promise> { + const w = await this.sdk.getWasmSdkConnected(); + return w.getMultipleChoiceProposalsByOwner(query); + } + + /** One page of every proposal, newest first. */ + async byCreatedAt( + query?: wasm.DecisionProposalsPageQuery, + ): Promise> { + const w = await this.sdk.getWasmSdkConnected(); + return w.getMultipleChoiceProposalsByCreatedAt(query); + } + + /** + * The vote among a proposal's choices as a vote poll, for `sdk.voting` and the contested + * resource queries. + */ + async votePoll(proposalId: wasm.IdentifierLike): Promise { + const w = await this.sdk.getWasmSdkConnected(); + return w.getMultipleChoiceProposalVotePoll(proposalId); + } + + /** + * The vote among a proposal's choices: every choice with its tally while the vote runs, and + * its result with every choice's final tally once it ended. + */ + async voteState(proposalId: wasm.IdentifierLike): Promise { + const w = await this.sdk.getWasmSdkConnected(); + return w.getMultipleChoiceProposalVote(proposalId); + } + + /** + * The choice the finished vote of a proposal kept, or undefined while the vote runs and when + * it kept none. + */ + async keptChoice(proposalId: wasm.IdentifierLike): Promise { + const w = await this.sdk.getWasmSdkConnected(); + return w.getMultipleChoiceProposalKeptChoice(proposalId); + } + + /** + * The answer a masternode gave in the vote among a proposal's choices, or undefined when it + * has not voted in it or the vote ended. + */ + async masternodeVote( + proTxHash: wasm.IdentifierLike, + proposalId: wasm.IdentifierLike, + ): Promise { + const w = await this.sdk.getWasmSdkConnected(); + return w.getMasternodeMultipleChoiceProposalVote(proTxHash, proposalId); + } + + /** + * Votes in the vote among a proposal's choices for a masternode, and returns the vote as + * Platform recorded it. + */ + async vote(options: wasm.MultipleChoiceProposalVoteOptions): Promise { + const w = await this.sdk.getWasmSdkConnected(); + return w.multipleChoiceProposalVote(options); + } +} diff --git a/packages/js-evo-sdk/src/sdk.ts b/packages/js-evo-sdk/src/sdk.ts index e59e2843d58..b23507852d7 100644 --- a/packages/js-evo-sdk/src/sdk.ts +++ b/packages/js-evo-sdk/src/sdk.ts @@ -460,6 +460,7 @@ export { ShieldedFacade } from './shielded/facade.js'; export { EncryptedForFacade } from './encrypted-for/facade.js'; export { ModerationChartersFacade } from './moderation-charters/facade.js'; export { DecisionProposalsFacade } from './decision-proposals/facade.js'; +export { MultipleChoiceProposalsFacade } from './decision-proposals/multiple-choice-facade.js'; export { PrivateDocumentsFacade } from './private-documents/facade.js'; export { wallet } from './wallet/functions.js'; export * from './wasm.js'; diff --git a/packages/js-evo-sdk/tests/unit/facades/multiple-choice-proposals.spec.ts b/packages/js-evo-sdk/tests/unit/facades/multiple-choice-proposals.spec.ts new file mode 100644 index 00000000000..70d95e4655e --- /dev/null +++ b/packages/js-evo-sdk/tests/unit/facades/multiple-choice-proposals.spec.ts @@ -0,0 +1,169 @@ +import type { SinonStub } from 'sinon'; +import init, * as wasmSDKPackage from '@dashevo/wasm-sdk'; +import { EvoSDK } from '../../../dist/sdk.js'; + +describe('MultipleChoiceProposalsFacade', () => { + let wasmSdk: wasmSDKPackage.WasmSdk; + let client: EvoSDK; + + let buildMultipleChoiceProposalStub: SinonStub; + let buildMultipleChoiceProposalEditStub: SinonStub; + let buildMultipleChoiceProposalChoiceStub: SinonStub; + let getMultipleChoiceProposalProcessingFeeStub: SinonStub; + let getMultipleChoiceProposalChoiceFundStub: SinonStub; + let getMultipleChoiceProposalStub: SinonStub; + let getMultipleChoiceProposalsByOwnerStub: SinonStub; + let getMultipleChoiceProposalsByCreatedAtStub: SinonStub; + let getMultipleChoiceProposalVotePollStub: SinonStub; + let getMultipleChoiceProposalVoteStub: SinonStub; + let getMultipleChoiceProposalKeptChoiceStub: SinonStub; + let getMasternodeMultipleChoiceProposalVoteStub: SinonStub; + let multipleChoiceProposalVoteStub: SinonStub; + + const ownerId = '5mjGWa9mruHnLBht3ntBi8CZ6sNk3hZZsQMgTvgQobjS'; + const proposalId = '4EfA9Jrvv3nnCFdSf7fad59851iiTRZ6Wcu6YVJ4iSeF'; + const choiceId = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec'; + const proTxHash = 'a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2'; + + beforeEach(async function setup() { + await init(); + const builder = wasmSDKPackage.WasmSdkBuilder.testnet(); + wasmSdk = await builder.build(); + client = EvoSDK.fromWasm(wasmSdk); + + buildMultipleChoiceProposalStub = this.sinon.stub(wasmSdk, 'buildMultipleChoiceProposal').resolves({}); + buildMultipleChoiceProposalEditStub = this.sinon.stub(wasmSdk, 'buildMultipleChoiceProposalEdit').returns({}); + buildMultipleChoiceProposalChoiceStub = this.sinon.stub(wasmSdk, 'buildMultipleChoiceProposalChoice').resolves({}); + getMultipleChoiceProposalProcessingFeeStub = this.sinon.stub(wasmSdk, 'getMultipleChoiceProposalProcessingFee').resolves(20_000_000_000n); + getMultipleChoiceProposalChoiceFundStub = this.sinon.stub(wasmSdk, 'getMultipleChoiceProposalChoiceFund').resolves(10_000_000_000n); + getMultipleChoiceProposalStub = this.sinon.stub(wasmSdk, 'getMultipleChoiceProposal').resolves(undefined); + getMultipleChoiceProposalsByOwnerStub = this.sinon.stub(wasmSdk, 'getMultipleChoiceProposalsByOwner').resolves(new Map()); + getMultipleChoiceProposalsByCreatedAtStub = this.sinon.stub(wasmSdk, 'getMultipleChoiceProposalsByCreatedAt').resolves(new Map()); + getMultipleChoiceProposalVotePollStub = this.sinon.stub(wasmSdk, 'getMultipleChoiceProposalVotePoll').returns({}); + getMultipleChoiceProposalVoteStub = this.sinon.stub(wasmSdk, 'getMultipleChoiceProposalVote').resolves({ choices: new Map() }); + getMultipleChoiceProposalKeptChoiceStub = this.sinon.stub(wasmSdk, 'getMultipleChoiceProposalKeptChoice').resolves(undefined); + getMasternodeMultipleChoiceProposalVoteStub = this.sinon.stub(wasmSdk, 'getMasternodeMultipleChoiceProposalVote').resolves(undefined); + multipleChoiceProposalVoteStub = this.sinon.stub(wasmSdk, 'multipleChoiceProposalVote').resolves({}); + }); + + describe('build()', () => { + it('should forward the options to buildMultipleChoiceProposal', async () => { + const options = { + ownerId, + title: 'Which block size?', + descriptionDocument: { id: choiceId, contractId: ownerId, documentType: 'post' }, + url: 'https://forum.dash.org/t/block-size', + open: true, + }; + await client.decisionProposals.multipleChoice.build(options); + expect(buildMultipleChoiceProposalStub).to.be.calledOnceWithExactly(options); + }); + }); + + describe('buildEdit()', () => { + it('should forward the proposal and the edit to buildMultipleChoiceProposalEdit', async () => { + const proposal = {} as wasmSDKPackage.Document; + const edit = { title: 'Which block size, then?', descriptionDocument: null }; + await client.decisionProposals.multipleChoice.buildEdit(proposal, edit); + expect(buildMultipleChoiceProposalEditStub).to.be.calledOnceWithExactly(proposal, edit); + }); + }); + + describe('buildChoice()', () => { + it('should forward the options to buildMultipleChoiceProposalChoice', async () => { + const options = { ownerId, proposalId, title: 'Double it' }; + await client.decisionProposals.multipleChoice.buildChoice(options); + expect(buildMultipleChoiceProposalChoiceStub).to.be.calledOnceWithExactly(options); + }); + }); + + describe('processingFee()', () => { + it('should return the fee getMultipleChoiceProposalProcessingFee gives', async () => { + const fee = await client.decisionProposals.multipleChoice.processingFee(); + expect(getMultipleChoiceProposalProcessingFeeStub).to.be.calledOnceWithExactly(); + expect(fee).to.equal(20_000_000_000n); + }); + }); + + describe('choiceFund()', () => { + it('should forward the proposal id to getMultipleChoiceProposalChoiceFund', async () => { + const fund = await client.decisionProposals.multipleChoice.choiceFund(proposalId); + expect(getMultipleChoiceProposalChoiceFundStub).to.be.calledOnceWithExactly(proposalId); + expect(fund).to.equal(10_000_000_000n); + }); + }); + + describe('get()', () => { + it('should forward the proposal id to getMultipleChoiceProposal', async () => { + const result = await client.decisionProposals.multipleChoice.get(proposalId); + expect(getMultipleChoiceProposalStub).to.be.calledOnceWithExactly(proposalId); + expect(result).to.equal(undefined); + }); + }); + + describe('byOwner()', () => { + it('should forward the query to getMultipleChoiceProposalsByOwner', async () => { + const query = { ownerId, startAfter: proposalId }; + const result = await client.decisionProposals.multipleChoice.byOwner(query); + expect(getMultipleChoiceProposalsByOwnerStub).to.be.calledOnceWithExactly(query); + expect(result).to.be.instanceOf(Map); + }); + }); + + describe('byCreatedAt()', () => { + it('should forward the query to getMultipleChoiceProposalsByCreatedAt', async () => { + const query = { limit: 5 }; + await client.decisionProposals.multipleChoice.byCreatedAt(query); + expect(getMultipleChoiceProposalsByCreatedAtStub).to.be.calledOnceWithExactly(query); + }); + + it('should list from the start without a query', async () => { + await client.decisionProposals.multipleChoice.byCreatedAt(); + expect(getMultipleChoiceProposalsByCreatedAtStub).to.be.calledOnceWithExactly(undefined); + }); + }); + + describe('votePoll()', () => { + it('should forward the proposal id to getMultipleChoiceProposalVotePoll', async () => { + await client.decisionProposals.multipleChoice.votePoll(proposalId); + expect(getMultipleChoiceProposalVotePollStub).to.be.calledOnceWithExactly(proposalId); + }); + }); + + describe('voteState()', () => { + it('should forward the proposal id to getMultipleChoiceProposalVote', async () => { + const vote = await client.decisionProposals.multipleChoice.voteState(proposalId); + expect(getMultipleChoiceProposalVoteStub).to.be.calledOnceWithExactly(proposalId); + expect(vote.choices).to.be.instanceOf(Map); + }); + }); + + describe('keptChoice()', () => { + it('should forward the proposal id to getMultipleChoiceProposalKeptChoice', async () => { + await client.decisionProposals.multipleChoice.keptChoice(proposalId); + expect(getMultipleChoiceProposalKeptChoiceStub).to.be.calledOnceWithExactly(proposalId); + }); + }); + + describe('masternodeVote()', () => { + it('should forward the masternode and the proposal to getMasternodeMultipleChoiceProposalVote', async () => { + await client.decisionProposals.multipleChoice.masternodeVote(proTxHash, proposalId); + expect(getMasternodeMultipleChoiceProposalVoteStub) + .to.be.calledOnceWithExactly(proTxHash, proposalId); + }); + }); + + describe('vote()', () => { + it('should forward the options to multipleChoiceProposalVote', async () => { + const options = { + masternodeProTxHash: proTxHash, + proposalId, + voteChoice: { choiceId }, + votingKey: {} as wasmSDKPackage.IdentityPublicKey, + signer: {} as wasmSDKPackage.IdentitySigner, + }; + await client.decisionProposals.multipleChoice.vote(options); + expect(multipleChoiceProposalVoteStub).to.be.calledOnceWithExactly(options); + }); + }); +}); diff --git a/packages/rs-dpp/src/decision_proposal/mod.rs b/packages/rs-dpp/src/decision_proposal/mod.rs index ae87e9a5f47..1e0abe405a4 100644 --- a/packages/rs-dpp/src/decision_proposal/mod.rs +++ b/packages/rs-dpp/src/decision_proposal/mod.rs @@ -9,6 +9,11 @@ //! //! [`DecisionProposalVotePoll::from_proposal`] reads the poll a proposal opens from its id and //! properties. Consensus uses it to open the poll, and clients to name the poll they query. +//! +//! A multiple choice proposal opens no yes/no poll: its choices contend in a masternode vote +//! among documents, which [`multiple_choice`] names for clients. + +pub mod multiple_choice; use crate::balances::credits::Credits; use crate::consensus::basic::decision_proposal::InvalidDecisionProposalRuleError; diff --git a/packages/rs-dpp/src/decision_proposal/multiple_choice.rs b/packages/rs-dpp/src/decision_proposal/multiple_choice.rs new file mode 100644 index 00000000000..0c30fb6e89c --- /dev/null +++ b/packages/rs-dpp/src/decision_proposal/multiple_choice.rs @@ -0,0 +1,275 @@ +//! Multiple choice proposals (protocol version 15): what clients name them and their vote by. +//! +//! A multiple choice proposal is a `multipleChoiceProposal` document of the decision proposals +//! contract; its answers are `choice` documents, which contend in a masternode vote among +//! documents (`ContestedIndexResolution::MasternodeVoteOnDocuments`). The vote is keyed by the +//! proposal's id ([`multiple_choice_proposal_vote_poll`]), and a choice is named in it by its +//! own document id, wherever a contest among identities names a contender by an identity id +//! ([`MultipleChoiceVoteChoice`]). + +use crate::decision_proposal::DECISION_PROPOSALS_CONTRACT_ID; +use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use crate::voting::vote_polls::VotePoll; +use crate::voting::votes::resource_vote::v0::ResourceVoteV0; +use crate::voting::votes::resource_vote::ResourceVote; +use crate::voting::votes::Vote; +use platform_value::{Identifier, Value}; + +/// The name of the choice document type: an answer to a multiple choice proposal. +pub const CHOICE_DOCUMENT_TYPE_NAME: &str = "choice"; + +/// The contested index every choice falls under, on the proposal it answers. A choice's create +/// states its contest fund under this name. +pub const CHOICE_CONTEST_INDEX_NAME: &str = "byProposal"; + +/// The properties of a multiple choice proposal. +pub mod proposal_properties { + /// The question, in one line. Editable for two hours after the proposal is created. + pub const TITLE: &str = "title"; + /// The document saying what is being decided; optional, given with the two properties + /// naming where it lives and only with them. Editable for two hours. + pub const DESCRIPTION_ID: &str = "descriptionId"; + /// The contract the description document lives in. + pub const DESCRIPTION_CONTRACT_ID: &str = "descriptionContractId"; + /// The document type of the description document. + pub const DESCRIPTION_DOCUMENT_TYPE: &str = "descriptionDocumentType"; + /// Where what is being decided is described or discussed; optional, required of a proposal + /// that points at no description document. Editable for two hours. + pub const URL: &str = "url"; + /// Whether anyone may enter choices; only the proposal's owner may when it is false. + /// Never changes. + pub const OPEN: &str = "open"; +} + +/// The properties of a choice. +pub mod choice_properties { + /// The multiple choice proposal the choice answers. + pub const PROPOSAL_ID: &str = "proposalId"; + /// The answer, in one line. + pub const TITLE: &str = "title"; + /// What voting for the answer means; optional. + pub const DESCRIPTION: &str = "description"; +} + +/// Whether a document of `document_type_name` in the contract `contract_id` is a choice: a +/// `choice` of the decision proposals contract. Its create joins the vote among the choices of +/// the proposal it answers, or opens it. +pub fn is_choice(contract_id: &Identifier, document_type_name: &str) -> bool { + *contract_id == DECISION_PROPOSALS_CONTRACT_ID + && document_type_name == CHOICE_DOCUMENT_TYPE_NAME +} + +/// The vote among the choices of the multiple choice proposal `proposal_id`: the contest of +/// the `choice` type's `byProposal` index at that proposal, as a choice's create derives it +/// from its `proposalId`. The contested resource queries take it, and a masternode's vote +/// names it. Known from the proposal's id alone, whether or not a choice has opened the vote. +pub fn multiple_choice_proposal_vote_poll( + proposal_id: Identifier, +) -> ContestedDocumentResourceVotePoll { + ContestedDocumentResourceVotePoll { + contract_id: DECISION_PROPOSALS_CONTRACT_ID, + document_type_name: CHOICE_DOCUMENT_TYPE_NAME.to_string(), + index_name: CHOICE_CONTEST_INDEX_NAME.to_string(), + index_values: vec![Value::Identifier(proposal_id.to_buffer())], + } +} + +/// A masternode's answer in the vote among a multiple choice proposal's choices. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MultipleChoiceVoteChoice { + /// For the choice with this document id. The id of the identity that entered the choice + /// names no contender here, and a vote carrying it is refused. + Choice(Identifier), + /// For no choice and against none. + Abstain, + /// None of the choices: when these votes outnumber the leading choice, no choice is kept + /// and none can be entered for the proposal again. + NoneOfTheChoices, +} + +impl From for ResourceVoteChoice { + /// The resource vote choice the contest takes: a choice's document id travels where a + /// contest among identities carries an identity id, and none of the choices is a lock. + fn from(vote_choice: MultipleChoiceVoteChoice) -> Self { + match vote_choice { + MultipleChoiceVoteChoice::Choice(choice_id) => { + ResourceVoteChoice::TowardsIdentity(choice_id) + } + MultipleChoiceVoteChoice::Abstain => ResourceVoteChoice::Abstain, + MultipleChoiceVoteChoice::NoneOfTheChoices => ResourceVoteChoice::Lock, + } + } +} + +/// A masternode's vote `vote_choice` in the vote among the choices of the multiple choice +/// proposal `proposal_id`, to sign as a masternode vote transition. +pub fn multiple_choice_proposal_vote( + proposal_id: Identifier, + vote_choice: MultipleChoiceVoteChoice, +) -> Vote { + Vote::ResourceVote(ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll(multiple_choice_proposal_vote_poll( + proposal_id, + )), + resource_vote_choice: vote_choice.into(), + })) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::decision_proposal::{ + is_multiple_choice_proposal, MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + }; + + #[test] + fn should_recognize_only_the_choice_of_the_decision_proposals_contract() { + assert!(is_choice( + &DECISION_PROPOSALS_CONTRACT_ID, + CHOICE_DOCUMENT_TYPE_NAME + )); + assert!(!is_choice( + &DECISION_PROPOSALS_CONTRACT_ID, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME + )); + assert!(!is_choice( + &Identifier::new([1; 32]), + CHOICE_DOCUMENT_TYPE_NAME + )); + assert!(!is_multiple_choice_proposal( + &DECISION_PROPOSALS_CONTRACT_ID, + CHOICE_DOCUMENT_TYPE_NAME + )); + } + + #[test] + fn should_vote_towards_a_choice_by_its_document_id() { + let proposal_id = Identifier::new([7; 32]); + let choice_id = Identifier::new([9; 32]); + let answers = [ + ( + MultipleChoiceVoteChoice::Choice(choice_id), + ResourceVoteChoice::TowardsIdentity(choice_id), + ), + ( + MultipleChoiceVoteChoice::Abstain, + ResourceVoteChoice::Abstain, + ), + ( + MultipleChoiceVoteChoice::NoneOfTheChoices, + ResourceVoteChoice::Lock, + ), + ]; + for (vote_choice, resource_vote_choice) in answers { + assert_eq!( + multiple_choice_proposal_vote(proposal_id, vote_choice), + Vote::ResourceVote(ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + multiple_choice_proposal_vote_poll(proposal_id) + ), + resource_vote_choice, + })), + "{vote_choice:?}" + ); + } + } + + #[cfg(feature = "decision-proposals-contract")] + #[test] + fn should_name_the_types_and_properties_as_the_contract_crate_does() { + use data_contracts::decision_proposals_contract::v1::document_types::{ + choice, multiple_choice_proposal, + }; + + assert_eq!( + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + multiple_choice_proposal::NAME + ); + assert_eq!( + proposal_properties::TITLE, + multiple_choice_proposal::properties::TITLE + ); + assert_eq!( + proposal_properties::DESCRIPTION_ID, + multiple_choice_proposal::properties::DESCRIPTION_ID + ); + assert_eq!( + proposal_properties::DESCRIPTION_CONTRACT_ID, + multiple_choice_proposal::properties::DESCRIPTION_CONTRACT_ID + ); + assert_eq!( + proposal_properties::DESCRIPTION_DOCUMENT_TYPE, + multiple_choice_proposal::properties::DESCRIPTION_DOCUMENT_TYPE + ); + assert_eq!( + proposal_properties::URL, + multiple_choice_proposal::properties::URL + ); + assert_eq!( + proposal_properties::OPEN, + multiple_choice_proposal::properties::OPEN + ); + assert_eq!(CHOICE_DOCUMENT_TYPE_NAME, choice::NAME); + assert_eq!(CHOICE_CONTEST_INDEX_NAME, choice::indexes::BY_PROPOSAL); + assert_eq!( + choice_properties::PROPOSAL_ID, + choice::properties::PROPOSAL_ID + ); + assert_eq!(choice_properties::TITLE, choice::properties::TITLE); + assert_eq!( + choice_properties::DESCRIPTION, + choice::properties::DESCRIPTION + ); + } + + /// The poll named from the proposal's id alone is the one a choice's create derives from + /// its `proposalId`, in whichever form the create writes the id. + #[cfg(feature = "decision-proposals-contract")] + #[test] + fn should_name_the_vote_a_choice_joins_by_the_proposal_id_alone() { + use crate::data_contract::accessors::v0::DataContractV0Getters; + use crate::data_contract::document_type::methods::DocumentTypeV0Methods; + use crate::document::{Document, DocumentV0}; + use crate::system_data_contracts::{load_system_data_contract, SystemDataContract}; + use platform_version::version::PlatformVersion; + use std::collections::BTreeMap; + + let platform_version = PlatformVersion::latest(); + let contract = + load_system_data_contract(SystemDataContract::DecisionProposals, platform_version) + .expect("the contract loads at the latest version"); + let document_type = contract + .document_type_for_name(CHOICE_DOCUMENT_TYPE_NAME) + .expect("the choice type"); + let proposal_id = Identifier::new([7; 32]); + let forms = [ + Value::Identifier(proposal_id.to_buffer()), + Value::Bytes32(proposal_id.to_buffer()), + Value::Bytes(proposal_id.to_vec()), + ]; + for proposal_id_value in forms { + let choice: Document = DocumentV0 { + properties: BTreeMap::from([ + ( + choice_properties::PROPOSAL_ID.to_string(), + proposal_id_value.clone(), + ), + ( + choice_properties::TITLE.to_string(), + Value::Text("Double it".to_string()), + ), + ]), + ..Default::default() + } + .into(); + assert_eq!( + document_type + .contested_vote_poll_for_document(&choice, platform_version) + .expect("active"), + Some(multiple_choice_proposal_vote_poll(proposal_id)), + "{proposal_id_value:?}" + ); + } + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/multiple_choice_proposal_tests.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/multiple_choice_proposal_tests.rs index f80fd37439d..b6e03193d59 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/multiple_choice_proposal_tests.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/multiple_choice_proposal_tests.rs @@ -811,6 +811,38 @@ fn stored_choice( stored_document(platform, contract, choice::NAME, choice_id) } +/// The ids of the choices of the proposal `proposal_id` a document query finds through the +/// `byProposal` index, as a client reads the choice a vote kept: the choices a vote still +/// holds are in the vote's own storage, not there. +fn choices_found_by_proposal( + platform: &TempPlatform, + contract: &DataContract, + proposal_id: Identifier, + platform_version: &PlatformVersion, +) -> Vec { + let document_type = contract + .document_type_for_name(choice::NAME) + .expect("expected the choice type"); + let query = DriveDocumentQuery::from_value( + platform_value!({ + "where": [[choice::properties::PROPOSAL_ID, "==", proposal_id]], + }), + contract, + document_type, + &platform.config.drive, + platform_version, + ) + .expect("expected a document query"); + platform + .drive + .query_documents(query, None, false, None, None) + .expect("expected to query the choices") + .documents() + .iter() + .map(|document| document.id()) + .collect() +} + /// A serialized edit of the multiple choice proposal `question` by `proposer` (its owner) /// setting `changes`, its revision bumped. async fn edit_transition( @@ -1007,8 +1039,12 @@ async fn should_keep_the_choice_the_masternodes_vote_for_most() { prefunded_balance(&platform, &poll, platform_version), 4 * fund ); - // A choice is held by the vote, not stored, until the vote ends + // A choice is held by the vote, not stored, until the vote ends: a document query of the + // proposal's choices finds none of the four assert!(stored_choice(&platform, &contract, bob_choice).is_none()); + assert!( + choices_found_by_proposal(&platform, &contract, proposal_id, platform_version).is_empty() + ); // A vote names a choice by its document id. Two masternodes for Bob's choice, one each for // Alice's and Carol's, one for none of them @@ -1044,6 +1080,11 @@ async fn should_keep_the_choice_the_masternodes_vote_for_most() { for other in [alice_choice, carol_choice, proposer_choice] { assert!(stored_choice(&platform, &contract, other).is_none()); } + // Which leaves the kept choice the only one a document query of the proposal's finds + assert_eq!( + choices_found_by_proposal(&platform, &contract, proposal_id, platform_version), + vec![bob_choice] + ); } #[tokio::test] @@ -1112,6 +1153,9 @@ async fn should_keep_no_choice_when_the_lock_votes_outnumber_every_choice() { for entered in [alice_choice, bob_choice] { assert!(stored_choice(&platform, &contract, entered).is_none()); } + assert!( + choices_found_by_proposal(&platform, &contract, proposal_id, platform_version).is_empty() + ); // The masternodes' answer stands: no choice can be entered for the proposal again let (again, _) = choice_transition( diff --git a/packages/rs-sdk/src/platform/decision_proposals.rs b/packages/rs-sdk/src/platform/decision_proposals.rs index f029b639a1a..62cc96a64ea 100644 --- a/packages/rs-sdk/src/platform/decision_proposals.rs +++ b/packages/rs-sdk/src/platform/decision_proposals.rs @@ -24,6 +24,11 @@ //! for the poll's status and tallies, and to //! [`MasternodeYesNoVoteQuery::new`](crate::platform::yes_no_vote_polls::MasternodeYesNoVoteQuery::new) //! for a masternode's answer. +//! +//! A question with more than two answers is a multiple choice proposal, whose answers are +//! choices that contend in a masternode vote: see [`multiple_choice`]. + +pub mod multiple_choice; use crate::platform::documents::document_query::DocumentQuery; use crate::platform::documents::page::DocumentsPage; @@ -83,14 +88,14 @@ pub struct DecisionProposalEdit { pub url: Option>, } -/// A proposal ready to be put with +/// A proposal, or a choice of a multiple choice proposal, ready to be put with /// [`PutDocument`](crate::platform::transition::put_document::PutDocument): the document and /// the entropy its id derives from, which the put must reuse. #[derive(Debug, Clone)] pub struct DecisionProposalDocument { /// The document. Its id is a placeholder until it is put: from protocol version 14 the id - /// also commits to the identity contract nonce of the create transition. The poll is named - /// by the id of the document the put returns. + /// also commits to the identity contract nonce of the create transition. A proposal's poll, + /// and a choice in its vote, are named by the id of the document the put returns. pub document: Document, /// The entropy the document id derives from. pub entropy: Bytes32, @@ -181,9 +186,6 @@ pub fn build_decision_proposal_document( input: &DecisionProposalInput, entropy: Bytes32, ) -> Result { - let document_type = contract - .document_type_for_name(PROPOSAL_DOCUMENT_TYPE_NAME) - .map_err(|e| Error::Protocol(e.into()))?; let mut properties = BTreeMap::from([ ( properties::TITLE.to_string(), @@ -206,11 +208,32 @@ pub fn build_decision_proposal_document( if let Some(url) = &input.url { properties.insert(properties::URL.to_string(), Value::Text(url.clone())); } + new_document( + contract, + PROPOSAL_DOCUMENT_TYPE_NAME, + owner_id, + properties, + entropy, + ) +} + +/// A new `document_type_name` document of `owner_id` in `contract` holding `properties`, with +/// its id derived from `entropy` and its first revision when the type keeps one. +fn new_document( + contract: &DataContract, + document_type_name: &str, + owner_id: Identifier, + properties: BTreeMap, + entropy: Bytes32, +) -> Result { + let document_type = contract + .document_type_for_name(document_type_name) + .map_err(|e| Error::Protocol(e.into()))?; let document = DocumentV0 { id: Document::generate_document_id_v0( &contract.id(), &owner_id, - PROPOSAL_DOCUMENT_TYPE_NAME, + document_type_name, entropy.as_slice(), ), owner_id, @@ -303,13 +326,15 @@ fn proposals_by_end_date_query( ) } -/// The query for the proposals of `owner_id`, by creation time (`byOwner`), one page of them. +/// The query for the `document_type_name` documents of `owner_id`, by creation time (`byOwner`), +/// one page of them. fn proposals_by_owner_query( contract: Arc, + document_type_name: &str, owner_id: Identifier, page: DocumentsPage, ) -> Result { - let query = DocumentQuery::new(contract, PROPOSAL_DOCUMENT_TYPE_NAME)? + let query = DocumentQuery::new(contract, document_type_name)? .with_where(WhereClause { field: "$ownerId".to_string(), operator: WhereOperator::Equal, @@ -324,16 +349,17 @@ fn proposals_by_owner_query( paged(query, page) } -/// The query for every proposal, newest first (`byCreatedAt`), one page of them. +/// The query for every `document_type_name` document, newest first (`byCreatedAt`), one page +/// of them. fn proposals_by_created_at_query( contract: Arc, + document_type_name: &str, page: DocumentsPage, ) -> Result { - let query = - DocumentQuery::new(contract, PROPOSAL_DOCUMENT_TYPE_NAME)?.with_order_by(OrderClause { - field: "$createdAt".to_string(), - ascending: false, - }); + let query = DocumentQuery::new(contract, document_type_name)?.with_order_by(OrderClause { + field: "$createdAt".to_string(), + ascending: false, + }); paged(query, page) } @@ -415,7 +441,11 @@ impl Sdk { page: DocumentsPage, ) -> Result { let contract = self.fetch_decision_proposals_contract().await?; - Document::fetch_many(self, proposals_by_owner_query(contract, owner_id, page)?).await + Document::fetch_many( + self, + proposals_by_owner_query(contract, PROPOSAL_DOCUMENT_TYPE_NAME, owner_id, page)?, + ) + .await } /// One page of every proposal, newest first. [`DocumentsPage::after`] gives the next page. @@ -424,7 +454,11 @@ impl Sdk { page: DocumentsPage, ) -> Result { let contract = self.fetch_decision_proposals_contract().await?; - Document::fetch_many(self, proposals_by_created_at_query(contract, page)?).await + Document::fetch_many( + self, + proposals_by_created_at_query(contract, PROPOSAL_DOCUMENT_TYPE_NAME, page)?, + ) + .await } /// A masternode's answer `vote_choice` on the proposal `proposal_id`, to put with @@ -804,13 +838,22 @@ mod tests { } assert_eq!( served_through( - &proposals_by_owner_query(contract.clone(), Identifier::from([3; 32]), page) - .expect("builds") + &proposals_by_owner_query( + contract.clone(), + PROPOSAL_DOCUMENT_TYPE_NAME, + Identifier::from([3; 32]), + page + ) + .expect("builds") ), "byOwner" ); - let by_created_at = - proposals_by_created_at_query(contract, DocumentsPage::default()).expect("builds"); + let by_created_at = proposals_by_created_at_query( + contract, + PROPOSAL_DOCUMENT_TYPE_NAME, + DocumentsPage::default(), + ) + .expect("builds"); assert_eq!(served_through(&by_created_at), "byCreatedAt"); assert_eq!(by_created_at.limit, 100); assert_eq!(by_created_at.start, None); diff --git a/packages/rs-sdk/src/platform/decision_proposals/multiple_choice.rs b/packages/rs-sdk/src/platform/decision_proposals/multiple_choice.rs new file mode 100644 index 00000000000..bda7ad7bc60 --- /dev/null +++ b/packages/rs-sdk/src/platform/decision_proposals/multiple_choice.rs @@ -0,0 +1,1264 @@ +//! Multiple choice proposals (protocol version 15): questions whose answers are the choices +//! entered for them. A proposal is a `multipleChoiceProposal` document of the decision +//! proposals system contract and an answer is a `choice` document; the choices contend in a +//! masternode vote that the first choice opens, and the one with the most votes is kept. +//! +//! * [`Sdk::build_multiple_choice_proposal`] builds a proposal, put like any document create +//! with [`PutDocument`](crate::platform::transition::put_document::PutDocument). Its owner +//! pays the multiple choice proposal processing fee +//! ([`Sdk::multiple_choice_proposal_processing_fee`]) on top of the fees; the create does +//! not state it. +//! * [`build_multiple_choice_proposal_edit`] gives a proposal a new title, url or description +//! document, put as a replace, for two hours after the proposal is created. +//! * [`Sdk::build_choice`] builds an answer to a proposal, put like any document create. The +//! put states the contest fund ([`Sdk::choice_fund_to_join`]), which its owner pays. Anyone +//! enters choices for an open proposal, and only its owner for one that is not. +//! * [`Sdk::fetch_multiple_choice_proposal`] reads a proposal by id, and two listings read +//! them a page at a time: [`Sdk::fetch_multiple_choice_proposals_by_owner`] in filing order +//! and [`Sdk::fetch_multiple_choice_proposals_by_created_at`] newest first. +//! [`MultipleChoiceProposal::from_document`] reads a proposal's properties. +//! * [`Sdk::fetch_multiple_choice_proposal_vote`] reads the vote: the choices with their +//! tallies while it runs, and its outcome with every choice's tally afterwards. +//! [`Sdk::fetch_kept_choice`] reads the choice a finished vote kept. +//! * [`multiple_choice_proposal_vote`] builds a masternode's answer, put with +//! [`PutVote`](crate::platform::transition::vote::PutVote), and +//! [`Sdk::fetch_masternode_multiple_choice_vote`] reads the answer a masternode gave. +//! +//! A choice is named by its document id wherever a contest among identities names a contender +//! by an identity id: in a vote ([`MultipleChoiceVoteChoice::Choice`]), in the vote's state and +//! in its winner. The vote itself is the contest [`multiple_choice_proposal_vote_poll`] names +//! from the proposal's id, which the contested resource queries take as it is. + +use super::{ + new_document, proposals_by_created_at_query, proposals_by_owner_query, DecisionProposalDocument, +}; +use crate::platform::documents::document_query::DocumentQuery; +use crate::platform::documents::page::DocumentsPage; +use crate::platform::query::VoteQuery; +use crate::platform::{DataContract, Document, Fetch, FetchMany, Identifier}; +use crate::{Error, Sdk}; +use dpp::block::block_info::BlockInfo; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::decision_proposal::multiple_choice::{ + choice_properties, proposal_properties, CHOICE_DOCUMENT_TYPE_NAME, +}; +pub use dpp::decision_proposal::multiple_choice::{ + multiple_choice_proposal_vote, multiple_choice_proposal_vote_poll, MultipleChoiceVoteChoice, +}; +use dpp::decision_proposal::{ + is_multiple_choice_proposal, multiple_choice_proposal_processing_fee, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, +}; +use dpp::document::document_methods::DocumentMethodsV0; +use dpp::document::{DocumentV0Getters, DocumentV0Setters}; +use dpp::fee::Credits; +use dpp::platform_value::btreemap_extensions::BTreeValueMapHelper; +use dpp::platform_value::{Bytes32, Value}; +use dpp::secp256k1::rand::rngs::StdRng; +use dpp::secp256k1::rand::{Rng, SeedableRng}; +use dpp::version::feature_initial_protocol_versions::DECISION_PROPOSALS_CONTRACT_INITIAL_PROTOCOL_VERSION; +use dpp::version::PlatformVersion; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use dpp::voting::vote_polls::VotePoll; +use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; +use dpp::voting::votes::Vote; +use drive::query::{WhereClause, WhereOperator}; +use drive_proof_verifier::types::{Contenders, Documents}; +use std::collections::BTreeMap; +use std::sync::Arc; + +/// The document a multiple choice proposal points at for what is being decided. Platform +/// refuses one that is not of a moderated type the elected team of its contract may delete. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct DescriptionDocument { + /// The document. + pub id: Identifier, + /// The contract it lives in, one whose moderators the masternodes elect. + pub contract_id: Identifier, + /// Its document type. + pub document_type: String, +} + +/// What a new multiple choice proposal asks. Platform refuses a proposal that gives neither a +/// description document nor a url. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct MultipleChoiceProposalInput { + /// The question, in one line: 1 to 128 characters. + pub title: String, + /// The document saying what is being decided. + pub description_document: Option, + /// Where what is being decided is described, for a proposal that points at no description + /// document, or where it is discussed, for one that does: a URI of at most 512 characters. + pub url: Option, + /// Whether anyone may enter choices; only the proposal's owner may when it is false. It + /// never changes. + pub open: bool, +} + +/// What a multiple choice proposal changes to. A field left `None` keeps its value. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct MultipleChoiceProposalEdit { + /// The new title. + pub title: Option, + /// The new description document: `Some(Some(document))` points the proposal at it, + /// `Some(None)` leaves the proposal described at its url alone. + pub description_document: Option>, + /// The new url: `Some(Some(url))` sets it, `Some(None)` removes it. + pub url: Option>, +} + +/// A multiple choice proposal: its document and the properties read out of it. +#[derive(Debug, Clone, PartialEq)] +pub struct MultipleChoiceProposal { + /// The `multipleChoiceProposal` document. + pub document: Document, + /// The question, in one line. + pub title: String, + /// The document saying what is being decided, when the proposal points at one. + pub description_document: Option, + /// Where what is being decided is described or discussed. Nothing on chain moderates it. + pub url: Option, + /// Whether anyone may enter choices; only the proposal's owner may when it is false. + pub open: bool, +} + +impl MultipleChoiceProposal { + /// Reads a proposal out of a `multipleChoiceProposal` document. + pub fn from_document(document: Document) -> Result { + let malformed = |error: dpp::platform_value::Error| { + Error::Generic(format!( + "multiple choice proposal {} is malformed: {error}", + document.id() + )) + }; + let properties = document.properties(); + let description_document = properties + .get_optional_identifier(proposal_properties::DESCRIPTION_ID) + .map_err(malformed)? + .map(|id| { + Ok::<_, Error>(DescriptionDocument { + id, + contract_id: properties + .get_identifier(proposal_properties::DESCRIPTION_CONTRACT_ID) + .map_err(malformed)?, + document_type: properties + .get_string(proposal_properties::DESCRIPTION_DOCUMENT_TYPE) + .map_err(malformed)?, + }) + }) + .transpose()?; + Ok(Self { + title: properties + .get_string(proposal_properties::TITLE) + .map_err(malformed)?, + description_document, + url: properties + .get_optional_string(proposal_properties::URL) + .map_err(malformed)?, + open: properties + .get_bool(proposal_properties::OPEN) + .map_err(malformed)?, + document, + }) + } + + /// The proposal's id, which its choices and its vote name it by. + pub fn id(&self) -> Identifier { + self.document.id() + } + + /// The proposer, the only identity that enters choices when the proposal is not open. + pub fn owner_id(&self) -> Identifier { + self.document.owner_id() + } +} + +/// An answer to enter for a multiple choice proposal. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ChoiceInput { + /// The proposal the choice answers. + pub proposal_id: Identifier, + /// The answer, in one line: 1 to 128 characters. + pub title: String, + /// What voting for the answer means: 1 to 4096 characters. + pub description: Option, +} + +/// A choice: its document and the properties read out of it. +#[derive(Debug, Clone, PartialEq)] +pub struct Choice { + /// The `choice` document. + pub document: Document, + /// The proposal the choice answers. + pub proposal_id: Identifier, + /// The answer, in one line. + pub title: String, + /// What voting for the answer means. + pub description: Option, +} + +impl Choice { + /// Reads a choice out of a `choice` document. + pub fn from_document(document: Document) -> Result { + let malformed = |error: dpp::platform_value::Error| { + Error::Generic(format!("choice {} is malformed: {error}", document.id())) + }; + let properties = document.properties(); + Ok(Self { + proposal_id: properties + .get_identifier(choice_properties::PROPOSAL_ID) + .map_err(malformed)?, + title: properties + .get_string(choice_properties::TITLE) + .map_err(malformed)?, + description: properties + .get_optional_string(choice_properties::DESCRIPTION) + .map_err(malformed)?, + document, + }) + } + + /// The choice's id, which a vote towards it carries. + pub fn id(&self) -> Identifier { + self.document.id() + } + + /// The identity that entered the choice. + pub fn owner_id(&self) -> Identifier { + self.document.owner_id() + } +} + +/// A choice in the vote among a proposal's choices. +#[derive(Debug, Clone, PartialEq)] +pub struct ChoiceInVote { + /// The choice, while the vote runs. `None` once it ended: the choices that were not kept + /// are no longer in state, and the one that was kept is an ordinary document + /// ([`Sdk::fetch_kept_choice`]). + pub choice: Option, + /// The votes towards the choice: so far while the vote runs, final once it ended. + pub vote_tally: Option, +} + +/// The vote among a multiple choice proposal's choices. +#[derive(Debug, Clone, Default, PartialEq)] +pub struct MultipleChoiceProposalVote { + /// The choices by their document ids. Empty for a proposal no choice was entered for. + pub choices: BTreeMap, + /// The abstaining votes. + pub abstain_vote_tally: Option, + /// The votes for none of the choices. + pub none_of_the_choices_vote_tally: Option, + /// How the vote ended and at which block; `None` while it runs. A winner is named by the + /// document id of the choice that was kept; locked means none of the choices was. + pub winner: Option<(ContestedDocumentVotePollWinnerInfo, BlockInfo)>, +} + +impl MultipleChoiceProposalVote { + /// Reads the vote out of the state of its contest, as the contested resource vote state + /// query returns it, with `contract` the decision proposals contract. + pub fn from_contenders( + contract: &DataContract, + contenders: Contenders, + platform_version: &PlatformVersion, + ) -> Result { + let document_type = contract + .document_type_for_name(CHOICE_DOCUMENT_TYPE_NAME) + .map_err(|e| Error::Protocol(e.into()))?; + let choices = contenders + .contenders + .iter() + .map(|(choice_id, contender)| { + let mut contender = contender.try_to_contender(document_type, platform_version)?; + Ok(( + *choice_id, + ChoiceInVote { + choice: contender + .take_document() + .map(Choice::from_document) + .transpose()?, + vote_tally: contender.vote_tally(), + }, + )) + }) + .collect::>()?; + Ok(Self { + choices, + abstain_vote_tally: contenders.abstain_vote_tally, + none_of_the_choices_vote_tally: contenders.lock_vote_tally, + winner: contenders.winner, + }) + } + + /// The document id of the choice the vote kept; `None` while the vote runs, and when it + /// kept none. + pub fn kept_choice_id(&self) -> Option { + match self.winner { + Some((ContestedDocumentVotePollWinnerInfo::WonByIdentity(choice_id), _)) => { + Some(choice_id) + } + _ => None, + } + } +} + +/// The properties naming the description document `description_document`. +fn description_document_properties( + description_document: &DescriptionDocument, +) -> [(&'static str, Value); 3] { + [ + ( + proposal_properties::DESCRIPTION_ID, + Value::Identifier(description_document.id.to_buffer()), + ), + ( + proposal_properties::DESCRIPTION_CONTRACT_ID, + Value::Identifier(description_document.contract_id.to_buffer()), + ), + ( + proposal_properties::DESCRIPTION_DOCUMENT_TYPE, + Value::Text(description_document.document_type.clone()), + ), + ] +} + +/// Builds a multiple choice proposal of `owner_id` asking what `input` says, in `contract`, +/// the decision proposals contract, with its id derived from `entropy`. +pub fn build_multiple_choice_proposal_document( + contract: &DataContract, + owner_id: Identifier, + input: &MultipleChoiceProposalInput, + entropy: Bytes32, +) -> Result { + let mut properties = BTreeMap::from([ + ( + proposal_properties::TITLE.to_string(), + Value::Text(input.title.clone()), + ), + ( + proposal_properties::OPEN.to_string(), + Value::Bool(input.open), + ), + ]); + if let Some(description_document) = &input.description_document { + properties.extend( + description_document_properties(description_document) + .map(|(name, value)| (name.to_string(), value)), + ); + } + if let Some(url) = &input.url { + properties.insert( + proposal_properties::URL.to_string(), + Value::Text(url.clone()), + ); + } + new_document( + contract, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + owner_id, + properties, + entropy, + ) +} + +/// `proposal`, a `document_type_name` document of the contract `data_contract_id`, with what +/// `edit` changes and its next revision, ready to be put as a replace. Anything but a multiple +/// choice proposal is refused, as is an edit that leaves the proposal as it is: a replace that +/// changes nothing still pays its fees. Consensus refuses the replace more than two hours +/// after the proposal was created, one that leaves the proposal with neither a description +/// document nor a url, and any change to whether it is open. +pub fn build_multiple_choice_proposal_edit( + data_contract_id: &Identifier, + document_type_name: &str, + proposal: &Document, + edit: &MultipleChoiceProposalEdit, +) -> Result { + if !is_multiple_choice_proposal(data_contract_id, document_type_name) { + return Err(Error::Generic(format!( + "a {document_type_name} document of contract {data_contract_id} is not a multiple \ + choice proposal" + ))); + } + let mut document = proposal.clone(); + if let Some(title) = &edit.title { + document.set(proposal_properties::TITLE, Value::Text(title.clone())); + } + match &edit.description_document { + Some(Some(description_document)) => { + for (name, value) in description_document_properties(description_document) { + document.set(name, value); + } + } + Some(None) => { + for name in [ + proposal_properties::DESCRIPTION_ID, + proposal_properties::DESCRIPTION_CONTRACT_ID, + proposal_properties::DESCRIPTION_DOCUMENT_TYPE, + ] { + document.remove(name); + } + } + None => {} + } + match &edit.url { + Some(Some(url)) => document.set(proposal_properties::URL, Value::Text(url.clone())), + Some(None) => { + document.remove(proposal_properties::URL); + } + None => {} + } + if document.properties() == proposal.properties() { + return Err(Error::Generic(format!( + "the edit of multiple choice proposal {} changes nothing", + proposal.id() + ))); + } + document.increment_revision()?; + Ok(document) +} + +/// Builds a choice of `owner_id` answering what `input` says, in `contract`, the decision +/// proposals contract, with its id derived from `entropy`. +pub fn build_choice_document( + contract: &DataContract, + owner_id: Identifier, + input: &ChoiceInput, + entropy: Bytes32, +) -> Result { + let mut properties = BTreeMap::from([ + ( + choice_properties::PROPOSAL_ID.to_string(), + Value::Identifier(input.proposal_id.to_buffer()), + ), + ( + choice_properties::TITLE.to_string(), + Value::Text(input.title.clone()), + ), + ]); + if let Some(description) = &input.description { + properties.insert( + choice_properties::DESCRIPTION.to_string(), + Value::Text(description.clone()), + ); + } + new_document( + contract, + CHOICE_DOCUMENT_TYPE_NAME, + owner_id, + properties, + entropy, + ) +} + +/// The query for the choice the finished vote of the proposal `proposal_id` kept, which the +/// `byProposal` index holds as the one choice of that proposal. +fn kept_choice_query( + contract: Arc, + proposal_id: Identifier, +) -> Result { + Ok( + DocumentQuery::new(contract, CHOICE_DOCUMENT_TYPE_NAME)?.with_where(WhereClause { + field: choice_properties::PROPOSAL_ID.to_string(), + operator: WhereOperator::Equal, + value: Value::Identifier(proposal_id.to_buffer()), + }), + ) +} + +/// The answer the recorded `vote` gives in the vote among the choices of the proposal +/// `proposal_id`; `None` for a vote on anything else. +fn multiple_choice_vote_choice_of( + vote: &Vote, + proposal_id: Identifier, +) -> Option { + let Vote::ResourceVote(resource_vote) = vote else { + return None; + }; + let VotePoll::ContestedDocumentResourceVotePoll(vote_poll) = resource_vote.vote_poll() else { + return None; + }; + if *vote_poll != multiple_choice_proposal_vote_poll(proposal_id) { + return None; + } + Some(match resource_vote.resource_vote_choice() { + ResourceVoteChoice::TowardsIdentity(choice_id) => { + MultipleChoiceVoteChoice::Choice(choice_id) + } + ResourceVoteChoice::Abstain => MultipleChoiceVoteChoice::Abstain, + ResourceVoteChoice::Lock => MultipleChoiceVoteChoice::NoneOfTheChoices, + }) +} + +impl Sdk { + /// Builds a multiple choice proposal of `owner_id` asking what `input` says (see + /// [`build_multiple_choice_proposal_document`]). The result is put like any document + /// create; the owner pays [`Self::multiple_choice_proposal_processing_fee`] on top of the + /// fees. + pub async fn build_multiple_choice_proposal( + &self, + owner_id: Identifier, + input: &MultipleChoiceProposalInput, + ) -> Result { + let contract = self.fetch_decision_proposals_contract().await?; + let entropy = Bytes32::new(StdRng::from_os_rng().random()); + build_multiple_choice_proposal_document(&contract, owner_id, input, entropy) + } + + /// Builds a choice of `owner_id` answering what `input` says (see + /// [`build_choice_document`]). The result is put like any document create, which states + /// the contest fund; the owner pays it ([`Self::choice_fund_to_join`]) on top of the fees. + /// The first choice opens the vote, and later ones join it while its join window is open. + pub async fn build_choice( + &self, + owner_id: Identifier, + input: &ChoiceInput, + ) -> Result { + let contract = self.fetch_decision_proposals_contract().await?; + let entropy = Bytes32::new(StdRng::from_os_rng().random()); + build_choice_document(&contract, owner_id, input, entropy) + } + + /// What creating one multiple choice proposal adds to the processing fee of its batch, in + /// credits. The create does not state it: whoever pays the fees pays it, and an identity + /// whose balance does not cover it creates no proposal. + pub async fn multiple_choice_proposal_processing_fee(&self) -> Result { + self.require_protocol_version( + DECISION_PROPOSALS_CONTRACT_INITIAL_PROTOCOL_VERSION, + "the multiple choice proposal processing fee", + ) + .await?; + Ok(multiple_choice_proposal_processing_fee(self.version())) + } + + /// The fund a choice entered now for the proposal `proposal_id` pays, in credits: the + /// contest's fund, doubled once the vote holds 250 choices and again for every 50 more + /// (see [`Self::contest_fund_to_join`]). A put of a choice reads it and states it itself. + pub async fn choice_fund_to_join(&self, proposal_id: Identifier) -> Result { + self.require_protocol_version( + DECISION_PROPOSALS_CONTRACT_INITIAL_PROTOCOL_VERSION, + "the vote among a multiple choice proposal's choices", + ) + .await?; + self.contest_fund_to_join_vote_poll(&multiple_choice_proposal_vote_poll(proposal_id)) + .await + } + + /// The multiple choice proposal with id `proposal_id`, `None` when there is none. + pub async fn fetch_multiple_choice_proposal( + &self, + proposal_id: Identifier, + ) -> Result, Error> { + let contract = self.fetch_decision_proposals_contract().await?; + let query = DocumentQuery::new(contract, MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME)? + .with_document_id(&proposal_id); + Document::fetch(self, query).await + } + + /// One page of the multiple choice proposals of `owner_id`, by creation time. + /// [`DocumentsPage::after`] gives the next page. + pub async fn fetch_multiple_choice_proposals_by_owner( + &self, + owner_id: Identifier, + page: DocumentsPage, + ) -> Result { + let contract = self.fetch_decision_proposals_contract().await?; + Document::fetch_many( + self, + proposals_by_owner_query( + contract, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + owner_id, + page, + )?, + ) + .await + } + + /// One page of every multiple choice proposal, newest first. [`DocumentsPage::after`] + /// gives the next page. + pub async fn fetch_multiple_choice_proposals_by_created_at( + &self, + page: DocumentsPage, + ) -> Result { + let contract = self.fetch_decision_proposals_contract().await?; + Document::fetch_many( + self, + proposals_by_created_at_query( + contract, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + page, + )?, + ) + .await + } + + /// The vote among the choices of the proposal `proposal_id`: every choice with its tally + /// while the vote runs, and its outcome with every choice's final tally once it ended. A + /// proposal no choice was entered for has an empty vote. The choices are read in pages of + /// 100, so a vote of `n` choices costs `n / 100 + 1` proved queries. + pub async fn fetch_multiple_choice_proposal_vote( + &self, + proposal_id: Identifier, + ) -> Result { + let contract = self.fetch_decision_proposals_contract().await?; + let contenders = self + .fetch_contested_resource_vote_state( + &multiple_choice_proposal_vote_poll(proposal_id), + None, + ) + .await?; + MultipleChoiceProposalVote::from_contenders(&contract, contenders, self.version()) + } + + /// The choice the finished vote of the proposal `proposal_id` kept, stored as an ordinary + /// document under the identity that entered it. `None` while the vote runs, for a vote + /// that kept none of the choices, and for a proposal no choice was entered for. + /// + /// One proved document query through the `byProposal` index. The choices a vote holds are + /// in the vote's own storage, which a document query does not read: the index holds a + /// choice only once a vote has kept it, and being unique it holds at most that one. + pub async fn fetch_kept_choice( + &self, + proposal_id: Identifier, + ) -> Result, Error> { + let contract = self.fetch_decision_proposals_contract().await?; + Document::fetch(self, kept_choice_query(contract, proposal_id)?).await + } + + /// The answer the masternode `pro_tx_hash` gave in the vote among the choices of the + /// proposal `proposal_id`. `None` when the masternode has not voted in it, and once the + /// vote ended. + pub async fn fetch_masternode_multiple_choice_vote( + &self, + pro_tx_hash: Identifier, + proposal_id: Identifier, + ) -> Result, Error> { + self.require_protocol_version( + DECISION_PROPOSALS_CONTRACT_INITIAL_PROTOCOL_VERSION, + "the vote among a multiple choice proposal's choices", + ) + .await?; + let vote_poll_id = multiple_choice_proposal_vote_poll(proposal_id).unique_id()?; + let vote = Vote::fetch(self, VoteQuery::new(pro_tx_hash, vote_poll_id)).await?; + // The query starts at the poll's id, so it may answer with the masternode's vote on a + // later poll + Ok(vote.and_then(|vote| multiple_choice_vote_choice_of(&vote, proposal_id))) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; + use dpp::data_contract::validate_document::DataContractDocumentValidationMethodsV0; + use dpp::decision_proposal::multiple_choice::CHOICE_CONTEST_INDEX_NAME; + use dpp::decision_proposal::DECISION_PROPOSALS_CONTRACT_ID; + use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; + use dpp::document::INITIAL_REVISION; + use dpp::system_data_contracts::{load_system_data_contract, SystemDataContract}; + use dpp::voting::contender_structs::{ + ContenderWithSerializedDocument, ContenderWithSerializedDocumentV0, + }; + use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; + use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; + use dpp::voting::votes::resource_vote::ResourceVote; + use drive::config::DEFAULT_QUERY_LIMIT; + use drive::query::vote_poll_vote_state_query::{ + ContestedDocumentVotePollDriveQuery, ContestedDocumentVotePollDriveQueryResultType, + }; + use drive::query::DriveDocumentQuery; + + fn proposals_contract() -> Arc { + Arc::new( + load_system_data_contract( + SystemDataContract::DecisionProposals, + PlatformVersion::latest(), + ) + .expect("the decision proposals contract loads at the latest version"), + ) + } + + fn description_document() -> DescriptionDocument { + DescriptionDocument { + id: Identifier::from([5; 32]), + contract_id: Identifier::from([6; 32]), + document_type: "post".to_string(), + } + } + + fn input() -> MultipleChoiceProposalInput { + MultipleChoiceProposalInput { + title: "Which block size?".to_string(), + description_document: Some(description_document()), + url: Some("https://forum.dash.org/t/block-size".to_string()), + open: true, + } + } + + /// `document` with the system fields the platform fills in when it stores the create. + fn stored(document: &Document) -> Document { + let mut document = document.clone(); + document.set_created_at(Some(1_700_000_000_000)); + document.set_updated_at(Some(1_700_000_000_000)); + document + } + + fn built_proposal(input: &MultipleChoiceProposalInput) -> Document { + build_multiple_choice_proposal_document( + &proposals_contract(), + Identifier::from([3; 32]), + input, + Bytes32::new([9; 32]), + ) + .expect("builds") + .document + } + + fn built_choice(description: Option<&str>) -> Document { + build_choice_document( + &proposals_contract(), + Identifier::from([4; 32]), + &ChoiceInput { + proposal_id: Identifier::from([7; 32]), + title: "Double it".to_string(), + description: description.map(str::to_string), + }, + Bytes32::new([8; 32]), + ) + .expect("builds") + .document + } + + #[test] + fn should_build_a_multiple_choice_proposal_the_schema_accepts() { + let platform_version = PlatformVersion::latest(); + let contract = proposals_contract(); + let described = [ + input(), + MultipleChoiceProposalInput { + url: None, + ..input() + }, + MultipleChoiceProposalInput { + description_document: None, + open: false, + ..input() + }, + ]; + for input in described { + let built = build_multiple_choice_proposal_document( + &contract, + Identifier::from([3; 32]), + &input, + Bytes32::new([9; 32]), + ) + .expect("builds"); + assert_eq!(built.entropy, Bytes32::new([9; 32])); + assert_eq!(built.document.revision(), Some(INITIAL_REVISION)); + assert_eq!( + built.document.id(), + Document::generate_document_id_v0( + &DECISION_PROPOSALS_CONTRACT_ID, + &Identifier::from([3; 32]), + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + &[9; 32], + ) + ); + let document = stored(&built.document); + let validation = contract + .validate_document( + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + &document, + platform_version, + ) + .expect("validates"); + assert!(validation.is_valid(), "{input:?}: {:?}", validation.errors); + + // A multiple choice proposal opens no poll, so its create states no fund + let document_type = contract + .document_type_for_name(MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME) + .expect("the multiple choice proposal type"); + assert_eq!( + document_type + .prefunded_voting_balance_for_document(&built.document, platform_version) + .expect("active"), + None + ); + + let proposal = MultipleChoiceProposal::from_document(document.clone()).expect("reads"); + assert_eq!( + proposal, + MultipleChoiceProposal { + document, + title: input.title, + description_document: input.description_document, + url: input.url, + open: input.open, + } + ); + assert_eq!(proposal.owner_id(), Identifier::from([3; 32])); + } + } + + /// The builder writes what it is given: which descriptions Platform takes is the + /// contract's to say, so a proposal described nowhere is built and left to it. + #[test] + fn should_leave_out_the_description_document_and_url_not_given() { + let document = built_proposal(&MultipleChoiceProposalInput { + description_document: None, + url: None, + ..input() + }); + for property in [ + proposal_properties::DESCRIPTION_ID, + proposal_properties::DESCRIPTION_CONTRACT_ID, + proposal_properties::DESCRIPTION_DOCUMENT_TYPE, + proposal_properties::URL, + ] { + assert!(document.get(property).is_none(), "{property}"); + } + + let mut no_document_type = built_proposal(&input()); + no_document_type.remove(proposal_properties::DESCRIPTION_DOCUMENT_TYPE); + assert!(MultipleChoiceProposal::from_document(no_document_type).is_err()); + } + + fn edit_proposal( + proposal: &Document, + edit: MultipleChoiceProposalEdit, + ) -> Result { + build_multiple_choice_proposal_edit( + &DECISION_PROPOSALS_CONTRACT_ID, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + proposal, + &edit, + ) + } + + #[test] + fn should_edit_the_title_url_and_description_document_and_never_whether_it_is_open() { + let proposal = stored(&built_proposal(&input())); + + let retitled = edit_proposal( + &proposal, + MultipleChoiceProposalEdit { + title: Some("Which block size, then?".to_string()), + ..Default::default() + }, + ) + .expect("edits"); + assert_eq!(retitled.id(), proposal.id()); + assert_eq!(retitled.revision(), Some(INITIAL_REVISION + 1)); + let read = MultipleChoiceProposal::from_document(retitled).expect("reads"); + assert_eq!(read.title, "Which block size, then?"); + assert_eq!(read.description_document, Some(description_document())); + assert_eq!(read.url, input().url); + assert!(read.open); + + let elsewhere = DescriptionDocument { + id: Identifier::from([1; 32]), + contract_id: Identifier::from([2; 32]), + document_type: "note".to_string(), + }; + let pointed_elsewhere = edit_proposal( + &proposal, + MultipleChoiceProposalEdit { + description_document: Some(Some(elsewhere.clone())), + url: Some(None), + ..Default::default() + }, + ) + .expect("edits"); + let read = MultipleChoiceProposal::from_document(pointed_elsewhere).expect("reads"); + assert_eq!(read.description_document, Some(elsewhere)); + assert_eq!(read.url, None); + + // All three properties naming the description document go together + let at_its_url = edit_proposal( + &proposal, + MultipleChoiceProposalEdit { + description_document: Some(None), + ..Default::default() + }, + ) + .expect("edits"); + for property in [ + proposal_properties::DESCRIPTION_ID, + proposal_properties::DESCRIPTION_CONTRACT_ID, + proposal_properties::DESCRIPTION_DOCUMENT_TYPE, + ] { + assert!(at_its_url.get(property).is_none(), "{property}"); + } + let read = MultipleChoiceProposal::from_document(at_its_url).expect("reads"); + assert_eq!(read.description_document, None); + assert_eq!(read.url, input().url); + } + + #[test] + fn should_refuse_an_edit_that_changes_nothing_or_is_not_of_a_multiple_choice_proposal() { + let proposal = stored(&built_proposal(&input())); + let unchanged = [ + MultipleChoiceProposalEdit::default(), + MultipleChoiceProposalEdit { + title: Some(input().title), + description_document: Some(Some(description_document())), + url: Some(input().url), + }, + ]; + for edit in unchanged { + let error = edit_proposal(&proposal, edit.clone()).expect_err("changes nothing"); + assert!(error.to_string().contains("changes nothing"), "{edit:?}"); + } + + let edit = MultipleChoiceProposalEdit { + title: Some("Another question?".to_string()), + ..Default::default() + }; + for (data_contract_id, document_type_name) in [ + ( + Identifier::from([1; 32]), + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + ), + (DECISION_PROPOSALS_CONTRACT_ID, "proposal"), + (DECISION_PROPOSALS_CONTRACT_ID, CHOICE_DOCUMENT_TYPE_NAME), + ] { + let error = build_multiple_choice_proposal_edit( + &data_contract_id, + document_type_name, + &proposal, + &edit, + ) + .expect_err("not a multiple choice proposal"); + assert!( + error + .to_string() + .contains("is not a multiple choice proposal"), + "{document_type_name} of {data_contract_id}: {error}" + ); + } + } + + #[test] + fn should_build_a_choice_the_schema_accepts_and_the_vote_of_its_proposal_takes() { + let platform_version = PlatformVersion::latest(); + let contract = proposals_contract(); + let document_type = contract + .document_type_for_name(CHOICE_DOCUMENT_TYPE_NAME) + .expect("the choice type"); + for description in [Some("Twice the size it is today."), None] { + let built = built_choice(description); + assert_eq!(built.revision(), None); + let mut document = built.clone(); + document.set_created_at(Some(1_700_000_000_000)); + let validation = contract + .validate_document(CHOICE_DOCUMENT_TYPE_NAME, &document, platform_version) + .expect("validates"); + assert!(validation.is_valid(), "{:?}", validation.errors); + + // The choice joins the vote its proposal's id names, and its create states the + // fund of that contest under the contested index + assert_eq!( + document_type + .contested_vote_poll_for_document(&built, platform_version) + .expect("active"), + Some(multiple_choice_proposal_vote_poll(Identifier::from( + [7; 32] + ))) + ); + let (fund_name, fund) = document_type + .prefunded_voting_balance_for_document(&built, platform_version) + .expect("active") + .expect("a contested create states a fund"); + assert_eq!(fund_name, CHOICE_CONTEST_INDEX_NAME); + assert_eq!( + fund, + multiple_choice_proposal_vote_poll(Identifier::from([7; 32])) + .required_vote_resolution_fund_to_join(0, platform_version) + ); + + let choice = Choice::from_document(document.clone()).expect("reads"); + assert_eq!( + choice, + Choice { + document, + proposal_id: Identifier::from([7; 32]), + title: "Double it".to_string(), + description: description.map(str::to_string), + } + ); + assert_eq!(choice.owner_id(), Identifier::from([4; 32])); + } + } + + /// A contender of the vote with `vote_tally` votes: the choice `document`, when the vote + /// still holds it. + fn contender( + choice_id: Identifier, + document: Option<&Document>, + vote_tally: u32, + ) -> (Identifier, ContenderWithSerializedDocument) { + let contract = proposals_contract(); + let document_type = contract + .document_type_for_name(CHOICE_DOCUMENT_TYPE_NAME) + .expect("the choice type"); + let serialized_document = document.map(|document| { + document + .serialize(document_type, &contract, PlatformVersion::latest()) + .expect("serializes") + }); + ( + choice_id, + ContenderWithSerializedDocumentV0 { + identity_id: choice_id, + serialized_document, + vote_tally: Some(vote_tally), + } + .into(), + ) + } + + #[test] + fn should_read_a_running_vote_with_its_choices_and_a_finished_one_with_its_tallies() { + let platform_version = PlatformVersion::latest(); + let contract = proposals_contract(); + let mut double = built_choice(Some("Twice the size it is today.")); + double.set_created_at(Some(1_700_000_000_000)); + let keep_id = Identifier::from([2; 32]); + + let running = MultipleChoiceProposalVote::from_contenders( + &contract, + Contenders { + winner: None, + contenders: BTreeMap::from([contender(double.id(), Some(&double), 12)]), + abstain_vote_tally: Some(3), + lock_vote_tally: Some(1), + }, + platform_version, + ) + .expect("reads"); + assert_eq!( + running, + MultipleChoiceProposalVote { + choices: BTreeMap::from([( + double.id(), + ChoiceInVote { + choice: Some(Choice::from_document(double.clone()).expect("reads")), + vote_tally: Some(12), + } + )]), + abstain_vote_tally: Some(3), + none_of_the_choices_vote_tally: Some(1), + winner: None, + } + ); + assert_eq!(running.kept_choice_id(), None); + + // Once the vote ended its record names the choices by id alone + let finished = MultipleChoiceProposalVote::from_contenders( + &contract, + Contenders { + winner: Some(( + ContestedDocumentVotePollWinnerInfo::WonByIdentity(double.id()), + BlockInfo::default(), + )), + contenders: BTreeMap::from([ + contender(double.id(), None, 12), + contender(keep_id, None, 4), + ]), + abstain_vote_tally: Some(3), + lock_vote_tally: Some(1), + }, + platform_version, + ) + .expect("reads"); + assert_eq!(finished.kept_choice_id(), Some(double.id())); + assert_eq!( + finished.choices[&keep_id], + ChoiceInVote { + choice: None, + vote_tally: Some(4), + } + ); + + let none_kept = MultipleChoiceProposalVote { + winner: Some(( + ContestedDocumentVotePollWinnerInfo::Locked, + BlockInfo::default(), + )), + ..Default::default() + }; + assert_eq!(none_kept.kept_choice_id(), None); + } + + /// The index `query` is served through, and that a proof of it can be verified: the path + /// query the verifier rebuilds constructs. + fn served_through(query: &DocumentQuery) -> String { + let platform_version = PlatformVersion::latest(); + let drive_query = DriveDocumentQuery::try_from(query).expect("converts"); + drive_query + .construct_path_query(None, platform_version) + .expect("a provable path query"); + drive_query + .find_best_index(platform_version) + .expect("an index serves it") + .name + .clone() + } + + #[test] + fn should_serve_every_listing_through_the_index_the_schema_declares_for_it() { + let contract = proposals_contract(); + let page = DocumentsPage { + limit: Some(20), + start_after: Some(Identifier::from([5; 32])), + }; + let by_owner = proposals_by_owner_query( + contract.clone(), + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + Identifier::from([3; 32]), + page, + ) + .expect("builds"); + assert_eq!(served_through(&by_owner), "byOwner"); + assert_eq!(by_owner.limit, 20); + let by_created_at = proposals_by_created_at_query( + contract.clone(), + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + DocumentsPage::default(), + ) + .expect("builds"); + assert_eq!(served_through(&by_created_at), "byCreatedAt"); + assert_eq!(by_created_at.limit, 100); + assert_eq!( + served_through( + &kept_choice_query(contract, Identifier::from([7; 32])).expect("builds") + ), + CHOICE_CONTEST_INDEX_NAME + ); + } + + #[test] + fn should_read_a_masternode_answer_only_from_a_vote_on_the_proposal() { + let proposal_id = Identifier::from([7; 32]); + let choice_id = Identifier::from([9; 32]); + for vote_choice in [ + MultipleChoiceVoteChoice::Choice(choice_id), + MultipleChoiceVoteChoice::Abstain, + MultipleChoiceVoteChoice::NoneOfTheChoices, + ] { + let vote = multiple_choice_proposal_vote(proposal_id, vote_choice); + assert_eq!( + multiple_choice_vote_choice_of(&vote, proposal_id), + Some(vote_choice) + ); + // The vote query starts at the poll's id and may answer with a later poll's vote + assert_eq!( + multiple_choice_vote_choice_of(&vote, Identifier::from([8; 32])), + None + ); + } + let on_another_contest = Vote::ResourceVote(ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + index_name: "parentNameAndLabel".to_string(), + ..multiple_choice_proposal_vote_poll(proposal_id) + }, + ), + resource_vote_choice: ResourceVoteChoice::Abstain, + })); + assert_eq!( + multiple_choice_vote_choice_of(&on_another_contest, proposal_id), + None + ); + } + + /// The fund of a choice and the vote are read from the contest the proposal's id names. + #[tokio::test] + async fn should_read_the_choice_fund_and_the_vote_from_the_contest_of_the_proposal() { + let mut sdk = crate::SdkBuilder::new_mock() + .with_version(PlatformVersion::latest()) + .build() + .expect("a mock sdk"); + let proposal_id = Identifier::from([7; 32]); + let mut double = built_choice(Some("Twice the size it is today.")); + double.set_created_at(Some(1_700_000_000_000)); + let state = || Contenders { + winner: None, + contenders: BTreeMap::from([contender(double.id(), Some(&double), 12)]), + abstain_vote_tally: Some(3), + lock_vote_tally: Some(1), + }; + let contest_query = |result_type, with_other_tallies| ContestedDocumentVotePollDriveQuery { + vote_poll: multiple_choice_proposal_vote_poll(proposal_id), + result_type, + offset: None, + limit: Some(DEFAULT_QUERY_LIMIT), + start_at: None, + allow_include_locked_and_abstaining_vote_tally: with_other_tallies, + }; + sdk.mock() + .expect_fetch_many::<_, ContenderWithSerializedDocument, _, Contenders>( + contest_query( + ContestedDocumentVotePollDriveQueryResultType::VoteTally, + false, + ), + Some(state()), + ) + .await + .expect("registers the tallies"); + sdk.mock() + .expect_fetch_many::<_, ContenderWithSerializedDocument, _, Contenders>( + contest_query( + ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally, + true, + ), + Some(state()), + ) + .await + .expect("registers the vote state"); + // One choice entered: the next pays the contest's fund, not yet doubled + assert_eq!( + sdk.choice_fund_to_join(proposal_id).await.expect("reads"), + 10_000_000_000 + ); + // The mock SDK holds no system contract, so the vote is read as + // `fetch_multiple_choice_proposal_vote` reads it, with the contract given + let contenders = sdk + .fetch_contested_resource_vote_state( + &multiple_choice_proposal_vote_poll(proposal_id), + None, + ) + .await + .expect("reads"); + let vote = MultipleChoiceProposalVote::from_contenders( + &proposals_contract(), + contenders, + sdk.version(), + ) + .expect("reads"); + assert_eq!(vote.choices.len(), 1); + assert_eq!( + vote.choices[&double.id()], + ChoiceInVote { + choice: Some(Choice::from_document(double.clone()).expect("reads")), + vote_tally: Some(12), + } + ); + assert_eq!(vote.none_of_the_choices_vote_tally, Some(1)); + } + + #[tokio::test] + async fn should_price_a_multiple_choice_proposal_by_the_fee_schedule() { + let sdk = crate::SdkBuilder::new_mock() + .with_version(PlatformVersion::latest()) + .build() + .expect("a mock sdk"); + assert_eq!( + sdk.multiple_choice_proposal_processing_fee() + .await + .expect("active"), + 20_000_000_000 + ); + } +} diff --git a/packages/rs-sdk/src/platform/documents/contest_fund.rs b/packages/rs-sdk/src/platform/documents/contest_fund.rs index c3e4a6ca644..cf96efdcc57 100644 --- a/packages/rs-sdk/src/platform/documents/contest_fund.rs +++ b/packages/rs-sdk/src/platform/documents/contest_fund.rs @@ -14,6 +14,7 @@ use dpp::document::DocumentV0Getters; use dpp::fee::Credits; use dpp::state_transition::batch_transition::methods::StateTransitionCreationOptions; use dpp::voting::contender_structs::ContenderWithSerializedDocument; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use drive::config::DEFAULT_QUERY_LIMIT; use drive::query::vote_poll_vote_state_query::{ ContestedDocumentVotePollDriveQuery, ContestedDocumentVotePollDriveQueryResultType, @@ -61,6 +62,17 @@ impl Sdk { return Ok(None); }; + let contest_fund = self.contest_fund_to_join_vote_poll(&vote_poll).await?; + Ok(Some((vote_poll.index_name, contest_fund))) + } + + /// The fund a create pays to join the contest `vote_poll` now: the contest's fund, doubled + /// once the contest holds 250 contenders and again for every 50 more. The contenders are + /// counted as [`Self::contest_fund_to_join`] says. + pub async fn contest_fund_to_join_vote_poll( + &self, + vote_poll: &ContestedDocumentResourceVotePoll, + ) -> Result { let mut contenders: u16 = 0; let mut start_at = None; loop { @@ -91,9 +103,7 @@ impl Sdk { } } - let contest_fund = - vote_poll.required_vote_resolution_fund_to_join(contenders, self.version()); - Ok(Some((vote_poll.index_name, contest_fund))) + Ok(vote_poll.required_vote_resolution_fund_to_join(contenders, self.version())) } } @@ -128,7 +138,6 @@ mod tests { use dpp::tests::fixtures::get_dpns_data_contract_fixture; use dpp::version::PlatformVersion; use dpp::voting::contender_structs::ContenderWithSerializedDocumentV0; - use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use drive_proof_verifier::types::Contenders; use std::collections::BTreeMap; diff --git a/packages/rs-sdk/src/platform/documents/contest_vote_state.rs b/packages/rs-sdk/src/platform/documents/contest_vote_state.rs new file mode 100644 index 00000000000..80442d8c8fb --- /dev/null +++ b/packages/rs-sdk/src/platform/documents/contest_vote_state.rs @@ -0,0 +1,206 @@ +//! The whole state of a contest: every contender with its document and tally, read a page at a +//! time. + +use crate::platform::fetch_many::FetchMany; +use crate::{Error, Sdk}; +use dpp::voting::contender_structs::ContenderWithSerializedDocument; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use drive::config::DEFAULT_QUERY_LIMIT; +use drive::query::vote_poll_vote_state_query::{ + ContestedDocumentVotePollDriveQuery, ContestedDocumentVotePollDriveQueryResultType, +}; +use drive_proof_verifier::types::Contenders; + +impl Sdk { + /// The state of the contest `vote_poll`: its contenders with their documents and tallies, + /// the abstain and lock tallies, and the winner once the contest ended. + /// + /// Reads the contenders in the order of the ids the contest names them by, in pages of up + /// to 100 (the most Drive answers to one query) that each start after the last contender + /// read, until `limit` contenders are read or none are left. The abstain and lock tallies + /// and the winner come from the first page: Drive returns the tallies only to a query + /// without a start. + /// + /// `limit` is the most contenders returned; `None` returns every contender, and `Some(0)` + /// an empty state without a request. A contest that ended answers its first page with + /// every contender of its record, whatever the page asks for: no further page is read, and + /// its contenders are cut to `limit` here, the first in id order kept; its winner and its + /// abstain and lock tallies are returned whole. + pub async fn fetch_contested_resource_vote_state( + &self, + vote_poll: &ContestedDocumentResourceVotePoll, + limit: Option, + ) -> Result { + let mut state: Option = None; + let mut start_at = None; + loop { + let read = state.as_ref().map_or(0, |state| state.contenders.len()); + let page_limit = match limit { + Some(limit) => { + let left = (limit as usize).saturating_sub(read); + if left == 0 { + break; + } + left.min(DEFAULT_QUERY_LIMIT as usize) as u16 + } + None => DEFAULT_QUERY_LIMIT, + }; + let page = ContenderWithSerializedDocument::fetch_many( + self, + ContestedDocumentVotePollDriveQuery { + vote_poll: vote_poll.clone(), + result_type: + ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally, + allow_include_locked_and_abstaining_vote_tally: true, + start_at, + limit: Some(page_limit), + offset: None, + }, + ) + .await?; + let page_len = page.contenders.len(); + let last = page.contenders.keys().last().copied(); + // A page naming a winner is the record of a contest that ended, which is whole + let ended = page.winner.is_some(); + match state.as_mut() { + None => state = Some(page), + Some(state) => state.contenders.extend(page.contenders), + } + + // A short page is the last one + match last { + Some(last) if !ended && page_len >= page_limit as usize => { + start_at = Some((last.to_buffer(), false)); + } + _ => break, + } + } + + let mut state = state.unwrap_or_default(); + if let Some(limit) = limit { + while state.contenders.len() > limit as usize { + state.contenders.pop_last(); + } + } + Ok(state) + } +} + +#[cfg(all(test, feature = "mocks"))] +mod tests { + use super::*; + use crate::SdkBuilder; + use dpp::block::block_info::BlockInfo; + use dpp::platform_value::{Identifier, Value}; + use dpp::version::PlatformVersion; + use dpp::voting::contender_structs::ContenderWithSerializedDocumentV0; + use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; + use std::collections::BTreeMap; + + /// A contest that ended answers a page with every contender of its record, however few + /// the page asked for: the state holds `limit` of them, with the winner and the abstain + /// and lock tallies of the whole contest. + #[tokio::test] + async fn should_read_a_contest_that_ended_in_one_page_and_cut_it_to_the_limit() { + let mut sdk = SdkBuilder::new_mock() + .with_version(PlatformVersion::latest()) + .build() + .expect("a mock sdk"); + let vote_poll = ContestedDocumentResourceVotePoll { + contract_id: Identifier::new([7; 32]), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }; + let contender = |n: u8, vote_tally: u32| { + let identity_id = Identifier::new([n; 32]); + ( + identity_id, + ContenderWithSerializedDocument::V0(ContenderWithSerializedDocumentV0 { + identity_id, + serialized_document: None, + vote_tally: Some(vote_tally), + }), + ) + }; + let winner = Some(( + ContestedDocumentVotePollWinnerInfo::WonByIdentity(Identifier::new([3; 32])), + BlockInfo::default(), + )); + for limit in [1u16, 2] { + sdk.mock() + .expect_fetch_many::<_, ContenderWithSerializedDocument, _, Contenders>( + ContestedDocumentVotePollDriveQuery { + vote_poll: vote_poll.clone(), + result_type: + ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally, + allow_include_locked_and_abstaining_vote_tally: true, + start_at: None, + limit: Some(limit), + offset: None, + }, + Some(Contenders { + winner, + contenders: BTreeMap::from([ + contender(1, 4), + contender(2, 5), + contender(3, 12), + ]), + abstain_vote_tally: Some(6), + lock_vote_tally: Some(2), + }), + ) + .await + .expect("registers the page"); + } + // The whole record of a contest that ended comes with its first page, however many + // contenders it holds: no page after it is registered, so asking for one would fail + let record: BTreeMap<_, _> = (1..=150u8).map(|n| contender(n, 1)).collect(); + sdk.mock() + .expect_fetch_many::<_, ContenderWithSerializedDocument, _, Contenders>( + ContestedDocumentVotePollDriveQuery { + vote_poll: vote_poll.clone(), + result_type: + ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally, + allow_include_locked_and_abstaining_vote_tally: true, + start_at: None, + limit: Some(DEFAULT_QUERY_LIMIT), + offset: None, + }, + Some(Contenders { + winner, + contenders: record, + abstain_vote_tally: Some(6), + lock_vote_tally: Some(2), + }), + ) + .await + .expect("registers the record"); + let whole = sdk + .fetch_contested_resource_vote_state(&vote_poll, None) + .await + .expect("reads the record in one page"); + assert_eq!(whole.contenders.len(), 150); + assert_eq!(whole.winner, winner); + + for limit in [1u32, 2] { + let state = sdk + .fetch_contested_resource_vote_state(&vote_poll, Some(limit)) + .await + .expect("reads"); + assert_eq!( + state.contenders.keys().copied().collect::>(), + (1..=limit as u8) + .map(|n| Identifier::new([n; 32])) + .collect::>(), + "limit {limit}" + ); + assert_eq!(state.winner, winner); + assert_eq!(state.abstain_vote_tally, Some(6)); + assert_eq!(state.lock_vote_tally, Some(2)); + } + } +} diff --git a/packages/rs-sdk/src/platform/documents/mod.rs b/packages/rs-sdk/src/platform/documents/mod.rs index 9f43abbaf99..c54aca3aeb5 100644 --- a/packages/rs-sdk/src/platform/documents/mod.rs +++ b/packages/rs-sdk/src/platform/documents/mod.rs @@ -13,6 +13,7 @@ pub use dash_platform_queries::documents::{ pub mod chained_document_query_sdk; pub mod contest_fund; +pub mod contest_vote_state; pub mod document_query_sdk; mod fetch_bindings; pub mod page; diff --git a/packages/rs-sdk/src/platform/dpns_usernames/contested_queries.rs b/packages/rs-sdk/src/platform/dpns_usernames/contested_queries.rs index 5de0a064e85..fa8d0427abb 100644 --- a/packages/rs-sdk/src/platform/dpns_usernames/contested_queries.rs +++ b/packages/rs-sdk/src/platform/dpns_usernames/contested_queries.rs @@ -151,50 +151,8 @@ impl Sdk { ], }; - let mut state: Option = None; - let mut start_at = None; - loop { - let read = state.as_ref().map_or(0, |state| state.contenders.len()); - let page_limit = match limit { - Some(limit) => { - let left = (limit as usize).saturating_sub(read); - if left == 0 { - break; - } - left.min(DEFAULT_QUERY_LIMIT as usize) as u16 - } - None => DEFAULT_QUERY_LIMIT, - }; - let page = ContenderWithSerializedDocument::fetch_many( - self, - ContestedDocumentVotePollDriveQuery { - vote_poll: vote_poll.clone(), - result_type: - ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally, - allow_include_locked_and_abstaining_vote_tally: true, - start_at, - limit: Some(page_limit), - offset: None, - }, - ) - .await?; - let page_len = page.contenders.len(); - let last = page.contenders.keys().last().copied(); - match state.as_mut() { - None => state = Some(page), - Some(state) => state.contenders.extend(page.contenders), - } - - // A short page is the last one - match last { - Some(last) if page_len >= page_limit as usize => { - start_at = Some((last.to_buffer(), false)); - } - _ => break, - } - } - - Ok(state.unwrap_or_default()) + self.fetch_contested_resource_vote_state(&vote_poll, limit) + .await } /// Get voters who voted for a specific identity for a contested DPNS username diff --git a/packages/wasm-sdk/src/decision_proposals.rs b/packages/wasm-sdk/src/decision_proposals.rs index bb5395ba1c0..f48e358af13 100644 --- a/packages/wasm-sdk/src/decision_proposals.rs +++ b/packages/wasm-sdk/src/decision_proposals.rs @@ -2,6 +2,11 @@ //! masternodes. Thin bindings over `dash_sdk::platform::decision_proposals`: a proposal is a //! `proposal` document of the decision proposals system contract, created and edited like any //! document, and its poll is named by the proposal's id. +//! +//! A question with more than two answers is a multiple choice proposal: see +//! [`multiple_choice`]. + +pub mod multiple_choice; use crate::error::WasmSdkError; use crate::queries::utils::{documents_map, documents_page_of}; diff --git a/packages/wasm-sdk/src/decision_proposals/multiple_choice.rs b/packages/wasm-sdk/src/decision_proposals/multiple_choice.rs new file mode 100644 index 00000000000..59a9d654fe8 --- /dev/null +++ b/packages/wasm-sdk/src/decision_proposals/multiple_choice.rs @@ -0,0 +1,853 @@ +//! Multiple choice proposals (protocol version 15): questions whose answers are the choices +//! entered for them. Thin bindings over +//! `dash_sdk::platform::decision_proposals::multiple_choice`: a proposal is a +//! `multipleChoiceProposal` document and an answer a `choice` document of the decision +//! proposals system contract, created like any document, and the choices contend in a +//! masternode vote named by the proposal's id. + +use super::{optional_string_option, page_of, string_option}; +use crate::error::WasmSdkError; +use crate::queries::utils::documents_map; +use crate::queries::voting::yes_no::{block_to_js, set}; +use crate::sdk::WasmSdk; +use crate::state_transitions::identity::MasternodeVoteSigning; +use dash_sdk::dpp::decision_proposal::multiple_choice::CHOICE_DOCUMENT_TYPE_NAME; +use dash_sdk::dpp::decision_proposal::{ + DECISION_PROPOSALS_CONTRACT_ID, MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, +}; +use dash_sdk::dpp::document::Document; +use dash_sdk::dpp::voting::vote_polls::VotePoll; +use dash_sdk::platform::decision_proposals::multiple_choice::{ + build_multiple_choice_proposal_edit, multiple_choice_proposal_vote, + multiple_choice_proposal_vote_poll, ChoiceInput, DescriptionDocument, + MultipleChoiceProposalEdit, MultipleChoiceProposalInput, MultipleChoiceProposalVote, + MultipleChoiceVoteChoice, +}; +use dash_sdk::platform::Identifier; +use js_sys::{Map, Object, Reflect}; +use wasm_bindgen::prelude::wasm_bindgen; +use wasm_bindgen::JsValue; +use wasm_dpp2::data_contract::document::DocumentWasm; +use wasm_dpp2::error::WasmDppError; +use wasm_dpp2::identifier::{IdentifierLikeJs, IdentifierWasm}; +use wasm_dpp2::utils::{try_from_options_with, try_to_string}; +use wasm_dpp2::voting::vote::VoteWasm; +use wasm_dpp2::VotePollWasm; + +#[wasm_bindgen(typescript_custom_section)] +const MULTIPLE_CHOICE_PROPOSALS_TS: &'static str = r#" +/** + * The document a multiple choice proposal points at for what is being decided. Platform + * refuses one that is not of a moderated type the elected team of its contract may delete. + */ +export interface MultipleChoiceProposalDescriptionDocument { + /** The document. */ + id: IdentifierLike; + /** The contract it lives in, one whose moderators the masternodes elect. */ + contractId: IdentifierLike; + /** Its document type. */ + documentType: string; +} + +/** + * Options for `buildMultipleChoiceProposal`: a question put to the masternodes whose answers + * are the choices entered for it (protocol version 15). Its owner pays the multiple choice + * proposal processing fee (`getMultipleChoiceProposalProcessingFee`) on top of the fees. + * Platform refuses a proposal that gives neither a description document nor a url. + */ +export interface MultipleChoiceProposalOptions { + /** The proposer, the document's owner. */ + ownerId: IdentifierLike; + /** The question, in one line: 1 to 128 characters. */ + title: string; + /** The document saying what is being decided. */ + descriptionDocument?: MultipleChoiceProposalDescriptionDocument; + /** + * Where what is being decided is described, for a proposal that points at no description + * document, or where it is discussed, for one that does: a URI of at most 512 characters. + * Nothing on chain moderates it. + */ + url?: string; + /** + * Whether anyone may enter choices; only the proposal's owner may when it is false. It + * never changes. + */ + open: boolean; +} + +/** + * What a multiple choice proposal changes to (`buildMultipleChoiceProposalEdit`). A field left + * out keeps its value. Platform accepts the edit for two hours after the proposal is created; + * whether it is open never changes. + */ +export interface MultipleChoiceProposalEdit { + /** The new title. */ + title?: string; + /** The new description document; `null` leaves the proposal described at its url alone. */ + descriptionDocument?: MultipleChoiceProposalDescriptionDocument | null; + /** The new url; `null` removes it. */ + url?: string | null; +} + +/** + * Options for `buildMultipleChoiceProposalChoice`: an answer to a multiple choice proposal. + * Its owner pays the contest fund (`getMultipleChoiceProposalChoiceFund`) on top of the fees. + * Anyone enters choices for an open proposal, and only its owner for one that is not. + */ +export interface MultipleChoiceProposalChoiceOptions { + /** The identity entering the choice, the document's owner. */ + ownerId: IdentifierLike; + /** The proposal the choice answers. */ + proposalId: IdentifierLike; + /** The answer, in one line: 1 to 128 characters. */ + title: string; + /** What voting for the answer means: 1 to 4096 characters. */ + description?: string; +} + +/** + * A masternode's answer in the vote among a multiple choice proposal's choices: a choice, by + * its document id (not the id of the identity that entered it); `'abstain'`; or + * `'noneOfTheChoices'`, which keeps no choice when these votes outnumber the leading choice. + */ +export type MultipleChoiceVoteChoice = + | { choiceId: IdentifierLike } + | 'abstain' + | 'noneOfTheChoices'; + +/** The answer a masternode gave (`getMasternodeMultipleChoiceProposalVote`). */ +export type MasternodeMultipleChoiceVote = + | { choiceId: Identifier } + | 'abstain' + | 'noneOfTheChoices'; + +/** A choice in the vote among a multiple choice proposal's choices. */ +export interface MultipleChoiceProposalChoiceInVote { + /** + * The `choice` document, while the vote runs. Left out once it ended: the choices that were + * not kept are no longer in state, and `getMultipleChoiceProposalKeptChoice` reads the one + * that was. + */ + choice?: Document; + /** The votes towards the choice: so far while the vote runs, final once it ended. */ + voteTally?: number; +} + +/** The vote among a multiple choice proposal's choices (`getMultipleChoiceProposalVote`). */ +export interface MultipleChoiceProposalVote { + /** The choices by their base58 document ids. Empty for a proposal with no choice. */ + choices: Map; + /** The abstaining votes. */ + abstainVoteTally?: number; + /** The votes for none of the choices. */ + noneOfTheChoicesVoteTally?: number; + /** How the vote ended; left out while it runs. */ + result?: { + /** The document id of the choice that was kept; left out when none was. */ + keptChoiceId?: Identifier; + /** The block the vote ended at. */ + finalizationBlock: YesNoVotePollBlock; + }; +} + +/** Options for `multipleChoiceProposalVote`: a masternode's answer on a proposal. */ +export interface MultipleChoiceProposalVoteOptions { + /** + * The ProTxHash of the masternode: an Identifier, its 32 bytes, the hex Core's RPC shows, + * or base58. + */ + masternodeProTxHash: IdentifierLike; + /** The proposal. */ + proposalId: IdentifierLike; + /** The answer. */ + voteChoice: MultipleChoiceVoteChoice; + /** The masternode's voting public key. */ + votingKey: IdentityPublicKey; + /** Signer holding the private key of the voting key. */ + signer: IdentitySigner; + /** Optional settings for the broadcast. */ + settings?: PutSettings; +} +"#; + +#[wasm_bindgen] +extern "C" { + #[wasm_bindgen(typescript_type = "MultipleChoiceProposalOptions")] + pub type MultipleChoiceProposalOptionsJs; + + #[wasm_bindgen(typescript_type = "MultipleChoiceProposalEdit")] + pub type MultipleChoiceProposalEditJs; + + #[wasm_bindgen(typescript_type = "MultipleChoiceProposalChoiceOptions")] + pub type MultipleChoiceProposalChoiceOptionsJs; + + #[wasm_bindgen(typescript_type = "MultipleChoiceProposalVoteOptions")] + pub type MultipleChoiceProposalVoteOptionsJs; + + #[wasm_bindgen(typescript_type = "DecisionProposalsByOwnerQuery")] + pub type MultipleChoiceProposalsByOwnerQueryJs; + + #[wasm_bindgen(typescript_type = "DecisionProposalsPageQuery")] + pub type MultipleChoiceProposalsPageQueryJs; +} + +/// The description document `value` names. +fn description_document(value: &JsValue) -> Result { + Ok(DescriptionDocument { + id: IdentifierWasm::try_from_options(value, "id")?.into(), + contract_id: IdentifierWasm::try_from_options(value, "contractId")?.into(), + document_type: string_option(value, "documentType")?, + }) +} + +/// The property `property` of `options`: `None` when it is left out, `Some(None)` when it is +/// `null`, and what `read` makes of it otherwise. +fn nullable_option( + options: &JsValue, + property: &str, + read: impl FnOnce(&JsValue) -> Result, +) -> Result>, WasmSdkError> { + let value = Reflect::get(options, &JsValue::from_str(property)) + .map_err(|_| WasmSdkError::invalid_argument(format!("cannot read {property}")))?; + if value.is_undefined() { + Ok(None) + } else if value.is_null() { + Ok(Some(None)) + } else { + read(&value).map(|value| Some(Some(value))) + } +} + +/// The answer `property` of `options` gives: `{ choiceId }`, `'abstain'` or +/// `'noneOfTheChoices'`. +fn vote_choice_from_options( + options: &JsValue, + property: &str, +) -> Result { + let value = Reflect::get(options, &JsValue::from_str(property)) + .map_err(|_| WasmSdkError::invalid_argument(format!("cannot read {property}")))?; + match value.as_string().as_deref() { + Some("abstain") => Ok(MultipleChoiceVoteChoice::Abstain), + Some("noneOfTheChoices") => Ok(MultipleChoiceVoteChoice::NoneOfTheChoices), + Some(other) => Err(WasmSdkError::invalid_argument(format!( + "{property} on a multiple choice proposal is {{ choiceId }}, 'abstain' or \ + 'noneOfTheChoices', got '{other}'" + ))), + None if value.is_object() => Ok(MultipleChoiceVoteChoice::Choice( + IdentifierWasm::try_from_options(&value, "choiceId")?.into(), + )), + None => Err(WasmSdkError::invalid_argument(format!( + "{property} on a multiple choice proposal is {{ choiceId }}, 'abstain' or \ + 'noneOfTheChoices'" + ))), + } +} + +/// `vote_choice` as `getMasternodeMultipleChoiceProposalVote` returns it. +fn vote_choice_to_js(vote_choice: MultipleChoiceVoteChoice) -> Result { + Ok(match vote_choice { + MultipleChoiceVoteChoice::Choice(choice_id) => { + let object = Object::new(); + set(&object, "choiceId", IdentifierWasm::from(choice_id).into())?; + object.into() + } + MultipleChoiceVoteChoice::Abstain => JsValue::from_str("abstain"), + MultipleChoiceVoteChoice::NoneOfTheChoices => JsValue::from_str("noneOfTheChoices"), + }) +} + +fn document_wasm( + document: Document, + document_type_name: &str, + entropy: Option<[u8; 32]>, +) -> DocumentWasm { + DocumentWasm::new( + document, + DECISION_PROPOSALS_CONTRACT_ID, + document_type_name.to_string(), + entropy, + ) +} + +/// `vote` as `getMultipleChoiceProposalVote` returns it. +fn vote_to_js(vote: MultipleChoiceProposalVote) -> Result { + let kept_choice_id = vote.kept_choice_id(); + let choices = Map::new(); + for (choice_id, choice_in_vote) in vote.choices { + let entry = Object::new(); + if let Some(choice) = choice_in_vote.choice { + set( + &entry, + "choice", + document_wasm(choice.document, CHOICE_DOCUMENT_TYPE_NAME, None).into(), + )?; + } + if let Some(vote_tally) = choice_in_vote.vote_tally { + set(&entry, "voteTally", JsValue::from(vote_tally))?; + } + choices.set( + &IdentifierWasm::from(choice_id).to_base58().into(), + &entry.into(), + ); + } + let object = Object::new(); + set(&object, "choices", choices.into())?; + if let Some(abstain_vote_tally) = vote.abstain_vote_tally { + set( + &object, + "abstainVoteTally", + JsValue::from(abstain_vote_tally), + )?; + } + if let Some(none_of_the_choices_vote_tally) = vote.none_of_the_choices_vote_tally { + set( + &object, + "noneOfTheChoicesVoteTally", + JsValue::from(none_of_the_choices_vote_tally), + )?; + } + if let Some((_, finalization_block)) = &vote.winner { + let result = Object::new(); + if let Some(kept_choice_id) = kept_choice_id { + set( + &result, + "keptChoiceId", + IdentifierWasm::from(kept_choice_id).into(), + )?; + } + set( + &result, + "finalizationBlock", + block_to_js(finalization_block)?, + )?; + set(&object, "result", result.into())?; + } + Ok(object.into()) +} + +#[wasm_bindgen] +impl WasmSdk { + /// Builds a multiple choice proposal: a `multipleChoiceProposal` document of the decision + /// proposals contract with a fresh entropy, to create with `documentCreate`. Its owner + /// pays the multiple choice proposal processing fee on top of the fees; the create does + /// not state it. The id is final once `documentCreate` returns the stored document. + /// + /// @param options - The proposer, the question, where it is described and whether anyone + /// may enter choices. + /// @returns The proposal, ready for `documentCreate`. + #[wasm_bindgen(js_name = "buildMultipleChoiceProposal")] + pub async fn build_multiple_choice_proposal( + &self, + options: MultipleChoiceProposalOptionsJs, + ) -> Result { + let options: JsValue = options.into(); + let owner_id: Identifier = IdentifierWasm::try_from_options(&options, "ownerId")?.into(); + let input = MultipleChoiceProposalInput { + title: string_option(&options, "title")?, + description_document: nullable_option( + &options, + "descriptionDocument", + description_document, + )? + .flatten(), + url: optional_string_option(&options, "url")?, + open: try_from_options_with(&options, "open", |value| { + value + .as_bool() + .ok_or_else(|| WasmDppError::invalid_argument("'open' must be a boolean")) + })?, + }; + let built = self + .as_ref() + .build_multiple_choice_proposal(owner_id, &input) + .await?; + Ok(document_wasm( + built.document, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + Some(built.entropy.0), + )) + } + + /// A multiple choice proposal with what the edit changes and its next revision, to + /// replace with `documentReplace`. Platform accepts the edit for two hours after the + /// proposal is created. A document that is not a multiple choice proposal is refused. + /// + /// @param proposal - The proposal as stored, from `getMultipleChoiceProposal`. + /// @param edit - The new title, description document or url; `null` removes the + /// description document or the url. + /// @returns The edited proposal. + #[wasm_bindgen(js_name = "buildMultipleChoiceProposalEdit")] + pub fn build_multiple_choice_proposal_edit( + &self, + proposal: &DocumentWasm, + edit: MultipleChoiceProposalEditJs, + ) -> Result { + let edit: JsValue = edit.into(); + let edit = MultipleChoiceProposalEdit { + title: optional_string_option(&edit, "title")?, + description_document: nullable_option( + &edit, + "descriptionDocument", + description_document, + )?, + url: nullable_option(&edit, "url", |value| Ok(try_to_string(value, "url")?))?, + }; + let data_contract_id: Identifier = proposal.data_contract_id().into(); + let document: Document = proposal.clone().into(); + Ok(document_wasm( + build_multiple_choice_proposal_edit( + &data_contract_id, + &proposal.document_type_name(), + &document, + &edit, + )?, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + None, + )) + } + + /// Builds a choice: a `choice` document of the decision proposals contract with a fresh + /// entropy, to create with `documentCreate`, which states the contest fund. The first + /// choice opens the vote, and later ones join it while its join window is open. The id, + /// which a vote towards the choice carries, is final once `documentCreate` returns the + /// stored document. + /// + /// @param options - The identity entering the choice, the proposal and the answer. + /// @returns The choice, ready for `documentCreate`. + #[wasm_bindgen(js_name = "buildMultipleChoiceProposalChoice")] + pub async fn build_multiple_choice_proposal_choice( + &self, + options: MultipleChoiceProposalChoiceOptionsJs, + ) -> Result { + let options: JsValue = options.into(); + let owner_id: Identifier = IdentifierWasm::try_from_options(&options, "ownerId")?.into(); + let input = ChoiceInput { + proposal_id: IdentifierWasm::try_from_options(&options, "proposalId")?.into(), + title: string_option(&options, "title")?, + description: optional_string_option(&options, "description")?, + }; + let built = self.as_ref().build_choice(owner_id, &input).await?; + Ok(document_wasm( + built.document, + CHOICE_DOCUMENT_TYPE_NAME, + Some(built.entropy.0), + )) + } + + /// What creating one multiple choice proposal adds to the processing fee of its batch, in + /// credits. + #[wasm_bindgen(js_name = "getMultipleChoiceProposalProcessingFee")] + pub async fn get_multiple_choice_proposal_processing_fee(&self) -> Result { + Ok(self + .as_ref() + .multiple_choice_proposal_processing_fee() + .await?) + } + + /// The fund a choice entered now for a proposal pays, in credits: the contest's fund, + /// doubled once the vote holds 250 choices and again for every 50 more. + /// + /// @param proposalId - The proposal. + #[wasm_bindgen(js_name = "getMultipleChoiceProposalChoiceFund")] + pub async fn get_multiple_choice_proposal_choice_fund( + &self, + #[wasm_bindgen(js_name = "proposalId")] proposal_id: IdentifierLikeJs, + ) -> Result { + let proposal_id: Identifier = proposal_id.try_into()?; + Ok(self.as_ref().choice_fund_to_join(proposal_id).await?) + } + + /// A multiple choice proposal by id. + /// + /// @param proposalId - The proposal. + /// @returns The `multipleChoiceProposal` document, or undefined when there is none. + #[wasm_bindgen(js_name = "getMultipleChoiceProposal")] + pub async fn get_multiple_choice_proposal( + &self, + #[wasm_bindgen(js_name = "proposalId")] proposal_id: IdentifierLikeJs, + ) -> Result, WasmSdkError> { + let proposal_id: Identifier = proposal_id.try_into()?; + Ok(self + .as_ref() + .fetch_multiple_choice_proposal(proposal_id) + .await? + .map(|document| { + document_wasm(document, MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, None) + })) + } + + /// One page of an identity's multiple choice proposals, by creation time. + /// + /// @returns The proposals by id; pass the last id as `startAfter` for the next page. + #[wasm_bindgen( + js_name = "getMultipleChoiceProposalsByOwner", + unchecked_return_type = "Map" + )] + pub async fn get_multiple_choice_proposals_by_owner( + &self, + query: MultipleChoiceProposalsByOwnerQueryJs, + ) -> Result { + let query: JsValue = query.into(); + if query.is_undefined() || query.is_null() { + return Err(WasmSdkError::invalid_argument("Query object is required")); + } + let owner_id: Identifier = IdentifierWasm::try_from_options(&query, "ownerId")?.into(); + let documents = self + .as_ref() + .fetch_multiple_choice_proposals_by_owner(owner_id, page_of(&query)?) + .await?; + Ok(documents_map( + documents, + DECISION_PROPOSALS_CONTRACT_ID, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + )) + } + + /// One page of every multiple choice proposal, newest first. + /// + /// @returns The proposals by id; pass the last id as `startAfter` for the next page. + #[wasm_bindgen( + js_name = "getMultipleChoiceProposalsByCreatedAt", + unchecked_return_type = "Map" + )] + pub async fn get_multiple_choice_proposals_by_created_at( + &self, + query: Option, + ) -> Result { + let query: JsValue = query.map(Into::into).unwrap_or(JsValue::UNDEFINED); + let documents = self + .as_ref() + .fetch_multiple_choice_proposals_by_created_at(page_of(&query)?) + .await?; + Ok(documents_map( + documents, + DECISION_PROPOSALS_CONTRACT_ID, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + )) + } + + /// The vote among a proposal's choices as a vote poll, which `masternodeVote`, + /// `getContestedResourceVoteState` and the other contested resource queries take. In it a + /// choice is named by its document id wherever they name a contender by an identity id. + /// + /// @param proposalId - The proposal. + #[wasm_bindgen(js_name = "getMultipleChoiceProposalVotePoll")] + pub fn get_multiple_choice_proposal_vote_poll( + &self, + #[wasm_bindgen(js_name = "proposalId")] proposal_id: IdentifierLikeJs, + ) -> Result { + let proposal_id: Identifier = proposal_id.try_into()?; + Ok( + VotePoll::ContestedDocumentResourceVotePoll(multiple_choice_proposal_vote_poll( + proposal_id, + )) + .into(), + ) + } + + /// The vote among a proposal's choices: every choice with its tally while the vote runs, + /// and its result with every choice's final tally once it ended. A proposal no choice was + /// entered for has no choices. + /// + /// # Example + /// ```javascript + /// const vote = await sdk.getMultipleChoiceProposalVote(proposalId); + /// for (const [choiceId, { choice, voteTally }] of vote.choices) { + /// console.log(choiceId, choice?.properties.title, voteTally); + /// } + /// ``` + #[wasm_bindgen( + js_name = "getMultipleChoiceProposalVote", + unchecked_return_type = "MultipleChoiceProposalVote" + )] + pub async fn get_multiple_choice_proposal_vote( + &self, + #[wasm_bindgen(js_name = "proposalId")] proposal_id: IdentifierLikeJs, + ) -> Result { + let proposal_id: Identifier = proposal_id.try_into()?; + let vote = self + .as_ref() + .fetch_multiple_choice_proposal_vote(proposal_id) + .await?; + vote_to_js(vote) + } + + /// The choice the finished vote of a proposal kept, an ordinary document of the identity + /// that entered it. Undefined while the vote runs, when it kept none of the choices, and + /// for a proposal no choice was entered for. + /// + /// @param proposalId - The proposal. + #[wasm_bindgen(js_name = "getMultipleChoiceProposalKeptChoice")] + pub async fn get_multiple_choice_proposal_kept_choice( + &self, + #[wasm_bindgen(js_name = "proposalId")] proposal_id: IdentifierLikeJs, + ) -> Result, WasmSdkError> { + let proposal_id: Identifier = proposal_id.try_into()?; + Ok(self + .as_ref() + .fetch_kept_choice(proposal_id) + .await? + .map(|document| document_wasm(document, CHOICE_DOCUMENT_TYPE_NAME, None))) + } + + /// The answer a masternode gave in the vote among a proposal's choices. Undefined when + /// the masternode has not voted in it, and once the vote ended. + #[wasm_bindgen( + js_name = "getMasternodeMultipleChoiceProposalVote", + unchecked_return_type = "MasternodeMultipleChoiceVote | undefined" + )] + pub async fn get_masternode_multiple_choice_proposal_vote( + &self, + #[wasm_bindgen(js_name = "proTxHash")] pro_tx_hash: IdentifierLikeJs, + #[wasm_bindgen(js_name = "proposalId")] proposal_id: IdentifierLikeJs, + ) -> Result { + let pro_tx_hash: Identifier = pro_tx_hash + .try_into() + .map_err(|err| WasmSdkError::invalid_argument(format!("Invalid proTxHash: {err}")))?; + let proposal_id: Identifier = proposal_id.try_into()?; + match self + .as_ref() + .fetch_masternode_multiple_choice_vote(pro_tx_hash, proposal_id) + .await? + { + Some(vote_choice) => vote_choice_to_js(vote_choice), + None => Ok(JsValue::UNDEFINED), + } + } + + /// Votes in the vote among a proposal's choices for a masternode: builds the vote, signs + /// it with the voting key, broadcasts it and waits for the block that records it. Every + /// option is read before anything reaches the network. + /// + /// @param options - The masternode, the proposal, the answer, the voting key and signer. + /// @returns The vote as Platform recorded it. + #[wasm_bindgen(js_name = "multipleChoiceProposalVote")] + pub async fn multiple_choice_proposal_vote( + &self, + options: MultipleChoiceProposalVoteOptionsJs, + ) -> Result { + let options: JsValue = options.into(); + let pro_tx_hash: Identifier = + IdentifierWasm::try_from_options(&options, "masternodeProTxHash")?.into(); + let proposal_id: Identifier = + IdentifierWasm::try_from_options(&options, "proposalId")?.into(); + let vote_choice = vote_choice_from_options(&options, "voteChoice")?; + let signing = MasternodeVoteSigning::from_options(&options)?; + let vote = multiple_choice_proposal_vote(proposal_id, vote_choice); + self.put_masternode_vote(pro_tx_hash, vote, signing).await + } +} + +#[cfg(all(test, target_arch = "wasm32"))] +mod binding_tests { + use super::*; + use dash_sdk::dpp::block::block_info::BlockInfo; + use dash_sdk::dpp::decision_proposal::multiple_choice::choice_properties; + use dash_sdk::dpp::document::DocumentV0; + use dash_sdk::dpp::platform_value::Value; + use dash_sdk::dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; + use dash_sdk::platform::decision_proposals::multiple_choice::{Choice, ChoiceInVote}; + use std::collections::BTreeMap; + use wasm_bindgen::JsCast; + use wasm_bindgen_test::wasm_bindgen_test; + + fn get(value: &JsValue, key: &str) -> JsValue { + Reflect::get(value, &JsValue::from_str(key)).expect("a property") + } + + fn base58(id: Identifier) -> String { + IdentifierWasm::from(id).to_base58() + } + + /// The choice `title` of the proposal `[7; 32]`, with the document id `id`. + fn choice(id: Identifier, title: &str) -> Choice { + Choice::from_document( + DocumentV0 { + id, + owner_id: Identifier::new([4; 32]), + properties: BTreeMap::from([ + ( + choice_properties::PROPOSAL_ID.to_string(), + Value::Identifier([7; 32]), + ), + ( + choice_properties::TITLE.to_string(), + Value::Text(title.to_string()), + ), + ]), + ..Default::default() + } + .into(), + ) + .expect("a choice") + } + + fn choices_of(vote: &JsValue) -> Map { + let choices = get(vote, "choices"); + assert!(choices.is_instance_of::(), "a Map: {choices:?}"); + choices.unchecked_into() + } + + fn finalization_block() -> BlockInfo { + BlockInfo { + time_ms: 1_700_000_000_000, + height: 7, + core_height: 5, + ..Default::default() + } + } + + #[wasm_bindgen_test] + fn should_give_a_vote_with_no_choice_an_empty_map_and_nothing_else() { + let vote = vote_to_js(MultipleChoiceProposalVote::default()).expect("converts"); + assert_eq!(choices_of(&vote).size(), 0); + for property in ["abstainVoteTally", "noneOfTheChoicesVoteTally", "result"] { + assert!(get(&vote, property).is_undefined(), "{property}"); + } + } + + #[wasm_bindgen_test] + fn should_give_a_running_vote_its_choices_by_document_id_with_their_tallies() { + let double_id = Identifier::new([1; 32]); + let keep_id = Identifier::new([2; 32]); + let vote = vote_to_js(MultipleChoiceProposalVote { + choices: BTreeMap::from([ + ( + double_id, + ChoiceInVote { + choice: Some(choice(double_id, "Double it")), + vote_tally: Some(12), + }, + ), + ( + keep_id, + ChoiceInVote { + choice: Some(choice(keep_id, "Keep it")), + vote_tally: None, + }, + ), + ]), + abstain_vote_tally: Some(3), + none_of_the_choices_vote_tally: Some(1), + winner: None, + }) + .expect("converts"); + + let choices = choices_of(&vote); + assert_eq!(choices.size(), 2); + let double = choices.get(&base58(double_id).into()); + assert_eq!(get(&double, "voteTally").as_f64(), Some(12.0)); + let document = get(&double, "choice"); + assert_eq!( + get(&document, "documentTypeName").as_string().as_deref(), + Some(CHOICE_DOCUMENT_TYPE_NAME) + ); + assert_eq!( + IdentifierWasm::try_from_options(&document, "id") + .expect("an id") + .to_base58(), + base58(double_id) + ); + assert_eq!( + IdentifierWasm::try_from_options(&document, "dataContractId") + .expect("a contract id") + .to_base58(), + base58(DECISION_PROPOSALS_CONTRACT_ID) + ); + let keep = choices.get(&base58(keep_id).into()); + assert!(!get(&keep, "choice").is_undefined()); + assert!(get(&keep, "voteTally").is_undefined()); + + assert_eq!(get(&vote, "abstainVoteTally").as_f64(), Some(3.0)); + assert_eq!(get(&vote, "noneOfTheChoicesVoteTally").as_f64(), Some(1.0)); + assert!(get(&vote, "result").is_undefined()); + } + + #[wasm_bindgen_test] + fn should_give_a_vote_that_kept_a_choice_its_id_and_every_final_tally() { + let double_id = Identifier::new([1; 32]); + let keep_id = Identifier::new([2; 32]); + let tally = |vote_tally| ChoiceInVote { + choice: None, + vote_tally: Some(vote_tally), + }; + let vote = vote_to_js(MultipleChoiceProposalVote { + choices: BTreeMap::from([(double_id, tally(12)), (keep_id, tally(4))]), + abstain_vote_tally: Some(3), + none_of_the_choices_vote_tally: Some(1), + winner: Some(( + ContestedDocumentVotePollWinnerInfo::WonByIdentity(double_id), + finalization_block(), + )), + }) + .expect("converts"); + + let choices = choices_of(&vote); + for (choice_id, vote_tally) in [(double_id, 12.0), (keep_id, 4.0)] { + let entry = choices.get(&base58(choice_id).into()); + assert!(get(&entry, "choice").is_undefined()); + assert_eq!(get(&entry, "voteTally").as_f64(), Some(vote_tally)); + } + let result = get(&vote, "result"); + assert_eq!( + IdentifierWasm::try_from_options(&result, "keptChoiceId") + .expect("the kept choice") + .to_base58(), + base58(double_id) + ); + let block = get(&result, "finalizationBlock"); + assert_eq!(get(&block, "height"), JsValue::from(7u64)); + assert_eq!(get(&block, "coreHeight").as_f64(), Some(5.0)); + assert_eq!(get(&block, "timeMs"), JsValue::from(1_700_000_000_000u64)); + } + + #[wasm_bindgen_test] + fn should_give_a_vote_that_kept_no_choice_a_result_without_a_kept_choice() { + let vote = vote_to_js(MultipleChoiceProposalVote { + choices: BTreeMap::from([( + Identifier::new([1; 32]), + ChoiceInVote { + choice: None, + vote_tally: Some(2), + }, + )]), + abstain_vote_tally: Some(0), + none_of_the_choices_vote_tally: Some(9), + winner: Some(( + ContestedDocumentVotePollWinnerInfo::Locked, + finalization_block(), + )), + }) + .expect("converts"); + + let result = get(&vote, "result"); + assert!(result.is_object()); + assert!(get(&result, "keptChoiceId").is_undefined()); + assert!(get(&result, "finalizationBlock").is_object()); + assert_eq!(get(&vote, "abstainVoteTally").as_f64(), Some(0.0)); + assert_eq!(get(&vote, "noneOfTheChoicesVoteTally").as_f64(), Some(9.0)); + } + + #[wasm_bindgen_test] + fn should_read_a_masternode_answer_back_as_it_is_given() { + let choice_id = Identifier::new([1; 32]); + let options = |vote_choice: JsValue| { + let options = Object::new(); + set(&options, "voteChoice", vote_choice).expect("sets"); + JsValue::from(options) + }; + for vote_choice in [ + MultipleChoiceVoteChoice::Choice(choice_id), + MultipleChoiceVoteChoice::Abstain, + MultipleChoiceVoteChoice::NoneOfTheChoices, + ] { + let given = vote_choice_to_js(vote_choice).expect("converts"); + assert_eq!( + vote_choice_from_options(&options(given), "voteChoice").expect("reads"), + vote_choice + ); + } + assert!(vote_choice_from_options(&options("lock".into()), "voteChoice").is_err()); + assert!(vote_choice_from_options(&options(JsValue::from(1)), "voteChoice").is_err()); + } +} diff --git a/packages/wasm-sdk/src/queries/voting/yes_no.rs b/packages/wasm-sdk/src/queries/voting/yes_no.rs index 76450594be1..3eee76d7e61 100644 --- a/packages/wasm-sdk/src/queries/voting/yes_no.rs +++ b/packages/wasm-sdk/src/queries/voting/yes_no.rs @@ -69,7 +69,7 @@ export interface MasternodeYesNoVote { "#; /// Sets `key` on `object`. -fn set(object: &Object, key: &str, value: JsValue) -> Result<(), WasmSdkError> { +pub(crate) fn set(object: &Object, key: &str, value: JsValue) -> Result<(), WasmSdkError> { Reflect::set(object, &key.into(), &value) .map(|_| ()) .map_err(|_| WasmSdkError::generic(format!("failed to set `{key}`"))) @@ -85,7 +85,7 @@ fn yes_no_vote_poll(vote_poll: &VotePollWasm) -> Result Result { +pub(crate) fn block_to_js(block: &BlockInfo) -> Result { let object = Object::new(); set(&object, "height", BigInt::from(block.height).into())?; set(&object, "coreHeight", JsValue::from(block.core_height))?; diff --git a/packages/wasm-sdk/tests/unit/multiple-choice-proposals.spec.ts b/packages/wasm-sdk/tests/unit/multiple-choice-proposals.spec.ts new file mode 100644 index 00000000000..983bf227ba3 --- /dev/null +++ b/packages/wasm-sdk/tests/unit/multiple-choice-proposals.spec.ts @@ -0,0 +1,174 @@ +/** + * Multiple choice proposals (protocol version 15). `buildMultipleChoiceProposalEdit` and + * `getMultipleChoiceProposalVotePoll` need no network. The other calls parse every option + * before anything is fetched, so a call whose only fault is one option fails on that option: + * the options before it were accepted, and nothing reached the network. + */ +import { expect } from './helpers/chai.ts'; +import init, * as sdk from '../../dist/sdk.compressed.js'; + +const DECISION_PROPOSALS_CONTRACT_ID = '3iNyoNwjCTkb7XS3RHyWUtLx7pgC6AFAEQNNDHzxqngF'; +const ownerId = '5mjGWa9mruHnLBht3ntBi8CZ6sNk3hZZsQMgTvgQobjS'; +const proposalId = '4EfA9Jrvv3nnCFdSf7fad59851iiTRZ6Wcu6YVJ4iSeF'; +const descriptionId = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec'; +const proTxHashHex = 'a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2'; + +async function rejectionOf(promise: Promise): Promise { + try { + await promise; + } catch (e) { + return e as Error; + } + throw new Error('expected the call to be refused'); +} + +function refusalOf(call: () => unknown): Error { + try { + call(); + } catch (e) { + return e as Error; + } + throw new Error('expected the call to be refused'); +} + +describe('multiple choice proposals', () => { + let client: sdk.WasmSdk; + + before(async () => { + await init(); + client = await sdk.WasmSdkBuilder.testnet().build(); + }); + + after(() => { + client?.free(); + }); + + function storedProposal(documentTypeName = 'multipleChoiceProposal'): sdk.Document { + return new sdk.Document({ + properties: { + title: 'Which block size?', + descriptionId: new Uint8Array(32).fill(5), + descriptionContractId: new Uint8Array(32).fill(6), + descriptionDocumentType: 'post', + url: 'https://forum.dash.org/t/block-size', + open: true, + }, + documentTypeName, + dataContractId: DECISION_PROPOSALS_CONTRACT_ID, + ownerId, + revision: BigInt(1), + entropy: new Uint8Array(32).fill(3), + }); + } + + describe('buildMultipleChoiceProposalEdit()', () => { + it('should give the proposal a new title and its next revision', () => { + const proposal = storedProposal(); + const edited = client.buildMultipleChoiceProposalEdit(proposal, { title: 'Which block size, then?' }); + expect(edited.id.toBase58()).to.equal(proposal.id.toBase58()); + expect(edited.revision).to.equal(BigInt(2)); + const properties = edited.properties as Record; + expect(properties.title).to.equal('Which block size, then?'); + expect(properties.url).to.equal('https://forum.dash.org/t/block-size'); + expect(properties.descriptionDocumentType).to.equal('post'); + expect(properties.open).to.equal(true); + expect(edited.documentTypeName).to.equal('multipleChoiceProposal'); + }); + + it('should remove all three description properties when the edit sets the document to null', () => { + const edited = client.buildMultipleChoiceProposalEdit(storedProposal(), { descriptionDocument: null }); + const properties = edited.properties as Record; + expect(properties).to.not.have.property('descriptionId'); + expect(properties).to.not.have.property('descriptionContractId'); + expect(properties).to.not.have.property('descriptionDocumentType'); + expect(properties.url).to.equal('https://forum.dash.org/t/block-size'); + }); + + it('should point the proposal at another description document and remove the url', () => { + const edited = client.buildMultipleChoiceProposalEdit(storedProposal(), { + descriptionDocument: { id: proposalId, contractId: descriptionId, documentType: 'note' }, + url: null, + }); + const properties = edited.properties as Record; + expect(properties.descriptionDocumentType).to.equal('note'); + expect(properties).to.not.have.property('url'); + }); + + it('should refuse an edit that changes nothing', () => { + const error = refusalOf(() => client.buildMultipleChoiceProposalEdit(storedProposal(), {})); + expect(error.message).to.match(/changes nothing/); + }); + + it('should refuse a document that is not a multiple choice proposal', () => { + const error = refusalOf(() => client.buildMultipleChoiceProposalEdit( + storedProposal('proposal'), + { title: 'Another question?' }, + )); + expect(error.message).to.match(/is not a multiple choice proposal/); + }); + }); + + describe('getMultipleChoiceProposalVotePoll()', () => { + it('should name the contest of the choice type at the proposal', () => { + const votePoll = client.getMultipleChoiceProposalVotePoll(proposalId); + const json = votePoll.toJSON() as Record; + expect(JSON.stringify(json)).to.contain('byProposal'); + expect(JSON.stringify(json)).to.contain(DECISION_PROPOSALS_CONTRACT_ID); + }); + }); + + describe('listings', () => { + it('should accept Identifier instances as the owner and the cursor', async () => { + const error = await rejectionOf(client.getMultipleChoiceProposalsByOwner({ + ownerId: new sdk.Identifier(ownerId), + startAfter: new sdk.Identifier(ownerId), + limit: 1.5, + })); + expect(error.message).to.match(/'limit' must be an integer/); + }); + }); + + describe('buildMultipleChoiceProposal()', () => { + it('should refuse a description document that names no contract', async () => { + const error = await rejectionOf(client.buildMultipleChoiceProposal({ + ownerId, + title: 'Which block size?', + descriptionDocument: { id: descriptionId, documentType: 'post' } as never, + open: true, + })); + expect(error.message).to.match(/contractId/); + }); + + it('should refuse an open that is not a boolean', async () => { + const error = await rejectionOf(client.buildMultipleChoiceProposal({ + ownerId, + title: 'Which block size?', + url: 'https://forum.dash.org/t/block-size', + open: 'yes' as never, + })); + expect(error.message).to.match(/'open' must be a boolean/); + }); + }); + + describe('multipleChoiceProposalVote()', () => { + it('should refuse an answer that is neither a choice, abstain nor none of the choices', async () => { + const error = await rejectionOf(client.multipleChoiceProposalVote({ + masternodeProTxHash: proTxHashHex, + proposalId, + voteChoice: 'lock' as never, + } as never)); + expect(error.message).to.match(/'abstain' or 'noneOfTheChoices', got 'lock'/); + }); + + [{ choiceId: descriptionId }, 'abstain', 'noneOfTheChoices'].forEach((voteChoice) => { + it(`should accept ${JSON.stringify(voteChoice)} and read the voting key before the network`, async () => { + const error = await rejectionOf(client.multipleChoiceProposalVote({ + masternodeProTxHash: proTxHashHex, + proposalId, + voteChoice, + } as never)); + expect(error.message).to.match(/'votingKey' is required/); + }); + }); + }); +}); From b2e7395b96e92c4d788998f8771fccb69662be64 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Fri, 13 Nov 2026 21:48:59 +0700 Subject: [PATCH 24/26] fix(platform)!: refuse high-S signatures on key-recovery paths from protocol version 15 (#5899) Co-authored-by: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 --- .../src/address_funds/platform_address.rs | 95 +++++-- packages/rs-dpp/src/state_transition/mod.rs | 108 ++++++- .../signing_tests.rs | 6 +- .../signing_tests.rs | 2 +- .../state_transition_witness_validation.rs | 34 ++- .../verify_identity_signed_signature/mod.rs | 8 +- .../v0/mod.rs | 14 +- .../v1/mod.rs | 4 +- packages/rs-dpp/src/tests/utils/mod.rs | 32 +++ .../src/util/{ecdsa.rs => ecdsa/mod.rs} | 9 + .../util/ecdsa/verify_hash_signature/mod.rs | 268 ++++++++++++++++++ .../ecdsa/verify_hash_signature/v0/mod.rs | 12 + .../ecdsa/verify_hash_signature/v1/mod.rs | 25 ++ packages/rs-dpp/tests/ecdsa_compatibility.rs | 72 ++++- .../processor/traits/address_witnesses.rs | 38 ++- .../address_funding_from_asset_lock/tests.rs | 93 ++++++ .../transform_into_action/v0/mod.rs | 10 +- .../address_funds_transfer/tests.rs | 124 ++++++++ .../state_transitions/identity_create/mod.rs | 143 ++++++++++ .../identity_create/state/v0/mod.rs | 10 +- .../state_transitions/identity_top_up/mod.rs | 148 ++++++++++ .../transform_into_action/v0/mod.rs | 10 +- .../shield_from_asset_lock/tests.rs | 99 ++++++- .../transform_into_action/v1/mod.rs | 10 +- .../mod.rs | 8 + .../v1.rs | 1 + .../v2.rs | 1 + .../v3.rs | 13 + .../rs-platform-version/src/version/v15.rs | 20 +- .../transition/broadcast/retry_tests.rs | 2 +- 30 files changed, 1336 insertions(+), 83 deletions(-) rename packages/rs-dpp/src/util/{ecdsa.rs => ecdsa/mod.rs} (79%) create mode 100644 packages/rs-dpp/src/util/ecdsa/verify_hash_signature/mod.rs create mode 100644 packages/rs-dpp/src/util/ecdsa/verify_hash_signature/v0/mod.rs create mode 100644 packages/rs-dpp/src/util/ecdsa/verify_hash_signature/v1/mod.rs create mode 100644 packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/v3.rs diff --git a/packages/rs-dpp/src/address_funds/platform_address.rs b/packages/rs-dpp/src/address_funds/platform_address.rs index 248eb209588..e1cb3540a7d 100644 --- a/packages/rs-dpp/src/address_funds/platform_address.rs +++ b/packages/rs-dpp/src/address_funds/platform_address.rs @@ -12,12 +12,11 @@ use bincode::{Decode, DecodeUntrusted, Encode}; use dashcore::address::Payload; use dashcore::blockdata::script::ScriptBuf; use dashcore::hashes::sha256d; -use dashcore::{ - sign_message, signer, Address, Network, PrivateKey, PubkeyHash, PublicKey, ScriptHash, -}; +use dashcore::{sign_message, Address, Network, PrivateKey, PubkeyHash, PublicKey, ScriptHash}; use platform_serialization_derive::{ PlatformDeserializeTrusted, PlatformDeserializeUntrusted, PlatformSerialize, }; +use platform_version::version::PlatformVersion; #[cfg(feature = "serde-conversion")] use serde::{Deserialize, Serialize}; use std::convert::TryFrom; @@ -473,14 +472,19 @@ impl PlatformAddress { /// # Arguments /// * `witness` - The witness containing signature(s) and either a public key (P2PKH) or redeem script (P2SH) /// * `signable_bytes` - The data that was signed (will be double-SHA256 hashed internally) + /// * `platform_version` - Selects `verify_hash_signature` for a P2PKH witness: from protocol + /// version 15 a high-S signature and a header naming an uncompressed key are refused. /// /// # Returns /// * `Ok(AddressWitnessVerificationOperations)` - Operations performed if verification succeeds - /// * `Err(ProtocolError)` if verification fails + /// * `Err(ProtocolError::UnknownVersionMismatch)` if this build does not know the selected + /// `verify_hash_signature` version + /// * `Err(ProtocolError)` of another kind if verification fails pub fn verify_bytes_against_witness( &self, witness: &AddressWitness, signable_bytes: &[u8], + platform_version: &PlatformVersion, ) -> Result { match (self, witness) { (PlatformAddress::P2pkh(pubkey_hash), AddressWitness::P2pkh { signature }) => { @@ -492,13 +496,18 @@ impl PlatformAddress { // This saves 33 bytes per witness (no need to include pubkey) // at a ~4% CPU cost increase (recovery vs verify). let data_hash = dashcore::signer::double_sha(signable_bytes); - signer::verify_hash_signature(&data_hash, signature.as_slice(), pubkey_hash) - .map_err(|e| { - ProtocolError::AddressWitnessError(format!( - "P2PKH signature verification failed: {}", - e - )) - })?; + ecdsa::verify_hash_signature( + &data_hash, + signature.as_slice(), + pubkey_hash, + platform_version, + )? + .map_err(|e| { + ProtocolError::AddressWitnessError(format!( + "P2PKH signature verification failed: {}", + e + )) + })?; Ok(AddressWitnessVerificationOperations::for_p2pkh( signable_bytes.len(), @@ -896,7 +905,11 @@ mod tests { }; // Verify should succeed - let result = address.verify_bytes_against_witness(&witness, signable_bytes); + let result = address.verify_bytes_against_witness( + &witness, + signable_bytes, + PlatformVersion::latest(), + ); assert!( result.is_ok(), "P2PKH verification should succeed: {:?}", @@ -925,7 +938,8 @@ mod tests { }; // Verify should fail (recovered pubkey won't match because message differs) - let result = address.verify_bytes_against_witness(&witness, verify_bytes); + let result = + address.verify_bytes_against_witness(&witness, verify_bytes, PlatformVersion::latest()); assert!( result.is_err(), "P2PKH verification should fail with wrong data" @@ -954,7 +968,11 @@ mod tests { }; // Verify should fail (recovered pubkey hash won't match address) - let result = address.verify_bytes_against_witness(&witness, signable_bytes); + let result = address.verify_bytes_against_witness( + &witness, + signable_bytes, + PlatformVersion::latest(), + ); assert!( result.is_err(), "P2PKH verification should fail when signed with wrong key" @@ -995,7 +1013,11 @@ mod tests { }; // Verify should succeed - let result = address.verify_bytes_against_witness(&witness, signable_bytes); + let result = address.verify_bytes_against_witness( + &witness, + signable_bytes, + PlatformVersion::latest(), + ); assert!( result.is_ok(), "P2SH 2-of-3 multisig verification should succeed: {:?}", @@ -1032,7 +1054,11 @@ mod tests { }; // Verify should succeed - let result = address.verify_bytes_against_witness(&witness, signable_bytes); + let result = address.verify_bytes_against_witness( + &witness, + signable_bytes, + PlatformVersion::latest(), + ); assert!( result.is_ok(), "P2SH 2-of-3 multisig with keys 1 and 2 should succeed: {:?}", @@ -1068,7 +1094,11 @@ mod tests { }; // Verify should fail - let result = address.verify_bytes_against_witness(&witness, signable_bytes); + let result = address.verify_bytes_against_witness( + &witness, + signable_bytes, + PlatformVersion::latest(), + ); assert!( result.is_err(), "P2SH should fail with only 1 signature when 2 required" @@ -1107,7 +1137,11 @@ mod tests { }; // Verify should fail (script doesn't hash to address) - let result = address.verify_bytes_against_witness(&witness, signable_bytes); + let result = address.verify_bytes_against_witness( + &witness, + signable_bytes, + PlatformVersion::latest(), + ); assert!( result.is_err(), "P2SH should fail when script hash doesn't match address" @@ -1148,8 +1182,11 @@ mod tests { let p2pkh_witness = AddressWitness::P2pkh { signature: BinaryData::new(p2pkh_sig), }; - let p2pkh_result = - p2pkh_address.verify_bytes_against_witness(&p2pkh_witness, signable_bytes); + let p2pkh_result = p2pkh_address.verify_bytes_against_witness( + &p2pkh_witness, + signable_bytes, + PlatformVersion::latest(), + ); assert!( p2pkh_result.is_ok(), "P2PKH redemption should succeed: {:?}", @@ -1163,7 +1200,11 @@ mod tests { signatures: vec![BinaryData::new(p2sh_sig0), BinaryData::new(p2sh_sig2)], redeem_script: BinaryData::new(redeem_script), }; - let p2sh_result = p2sh_address.verify_bytes_against_witness(&p2sh_witness, signable_bytes); + let p2sh_result = p2sh_address.verify_bytes_against_witness( + &p2sh_witness, + signable_bytes, + PlatformVersion::latest(), + ); assert!( p2sh_result.is_ok(), "P2SH redemption should succeed: {:?}", @@ -1192,7 +1233,11 @@ mod tests { signatures: vec![BinaryData::new(vec![0x30, 0x44])], redeem_script: BinaryData::new(vec![0x52]), }; - let result = p2pkh_address.verify_bytes_against_witness(&p2sh_witness, signable_bytes); + let result = p2pkh_address.verify_bytes_against_witness( + &p2sh_witness, + signable_bytes, + PlatformVersion::latest(), + ); assert!(result.is_err()); assert!(result .unwrap_err() @@ -1203,7 +1248,11 @@ mod tests { let p2pkh_witness = AddressWitness::P2pkh { signature: BinaryData::new(vec![0x30, 0x44]), }; - let result = p2sh_address.verify_bytes_against_witness(&p2pkh_witness, signable_bytes); + let result = p2sh_address.verify_bytes_against_witness( + &p2pkh_witness, + signable_bytes, + PlatformVersion::latest(), + ); assert!(result.is_err()); assert!(result .unwrap_err() diff --git a/packages/rs-dpp/src/state_transition/mod.rs b/packages/rs-dpp/src/state_transition/mod.rs index ce7e77c4195..7c0b0bdf293 100644 --- a/packages/rs-dpp/src/state_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/mod.rs @@ -2404,6 +2404,7 @@ impl StateTransition { fn verify_ecdsa_hash_160_signature_by_public_key_hash( &self, public_key_hash: &[u8], + platform_version: &PlatformVersion, ) -> Result<(), ProtocolError> { let Some(signature) = self.signature() else { return Err(ProtocolError::InvalidVerificationWrongNumberOfElements { @@ -2419,15 +2420,19 @@ impl StateTransition { } let data = self.signable_bytes()?; let data_hash = double_sha(data); - signer::verify_hash_signature(&data_hash, signature.as_slice(), public_key_hash).map_err( - |e| { - ProtocolError::from(ConsensusError::SignatureError( - SignatureError::InvalidStateTransitionSignatureError( - InvalidStateTransitionSignatureError::new(e.to_string()), - ), - )) - }, - ) + ecdsa::verify_hash_signature( + &data_hash, + signature.as_slice(), + public_key_hash, + platform_version, + )? + .map_err(|e| { + ProtocolError::from(ConsensusError::SignatureError( + SignatureError::InvalidStateTransitionSignatureError( + InvalidStateTransitionSignatureError::new(e.to_string()), + ), + )) + }) } #[cfg(feature = "state-transition-validation")] @@ -3428,6 +3433,91 @@ mod tests { } } + // An ECDSA_HASH160 key is checked by recovering the public key, which takes any S and either + // header form. From protocol version 15 (`verify_hash_signature` 1) the two twins a third + // party can derive from a valid signature, the high-S one and the one whose header names an + // uncompressed key, are refused; protocol version 14 keeps accepting them for replay. + // Masternode votes, signed by an ECDSA_HASH160 VOTING key, take the same path. + #[cfg(feature = "state-transition-signing")] + #[test] + fn should_refuse_an_ecdsa_hash160_signature_twin_from_protocol_version_15() { + use crate::identity::identity_public_key::v0::IdentityPublicKeyV0; + use crate::tests::utils::{high_s_twin, uncompressed_header_twin}; + use secp256k1::{PublicKey as SecpPublicKey, SecretKey}; + + let bls = crate::bls::native_bls::NativeBlsModule; + let private_key = [0x21; 32]; + let public_key = SecpPublicKey::from_secret_key( + &SecretKey::from_secret_bytes(private_key).expect("a valid ECDSA private key"), + ); + let key_hash = ripemd160_sha256(&public_key.serialize()); + + let latest = PlatformVersion::latest(); + let last_without_the_check = PlatformVersion::get(14).expect("protocol version 14"); + + for (transition, key_id, purpose, label) in [ + (sample_transfer_st(), 11, Purpose::TRANSFER, "transfer"), + ( + sample_masternode_vote_st(), + 5, + Purpose::VOTING, + "masternode vote", + ), + ] { + let key: IdentityPublicKey = IdentityPublicKeyV0 { + id: key_id, + purpose, + security_level: SecurityLevel::CRITICAL, + key_type: KeyType::ECDSA_HASH160, + data: key_hash.to_vec().into(), + ..Default::default() + } + .into(); + + let mut signed = transition; + signed + .sign_by_private_key(&private_key, KeyType::ECDSA_HASH160, &bls) + .expect("the key signs"); + let signature = signed.signature().expect("signed").to_vec(); + + for platform_version in [latest, last_without_the_check] { + signed + .verify_identity_signed_signature(&key, &bls, platform_version) + .unwrap_or_else(|e| { + panic!( + "{label}: the low-S signature verifies at protocol version {}: {e:?}", + platform_version.protocol_version + ) + }); + } + for (twin, twin_label) in [ + (high_s_twin(&signature), "high-S twin"), + ( + uncompressed_header_twin(&signature), + "uncompressed header twin", + ), + ] { + let mut malleated = signed.clone(); + malleated.set_signature(BinaryData::new(twin)); + malleated + .verify_identity_signed_signature(&key, &bls, last_without_the_check) + .unwrap_or_else(|e| { + panic!("{label}: protocol version 14 accepts the {twin_label}: {e:?}") + }); + let error = malleated + .verify_identity_signed_signature(&key, &bls, latest) + .expect_err("the twin is refused"); + assert!( + matches!(&error, ProtocolError::ConsensusError(consensus_error) + if matches!(&**consensus_error, ConsensusError::SignatureError( + SignatureError::InvalidStateTransitionSignatureError(_) + ))), + "{label}, {twin_label}: {error:?}" + ); + } + } + } + fn sample_batch_st_with_delete() -> StateTransition { let base = DocumentBaseTransition::V0(DocumentBaseTransitionV0 { id: Identifier::from([1u8; 32]), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funding_from_asset_lock_transition/signing_tests.rs b/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funding_from_asset_lock_transition/signing_tests.rs index 94b90c44637..55959db9056 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funding_from_asset_lock_transition/signing_tests.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funding_from_asset_lock_transition/signing_tests.rs @@ -145,7 +145,7 @@ async fn try_from_asset_lock_with_signer_and_private_key_signs_single_p2pkh_inpu .expect("signable_bytes"); let input_addr = v0.inputs.keys().next().expect("one input"); input_addr - .verify_bytes_against_witness(&v0.input_witnesses[0], &signable) + .verify_bytes_against_witness(&v0.input_witnesses[0], &signable, PlatformVersion::latest()) .expect("witness should verify against signable bytes"); } @@ -187,7 +187,7 @@ async fn try_from_asset_lock_with_signer_and_private_key_signs_multiple_inputs() .signable_bytes() .expect("signable_bytes"); for (addr, witness) in v0.inputs.keys().zip(v0.input_witnesses.iter()) { - addr.verify_bytes_against_witness(witness, &signable) + addr.verify_bytes_against_witness(witness, &signable, PlatformVersion::latest()) .expect("witness should verify against signable bytes"); } } @@ -299,6 +299,6 @@ async fn try_from_asset_lock_with_signers_produces_matching_signature() { .expect("signable_bytes"); let input_addr = v0.inputs.keys().next().expect("one input"); input_addr - .verify_bytes_against_witness(&v0.input_witnesses[0], &signable) + .verify_bytes_against_witness(&v0.input_witnesses[0], &signable, PlatformVersion::latest()) .expect("witness should verify against signable bytes"); } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funds_transfer_transition/signing_tests.rs b/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funds_transfer_transition/signing_tests.rs index 680010c9051..ce1b814137e 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funds_transfer_transition/signing_tests.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funds_transfer_transition/signing_tests.rs @@ -241,7 +241,7 @@ fn verify_transition_signatures( .enumerate() { let _operations = address - .verify_bytes_against_witness(witness, &signable_bytes) + .verify_bytes_against_witness(witness, &signable_bytes, PlatformVersion::latest()) .map_err(|e| { ProtocolError::Generic(format!("Witness {} verification failed: {}", i, e)) })?; diff --git a/packages/rs-dpp/src/state_transition/traits/state_transition_witness_validation.rs b/packages/rs-dpp/src/state_transition/traits/state_transition_witness_validation.rs index ec9d56ce610..132e1c97ae9 100644 --- a/packages/rs-dpp/src/state_transition/traits/state_transition_witness_validation.rs +++ b/packages/rs-dpp/src/state_transition/traits/state_transition_witness_validation.rs @@ -3,6 +3,8 @@ use crate::consensus::signature::InvalidStateTransitionSignatureError; use crate::serialization::Signable; use crate::state_transition::StateTransitionWitnessSigned; use crate::validation::SimpleConsensusValidationResult; +use crate::ProtocolError; +use platform_version::version::PlatformVersion; /// Result of witness validation, containing both the validation result and the operations performed. pub struct WitnessValidationResult { @@ -46,45 +48,61 @@ pub trait StateTransitionWitnessValidation: StateTransitionWitnessSigned + Signa /// /// # Arguments /// * `signable_bytes` - The bytes that were signed (typically from `state_transition.signable_bytes()`) + /// * `platform_version` - Selects `verify_hash_signature` for P2PKH witnesses /// /// # Returns - /// * `WitnessValidationResult` - Contains validation result and operations performed - fn validate_witnesses(&self, signable_bytes: &[u8]) -> WitnessValidationResult { + /// * `Ok(WitnessValidationResult)` - Contains validation result and operations performed + /// * `Err(ProtocolError::UnknownVersionMismatch)` - This build does not know the selected + /// `verify_hash_signature` version + fn validate_witnesses( + &self, + signable_bytes: &[u8], + platform_version: &PlatformVersion, + ) -> Result { let inputs = self.inputs(); let witnesses = self.witnesses(); // Verify witness count matches input count before zipping if inputs.len() != witnesses.len() { - return WitnessValidationResult::new_with_error( + return Ok(WitnessValidationResult::new_with_error( InvalidStateTransitionSignatureError::new(format!( "Number of witnesses ({}) does not match number of inputs ({})", witnesses.len(), inputs.len() )) .into(), - ); + )); } let mut total_operations = AddressWitnessVerificationOperations::new(); // Validate each witness against its corresponding input address for (i, (address, witness)) in inputs.keys().zip(witnesses.iter()).enumerate() { - match address.verify_bytes_against_witness(witness, signable_bytes) { + match address.verify_bytes_against_witness(witness, signable_bytes, platform_version) { Ok(operations) => { total_operations.combine(&operations); } + // A version this build does not know is an internal error, not a witness that + // does not verify. `verify_bytes_against_witness` returns it only from the + // `verify_hash_signature` dispatcher, and every protocol version selects a known + // `verify_hash_signature`, so no witness that maps to a consensus error below is + // turned into this one. + Err(e @ ProtocolError::UnknownVersionMismatch { .. }) => return Err(e), Err(e) => { - return WitnessValidationResult::new_with_error( + return Ok(WitnessValidationResult::new_with_error( InvalidStateTransitionSignatureError::new(format!( "Witness {} verification failed: {}", i, e )) .into(), - ); + )); } } } - WitnessValidationResult::new(SimpleConsensusValidationResult::new(), total_operations) + Ok(WitnessValidationResult::new( + SimpleConsensusValidationResult::new(), + total_operations, + )) } } diff --git a/packages/rs-dpp/src/state_transition/verify_identity_signed_signature/mod.rs b/packages/rs-dpp/src/state_transition/verify_identity_signed_signature/mod.rs index 15b12d00b71..d014e12a81a 100644 --- a/packages/rs-dpp/src/state_transition/verify_identity_signed_signature/mod.rs +++ b/packages/rs-dpp/src/state_transition/verify_identity_signed_signature/mod.rs @@ -12,6 +12,10 @@ impl StateTransition { /// Generation 0 (protocol versions 1 to 13) accepts a BLS12_381 signature that is well /// formed but does not verify: it fails only when the BLS module errors, never on its /// `Ok(false)`. Generation 1 refuses that signature too. + /// + /// An ECDSA_HASH160 key is checked by recovering the public key, through + /// `verify_hash_signature`, which `platform_version` selects too: from protocol version 15 it + /// refuses a high-S signature and a header naming an uncompressed key. pub fn verify_identity_signed_signature( &self, public_key: &IdentityPublicKey, @@ -23,8 +27,8 @@ impl StateTransition { .state_transition_method_versions .verify_identity_signed_signature { - 0 => self.verify_identity_signed_signature_v0(public_key, bls), - 1 => self.verify_identity_signed_signature_v1(public_key, bls), + 0 => self.verify_identity_signed_signature_v0(public_key, bls, platform_version), + 1 => self.verify_identity_signed_signature_v1(public_key, bls, platform_version), version => Err(ProtocolError::UnknownVersionMismatch { method: "StateTransition::verify_identity_signed_signature".to_string(), known_versions: vec![0, 1], diff --git a/packages/rs-dpp/src/state_transition/verify_identity_signed_signature/v0/mod.rs b/packages/rs-dpp/src/state_transition/verify_identity_signed_signature/v0/mod.rs index 6c99ca6a32d..6a29799acf8 100644 --- a/packages/rs-dpp/src/state_transition/verify_identity_signed_signature/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/verify_identity_signed_signature/v0/mod.rs @@ -4,6 +4,7 @@ use crate::identity::{IdentityPublicKey, KeyType}; use crate::state_transition::errors::{PublicKeyMismatchError, StateTransitionIsNotSignedError}; use crate::state_transition::StateTransition; use crate::{BlsModule, ProtocolError}; +use platform_version::version::PlatformVersion; impl StateTransition { /// Kept as is for replay: the BLS verdict is dropped, so a BLS12_381 signature that does @@ -13,18 +14,24 @@ impl StateTransition { &self, public_key: &IdentityPublicKey, bls: &impl BlsModule, + platform_version: &PlatformVersion, ) -> Result<(), ProtocolError> { - self.identity_signed_signature_verdict_v0(public_key, bls) + self.identity_signed_signature_verdict_v0(public_key, bls, platform_version) .map(|_| ()) } /// The checks of generation 0, returning whether the signature verifies. Today only the /// BLS12_381 arm returns `false`, for a signature that is well formed but does not verify; /// the ECDSA arms report a failed check as an error. Generation 1 runs the same checks. + /// + /// The ECDSA_HASH160 arm reads `platform_version` only to select `verify_hash_signature`: + /// 0, the check this arm made before, at protocol versions 1 to 14, and 1, which also refuses + /// a high-S signature and a header naming an uncompressed key, from 15. pub(super) fn identity_signed_signature_verdict_v0( &self, public_key: &IdentityPublicKey, bls: &impl BlsModule, + platform_version: &PlatformVersion, ) -> Result { // self.verify_public_key_level_and_purpose(public_key)?; if public_key.disabled_at().is_some() { @@ -51,7 +58,10 @@ impl StateTransition { let public_key_bytes = public_key.data().as_slice(); match public_key.key_type() { KeyType::ECDSA_HASH160 => self - .verify_ecdsa_hash_160_signature_by_public_key_hash(public_key_bytes) + .verify_ecdsa_hash_160_signature_by_public_key_hash( + public_key_bytes, + platform_version, + ) .map(|()| true), KeyType::ECDSA_SECP256K1 => self diff --git a/packages/rs-dpp/src/state_transition/verify_identity_signed_signature/v1/mod.rs b/packages/rs-dpp/src/state_transition/verify_identity_signed_signature/v1/mod.rs index 5d4e245656f..48433d7ba7a 100644 --- a/packages/rs-dpp/src/state_transition/verify_identity_signed_signature/v1/mod.rs +++ b/packages/rs-dpp/src/state_transition/verify_identity_signed_signature/v1/mod.rs @@ -4,6 +4,7 @@ use crate::identity::identity_public_key::accessors::v0::IdentityPublicKeyGetter use crate::identity::IdentityPublicKey; use crate::state_transition::StateTransition; use crate::{BlsModule, ProtocolError}; +use platform_version::version::PlatformVersion; impl StateTransition { /// Runs the checks of generation 0 and also refuses a signature they report does not @@ -13,8 +14,9 @@ impl StateTransition { &self, public_key: &IdentityPublicKey, bls: &impl BlsModule, + platform_version: &PlatformVersion, ) -> Result<(), ProtocolError> { - if self.identity_signed_signature_verdict_v0(public_key, bls)? { + if self.identity_signed_signature_verdict_v0(public_key, bls, platform_version)? { Ok(()) } else { Err(ProtocolError::from(ConsensusError::SignatureError( diff --git a/packages/rs-dpp/src/tests/utils/mod.rs b/packages/rs-dpp/src/tests/utils/mod.rs index 30661cd5785..b7343bdd363 100644 --- a/packages/rs-dpp/src/tests/utils/mod.rs +++ b/packages/rs-dpp/src/tests/utils/mod.rs @@ -284,3 +284,35 @@ pub fn new_block_header(timestamp_secs: Option) -> Header { time: timestamp_secs.unwrap_or_default(), } } + +/// `signature`, a 65-byte compact recoverable ECDSA signature, with S replaced by `n - S` and the +/// recovery id's parity flipped: the high-S twin a third party can derive from a valid low-S +/// signature. Key recovery accepts it like the original. +pub fn high_s_twin(signature: &[u8]) -> Vec { + let mut twin = signature.to_vec(); + let s: [u8; 32] = twin[33..].try_into().expect("a 65-byte signature"); + let negated = secp256k1::SecretKey::from_secret_bytes(s) + .expect("S is a valid scalar") + .negate(); + twin[33..].copy_from_slice(&negated.to_secret_bytes()); + // The header is 27 + recovery id, plus 4 for a compressed key. + let base = if twin[0] >= 31 { 31 } else { 27 }; + twin[0] = base + ((twin[0] - base) ^ 1); + twin +} + +/// `signature`, a 65-byte compact recoverable ECDSA signature made by a compressed key, with its +/// header rewritten from `31 + id` to `27 + id`, the header of an uncompressed key: a twin a +/// third party can derive from a valid signature without touching R or S. Key recovery accepts +/// it like the original, because it hashes the recovered key in its compressed form whatever +/// the header says. +pub fn uncompressed_header_twin(signature: &[u8]) -> Vec { + assert_eq!(signature.len(), 65, "a 65-byte compact signature"); + assert!( + (31..=34).contains(&signature[0]), + "the header of a compressed key" + ); + let mut twin = signature.to_vec(); + twin[0] -= 4; + twin +} diff --git a/packages/rs-dpp/src/util/ecdsa.rs b/packages/rs-dpp/src/util/ecdsa/mod.rs similarity index 79% rename from packages/rs-dpp/src/util/ecdsa.rs rename to packages/rs-dpp/src/util/ecdsa/mod.rs index 8145af267f2..7331f5c5e4b 100644 --- a/packages/rs-dpp/src/util/ecdsa.rs +++ b/packages/rs-dpp/src/util/ecdsa/mod.rs @@ -3,10 +3,19 @@ //! low-S twin, the same signature with S negated, so Platform checks S itself, at every protocol //! version. Accepting it would fork from nodes that refuse it and change the replay of chain //! history. +//! +//! A signature checked by recovering its public key ([`verify_hash_signature`]) is the +//! exception: every released Platform accepts a high-S one there, and one whose header names an +//! uncompressed key, so refusing them is a rule of protocol version 15, selected by +//! `verify_hash_signature`. use dashcore::crypto::ecdsa::{EcdsaError, EcdsaPublicKey, EcdsaSignature}; use dashcore::{sign_message, signer}; +mod verify_hash_signature; + +pub use verify_hash_signature::verify_hash_signature; + /// [`signer::verify_data_signature`], refusing a high-S signature with the error of a signature /// that does not verify. Every other input gets the result and the error `dashcore` gives. pub fn verify_data_signature( diff --git a/packages/rs-dpp/src/util/ecdsa/verify_hash_signature/mod.rs b/packages/rs-dpp/src/util/ecdsa/verify_hash_signature/mod.rs new file mode 100644 index 00000000000..99f0d027d06 --- /dev/null +++ b/packages/rs-dpp/src/util/ecdsa/verify_hash_signature/mod.rs @@ -0,0 +1,268 @@ +use crate::util::ecdsa::verify_hash_signature::v0::verify_hash_signature_v0; +use crate::util::ecdsa::verify_hash_signature::v1::verify_hash_signature_v1; +use crate::ProtocolError; +use platform_version::version::PlatformVersion; + +mod v0; +mod v1; + +/// Checks that `signature`, a 65-byte compact recoverable ECDSA signature over `data_hash`, was +/// made by the key whose HASH160 is `public_key_hash`, by recovering the key: an ECDSA_HASH160 +/// identity key, a P2PKH address witness, an asset lock's one-time key. +/// +/// Recovery alone leaves a third party two ways to turn a valid signature into another valid +/// one, and so to change the hash of the transition carrying it: +/// +/// - it takes any S, so the signature stays valid with S replaced by `n - S` and the recovery +/// id's parity flipped; +/// - it hashes the recovered key in its compressed form whatever the header says, so the +/// signature stays valid with its header rewritten from `31 + id` (a compressed key) to +/// `27 + id` (an uncompressed one). +/// +/// # Parameters +/// +/// - `data_hash`: the 32-byte digest that was signed. +/// - `signature`: the compact recoverable signature. +/// - `public_key_hash`: the HASH160 of the compressed public key expected to have signed. +/// - `platform_version`: selects the rule through +/// `dpp.state_transition_method_versions.verify_hash_signature`. 0 is +/// `dashcore::signer::verify_hash_signature`, which accepts both rewrites (protocol versions +/// 1 to 14); 1 also refuses a high-S signature and a header that does not name a compressed +/// key. +/// +/// # Returns +/// +/// `Ok(Ok(()))` when the signature is valid, `Ok(Err(_))` with the reason when it is not, and +/// `Err(ProtocolError::UnknownVersionMismatch)` for a version this build does not know. +pub fn verify_hash_signature( + data_hash: &[u8], + signature: &[u8], + public_key_hash: &[u8], + platform_version: &PlatformVersion, +) -> Result, ProtocolError> { + match platform_version + .dpp + .state_transition_method_versions + .verify_hash_signature + { + 0 => Ok(verify_hash_signature_v0( + data_hash, + signature, + public_key_hash, + )), + 1 => Ok(verify_hash_signature_v1( + data_hash, + signature, + public_key_hash, + )), + version => Err(ProtocolError::UnknownVersionMismatch { + method: "verify_hash_signature".to_string(), + known_versions: vec![0, 1], + received: version, + }), + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::tests::utils::{high_s_twin, uncompressed_header_twin}; + use dashcore::crypto::ecdsa::{EcdsaError, EcdsaSignature}; + use dashcore::signer::{double_sha, sign_hash}; + use dashcore::{sign_message, signer, PrivateKey}; + + /// Half the curve order, `n / 2`, the largest low S. + const HALF_ORDER: [u8; 32] = [ + 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x5d, 0x57, 0x6e, 0x73, 0x57, 0xa4, 0x50, 0x1d, 0xdf, 0xe9, 0x2f, 0x46, 0x68, 0x1b, + 0x20, 0xa0, + ]; + /// The curve order `n`. + const ORDER: [u8; 32] = [ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, + 0x41, 0x41, + ]; + + fn signature_s_is_low(signature: &[u8]) -> bool { + sign_message::from_slice(signature) + .expect("a compact recoverable signature") + .signature() + .expect("a valid signature") + .is_low_s() + } + + /// A low-S signature over a digest, the digest, and the signing key's HASH160. + fn fixture() -> (Vec, Vec, Vec) { + let secret = [0x11; 32]; + let key_hash = PrivateKey::from_byte_array(&secret, dashcore::Network::Testnet) + .expect("a valid key") + .public_key() + .pubkey_hash(); + let digest = double_sha(b"a message"); + let signature = sign_hash(&digest, &secret).expect("signs").to_vec(); + (digest, signature, key_hash.to_byte_array().to_vec()) + } + + /// `signature` with its S replaced by `s`. + fn with_s(signature: &[u8], s: [u8; 32]) -> Vec { + let mut changed = signature.to_vec(); + changed[33..].copy_from_slice(&s); + changed + } + + /// `signature` with its header byte replaced by `header`. + fn with_header(signature: &[u8], header: u8) -> Vec { + let mut changed = signature.to_vec(); + changed[0] = header; + changed + } + + fn protocol_version(version: u32) -> &'static PlatformVersion { + PlatformVersion::get(version).expect("a known protocol version") + } + + #[test] + fn should_hold_s_equal_to_half_the_order_low_and_one_more_high() { + let mut compact = [1u8; 64]; + compact[32..].copy_from_slice(&HALF_ORDER); + assert!(EcdsaSignature::from_bytes(&compact) + .expect("a valid signature") + .is_low_s()); + compact[63] += 1; + assert!(!EcdsaSignature::from_bytes(&compact) + .expect("a valid signature") + .is_low_s()); + } + + #[test] + fn should_build_a_high_s_twin_that_recovery_alone_accepts() { + let (digest, signature, key_hash) = fixture(); + let twin = high_s_twin(&signature); + assert!(signature_s_is_low(&signature)); + assert!(!signature_s_is_low(&twin)); + signer::verify_hash_signature(&digest, &twin, &key_hash) + .expect("recovery alone accepts the twin"); + } + + #[test] + fn should_build_an_uncompressed_header_twin_that_recovery_alone_accepts() { + let (digest, signature, key_hash) = fixture(); + let twin = uncompressed_header_twin(&signature); + assert_eq!(twin[0] + 4, signature[0]); + assert_eq!(twin[1..], signature[1..]); + assert!(signature_s_is_low(&twin)); + signer::verify_hash_signature(&digest, &twin, &key_hash) + .expect("recovery alone accepts the twin"); + } + + #[test] + fn should_accept_the_high_s_twin_up_to_protocol_version_14() { + let (digest, signature, key_hash) = fixture(); + let twin = high_s_twin(&signature); + for version in [1, 13, 14] { + let platform_version = protocol_version(version); + verify_hash_signature(&digest, &signature, &key_hash, platform_version) + .expect("a known version") + .expect("the low-S signature is valid"); + verify_hash_signature(&digest, &twin, &key_hash, platform_version) + .expect("a known version") + .expect("protocol version 14 and earlier accept the high-S twin"); + } + } + + #[test] + fn should_refuse_the_high_s_twin_at_the_latest_protocol_version() { + let (digest, signature, key_hash) = fixture(); + let platform_version = PlatformVersion::latest(); + verify_hash_signature(&digest, &signature, &key_hash, platform_version) + .expect("a known version") + .expect("the low-S signature is valid"); + let error = verify_hash_signature( + &digest, + &high_s_twin(&signature), + &key_hash, + platform_version, + ) + .expect("a known version") + .expect_err("the high-S twin is refused"); + assert_eq!(error.to_string(), EcdsaError::VerifyFailed.to_string()); + } + + #[test] + fn should_accept_the_uncompressed_header_twin_up_to_protocol_version_14() { + let (digest, signature, key_hash) = fixture(); + let twin = uncompressed_header_twin(&signature); + for version in [1, 13, 14] { + verify_hash_signature(&digest, &twin, &key_hash, protocol_version(version)) + .expect("a known version") + .expect("protocol version 14 and earlier accept the uncompressed header"); + } + } + + #[test] + fn should_refuse_the_uncompressed_header_twin_at_the_latest_protocol_version() { + let (digest, signature, key_hash) = fixture(); + let platform_version = PlatformVersion::latest(); + // The twin, and the twin of the high-S twin: neither rewrite hides the other. + for twin in [ + uncompressed_header_twin(&signature), + uncompressed_header_twin(&high_s_twin(&signature)), + ] { + let error = verify_hash_signature(&digest, &twin, &key_hash, platform_version) + .expect("a known version") + .expect_err("the uncompressed header is refused"); + assert_eq!(error.to_string(), EcdsaError::VerifyFailed.to_string()); + } + } + + /// Of the eight headers recovery parses, 27 to 34, the latest protocol version accepts one: + /// the compressed-key header carrying the recovery id that recovers the signing key. + #[test] + fn should_accept_a_single_header_at_the_latest_protocol_version() { + let (digest, signature, key_hash) = fixture(); + let accepted: Vec = (27..=34) + .filter(|header| { + let mut candidate = signature.clone(); + candidate[0] = *header; + verify_hash_signature(&digest, &candidate, &key_hash, PlatformVersion::latest()) + .expect("a known version") + .is_ok() + }) + .collect(); + assert_eq!(accepted, vec![signature[0]]); + } + + /// A signature recovery already refuses (another key, a wrong length, S zero or not below the + /// curve order, a header outside 27 to 34) fails with the library's own error at both + /// versions. + #[test] + fn should_fail_an_invalid_signature_with_the_same_error_at_both_versions() { + let (digest, signature, key_hash) = fixture(); + let wrong_key_hash = [7u8; 20]; + let cases = [ + (signature.clone(), wrong_key_hash.to_vec(), "another key"), + (signature[..64].to_vec(), key_hash.clone(), "a wrong length"), + (with_s(&signature, [0; 32]), key_hash.clone(), "S zero"), + (with_s(&signature, ORDER), key_hash.clone(), "S equal to n"), + ( + with_s(&signature, [0xff; 32]), + key_hash.clone(), + "S above n", + ), + (with_header(&signature, 26), key_hash.clone(), "header 26"), + (with_header(&signature, 35), key_hash.clone(), "header 35"), + ]; + for (signature, key_hash, label) in cases { + let legacy = + verify_hash_signature(&digest, &signature, &key_hash, protocol_version(14)) + .expect("a known version") + .expect_err(label); + let latest = + verify_hash_signature(&digest, &signature, &key_hash, PlatformVersion::latest()) + .expect("a known version") + .expect_err(label); + assert_eq!(legacy.to_string(), latest.to_string(), "{label}"); + } + } +} diff --git a/packages/rs-dpp/src/util/ecdsa/verify_hash_signature/v0/mod.rs b/packages/rs-dpp/src/util/ecdsa/verify_hash_signature/v0/mod.rs new file mode 100644 index 00000000000..aa189caa20d --- /dev/null +++ b/packages/rs-dpp/src/util/ecdsa/verify_hash_signature/v0/mod.rs @@ -0,0 +1,12 @@ +use dashcore::signer; + +/// Generation 0, protocol versions 1 to 14: `dashcore`'s recovery check and nothing else. It +/// accepts a high-S signature and a header naming an uncompressed key. Kept as is for replay. +#[inline(always)] +pub(super) fn verify_hash_signature_v0( + data_hash: &[u8], + signature: &[u8], + public_key_hash: &[u8], +) -> Result<(), anyhow::Error> { + signer::verify_hash_signature(data_hash, signature, public_key_hash) +} diff --git a/packages/rs-dpp/src/util/ecdsa/verify_hash_signature/v1/mod.rs b/packages/rs-dpp/src/util/ecdsa/verify_hash_signature/v1/mod.rs new file mode 100644 index 00000000000..9d66cfd7250 --- /dev/null +++ b/packages/rs-dpp/src/util/ecdsa/verify_hash_signature/v1/mod.rs @@ -0,0 +1,25 @@ +use anyhow::ensure; +use dashcore::crypto::ecdsa::EcdsaError; +use dashcore::{sign_message, signer}; + +/// Generation 1, from protocol version 15: `dashcore`'s recovery check, then the signature must +/// be the one form a signer produces. A header naming an uncompressed key (`27 + id` in place +/// of `31 + id`) and an S in the upper half of the curve order are refused with +/// [`EcdsaError::VerifyFailed`], the error of a signature that does not verify. +/// +/// The library checks first, so every other input fails exactly as it does in generation 0, +/// with the library's own error. +#[inline(always)] +pub(super) fn verify_hash_signature_v1( + data_hash: &[u8], + signature: &[u8], + public_key_hash: &[u8], +) -> Result<(), anyhow::Error> { + signer::verify_hash_signature(data_hash, signature, public_key_hash)?; + // `dashcore` parsed the signature to recover its key, so parsing it again succeeds. + let signature = sign_message::from_slice(signature)?; + // The key hash compared above is the compressed key's, whatever the header says. + ensure!(signature.is_compressed()?, EcdsaError::VerifyFailed); + ensure!(signature.signature()?.is_low_s(), EcdsaError::VerifyFailed); + Ok(()) +} diff --git a/packages/rs-dpp/tests/ecdsa_compatibility.rs b/packages/rs-dpp/tests/ecdsa_compatibility.rs index a5885ffe1ca..936d0404c35 100644 --- a/packages/rs-dpp/tests/ecdsa_compatibility.rs +++ b/packages/rs-dpp/tests/ecdsa_compatibility.rs @@ -19,6 +19,7 @@ use dpp::identity::{IdentityPublicKey, KeyType, Purpose, SecurityLevel}; use dpp::secp256k1::{ecdsa::RecoverableSignature, ecdsa::RecoveryId, Message}; use dpp::serialization::PlatformMessageSignable; use dpp::util::ecdsa::verify_data_signature; +use dpp::version::PlatformVersion; use dpp::ProtocolError; use vectors::{ECDSA_PUBLIC_KEY, TRANSFER_ECDSA_SIGNATURE, TRANSFER_HASH, TRANSFER_SIGNABLE}; @@ -76,7 +77,7 @@ fn should_preserve_witness_fee_operations_for_recovery_and_multisig_search() { }; assert_eq!( address - .verify_bytes_against_witness(&witness, &data) + .verify_bytes_against_witness(&witness, &data, PlatformVersion::latest()) .unwrap(), AddressWitnessVerificationOperations::for_p2pkh(data.len()) ); @@ -95,12 +96,12 @@ fn should_preserve_witness_fee_operations_for_recovery_and_multisig_search() { }; assert_eq!( address - .verify_bytes_against_witness(&witness, &data) + .verify_bytes_against_witness(&witness, &data, PlatformVersion::latest()) .unwrap(), AddressWitnessVerificationOperations::for_p2sh_multisig(2, data.len()) ); assert!(address - .verify_bytes_against_witness(&witness, b"different message") + .verify_bytes_against_witness(&witness, b"different message", PlatformVersion::latest()) .is_err()); } @@ -275,6 +276,61 @@ fn should_reject_high_s_verification_but_accept_high_s_recovery() { .unwrap(); } +/// The historical signature with its header rewritten from that of a compressed key to that of +/// an uncompressed one: R, S and the recovery id are untouched. Key recovery hashes the recovered +/// key in its compressed form either way. +fn uncompressed_header_twin() -> Vec { + let (_, mut signature, _) = fixture(); + assert_eq!(signature[0], 31); + signature[0] = 27; + signature +} + +/// A P2PKH witness is checked by recovering the key, which takes any S and either header form. +/// Protocol version 14 accepts the two twins a third party can derive from the historical +/// signature, the high-S one and the one whose header names an uncompressed key, for replay; +/// from protocol version 15 (`verify_hash_signature` 1) each is refused as a signature that does +/// not verify. The signature itself is accepted at both. +#[test] +fn should_refuse_a_p2pkh_witness_twin_from_protocol_version_15() { + let (data, signature, public_key) = fixture(); + let address = PlatformAddress::P2pkh(hash160::Hash::hash(&public_key).to_byte_array()); + let witness = |signature: Vec| AddressWitness::P2pkh { + signature: signature.into(), + }; + let last_without_the_check = PlatformVersion::get(14).unwrap(); + let latest = PlatformVersion::latest(); + for platform_version in [last_without_the_check, latest] { + assert_eq!( + address + .verify_bytes_against_witness(&witness(signature.clone()), &data, platform_version) + .unwrap(), + AddressWitnessVerificationOperations::for_p2pkh(data.len()) + ); + } + for twin in [high_s_twin(), uncompressed_header_twin()] { + assert_eq!( + address + .verify_bytes_against_witness(&witness(twin.clone()), &data, last_without_the_check) + .unwrap(), + AddressWitnessVerificationOperations::for_p2pkh(data.len()) + ); + match address + .verify_bytes_against_witness(&witness(twin), &data, latest) + .unwrap_err() + { + ProtocolError::AddressWitnessError(message) => assert_eq!( + message, + format!( + "P2PKH signature verification failed: {}", + EcdsaError::VerifyFailed + ) + ), + error => panic!("unexpected error: {error}"), + } + } +} + #[test] fn should_reject_a_high_s_signature_in_a_multisig_witness() { let (data, signature, public_key) = fixture(); @@ -287,10 +343,10 @@ fn should_reject_a_high_s_signature_in_a_multisig_witness() { redeem_script: script.clone().into(), }; address - .verify_bytes_against_witness(&witness(signature), &data) + .verify_bytes_against_witness(&witness(signature), &data, PlatformVersion::latest()) .unwrap(); match address - .verify_bytes_against_witness(&witness(high_s_twin()), &data) + .verify_bytes_against_witness(&witness(high_s_twin()), &data, PlatformVersion::latest()) .unwrap_err() { ProtocolError::AddressWitnessError(message) => { @@ -319,7 +375,7 @@ fn should_charge_every_verification_a_refused_high_s_twin_takes_in_a_multisig_wi }; assert_eq!( address - .verify_bytes_against_witness(&witness, &data) + .verify_bytes_against_witness(&witness, &data, PlatformVersion::latest()) .unwrap(), AddressWitnessVerificationOperations::for_p2sh_multisig(3, data.len()) ); @@ -367,7 +423,7 @@ fn should_preserve_multisig_malformed_signature_error() { redeem_script: script.into(), }; let error = address - .verify_bytes_against_witness(&witness, &data) + .verify_bytes_against_witness(&witness, &data, PlatformVersion::latest()) .unwrap_err(); match error { ProtocolError::AddressWitnessError(message) => { @@ -389,7 +445,7 @@ fn should_preserve_multisig_malformed_public_key_error() { redeem_script: script.into(), }; let error = address - .verify_bytes_against_witness(&witness, &data) + .verify_bytes_against_witness(&witness, &data, PlatformVersion::latest()) .unwrap_err(); match error { ProtocolError::AddressWitnessError(message) => { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/address_witnesses.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/address_witnesses.rs index c3dc54460ae..b3b4066a628 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/address_witnesses.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/address_witnesses.rs @@ -78,21 +78,23 @@ impl StateTransitionAddressWitnessValidationV0 for StateTransition { let witness_result = match self { StateTransition::AddressFundsTransfer(st) => { - st.validate_witnesses(&signable_bytes) + st.validate_witnesses(&signable_bytes, platform_version) } StateTransition::IdentityCreateFromAddresses(st) => { - st.validate_witnesses(&signable_bytes) + st.validate_witnesses(&signable_bytes, platform_version) } StateTransition::IdentityTopUpFromAddresses(st) => { - st.validate_witnesses(&signable_bytes) + st.validate_witnesses(&signable_bytes, platform_version) } StateTransition::AddressCreditWithdrawal(st) => { - st.validate_witnesses(&signable_bytes) + st.validate_witnesses(&signable_bytes, platform_version) } StateTransition::AddressFundingFromAssetLock(st) => { - st.validate_witnesses(&signable_bytes) + st.validate_witnesses(&signable_bytes, platform_version) + } + StateTransition::Shield(st) => { + st.validate_witnesses(&signable_bytes, platform_version) } - StateTransition::Shield(st) => st.validate_witnesses(&signable_bytes), // These state transitions don't have address witness validation StateTransition::DataContractCreate(_) | StateTransition::DataContractUpdate(_) @@ -120,7 +122,7 @@ impl StateTransitionAddressWitnessValidationV0 for StateTransition { | StateTransition::IdentityCreateFromShieldedPool(_) => { return Ok(SimpleConsensusValidationResult::new()); } - }; + }?; // Add operations to execution context for fee calculation add_witness_verification_operations_to_context( @@ -511,5 +513,27 @@ mod tests { assert_eq!(signature_verifications(&exec_ctx), 16); } } + + /// A `verify_hash_signature` version this build does not know is an internal error, not + /// a witness that does not verify: it must not become an unpaid consensus refusal. + #[tokio::test] + async fn should_return_an_internal_error_for_an_unknown_hash_signature_version() { + let mut platform_version = PlatformVersion::latest().clone(); + platform_version + .dpp + .state_transition_method_versions + .verify_hash_signature = 99; + let st = signed_transfer(1, PlatformVersion::latest()).await; + let mut exec_ctx = + StateTransitionExecutionContext::default_for_platform_version(&platform_version) + .unwrap(); + let result = st.validate_address_witnesses(&mut exec_ctx, &platform_version); + assert_matches!( + result, + Err(Error::Protocol( + dpp::ProtocolError::UnknownVersionMismatch { received: 99, .. } + )) + ); + } } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funding_from_asset_lock/tests.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funding_from_asset_lock/tests.rs index 130ccb4fd33..4ca6a8350e4 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funding_from_asset_lock/tests.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funding_from_asset_lock/tests.rs @@ -1200,6 +1200,99 @@ mod tests { ); } + /// The asset lock's one-time key is checked by recovering the public key, which takes + /// any S and either header form. Protocol version 14 accepts the high-S twin of the + /// signature and the twin whose header names an uncompressed key, for replay; from + /// protocol version 15 a block refuses each unpaid, with the error of a signature that + /// does not verify, and leaves the asset lock unused. The signature the key made is + /// accepted at both. + #[tokio::test] + async fn should_refuse_an_asset_lock_signature_twin_from_protocol_version_15() { + use crate::execution::validation::state_transition::state_transitions::test_helpers::process_transition_and_commit; + use dpp::consensus::signature::SignatureError; + use dpp::tests::utils::{high_s_twin, uncompressed_header_twin}; + + let latest = PlatformVersion::latest().protocol_version; + let twins: [(&str, fn(&[u8]) -> Vec); 2] = [ + ("high-S twin", high_s_twin), + ("uncompressed header twin", uncompressed_header_twin), + ]; + // (protocol version, the twins submitted before the signature itself). The asset + // lock is consumed by the first transition a block accepts, so at 14 each twin gets + // its own platform, as does the signature. + for (protocol_version, submitted) in [ + (14, &twins[..0]), + (14, &twins[..1]), + (14, &twins[1..]), + (latest, &twins[..]), + ] { + let platform_version = + PlatformVersion::get(protocol_version).expect("known protocol version"); + let platform = TestPlatformBuilder::new() + .with_config(PlatformConfig { + testing_configs: PlatformTestConfig { + disable_instant_lock_signature_verification: true, + ..Default::default() + }, + ..Default::default() + }) + .with_initial_protocol_version(protocol_version) + .build_with_mock_rpc() + .set_genesis_state(); + + let signer = TestAddressSigner::new(); + let mut rng = StdRng::seed_from_u64(567); + let (asset_lock_proof, asset_lock_pk) = create_asset_lock_proof_with_key(&mut rng); + let mut outputs = BTreeMap::new(); + outputs.insert(create_platform_address(1), Some(dash_to_credits!(0.5))); + outputs.insert(create_platform_address(2), None); + let signed = create_signed_address_funding_from_asset_lock_transition( + asset_lock_proof, + &asset_lock_pk, + &signer, + BTreeMap::new(), + outputs, + vec![AddressFundsFeeStrategyStep::ReduceOutput(0)], + ) + .await; + let signature = signed.signature().expect("signed").to_vec(); + + let mut asset_lock_used = false; + for (twin_label, twin) in submitted { + let mut malleated = signed.clone(); + malleated.set_signature(twin(&signature).into()); + let result = + process_transition_and_commit(&platform, malleated, platform_version); + if protocol_version == 14 { + assert_matches!( + result.execution_results().as_slice(), + [StateTransitionExecutionResult::SuccessfulExecution { .. }], + "protocol version 14 accepts the {twin_label}" + ); + asset_lock_used = true; + } else { + assert_matches!( + result.execution_results().as_slice(), + [StateTransitionExecutionResult::UnpaidConsensusError( + ConsensusError::SignatureError(SignatureError::BasicECDSAError(_)) + )], + "protocol version {protocol_version} refuses the {twin_label}" + ); + } + } + if !asset_lock_used { + // No twin was accepted, so the asset lock is unused and the signature the + // key made still funds. + let result = process_transition_and_commit(&platform, signed, platform_version); + assert_matches!( + result.execution_results().as_slice(), + [StateTransitionExecutionResult::SuccessfulExecution { .. }], + "protocol version {protocol_version} accepts the signature" + ); + } + } + } + #[tokio::test] async fn test_asset_lock_funding_to_multiple_addresses() { let platform_version = PlatformVersion::latest(); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funding_from_asset_lock/transform_into_action/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funding_from_asset_lock/transform_into_action/v0/mod.rs index d1c45b073c3..837251d90c4 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funding_from_asset_lock/transform_into_action/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funding_from_asset_lock/transform_into_action/v0/mod.rs @@ -6,10 +6,10 @@ use dpp::balances::credits::CREDITS_PER_DUFF; use dpp::consensus::basic::identity::IdentityAssetLockTransactionOutPointNotEnoughBalanceError; use dpp::consensus::signature::{BasicECDSAError, SignatureError}; -use dpp::dashcore::signer; use dpp::dashcore::{ScriptBuf, Txid}; use dpp::identity::state_transition::AssetLockProved; use dpp::identity::KeyType; +use dpp::util::ecdsa::verify_hash_signature; use dpp::prelude::ConsensusValidationResult; @@ -175,11 +175,15 @@ impl AddressFundingFromAssetLockStateTransitionTransformIntoActionValidationV0 SignatureVerificationOperation::new(KeyType::ECDSA_HASH160), )); - if let Err(e) = signer::verify_hash_signature( + // `verify_hash_signature` 0 at protocol versions 14 and earlier is the + // `dashcore::signer::verify_hash_signature` call this site made before; 1 also + // refuses a high-S signature and a header naming an uncompressed key. + if let Err(e) = verify_hash_signature( signable_bytes_hasher.hash_bytes().as_slice(), self.signature().as_slice(), public_key_hash, - ) { + platform_version, + )? { return Ok(ConsensusValidationResult::new_with_error( SignatureError::BasicECDSAError(BasicECDSAError::new(e.to_string())).into(), )); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funds_transfer/tests.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funds_transfer/tests.rs index 7d1b89af779..3b41ad601e0 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funds_transfer/tests.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funds_transfer/tests.rs @@ -9256,4 +9256,128 @@ mod tests { } } } + + // ========================================== + // P2PKH WITNESS TWINS + // ========================================== + + /// A P2PKH witness is checked by recovering the public key, which takes any S and either + /// header form. A third party can replace a witness's signature with its high-S twin, or with + /// the twin whose header names an uncompressed key, and change the transition's hash. + /// Protocol version 14 accepts each twin, for replay; from protocol version 15 a block + /// refuses each unpaid, with the error of a witness that does not verify. The witness the + /// key made is accepted at both. + mod witness_twins { + use super::*; + use dpp::tests::utils::{high_s_twin, uncompressed_header_twin}; + + #[tokio::test] + async fn should_refuse_a_p2pkh_witness_twin_from_protocol_version_15() { + for platform_version in [ + PlatformVersion::get(14).expect("expected protocol version 14"), + PlatformVersion::latest(), + ] { + let protocol_version = platform_version.protocol_version; + let mut platform = TestPlatformBuilder::new() + .with_config(PlatformConfig::default()) + .with_initial_protocol_version(protocol_version) + .build_with_mock_rpc() + .set_genesis_state(); + + let mut signer = TestAddressSigner::new(); + let input_address = signer.add_p2pkh([1u8; 32]); + setup_address_with_balance(&mut platform, input_address, 0, dash_to_credits!(1.0)); + let mut inputs = BTreeMap::new(); + inputs.insert(input_address, (1, dash_to_credits!(0.1))); + let mut outputs = BTreeMap::new(); + outputs.insert(create_platform_address(2), dash_to_credits!(0.1)); + let signed = AddressFundsTransferTransitionV0::try_from_inputs_with_signer( + inputs, + outputs, + vec![AddressFundsFeeStrategyStep::DeductFromInput(0)], + &signer, + 0, + platform_version, + ) + .await + .expect("should create signed transition"); + + let StateTransition::AddressFundsTransfer(AddressFundsTransferTransition::V0( + signed_v0, + )) = &signed + else { + panic!("expected an address funds transfer"); + }; + let AddressWitness::P2pkh { signature } = &signed_v0.input_witnesses[0] else { + panic!("expected a P2PKH witness"); + }; + let signature = signature.to_vec(); + let with_witness_signature = |signature: Vec| { + let mut malleated = signed.clone(); + let StateTransition::AddressFundsTransfer(AddressFundsTransferTransition::V0( + v0, + )) = &mut malleated + else { + panic!("expected an address funds transfer"); + }; + v0.input_witnesses[0] = AddressWitness::P2pkh { + signature: BinaryData::new(signature), + }; + malleated + }; + + // Each transition runs in its own uncommitted block transaction, so all spend + // the same nonce. + let process = |transition: &StateTransition| { + let platform_state = platform.state.load(); + let transaction = platform.drive.grove.start_transaction(); + platform + .platform + .process_raw_state_transitions( + &[transition.serialize_to_bytes().expect("serializes")], + &platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + false, + None, + ) + .expect("expected to process state transition") + .into_execution_results() + }; + + assert_matches!( + process(&signed).as_slice(), + [StateTransitionExecutionResult::SuccessfulExecution { .. }], + "protocol version {protocol_version} accepts the witness the key made" + ); + for (twin_label, twin) in [ + ("high-S twin", high_s_twin(&signature)), + ( + "uncompressed header twin", + uncompressed_header_twin(&signature), + ), + ] { + let malleated_results = process(&with_witness_signature(twin)); + if protocol_version == 14 { + assert_matches!( + malleated_results.as_slice(), + [StateTransitionExecutionResult::SuccessfulExecution { .. }], + "protocol version 14 accepts the {twin_label}" + ); + } else { + assert_matches!( + malleated_results.as_slice(), + [StateTransitionExecutionResult::UnpaidConsensusError( + ConsensusError::SignatureError( + SignatureError::InvalidStateTransitionSignatureError(_) + ) + )], + "protocol version {protocol_version} refuses the {twin_label}" + ); + } + } + } + } + } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/mod.rs index 9c07ac33abd..5abad522ab1 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/mod.rs @@ -508,6 +508,149 @@ mod tests { assert_eq!(identity_balance, expected_identity_balance); } + /// The asset lock's one-time key is checked by recovering the public key, which takes any S + /// and either header form. A third party can replace an identity create's signature with its + /// high-S twin, or with the twin whose header names an uncompressed key, and change the + /// transition's hash. Protocol version 14 accepts each twin, for replay; from protocol + /// version 15 a block refuses each unpaid, with the error of a signature that does not + /// verify, and leaves the asset lock unused. The signature the key made is accepted at both. + #[tokio::test] + async fn should_refuse_an_asset_lock_signature_twin_from_protocol_version_15() { + use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult; + use dpp::consensus::signature::SignatureError; + use dpp::tests::utils::{high_s_twin, uncompressed_header_twin}; + + let latest = PlatformVersion::latest().protocol_version; + let twins: [(&str, fn(&[u8]) -> Vec); 2] = [ + ("high-S twin", high_s_twin), + ("uncompressed header twin", uncompressed_header_twin), + ]; + // (protocol version, the twins submitted before the signature itself). The asset lock is + // consumed by the first transition a block accepts, so at 14 each twin gets its own + // platform, as does the signature. + for (protocol_version, submitted) in [ + (14, &twins[..0]), + (14, &twins[..1]), + (14, &twins[1..]), + (latest, &twins[..]), + ] { + let platform_version = PlatformVersion::get(protocol_version) + .expect("expected platform version for the requested protocol_version"); + let platform = TestPlatformBuilder::new() + .with_initial_protocol_version(protocol_version) + .with_config(PlatformConfig { + testing_configs: PlatformTestConfig { + disable_instant_lock_signature_verification: true, + ..Default::default() + }, + ..Default::default() + }) + .build_with_mock_rpc() + .set_initial_state_structure(); + let platform_state = platform.state.load(); + let mut signer = SimpleSigner::default(); + let mut rng = StdRng::seed_from_u64(567); + + let (master_key, master_private_key) = + IdentityPublicKey::random_ecdsa_master_authentication_key( + 0, + Some(58), + platform_version, + ) + .expect("expected to get key pair"); + signer.add_identity_public_key(master_key.clone(), master_private_key); + + let (_, pk) = ECDSA_SECP256K1 + .random_public_and_private_key_data(&mut rng, platform_version) + .unwrap(); + let asset_lock_proof = instant_asset_lock_proof_fixture( + Some(PrivateKey::from_byte_array(&pk, Network::Testnet).unwrap()), + None, + ); + let identity: Identity = IdentityV0 { + id: asset_lock_proof + .create_identifier() + .expect("expected an identifier"), + public_keys: BTreeMap::from([(0, master_key)]), + balance: 1000000000, + revision: 0, + } + .into(); + + let signed: StateTransition = + IdentityCreateTransition::try_from_identity_with_signer_and_private_key( + &identity, + asset_lock_proof, + pk.as_slice(), + &signer, + &NativeBlsModule, + 0, + platform_version, + ) + .await + .expect("expected an identity create transition"); + let signature = signed.signature().expect("signed").to_vec(); + + let process = |transition: &StateTransition| { + let transaction = platform.drive.grove.start_transaction(); + let result = platform + .platform + .process_raw_state_transitions( + &[transition.serialize_to_bytes().expect("serializes")], + &platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + false, + None, + ) + .expect("expected to process state transition"); + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit"); + result + }; + + let mut asset_lock_used = false; + for (twin_label, twin) in submitted { + let mut malleated = signed.clone(); + malleated.set_signature(twin(&signature).into()); + let result = process(&malleated); + if protocol_version == 14 { + assert_eq!( + result.valid_count(), + 1, + "protocol version 14 accepts the {twin_label}: {:?}", + result.execution_results() + ); + asset_lock_used = true; + } else { + assert_matches!( + result.execution_results().as_slice(), + [StateTransitionExecutionResult::UnpaidConsensusError( + ConsensusError::SignatureError(SignatureError::BasicECDSAError(_)) + )], + "protocol version {protocol_version} refuses the {twin_label}" + ); + } + } + if !asset_lock_used { + // No twin was accepted, so the asset lock is unused and the signature the key + // made still creates. + let result = process(&signed); + assert_eq!( + result.valid_count(), + 1, + "protocol version {protocol_version} accepts the signature: {:?}", + result.execution_results() + ); + } + } + } + /// Neither the InstantSend lock nor the transition's signature covers an instant proof's /// asset-lock payload length prefix, and every node has always read the payload whatever /// length the prefix announces. Anyone relaying a pending IdentityCreate can change the diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/state/v0/mod.rs index b688f19d77f..ffa60170fbb 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/state/v0/mod.rs @@ -7,9 +7,9 @@ use dpp::consensus::basic::identity::IdentityAssetLockTransactionOutPointNotEnou use dpp::consensus::signature::{BasicECDSAError, SignatureError}; use dpp::consensus::state::identity::IdentityAlreadyExistsError; -use dpp::dashcore::signer; use dpp::dashcore::{ScriptBuf, Txid}; use dpp::identity::KeyType; +use dpp::util::ecdsa::verify_hash_signature; use dpp::identity::state_transition::AssetLockProved; use dpp::prelude::ConsensusValidationResult; @@ -234,11 +234,15 @@ impl IdentityCreateStateTransitionStateValidationV0 for IdentityCreateTransition SignatureVerificationOperation::new(KeyType::ECDSA_HASH160), )); - if let Err(e) = signer::verify_hash_signature( + // `verify_hash_signature` 0 at protocol versions 14 and earlier is the + // `dashcore::signer::verify_hash_signature` call this site made before; 1 also + // refuses a high-S signature and a header naming an uncompressed key. + if let Err(e) = verify_hash_signature( signable_bytes_hasher.hash_bytes().as_slice(), self.signature().as_slice(), public_key_hash, - ) { + platform_version, + )? { return Ok(ConsensusValidationResult::new_with_error( SignatureError::BasicECDSAError(BasicECDSAError::new(e.to_string())).into(), )); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/mod.rs index d6a54ae5397..283de584131 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/mod.rs @@ -416,6 +416,154 @@ mod tests { assert_eq!(identity_balance, expected_identity_balance); // about 0.5 Dash starting balance + 1 Dash asset lock top up } + /// The asset lock's one-time key is checked by recovering the public key, which takes any S + /// and either header form. A third party can replace a top-up's signature with its + /// high-S twin, or with the twin whose header names an uncompressed key, and change the + /// transition's hash. Protocol version 14 accepts each twin, for replay; from protocol + /// version 15 a block refuses each unpaid, with the error of a signature that does not + /// verify, and leaves the asset lock unused. The signature the key made is accepted at both. + #[test] + fn should_refuse_an_asset_lock_signature_twin_from_protocol_version_15() { + use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult; + use assert_matches::assert_matches; + use dpp::consensus::signature::SignatureError; + use dpp::consensus::ConsensusError; + use dpp::tests::utils::{high_s_twin, uncompressed_header_twin}; + + let latest = PlatformVersion::latest().protocol_version; + let twins: [(&str, fn(&[u8]) -> Vec); 2] = [ + ("high-S twin", high_s_twin), + ("uncompressed header twin", uncompressed_header_twin), + ]; + // (protocol version, the twins submitted before the signature itself). The asset lock is + // consumed by the first transition a block accepts, so at 14 each twin gets its own + // platform, as does the signature. + for (protocol_version, submitted) in [ + (14, &twins[..0]), + (14, &twins[..1]), + (14, &twins[1..]), + (latest, &twins[..]), + ] { + let platform_version = PlatformVersion::get(protocol_version) + .expect("expected platform version for the requested protocol_version"); + let platform = TestPlatformBuilder::new() + .with_initial_protocol_version(protocol_version) + .with_config(PlatformConfig { + testing_configs: PlatformTestConfig { + disable_instant_lock_signature_verification: true, + ..Default::default() + }, + ..Default::default() + }) + .build_with_mock_rpc() + .set_initial_state_structure(); + let platform_state = platform.state.load(); + let mut rng = StdRng::seed_from_u64(567); + + let (master_key, _) = IdentityPublicKey::random_ecdsa_master_authentication_key( + 0, + Some(58), + platform_version, + ) + .expect("expected to get key pair"); + let identity: Identity = IdentityV0 { + id: Identifier::random_with_rng(&mut rng), + public_keys: BTreeMap::from([(0, master_key)]), + balance: 50000000000, + revision: 0, + } + .into(); + platform + .drive + .add_new_identity( + identity.clone(), + false, + &BlockInfo::default(), + true, + None, + platform_version, + ) + .expect("expected to add a new identity"); + + let (_, pk) = ECDSA_SECP256K1 + .random_public_and_private_key_data(&mut rng, platform_version) + .unwrap(); + let asset_lock_proof = instant_asset_lock_proof_fixture( + Some(PrivateKey::from_byte_array(&pk, Network::Testnet).unwrap()), + None, + ); + let signed: StateTransition = + IdentityTopUpTransition::try_from_identity_with_private_key( + &identity, + asset_lock_proof, + pk.as_slice(), + 0, + platform_version, + None, + ) + .expect("expected an identity top up transition"); + let signature = signed.signature().expect("signed").to_vec(); + + let process = |transition: &StateTransition| { + let transaction = platform.drive.grove.start_transaction(); + let result = platform + .platform + .process_raw_state_transitions( + &[transition.serialize_to_bytes().expect("serializes")], + &platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + false, + None, + ) + .expect("expected to process state transition"); + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit"); + result + }; + + let mut asset_lock_used = false; + for (twin_label, twin) in submitted { + let mut malleated = signed.clone(); + malleated.set_signature(twin(&signature).into()); + let result = process(&malleated); + if protocol_version == 14 { + assert_eq!( + result.valid_count(), + 1, + "protocol version 14 accepts the {twin_label}: {:?}", + result.execution_results() + ); + asset_lock_used = true; + } else { + assert_matches!( + result.execution_results().as_slice(), + [StateTransitionExecutionResult::UnpaidConsensusError( + ConsensusError::SignatureError(SignatureError::BasicECDSAError(_)) + )], + "protocol version {protocol_version} refuses the {twin_label}" + ); + } + } + if !asset_lock_used { + // No twin was accepted, so the asset lock is unused and the signature the key + // made still tops up. + let result = process(&signed); + assert_eq!( + result.valid_count(), + 1, + "protocol version {protocol_version} accepts the signature: {:?}", + result.execution_results() + ); + } + } + } + /// Regression for the proposer-side mint accounting: a minting transition (an asset-lock /// top up) that executes but is then dropped from the proposal (`InternalError` -> /// `TxAction::Removed`) has its GroveDB writes rolled back to the savepoint — its mint diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/transform_into_action/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/transform_into_action/v0/mod.rs index 174391c0975..3b2098c7058 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/transform_into_action/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/transform_into_action/v0/mod.rs @@ -6,10 +6,10 @@ use dpp::balances::credits::CREDITS_PER_DUFF; use dpp::consensus::basic::identity::IdentityAssetLockTransactionOutPointNotEnoughBalanceError; use dpp::consensus::signature::{BasicECDSAError, SignatureError}; -use dpp::dashcore::signer; use dpp::dashcore::{ScriptBuf, Txid}; use dpp::identity::state_transition::AssetLockProved; use dpp::identity::KeyType; +use dpp::util::ecdsa::verify_hash_signature; use dpp::prelude::ConsensusValidationResult; @@ -166,11 +166,15 @@ impl IdentityTopUpStateTransitionStateValidationV0 for IdentityTopUpTransition { SignatureVerificationOperation::new(KeyType::ECDSA_HASH160), )); - if let Err(e) = signer::verify_hash_signature( + // `verify_hash_signature` 0 at protocol versions 14 and earlier is the + // `dashcore::signer::verify_hash_signature` call this site made before; 1 also + // refuses a high-S signature and a header naming an uncompressed key. + if let Err(e) = verify_hash_signature( signable_bytes_hasher.hash_bytes().as_slice(), self.signature().as_slice(), public_key_hash, - ) { + platform_version, + )? { return Ok(ConsensusValidationResult::new_with_error( SignatureError::BasicECDSAError(BasicECDSAError::new(e.to_string())).into(), )); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield_from_asset_lock/tests.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield_from_asset_lock/tests.rs index b0eb7784452..511bff9996c 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield_from_asset_lock/tests.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield_from_asset_lock/tests.rs @@ -572,6 +572,12 @@ mod tests { mod signature_validation { use super::*; + use crate::execution::validation::state_transition::state_transitions::test_helpers::{ + build_outputs_only_bundle_bound, process_transition_and_commit, + setup_platform_at_protocol_version, OutputsOnlyBundle, + }; + use dpp::tests::utils::{high_s_twin, uncompressed_header_twin}; + use std::collections::BTreeMap; #[test] fn test_wrong_ecdsa_signature_returns_error() { @@ -642,11 +648,96 @@ mod tests { )] ); } - } - // ========================================== - // ZK PROOF VERIFICATION TESTS - // ========================================== + /// The asset lock's one-time key is checked by recovering the public key, which takes + /// any S and either header form. A third party can replace a shield's signature with its + /// high-S twin, or with the twin whose header names an uncompressed key, and change the + /// transition's hash. Protocol version 14 accepts each twin, for replay; from protocol + /// version 15 a block refuses each unpaid, with the error of a signature that does not + /// verify, and leaves the asset lock unused. The signature the key made is accepted at + /// both. + /// + /// The bundle is proved for real, so a transition that passes the signature check is + /// executed. + #[test] + fn should_refuse_an_asset_lock_signature_twin_from_protocol_version_15() { + let latest = PlatformVersion::latest().protocol_version; + let twins: [(&str, fn(&[u8]) -> Vec); 2] = [ + ("high-S twin", high_s_twin), + ("uncompressed header twin", uncompressed_header_twin), + ]; + // (protocol version, the twins submitted before the signature itself). The asset + // lock is consumed by the first transition a block accepts, so at 14 each twin gets + // its own platform, as does the signature. + // Every platform below is funded by the same asset lock, so a bundle proved against + // it serves each platform whose protocol version binds the lock the same way. + let mut bundles: BTreeMap, OutputsOnlyBundle> = BTreeMap::new(); + for (protocol_version, submitted) in [ + (14, &twins[..0]), + (14, &twins[..1]), + (14, &twins[1..]), + (latest, &twins[..]), + ] { + let platform_version = + PlatformVersion::get(protocol_version).expect("known protocol version"); + let platform = setup_platform_at_protocol_version(protocol_version); + + let mut rng = StdRng::seed_from_u64(567); + let (asset_lock_proof, asset_lock_pk) = create_asset_lock_proof_with_key(&mut rng); + let extra_sighash_data = + shield_from_asset_lock_extra_sighash_data(&asset_lock_proof, platform_version) + .expect("the binding of the funding asset lock"); + let bundle = bundles + .entry(extra_sighash_data.clone()) + .or_insert_with(|| build_outputs_only_bundle_bound(5_000, &extra_sighash_data)) + .clone(); + let signed = create_signed_shield_from_asset_lock_transition( + asset_lock_proof, + &asset_lock_pk, + bundle.actions, + bundle.amount, + bundle.anchor, + bundle.proof, + bundle.binding_signature, + ); + let signature = signed.signature().expect("signed").to_vec(); + + let mut asset_lock_used = false; + for (twin_label, twin) in submitted { + let mut malleated = signed.clone(); + malleated.set_signature(twin(&signature).into()); + let result = + process_transition_and_commit(&platform, malleated, platform_version); + if protocol_version == 14 { + assert_matches!( + result.execution_results().as_slice(), + [StateTransitionExecutionResult::SuccessfulExecution { .. }], + "protocol version 14 accepts the {twin_label}" + ); + asset_lock_used = true; + } else { + assert_matches!( + result.execution_results().as_slice(), + [StateTransitionExecutionResult::UnpaidConsensusError( + ConsensusError::SignatureError(SignatureError::BasicECDSAError(_)) + )], + "protocol version {protocol_version} refuses the {twin_label}" + ); + } + } + if !asset_lock_used { + // No twin was accepted, so the asset lock is unused and the signature the + // key made still shields. + let result = process_transition_and_commit(&platform, signed, platform_version); + assert_matches!( + result.execution_results().as_slice(), + [StateTransitionExecutionResult::SuccessfulExecution { .. }], + "protocol version {protocol_version} accepts the signature" + ); + } + } + } + } mod proof_verification { use super::*; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield_from_asset_lock/transform_into_action/v1/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield_from_asset_lock/transform_into_action/v1/mod.rs index 620dc964b83..38f2a9d8cc8 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield_from_asset_lock/transform_into_action/v1/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield_from_asset_lock/transform_into_action/v1/mod.rs @@ -22,7 +22,7 @@ use dpp::consensus::basic::identity::IdentityAssetLockTransactionOutPointNotEnou use dpp::consensus::basic::state_transition::ShieldedImplicitFeeCapExceededError; use dpp::consensus::signature::{BasicECDSAError, SignatureError}; use dpp::consensus::state::state_error::StateError; -use dpp::dashcore::signer; +use dpp::util::ecdsa::verify_hash_signature; use dpp::dashcore::{ ScriptBuf, Txid}; use dpp::fee::Credits; use dpp::shielded::{compute_minimum_shielded_fee, shield_from_asset_lock_extra_sighash_data}; @@ -225,11 +225,15 @@ impl ShieldFromAssetLockStateTransitionTransformIntoActionValidationV1 SignatureVerificationOperation::new(KeyType::ECDSA_HASH160), )); - if let Err(e) = signer::verify_hash_signature( + // `verify_hash_signature` 0 at protocol versions 14 and earlier is the + // `dashcore::signer::verify_hash_signature` call this site made before; 1 also + // refuses a high-S signature and a header naming an uncompressed key. + if let Err(e) = verify_hash_signature( signable_bytes_hasher.hash_bytes().as_slice(), self.signature().as_slice(), public_key_hash, - ) { + platform_version, + )? { return Ok(ConsensusValidationResult::new_with_error( SignatureError::BasicECDSAError(BasicECDSAError::new(e.to_string())).into(), )); diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/mod.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/mod.rs index 3564e202adc..56585545867 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/mod.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/mod.rs @@ -2,6 +2,7 @@ use versioned_feature_core::FeatureVersion; pub mod v1; pub mod v2; +pub mod v3; #[derive(Clone, Debug, Default)] pub struct DPPStateTransitionMethodVersions { @@ -9,6 +10,13 @@ pub struct DPPStateTransitionMethodVersions { /// `StateTransition::verify_identity_signed_signature`: 0 accepts a BLS12_381 signature /// that is well formed but does not verify, 1 refuses it. pub verify_identity_signed_signature: FeatureVersion, + /// `dpp::util::ecdsa::verify_hash_signature`, the check of a compact recoverable + /// ECDSA signature by recovering its public key and comparing the key's HASH160 (an + /// ECDSA_HASH160 identity key, a P2PKH address witness, an asset lock's one-time key): 0 + /// accepts a signature whose S is in the upper half of the curve order and one whose header + /// names an uncompressed key, each of which any third party can derive from a valid + /// signature, 1 refuses both. + pub verify_hash_signature: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/v1.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/v1.rs index 2d02c1c55a4..c0cc3a40698 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/v1.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/v1.rs @@ -13,4 +13,5 @@ pub const STATE_TRANSITION_METHOD_VERSIONS_V1: DPPStateTransitionMethodVersions validate_identity_public_keys_structure: 0, }, verify_identity_signed_signature: 0, + verify_hash_signature: 0, }; diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/v2.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/v2.rs index f00e3e9b46d..a429a6e5d2b 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/v2.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/v2.rs @@ -18,4 +18,5 @@ pub const STATE_TRANSITION_METHOD_VERSIONS_V2: DPPStateTransitionMethodVersions validate_identity_public_keys_structure: 1, }, verify_identity_signed_signature: 1, + verify_hash_signature: 0, }; diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/v3.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/v3.rs new file mode 100644 index 00000000000..88f6c2a47c1 --- /dev/null +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_method_versions/v3.rs @@ -0,0 +1,13 @@ +use crate::version::dpp_versions::dpp_state_transition_method_versions::v2::STATE_TRANSITION_METHOD_VERSIONS_V2; +use crate::version::dpp_versions::dpp_state_transition_method_versions::DPPStateTransitionMethodVersions; + +/// V3 is protocol version 15's table. `verify_hash_signature` 0 -> 1: a signature checked by +/// recovering its public key (an ECDSA_HASH160 identity key, a P2PKH address witness, an asset +/// lock's one-time key) must have S in the lower half of the curve order and a header naming a +/// compressed key, so a third party can no longer turn a valid signature into a second one and +/// change the transition's hash. V2 stays as is for replay. +pub const STATE_TRANSITION_METHOD_VERSIONS_V3: DPPStateTransitionMethodVersions = + DPPStateTransitionMethodVersions { + verify_hash_signature: 1, + ..STATE_TRANSITION_METHOD_VERSIONS_V2 + }; diff --git a/packages/rs-platform-version/src/version/v15.rs b/packages/rs-platform-version/src/version/v15.rs index 2a3c212d2a9..6a0691f5044 100644 --- a/packages/rs-platform-version/src/version/v15.rs +++ b/packages/rs-platform-version/src/version/v15.rs @@ -7,7 +7,7 @@ use crate::version::dpp_versions::dpp_factory_versions::v1::DPP_FACTORY_VERSIONS use crate::version::dpp_versions::dpp_identity_versions::v1::IDENTITY_VERSIONS_V1; use crate::version::dpp_versions::dpp_method_versions::v3::DPP_METHOD_VERSIONS_V3; use crate::version::dpp_versions::dpp_state_transition_conversion_versions::v2::STATE_TRANSITION_CONVERSION_VERSIONS_V2; -use crate::version::dpp_versions::dpp_state_transition_method_versions::v2::STATE_TRANSITION_METHOD_VERSIONS_V2; +use crate::version::dpp_versions::dpp_state_transition_method_versions::v3::STATE_TRANSITION_METHOD_VERSIONS_V3; use crate::version::dpp_versions::dpp_state_transition_serialization_versions::v4::STATE_TRANSITION_SERIALIZATION_VERSIONS_V4; use crate::version::dpp_versions::dpp_state_transition_versions::v5::STATE_TRANSITION_VERSIONS_V5; use crate::version::dpp_versions::dpp_token_versions::v3::TOKEN_VERSIONS_V3; @@ -913,6 +913,22 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// `validate_schema_patterns` and `registration_cost` 2, so a block accepts there what it /// accepted before, and a contract registered earlier is not checked again when it is /// read. +/// +/// 43. **One signature form where the key is recovered**: an ECDSA signature checked by +/// recovering its public key and comparing the key's HASH160 (an identity-signed +/// transition's ECDSA_HASH160 key, masternode votes included; a P2PKH address witness; +/// the one-time key of an asset lock funding an identity create, a top-up, an address +/// funding or a shield) stays valid with S replaced by `n - S` and the recovery id's +/// parity flipped, and with its header rewritten from that of a compressed key +/// (`31 + id`) to that of an uncompressed one (`27 + id`), so a third party could change +/// a transition's hash. `verify_hash_signature` 1 (`STATE_TRANSITION_METHOD_VERSIONS_V3`) +/// refuses a signature whose S is in the upper half of the curve order or whose header +/// does not name a compressed key, with the error each path gives a signature that does +/// not verify, unpaid as before. Signing produces low-S signatures under the compressed +/// key's header, so no honest signer is affected. The checks that verify against a +/// public key already refuse high-S. Protocol v14 and earlier keep +/// `verify_hash_signature` 0, so the blocks committed under them replay with the same +/// results. pub const PLATFORM_V15: PlatformVersion = PlatformVersion { protocol_version: PROTOCOL_VERSION_15, drive: DRIVE_VERSION_V10, // changed: calculate_fee 1 prices a refund at the storing epoch's rate (note 27); apply_contract_with_serialization 1 writes nothing for a contract whose format version 1 bytes match the stored one's (note 8); vote method versions v4: register_identity_vote 1 registers a yes/no vote, remove_all_votes_given_by_identities 1 also removes the yes/no votes of a masternode that left the list, every yes_no method and remove_vote_poll_end_date_query_operations Some(0) make yes/no polls active, add_vote_poll_end_date_query_operations 1 adds only the entry when the batch already queues the end date's tree with other storage flags, and verify methods v4 make the yes/no proof verifiers active (note 10) and verify_private_document_entries Some(0) a page of a private type's store (note 13); state transition method versions v5: document_create_transition 1 deletes a consumed document from what its lookup read (note 11); document method versions v5: insert_empty_private_document_store_operation Some(0) creates a private document type's store, and fetch_private_document_entries and prove_private_document_entries Some(0) read and prove a page of it (note 13); apply_drive_operations 2 resolves a batch's estimate, remove_reference_for_index_level_for_contract_operations 2, add_reference_for_index_level_for_contract_operations 1, stateless_delete_of_non_tree_for_costs 1 and for_total_system_credits_update 1 describe their layers as they are (note 14); create_initial_state_structure 5 adds the token marketplace escrow trees; calculate_total_tokens_balance 2 counts escrowed tokens; the escrow primitives; the identity balance, token balance, prefunded specialized balance and contract fee pot estimations (for_balances 1, for_token_balances 1, estimated_cost_for_prefunded_specialized_balance_update 2, add_estimation_costs_for_contract_fee_pot_update 1) keep a deeper layer description (note 17); fetch_core_fork_activation_height and store_core_fork_activation_height Some(0) keep the Core fork activations (note 18); document method versions v5: append_private_document_entries_operations Some(0) appends a private document create's entries (note 25); grove_version GROVE_V5 (note 26); verify methods v4: verify_proof_keep_serialized 1 verifies a document that may be contested (note 29); document method versions v5: single_document_path_query 1 selects the latest retained revision at or before a block time, and verify_proof_keep_serialized 1 verifies it (note 31); retained-history writers, readers, estimates and verifiers select the per-type revision layout (note 35); add_new_keys_to_masternode_identity 1 adds a masternode key whose hash the identity already holds a reference for (note 32); document method versions v5: insert.add_document_for_contract_operations 2, delete.delete_document_for_contract_operations 1, delete.remove_document_from_primary_storage 1 and its estimate 1, query.fetch_document_lifecycle Some(0), and the erase/lifecycle estimate and erase_refund_recipient_cost selectors Some(0); batch_operations.convert_drive_operations_to_grove_operations 2; state transition method versions v5: document_delete_transition 1 and document_erase_transition Some(0); verify methods v4: single_document.verify_proof 1 extend retained history (note 41); document method versions v5: add_indices_for_top_index_level_for_contract_operations 3 writes no entry in an expired time range bucket (note 36) @@ -929,7 +945,7 @@ pub const PLATFORM_V15: PlatformVersion = PlatformVersion { validation: DPP_VALIDATION_VERSIONS_V6, // changed: document type update 2 preserves erasure constraints (note 41) state_transition_serialization_versions: STATE_TRANSITION_SERIALIZATION_VERSIONS_V4, // changed: document erase bounds Some(0) admit the appended kind (note 41) state_transition_conversion_versions: STATE_TRANSITION_CONVERSION_VERSIONS_V2, - state_transition_method_versions: STATE_TRANSITION_METHOD_VERSIONS_V2, + state_transition_method_versions: STATE_TRANSITION_METHOD_VERSIONS_V3, // changed: verify_hash_signature 1 refuses a high-S signature and an uncompressed-key header where the key is recovered (note 43) state_transitions: STATE_TRANSITION_VERSIONS_V5, // changed: validate_asset_lock_transaction_structure 1 drops the input cap and validate_instant_asset_lock_proof_structure 1 applies it to instant proofs only, so a chain proof redeems a lock of more than 100 inputs (note 30) contract_versions: CONTRACT_VERSIONS_V7, // changed: parse_property_constraints 1 lets countOf and sumOf match byte array keys (note 4); validate_document 2 checks documents natively (note 6); check_document_type_schema 1 checks schemas natively at registration (note 7); contract_storage_serialization_version 2 stores contracts compiled (note 8); parse_private_document 0 parses private document types (note 13); apply_generated_from 1 admits sys.tokens.decimals (note 15); try_from_schema 4 parses lifecycle flags (note 41); validate_schema_patterns 0 bounds the patterns of a contract and registration_cost 3 estimates its fee without compiling one (note 42) document_versions: DOCUMENT_VERSIONS_V4, diff --git a/packages/rs-sdk/src/platform/transition/broadcast/retry_tests.rs b/packages/rs-sdk/src/platform/transition/broadcast/retry_tests.rs index b55a906f3f5..4fae33476d9 100644 --- a/packages/rs-sdk/src/platform/transition/broadcast/retry_tests.rs +++ b/packages/rs-sdk/src/platform/transition/broadcast/retry_tests.rs @@ -521,7 +521,7 @@ fn signed_address_transfer() -> StateTransition { signature: signer::sign(&bytes, &private_key).unwrap().to_vec().into(), }; input - .verify_bytes_against_witness(&witness, &bytes) + .verify_bytes_against_witness(&witness, &bytes, PlatformVersion::latest()) .unwrap(); transfer.input_witnesses.push(witness); let transition = transfer.into(); From 9367820b82e88605d8ee52483c880e4ca46ea59c Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Sat, 14 Nov 2026 02:37:57 +0700 Subject: [PATCH 25/26] feat(sdk): multiple choice decision proposals in the Swift and Kotlin SDKs (#5919) Co-authored-by: Claude Fable 5.2 --- docs/protocol/decision-proposals.md | 16 +- .../kotlin-sdk/KotlinExampleApp/TEST_PLAN.md | 19 +- .../example/navigation/AppNavHost.kt | 16 + .../example/navigation/Routes.kt | 17 + .../example/ui/contracts/QueryDetailScreen.kt | 15 + .../example/ui/contracts/QueryRegistry.kt | 107 +- .../identity/DecisionProposalDetailScreen.kt | 5 +- .../MultipleChoiceProposalDetailScreen.kt | 1022 +++++++++++++++++ .../identity/MultipleChoiceProposalsScreen.kt | 703 ++++++++++++ .../dashfoundation/example/util/Formatters.kt | 7 + ...ltipleChoiceDocumentCreateViewModelTest.kt | 174 +++ .../MultipleChoiceProposalFormTest.kt | 163 +++ .../example/util/FormattersTest.kt | 11 + packages/kotlin-sdk/PARITY.md | 20 +- .../dashsdk/MultipleChoiceProposalsFfiTest.kt | 250 ++++ .../kotlin/org/dashfoundation/dashsdk/Sdk.kt | 10 + .../ffi/MultipleChoiceProposalsNative.kt | 181 +++ .../dashsdk/voting/DecisionProposalModels.kt | 29 +- .../voting/MultipleChoiceProposalModels.kt | 431 +++++++ .../dashsdk/voting/MultipleChoiceProposals.kt | 299 +++++ .../dashsdk/wallet/PlatformWalletManager.kt | 10 + .../MultipleChoiceProposalModelsTest.kt | 338 ++++++ .../src/decision_proposal.rs | 2 +- packages/rs-platform-wallet-ffi/src/lib.rs | 2 + .../src/multiple_choice_proposal.rs | 872 ++++++++++++++ .../identity/network/decision_proposal.rs | 37 +- .../src/wallet/identity/network/mod.rs | 1 + .../network/multiple_choice_proposal.rs | 664 +++++++++++ .../rs-sdk-ffi/src/decision_proposal/json.rs | 2 +- .../rs-sdk-ffi/src/decision_proposal/mod.rs | 2 + .../decision_proposal/multiple_choice/json.rs | 490 ++++++++ .../decision_proposal/multiple_choice/mod.rs | 795 +++++++++++++ .../src/decision_proposal/queries.rs | 5 +- .../src/decision_proposals.rs | 40 +- packages/rs-unified-sdk-jni/src/lib.rs | 1 + .../src/multiple_choice_proposals.rs | 812 +++++++++++++ ...latformWalletMultipleChoiceProposals.swift | 261 +++++ .../Voting/MultipleChoiceProposal.swift | 437 +++++++ .../Voting/SDK+DecisionProposals.swift | 6 +- .../Voting/SDK+MultipleChoiceProposals.swift | 312 +++++ .../MultipleChoiceProposalDetailView.swift | 603 ++++++++++ .../MultipleChoiceProposalFormViews.swift | 794 +++++++++++++ .../MultipleChoiceProposalsView.swift | 259 +++++ .../Views/PlatformQueriesView.swift | 14 + .../MultipleChoiceProposalDecodingTests.swift | 269 +++++ ...ltipleChoiceProposalMarshallingTests.swift | 207 ++++ 46 files changed, 10670 insertions(+), 60 deletions(-) create mode 100644 packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/MultipleChoiceProposalDetailScreen.kt create mode 100644 packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/MultipleChoiceProposalsScreen.kt create mode 100644 packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/identity/MultipleChoiceDocumentCreateViewModelTest.kt create mode 100644 packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/identity/MultipleChoiceProposalFormTest.kt create mode 100644 packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/MultipleChoiceProposalsFfiTest.kt create mode 100644 packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/MultipleChoiceProposalsNative.kt create mode 100644 packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/MultipleChoiceProposalModels.kt create mode 100644 packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/MultipleChoiceProposals.kt create mode 100644 packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/voting/MultipleChoiceProposalModelsTest.kt create mode 100644 packages/rs-platform-wallet-ffi/src/multiple_choice_proposal.rs create mode 100644 packages/rs-platform-wallet/src/wallet/identity/network/multiple_choice_proposal.rs create mode 100644 packages/rs-sdk-ffi/src/decision_proposal/multiple_choice/json.rs create mode 100644 packages/rs-sdk-ffi/src/decision_proposal/multiple_choice/mod.rs create mode 100644 packages/rs-unified-sdk-jni/src/multiple_choice_proposals.rs create mode 100644 packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWalletMultipleChoiceProposals.swift create mode 100644 packages/swift-sdk/Sources/SwiftDashSDK/Voting/MultipleChoiceProposal.swift create mode 100644 packages/swift-sdk/Sources/SwiftDashSDK/Voting/SDK+MultipleChoiceProposals.swift create mode 100644 packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DecisionProposals/MultipleChoiceProposalDetailView.swift create mode 100644 packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DecisionProposals/MultipleChoiceProposalFormViews.swift create mode 100644 packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DecisionProposals/MultipleChoiceProposalsView.swift create mode 100644 packages/swift-sdk/SwiftTests/SwiftDashSDKTests/MultipleChoiceProposalDecodingTests.swift create mode 100644 packages/swift-sdk/SwiftTests/SwiftDashSDKTests/MultipleChoiceProposalMarshallingTests.swift diff --git a/docs/protocol/decision-proposals.md b/docs/protocol/decision-proposals.md index 9cc64feb53a..8266e99737e 100644 --- a/docs/protocol/decision-proposals.md +++ b/docs/protocol/decision-proposals.md @@ -408,10 +408,14 @@ given its contest fund like any contested create), and their contested resource queries and masternode vote read and answer the vote, with a choice's document id wherever they name a contender by an identity id. -The Rust SDK (`dash_sdk::platform::decision_proposals::multiple_choice`) and the +The Rust SDK (`dash_sdk::platform::decision_proposals::multiple_choice`), the JavaScript SDKs (`sdk.decisionProposals.multipleChoice` in `@dashevo/evo-sdk`, -the `*MultipleChoiceProposal*` methods of `@dashevo/wasm-sdk`) have helpers over -those: +the `*MultipleChoiceProposal*` methods of `@dashevo/wasm-sdk`) and the mobile +SDKs (the `dash_sdk_multiple_choice_proposal_*` C functions of `rs-sdk-ffi` and +the `platform_wallet_multiple_choice_proposal_*` ones of +`rs-platform-wallet-ffi`, wrapped by the Swift SDK and by the Kotlin SDK's +`Sdk.multipleChoiceProposals` and `PlatformWalletManager.multipleChoiceProposals`) +have helpers over those: - build a proposal, its edit and a choice as documents to create or replace; - give the proposal's processing fee and the fund a choice entered now pays; @@ -425,5 +429,7 @@ those: The contest a proposal's choices run in is named from the proposal's id alone (`dpp::decision_proposal::multiple_choice::multiple_choice_proposal_vote_poll`). The helpers write what they are given: which descriptions, texts and choices -Platform takes is checked by the contract, on chain. The mobile SDKs have no -multiple choice helpers yet. +Platform takes is checked by the contract, on chain. The mobile SDKs create +and edit a proposal and enter a choice through the platform wallet, which signs +and puts the document, where the Rust and JavaScript helpers return the document +to put. diff --git a/packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md b/packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md index 0a276aa692c..b43f3dda640 100644 --- a/packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md +++ b/packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md @@ -182,6 +182,13 @@ Most Platform actions have hard preconditions. Establish these fixtures before s | VOTE-11 | Edit a decision proposal's text | Platform | Thorough | ✅ | proposal | Detail → Edit Text (`decisionProposal.edit`, shown only when a local wallet identity filed it) → `editDecisionProposal.*` → `PlatformWalletManager.decisionProposals.edit` (one `platform_wallet_decision_proposal_edit` call; no signing key is chosen in the app). Accepted for a day after creation; an edit that changes nothing is refused before anything is broadcast, and an edit that raced another one is refused by Platform (consensus code 40106) rather than overwriting it. The dialog cannot be dismissed while it broadcasts. | | VOTE-12 | Masternode vote on a decision proposal (yes / no / abstain) | Platform | Thorough | ✅ | proposal, masternode | Detail → Vote (`decisionProposal.vote`) → `decisionProposalVote.choice` / `.proTxHash` / `.votingKey` / `.submit` → `dash_sdk_decision_proposal_cast_vote`. The voting key shows as dots and a screenshot of the open dialog comes out blank (FLAG_SECURE). **Requires masternode voting credentials**; a vote from a regular wallet is refused (no voter identity). | | VOTE-13 | Read a masternode's answer on a decision proposal | Platform | Thorough | ✅ | proposal, masternode, read-only | Vote dialog → Read This Masternode's Answer (`decisionProposalVote.lookUp`) → `dash_sdk_decision_proposal_get_masternode_vote`. No answer once the poll finished. | +| VOTE-14 | List multiple choice proposals (mine / newest, paged) | Platform | Thorough | ✅ | proposal, read-only | `QueriesListScreen` → Multiple Choice Proposals (`votingQueries.multipleChoiceProposalsLink`) → `MultipleChoiceProposalsScreen`: listing picker (`multipleChoiceProposals.listing`), identity picker for Mine (`multipleChoiceProposals.ownerPicker`), Load More (`multipleChoiceProposals.loadMore`). Needs protocol version 15; an earlier network shows a load error. | +| VOTE-15 | Create a multiple choice proposal | Platform | Thorough | ✅ | proposal | `MultipleChoiceProposalsScreen` + (`multipleChoiceProposals.create`) → `CreateMultipleChoiceProposalScreen` (`createMultipleChoiceProposal.*`) → `PlatformWalletManager.multipleChoiceProposals.create` (one `platform_wallet_multiple_choice_proposal_create` call; the success section shows the returned id). The Proposer section shows the processing fee read from `dash_sdk_multiple_choice_proposal_get_processing_fee` (`createMultipleChoiceProposal.processingFee`, 0.2 DASH at protocol version 15), which Platform charges on top of the fees. The description document is three optional fields (`.descriptionDocumentId` / `.descriptionDocumentContractId` / `.descriptionDocumentType`); the switch `.open` says whether anyone may enter choices. While it broadcasts, system Back does nothing, and a rotation or a bottom-tab switch does not cancel it. Platform refuses a proposal with neither a description document nor a url. Protocol version 15. | +| VOTE-16 | View a multiple choice proposal, its choices and its vote | Platform | Thorough | ✅ | proposal, read-only | `MultipleChoiceProposalDetailScreen` (row `multipleChoiceProposals.row.`): the proposal, who enters choices (`multipleChoiceProposal.open`), the vote status (`multipleChoiceProposal.voteStatus`: no choice entered, voting open, or how it ended), every choice with its tally (`multipleChoiceProposal.choice.`), the none-of-the-choices and abstain tallies, and once the vote ended the kept choice (`multipleChoiceProposal.keptChoice`, read with `dash_sdk_multiple_choice_proposal_get_kept_choice`). | +| VOTE-17 | Enter a choice for a multiple choice proposal | Platform | Thorough | ✅ | proposal | Detail → Enter a Choice (`multipleChoiceProposal.enterChoice`, shown when a loaded wallet holds an identity) → `enterProposalChoice.ownerPicker` / `.title` / `.description` / `.submitButton` → `PlatformWalletManager.multipleChoiceProposals.enterChoice` (one `platform_wallet_multiple_choice_proposal_enter_choice` call). The dialog shows the contest fund read from `dash_sdk_multiple_choice_proposal_get_choice_fund_to_join` (`enterProposalChoice.fund`), paid on top of the fees. The first choice opens the vote. Platform refuses a choice from anyone but the owner when the proposal is not open; the app does not pre-check it. The entry survives a rotation (the detail screen then shows its outcome), system Back does nothing while it broadcasts, and the action result names the new choice id. | +| VOTE-18 | Edit a multiple choice proposal | Platform | Thorough | ✅ | proposal | Detail → Edit (`multipleChoiceProposal.edit`, shown only when a local wallet identity filed it) → `editMultipleChoiceProposal.*` → `PlatformWalletManager.multipleChoiceProposals.edit` (one `platform_wallet_multiple_choice_proposal_edit` call). Only the changed fields are sent; an emptied url, or three emptied description document fields, removes it. Accepted for two hours after creation (Platform refuses it afterwards; the app does not hide the button); an edit that changes nothing is refused before anything is broadcast, one that leaves neither a description document nor a url is refused by Platform, and one that raced another edit is refused with consensus code 40106. The dialog cannot be dismissed while it broadcasts. | +| VOTE-19 | Masternode vote among a multiple choice proposal's choices (a choice / none of the choices / abstain) | Platform | Thorough | ✅ | proposal, masternode | Detail → Vote (`multipleChoiceProposal.vote`) → `multipleChoiceProposalVote.choice` (every choice of the running vote by title and id, then None of the choices and Abstain) / `.proTxHash` / `.votingKey` / `.submit` → `dash_sdk_multiple_choice_proposal_cast_vote`. The voting key shows as dots and a screenshot of the open dialog comes out blank (FLAG_SECURE); the dialog cannot be dismissed while it broadcasts. **Requires masternode voting credentials**; a vote from a regular wallet is refused (no voter identity). | +| VOTE-20 | Read a masternode's answer among a multiple choice proposal's choices | Platform | Thorough | ✅ | proposal, masternode, read-only | Vote dialog → Read This Masternode's Answer (`multipleChoiceProposalVote.lookUp`) → `dash_sdk_multiple_choice_proposal_get_masternode_vote`. No answer once the vote ended. | ### 4.6 Data Contracts — `Domain=Contract` @@ -314,7 +321,7 @@ Counts are of rows reachable in the app (Status `✅`/`🧪`/`⚠️`); `🔌`/` |---|---|---| | Essential | 21 | yes | | Common | 29 | yes | -| Thorough | 42 | yes | +| Thorough | 49 | yes | | Uncommon | 25 | yes | | Manual | 1 (`CORE-08`) | no — physical device | @@ -323,7 +330,7 @@ Counts are of rows reachable in the app (Status `✅`/`🧪`/`⚠️`); `🔌`/` | Layer | Count (approx.) | |---|---| | Core | 17 | -| Platform | ~80 | +| Platform | ~87 | | Cross | 7 | | Shielded | 16 | @@ -337,7 +344,7 @@ Membership of each feature category across **all** sections (primary section mem - **Identity** — `ID-01..15`, `SH-11` - **Address** (DIP-17 platform addresses) — `ADDR-01..04`, `ADDR-06..09`, `ID-06`, `ID-08`, `ID-11` - **DPNS** — `DPNS-01..08` -- **Voting** — `VOTE-01..13`, `DPNS-05`, `DPNS-08` +- **Voting** — `VOTE-01..20`, `DPNS-05`, `DPNS-08` - **Contract** — `DC-01..04` - **Document** — `DOC-01..15` - **Token** — `TOK-01..20` @@ -354,6 +361,6 @@ Tags are cross-cutting modalities. A test may appear under multiple tags. - **contested** — `DPNS-05`, `DPNS-08`, `VOTE-01..06` - **withdrawal** — `ID-10`, `ADDR-04`, `SH-08`, `SH-16` - **regression** — `TOK-17`, `DP-10` -- **read-only** — `SH-13`, `SYS-05`, `SYS-06`, `VOTE-02..06`, `VOTE-08`, `VOTE-10`, `VOTE-13`, `TOK-18`, `TOK-19` -- **masternode** — `VOTE-01`, `VOTE-12`, `VOTE-13` -- **proposal** (decision proposals, protocol version 15): `VOTE-08..13` +- **read-only** — `SH-13`, `SYS-05`, `SYS-06`, `VOTE-02..06`, `VOTE-08`, `VOTE-10`, `VOTE-13`, `VOTE-14`, `VOTE-16`, `VOTE-20`, `TOK-18`, `TOK-19` +- **masternode** — `VOTE-01`, `VOTE-12`, `VOTE-13`, `VOTE-19`, `VOTE-20` +- **proposal** (decision proposals, yes/no and multiple choice, protocol version 15): `VOTE-08..20` diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/AppNavHost.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/AppNavHost.kt index b55b17e3b2c..f3429a0eed7 100644 --- a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/AppNavHost.kt +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/AppNavHost.kt @@ -32,8 +32,11 @@ import org.dashfoundation.example.ui.identity.AddIdentityKeyScreen import org.dashfoundation.example.ui.identity.ContestDetailScreen import org.dashfoundation.example.ui.identity.CreateDecisionProposalScreen import org.dashfoundation.example.ui.identity.CreateIdentityScreen +import org.dashfoundation.example.ui.identity.CreateMultipleChoiceProposalScreen import org.dashfoundation.example.ui.identity.DecisionProposalDetailScreen import org.dashfoundation.example.ui.identity.DecisionProposalsScreen +import org.dashfoundation.example.ui.identity.MultipleChoiceProposalDetailScreen +import org.dashfoundation.example.ui.identity.MultipleChoiceProposalsScreen import org.dashfoundation.example.ui.dashpay.AddContactScreen import org.dashfoundation.example.ui.dashpay.ContactDetailScreen import org.dashfoundation.example.ui.dashpay.ContactRequestsScreen @@ -486,6 +489,19 @@ fun AppNavHost( ) } + composable { MultipleChoiceProposalsScreen(navController) } + + composable { + CreateMultipleChoiceProposalScreen(navController) + } + + composable { entry -> + MultipleChoiceProposalDetailScreen( + entry.toRoute().proposalId, + navController, + ) + } + composable { entry -> val route = entry.toRoute() GroupDetailScreen(route.contractIdHex, route.position, navController) diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/Routes.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/Routes.kt index f9f8ede75c4..05023153150 100644 --- a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/Routes.kt +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/Routes.kt @@ -430,6 +430,23 @@ import kotlinx.serialization.Serializable */ @Serializable data class DecisionProposalDetail(val proposalId: String) +/** + * Multiple choice proposal listings: a local identity's and the newest + * (← `MultipleChoiceProposalsView.swift`). Reached from the Platform Queries list, beside + * [DecisionProposalsList]. + */ +@Serializable object MultipleChoiceProposalsList + +/** File a new multiple choice proposal (← `CreateMultipleChoiceProposalView`). */ +@Serializable object CreateMultipleChoiceProposal + +/** + * One multiple choice proposal: its choices and their tallies, how the vote ended, entering + * a choice, the edit and the masternode vote (← `MultipleChoiceProposalDetailView.swift`). + * [proposalId] is base58. + */ +@Serializable data class MultipleChoiceProposalDetail(val proposalId: String) + /** * One contract group's members + live proposals (← `GroupDetailView.swift`). * [position] is the group contract position inside the contract's diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/QueryDetailScreen.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/QueryDetailScreen.kt index edb8e45919b..bdd6bbdf67e 100644 --- a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/QueryDetailScreen.kt +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/QueryDetailScreen.kt @@ -40,6 +40,7 @@ import org.dashfoundation.example.navigation.AddressQueries import org.dashfoundation.example.navigation.DecisionProposalsList import org.dashfoundation.example.navigation.Diagnostics import org.dashfoundation.example.navigation.GroveDbPathElements +import org.dashfoundation.example.navigation.MultipleChoiceProposalsList import org.dashfoundation.example.navigation.QueryDetail import org.dashfoundation.example.ui.components.FormSection import org.dashfoundation.example.ui.components.SubmitButton @@ -136,6 +137,20 @@ fun QueriesListScreen(navController: NavHostController) { .clickable { navController.navigate(DecisionProposalsList) } .testTag("votingQueries.decisionProposalsLink"), ) + ListItem( + headlineContent = { Text("Multiple Choice Proposals") }, + supportingContent = { + Text( + "Browse, file and edit questions answered by the choices entered " + + "for them, enter choices and vote among them (protocol " + + "version 15)", + style = MaterialTheme.typography.bodySmall, + ) + }, + modifier = Modifier + .clickable { navController.navigate(MultipleChoiceProposalsList) } + .testTag("votingQueries.multipleChoiceProposalsLink"), + ) ListItem( headlineContent = { Text("Run All Queries") }, supportingContent = { diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/QueryRegistry.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/QueryRegistry.kt index 58260589e73..b0bdc04f2d6 100644 --- a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/QueryRegistry.kt +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/QueryRegistry.kt @@ -1,7 +1,6 @@ package org.dashfoundation.example.ui.contracts import org.dashfoundation.dashsdk.Sdk -import org.dashfoundation.dashsdk.voting.DecisionProposal import org.dashfoundation.example.ui.identity.decode32ByteHex /** @@ -598,6 +597,105 @@ internal val QUERY_REGISTRY: List = listOf( ?.toString() }, + // ── Multiple Choice Proposals (protocol version 15) ─────────────────── + // The typed reads of `Sdk.multipleChoiceProposals`, shown as their + // Kotlin values. `MultipleChoiceProposalsScreen` is the full flow (list, + // file, edit, enter a choice, vote); these rows run each read on its own. + QueryDefinition( + name = "getMultipleChoiceProposal", + label = "Get Multiple Choice Proposal", + description = "Fetch a multiple choice proposal by its base58 id.", + inputs = listOf(QueryInput("proposalId", "Proposal ID", required = true)), + runsInDiagnostics = false, + ) { sdk, inputs -> + sdk.multipleChoiceProposals.fetch(inputs.getValue("proposalId").trim())?.toString() + }, + QueryDefinition( + name = "getMultipleChoiceProposalsByOwner", + label = "Get Multiple Choice Proposals by Owner", + description = "The multiple choice proposals an identity filed, in the order it filed them.", + inputs = listOf( + QueryInput("ownerId", "Owner Identity ID", required = true), + QueryInput("limit", "Limit", required = false, placeholder = "20"), + QueryInput("startAfter", "Start after proposal ID", required = false), + ), + runsInDiagnostics = false, + ) { sdk, inputs -> + sdk.multipleChoiceProposals.listByOwner( + ownerId = inputs.getValue("ownerId").trim(), + limit = inputs["limit"]?.trim()?.toIntOrNull() ?: 0, + startAfter = inputs["startAfter"]?.trim()?.takeIf { it.isNotEmpty() }, + ).describeProposals() + }, + QueryDefinition( + name = "getMultipleChoiceProposalsByCreatedAt", + label = "Get Multiple Choice Proposals by Creation", + description = "Every multiple choice proposal, newest first.", + inputs = listOf( + QueryInput("limit", "Limit", required = false, placeholder = "20"), + QueryInput("startAfter", "Start after proposal ID", required = false), + ), + runsInDiagnostics = false, + ) { sdk, inputs -> + sdk.multipleChoiceProposals.listByCreatedAt( + limit = inputs["limit"]?.trim()?.toIntOrNull() ?: 0, + startAfter = inputs["startAfter"]?.trim()?.takeIf { it.isNotEmpty() }, + ).describeProposals() + }, + QueryDefinition( + name = "getMultipleChoiceProposalVote", + label = "Get Multiple Choice Proposal Vote", + description = "The choices of a proposal with their tallies, and how the vote ended once it did.", + inputs = listOf(QueryInput("proposalId", "Proposal ID", required = true)), + runsInDiagnostics = false, + ) { sdk, inputs -> + sdk.multipleChoiceProposals.vote(inputs.getValue("proposalId").trim()).toString() + }, + QueryDefinition( + name = "getMultipleChoiceProposalKeptChoice", + label = "Get Multiple Choice Proposal Kept Choice", + description = "The choice a proposal's finished vote kept.", + inputs = listOf(QueryInput("proposalId", "Proposal ID", required = true)), + runsInDiagnostics = false, + ) { sdk, inputs -> + sdk.multipleChoiceProposals.keptChoice(inputs.getValue("proposalId").trim())?.toString() + }, + QueryDefinition( + name = "getMasternodeMultipleChoiceVote", + label = "Get Masternode Multiple Choice Vote", + description = "A masternode's answer among a proposal's choices while the vote runs.", + inputs = listOf( + QueryInput("proTxHash", "pro_tx_hash (64 hex chars, wire order)", required = true), + QueryInput("proposalId", "Proposal ID", required = true), + ), + runsInDiagnostics = false, + ) { sdk, inputs -> + val proTxHash = requireNotNull(decode32ByteHex(inputs.getValue("proTxHash"))) { + "pro_tx_hash must be 32 bytes (64 hex characters)" + } + sdk.multipleChoiceProposals + .masternodeVote(proTxHash, inputs.getValue("proposalId").trim()) + ?.toString() + }, + QueryDefinition( + name = "getMultipleChoiceProposalProcessingFee", + label = "Get Multiple Choice Proposal Processing Fee", + description = "What creating a multiple choice proposal adds to the processing fee, in credits.", + inputs = emptyList(), + runsInDiagnostics = false, + ) { sdk, _ -> + "${sdk.multipleChoiceProposals.processingFee()} credits" + }, + QueryDefinition( + name = "getMultipleChoiceProposalChoiceFundToJoin", + label = "Get Choice Fund to Join", + description = "The contest fund a choice entered now for a proposal pays, in credits.", + inputs = listOf(QueryInput("proposalId", "Proposal ID", required = true)), + runsInDiagnostics = false, + ) { sdk, inputs -> + "${sdk.multipleChoiceProposals.choiceFundToJoin(inputs.getValue("proposalId").trim())} credits" + }, + // ── Protocol & Version ──────────────────────────────────────────────── QueryDefinition( name = "getProtocolVersionUpgradeState", @@ -898,7 +996,10 @@ internal val QUERY_REGISTRY: List = listOf( }, ) -/** A decision proposal listing page as text: its size, then one proposal per line. */ -private fun List.describeProposals(): String = +/** + * A decision proposal listing page (yes/no or multiple choice) as text: its size, then one + * proposal per line. + */ +private fun List.describeProposals(): String = "$size proposal" + (if (size == 1) "" else "s") + joinToString(separator = "\n", prefix = if (isEmpty()) "" else "\n") diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/DecisionProposalDetailScreen.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/DecisionProposalDetailScreen.kt index c76d1737cdd..1be5cd5b379 100644 --- a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/DecisionProposalDetailScreen.kt +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/DecisionProposalDetailScreen.kt @@ -255,9 +255,10 @@ fun DecisionProposalDetailScreen( /** * [read]'s value, or null after handing its failure to [onError], so one failed read - * leaves the others shown. Cancellation is rethrown, never reported as a failure. + * leaves the others shown. Cancellation is rethrown, never reported as a failure. Shared + * with the multiple choice proposal detail screen. */ -private suspend fun readOrNull(onError: (Exception) -> Unit, read: suspend () -> T?): T? = +internal suspend fun readOrNull(onError: (Exception) -> Unit, read: suspend () -> T?): T? = try { read() } catch (e: CancellationException) { diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/MultipleChoiceProposalDetailScreen.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/MultipleChoiceProposalDetailScreen.kt new file mode 100644 index 00000000000..5133c414ce4 --- /dev/null +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/MultipleChoiceProposalDetailScreen.kt @@ -0,0 +1,1022 @@ +package org.dashfoundation.example.ui.identity + +import androidx.activity.compose.BackHandler +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.icons.filled.Refresh +import androidx.compose.material3.AlertDialog +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TextButton +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.text.input.PasswordVisualTransformation +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.DialogProperties +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.viewmodel.compose.viewModel +import androidx.navigation.NavHostController +import java.util.Date +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.launch +import org.dashfoundation.dashsdk.persistence.entities.IdentityEntity +import org.dashfoundation.dashsdk.voting.DescriptionDocumentParams +import org.dashfoundation.dashsdk.voting.MultipleChoiceProposal +import org.dashfoundation.dashsdk.voting.MultipleChoiceProposalEdit +import org.dashfoundation.dashsdk.voting.MultipleChoiceProposalVote +import org.dashfoundation.dashsdk.voting.MultipleChoiceVoteChoice +import org.dashfoundation.dashsdk.voting.ProposalChoice +import org.dashfoundation.dashsdk.voting.ProposalChoiceParams +import org.dashfoundation.example.di.LocalAppContainer +import org.dashfoundation.example.di.LocalAppState +import org.dashfoundation.example.ui.components.AccessiblePicker +import org.dashfoundation.example.ui.components.FormSection +import org.dashfoundation.example.ui.components.LabeledContent +import org.dashfoundation.example.ui.components.SubmitButton +import org.dashfoundation.example.ui.tokens.displayLabel +import org.dashfoundation.example.util.Base58 +import org.dashfoundation.example.util.formatCredits +import org.dashfoundation.example.util.formatDate +import org.dashfoundation.example.util.toHex +import org.dashfoundation.example.util.truncateMiddle + +/** + * One multiple choice proposal: port of `MultipleChoiceProposalDetailView.swift`, beside + * the yes/no [DecisionProposalDetailScreen]. + * + * Reads the proposal, the vote among its choices and, once the vote ended, the choice it + * kept through `Sdk.multipleChoiceProposals` (each independently, so one failing read + * leaves the others shown). Shows the choices with their tallies while the vote runs and + * how it ended afterwards. Offers the masternode vote ([MultipleChoiceVoteDialog], the same + * credentials [ContestDetailScreen] collects), entering a choice for a local wallet + * identity ([EnterChoiceDialog]) and, when a local wallet identity filed the proposal, the + * edit ([EditMultipleChoiceProposalDialog]). + * + * Entering a choice pays the contest fund, so it runs in [choiceEntry], which the screen's + * back-stack entry holds, and Back is held while it runs. + */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun MultipleChoiceProposalDetailScreen( + proposalId: String, + navController: NavHostController, + choiceEntry: MultipleChoiceDocumentCreateViewModel = viewModel(), +) { + val appState = LocalAppState.current + val container = LocalAppContainer.current + val sdk by appState.sdk.collectAsStateWithLifecycle() + val network by appState.currentNetwork.collectAsStateWithLifecycle() + val walletIdentities by container.database.identityDao() + .observeWalletOwnedByNetwork(network.ffiValue) + .collectAsStateWithLifecycle(initialValue = emptyList()) + + var proposal by remember { mutableStateOf(null) } + var vote by remember { mutableStateOf(null) } + var keptChoice by remember { mutableStateOf(null) } + var proposalError by remember { mutableStateOf(null) } + var voteError by remember { mutableStateOf(null) } + var isLoading by remember { mutableStateOf(false) } + var refreshTick by remember { mutableStateOf(0) } + + var showVote by remember { mutableStateOf(false) } + var showEnterChoice by remember { mutableStateOf(false) } + var showEdit by remember { mutableStateOf(false) } + var actionMessage by remember { mutableStateOf(null) } + + LaunchedEffect(sdk, proposalId, refreshTick) { + val currentSdk = sdk ?: run { + proposalError = "SDK not initialized" + return@LaunchedEffect + } + isLoading = true + proposalError = null + voteError = null + try { + proposal = readOrNull({ proposalError = "Loading the proposal failed: ${it.message}" }) { + currentSdk.multipleChoiceProposals.fetch(proposalId) + } + if (proposal == null && proposalError == null) { + proposalError = "Platform has no multiple choice proposal $proposalId." + } + val read = readOrNull({ voteError = "Loading the vote failed: ${it.message}" }) { + currentSdk.multipleChoiceProposals.vote(proposalId) + } + vote = read + // The choices not kept are gone once the vote ended; the kept one is a read of + // its own. + keptChoice = if (read?.result != null) { + readOrNull({ voteError = "Loading the kept choice failed: ${it.message}" }) { + currentSdk.multipleChoiceProposals.keptChoice(proposalId) + } + } else { + null + } + } finally { + isLoading = false + } + } + + // A choice Platform confirmed, also when its dialog left composition meanwhile. + val enteredChoiceId = choiceEntry.createdId + LaunchedEffect(enteredChoiceId) { + if (enteredChoiceId != null) { + showEnterChoice = false + actionMessage = "Choice entered: ${truncateMiddle(enteredChoiceId, 12, 8)}" + choiceEntry.acknowledge() + refreshTick++ + } + } + + // The local wallet identity that filed the proposal, which may edit it. + val owner = remember(proposal, walletIdentities) { + proposal?.let { shown -> + walletIdentities.firstOrNull { Base58.encode(it.identityId) == shown.ownerId } + } + } + + val isEnteringChoice = choiceEntry.isSubmitting + // System Back would pop the entry and clear the paid choice entry with it; the toolbar + // Back is disabled for the same reason. + BackHandler(enabled = isEnteringChoice) {} + + Scaffold( + topBar = { + TopAppBar( + title = { Text("Multiple Choice Proposal") }, + navigationIcon = { + IconButton( + onClick = { navController.popBackStack() }, + enabled = !isEnteringChoice, + ) { + Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back") + } + }, + actions = { + IconButton( + onClick = { refreshTick++ }, + enabled = !isLoading, + modifier = Modifier.testTag("multipleChoiceProposal.refresh"), + ) { + Icon(Icons.Default.Refresh, contentDescription = "Refresh") + } + }, + ) + }, + ) { padding -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(padding) + .verticalScroll(rememberScrollState()) + .padding(16.dp), + verticalArrangement = Arrangement.spacedBy(16.dp), + ) { + proposalError?.let { message -> + Text( + message, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + modifier = Modifier.testTag("multipleChoiceProposal.error"), + ) + } + + val shown = proposal + if (shown != null) { + MultipleChoiceProposalSection(shown, isOwnerLocal = owner != null) + } + + MultipleChoiceVoteSection( + vote = vote, + keptChoice = keptChoice, + isLoading = isLoading, + error = voteError, + ) + + FormSection(title = "Actions") { + actionMessage?.let { message -> + Text( + message, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.primary, + modifier = Modifier.testTag("multipleChoiceProposal.actionResult"), + ) + } + SubmitButton( + text = "Vote as a Masternode…", + isLoading = false, + // Platform takes votes only while the vote runs + enabled = sdk != null && shown != null && vote?.result == null, + modifier = Modifier.fillMaxWidth().testTag("multipleChoiceProposal.vote"), + ) { + actionMessage = null + showVote = true + } + Text( + "Only masternodes vote, with the voting key of a pro_tx_hash: for one " + + "choice, for none of the choices, or abstaining. A regular wallet " + + "has no voting key, so Platform refuses its vote.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + if (walletIdentities.isNotEmpty()) { + SubmitButton( + text = if (isEnteringChoice) "Entering a Choice…" else "Enter a Choice…", + isLoading = isEnteringChoice, + enabled = sdk != null && shown != null && vote?.result == null, + modifier = Modifier + .fillMaxWidth() + .testTag("multipleChoiceProposal.enterChoice"), + ) { + actionMessage = null + choiceEntry.error = null + showEnterChoice = true + } + // Shown here when the dialog that started the entry is gone (a rotation). + if (!showEnterChoice) { + choiceEntry.error?.let { message -> + Text( + message, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + modifier = Modifier.testTag("multipleChoiceProposal.enterChoiceError"), + ) + } + } + Text( + "A choice pays the contest fund on top of the fees and is never " + + "edited. For this proposal, " + + (shown?.whoEntersChoices() ?: "Platform says who enters choices") + ".", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + if (owner != null) { + SubmitButton( + text = "Edit…", + isLoading = false, + enabled = sdk != null && shown != null, + modifier = Modifier.fillMaxWidth().testTag("multipleChoiceProposal.edit"), + ) { + actionMessage = null + showEdit = true + } + Text( + "Platform accepts an edit of the title, description document and " + + "url for a short time after the proposal is created, and " + + "refuses it afterwards. Whether the proposal is open never " + + "changes.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + } + } + } + + val shown = proposal + if (showVote && shown != null) { + MultipleChoiceVoteDialog( + proposal = shown, + vote = vote, + onDismiss = { showVote = false }, + onVoted = { message -> + showVote = false + actionMessage = message + refreshTick++ // pull fresh tallies after an accepted vote + }, + ) + } + if (showEnterChoice && shown != null && walletIdentities.isNotEmpty()) { + EnterChoiceDialog( + proposal = shown, + identities = walletIdentities, + proposer = owner, + entry = choiceEntry, + onDismiss = { showEnterChoice = false }, + ) + } + val editor = owner + if (showEdit && shown != null && editor != null) { + EditMultipleChoiceProposalDialog( + proposal = shown, + owner = editor, + onDismiss = { showEdit = false }, + onEdited = { message -> + showEdit = false + actionMessage = message + refreshTick++ + }, + ) + } +} + +@Composable +private fun MultipleChoiceProposalSection(proposal: MultipleChoiceProposal, isOwnerLocal: Boolean) { + FormSection(title = "Proposal") { + Text( + proposal.title, + style = MaterialTheme.typography.titleMedium, + modifier = Modifier.testTag("multipleChoiceProposal.title"), + ) + proposal.url?.let { LabeledContent("URL", it) } + proposal.descriptionDocument?.let { described -> + LabeledContent( + "Description document", + truncateMiddle(described.id, 12, 8), + modifier = Modifier.testTag("multipleChoiceProposal.descriptionDocument"), + ) + LabeledContent("In contract", truncateMiddle(described.contractId, 12, 8)) + LabeledContent("Of type", described.documentType) + } + LabeledContent( + "Choices", + proposal.whoEntersChoices(), + modifier = Modifier.testTag("multipleChoiceProposal.open"), + ) + LabeledContent("ID", truncateMiddle(proposal.id, 12, 8)) + LabeledContent( + "Proposer", + truncateMiddle(proposal.ownerId, 10, 6) + if (isOwnerLocal) " (local)" else "", + ) + proposal.revision?.let { LabeledContent("Revision", "$it") } + proposal.createdAtMs?.let { LabeledContent("Created", formatDate(Date(it))) } + proposal.updatedAtMs?.let { LabeledContent("Updated", formatDate(Date(it))) } + } +} + +@Composable +private fun MultipleChoiceVoteSection( + vote: MultipleChoiceProposalVote?, + keptChoice: ProposalChoice?, + isLoading: Boolean, + error: String?, +) { + FormSection(title = "Vote") { + error?.let { message -> + Text( + message, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + modifier = Modifier.testTag("multipleChoiceProposal.voteError"), + ) + } + when { + vote != null -> MultipleChoiceVoteRows(vote, keptChoice) + isLoading -> LabeledContent("Status", "Loading…") + } + Text( + "A vote names a choice by its id. The choice with the most votes is kept as an " + + "ordinary document and the others are gone, unless the votes for none of " + + "the choices outnumber it. Abstaining is recorded but plays no part in " + + "the result.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } +} + +@Composable +private fun MultipleChoiceVoteRows(vote: MultipleChoiceProposalVote, keptChoice: ProposalChoice?) { + val result = vote.result + LabeledContent( + "Status", + when { + result != null -> result.outcome.label() + vote.choices.isEmpty() -> "No choice entered" + else -> "Voting open" + }, + modifier = Modifier.testTag("multipleChoiceProposal.voteStatus"), + ) + if (result != null) { + result.keptChoiceId?.let { keptId -> + LabeledContent( + "Kept choice", + keptChoice?.title ?: truncateMiddle(keptId, 12, 8), + modifier = Modifier.testTag("multipleChoiceProposal.keptChoice"), + ) + keptChoice?.description?.let { Text(it, style = MaterialTheme.typography.bodyMedium) } + LabeledContent("Kept choice ID", truncateMiddle(keptId, 12, 8)) + } + LabeledContent("Closed at block", "${result.finalizationBlock.height}") + } + vote.choices.forEach { entry -> + val kept = result?.keptChoiceId == entry.id + // Once the vote ended the choices are gone from the vote; the kept one is known. + val title = entry.choice?.title + ?: keptChoice?.takeIf { kept }?.title + ?: truncateMiddle(entry.id, 12, 8) + LabeledContent( + title + if (kept) " (kept)" else "", + entry.voteTally.tally(), + modifier = Modifier.testTag("multipleChoiceProposal.choice.${entry.id}"), + ) + entry.choice?.description?.let { + Text( + it, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + entry.choice?.let { + Text( + "${truncateMiddle(entry.id, 12, 8)} · entered by ${truncateMiddle(it.ownerId, 10, 6)}", + style = MaterialTheme.typography.labelSmall.copy(fontFamily = FontFamily.Monospace), + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + } + LabeledContent( + "None of the choices", + vote.noneOfTheChoicesVoteTally.tally(), + modifier = Modifier.testTag("multipleChoiceProposal.noneOfTheChoices"), + ) + LabeledContent( + "Abstain", + vote.abstainVoteTally.tally(), + modifier = Modifier.testTag("multipleChoiceProposal.abstain"), + ) +} + +/** A tally as text; Platform does not report every tally. */ +private fun Long?.tally(): String = this?.let { "$it" } ?: "not reported" + +/** How a finished vote ended, as the status row says it. */ +private fun MultipleChoiceProposalVote.Outcome.label(): String = when (this) { + MultipleChoiceProposalVote.Outcome.KEPT_CHOICE -> "Ended: a choice was kept" + MultipleChoiceProposalVote.Outcome.NONE_OF_THE_CHOICES -> "Ended: none of the choices was kept" + MultipleChoiceProposalVote.Outcome.NO_WINNER -> "Ended without a winner" +} + +/** Display name of a vote answer; a choice shows its title when the vote still holds it. */ +private fun MultipleChoiceVoteChoice.label(vote: MultipleChoiceProposalVote?): String = when (this) { + is MultipleChoiceVoteChoice.Choice -> { + val title = vote?.choices?.firstOrNull { it.id == choiceId }?.choice?.title + val id = truncateMiddle(choiceId, 8, 6) + if (title != null) "$title ($id)" else id + } + MultipleChoiceVoteChoice.NoneOfTheChoices -> "None of the choices" + MultipleChoiceVoteChoice.Abstain -> "Abstain" +} + +/** + * Picks an answer and takes masternode credentials: port of + * `MultipleChoiceProposalVoteSheet` in `MultipleChoiceProposalDetailView.swift`. Votes + * through `Sdk.multipleChoiceProposals.castVote`, and reads the masternode's current answer + * through `Sdk.multipleChoiceProposals.masternodeVote`. The answers offered are the choices + * the vote holds, each by its document id, none of the choices, and abstaining. + * + * The voting private key is masked as it is typed, and screen capture is blocked while the + * dialog is open (see [HoldSecureWindow]). The dialog cannot be dismissed, by Back or a tap + * outside, while a call runs. + */ +@Composable +private fun MultipleChoiceVoteDialog( + proposal: MultipleChoiceProposal, + vote: MultipleChoiceProposalVote?, + onDismiss: () -> Unit, + onVoted: (String) -> Unit, +) { + val appState = LocalAppState.current + val scope = rememberCoroutineScope() + val sdk by appState.sdk.collectAsStateWithLifecycle() + HoldSecureWindow() + + val answers: List = remember(vote) { + vote?.choices.orEmpty().map { MultipleChoiceVoteChoice.Choice(it.id) } + + listOf(MultipleChoiceVoteChoice.NoneOfTheChoices, MultipleChoiceVoteChoice.Abstain) + } + var choice by remember { mutableStateOf(answers.first()) } + var proTxHashHex by remember { mutableStateOf("") } + var votingKeyHex by remember { mutableStateOf("") } + var isBusy by remember { mutableStateOf(false) } + var message by remember { mutableStateOf(null) } + var messageIsError by remember { mutableStateOf(false) } + + AlertDialog( + onDismissRequest = { if (!isBusy) onDismiss() }, + properties = secureDialogProperties(dismissible = !isBusy), + title = { Text("Vote · ${truncateMiddle(proposal.title, 20, 8)}") }, + text = { + Column(verticalArrangement = Arrangement.spacedBy(12.dp)) { + AccessiblePicker( + label = "Answer", + options = answers, + selected = choice, + optionLabel = { it.label(vote) }, + testTag = "multipleChoiceProposalVote.choice", + enabled = !isBusy, + onSelected = { choice = it }, + ) + OutlinedTextField( + value = proTxHashHex, + onValueChange = { proTxHashHex = it }, + label = { Text("pro_tx_hash (64 hex chars, wire order)") }, + singleLine = true, + enabled = !isBusy, + textStyle = MaterialTheme.typography.bodySmall + .copy(fontFamily = FontFamily.Monospace), + modifier = Modifier.fillMaxWidth().testTag("multipleChoiceProposalVote.proTxHash"), + ) + OutlinedTextField( + value = votingKeyHex, + onValueChange = { votingKeyHex = it }, + label = { Text("voting private key (64 hex chars)") }, + singleLine = true, + enabled = !isBusy, + textStyle = MaterialTheme.typography.bodySmall + .copy(fontFamily = FontFamily.Monospace), + // KeyboardType.Password only configures the keyboard; the + // transformation masks what the field shows. + visualTransformation = PasswordVisualTransformation(), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password), + modifier = Modifier.fillMaxWidth().testTag("multipleChoiceProposalVote.votingKey"), + ) + Text( + "The pro_tx_hash goes in wire order, the reverse of the hex Core " + + "displays. The voting public key and signer are derived from the " + + "private key on the Rust side; the key bytes are not stored.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + TextButton( + enabled = !isBusy && proTxHashHex.isNotBlank(), + onClick = { + val currentSdk = sdk ?: return@TextButton + val proTxHash = decode32ByteHex(proTxHashHex) + if (proTxHash == null) { + message = "pro_tx_hash must be 32 bytes (64 hex characters)." + messageIsError = true + return@TextButton + } + isBusy = true + scope.launch { + try { + val answer = currentSdk.multipleChoiceProposals + .masternodeVote(proTxHash, proposal.id) + message = answer?.let { + "This masternode answered ${it.label(vote)}." + } ?: "This masternode has no answer in the running vote." + messageIsError = false + } catch (e: CancellationException) { + throw e + } catch (e: Exception) { + message = "Reading the answer failed: ${e.message}" + messageIsError = true + } finally { + isBusy = false + } + } + }, + modifier = Modifier.testTag("multipleChoiceProposalVote.lookUp"), + ) { Text("Read This Masternode's Answer") } + message?.let { + Text( + it, + style = MaterialTheme.typography.bodySmall, + color = if (messageIsError) { + MaterialTheme.colorScheme.error + } else { + MaterialTheme.colorScheme.primary + }, + modifier = Modifier.testTag("multipleChoiceProposalVote.result"), + ) + } + } + }, + confirmButton = { + TextButton( + enabled = !isBusy && proTxHashHex.isNotBlank() && votingKeyHex.isNotBlank(), + onClick = { + val currentSdk = sdk ?: return@TextButton + val proTxHash = decode32ByteHex(proTxHashHex) + if (proTxHash == null) { + message = "pro_tx_hash must be 32 bytes (64 hex characters)." + messageIsError = true + return@TextButton + } + val votingKey = decode32ByteHex(votingKeyHex) + if (votingKey == null) { + message = "Voting private key must be 32 bytes (64 hex characters)." + messageIsError = true + return@TextButton + } + isBusy = true + scope.launch { + try { + currentSdk.multipleChoiceProposals.castVote( + proposalId = proposal.id, + choice = choice, + proTxHash = proTxHash, + votingPrivateKey = votingKey, + ) + onVoted("Vote accepted by Platform.") + } catch (e: CancellationException) { + throw e + } catch (e: Exception) { + message = "Vote rejected: ${e.message}" + messageIsError = true + } finally { + votingKey.fill(0) + isBusy = false + } + } + }, + modifier = Modifier.testTag("multipleChoiceProposalVote.submit"), + ) { Text(if (isBusy) "Broadcasting…" else "Submit Vote") } + }, + dismissButton = { + TextButton(enabled = !isBusy, onClick = onDismiss) { Text("Cancel") } + }, + ) +} + +/** + * Enters a choice for a proposal as a local wallet identity: port of + * `EnterProposalChoiceView` (`MultipleChoiceProposalFormViews.swift`). Submits through + * `PlatformWalletManager.multipleChoiceProposals.enterChoice`, one platform wallet call that + * builds the choice, states the contest fund, signs with a key it picks and waits for + * Platform to confirm. The fund is read through `Sdk.multipleChoiceProposals.choiceFundToJoin` + * and shown before the submit. + * + * The entry runs in [entry], held by the detail screen's back-stack entry, so a dialog that + * leaves composition (a rotation) does not cancel a paid choice; the detail screen reports + * its outcome. The dialog cannot be dismissed while the entry runs. Who may enter a choice + * is Platform's to say: any local wallet identity can be picked. + */ +@Composable +private fun EnterChoiceDialog( + proposal: MultipleChoiceProposal, + identities: List, + proposer: IdentityEntity?, + entry: MultipleChoiceDocumentCreateViewModel, + onDismiss: () -> Unit, +) { + val appState = LocalAppState.current + val container = LocalAppContainer.current + val sdk by appState.sdk.collectAsStateWithLifecycle() + val manager by container.walletManagerStore.activeManager.collectAsStateWithLifecycle() + + var owner by remember { mutableStateOf(proposer ?: identities.first()) } + var title by remember { mutableStateOf("") } + var description by remember { mutableStateOf("") } + val isSubmitting = entry.isSubmitting + + // The fund a choice entered now pays, read rather than assumed: it rises as the vote + // fills up. + var fund by remember { mutableStateOf(null) } + var fundError by remember { mutableStateOf(null) } + LaunchedEffect(sdk, proposal.id) { + fund = null + fundError = null + val currentSdk = sdk ?: return@LaunchedEffect + try { + fund = currentSdk.multipleChoiceProposals.choiceFundToJoin(proposal.id) + } catch (e: CancellationException) { + throw e + } catch (e: Exception) { + fundError = "Reading the contest fund failed: ${e.message}" + } + } + + AlertDialog( + onDismissRequest = { if (!isSubmitting) onDismiss() }, + properties = DialogProperties( + dismissOnBackPress = !isSubmitting, + dismissOnClickOutside = !isSubmitting, + ), + title = { Text("Enter a Choice") }, + text = { + Column(verticalArrangement = Arrangement.spacedBy(12.dp)) { + AccessiblePicker( + label = "Entered by", + options = identities, + selected = owner, + optionLabel = { it.displayLabel() }, + testTag = "enterProposalChoice.ownerPicker", + enabled = !isSubmitting, + onSelected = { owner = it }, + ) + OutlinedTextField( + value = title, + onValueChange = { title = it }, + label = { Text("Title: the answer, in one line") }, + singleLine = true, + enabled = !isSubmitting, + modifier = Modifier.fillMaxWidth().testTag("enterProposalChoice.title"), + ) + OutlinedTextField( + value = description, + onValueChange = { description = it }, + label = { Text("Description: what voting for it means (optional)") }, + minLines = 3, + enabled = !isSubmitting, + modifier = Modifier.fillMaxWidth().testTag("enterProposalChoice.description"), + ) + LabeledContent( + "Contest fund", + fund?.let { formatCredits(it) } + ?: if (fundError == null) "Loading…" else "Unavailable", + modifier = Modifier.testTag("enterProposalChoice.fund"), + ) + Text( + "The choice pays the contest fund on top of the fees and is never " + + "edited. For this proposal, ${proposal.whoEntersChoices()}.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + (entry.error ?: fundError)?.let { + Text( + it, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + modifier = Modifier.testTag("enterProposalChoice.error"), + ) + } + } + }, + confirmButton = { + TextButton( + enabled = !isSubmitting && manager != null, + onClick = { + val mgr = manager ?: return@TextButton + val wallet = owner.walletId?.toHex()?.let { mgr.wallets.value[it] } + if (wallet == null) { + entry.error = "The identity's wallet is not loaded in the wallet manager." + return@TextButton + } + val proposalIdBytes = Base58.decodeIdentifier(proposal.id) + if (proposalIdBytes == null) { + entry.error = "The proposal id is not a 32-byte base58 identifier." + return@TextButton + } + val enteredBy = owner.identityId + val params = ProposalChoiceParams( + title = title, + description = description.ifBlank { null }, + ) + entry.submit { + mgr.multipleChoiceProposals.enterChoice( + walletHandle = wallet.handle, + ownerId = enteredBy, + proposalId = proposalIdBytes, + params = params, + signerHandle = mgr.signerHandle, + ).id + } + }, + modifier = Modifier.testTag("enterProposalChoice.submitButton"), + ) { Text(if (isSubmitting) "Broadcasting…" else "Enter / Broadcast") } + }, + dismissButton = { + TextButton(enabled = !isSubmitting, onClick = onDismiss) { Text("Cancel") } + }, + ) +} + +/** + * Gives a proposal a local identity filed a new title, url or description document: port + * of `EditMultipleChoiceProposalView` (`MultipleChoiceProposalFormViews.swift`). Submits + * through `PlatformWalletManager.multipleChoiceProposals.edit`, one platform wallet call + * that reads the stored proposal, applies the edit (rs-sdk refuses one that changes + * nothing), signs with a key it picks and waits for Platform to confirm. + * + * The dialog cannot be dismissed (Back or a tap outside) while the edit runs, so the + * replace running in its scope is not cancelled with it. Should the dialog still leave + * composition mid-edit (a rotation), the detail screen reads the proposal again, and an edit + * repeating one that landed changes nothing, which rs-sdk refuses before anything is + * broadcast. + */ +@Composable +private fun EditMultipleChoiceProposalDialog( + proposal: MultipleChoiceProposal, + owner: IdentityEntity, + onDismiss: () -> Unit, + onEdited: (String) -> Unit, +) { + val container = LocalAppContainer.current + val scope = rememberCoroutineScope() + val manager by container.walletManagerStore.activeManager.collectAsStateWithLifecycle() + + val described = proposal.descriptionDocument + var title by remember { mutableStateOf(proposal.title) } + var url by remember { mutableStateOf(proposal.url.orEmpty()) } + var describedId by remember { mutableStateOf(described?.id.orEmpty()) } + var describedContractId by remember { mutableStateOf(described?.contractId.orEmpty()) } + var describedType by remember { mutableStateOf(described?.documentType.orEmpty()) } + var isSubmitting by remember { mutableStateOf(false) } + var error by remember { mutableStateOf(null) } + + AlertDialog( + onDismissRequest = { if (!isSubmitting) onDismiss() }, + properties = DialogProperties( + dismissOnBackPress = !isSubmitting, + dismissOnClickOutside = !isSubmitting, + ), + title = { Text("Edit Proposal") }, + text = { + Column( + verticalArrangement = Arrangement.spacedBy(12.dp), + modifier = Modifier.verticalScroll(rememberScrollState()), + ) { + OutlinedTextField( + value = title, + onValueChange = { title = it }, + label = { Text("Title") }, + singleLine = true, + enabled = !isSubmitting, + modifier = Modifier.fillMaxWidth().testTag("editMultipleChoiceProposal.title"), + ) + OutlinedTextField( + value = url, + onValueChange = { url = it }, + label = { Text("URL (empty for none)") }, + singleLine = true, + enabled = !isSubmitting, + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri), + modifier = Modifier.fillMaxWidth().testTag("editMultipleChoiceProposal.url"), + ) + OutlinedTextField( + value = describedId, + onValueChange = { describedId = it }, + label = { Text("Description document ID (empty for none)") }, + singleLine = true, + enabled = !isSubmitting, + modifier = Modifier + .fillMaxWidth() + .testTag("editMultipleChoiceProposal.descriptionDocumentId"), + ) + OutlinedTextField( + value = describedContractId, + onValueChange = { describedContractId = it }, + label = { Text("Its contract ID") }, + singleLine = true, + enabled = !isSubmitting, + modifier = Modifier + .fillMaxWidth() + .testTag("editMultipleChoiceProposal.descriptionDocumentContractId"), + ) + OutlinedTextField( + value = describedType, + onValueChange = { describedType = it }, + label = { Text("Its document type") }, + singleLine = true, + enabled = !isSubmitting, + modifier = Modifier + .fillMaxWidth() + .testTag("editMultipleChoiceProposal.descriptionDocumentType"), + ) + Text( + "Only the title, url and description document can change, and only " + + "for a short time after the proposal was created. Platform " + + "refuses an edit that leaves the proposal with neither a " + + "description document nor a url.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + error?.let { + Text( + it, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + modifier = Modifier.testTag("editMultipleChoiceProposal.error"), + ) + } + } + }, + confirmButton = { + TextButton( + enabled = !isSubmitting && manager != null, + onClick = { + val mgr = manager ?: return@TextButton + val wallet = owner.walletId?.toHex()?.let { mgr.wallets.value[it] } + if (wallet == null) { + error = "The proposer's wallet is not loaded in the wallet manager." + return@TextButton + } + val proposalIdBytes = Base58.decodeIdentifier(proposal.id) + if (proposalIdBytes == null) { + error = "The proposal id is not a 32-byte base58 identifier." + return@TextButton + } + val edit = when ( + val built = multipleChoiceProposalEdit( + proposal = proposal, + title = title, + url = url, + describedId = describedId, + describedContractId = describedContractId, + describedType = describedType, + ) + ) { + is BuiltMultipleChoiceEdit.Unreadable -> { + error = built.message + return@TextButton + } + is BuiltMultipleChoiceEdit.Edit -> built.edit + } + isSubmitting = true + error = null + scope.launch { + try { + mgr.multipleChoiceProposals.edit( + walletHandle = wallet.handle, + ownerId = owner.identityId, + proposalId = proposalIdBytes, + edit = edit, + signerHandle = mgr.signerHandle, + ) + onEdited("Edit accepted by Platform.") + } catch (e: CancellationException) { + throw e + } catch (e: Exception) { + error = e.message ?: "Edit failed" + } finally { + isSubmitting = false + } + } + }, + modifier = Modifier.testTag("editMultipleChoiceProposal.submitButton"), + ) { Text(if (isSubmitting) "Broadcasting…" else "Replace / Broadcast") } + }, + dismissButton = { + TextButton(enabled = !isSubmitting, onClick = onDismiss) { Text("Cancel") } + }, + ) +} + +/** The edit an edit form's fields make, or why a field could not be read. */ +internal sealed interface BuiltMultipleChoiceEdit { + data class Edit(val edit: MultipleChoiceProposalEdit) : BuiltMultipleChoiceEdit + + /** A description document id field does not hold the 32 bytes the wallet call takes. */ + data class Unreadable(val message: String) : BuiltMultipleChoiceEdit +} + +/** + * The edit that turns [proposal], as the form was opened with it, into what the form's + * fields now hold. Only the fields the user changed are sent: an untouched field must not + * write back the value the form was opened with over a newer edit by another client. An + * emptied url removes the url, and three emptied description document fields remove the + * description document. Whether the result is an acceptable proposal is not looked at here. + */ +internal fun multipleChoiceProposalEdit( + proposal: MultipleChoiceProposal, + title: String, + url: String, + describedId: String, + describedContractId: String, + describedType: String, +): BuiltMultipleChoiceEdit { + val trimmedUrl = url.trim() + val urlChange = when { + trimmedUrl == proposal.url.orEmpty() -> MultipleChoiceProposalEdit.Change.Keep + trimmedUrl.isEmpty() -> MultipleChoiceProposalEdit.Change.Remove + else -> MultipleChoiceProposalEdit.Change.Set(trimmedUrl) + } + val described = proposal.descriptionDocument + val describedUntouched = describedId.trim() == described?.id.orEmpty() && + describedContractId.trim() == described?.contractId.orEmpty() && + describedType.trim() == described?.documentType.orEmpty() + val describedChange: MultipleChoiceProposalEdit.Change = + if (describedUntouched) { + MultipleChoiceProposalEdit.Change.Keep + } else { + when (val parsed = parseDescriptionDocument(describedId, describedContractId, describedType)) { + is ParsedDescriptionDocument.Unreadable -> + return BuiltMultipleChoiceEdit.Unreadable(parsed.message) + ParsedDescriptionDocument.None -> MultipleChoiceProposalEdit.Change.Remove + is ParsedDescriptionDocument.Document -> + MultipleChoiceProposalEdit.Change.Set(parsed.document) + } + } + return BuiltMultipleChoiceEdit.Edit( + MultipleChoiceProposalEdit( + title = title.takeIf { it != proposal.title }, + descriptionDocument = describedChange, + url = urlChange, + ), + ) +} diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/MultipleChoiceProposalsScreen.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/MultipleChoiceProposalsScreen.kt new file mode 100644 index 00000000000..124a857da84 --- /dev/null +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/MultipleChoiceProposalsScreen.kt @@ -0,0 +1,703 @@ +package org.dashfoundation.example.ui.identity + +import androidx.activity.compose.BackHandler +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.imePadding +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.filled.Refresh +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.ListItem +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Switch +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.unit.dp +import androidx.lifecycle.ViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.viewModelScope +import androidx.lifecycle.viewmodel.compose.viewModel +import androidx.navigation.NavHostController +import java.util.Date +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.launch +import org.dashfoundation.dashsdk.Sdk +import org.dashfoundation.dashsdk.persistence.entities.IdentityEntity +import org.dashfoundation.dashsdk.voting.DescriptionDocumentParams +import org.dashfoundation.dashsdk.voting.MultipleChoiceProposal +import org.dashfoundation.dashsdk.voting.MultipleChoiceProposalParams +import org.dashfoundation.example.di.LocalAppContainer +import org.dashfoundation.example.di.LocalAppState +import org.dashfoundation.example.navigation.CreateMultipleChoiceProposal +import org.dashfoundation.example.navigation.MultipleChoiceProposalDetail +import org.dashfoundation.example.ui.components.AccessiblePicker +import org.dashfoundation.example.ui.components.ErrorAlertDialog +import org.dashfoundation.example.ui.components.FormSection +import org.dashfoundation.example.ui.components.LabeledContent +import org.dashfoundation.example.ui.components.SubmitButton +import org.dashfoundation.example.ui.tokens.displayLabel +import org.dashfoundation.example.util.Base58 +import org.dashfoundation.example.util.formatCredits +import org.dashfoundation.example.util.formatDate +import org.dashfoundation.example.util.toHex +import org.dashfoundation.example.util.truncateMiddle + +/** The two ways the list reads proposals, each one Platform listing (← `Listing`). */ +private enum class MultipleChoiceListing(val label: String, val footer: String) { + MINE("Mine", "Proposals the selected identity filed, in the order it filed them."), + NEWEST("Newest", "Every multiple choice proposal, newest first."), +} + +/** Proposals per page; a page shorter than this is the last. */ +private const val MULTIPLE_CHOICE_PAGE_SIZE = 20 + +/** + * Multiple choice proposals (protocol version 15): port of + * `MultipleChoiceProposalsView.swift`, beside the yes/no [DecisionProposalsScreen]. + * + * Lists proposals two ways, a page at a time, through `Sdk.multipleChoiceProposals`: the + * ones a local identity filed (`listByOwner`) and the newest (`listByCreatedAt`). Rows drill + * into [MultipleChoiceProposalDetailScreen]; the + action opens + * [CreateMultipleChoiceProposalScreen]. Nothing here decides what a proposal is. + */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun MultipleChoiceProposalsScreen(navController: NavHostController) { + val appState = LocalAppState.current + val container = LocalAppContainer.current + val scope = rememberCoroutineScope() + val sdk by appState.sdk.collectAsStateWithLifecycle() + val network by appState.currentNetwork.collectAsStateWithLifecycle() + val identities by container.database.identityDao() + .observeByNetwork(network.ffiValue) + .collectAsStateWithLifecycle(initialValue = emptyList()) + + var listing by remember { mutableStateOf(MultipleChoiceListing.NEWEST) } + var owner by remember { mutableStateOf(null) } + var proposals by remember { mutableStateOf>(emptyList()) } + var hasMore by remember { mutableStateOf(false) } + var isLoading by remember { mutableStateOf(false) } + var errorMessage by remember { mutableStateOf(null) } + var refreshTick by remember { mutableStateOf(0) } + // Bumped on every fresh load so a late "load more" page of a previous + // listing is dropped instead of mixed in. + var loadGeneration by remember { mutableStateOf(0) } + + // Start "Mine" on the first local identity rather than empty. + LaunchedEffect(listing, identities) { + if (listing == MultipleChoiceListing.MINE && owner == null) owner = identities.firstOrNull() + } + + val ownerBase58 = owner?.let { Base58.encode(it.identityId) } + + LaunchedEffect(sdk, listing, ownerBase58, refreshTick) { + loadGeneration++ + proposals = emptyList() + hasMore = false + errorMessage = null + val currentSdk = sdk ?: run { + errorMessage = "SDK not initialized" + return@LaunchedEffect + } + if (listing == MultipleChoiceListing.MINE && ownerBase58 == null) return@LaunchedEffect + isLoading = true + try { + val page = loadMultipleChoicePage(currentSdk, listing, ownerBase58, startAfter = null) + proposals = page + hasMore = page.size == MULTIPLE_CHOICE_PAGE_SIZE + } catch (e: Exception) { + errorMessage = "Loading failed: ${e.message}" + } finally { + isLoading = false + } + } + + Scaffold( + topBar = { + TopAppBar( + title = { Text("Multiple Choice Proposals") }, + navigationIcon = { + IconButton(onClick = { navController.popBackStack() }) { + Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back") + } + }, + actions = { + IconButton( + onClick = { refreshTick++ }, + enabled = !isLoading, + modifier = Modifier.testTag("multipleChoiceProposals.refresh"), + ) { + Icon(Icons.Default.Refresh, contentDescription = "Refresh") + } + IconButton( + onClick = { navController.navigate(CreateMultipleChoiceProposal) }, + enabled = sdk != null, + modifier = Modifier.testTag("multipleChoiceProposals.create"), + ) { + Icon(Icons.Default.Add, contentDescription = "New multiple choice proposal") + } + }, + ) + }, + ) { padding -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(padding) + .verticalScroll(rememberScrollState()) + .padding(16.dp), + verticalArrangement = Arrangement.spacedBy(16.dp), + ) { + FormSection(title = "Listing") { + AccessiblePicker( + label = "Listing", + options = MultipleChoiceListing.entries, + selected = listing, + optionLabel = { it.label }, + testTag = "multipleChoiceProposals.listing", + onSelected = { listing = it }, + ) + if (listing == MultipleChoiceListing.MINE) { + if (identities.isEmpty()) { + Text( + "No local identity on this network.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } else { + AccessiblePicker( + label = "Identity", + options = identities, + selected = owner ?: identities.first(), + optionLabel = { it.displayLabel() }, + testTag = "multipleChoiceProposals.ownerPicker", + onSelected = { owner = it }, + ) + } + } + Text( + listing.footer, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + + FormSection(title = "Proposals") { + errorMessage?.let { message -> + Text( + message, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + modifier = Modifier.testTag("multipleChoiceProposals.error"), + ) + } + when { + isLoading && proposals.isEmpty() -> CircularProgressIndicator( + modifier = Modifier.padding(8.dp), + ) + listing == MultipleChoiceListing.MINE && ownerBase58 == null -> Text( + "Select an identity to list its proposals.", + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + proposals.isEmpty() && errorMessage == null -> Text( + "No proposals", + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + proposals.forEach { proposal -> + MultipleChoiceProposalRow(proposal) { + navController.navigate(MultipleChoiceProposalDetail(proposal.id)) + } + } + if (hasMore) { + OutlinedButton( + onClick = { + val currentSdk = sdk ?: return@OutlinedButton + val last = proposals.lastOrNull() ?: return@OutlinedButton + val generation = loadGeneration + isLoading = true + scope.launch { + try { + val page = loadMultipleChoicePage( + currentSdk, + listing, + ownerBase58, + startAfter = last.id, + ) + if (generation == loadGeneration) { + proposals = proposals + page + hasMore = page.size == MULTIPLE_CHOICE_PAGE_SIZE + } + } catch (e: Exception) { + if (generation == loadGeneration) { + errorMessage = "Loading failed: ${e.message}" + } + } finally { + isLoading = false + } + } + }, + enabled = !isLoading, + modifier = Modifier + .fillMaxWidth() + .testTag("multipleChoiceProposals.loadMore"), + ) { + Text("Load More") + } + } + } + } + } +} + +/** One page of [listing] after [startAfter] (null for the first page). */ +private suspend fun loadMultipleChoicePage( + sdk: Sdk, + listing: MultipleChoiceListing, + ownerBase58: String?, + startAfter: String?, +): List = when (listing) { + MultipleChoiceListing.MINE -> sdk.multipleChoiceProposals.listByOwner( + ownerId = requireNotNull(ownerBase58) { "no identity selected" }, + limit = MULTIPLE_CHOICE_PAGE_SIZE, + startAfter = startAfter, + ) + MultipleChoiceListing.NEWEST -> sdk.multipleChoiceProposals.listByCreatedAt( + limit = MULTIPLE_CHOICE_PAGE_SIZE, + startAfter = startAfter, + ) +} + +/** One proposal in a listing (← `MultipleChoiceProposalRow`). */ +@Composable +private fun MultipleChoiceProposalRow(proposal: MultipleChoiceProposal, onClick: () -> Unit) { + ListItem( + headlineContent = { Text(proposal.title, maxLines = 2) }, + supportingContent = { + Column { + Text( + listOfNotNull( + proposal.createdAtMs?.let { "Created ${formatDate(Date(it))}" }, + proposal.whoEntersChoices(), + ).joinToString(" · "), + style = MaterialTheme.typography.bodySmall, + ) + Text( + truncateMiddle(proposal.id, 12, 8), + style = MaterialTheme.typography.labelSmall + .copy(fontFamily = FontFamily.Monospace), + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + }, + modifier = Modifier + .clickable(onClick = onClick) + .testTag("multipleChoiceProposals.row.${proposal.id}"), + ) +} + +/** Who may enter choices for this proposal, as the screens say it. */ +internal fun MultipleChoiceProposal.whoEntersChoices(): String = + if (open) "anyone enters choices" else "only its owner enters choices" + +/** + * A paid write of the multiple choice proposal screens that creates a document (the + * proposal on [CreateMultipleChoiceProposalScreen], a choice on + * [MultipleChoiceProposalDetailScreen]), held by the screen's back-stack entry rather than + * by its composition, as [CreateDecisionProposalViewModel] holds the yes/no create. + * + * Creating a proposal pays the processing fee and entering a choice pays the contest fund. + * A coroutine of the composition is cancelled whenever the screen leaves composition (a + * rotation, a switch to another bottom tab), which would drop a write Platform already + * accepted and invite a second, paid retry. The back-stack entry outlives all of those, so + * the write runs to its end and the screen shows the outcome when it composes again. Back, + * which would clear the entry, is held by the screens while the write runs. + */ +class MultipleChoiceDocumentCreateViewModel : ViewModel() { + + /** Whether a write is running. */ + var isSubmitting by mutableStateOf(false) + private set + + /** The message of the last failure, form errors included, until it is dismissed. */ + var error by mutableStateOf(null) + + /** The created document's id, base58, once Platform confirmed the write. */ + var createdId by mutableStateOf(null) + private set + + /** + * Run [create], which returns the created document's id, unless a write is running or + * one succeeded and was not [acknowledge]d: the form is never submitted twice. + */ + fun submit(create: suspend () -> String) { + if (isSubmitting || createdId != null) return + isSubmitting = true + error = null + viewModelScope.launch { + try { + createdId = create() + } catch (e: CancellationException) { + throw e + } catch (e: Exception) { + error = e.message ?: "Broadcast failed" + } finally { + isSubmitting = false + } + } + } + + /** + * Forget a confirmed write once the screen showed it, so that another document (a + * further choice) can be created. Does nothing while a write runs. + */ + fun acknowledge() { + if (!isSubmitting) createdId = null + } +} + +/** + * Files a new multiple choice proposal for an identity held by a loaded wallet: port of + * `CreateMultipleChoiceProposalView` (`MultipleChoiceProposalFormViews.swift`), beside the + * yes/no [CreateDecisionProposalScreen]. + * + * Submits through `PlatformWalletManager.multipleChoiceProposals.create`, one platform + * wallet call that builds the proposal and waits for Platform to confirm; Platform charges + * the proposer the processing fee, which the screen reads through + * `Sdk.multipleChoiceProposals.processingFee` and shows before the submit. The submission + * lives in [MultipleChoiceDocumentCreateViewModel] and Back is held while it runs, so + * leaving the screen never cancels a paid create. Nothing in the form is checked here: + * Platform refuses a proposal outside its limits. + */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun CreateMultipleChoiceProposalScreen( + navController: NavHostController, + submission: MultipleChoiceDocumentCreateViewModel = viewModel(), +) { + val appState = LocalAppState.current + val container = LocalAppContainer.current + val sdk by appState.sdk.collectAsStateWithLifecycle() + val network by appState.currentNetwork.collectAsStateWithLifecycle() + val manager by container.walletManagerStore.activeManager.collectAsStateWithLifecycle() + // Identities on the active network held by a loaded wallet, so the + // manager's signer can sign for them. + val identities by container.database.identityDao() + .observeWalletOwnedByNetwork(network.ffiValue) + .collectAsStateWithLifecycle(initialValue = emptyList()) + + var owner by remember { mutableStateOf(null) } + LaunchedEffect(identities) { + if (owner == null) owner = identities.firstOrNull() + } + var title by rememberSaveable { mutableStateOf("") } + var url by rememberSaveable { mutableStateOf("") } + var describedId by rememberSaveable { mutableStateOf("") } + var describedContractId by rememberSaveable { mutableStateOf("") } + var describedType by rememberSaveable { mutableStateOf("") } + var open by rememberSaveable { mutableStateOf(true) } + + // The processing fee as Platform charges it on this network, read rather than assumed. + var processingFee by remember { mutableStateOf(null) } + var processingFeeError by remember { mutableStateOf(null) } + LaunchedEffect(sdk) { + processingFee = null + processingFeeError = null + val currentSdk = sdk ?: return@LaunchedEffect + try { + processingFee = currentSdk.multipleChoiceProposals.processingFee() + } catch (e: CancellationException) { + throw e + } catch (e: Exception) { + processingFeeError = "Reading the processing fee failed: ${e.message}" + } + } + + val isSubmitting = submission.isSubmitting + // System Back would pop the entry and clear the submission with it; the toolbar Back + // is disabled for the same reason. + BackHandler(enabled = isSubmitting) {} + + Scaffold( + topBar = { + TopAppBar( + title = { Text("New Multiple Choice Proposal") }, + navigationIcon = { + IconButton( + onClick = { navController.popBackStack() }, + enabled = !isSubmitting, + ) { + Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back") + } + }, + ) + }, + ) { padding -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(padding) + .verticalScroll(rememberScrollState()) + .imePadding() + .padding(16.dp), + verticalArrangement = Arrangement.spacedBy(16.dp), + ) { + val createdId = submission.createdId + if (createdId != null) { + FormSection(title = "Proposal Created") { + Text( + "Broadcast confirmed on-chain.", + color = MaterialTheme.colorScheme.primary, + modifier = Modifier.testTag("createMultipleChoiceProposal.success"), + ) + LabeledContent("ID", truncateMiddle(createdId, 12, 8)) + } + SubmitButton( + text = "Done", + isLoading = false, + modifier = Modifier + .fillMaxWidth() + .testTag("createMultipleChoiceProposal.doneButton"), + ) { navController.popBackStack() } + return@Column + } + + FormSection(title = "Proposer") { + if (identities.isEmpty()) { + Text( + "No identity held by a loaded wallet on this network.", + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } else { + AccessiblePicker( + label = "Proposer", + options = identities, + selected = owner ?: identities.first(), + optionLabel = { it.displayLabel() }, + testTag = "createMultipleChoiceProposal.ownerPicker", + enabled = !isSubmitting, + onSelected = { owner = it }, + ) + } + LabeledContent( + "Processing fee", + processingFee?.let { formatCredits(it) } + ?: if (processingFeeError == null) "Loading…" else "Unavailable", + modifier = Modifier.testTag("createMultipleChoiceProposal.processingFee"), + ) + processingFeeError?.let { message -> + Text( + message, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + modifier = Modifier.testTag("createMultipleChoiceProposal.processingFeeError"), + ) + } + Text( + "Platform charges this identity the processing fee for the create, on " + + "top of the fees.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + + FormSection(title = "Question") { + OutlinedTextField( + value = title, + onValueChange = { title = it }, + label = { Text("Title: the question, in one line") }, + singleLine = true, + enabled = !isSubmitting, + modifier = Modifier + .fillMaxWidth() + .testTag("createMultipleChoiceProposal.title"), + ) + OutlinedTextField( + value = url, + onValueChange = { url = it }, + label = { Text("URL where it is described or discussed") }, + singleLine = true, + enabled = !isSubmitting, + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri), + modifier = Modifier + .fillMaxWidth() + .testTag("createMultipleChoiceProposal.url"), + ) + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.fillMaxWidth(), + ) { + Text("Anyone may enter choices", modifier = Modifier.weight(1f)) + Switch( + checked = open, + onCheckedChange = { open = it }, + enabled = !isSubmitting, + modifier = Modifier.testTag("createMultipleChoiceProposal.open"), + ) + } + Text( + "The answers are the choices entered once the proposal exists: by " + + "anyone when it is open, by the proposer alone when it is not, " + + "which never changes. The title, url and description document can " + + "be edited for a short time after the proposal is created.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + + FormSection(title = "Description Document (optional)") { + OutlinedTextField( + value = describedId, + onValueChange = { describedId = it }, + label = { Text("Document ID (base58)") }, + singleLine = true, + enabled = !isSubmitting, + modifier = Modifier + .fillMaxWidth() + .testTag("createMultipleChoiceProposal.descriptionDocumentId"), + ) + OutlinedTextField( + value = describedContractId, + onValueChange = { describedContractId = it }, + label = { Text("Contract ID (base58)") }, + singleLine = true, + enabled = !isSubmitting, + modifier = Modifier + .fillMaxWidth() + .testTag("createMultipleChoiceProposal.descriptionDocumentContractId"), + ) + OutlinedTextField( + value = describedType, + onValueChange = { describedType = it }, + label = { Text("Document type") }, + singleLine = true, + enabled = !isSubmitting, + modifier = Modifier + .fillMaxWidth() + .testTag("createMultipleChoiceProposal.descriptionDocumentType"), + ) + Text( + "The document saying what is being decided. Platform takes a proposal " + + "with a description document, a url or both, and refuses a " + + "document that is not of a moderated type.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + + SubmitButton( + text = if (isSubmitting) "Broadcasting…" else "Create / Broadcast", + isLoading = isSubmitting, + enabled = manager != null && owner != null, + modifier = Modifier + .fillMaxWidth() + .testTag("createMultipleChoiceProposal.submitButton"), + ) { + val mgr = manager ?: return@SubmitButton + val proposer = owner ?: return@SubmitButton + val wallet = proposer.walletId?.toHex()?.let { mgr.wallets.value[it] } + if (wallet == null) { + submission.error = "The proposer's wallet is not loaded in the wallet manager." + return@SubmitButton + } + // Form parsing only: what a proposal must hold is Platform's to say. + val described = when ( + val parsed = parseDescriptionDocument(describedId, describedContractId, describedType) + ) { + is ParsedDescriptionDocument.Unreadable -> { + submission.error = parsed.message + return@SubmitButton + } + ParsedDescriptionDocument.None -> null + is ParsedDescriptionDocument.Document -> parsed.document + } + val params = MultipleChoiceProposalParams( + title = title, + descriptionDocument = described, + url = url.trim().ifEmpty { null }, + open = open, + ) + submission.submit { + mgr.multipleChoiceProposals.create( + walletHandle = wallet.handle, + ownerId = proposer.identityId, + params = params, + signerHandle = mgr.signerHandle, + ).id + } + } + } + } + + ErrorAlertDialog(message = submission.error, onDismiss = { submission.error = null }) +} + +/** What the three description document fields of a form hold. */ +internal sealed interface ParsedDescriptionDocument { + /** All three fields are empty: no description document. */ + data object None : ParsedDescriptionDocument + + /** The fields name a document. */ + data class Document(val document: DescriptionDocumentParams) : ParsedDescriptionDocument + + /** An id field does not hold the 32 bytes the wallet call takes. */ + data class Unreadable(val message: String) : ParsedDescriptionDocument +} + +/** + * Read a form's description document fields into the bytes the wallet call takes. Only the + * text-to-bytes step can fail here; whether the document may describe a proposal is + * Platform's to say. + */ +internal fun parseDescriptionDocument( + id: String, + contractId: String, + documentType: String, +): ParsedDescriptionDocument { + if (id.isBlank() && contractId.isBlank() && documentType.isBlank()) { + return ParsedDescriptionDocument.None + } + val idBytes = Base58.decodeIdentifier(id) + ?: return ParsedDescriptionDocument.Unreadable( + "The description document id is not a 32-byte base58 identifier.", + ) + val contractIdBytes = Base58.decodeIdentifier(contractId) + ?: return ParsedDescriptionDocument.Unreadable( + "The description document's contract id is not a 32-byte base58 identifier.", + ) + return ParsedDescriptionDocument.Document( + DescriptionDocumentParams(idBytes, contractIdBytes, documentType.trim()), + ) +} diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/util/Formatters.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/util/Formatters.kt index 81f6aea4798..84dd959d6e9 100644 --- a/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/util/Formatters.kt +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/util/Formatters.kt @@ -69,6 +69,13 @@ fun formatDuffs(duffs: Long): String = formatDashAmount(duffs.toDouble() / 100_0 fun formatCredits(credits: Long): String = formatDashAmount(credits.toDouble() / 100_000_000_000.0) +/** + * [formatCredits] for an amount the SDK reads as unsigned (a fee, a contest fund): it is + * never narrowed to [Long], which would show an amount past [Long.MAX_VALUE] as negative. + */ +fun formatCredits(credits: ULong): String = + formatDashAmount(credits.toDouble() / 100_000_000_000.0) + private fun formatDashAmount(dash: Double): String { val formatter = java.text.DecimalFormat("#,##0.########") return "${formatter.format(dash)} DASH" diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/identity/MultipleChoiceDocumentCreateViewModelTest.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/identity/MultipleChoiceDocumentCreateViewModelTest.kt new file mode 100644 index 00000000000..e7602151be0 --- /dev/null +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/identity/MultipleChoiceDocumentCreateViewModelTest.kt @@ -0,0 +1,174 @@ +package org.dashfoundation.example.ui.identity + +import androidx.lifecycle.ViewModelStore +import kotlinx.coroutines.CompletableDeferred +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.StandardTestDispatcher +import kotlinx.coroutines.test.advanceUntilIdle +import kotlinx.coroutines.test.resetMain +import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.test.setMain +import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Before +import org.junit.Test + +/** + * [MultipleChoiceDocumentCreateViewModel] holds the two paid writes of the multiple choice + * proposal screens (creating a proposal, entering a choice) as + * [CreateDecisionProposalViewModel] holds the yes/no create: the write runs in the + * ViewModel's own scope, which lives as long as the screen's back-stack entry rather than + * its composition, is submitted at most once until its outcome was shown, and reports a + * failure without a cancellation passing for one. + */ +@OptIn(ExperimentalCoroutinesApi::class) +class MultipleChoiceDocumentCreateViewModelTest { + + private val dispatcher = StandardTestDispatcher() + + private val proposalId = "8vLzWy3oPYAwJ9W8TjWZ3vSJMy7bDqyuvbMvzQMxVjPN" + private val choiceId = "5DbLwAxGBzUzo81VewMUwn4b5P4bpv9FNFybi25XB5Bk" + + @Before + fun setMain() { + Dispatchers.setMain(dispatcher) + } + + @After + fun resetMain() { + Dispatchers.resetMain() + } + + @Test + fun shouldRecordTheCreatedIdAndNeverSubmitTwice() = runTest(dispatcher) { + val submission = MultipleChoiceDocumentCreateViewModel() + val confirmed = CompletableDeferred() + var creates = 0 + + submission.submit { + creates++ + confirmed.await() + } + advanceUntilIdle() + assertTrue(submission.isSubmitting) + + // A second tap while the first create runs is ignored. + submission.submit { + creates++ + "second" + } + advanceUntilIdle() + assertEquals(1, creates) + + confirmed.complete(proposalId) + advanceUntilIdle() + assertFalse(submission.isSubmitting) + assertEquals(proposalId, submission.createdId) + assertNull(submission.error) + + // So is one after the create succeeded. + submission.submit { + creates++ + "third" + } + advanceUntilIdle() + assertEquals(1, creates) + assertEquals(proposalId, submission.createdId) + } + + @Test + fun shouldRecordAFailureAndAllowAnotherSubmit() = runTest(dispatcher) { + val submission = MultipleChoiceDocumentCreateViewModel() + + submission.submit { throw IllegalStateException("Platform refused the proposal") } + advanceUntilIdle() + assertFalse(submission.isSubmitting) + assertEquals("Platform refused the proposal", submission.error) + assertNull(submission.createdId) + + submission.submit { proposalId } + advanceUntilIdle() + assertNull(submission.error) + assertEquals(proposalId, submission.createdId) + } + + /** + * The detail screen enters one choice after another: once it showed a confirmed choice + * it acknowledges it, and only then is another one submitted. + */ + @Test + fun shouldAllowAnotherChoiceOnlyOnceTheConfirmedOneWasAcknowledged() = runTest(dispatcher) { + val entry = MultipleChoiceDocumentCreateViewModel() + var entries = 0 + + entry.submit { + entries++ + choiceId + } + advanceUntilIdle() + assertEquals(choiceId, entry.createdId) + + entry.acknowledge() + assertNull(entry.createdId) + + entry.submit { + entries++ + proposalId + } + advanceUntilIdle() + assertEquals(2, entries) + assertEquals(proposalId, entry.createdId) + } + + /** Acknowledging while a write runs neither drops its outcome nor lets a second one in. */ + @Test + fun shouldNotAcknowledgeWhileAWriteRuns() = runTest(dispatcher) { + val entry = MultipleChoiceDocumentCreateViewModel() + val confirmed = CompletableDeferred() + var entries = 0 + + entry.submit { + entries++ + confirmed.await() + } + advanceUntilIdle() + entry.acknowledge() + entry.submit { + entries++ + "second" + } + advanceUntilIdle() + assertTrue(entry.isSubmitting) + assertEquals(1, entries) + + confirmed.complete(choiceId) + advanceUntilIdle() + assertEquals(choiceId, entry.createdId) + } + + /** + * Only clearing the back-stack entry's store stops a running write, and the + * cancellation is not reported as a failure. + */ + @Test + fun shouldStopOnlyWhenTheEntryIsClearedWithoutReportingAFailure() = runTest(dispatcher) { + val store = ViewModelStore() + val submission = MultipleChoiceDocumentCreateViewModel() + store.put("createMultipleChoiceProposal", submission) + val confirmed = CompletableDeferred() + + submission.submit { confirmed.await() } + advanceUntilIdle() + assertTrue(submission.isSubmitting) + + store.clear() + advanceUntilIdle() + assertFalse(submission.isSubmitting) + assertNull(submission.error) + assertNull(submission.createdId) + } +} diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/identity/MultipleChoiceProposalFormTest.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/identity/MultipleChoiceProposalFormTest.kt new file mode 100644 index 00000000000..2a43fa86edb --- /dev/null +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/identity/MultipleChoiceProposalFormTest.kt @@ -0,0 +1,163 @@ +package org.dashfoundation.example.ui.identity + +import org.dashfoundation.dashsdk.voting.DescriptionDocumentParams +import org.dashfoundation.dashsdk.voting.MultipleChoiceProposal +import org.dashfoundation.dashsdk.voting.MultipleChoiceProposalEdit +import org.dashfoundation.example.util.Base58 +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * How the multiple choice proposal forms turn their text fields into what the wallet calls + * take: the description document's ids as bytes, and an edit that sends only what the user + * changed. The forms judge nothing else; Platform refuses what it does not accept. + */ +class MultipleChoiceProposalFormTest { + + private val describedIdBytes = ByteArray(32) { 5 } + private val describedContractIdBytes = ByteArray(32) { 6 } + private val describedId = Base58.encode(describedIdBytes) + private val describedContractId = Base58.encode(describedContractIdBytes) + + private val proposal = MultipleChoiceProposal( + id = Base58.encode(ByteArray(32) { 1 }), + ownerId = Base58.encode(ByteArray(32) { 2 }), + revision = 1, + createdAtMs = 1_700_000_000_000, + updatedAtMs = 1_700_000_000_000, + title = "Which block size?", + descriptionDocument = MultipleChoiceProposal.DescriptionDocument(describedId, describedContractId, "post"), + url = "https://forum.dash.org/t/block-size", + open = true, + ) + + /** The edit the form makes when its fields hold what is given, the rest untouched. */ + private fun edit( + proposal: MultipleChoiceProposal = this.proposal, + title: String = proposal.title, + url: String = proposal.url.orEmpty(), + describedId: String = proposal.descriptionDocument?.id.orEmpty(), + describedContractId: String = proposal.descriptionDocument?.contractId.orEmpty(), + describedType: String = proposal.descriptionDocument?.documentType.orEmpty(), + ): BuiltMultipleChoiceEdit = + multipleChoiceProposalEdit(proposal, title, url, describedId, describedContractId, describedType) + + private fun changes(edit: MultipleChoiceProposalEdit) = BuiltMultipleChoiceEdit.Edit(edit) + + @Test + fun shouldReadThreeEmptyFieldsAsNoDescriptionDocument() { + assertEquals(ParsedDescriptionDocument.None, parseDescriptionDocument("", " ", "")) + } + + @Test + fun shouldReadTheDescriptionDocumentIdsAsTheirBytes() { + assertEquals( + ParsedDescriptionDocument.Document( + DescriptionDocumentParams(describedIdBytes, describedContractIdBytes, "post"), + ), + parseDescriptionDocument(" $describedId ", describedContractId, " post "), + ) + } + + @Test + fun shouldReportAnIdFieldThatDoesNotHold32Bytes() { + val noId = parseDescriptionDocument("", describedContractId, "post") + assertTrue("$noId", noId is ParsedDescriptionDocument.Unreadable) + val shortContractId = parseDescriptionDocument(describedId, "abc", "post") + assertTrue("$shortContractId", shortContractId is ParsedDescriptionDocument.Unreadable) + } + + /** A document type left empty still crosses: the wallet is the one to refuse it. */ + @Test + fun shouldLeaveAnEmptyDocumentTypeToTheWallet() { + assertEquals( + ParsedDescriptionDocument.Document( + DescriptionDocumentParams(describedIdBytes, describedContractIdBytes, ""), + ), + parseDescriptionDocument(describedId, describedContractId, ""), + ) + } + + @Test + fun shouldSendNothingForAnUntouchedForm() { + assertEquals(changes(MultipleChoiceProposalEdit()), edit()) + } + + @Test + fun shouldSendOnlyTheFieldTheUserChanged() { + assertEquals( + changes(MultipleChoiceProposalEdit(title = "Which block size next year?")), + edit(title = "Which block size next year?"), + ) + assertEquals( + changes( + MultipleChoiceProposalEdit( + url = MultipleChoiceProposalEdit.Change.Set("https://example.org/sizes"), + ), + ), + edit(url = " https://example.org/sizes "), + ) + val otherId = Base58.encode(ByteArray(32) { 7 }) + assertEquals( + changes( + MultipleChoiceProposalEdit( + descriptionDocument = MultipleChoiceProposalEdit.Change.Set( + DescriptionDocumentParams(ByteArray(32) { 7 }, describedContractIdBytes, "post"), + ), + ), + ), + edit(describedId = otherId), + ) + } + + @Test + fun shouldRemoveAnEmptiedUrlOrDescriptionDocument() { + assertEquals( + changes(MultipleChoiceProposalEdit(url = MultipleChoiceProposalEdit.Change.Remove)), + edit(url = ""), + ) + assertEquals( + changes( + MultipleChoiceProposalEdit( + descriptionDocument = MultipleChoiceProposalEdit.Change.Remove, + ), + ), + edit(describedId = "", describedContractId = "", describedType = ""), + ) + } + + /** Fields that were empty and stay empty are untouched, not a removal. */ + @Test + fun shouldKeepWhatAProposalDoesNotHave() { + val bare = proposal.copy(descriptionDocument = null, url = null) + assertEquals(changes(MultipleChoiceProposalEdit()), edit(proposal = bare)) + assertEquals( + changes( + MultipleChoiceProposalEdit( + descriptionDocument = MultipleChoiceProposalEdit.Change.Set( + DescriptionDocumentParams(describedIdBytes, describedContractIdBytes, "post"), + ), + ), + ), + edit( + proposal = bare, + describedId = describedId, + describedContractId = describedContractId, + describedType = "post", + ), + ) + } + + @Test + fun shouldReportAnEditedDescriptionDocumentIdThatDoesNotHold32Bytes() { + val built = edit(describedId = "abc") + assertTrue("$built", built is BuiltMultipleChoiceEdit.Unreadable) + } + + @Test + fun shouldSayWhoEntersChoices() { + assertEquals("anyone enters choices", proposal.whoEntersChoices()) + assertEquals("only its owner enters choices", proposal.copy(open = false).whoEntersChoices()) + } +} diff --git a/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/util/FormattersTest.kt b/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/util/FormattersTest.kt index 54c9289c452..6f1f6f51423 100644 --- a/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/util/FormattersTest.kt +++ b/packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/util/FormattersTest.kt @@ -1,6 +1,7 @@ package org.dashfoundation.example.util import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse import org.junit.Assert.assertNull import org.junit.Test @@ -32,4 +33,14 @@ class FormattersTest { assertEquals(10_000L, parseDashToDuffs("0.0001")) assertNull(parseDashToDuffs("0.000000001")) } + + @Test + fun formatCreditsKeepsAnUnsignedAmountUnsigned() { + // An unsigned amount formats as the same amount read as a Long. + assertEquals(formatCredits(20_000_000_000L), formatCredits(20_000_000_000uL)) + // Past Long.MAX_VALUE it is still a positive amount, where a narrowing to Long + // would have shown a negative one. + assertFalse(formatCredits(ULong.MAX_VALUE).startsWith("-")) + assertFalse(formatCredits(Long.MAX_VALUE.toULong() + 1uL).startsWith("-")) + } } diff --git a/packages/kotlin-sdk/PARITY.md b/packages/kotlin-sdk/PARITY.md index 8c3c53695a3..5e450bf63fa 100644 --- a/packages/kotlin-sdk/PARITY.md +++ b/packages/kotlin-sdk/PARITY.md @@ -56,7 +56,7 @@ Status legend: | OptionsView.swift | ui/settings/SettingsScreen.kt · `SettingsHome` (+ AboutSheet.kt) | ported — Network/SPV/Data/Platform/About sections incl. About bottom sheet | | PendingPlatformFundFromAssetLocksList.swift | ui/funding/AddressFundProgressScreen.kt (`PendingAssetLocksList`) | ported (embedded in IdentitiesHome, matching iOS) | | PendingRegistrationsList.swift | ui/identity/RegistrationProgressScreen.kt (`PendingRegistrationRow`) | ported (embedded in IdentitiesHome) | -| PlatformQueriesView.swift | ui/contracts/QueryDetailScreen.kt (`QueriesListScreen`) · `QueriesList` | ported — the Decision Proposals link (`votingQueries.decisionProposalsLink`) opens `DecisionProposalsList`, and the seven decision proposal reads have registry rows kept out of Run All Queries; the registry now spans the iOS query catalog (adapted: one flat Material list instead of 12 category groups) plus the dedicated GroveDB Path Elements / Address Queries / Run All Queries entries | +| PlatformQueriesView.swift | ui/contracts/QueryDetailScreen.kt (`QueriesListScreen`) · `QueriesList` | ported — the Decision Proposals link (`votingQueries.decisionProposalsLink`) opens `DecisionProposalsList` and the Multiple Choice Proposals link (`votingQueries.multipleChoiceProposalsLink`) opens `MultipleChoiceProposalsList`; the seven decision proposal reads and the eight multiple choice proposal reads have registry rows kept out of Run All Queries; the registry now spans the iOS query catalog (adapted: one flat Material list instead of 12 category groups) plus the dedicated GroveDB Path Elements / Address Queries / Run All Queries entries | | PlatformStateTransitionsView.swift | ui/transitions/StateTransitionsScreen.kt · `StateTransitions` | ported (iOS file is a trivial wrapper around StateTransitionsView) | | QueryDetailView.swift | ui/contracts/QueryDetailScreen.kt · `QueryDetail` | ported for the bridged registry | | QuickBasicTokenView.swift | ui/tokens/QuickBasicTokenScreen.kt · `QuickBasicToken` | ported — contract-registration submit wired via `ManagedPlatformWallet.dataContracts.create` (`platform_wallet_create_data_contract_with_signer`) | @@ -136,6 +136,24 @@ rebuilt `libdash_sdk_jni.so` and a network at protocol version 15. | DecisionProposalDetailView.swift | ui/identity/DecisionProposalDetailScreen.kt · `DecisionProposalDetail` | ported: proposal, rule, poll state (open tallies or finished result) and poll id; masternode vote and answer lookup over `castVote` / `masternodeVote` with the contest screen's credential form (voting key masked, FLAG_SECURE held while the dialog is open) | | DecisionProposalFormViews.swift | ui/identity/DecisionProposalsScreen.kt · `CreateDecisionProposal` (create); ui/identity/DecisionProposalDetailScreen.kt (edit dialog) | ported: create through `PlatformWalletManager.decisionProposals.create` (`platform_wallet_decision_proposal_create`, returning the proposal id and the confirmed document); edit through `.edit` (`platform_wallet_decision_proposal_edit`; the wallet picks the signing key and a concurrent edit is refused with consensus code 40106). The create runs in a back-stack-entry ViewModel with Back held while it runs, and the edit dialog cannot be dismissed while it runs. The end date is entered as days from now rather than with a date picker | +Multiple choice proposals (protocol version 15): questions answered by the +choices entered for them. The Kotlin SDK bridges every +`dash_sdk_multiple_choice_proposal_*` function and the platform wallet's +`platform_wallet_multiple_choice_proposal_create` / `_edit` / `_enter_choice` +one JNI export each (`rs-unified-sdk-jni/src/multiple_choice_proposals.rs`); +`Sdk.multipleChoiceProposals` reads, reads the processing fee and the contest +fund, and votes, and `PlatformWalletManager.multipleChoiceProposals` creates, +edits and enters a choice, one native call each. Compile-verified, with JVM +tests of the JSON decoding and of the app's form and submission logic; the +device run waits on a rebuilt `libdash_sdk_jni.so` and a network at protocol +version 15. + +| Swift file | Android file / route | Status | +| --- | --- | --- | +| MultipleChoiceProposalsView.swift | ui/identity/MultipleChoiceProposalsScreen.kt · `MultipleChoiceProposalsList` | ported: Mine / Newest listings, paged, over `Sdk.multipleChoiceProposals.listByOwner` / `listByCreatedAt`; reached from the Platform Queries list (`votingQueries.multipleChoiceProposalsLink`) as on iOS | +| MultipleChoiceProposalDetailView.swift | ui/identity/MultipleChoiceProposalDetailScreen.kt · `MultipleChoiceProposalDetail` | ported: proposal, its choices with their tallies while the vote runs, the outcome and the kept choice once it ended (`vote` / `keptChoice`); masternode vote and answer lookup over `castVote` / `masternodeVote` with the contest screen's credential form (voting key masked, FLAG_SECURE held while the dialog is open, no dismissal while a call runs), the answers being the vote's choices by document id, none of the choices and abstain | +| MultipleChoiceProposalFormViews.swift | ui/identity/MultipleChoiceProposalsScreen.kt · `CreateMultipleChoiceProposal` (create); ui/identity/MultipleChoiceProposalDetailScreen.kt (enter a choice and edit dialogs) | ported: create through `PlatformWalletManager.multipleChoiceProposals.create` (`platform_wallet_multiple_choice_proposal_create`), showing the processing fee read through `Sdk.multipleChoiceProposals.processingFee`; enter a choice through `.enterChoice` (`platform_wallet_multiple_choice_proposal_enter_choice`), showing the contest fund read through `choiceFundToJoin`; edit through `.edit` (`platform_wallet_multiple_choice_proposal_edit`), sending only the changed fields, with keep / set / remove for the url and the description document. The create and the choice entry each run in a back-stack-entry ViewModel with Back held while they run, and the dialogs cannot be dismissed while they run. Adapted: the choice entry and the edit are dialogs of the detail screen rather than pushed views. Who may enter a choice and how long the edit stays open are left to Platform, which refuses what it does not accept | + ## Views/Components/ | Swift file | Android file | Status | diff --git a/packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/MultipleChoiceProposalsFfiTest.kt b/packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/MultipleChoiceProposalsFfiTest.kt new file mode 100644 index 00000000000..ac118c8bda0 --- /dev/null +++ b/packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/MultipleChoiceProposalsFfiTest.kt @@ -0,0 +1,250 @@ +package org.dashfoundation.dashsdk + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import org.dashfoundation.dashsdk.errors.DashSdkError +import org.dashfoundation.dashsdk.ffi.DashSDKException +import org.dashfoundation.dashsdk.ffi.MultipleChoiceProposalsNative +import org.dashfoundation.dashsdk.ffi.NativeLoader +import org.dashfoundation.dashsdk.ffi.SdkNative +import org.dashfoundation.dashsdk.persistence.toBase58String +import org.dashfoundation.dashsdk.voting.MultipleChoiceVoteChoice +import org.dashfoundation.dashsdk.voting.toNative +import org.junit.After +import org.junit.Assert.assertArrayEquals +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNotEquals +import org.junit.Assert.assertThrows +import org.junit.Assert.assertTrue +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith + +/** + * Round trips of the multiple choice proposal JNI exports through `rs-sdk-ffi` and + * `platform-wallet-ffi` on a device: the symbol names, the argument marshalling and the + * error codes Kotlin maps. Every call here is refused before anything reaches the network + * (the JNI layer and the C functions read every argument first), so no network, wallet or + * protocol version 15 is needed: `createTrusted` only builds the client. The flows that + * reach Platform (create, edit, enter a choice, the reads, the two amounts, vote) need a + * network at protocol version 15 and are exercised through KotlinExampleApp. + */ +@RunWith(AndroidJUnit4::class) +class MultipleChoiceProposalsFfiTest { + + /** A well-formed 32-byte id that names no proposal. */ + private val proposalIdBytes = ByteArray(32) { 0x11 } + private val proposalId = proposalIdBytes.toBase58String() + + /** A well-formed 32-byte identity id. */ + private val ownerId = ByteArray(32) { 0x22 } + + /** A well-formed id that names no choice, base58. */ + private val choiceId = ByteArray(32) { 0x33 }.toBase58String() + + private var handle = 0L + + @Before + fun createSdk() { + NativeLoader.ensureLoaded() + handle = SdkNative.createTrusted( + network = 1, + dapiAddresses = null, + quorumUrl = null, + skipAssetLockProofVerification = false, + requestRetryCount = 3, + requestTimeoutMs = 30_000, + platformVersion = 0, + ) + assertNotEquals("createTrusted must return a live handle", 0L, handle) + } + + @After + fun destroySdk() { + SdkNative.destroy(handle) + } + + /** rs-sdk-ffi refuses ids that are not base58 with InvalidParameter (1). */ + @Test + fun shouldRefuseBadArgumentsBeforeTheNetwork() { + assertCode(1) { MultipleChoiceProposalsNative.fetch(handle, "0OIl") } + assertCode(1) { MultipleChoiceProposalsNative.getVote(handle, "0OIl") } + assertCode(1) { MultipleChoiceProposalsNative.getKeptChoice(handle, "0OIl") } + assertCode(1) { MultipleChoiceProposalsNative.getChoiceFundToJoin(handle, "0OIl") } + assertCode(1) { MultipleChoiceProposalsNative.listByOwner(handle, "0OIl", 0, null) } + assertCode(1) { MultipleChoiceProposalsNative.listByOwner(handle, proposalId, 0, "0OIl") } + assertCode(1) { MultipleChoiceProposalsNative.listByCreatedAt(handle, 0, "0OIl") } + assertCode(1) { + MultipleChoiceProposalsNative.getMasternodeVote(handle, ByteArray(32) { 1 }, "0OIl") + } + } + + /** The JNI layer refuses a value the C type cannot hold instead of wrapping it. */ + @Test + fun shouldRefuseNumbersOutsideTheCTypes() { + assertCode(1) { MultipleChoiceProposalsNative.listByOwner(handle, proposalId, -1, null) } + assertCode(1) { MultipleChoiceProposalsNative.listByCreatedAt(handle, -1, null) } + } + + /** + * The wallet writes read exactly 32 bytes behind each id, and the two that create a + * document check the array its id is written back to before anything is broadcast. + */ + @Test + fun shouldRefuseAWalletWriteIdThatIsNot32Bytes() { + assertCode(1) { create(outProposalId = ByteArray(31)) } + assertCode(1) { create(ownerId = ByteArray(33)) } + assertCode(1) { create(descriptionDocumentId = ByteArray(31)) } + assertCode(1) { create(descriptionDocumentContractId = ByteArray(33)) } + assertCode(1) { edit(ownerId = ByteArray(31)) } + assertCode(1) { edit(proposalId = ByteArray(33)) } + assertCode(1) { edit(descriptionDocumentId = ByteArray(33)) } + assertCode(1) { enterChoice(outChoiceId = ByteArray(31)) } + assertCode(1) { enterChoice(ownerId = ByteArray(33)) } + assertCode(1) { enterChoice(proposalId = ByteArray(31)) } + } + + /** + * The three wallet writes reach `platform-wallet-ffi`, which refuses a null signer + * (`ErrorNullPointer`, 3) before it looks the wallet up; the code arrives shifted by the + * platform wallet offset, and no id is written back. + */ + @Test + fun shouldReachThePlatformWalletForTheWrites() { + val nullPointer = DashSdkError.PLATFORM_WALLET_CODE_OFFSET + 3 + val outProposalId = ByteArray(32) + assertCode(nullPointer) { create(outProposalId = outProposalId) } + assertArrayEquals(ByteArray(32), outProposalId) + // A description document given in part still crosses: the wallet is the one to refuse it. + assertCode(nullPointer) { create(descriptionDocumentId = null, descriptionDocumentType = null) } + assertCode(nullPointer) { edit() } + assertCode(nullPointer) { edit(url = "https://example.com", removeUrl = true) } + assertCode(nullPointer) { edit(removeDescriptionDocument = true) } + val outChoiceId = ByteArray(32) + assertCode(nullPointer) { enterChoice(outChoiceId = outChoiceId) } + assertArrayEquals(ByteArray(32), outChoiceId) + } + + /** The C functions read exactly 32 bytes behind these pointers. */ + @Test + fun shouldRefuseAProTxHashOrVotingKeyThatIsNot32Bytes() { + assertCode(1) { + MultipleChoiceProposalsNative.getMasternodeVote(handle, ByteArray(31), proposalId) + } + assertCode(1) { + MultipleChoiceProposalsNative.castVote( + handle, proposalId, 1, null, ByteArray(31), ByteArray(32), 1, + ) + } + assertCode(1) { + MultipleChoiceProposalsNative.castVote( + handle, proposalId, 1, null, ByteArray(32), ByteArray(33), 1, + ) + } + } + + /** + * rs-sdk-ffi reads the vote choice and the choice id before the voting key, so every + * Kotlin choice gets past them and is refused on the all-zero key instead, while a byte + * outside the three is refused as a choice. Nothing reaches the network either way. + */ + @Test + fun shouldAcceptExactlyTheThreeVoteChoices() { + val choices = listOf( + MultipleChoiceVoteChoice.Choice(choiceId), + MultipleChoiceVoteChoice.NoneOfTheChoices, + MultipleChoiceVoteChoice.Abstain, + ) + for (choice in choices) { + val vote = choice.toNative() + val error = assertCode(1) { castVote(vote.discriminant, vote.choiceId) } + assertFalse(error.message, error.message.orEmpty().contains("vote_choice")) + assertFalse(error.message, error.message.orEmpty().contains("choice_id")) + } + val refused = assertCode(1) { castVote(3, null) } + assertTrue(refused.message, refused.message.orEmpty().contains("vote_choice")) + assertCode(1) { castVote(256, null) } + } + + /** A vote for a choice names it, and the other answers name none. */ + @Test + fun shouldRefuseAChoiceIdThatDoesNotFitTheVoteChoice() { + val missing = assertCode(1) { castVote(0, null) } + assertTrue(missing.message, missing.message.orEmpty().contains("choice_id")) + for (voteChoice in listOf(1, 2)) { + val superfluous = assertCode(1) { castVote(voteChoice, choiceId) } + assertTrue(superfluous.message, superfluous.message.orEmpty().contains("choice_id")) + } + assertCode(1) { castVote(0, "0OIl") } + } + + /** `castVote` for an all-ones pro_tx_hash with an all-zero voting key. */ + private fun castVote(voteChoice: Int, choiceId: String?) { + MultipleChoiceProposalsNative.castVote( + handle, proposalId, voteChoice, choiceId, ByteArray(32) { 1 }, ByteArray(32), 1, + ) + } + + /** `create` on no wallet and no signer, with valid arguments unless overridden. */ + private fun create( + ownerId: ByteArray = this.ownerId, + descriptionDocumentId: ByteArray? = ByteArray(32) { 0x44 }, + descriptionDocumentContractId: ByteArray? = ByteArray(32) { 0x55 }, + descriptionDocumentType: String? = "post", + outProposalId: ByteArray = ByteArray(32), + ) { + MultipleChoiceProposalsNative.create( + 0L, + ownerId, + "title", + descriptionDocumentId, + descriptionDocumentContractId, + descriptionDocumentType, + null, + true, + 0L, + outProposalId, + ) + } + + /** `edit` on no wallet and no signer, with valid arguments unless overridden. */ + private fun edit( + ownerId: ByteArray = this.ownerId, + proposalId: ByteArray = proposalIdBytes, + descriptionDocumentId: ByteArray? = null, + removeDescriptionDocument: Boolean = false, + url: String? = null, + removeUrl: Boolean = false, + ) { + MultipleChoiceProposalsNative.edit( + 0L, + ownerId, + proposalId, + "new title", + descriptionDocumentId, + null, + null, + removeDescriptionDocument, + url, + removeUrl, + 0L, + ) + } + + /** `enterChoice` on no wallet and no signer, with valid arguments unless overridden. */ + private fun enterChoice( + ownerId: ByteArray = this.ownerId, + proposalId: ByteArray = proposalIdBytes, + outChoiceId: ByteArray = ByteArray(32), + ) { + MultipleChoiceProposalsNative.enterChoice( + 0L, ownerId, proposalId, "title", null, 0L, outChoiceId, + ) + } + + private fun assertCode(code: Int, call: () -> Unit): DashSDKException { + val error = assertThrows(DashSDKException::class.java) { call() } + assertEquals(error.message, code, error.code) + return error + } +} diff --git a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/Sdk.kt b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/Sdk.kt index 2f7b4c03291..5f2b12bd30c 100644 --- a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/Sdk.kt +++ b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/Sdk.kt @@ -84,6 +84,16 @@ class Sdk private constructor( org.dashfoundation.dashsdk.voting.DecisionProposals(this) } + /** + * Multiple choice proposal reads, the amounts a proposal and a choice cost, and the + * masternode vote among a proposal's choices (protocol version 15); mirrors the Swift + * SDK's `SDK+MultipleChoiceProposals.swift`. Creating and editing a proposal and + * entering a choice go through `PlatformWalletManager.multipleChoiceProposals`. + */ + val multipleChoiceProposals: org.dashfoundation.dashsdk.voting.MultipleChoiceProposals by lazy { + org.dashfoundation.dashsdk.voting.MultipleChoiceProposals(this) + } + /** Evonode proposed-epoch-block queries. */ val evonodes: org.dashfoundation.dashsdk.queries.Evonodes by lazy { org.dashfoundation.dashsdk.queries.Evonodes(this) diff --git a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/MultipleChoiceProposalsNative.kt b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/MultipleChoiceProposalsNative.kt new file mode 100644 index 00000000000..86947a1a60e --- /dev/null +++ b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/MultipleChoiceProposalsNative.kt @@ -0,0 +1,181 @@ +package org.dashfoundation.dashsdk.ffi + +/** + * Raw JNI surface for multiple choice proposals (protocol version 15): mirrors + * `rs-unified-sdk-jni/src/multiple_choice_proposals.rs`, one export per C function: each + * `dash_sdk_multiple_choice_proposal_*` function of `rs-sdk-ffi` (the reads, the two amounts + * and the masternode vote), and `platform_wallet_multiple_choice_proposal_create` / `_edit` / + * `_enter_choice` of `platform-wallet-ffi` (the writes). + * + * Internal: the public API is [org.dashfoundation.dashsdk.voting.MultipleChoiceProposals] + * (reads and the masternode vote) and + * [org.dashfoundation.dashsdk.voting.MultipleChoiceProposalTransactions] (create, edit and + * enter a choice), one native call each; no export stitches two C calls together. `sdk` is + * `Sdk.handle`, `walletHandle` a `ManagedPlatformWallet` handle and `signerHandle` the + * manager's `PlatformWalletManager.signerHandle`. Ids are base58 strings except where a + * `ByteArray` is named. Errors throw [DashSDKException]. + */ +internal object MultipleChoiceProposalsNative { + + /** + * Create + broadcast a multiple choice proposal of [ownerId] asking [title], signed via + * [signerHandle]. Bridges `platform_wallet_multiple_choice_proposal_create`: the wallet + * builds the proposal, picks the signing key, broadcasts and waits for Platform to + * confirm; Platform charges the owner the processing fee [getProcessingFee] reads on top + * of the fees. + * + * @param ownerId the proposer's 32-byte identity id. + * @param descriptionDocumentId the 32-byte id of the document saying what is being + * decided; null, with the next two, for none. + * @param descriptionDocumentContractId the 32-byte id of the contract that document + * lives in. + * @param descriptionDocumentType that document's type. + * @param url null for none. + * @param open whether anyone may enter choices; only the owner may when it is false. + * @param outProposalId a `ByteArray(32)`, checked before anything is broadcast, that + * receives the proposal's id. + * @return the confirmed document's canonical JSON. + */ + external fun create( + walletHandle: Long, + ownerId: ByteArray, + title: String, + descriptionDocumentId: ByteArray?, + descriptionDocumentContractId: ByteArray?, + descriptionDocumentType: String?, + url: String?, + open: Boolean, + signerHandle: Long, + outProposalId: ByteArray, + ): String + + /** + * Give the proposal [proposalId] of [ownerId] what the arguments change and broadcast + * the replace, signed via [signerHandle]. Bridges + * `platform_wallet_multiple_choice_proposal_edit`: the wallet reads the proposal once, + * edits it at the revision after the one read and picks the signing key as [create] + * does. + * + * @param ownerId the proposer's 32-byte identity id. + * @param proposalId the proposal's 32-byte id. + * @param title null keeps it. + * @param descriptionDocumentId with the next two, the new description document; all + * null keeps it, unless [removeDescriptionDocument]. + * @param removeDescriptionDocument removes the description document; the wallet refuses + * it together with a new one. + * @param url null keeps it, unless [removeUrl]. + * @param removeUrl removes the url; the wallet refuses it together with a non-null [url]. + * @return the confirmed document's canonical JSON, at its new revision. + */ + external fun edit( + walletHandle: Long, + ownerId: ByteArray, + proposalId: ByteArray, + title: String?, + descriptionDocumentId: ByteArray?, + descriptionDocumentContractId: ByteArray?, + descriptionDocumentType: String?, + removeDescriptionDocument: Boolean, + url: String?, + removeUrl: Boolean, + signerHandle: Long, + ): String + + /** + * Enter a choice of [ownerId] for the proposal [proposalId] and broadcast it, signed via + * [signerHandle]. Bridges `platform_wallet_multiple_choice_proposal_enter_choice`: the + * wallet builds the choice, whose put states the contest fund [getChoiceFundToJoin] + * reads (paid by the owner on top of the fees), picks the signing key, broadcasts and + * waits for Platform to confirm. + * + * @param ownerId the 32-byte id of the identity entering the choice. + * @param proposalId the proposal's 32-byte id. + * @param description null for none. + * @param outChoiceId a `ByteArray(32)`, checked before anything is broadcast, that + * receives the choice's id. + * @return the confirmed document's canonical JSON. + */ + external fun enterChoice( + walletHandle: Long, + ownerId: ByteArray, + proposalId: ByteArray, + title: String, + description: String?, + signerHandle: Long, + outChoiceId: ByteArray, + ): String + + /** + * A proposal as JSON, or null when there is none. Bridges + * `dash_sdk_multiple_choice_proposal_fetch`. + */ + external fun fetch(sdk: Long, proposalId: String): String? + + /** + * One page of [ownerId]'s proposals in filing order, as a JSON array. [limit] 0 is 100. + * Bridges `dash_sdk_multiple_choice_proposal_list_by_owner`. + */ + external fun listByOwner(sdk: Long, ownerId: String, limit: Int, startAfter: String?): String? + + /** + * One page of every proposal, newest first, as a JSON array. Bridges + * `dash_sdk_multiple_choice_proposal_list_by_created_at`. + */ + external fun listByCreatedAt(sdk: Long, limit: Int, startAfter: String?): String? + + /** + * The vote among [proposalId]'s choices as JSON: every choice with its tally, the other + * tallies and how the vote ended once it did. Bridges + * `dash_sdk_multiple_choice_proposal_get_vote`. + */ + external fun getVote(sdk: Long, proposalId: String): String? + + /** + * The choice [proposalId]'s finished vote kept as JSON, or null while the vote runs and + * when it kept none. Bridges `dash_sdk_multiple_choice_proposal_get_kept_choice`. + */ + external fun getKeptChoice(sdk: Long, proposalId: String): String? + + /** + * A masternode's answer in [proposalId]'s vote as `{"choice", "choiceId"}`, or null when + * it has not voted or the vote ended. Bridges + * `dash_sdk_multiple_choice_proposal_get_masternode_vote`. + * + * @param voterProTxHash 32 bytes in wire order, as [castVote] takes it. + */ + external fun getMasternodeVote(sdk: Long, voterProTxHash: ByteArray, proposalId: String): String? + + /** + * What creating one proposal adds to the processing fee of its batch, in credits as a + * decimal string. Bridges `dash_sdk_multiple_choice_proposal_get_processing_fee`. + */ + external fun getProcessingFee(sdk: Long): String? + + /** + * The fund a choice entered now for [proposalId] pays, in credits as a decimal string. + * Bridges `dash_sdk_multiple_choice_proposal_get_choice_fund_to_join`. + */ + external fun getChoiceFundToJoin(sdk: Long, proposalId: String): String? + + /** + * Vote among [proposalId]'s choices for a masternode and wait for the response. Bridges + * `dash_sdk_multiple_choice_proposal_cast_vote`. + * + * @param voteChoice `0` for the choice [choiceId] names, `1` none of the choices, `2` + * abstain. + * @param choiceId the document id of the choice voted for; null for the answers that + * name none. + * @param voterProTxHash 32 bytes in wire order (the reverse of the hex Core displays). + * @param votingPrivateKey the 32-byte masternode voting private key; not stored. + * @param networkOrd `Network.ffiValue`. + */ + external fun castVote( + sdk: Long, + proposalId: String, + voteChoice: Int, + choiceId: String?, + voterProTxHash: ByteArray, + votingPrivateKey: ByteArray, + networkOrd: Int, + ) +} diff --git a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/DecisionProposalModels.kt b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/DecisionProposalModels.kt index ffd5c2643ae..7ba70888525 100644 --- a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/DecisionProposalModels.kt +++ b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/DecisionProposalModels.kt @@ -363,15 +363,6 @@ data class YesNoVotePollState( finalizationBlock = block(obj.obj("finalizationBlock")), ) } - - private fun block(obj: JsonObject): PlatformBlockInfo = with(DecisionProposalJson) { - PlatformBlockInfo( - height = obj.long("height"), - coreHeight = obj.long("coreHeight"), - timeMs = obj.long("timeMs"), - epoch = obj.int("epoch"), - ) - } } } @@ -394,6 +385,18 @@ internal object DecisionProposalJson { fun JsonObject.obj(name: String): JsonObject = this[name] as? JsonObject ?: throw malformed(name) + fun JsonObject.optionalObj(name: String): JsonObject? = when (val value = this[name]) { + null, JsonNull -> null + is JsonObject -> value + else -> throw malformed(name) + } + + /** The objects of the array [name], in its order. */ + fun JsonObject.objects(name: String): List = + (this[name] as? JsonArray ?: throw malformed(name)).map { entry -> + entry as? JsonObject ?: throw malformed(name) + } + fun JsonObject.string(name: String): String = (this[name] as? JsonPrimitive)?.takeIf { it.isString }?.content ?: throw malformed(name) @@ -420,6 +423,14 @@ internal object DecisionProposalJson { (this[name] as? JsonPrimitive)?.takeUnless { it.isString }?.booleanOrNull ?: throw malformed(name) + /** A block as every decision proposal read writes it. */ + fun block(obj: JsonObject): PlatformBlockInfo = PlatformBlockInfo( + height = obj.long("height"), + coreHeight = obj.long("coreHeight"), + timeMs = obj.long("timeMs"), + epoch = obj.int("epoch"), + ) + private fun number(value: JsonElement?): Long? = (value as? JsonPrimitive)?.takeUnless { it.isString || it is JsonNull }?.longOrNull diff --git a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/MultipleChoiceProposalModels.kt b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/MultipleChoiceProposalModels.kt new file mode 100644 index 00000000000..5cac1180cb9 --- /dev/null +++ b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/MultipleChoiceProposalModels.kt @@ -0,0 +1,431 @@ +package org.dashfoundation.dashsdk.voting + +import kotlinx.serialization.json.JsonArray +import kotlinx.serialization.json.JsonObject +import org.dashfoundation.dashsdk.errors.DashSdkError + +// The types the multiple choice proposal reads return, decoded from the JSON rs-sdk-ffi +// writes (`packages/rs-sdk-ffi/src/decision_proposal/multiple_choice/json.rs`), and the +// inputs of the writes. Rust decides every value; these types only carry it. Names and +// shapes follow the Swift SDK (`SwiftDashSDK/Voting/MultipleChoiceProposal.swift`) and +// rs-sdk. + +/** + * A multiple choice proposal (protocol version 15): a question an identity put to the + * masternodes whose answers are the choices entered for it, a `multipleChoiceProposal` + * document of the decision proposals system contract. + * + * The choices contend in a masternode vote the first choice opens; the choice with the most + * votes is kept as an ordinary document, unless the votes for none of the choices outnumber + * it. The title, description document and url can be edited for two hours after the + * proposal is created; [open] never changes. A proposal has a description document, a url + * or both. + */ +data class MultipleChoiceProposal( + /** The proposal's id, base58. */ + val id: String, + /** The proposer's identity id, base58. */ + val ownerId: String, + /** The document revision; null when the document does not carry one. */ + val revision: Long?, + /** When the proposal was created, in milliseconds since the Unix epoch; may be null. */ + val createdAtMs: Long?, + /** When the proposal was last changed, in milliseconds since the Unix epoch; may be null. */ + val updatedAtMs: Long?, + /** The question, in one line. */ + val title: String, + /** The document saying what is being decided; null when the proposal points at none. */ + val descriptionDocument: DescriptionDocument?, + /** Where what is being decided is described or discussed; null when it has none. */ + val url: String?, + /** Whether anyone may enter choices; only the proposal's owner may when it is false. */ + val open: Boolean, +) { + /** + * The document a multiple choice proposal points at for what is being decided, as the + * reads return it. Platform refuses one that is not of a moderated type the elected + * team of its contract may delete. + */ + data class DescriptionDocument( + /** The document's id, base58. */ + val id: String, + /** The id of the contract it lives in, base58. */ + val contractId: String, + /** Its document type. */ + val documentType: String, + ) + + internal companion object { + /** Decode the proposal object every multiple choice proposal read returns. */ + fun fromJson(json: String): MultipleChoiceProposal = fromJsonObject( + DecisionProposalJson.parseObject(json, "multiple choice proposal"), + ) + + /** Decode a listing: a JSON array of proposal objects, in the listing's order. */ + fun listFromJson(json: String): List { + val array = DecisionProposalJson.parse(json, "multiple choice proposal listing") + as? JsonArray + ?: throw DashSdkError.SerializationError( + "Malformed multiple choice proposal listing: $json", + ) + return array.map { entry -> + fromJsonObject( + entry as? JsonObject + ?: throw DashSdkError.SerializationError( + "Malformed multiple choice proposal: $entry", + ), + ) + } + } + + private fun fromJsonObject(json: JsonObject): MultipleChoiceProposal = + with(DecisionProposalJson) { + MultipleChoiceProposal( + id = json.string("id"), + ownerId = json.string("ownerId"), + revision = json.optionalLong("revision"), + createdAtMs = json.optionalLong("createdAt"), + updatedAtMs = json.optionalLong("updatedAt"), + title = json.string("title"), + descriptionDocument = json.optionalObj("descriptionDocument")?.let { described -> + DescriptionDocument( + id = described.string("id"), + contractId = described.string("contractId"), + documentType = described.string("documentType"), + ) + }, + url = json.optionalString("url"), + open = json.boolean("open"), + ) + } + } +} + +/** + * An answer entered for a multiple choice proposal, a `choice` document of the decision + * proposals system contract. A choice is never edited. Its [id] is what a masternode vote + * for it names ([MultipleChoiceVoteChoice.Choice]), not the id of the identity that entered + * it. + */ +data class ProposalChoice( + /** The choice's document id, base58. */ + val id: String, + /** The identity that entered it, base58. */ + val ownerId: String, + /** The proposal it answers, base58. */ + val proposalId: String, + /** The document revision; null when the document does not carry one. */ + val revision: Long?, + /** When the choice was entered, in milliseconds since the Unix epoch; may be null. */ + val createdAtMs: Long?, + /** Null when the document does not carry it. */ + val updatedAtMs: Long?, + /** The answer, in one line. */ + val title: String, + /** What voting for the answer means; null when the choice has none. */ + val description: String?, +) { + internal companion object { + /** Decode the choice object every read of a choice returns. */ + fun fromJson(json: String): ProposalChoice = + fromJsonObject(DecisionProposalJson.parseObject(json, "choice")) + + fun fromJsonObject(json: JsonObject): ProposalChoice = with(DecisionProposalJson) { + ProposalChoice( + id = json.string("id"), + ownerId = json.string("ownerId"), + proposalId = json.string("proposalId"), + revision = json.optionalLong("revision"), + createdAtMs = json.optionalLong("createdAt"), + updatedAtMs = json.optionalLong("updatedAt"), + title = json.string("title"), + description = json.optionalString("description"), + ) + } + } +} + +/** + * The vote among a multiple choice proposal's choices + * (`dash_sdk_multiple_choice_proposal_get_vote`): every choice with its tally while the vote + * runs, and how it ended with every choice's final tally once it did. + */ +data class MultipleChoiceProposalVote( + /** The choices, ordered by choice id; empty for a proposal no choice was entered for. */ + val choices: List, + /** The abstaining votes; null when Platform does not report them. */ + val abstainVoteTally: Long?, + /** The votes for none of the choices; null when Platform does not report them. */ + val noneOfTheChoicesVoteTally: Long?, + /** How the vote ended; null while it runs. */ + val result: Result?, +) { + /** One choice in the vote. */ + data class ChoiceInVote( + /** The choice's document id, base58: the id a vote for it names. */ + val id: String, + /** + * The choice, while the vote runs. Null once it ended: the choices not kept are + * gone, and the kept one is read with [MultipleChoiceProposals.keptChoice]. + */ + val choice: ProposalChoice?, + /** + * The votes towards the choice: so far while the vote runs, final once it ended. + * Null when Platform does not report it. + */ + val voteTally: Long?, + ) + + /** How a finished vote ended. [jsonName] is how the vote JSON names it. */ + enum class Outcome(val jsonName: String) { + /** The choice [Result.keptChoiceId] names was kept as an ordinary document. */ + KEPT_CHOICE("keptChoice"), + + /** The votes for none of the choices outnumbered the leading choice; none was kept. */ + NONE_OF_THE_CHOICES("noneOfTheChoices"), + + /** No choice won; none was kept. */ + NO_WINNER("noWinner"), + ; + + internal companion object { + fun fromJsonName(name: String): Outcome = + entries.firstOrNull { it.jsonName == name } + ?: throw DashSdkError.SerializationError( + "Unknown multiple choice vote outcome: $name", + ) + } + } + + /** The record of a finished vote. */ + data class Result( + val outcome: Outcome, + /** The kept choice's document id, base58; null unless [outcome] is [Outcome.KEPT_CHOICE]. */ + val keptChoiceId: String?, + /** The block that ended the vote. */ + val finalizationBlock: PlatformBlockInfo, + ) + + internal companion object { + /** Decode the vote object. */ + fun fromJson(json: String): MultipleChoiceProposalVote = with(DecisionProposalJson) { + val obj = parseObject(json, "multiple choice proposal vote") + MultipleChoiceProposalVote( + choices = obj.objects("choices").map { entry -> + ChoiceInVote( + id = entry.string("id"), + choice = entry.optionalObj("choice")?.let(ProposalChoice::fromJsonObject), + voteTally = entry.optionalLong("voteTally"), + ) + }, + abstainVoteTally = obj.optionalLong("abstainVoteTally"), + noneOfTheChoicesVoteTally = obj.optionalLong("noneOfTheChoicesVoteTally"), + result = obj.optionalObj("result")?.let { result -> + Result( + outcome = Outcome.fromJsonName(result.string("outcome")), + keptChoiceId = result.optionalString("keptChoiceId"), + finalizationBlock = block(result.obj("finalizationBlock")), + ) + }, + ) + } + } +} + +/** + * A masternode's answer in the vote among a multiple choice proposal's choices: what + * [MultipleChoiceProposals.castVote] takes and [MultipleChoiceProposals.masternodeVote] + * returns. Kotlin mirror of Swift's and rs-dpp's `MultipleChoiceVoteChoice`. + */ +sealed class MultipleChoiceVoteChoice { + /** + * A vote for the choice whose document id is [choiceId], base58 (not the id of the + * identity that entered it). + */ + data class Choice(val choiceId: String) : MultipleChoiceVoteChoice() + + /** A vote that no choice be kept: none is when these outnumber the leading choice. */ + data object NoneOfTheChoices : MultipleChoiceVoteChoice() + + /** An abstention, recorded but playing no part in the result. */ + data object Abstain : MultipleChoiceVoteChoice() + + internal companion object { + /** + * Decode `{"choice": "choice", "choiceId": ""}` or + * `{"choice": "noneOfTheChoices" | "abstain", "choiceId": null}`. + */ + fun fromJson(json: String): MultipleChoiceVoteChoice = with(DecisionProposalJson) { + val obj = parseObject(json, "masternode multiple choice vote") + when (val name = obj.string("choice")) { + "choice" -> Choice(obj.string("choiceId")) + "noneOfTheChoices" -> NoneOfTheChoices + "abstain" -> Abstain + else -> throw DashSdkError.SerializationError( + "Unknown multiple choice vote choice: $name", + ) + } + } + } +} + +/** + * How `dash_sdk_multiple_choice_proposal_cast_vote` takes a [MultipleChoiceVoteChoice]: the + * `vote_choice` byte ([discriminant]: `0` a choice, `1` none of the choices, `2` abstain) and + * the `choice_id`, null for the answers that name none. The header declares no enum, so the + * three values are mirrored here. + */ +internal data class NativeMultipleChoiceVote(val discriminant: Int, val choiceId: String?) + +/** This answer as the `vote_choice` and `choice_id` of the cast vote. */ +internal fun MultipleChoiceVoteChoice.toNative(): NativeMultipleChoiceVote = when (this) { + is MultipleChoiceVoteChoice.Choice -> NativeMultipleChoiceVote(discriminant = 0, choiceId = choiceId) + MultipleChoiceVoteChoice.NoneOfTheChoices -> NativeMultipleChoiceVote(discriminant = 1, choiceId = null) + MultipleChoiceVoteChoice.Abstain -> NativeMultipleChoiceVote(discriminant = 2, choiceId = null) +} + +/** + * The document a new or edited multiple choice proposal points at, as the wallet writes take + * it: the ids as their 32 bytes, like the other ids of + * [MultipleChoiceProposalTransactions]. Kotlin mirror of the C `DescriptionDocumentFFI` and + * Swift's `DescriptionDocumentParams`. Nothing is checked here. + */ +class DescriptionDocumentParams( + /** The document's 32-byte id. */ + val id: ByteArray, + /** The 32-byte id of the contract it lives in. */ + val contractId: ByteArray, + /** Its document type. */ + val documentType: String, +) { + override fun equals(other: Any?): Boolean = + this === other || + other is DescriptionDocumentParams && + id.contentEquals(other.id) && + contractId.contentEquals(other.contractId) && + documentType == other.documentType + + override fun hashCode(): Int = + 31 * (31 * id.contentHashCode() + contractId.contentHashCode()) + documentType.hashCode() + + override fun toString(): String = + "DescriptionDocumentParams(id=${id.toHexString()}, " + + "contractId=${contractId.toHexString()}, documentType=$documentType)" + + private fun ByteArray.toHexString(): String = joinToString("") { "%02x".format(it) } +} + +/** + * What a new multiple choice proposal asks, the input of + * [MultipleChoiceProposalTransactions.create]. Kotlin mirror of the C + * `MultipleChoiceProposalParamsFFI` and Swift's `MultipleChoiceProposalParams`. Nothing is + * checked here: Platform refuses a title of + * more than 128 characters, a url of more than 512, and a proposal that gives neither a + * description document nor a url. + */ +data class MultipleChoiceProposalParams( + /** The question, in one line. */ + val title: String, + /** The document saying what is being decided; null for none. */ + val descriptionDocument: DescriptionDocumentParams? = null, + /** + * Where what is being decided is described, for a proposal that points at no description + * document, or where it is discussed, for one that does; null for none. + */ + val url: String? = null, + /** + * Whether anyone may enter choices; only the proposal's owner may when it is false. It + * never changes. + */ + val open: Boolean, +) + +/** + * What a stored multiple choice proposal changes to, the input of + * [MultipleChoiceProposalTransactions.edit]. A field left as it is here keeps its value. + * Kotlin mirror of the C `MultipleChoiceProposalEditFFI` and Swift's + * `MultipleChoiceProposalEdit`; rs-sdk refuses an edit that changes nothing, and Platform + * one more than two hours after the proposal was created and one that leaves it with + * neither a description document nor a url. + */ +data class MultipleChoiceProposalEdit( + /** The new title; null keeps it. */ + val title: String? = null, + /** What happens to the description document. */ + val descriptionDocument: Change = Change.Keep, + /** What happens to the url. */ + val url: Change = Change.Keep, +) { + /** What an edit does to a field a proposal may not have. */ + sealed interface Change { + /** The field stays as it is. */ + data object Keep : Change + + /** The field becomes [value]. */ + data class Set(val value: T) : Change + + /** The proposal no longer has the field. */ + data object Remove : Change + } +} + +/** + * How `MultipleChoiceProposalEditFFI` says a [MultipleChoiceProposalEdit.Change]: the new + * [value], or null with [remove] set to remove the field, or null without it to keep it. + */ +internal data class NativeChange(val value: T?, val remove: Boolean) + +/** This change as a field and its `remove_` flag of `MultipleChoiceProposalEditFFI`. */ +internal fun MultipleChoiceProposalEdit.Change.toNative(): NativeChange = when (this) { + MultipleChoiceProposalEdit.Change.Keep -> NativeChange(value = null, remove = false) + is MultipleChoiceProposalEdit.Change.Set -> NativeChange(value = value, remove = false) + MultipleChoiceProposalEdit.Change.Remove -> NativeChange(value = null, remove = true) +} + +/** + * An answer to enter for a multiple choice proposal, the input of + * [MultipleChoiceProposalTransactions.enterChoice]. Kotlin mirror of the C `ChoiceParamsFFI` + * and Swift's `ProposalChoiceParams`. Nothing is checked here: Platform refuses a title of + * more than 128 characters and a description of more than 4096. + */ +data class ProposalChoiceParams( + /** The answer, in one line. */ + val title: String, + /** What voting for the answer means; null for none. */ + val description: String? = null, +) + +/** + * A multiple choice proposal Platform confirmed creating, as + * [MultipleChoiceProposalTransactions.create] returns it. + */ +data class CreatedMultipleChoiceProposal( + /** The proposal's id, base58: the id the reads of `Sdk.multipleChoiceProposals` take. */ + val id: String, + /** + * The confirmed document's canonical JSON, the shape the platform wallet's document + * create returns. + */ + val documentJson: String, +) + +/** + * A choice Platform confirmed entering, as [MultipleChoiceProposalTransactions.enterChoice] + * returns it. + */ +data class EnteredProposalChoice( + /** The choice's document id, base58: the id a masternode vote for it names. */ + val id: String, + /** + * The confirmed document's canonical JSON, the shape the platform wallet's document + * create returns. + */ + val documentJson: String, +) + +/** + * The credits a multiple choice proposal amount read returns: rs-sdk-ffi writes them as a + * decimal string, not JSON. Anything else is a [DashSdkError.SerializationError]. + */ +internal fun creditsFromDecimal(decimal: String): ULong = decimal.toULongOrNull() + ?: throw DashSdkError.SerializationError("Malformed credit amount: $decimal") diff --git a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/MultipleChoiceProposals.kt b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/MultipleChoiceProposals.kt new file mode 100644 index 00000000000..9c80d62c0bc --- /dev/null +++ b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/MultipleChoiceProposals.kt @@ -0,0 +1,299 @@ +package org.dashfoundation.dashsdk.voting + +import org.dashfoundation.dashsdk.Sdk +import org.dashfoundation.dashsdk.errors.DashSdkError +import org.dashfoundation.dashsdk.errors.mapNativeErrors +import org.dashfoundation.dashsdk.ffi.MultipleChoiceProposalsNative +import org.dashfoundation.dashsdk.persistence.toBase58String +import org.dashfoundation.dashsdk.wallet.TeardownGate +import org.dashfoundation.dashsdk.wallet.op +import org.dashfoundation.dashsdk.wallet.opReturningCompletedResult + +/** + * Multiple choice proposals (protocol version 15): questions whose answers are the choices + * entered for them, as `multipleChoiceProposal` and `choice` documents of the decision + * proposals system contract. Reads of proposals and of the vote among their choices, the + * two amounts a proposal and a choice cost, and the masternode vote. Kotlin counterpart of + * the Swift SDK's `SDK+MultipleChoiceProposals.swift`; reach it through + * `Sdk.multipleChoiceProposals`. Creating and editing a proposal and entering a choice go + * through the wallet: [MultipleChoiceProposalTransactions]. + * + * Thin wrapper over [MultipleChoiceProposalsNative]: rs-sdk decides everything (which + * documents are proposals and choices, the vote's contest, the funds and fees), every read + * is proved, and nothing is checked here. Every call runs under the SDK's query gate, so + * closing the SDK waits for it. Ids are base58 strings. A network below protocol version 15 + * has no decision proposals contract, which the calls report as an error. + */ +class MultipleChoiceProposals internal constructor(private val sdk: Sdk) { + + /** The proposal [proposalId], or null when there is none. */ + suspend fun fetch(proposalId: String): MultipleChoiceProposal? = sdk.queryGate.op { + mapNativeErrors { MultipleChoiceProposalsNative.fetch(sdk.handle, proposalId) } + ?.let(MultipleChoiceProposal::fromJson) + } + + /** + * One page of [ownerId]'s proposals, in the order it filed them. + * + * @param limit the most proposals to return, at most 100; 0 for 100. A page shorter + * than the limit is the last. + * @param startAfter the id of the last proposal of the previous page; null for the first. + */ + suspend fun listByOwner( + ownerId: String, + limit: Int = 0, + startAfter: String? = null, + ): List = sdk.queryGate.op { + val json = mapNativeErrors { + MultipleChoiceProposalsNative.listByOwner(sdk.handle, ownerId, limit, startAfter) + } + MultipleChoiceProposal.listFromJson(json.returned("listByOwner")) + } + + /** One page of every proposal, newest first; paging as [listByOwner]. */ + suspend fun listByCreatedAt( + limit: Int = 0, + startAfter: String? = null, + ): List = sdk.queryGate.op { + val json = mapNativeErrors { + MultipleChoiceProposalsNative.listByCreatedAt(sdk.handle, limit, startAfter) + } + MultipleChoiceProposal.listFromJson(json.returned("listByCreatedAt")) + } + + /** + * The vote among [proposalId]'s choices: every choice with its tally while the vote + * runs, and how it ended with every choice's final tally once it did. A proposal no + * choice was entered for has no choices and no result. + */ + suspend fun vote(proposalId: String): MultipleChoiceProposalVote = sdk.queryGate.op { + val json = mapNativeErrors { MultipleChoiceProposalsNative.getVote(sdk.handle, proposalId) } + MultipleChoiceProposalVote.fromJson(json.returned("getVote")) + } + + /** + * The choice [proposalId]'s finished vote kept, an ordinary document of the identity + * that entered it; null while the vote runs, when it kept none of the choices, and for + * a proposal no choice was entered for. + */ + suspend fun keptChoice(proposalId: String): ProposalChoice? = sdk.queryGate.op { + mapNativeErrors { MultipleChoiceProposalsNative.getKeptChoice(sdk.handle, proposalId) } + ?.let(ProposalChoice::fromJson) + } + + /** + * The answer a masternode gave in [proposalId]'s vote, or null when it has not voted in + * it, and once the vote ended. + * + * @param proTxHash the masternode's 32-byte pro_tx_hash in wire order, as [castVote] + * takes it. + */ + suspend fun masternodeVote( + proTxHash: ByteArray, + proposalId: String, + ): MultipleChoiceVoteChoice? = sdk.queryGate.op { + mapNativeErrors { + MultipleChoiceProposalsNative.getMasternodeVote(sdk.handle, proTxHash, proposalId) + }?.let(MultipleChoiceVoteChoice::fromJson) + } + + /** + * What creating one multiple choice proposal adds to the processing fee of its batch, + * in credits (0.2 Dash at protocol version 15). Platform charges the owner it on top of + * the fees; the create does not state it. + */ + suspend fun processingFee(): ULong = sdk.queryGate.op { + creditsFromDecimal( + mapNativeErrors { MultipleChoiceProposalsNative.getProcessingFee(sdk.handle) } + .returned("getProcessingFee"), + ) + } + + /** + * The fund a choice entered now for [proposalId] pays, in credits: the contest's fund, + * raised as the vote fills up. Entering a choice reads and states it itself; this is + * for showing it beforehand. + */ + suspend fun choiceFundToJoin(proposalId: String): ULong = sdk.queryGate.op { + creditsFromDecimal( + mapNativeErrors { + MultipleChoiceProposalsNative.getChoiceFundToJoin(sdk.handle, proposalId) + }.returned("getChoiceFundToJoin"), + ) + } + + /** + * Vote among [proposalId]'s choices for a masternode and wait for the response: the + * vote is signed with the masternode voting key derived from [votingPrivateKey] and + * broadcast for [proTxHash]. A vote from a wallet that is not a masternode is refused + * by Platform (no voter identity), the expected outcome. + * + * @param proTxHash 32-byte pro_tx_hash in wire order: the orientation `Txid` stores, + * which a parsed ProRegTx yields. NOT the byte order of the hex Core displays, which + * is its reverse (see [VoteCasting.castVote]). + * @param votingPrivateKey 32-byte masternode voting private key; not stored. + */ + suspend fun castVote( + proposalId: String, + choice: MultipleChoiceVoteChoice, + proTxHash: ByteArray, + votingPrivateKey: ByteArray, + ) = sdk.queryGate.op { + val vote = choice.toNative() + mapNativeErrors { + MultipleChoiceProposalsNative.castVote( + sdk.handle, + proposalId, + vote.discriminant, + vote.choiceId, + proTxHash, + votingPrivateKey, + sdk.network.ffiValue, + ) + } + } +} + +/** + * Creating and editing multiple choice proposals and entering their choices through the + * platform wallet: the Kotlin counterpart of Swift's `ManagedPlatformWallet` multiple choice + * proposal slice (`ManagedPlatformWalletMultipleChoiceProposals.swift`). Reach it through + * `PlatformWalletManager.multipleChoiceProposals`; callers thread the wallet handle and the + * manager's `signerHandle` into each call, as for the wallet's document calls. + * + * Each call is one native call (`platform_wallet_multiple_choice_proposal_create` / `_edit` + * / `_enter_choice`): the wallet builds the document (or reads the stored proposal and edits + * it), picks the signing key, broadcasts and waits for Platform to confirm. Nothing is + * decided or checked here. + * + * Cancellation: native code cannot see a coroutine's cancellation, so a write can complete + * after its caller was cancelled. Each call then still returns what Platform confirmed + * (see [opReturningCompletedResult]) instead of throwing, so a paid create or choice is + * never hidden from a caller that would otherwise pay for it again. The coroutine stays + * cancelled: handle the result before the next suspension point. + */ +class MultipleChoiceProposalTransactions internal constructor(private val gate: TeardownGate?) { + + /** + * Create and broadcast a multiple choice proposal of [ownerId] asking what [params] + * says, signed via [signerHandle] with a key the wallet selects. Platform charges the + * owner the processing fee [MultipleChoiceProposals.processingFee] reads on top of the + * fees. + * + * @param walletHandle the handle of the wallet that holds [ownerId]. + * @param ownerId the proposer's 32-byte identity id. + * @return the proposal Platform confirmed: its id and the document's canonical JSON. + */ + suspend fun create( + walletHandle: Long, + ownerId: ByteArray, + params: MultipleChoiceProposalParams, + signerHandle: Long, + ): CreatedMultipleChoiceProposal = gate.opReturningCompletedResult { + val proposalId = ByteArray(ID_SIZE) + val documentJson = mapNativeErrors { + MultipleChoiceProposalsNative.create( + walletHandle, + ownerId, + params.title, + params.descriptionDocument?.id, + params.descriptionDocument?.contractId, + params.descriptionDocument?.documentType, + params.url, + params.open, + signerHandle, + proposalId, + ) + } + CreatedMultipleChoiceProposal(id = proposalId.toBase58String(), documentJson = documentJson) + } + + /** + * Give the proposal [proposalId] of [ownerId] what [edit] changes and broadcast the + * replace, signed via [signerHandle] with a key the wallet selects as [create] does. + * + * The wallet reads the proposal once and puts the edit at the revision after the one + * read: if another edit lands in between, Platform refuses this one (its + * [DashSdkError.consensusError] code is 40106) rather than overwrite it, and the caller + * reads the proposal again before offering the edit anew. rs-sdk refuses an edit that + * changes nothing, and Platform one more than two hours after the proposal was created + * and one that leaves it with neither a description document nor a url. + * + * @param proposalId the proposal's 32-byte id. + * @return the confirmed document's canonical JSON, at its new revision. + * @throws DashSdkError.PlatformWallet.NotFound when there is no such proposal. + */ + suspend fun edit( + walletHandle: Long, + ownerId: ByteArray, + proposalId: ByteArray, + edit: MultipleChoiceProposalEdit, + signerHandle: Long, + ): String = gate.opReturningCompletedResult { + val descriptionDocument = edit.descriptionDocument.toNative() + val url = edit.url.toNative() + mapNativeErrors { + MultipleChoiceProposalsNative.edit( + walletHandle, + ownerId, + proposalId, + edit.title, + descriptionDocument.value?.id, + descriptionDocument.value?.contractId, + descriptionDocument.value?.documentType, + descriptionDocument.remove, + url.value, + url.remove, + signerHandle, + ) + } + } + + /** + * Enter the choice [params] describes, owned by [ownerId], for the proposal + * [proposalId] and broadcast it, signed via [signerHandle] with a key the wallet + * selects as [create] does. The put states the contest fund + * [MultipleChoiceProposals.choiceFundToJoin] reads, paid by the owner on top of the + * fees; the first choice opens the vote. Platform refuses a choice for a proposal that + * is not open from anyone but its owner, and one entered once the vote's join window + * closed. A choice is never edited. + * + * @param ownerId the 32-byte id of the identity entering the choice. + * @param proposalId the proposal's 32-byte id. + * @return the choice Platform confirmed: its id and the document's canonical JSON. + */ + suspend fun enterChoice( + walletHandle: Long, + ownerId: ByteArray, + proposalId: ByteArray, + params: ProposalChoiceParams, + signerHandle: Long, + ): EnteredProposalChoice = gate.opReturningCompletedResult { + val choiceId = ByteArray(ID_SIZE) + val documentJson = mapNativeErrors { + MultipleChoiceProposalsNative.enterChoice( + walletHandle, + ownerId, + proposalId, + params.title, + params.description, + signerHandle, + choiceId, + ) + } + EnteredProposalChoice(id = choiceId.toBase58String(), documentJson = documentJson) + } + + private companion object { + /** The length of the id a create writes back. */ + const val ID_SIZE = 32 + } +} + +/** + * The value a native call returned. Null is reserved for a thrown error (already raised by + * the JNI layer) or an absence the call can report; for a call that always answers, null is + * a broken native result. + */ +private fun T?.returned(call: String): T = this + ?: throw DashSdkError.InternalError("MultipleChoiceProposalsNative.$call returned nothing") diff --git a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt index c1ec7960603..fd1a4d10ea9 100644 --- a/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt +++ b/packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt @@ -868,6 +868,16 @@ class PlatformWalletManager( val decisionProposals: org.dashfoundation.dashsdk.voting.DecisionProposalTransactions = org.dashfoundation.dashsdk.voting.DecisionProposalTransactions(teardownGate) + /** + * Multiple choice proposal create and edit, and entering a choice (protocol version + * 15): the multiple choice proposal slice of `ManagedPlatformWallet` + * (`ManagedPlatformWalletMultipleChoiceProposals.swift`). Stateless; callers thread the + * wallet handle and [signerHandle] into each call. Reads and the masternode vote are on + * `Sdk.multipleChoiceProposals`. + */ + val multipleChoiceProposals: org.dashfoundation.dashsdk.voting.MultipleChoiceProposalTransactions = + org.dashfoundation.dashsdk.voting.MultipleChoiceProposalTransactions(teardownGate) + // ── Native manager bundle ───────────────────────────────────────── private val nativeInitialization = initializePlatformWalletNativeManager( diff --git a/packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/voting/MultipleChoiceProposalModelsTest.kt b/packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/voting/MultipleChoiceProposalModelsTest.kt new file mode 100644 index 00000000000..221baf7df48 --- /dev/null +++ b/packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/voting/MultipleChoiceProposalModelsTest.kt @@ -0,0 +1,338 @@ +package org.dashfoundation.dashsdk.voting + +import org.dashfoundation.dashsdk.errors.DashSdkError +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertThrows +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * Decoding of what the multiple choice proposal natives return, and the encoding of what + * they take (the vote choice, an edit's changes). + * + * Rust writes every value (rs-sdk-ffi's `decision_proposal/multiple_choice/json.rs` tests + * pin the same shapes); Kotlin only decodes, so these tests pin the JSON as rs-sdk-ffi + * writes it, key for key. Pure JVM: no native library is loaded. + */ +class MultipleChoiceProposalModelsTest { + + private val proposalId = "8vLzWy3oPYAwJ9W8TjWZ3vSJMy7bDqyuvbMvzQMxVjPN" + private val ownerId = "CQwyTH5AnQ5YQVGeYhBP8ihLdMKKbS6ydzN2E8wRWMNn" + private val choiceId = "5DbLwAxGBzUzo81VewMUwn4b5P4bpv9FNFybi25XB5Bk" + private val otherChoiceId = "4EfA9Jrvv3nnCFdSf7fad59851iiTRZ6Wcu6YVJ4iSeF" + private val describedId = "7NYmEKQsYtniQRUmxwdPGeVcirMoPh5ZPyAKz8BWFy3r" + private val describedContractId = "GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec" + + private val proposalJson = """ + {"id":"$proposalId","ownerId":"$ownerId","revision":1, + "createdAt":1700000000000,"updatedAt":1700000000000, + "title":"Which block size?", + "descriptionDocument":{"id":"$describedId","contractId":"$describedContractId","documentType":"post"}, + "url":"https://forum.dash.org/t/block-size","open":true} + """.trimIndent() + + private val choiceJson = """ + {"id":"$choiceId","ownerId":"$ownerId","proposalId":"$proposalId","revision":null, + "createdAt":1700000000000,"updatedAt":null, + "title":"Double it","description":"Twice the size it is today."} + """.trimIndent() + + private val choice = ProposalChoice( + id = choiceId, + ownerId = ownerId, + proposalId = proposalId, + revision = null, + createdAtMs = 1_700_000_000_000, + updatedAtMs = null, + title = "Double it", + description = "Twice the size it is today.", + ) + + @Test + fun shouldDecodeAProposalWithEveryField() { + assertEquals( + MultipleChoiceProposal( + id = proposalId, + ownerId = ownerId, + revision = 1, + createdAtMs = 1_700_000_000_000, + updatedAtMs = 1_700_000_000_000, + title = "Which block size?", + descriptionDocument = MultipleChoiceProposal.DescriptionDocument( + id = describedId, + contractId = describedContractId, + documentType = "post", + ), + url = "https://forum.dash.org/t/block-size", + open = true, + ), + MultipleChoiceProposal.fromJson(proposalJson), + ) + } + + @Test + fun shouldDecodeAnAbsentDescriptionDocumentUrlAndSystemFieldsAsNull() { + val proposal = MultipleChoiceProposal.fromJson( + """ + {"id":"$proposalId","ownerId":"$ownerId","revision":null,"createdAt":null, + "updatedAt":null,"title":"t","descriptionDocument":null,"url":null,"open":false} + """.trimIndent(), + ) + assertNull(proposal.descriptionDocument) + assertNull(proposal.url) + assertNull(proposal.revision) + assertNull(proposal.createdAtMs) + assertNull(proposal.updatedAtMs) + assertEquals(false, proposal.open) + } + + @Test + fun shouldDecodeAListingInItsOrder() { + val second = proposalJson.replace(proposalId, otherChoiceId) + val listing = MultipleChoiceProposal.listFromJson("[$proposalJson,$second]") + assertEquals(listOf(proposalId, otherChoiceId), listing.map { it.id }) + assertEquals(emptyList(), MultipleChoiceProposal.listFromJson("[]")) + } + + @Test + fun shouldDecodeAChoiceWithEveryFieldAndAnAbsentDescriptionAsNull() { + assertEquals(choice, ProposalChoice.fromJson(choiceJson)) + val bare = ProposalChoice.fromJson( + choiceJson.replace("\"Twice the size it is today.\"", "null"), + ) + assertNull(bare.description) + assertNull(bare.revision) + assertNull(bare.updatedAtMs) + } + + @Test + fun shouldDecodeARunningVoteWithItsChoicesAndTallies() { + val vote = MultipleChoiceProposalVote.fromJson( + """ + {"choices":[{"id":"$choiceId","choice":$choiceJson,"voteTally":12}, + {"id":"$otherChoiceId","choice":null,"voteTally":null}], + "abstainVoteTally":3,"noneOfTheChoicesVoteTally":1,"result":null} + """.trimIndent(), + ) + assertEquals( + MultipleChoiceProposalVote( + choices = listOf( + MultipleChoiceProposalVote.ChoiceInVote(id = choiceId, choice = choice, voteTally = 12), + MultipleChoiceProposalVote.ChoiceInVote(id = otherChoiceId, choice = null, voteTally = null), + ), + abstainVoteTally = 3, + noneOfTheChoicesVoteTally = 1, + result = null, + ), + vote, + ) + } + + @Test + fun shouldDecodeHowAFinishedVoteEndedForEveryOutcome() { + val outcomes = listOf( + Triple("keptChoice", "\"$choiceId\"", MultipleChoiceProposalVote.Outcome.KEPT_CHOICE), + Triple("noneOfTheChoices", "null", MultipleChoiceProposalVote.Outcome.NONE_OF_THE_CHOICES), + Triple("noWinner", "null", MultipleChoiceProposalVote.Outcome.NO_WINNER), + ) + for ((name, keptChoiceId, outcome) in outcomes) { + val vote = MultipleChoiceProposalVote.fromJson( + """ + {"choices":[{"id":"$choiceId","choice":null,"voteTally":9}], + "abstainVoteTally":null,"noneOfTheChoicesVoteTally":4, + "result":{"outcome":"$name","keptChoiceId":$keptChoiceId, + "finalizationBlock":{"height":9,"coreHeight":42,"timeMs":9000,"epoch":3}}} + """.trimIndent(), + ) + assertEquals( + name, + MultipleChoiceProposalVote( + choices = listOf( + MultipleChoiceProposalVote.ChoiceInVote(id = choiceId, choice = null, voteTally = 9), + ), + abstainVoteTally = null, + noneOfTheChoicesVoteTally = 4, + result = MultipleChoiceProposalVote.Result( + outcome = outcome, + keptChoiceId = choiceId.takeIf { outcome == MultipleChoiceProposalVote.Outcome.KEPT_CHOICE }, + finalizationBlock = PlatformBlockInfo( + height = 9, + coreHeight = 42, + timeMs = 9_000, + epoch = 3, + ), + ), + ), + vote, + ) + } + assertEquals(3, MultipleChoiceProposalVote.Outcome.entries.size) + } + + @Test + fun shouldDecodeAVoteWithNoChoiceAsEmpty() { + assertEquals( + MultipleChoiceProposalVote( + choices = emptyList(), + abstainVoteTally = null, + noneOfTheChoicesVoteTally = null, + result = null, + ), + MultipleChoiceProposalVote.fromJson( + """{"choices":[],"abstainVoteTally":null,"noneOfTheChoicesVoteTally":null,"result":null}""", + ), + ) + } + + @Test + fun shouldDecodeAMasternodeAnswerForEveryChoice() { + assertEquals( + MultipleChoiceVoteChoice.Choice(choiceId), + MultipleChoiceVoteChoice.fromJson("""{"choice":"choice","choiceId":"$choiceId"}"""), + ) + assertEquals( + MultipleChoiceVoteChoice.NoneOfTheChoices, + MultipleChoiceVoteChoice.fromJson("""{"choice":"noneOfTheChoices","choiceId":null}"""), + ) + assertEquals( + MultipleChoiceVoteChoice.Abstain, + MultipleChoiceVoteChoice.fromJson("""{"choice":"abstain","choiceId":null}"""), + ) + } + + /** The `vote_choice` byte and `choice_id` of `dash_sdk_multiple_choice_proposal_cast_vote`. */ + @Test + fun shouldEncodeTheVoteChoiceAsTheFfiByteAndChoiceId() { + assertEquals( + NativeMultipleChoiceVote(discriminant = 0, choiceId = choiceId), + MultipleChoiceVoteChoice.Choice(choiceId).toNative(), + ) + assertEquals( + NativeMultipleChoiceVote(discriminant = 1, choiceId = null), + MultipleChoiceVoteChoice.NoneOfTheChoices.toNative(), + ) + assertEquals( + NativeMultipleChoiceVote(discriminant = 2, choiceId = null), + MultipleChoiceVoteChoice.Abstain.toNative(), + ) + } + + /** A field and its `remove_` flag of `MultipleChoiceProposalEditFFI`, one shape per change. */ + @Test + fun shouldEncodeEveryChangeAsTheEditTakesIt() { + assertEquals( + NativeChange(value = null, remove = false), + (MultipleChoiceProposalEdit.Change.Keep as MultipleChoiceProposalEdit.Change).toNative(), + ) + assertEquals( + NativeChange(value = "https://forum.dash.org/t/block-size", remove = false), + MultipleChoiceProposalEdit.Change.Set("https://forum.dash.org/t/block-size").toNative(), + ) + assertEquals( + NativeChange(value = null, remove = true), + (MultipleChoiceProposalEdit.Change.Remove as MultipleChoiceProposalEdit.Change).toNative(), + ) + + val described = DescriptionDocumentParams(ByteArray(32) { 5 }, ByteArray(32) { 6 }, "post") + assertEquals( + NativeChange(value = described, remove = false), + MultipleChoiceProposalEdit.Change.Set(described).toNative(), + ) + + val untouched = MultipleChoiceProposalEdit() + assertNull(untouched.title) + assertEquals(MultipleChoiceProposalEdit.Change.Keep, untouched.descriptionDocument) + assertEquals(MultipleChoiceProposalEdit.Change.Keep, untouched.url) + } + + /** The input holds byte arrays, so it compares them by content. */ + @Test + fun shouldCompareADescriptionDocumentParamsByItsContent() { + val described = DescriptionDocumentParams(ByteArray(32) { 5 }, ByteArray(32) { 6 }, "post") + val same = DescriptionDocumentParams(ByteArray(32) { 5 }, ByteArray(32) { 6 }, "post") + assertEquals(described, same) + assertEquals(described.hashCode(), same.hashCode()) + assertNotEquals(described, DescriptionDocumentParams(ByteArray(32) { 7 }, ByteArray(32) { 6 }, "post")) + assertNotEquals(described, DescriptionDocumentParams(ByteArray(32) { 5 }, ByteArray(32) { 7 }, "post")) + assertNotEquals(described, DescriptionDocumentParams(ByteArray(32) { 5 }, ByteArray(32) { 6 }, "note")) + } + + /** The two amounts cross as decimal strings of credits, up to `u64::MAX`. */ + @Test + fun shouldDecodeACreditAmountFromItsDecimalString() { + assertEquals(20_000_000_000uL, creditsFromDecimal("20000000000")) + assertEquals(ULong.MAX_VALUE, creditsFromDecimal("18446744073709551615")) + for (malformed in listOf("", "-1", "2e10", "18446744073709551616", "\"20000000000\"")) { + assertThrows(malformed, DashSdkError.SerializationError::class.java) { + creditsFromDecimal(malformed) + } + } + } + + @Test + fun shouldRefuseJsonMissingARequiredField() { + val error = assertThrows(DashSdkError.SerializationError::class.java) { + MultipleChoiceProposal.fromJson(proposalJson.replace("\"open\"", "\"isOpen\"")) + } + assertTrue(error.message.orEmpty(), error.message.orEmpty().contains("open")) + assertThrows(DashSdkError.SerializationError::class.java) { + ProposalChoice.fromJson(choiceJson.replace("\"proposalId\"", "\"proposal\"")) + } + assertThrows(DashSdkError.SerializationError::class.java) { + MultipleChoiceProposalVote.fromJson( + """{"abstainVoteTally":null,"noneOfTheChoicesVoteTally":null,"result":null}""", + ) + } + } + + @Test + fun shouldRefuseAFieldOfTheWrongType() { + assertThrows(DashSdkError.SerializationError::class.java) { + MultipleChoiceProposal.fromJson(proposalJson.replace("\"open\":true", "\"open\":\"true\"")) + } + assertThrows(DashSdkError.SerializationError::class.java) { + MultipleChoiceProposal.fromJson( + proposalJson.replace(Regex("\"descriptionDocument\":\\{[^}]*\\}"), "\"descriptionDocument\":\"post\""), + ) + } + assertThrows(DashSdkError.SerializationError::class.java) { + MultipleChoiceProposalVote.fromJson( + """{"choices":["$choiceId"],"abstainVoteTally":null, + "noneOfTheChoicesVoteTally":null,"result":null}""", + ) + } + } + + @Test + fun shouldRefuseAnUnknownOutcomeOrChoice() { + assertThrows(DashSdkError.SerializationError::class.java) { + MultipleChoiceProposalVote.fromJson( + """{"choices":[],"abstainVoteTally":null,"noneOfTheChoicesVoteTally":null, + "result":{"outcome":"tied","keptChoiceId":null, + "finalizationBlock":{"height":9,"coreHeight":42,"timeMs":9000,"epoch":3}}}""", + ) + } + assertThrows(DashSdkError.SerializationError::class.java) { + MultipleChoiceVoteChoice.fromJson("""{"choice":"maybe","choiceId":null}""") + } + // A vote for a choice names it. + assertThrows(DashSdkError.SerializationError::class.java) { + MultipleChoiceVoteChoice.fromJson("""{"choice":"choice","choiceId":null}""") + } + } + + @Test + fun shouldRefuseTextThatIsNotJson() { + assertThrows(DashSdkError.SerializationError::class.java) { + MultipleChoiceProposal.listFromJson("not json") + } + assertThrows(DashSdkError.SerializationError::class.java) { + MultipleChoiceProposal.listFromJson(proposalJson) + } + assertThrows(DashSdkError.SerializationError::class.java) { + ProposalChoice.fromJson("[]") + } + } +} diff --git a/packages/rs-platform-wallet-ffi/src/decision_proposal.rs b/packages/rs-platform-wallet-ffi/src/decision_proposal.rs index 1b6784d9217..465a35a2a1f 100644 --- a/packages/rs-platform-wallet-ffi/src/decision_proposal.rs +++ b/packages/rs-platform-wallet-ffi/src/decision_proposal.rs @@ -81,7 +81,7 @@ pub struct DecisionProposalEditFFI { /// # Safety /// `ptr` must be null or point to a NUL-terminated string that outlives /// the call. -unsafe fn required_string( +pub(crate) unsafe fn required_string( ptr: *const c_char, field: &str, ) -> Result { diff --git a/packages/rs-platform-wallet-ffi/src/lib.rs b/packages/rs-platform-wallet-ffi/src/lib.rs index 7689e70b984..a7eedf9f7cf 100644 --- a/packages/rs-platform-wallet-ffi/src/lib.rs +++ b/packages/rs-platform-wallet-ffi/src/lib.rs @@ -65,6 +65,7 @@ pub mod masternode_update_service; pub mod masternode_withdrawal; pub mod memory_explorer; pub mod mnemonic_words; +pub mod multiple_choice_proposal; pub mod parse_state_transition; pub mod persistence; pub mod platform_address_sync; @@ -153,6 +154,7 @@ pub use manager::*; pub use manager_diagnostics::*; pub use memory_explorer::*; pub use mnemonic_words::*; +pub use multiple_choice_proposal::*; pub use persistence::*; pub use platform_address_sync::*; pub use platform_address_types::*; diff --git a/packages/rs-platform-wallet-ffi/src/multiple_choice_proposal.rs b/packages/rs-platform-wallet-ffi/src/multiple_choice_proposal.rs new file mode 100644 index 00000000000..a19abcf5caa --- /dev/null +++ b/packages/rs-platform-wallet-ffi/src/multiple_choice_proposal.rs @@ -0,0 +1,872 @@ +//! FFI bindings for multiple choice proposal create and edit, and for +//! entering a choice, on `IdentityWallet` (protocol version 15). +//! +//! Thin: each function reads its C arguments, calls +//! `IdentityWallet::create_multiple_choice_proposal_with_signer`, +//! `IdentityWallet::edit_multiple_choice_proposal_with_signer` or +//! `IdentityWallet::enter_choice_with_signer` on the platform-wallet 8 MB +//! worker stack, and writes the confirmed document back. rs-sdk and the +//! wallet decide everything else: the documents' properties, the contest +//! fund a choice states, the signing key, refusing an edit that changes +//! nothing, and the revision an edit is put at. + +use std::ffi::CString; +use std::os::raw::c_char; +use std::ptr; +use std::slice; + +use dash_sdk::platform::decision_proposals::multiple_choice::{ + ChoiceInput, DescriptionDocument, MultipleChoiceProposalEdit, MultipleChoiceProposalInput, +}; +use dpp::document::{Document, DocumentV0Getters}; +use dpp::prelude::Identifier; +use platform_wallet::PlatformWalletError; +use rs_sdk_ffi::{SignerHandle, VTableSigner}; + +use crate::check_ptr; +use crate::dashpay_profile::decode_opt_c_str; +use crate::decision_proposal::required_string; +use crate::document::confirmed_document_to_json; +use crate::error::*; +use crate::handle::*; +use crate::runtime::block_on_worker; +use crate::types::read_identifier; +use crate::{unwrap_option_or_return, unwrap_result_or_return}; + +/// The document a multiple choice proposal points at for what is being +/// decided. Every field is required. Platform refuses a document that is +/// not of a moderated type the elected team of its contract may delete. +#[repr(C)] +pub struct DescriptionDocumentFFI { + /// The document's 32-byte id. + pub id: *const u8, + /// The 32-byte id of the contract it lives in. + pub contract_id: *const u8, + /// Its document type, NUL-terminated UTF-8. + pub document_type: *const c_char, +} + +/// What a new multiple choice proposal asks +/// (`platform_wallet_multiple_choice_proposal_create`). Platform refuses +/// values outside the limits noted here when the proposal is created, and +/// a proposal that gives neither a description document nor a url; +/// nothing is checked before. +#[repr(C)] +pub struct MultipleChoiceProposalParamsFFI { + /// The question, in one line: 1 to 128 characters. NUL-terminated + /// UTF-8, required. + pub title: *const c_char, + /// The document saying what is being decided; null for none. + pub description_document: *const DescriptionDocumentFFI, + /// Where what is being decided is described, for a proposal that + /// points at no description document, or where it is discussed, for + /// one that does: a URI of at most 512 characters. NUL-terminated + /// UTF-8; null for none. + pub url: *const c_char, + /// Whether anyone may enter choices; only the proposal's owner may + /// when it is false. It never changes. + pub open: bool, +} + +/// What a multiple choice proposal changes to +/// (`platform_wallet_multiple_choice_proposal_edit`). A field left null +/// keeps its value. Platform accepts the edit for two hours after the +/// proposal was created, and refuses one that leaves it with neither a +/// description document nor a url; whether it is open never changes. +#[repr(C)] +pub struct MultipleChoiceProposalEditFFI { + /// The new title, NUL-terminated UTF-8; null keeps it. + pub title: *const c_char, + /// The new description document; null keeps it, unless + /// `remove_description_document` is set. + pub description_document: *const DescriptionDocumentFFI, + /// Removes the description document, leaving the proposal described + /// at its url alone. Setting it together with a non-null + /// `description_document` is refused with `ErrorInvalidParameter`. + pub remove_description_document: bool, + /// The new url, NUL-terminated UTF-8; null keeps it, unless + /// `remove_url` is set. + pub url: *const c_char, + /// Removes the url. Setting it together with a non-null `url` is + /// refused with `ErrorInvalidParameter`. + pub remove_url: bool, +} + +/// An answer to enter for a multiple choice proposal +/// (`platform_wallet_multiple_choice_proposal_enter_choice`). Platform +/// refuses values outside the limits noted here; nothing is checked +/// before. +#[repr(C)] +pub struct ChoiceParamsFFI { + /// The answer, in one line: 1 to 128 characters. NUL-terminated + /// UTF-8, required. + pub title: *const c_char, + /// What voting for the answer means: 1 to 4096 characters. + /// NUL-terminated UTF-8; null for none. + pub description: *const c_char, +} + +/// The description document `description_document` names, `None` when it +/// is null. +/// +/// # Safety +/// `description_document` must be null or point to a +/// `DescriptionDocumentFFI` whose `id` and `contract_id` are null or point +/// to 32 readable bytes and whose `document_type` is null or +/// NUL-terminated. +unsafe fn description_document( + description_document: *const DescriptionDocumentFFI, +) -> Result, PlatformWalletFFIResult> { + let Some(description_document) = description_document.as_ref() else { + return Ok(None); + }; + Ok(Some(DescriptionDocument { + id: read_identifier(description_document.id)?, + contract_id: read_identifier(description_document.contract_id)?, + document_type: required_string( + description_document.document_type, + "description_document.document_type", + )?, + })) +} + +/// `value` as an edit of an optional field: `Some(Some(value))` sets it, +/// `Some(None)` removes it and `None` keeps it. Both at once is refused. +fn set_or_remove( + value: Option, + remove: bool, + field: &str, +) -> Result>, PlatformWalletFFIResult> { + match (value, remove) { + (Some(_), true) => Err(PlatformWalletFFIResult::err( + PlatformWalletFFIResultCode::ErrorInvalidParameter, + format!("{field} and remove_{field} cannot both be set"), + )), + (Some(value), false) => Ok(Some(Some(value))), + (None, true) => Ok(Some(None)), + (None, false) => Ok(None), + } +} + +/// The proposal input `params` holds. +/// +/// # Safety +/// `params` must point to a `MultipleChoiceProposalParamsFFI` whose +/// pointer fields are null or valid as documented on it. +unsafe fn proposal_input( + params: &MultipleChoiceProposalParamsFFI, +) -> Result { + Ok(MultipleChoiceProposalInput { + title: required_string(params.title, "title")?, + description_document: description_document(params.description_document)?, + url: decode_opt_c_str(params.url)?, + open: params.open, + }) +} + +/// The edit `edit` holds. +/// +/// # Safety +/// `edit` must point to a `MultipleChoiceProposalEditFFI` whose pointer +/// fields are null or valid as documented on it. +unsafe fn proposal_edit( + edit: &MultipleChoiceProposalEditFFI, +) -> Result { + Ok(MultipleChoiceProposalEdit { + title: decode_opt_c_str(edit.title)?, + description_document: set_or_remove( + description_document(edit.description_document)?, + edit.remove_description_document, + "description_document", + )?, + url: set_or_remove(decode_opt_c_str(edit.url)?, edit.remove_url, "url")?, + }) +} + +/// The choice input `params` holds for the proposal `proposal_id`. +/// +/// # Safety +/// `params` must point to a `ChoiceParamsFFI` whose string fields are null +/// or NUL-terminated. +unsafe fn choice_input( + proposal_id: Identifier, + params: &ChoiceParamsFFI, +) -> Result { + Ok(ChoiceInput { + proposal_id, + title: required_string(params.title, "title")?, + description: decode_opt_c_str(params.description)?, + }) +} + +/// Write `json` to `*out_document_json`, handing its ownership to the +/// caller. +/// +/// # Safety +/// `out_document_json` must be a valid, writable pointer. +unsafe fn write_document_json( + json: String, + out_document_json: *mut *mut c_char, +) -> Result<(), PlatformWalletFFIResult> { + // A NUL byte inside the JSON would be a serializer bug; refuse it + // rather than panic across the FFI boundary. + *out_document_json = CString::new(json)?.into_raw(); + Ok(()) +} + +/// Create + broadcast a multiple choice proposal of `owner_identity_id` +/// asking what `params` says, signed via the external `signer_handle`. +/// +/// Goes through `IdentityWallet::create_multiple_choice_proposal_with_signer`: +/// rs-sdk builds the proposal; Platform charges the owner the multiple +/// choice proposal processing fee (0.2 Dash, +/// `dash_sdk_multiple_choice_proposal_get_processing_fee`) on top of the +/// fees, which the create does not state. The wallet signs with the +/// owner's first AUTHENTICATION + ECDSA key at a security level the +/// `multipleChoiceProposal` type accepts that the signer holds, broadcasts +/// on the platform-wallet 8 MB worker stack, waits for the confirmed +/// document and keeps the owner's proven balance. A network below protocol +/// version 15 has no decision proposals, which is an error. +/// +/// On success the proposal's 32-byte id is written to `out_proposal_id`, +/// and the confirmed document's canonical JSON (the shape +/// [`platform_wallet_create_document_with_signer`](crate::platform_wallet_create_document_with_signer) +/// returns) to `*out_document_json`; release it with +/// `platform_wallet_string_free`. On any error `*out_document_json` is +/// left null. A refusal by Platform carries its `consensus_code`. +/// +/// # Safety +/// - `owner_identity_id` must point to 32 readable bytes. +/// - `params` must point to a `MultipleChoiceProposalParamsFFI` whose +/// `title` is a NUL-terminated string, whose `url` is null or one, and +/// whose `description_document` is null or points to a +/// `DescriptionDocumentFFI` with 32 readable bytes at `id` and at +/// `contract_id` and a NUL-terminated `document_type`. +/// - `signer_handle` must be a live signer, which the caller keeps owning. +/// - `out_proposal_id` must point to 32 writable bytes and +/// `out_document_json` must be a valid, writable pointer. +#[no_mangle] +pub unsafe extern "C" fn platform_wallet_multiple_choice_proposal_create( + wallet_handle: Handle, + owner_identity_id: *const u8, + params: *const MultipleChoiceProposalParamsFFI, + signer_handle: *mut SignerHandle, + out_proposal_id: *mut u8, + out_document_json: *mut *mut c_char, +) -> PlatformWalletFFIResult { + check_ptr!(params); + check_ptr!(signer_handle); + check_ptr!(out_proposal_id); + check_ptr!(out_document_json); + *out_document_json = ptr::null_mut(); + + let owner_id = unwrap_result_or_return!(read_identifier(owner_identity_id)); + let input = unwrap_result_or_return!(proposal_input(&*params)); + let signer_addr = signer_handle as usize; + + let option = PLATFORM_WALLET_STORAGE.with_item(wallet_handle, |wallet| { + let identity_wallet = wallet.identity().clone(); + block_on_worker(async move { + let signer: &VTableSigner = &*(signer_addr as *const VTableSigner); + let confirmed: Document = identity_wallet + .create_multiple_choice_proposal_with_signer(&owner_id, &input, signer) + .await?; + let json = confirmed_document_to_json(&confirmed)?; + Ok::<_, PlatformWalletError>((confirmed.id(), json)) + }) + }); + let result = unwrap_option_or_return!(option); + let (proposal_id, document_json) = unwrap_result_or_return!(result); + + unwrap_result_or_return!(write_document_json(document_json, out_document_json)); + slice::from_raw_parts_mut(out_proposal_id, 32).copy_from_slice(proposal_id.as_slice()); + PlatformWalletFFIResult::ok() +} + +/// Give the multiple choice proposal `proposal_id` of `owner_identity_id` +/// what `edit` changes, and broadcast the replace, signed via the external +/// `signer_handle`. +/// +/// Goes through `IdentityWallet::edit_multiple_choice_proposal_with_signer`, +/// which reads the proposal once, applies the edit and the revision after +/// the one read (rs-sdk refuses an edit that changes nothing), signs with a +/// key chosen as the create chooses it and puts that document. It never +/// reads the proposal again before the put: if another edit lands in +/// between, Platform refuses this one (`consensus_code` 40106, +/// `InvalidDocumentRevisionError`) rather than overwrite it, and the host +/// reads the proposal again before offering the edit anew. Platform also +/// refuses an edit more than two hours after the proposal was created, and +/// one that leaves it with neither a description document nor a url. +/// +/// On success the confirmed document's canonical JSON, at its new +/// revision, is written to `*out_document_json`; release it with +/// `platform_wallet_string_free`. On any error it is left null. +/// +/// # Errors +/// - `NotFound` when there is no such proposal; +/// - `ErrorInvalidParameter` when the proposal belongs to another +/// identity, the edit changes nothing, `url` and `remove_url` are both +/// set, or `description_document` and `remove_description_document` are +/// both set; +/// - `ErrorInvalidIdentifier` for a `description_document` whose `id` or +/// `contract_id` is null, and `ErrorNullPointer` for one whose +/// `document_type` is; +/// - `ErrorUtf8Conversion` for a string field that is not UTF-8; +/// - a refusal by Platform carries its `consensus_code`. +/// +/// # Safety +/// - `owner_identity_id` and `proposal_id` must each point to 32 readable +/// bytes. +/// - `edit` must point to a `MultipleChoiceProposalEditFFI` whose string +/// fields are null or NUL-terminated and whose `description_document` is +/// null or valid as `platform_wallet_multiple_choice_proposal_create` +/// requires. +/// - `signer_handle` must be a live signer, which the caller keeps owning. +/// - `out_document_json` must be a valid, writable pointer. +#[no_mangle] +pub unsafe extern "C" fn platform_wallet_multiple_choice_proposal_edit( + wallet_handle: Handle, + owner_identity_id: *const u8, + proposal_id: *const u8, + edit: *const MultipleChoiceProposalEditFFI, + signer_handle: *mut SignerHandle, + out_document_json: *mut *mut c_char, +) -> PlatformWalletFFIResult { + check_ptr!(edit); + check_ptr!(signer_handle); + check_ptr!(out_document_json); + *out_document_json = ptr::null_mut(); + + let owner_id = unwrap_result_or_return!(read_identifier(owner_identity_id)); + let proposal_id = unwrap_result_or_return!(read_identifier(proposal_id)); + let edit = unwrap_result_or_return!(proposal_edit(&*edit)); + let signer_addr = signer_handle as usize; + + let option = PLATFORM_WALLET_STORAGE.with_item(wallet_handle, |wallet| { + let identity_wallet = wallet.identity().clone(); + block_on_worker(async move { + let signer: &VTableSigner = &*(signer_addr as *const VTableSigner); + let confirmed: Document = identity_wallet + .edit_multiple_choice_proposal_with_signer(&owner_id, &proposal_id, &edit, signer) + .await?; + confirmed_document_to_json(&confirmed) + }) + }); + let result = unwrap_option_or_return!(option); + let document_json = unwrap_result_or_return!(result); + + unwrap_result_or_return!(write_document_json(document_json, out_document_json)); + PlatformWalletFFIResult::ok() +} + +/// Enter the choice `params` describes, owned by `owner_identity_id`, for +/// the multiple choice proposal `proposal_id`, and broadcast it, signed +/// via the external `signer_handle`. +/// +/// Goes through `IdentityWallet::enter_choice_with_signer`: rs-sdk builds +/// the choice, and its put reads the fund of the contest among the +/// proposal's choices just before it is signed and states it +/// (`dash_sdk_multiple_choice_proposal_get_choice_fund_to_join` reads the +/// same amount), which the owner pays on top of the fees. The first choice +/// opens the vote. Signed, broadcast and kept like +/// `platform_wallet_multiple_choice_proposal_create`. Platform refuses a +/// choice for a proposal that is not open from anyone but its owner, and +/// one entered once the vote's join window closed. A choice is never +/// edited. +/// +/// On success the choice's 32-byte id, the id a masternode vote towards it +/// names, is written to `out_choice_id`, and the confirmed document's +/// canonical JSON to `*out_document_json`; release it with +/// `platform_wallet_string_free`. On any error `*out_document_json` is +/// left null. A refusal by Platform carries its `consensus_code`. +/// +/// # Safety +/// - `owner_identity_id` and `proposal_id` must each point to 32 readable +/// bytes. +/// - `params` must point to a `ChoiceParamsFFI` whose `title` is a +/// NUL-terminated string and whose `description` is null or one. +/// - `signer_handle` must be a live signer, which the caller keeps owning. +/// - `out_choice_id` must point to 32 writable bytes and +/// `out_document_json` must be a valid, writable pointer. +#[no_mangle] +pub unsafe extern "C" fn platform_wallet_multiple_choice_proposal_enter_choice( + wallet_handle: Handle, + owner_identity_id: *const u8, + proposal_id: *const u8, + params: *const ChoiceParamsFFI, + signer_handle: *mut SignerHandle, + out_choice_id: *mut u8, + out_document_json: *mut *mut c_char, +) -> PlatformWalletFFIResult { + check_ptr!(params); + check_ptr!(signer_handle); + check_ptr!(out_choice_id); + check_ptr!(out_document_json); + *out_document_json = ptr::null_mut(); + + let owner_id = unwrap_result_or_return!(read_identifier(owner_identity_id)); + let proposal_id = unwrap_result_or_return!(read_identifier(proposal_id)); + let input = unwrap_result_or_return!(choice_input(proposal_id, &*params)); + let signer_addr = signer_handle as usize; + + let option = PLATFORM_WALLET_STORAGE.with_item(wallet_handle, |wallet| { + let identity_wallet = wallet.identity().clone(); + block_on_worker(async move { + let signer: &VTableSigner = &*(signer_addr as *const VTableSigner); + let confirmed: Document = identity_wallet + .enter_choice_with_signer(&owner_id, &input, signer) + .await?; + let json = confirmed_document_to_json(&confirmed)?; + Ok::<_, PlatformWalletError>((confirmed.id(), json)) + }) + }); + let result = unwrap_option_or_return!(option); + let (choice_id, document_json) = unwrap_result_or_return!(result); + + unwrap_result_or_return!(write_document_json(document_json, out_document_json)); + slice::from_raw_parts_mut(out_choice_id, 32).copy_from_slice(choice_id.as_slice()); + PlatformWalletFFIResult::ok() +} + +#[cfg(test)] +mod tests { + use super::*; + + fn c_string(value: &str) -> CString { + CString::new(value).expect("no NUL") + } + + fn no_edit() -> MultipleChoiceProposalEditFFI { + MultipleChoiceProposalEditFFI { + title: ptr::null(), + description_document: ptr::null(), + remove_description_document: false, + url: ptr::null(), + remove_url: false, + } + } + + const DOCUMENT_ID: [u8; 32] = [5; 32]; + const CONTRACT_ID: [u8; 32] = [6; 32]; + + fn expected_description_document() -> DescriptionDocument { + DescriptionDocument { + id: Identifier::from(DOCUMENT_ID), + contract_id: Identifier::from(CONTRACT_ID), + document_type: "post".to_string(), + } + } + + #[test] + fn should_read_the_proposal_params() { + let title = c_string("Which block size?"); + let url = c_string("https://forum.dash.org/t/block-size"); + let document_type = c_string("post"); + let described = DescriptionDocumentFFI { + id: DOCUMENT_ID.as_ptr(), + contract_id: CONTRACT_ID.as_ptr(), + document_type: document_type.as_ptr(), + }; + let mut params = MultipleChoiceProposalParamsFFI { + title: title.as_ptr(), + description_document: &described, + url: url.as_ptr(), + open: true, + }; + unsafe { + assert_eq!( + proposal_input(¶ms).expect("reads"), + MultipleChoiceProposalInput { + title: "Which block size?".to_string(), + description_document: Some(expected_description_document()), + url: Some("https://forum.dash.org/t/block-size".to_string()), + open: true, + } + ); + params.url = ptr::null(); + params.description_document = ptr::null(); + params.open = false; + let read = proposal_input(¶ms).expect("reads"); + assert_eq!(read.url, None); + assert_eq!(read.description_document, None); + assert!(!read.open); + params.title = ptr::null(); + let refused = proposal_input(¶ms).expect_err("no title"); + assert_eq!(refused.code, PlatformWalletFFIResultCode::ErrorNullPointer); + } + } + + /// A description document is all three of its fields or nothing: one + /// with a null field cannot be read. + #[test] + fn should_refuse_a_description_document_with_a_null_field() { + let document_type = c_string("post"); + let complete = DescriptionDocumentFFI { + id: DOCUMENT_ID.as_ptr(), + contract_id: CONTRACT_ID.as_ptr(), + document_type: document_type.as_ptr(), + }; + unsafe { + for no_id in [ + DescriptionDocumentFFI { + id: ptr::null(), + ..complete + }, + DescriptionDocumentFFI { + contract_id: ptr::null(), + ..complete + }, + ] { + let refused = description_document(&no_id).expect_err("no id"); + assert_eq!( + refused.code, + PlatformWalletFFIResultCode::ErrorInvalidIdentifier + ); + } + let refused = description_document(&DescriptionDocumentFFI { + document_type: ptr::null(), + ..complete + }) + .expect_err("no document type"); + assert_eq!(refused.code, PlatformWalletFFIResultCode::ErrorNullPointer); + } + } + + #[test] + fn should_read_the_edit_and_refuse_a_field_both_set_and_removed() { + let title = c_string("Which block size, then?"); + let url = c_string("https://example.com"); + let document_type = c_string("post"); + let described = DescriptionDocumentFFI { + id: DOCUMENT_ID.as_ptr(), + contract_id: CONTRACT_ID.as_ptr(), + document_type: document_type.as_ptr(), + }; + unsafe { + assert_eq!( + proposal_edit(&no_edit()).expect("reads"), + MultipleChoiceProposalEdit::default() + ); + assert_eq!( + proposal_edit(&MultipleChoiceProposalEditFFI { + title: title.as_ptr(), + description_document: &described, + url: url.as_ptr(), + ..no_edit() + }) + .expect("reads"), + MultipleChoiceProposalEdit { + title: Some("Which block size, then?".to_string()), + description_document: Some(Some(expected_description_document())), + url: Some(Some("https://example.com".to_string())), + } + ); + assert_eq!( + proposal_edit(&MultipleChoiceProposalEditFFI { + remove_description_document: true, + remove_url: true, + ..no_edit() + }) + .expect("reads"), + MultipleChoiceProposalEdit { + title: None, + description_document: Some(None), + url: Some(None), + } + ); + for contradictory in [ + MultipleChoiceProposalEditFFI { + url: url.as_ptr(), + remove_url: true, + ..no_edit() + }, + MultipleChoiceProposalEditFFI { + description_document: &described, + remove_description_document: true, + ..no_edit() + }, + ] { + let refused = proposal_edit(&contradictory).expect_err("contradictory"); + assert_eq!( + refused.code, + PlatformWalletFFIResultCode::ErrorInvalidParameter + ); + } + } + } + + #[test] + fn should_read_the_choice_params() { + let proposal_id = Identifier::from([7; 32]); + let title = c_string("Double it"); + let description = c_string("Twice the size it is today."); + let mut params = ChoiceParamsFFI { + title: title.as_ptr(), + description: description.as_ptr(), + }; + unsafe { + assert_eq!( + choice_input(proposal_id, ¶ms).expect("reads"), + ChoiceInput { + proposal_id, + title: "Double it".to_string(), + description: Some("Twice the size it is today.".to_string()), + } + ); + params.description = ptr::null(); + assert_eq!( + choice_input(proposal_id, ¶ms) + .expect("reads") + .description, + None + ); + params.title = ptr::null(); + let refused = choice_input(proposal_id, ¶ms).expect_err("no title"); + assert_eq!(refused.code, PlatformWalletFFIResultCode::ErrorNullPointer); + } + } + + #[test] + fn should_refuse_a_string_that_is_not_utf8() { + let not_utf8 = CString::new(vec![0xff, 0xfe]).expect("no NUL"); + let proposal_id = Identifier::from([7; 32]); + unsafe { + let refused = proposal_input(&MultipleChoiceProposalParamsFFI { + title: not_utf8.as_ptr(), + description_document: ptr::null(), + url: ptr::null(), + open: true, + }) + .expect_err("not UTF-8"); + assert_eq!( + refused.code, + PlatformWalletFFIResultCode::ErrorUtf8Conversion + ); + let not_utf8_type = DescriptionDocumentFFI { + id: DOCUMENT_ID.as_ptr(), + contract_id: CONTRACT_ID.as_ptr(), + document_type: not_utf8.as_ptr(), + }; + for edit in [ + MultipleChoiceProposalEditFFI { + title: not_utf8.as_ptr(), + ..no_edit() + }, + MultipleChoiceProposalEditFFI { + url: not_utf8.as_ptr(), + ..no_edit() + }, + MultipleChoiceProposalEditFFI { + description_document: ¬_utf8_type, + ..no_edit() + }, + ] { + let refused = proposal_edit(&edit).expect_err("not UTF-8"); + assert_eq!( + refused.code, + PlatformWalletFFIResultCode::ErrorUtf8Conversion + ); + } + for params in [ + ChoiceParamsFFI { + title: not_utf8.as_ptr(), + description: ptr::null(), + }, + ChoiceParamsFFI { + title: not_utf8.as_ptr(), + description: not_utf8.as_ptr(), + }, + ] { + let refused = choice_input(proposal_id, ¶ms).expect_err("not UTF-8"); + assert_eq!( + refused.code, + PlatformWalletFFIResultCode::ErrorUtf8Conversion + ); + } + } + } + + /// Every pointer is checked before the wallet is looked up, and the + /// JSON out-param is left null on the way out. + #[test] + fn should_refuse_null_pointers() { + let id = [0u8; 32]; + let mut out_id = [0u8; 32]; + let mut out_json: *mut c_char = ptr::null_mut(); + let title = c_string("Which block size?"); + let url = c_string("https://forum.dash.org/t/block-size"); + let params = MultipleChoiceProposalParamsFFI { + title: title.as_ptr(), + description_document: ptr::null(), + url: url.as_ptr(), + open: true, + }; + let edit = no_edit(); + let choice = ChoiceParamsFFI { + title: title.as_ptr(), + description: ptr::null(), + }; + // A dangling but non-null signer: every call below returns at a + // pointer check before the signer is read. + let signer = ptr::NonNull::::dangling().as_ptr(); + unsafe { + for result in [ + platform_wallet_multiple_choice_proposal_create( + 0, + id.as_ptr(), + ptr::null(), + signer, + out_id.as_mut_ptr(), + &mut out_json, + ), + platform_wallet_multiple_choice_proposal_create( + 0, + id.as_ptr(), + ¶ms, + ptr::null_mut(), + out_id.as_mut_ptr(), + &mut out_json, + ), + platform_wallet_multiple_choice_proposal_create( + 0, + id.as_ptr(), + ¶ms, + signer, + ptr::null_mut(), + &mut out_json, + ), + platform_wallet_multiple_choice_proposal_create( + 0, + id.as_ptr(), + ¶ms, + signer, + out_id.as_mut_ptr(), + ptr::null_mut(), + ), + platform_wallet_multiple_choice_proposal_edit( + 0, + id.as_ptr(), + id.as_ptr(), + ptr::null(), + signer, + &mut out_json, + ), + platform_wallet_multiple_choice_proposal_edit( + 0, + id.as_ptr(), + id.as_ptr(), + &edit, + ptr::null_mut(), + &mut out_json, + ), + platform_wallet_multiple_choice_proposal_edit( + 0, + id.as_ptr(), + id.as_ptr(), + &edit, + signer, + ptr::null_mut(), + ), + platform_wallet_multiple_choice_proposal_enter_choice( + 0, + id.as_ptr(), + id.as_ptr(), + ptr::null(), + signer, + out_id.as_mut_ptr(), + &mut out_json, + ), + platform_wallet_multiple_choice_proposal_enter_choice( + 0, + id.as_ptr(), + id.as_ptr(), + &choice, + ptr::null_mut(), + out_id.as_mut_ptr(), + &mut out_json, + ), + platform_wallet_multiple_choice_proposal_enter_choice( + 0, + id.as_ptr(), + id.as_ptr(), + &choice, + signer, + ptr::null_mut(), + &mut out_json, + ), + platform_wallet_multiple_choice_proposal_enter_choice( + 0, + id.as_ptr(), + id.as_ptr(), + &choice, + signer, + out_id.as_mut_ptr(), + ptr::null_mut(), + ), + ] { + assert_eq!(result.code, PlatformWalletFFIResultCode::ErrorNullPointer); + } + assert!(out_json.is_null()); + } + } + + /// An argument the wallet cannot read is refused before the wallet is + /// looked up, and the JSON out-param is left null. + #[test] + fn should_refuse_unreadable_arguments_before_the_wallet_is_looked_up() { + let id = [0u8; 32]; + let mut out_id = [0u8; 32]; + let mut out_json: *mut c_char = ptr::null_mut(); + let no_title = MultipleChoiceProposalParamsFFI { + title: ptr::null(), + description_document: ptr::null(), + url: ptr::null(), + open: true, + }; + let url = c_string("https://example.com"); + let contradictory = MultipleChoiceProposalEditFFI { + url: url.as_ptr(), + remove_url: true, + ..no_edit() + }; + let untitled_choice = ChoiceParamsFFI { + title: ptr::null(), + description: ptr::null(), + }; + let signer = ptr::NonNull::::dangling().as_ptr(); + unsafe { + let created = platform_wallet_multiple_choice_proposal_create( + 0, + id.as_ptr(), + &no_title, + signer, + out_id.as_mut_ptr(), + &mut out_json, + ); + assert_eq!(created.code, PlatformWalletFFIResultCode::ErrorNullPointer); + let edited = platform_wallet_multiple_choice_proposal_edit( + 0, + id.as_ptr(), + id.as_ptr(), + &contradictory, + signer, + &mut out_json, + ); + assert_eq!( + edited.code, + PlatformWalletFFIResultCode::ErrorInvalidParameter + ); + let entered = platform_wallet_multiple_choice_proposal_enter_choice( + 0, + id.as_ptr(), + id.as_ptr(), + &untitled_choice, + signer, + out_id.as_mut_ptr(), + &mut out_json, + ); + assert_eq!(entered.code, PlatformWalletFFIResultCode::ErrorNullPointer); + assert!(out_json.is_null()); + } + } +} diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/decision_proposal.rs b/packages/rs-platform-wallet/src/wallet/identity/network/decision_proposal.rs index cb6b3d61bc4..9308184ba60 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/decision_proposal.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/decision_proposal.rs @@ -59,7 +59,9 @@ impl IdentityWallet { where S: Signer + Send + Sync, { - let document_type = self.decision_proposal_document_type().await?; + let document_type = self + .decision_proposals_document_type(PROPOSAL_DOCUMENT_TYPE_NAME) + .await?; let DecisionProposalDocument { document, entropy } = self .sdk .build_decision_proposal(*owner_identity_id, input) @@ -110,7 +112,9 @@ impl IdentityWallet { where S: Signer + Send + Sync, { - let document_type = self.decision_proposal_document_type().await?; + let document_type = self + .decision_proposals_document_type(PROPOSAL_DOCUMENT_TYPE_NAME) + .await?; let read = self.sdk.fetch_decision_proposal(*proposal_id).await?; let replacement = decision_proposal_replacement(owner_identity_id, proposal_id, read, edit)?; @@ -129,15 +133,18 @@ impl IdentityWallet { .await?) } - /// The `proposal` document type of the decision proposals contract, - /// which rs-sdk resolves (refusing a network below protocol version - /// 15). The contract is registered for the proof check that follows - /// the put. - async fn decision_proposal_document_type(&self) -> Result { + /// The document type `document_type_name` of the decision proposals + /// contract, which rs-sdk resolves (refusing a network below protocol + /// version 15). The contract is registered for the proof check that + /// follows the put. + pub(super) async fn decision_proposals_document_type( + &self, + document_type_name: &str, + ) -> Result { let contract = self.sdk.fetch_decision_proposals_contract().await?; self.register_contract_for_proof_verification(&contract); contract - .document_type_cloned_for_name(PROPOSAL_DOCUMENT_TYPE_NAME) + .document_type_cloned_for_name(document_type_name) .map_err(|e| PlatformWalletError::Sdk(dash_sdk::Error::Protocol(e.into()))) } } @@ -176,7 +183,7 @@ fn decision_proposal_replacement( } #[cfg(test)] -mod tests { +pub(super) mod tests { use super::super::signing_key::tests::{ available, identity, lock_checking_signer, wallet_with_signing_keys_on, }; @@ -209,15 +216,15 @@ mod tests { const CREATED_AT: u64 = 1_700_000_000_000; /// The identity contract nonce Platform reports for the owner. - const STORED_NONCE: u64 = 4; + pub(crate) const STORED_NONCE: u64 = 4; const NEW_TITLE: &str = "Raise the block size to 4 MB?"; /// The owner identity `wallet_with_signing_keys_on` holds. - fn owner() -> Identifier { + pub(crate) fn owner() -> Identifier { Identifier::default() } - fn proposals_contract() -> Arc { + pub(crate) fn proposals_contract() -> Arc { Arc::new( load_system_data_contract( SystemDataContract::DecisionProposals, @@ -264,7 +271,7 @@ mod tests { /// Serves the bundled decision proposals contract (nothing else), the /// way a host's context provider does, so rs-sdk resolves it without a /// network fetch or a dump directory. - struct ProposalsContractProvider(Arc); + pub(crate) struct ProposalsContractProvider(pub(crate) Arc); impl dash_sdk::platform::ContextProvider for ProposalsContractProvider { fn get_data_contract( @@ -313,7 +320,7 @@ mod tests { /// A mock SDK at the latest protocol version that resolves the /// decision proposals contract. A request without an expectation /// fails. - fn proposals_sdk() -> dash_sdk::Sdk { + pub(crate) fn proposals_sdk() -> dash_sdk::Sdk { dash_sdk::SdkBuilder::new_mock() .with_version(PlatformVersion::latest()) .with_context_provider(ProposalsContractProvider(proposals_contract())) @@ -344,7 +351,7 @@ mod tests { /// Signs with a fixed signature, so the transition it signs is known. #[derive(Debug)] - struct FixedSignatureSigner; + pub(crate) struct FixedSignatureSigner; #[async_trait] impl Signer for FixedSignatureSigner { diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/mod.rs b/packages/rs-platform-wallet/src/wallet/identity/network/mod.rs index ac7eba762cd..5544717563a 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/mod.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/mod.rs @@ -48,6 +48,7 @@ mod identity_handle; mod key_limits; mod key_selection; mod loading; +mod multiple_choice_proposal; mod register_from_addresses; mod registration; mod state_transition_summary; diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/multiple_choice_proposal.rs b/packages/rs-platform-wallet/src/wallet/identity/network/multiple_choice_proposal.rs new file mode 100644 index 00000000000..e0099e4ffb7 --- /dev/null +++ b/packages/rs-platform-wallet/src/wallet/identity/network/multiple_choice_proposal.rs @@ -0,0 +1,664 @@ +//! Multiple choice proposal create and edit, and entering a choice, on +//! `IdentityWallet` (protocol version 15). +//! +//! rs-sdk decides what a multiple choice proposal and a choice are +//! (`dash_sdk::platform::decision_proposals::multiple_choice`): the +//! properties they are created with, refusing an edit that changes +//! nothing, and the revision an edit moves to. The put of a choice states +//! the fund of the contest it joins, read just before it is signed. These +//! operations orchestrate: they resolve the contract, read the proposal, +//! select the signing key, put the document and keep the owner's proven +//! balance, through the steps the yes/no proposal create in +//! `decision_proposal.rs` takes. +//! +//! An edit reads the proposal once and puts that document at the revision +//! after the one it read, exactly as a yes/no proposal edit does: when +//! another edit lands in between, Platform refuses this one +//! (`InvalidDocumentRevisionError`, 40106) instead of letting it overwrite +//! what it never saw. A choice is never edited. + +use dash_sdk::platform::decision_proposals::multiple_choice::{ + build_multiple_choice_proposal_edit, ChoiceInput, MultipleChoiceProposalEdit, + MultipleChoiceProposalInput, +}; +use dash_sdk::platform::decision_proposals::DecisionProposalDocument; +use dpp::decision_proposal::multiple_choice::CHOICE_DOCUMENT_TYPE_NAME; +use dpp::decision_proposal::{ + DECISION_PROPOSALS_CONTRACT_ID, MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, +}; +use dpp::document::{Document, DocumentV0Getters}; +use dpp::identity::signer::Signer; +use dpp::identity::IdentityPublicKey; +use dpp::prelude::Identifier; + +use crate::error::PlatformWalletError; + +use super::*; + +impl IdentityWallet { + /// Create a multiple choice proposal of `owner_identity_id` asking + /// what `input` says, and return it as Platform stored it. + /// + /// rs-sdk builds the proposal (`Sdk::build_multiple_choice_proposal`). + /// Platform charges the owner the multiple choice proposal processing + /// fee (0.2 Dash, `Sdk::multiple_choice_proposal_processing_fee`) on + /// top of the fees; the create does not state it. The transition is + /// signed with the owner's first AUTHENTICATION + ECDSA key at a + /// security level the `multipleChoiceProposal` type accepts that + /// `signer` can sign with, and the owner's balance the proof carries + /// is kept. Platform refuses a proposal that gives neither a + /// description document nor a url. The proposal's id is the id of the + /// returned document. + /// + /// A network below protocol version 15 has no decision proposals + /// contract, which is an error. SDK and Platform failures, a refusal + /// included, arrive as [`PlatformWalletError::Sdk`]. + pub async fn create_multiple_choice_proposal_with_signer( + &self, + owner_identity_id: &Identifier, + input: &MultipleChoiceProposalInput, + signer: &S, + ) -> Result + where + S: Signer + Send + Sync, + { + let document_type = self + .decision_proposals_document_type(MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME) + .await?; + let DecisionProposalDocument { document, entropy } = self + .sdk + .build_multiple_choice_proposal(*owner_identity_id, input) + .await?; + let signing_key = self + .select_document_signing_key(owner_identity_id, &document_type, signer) + .await?; + Ok(self + .put_document_keeping_owner_balance( + &document, + document_type, + Some(entropy.to_buffer()), + signing_key, + signer, + None, + ) + .await?) + } + + /// Give the multiple choice proposal `proposal_id` of + /// `owner_identity_id` what `edit` changes, and return it as Platform + /// stored it. + /// + /// Reads the proposal once, applies the edit with rs-sdk's + /// `build_multiple_choice_proposal_edit` (which refuses an edit that + /// changes nothing and moves to the revision after the one read) and + /// puts that document as a replace, signed and kept like + /// [`Self::create_multiple_choice_proposal_with_signer`]. The put + /// carries the revision after the one read: if another edit lands in + /// between, Platform refuses this one (`InvalidDocumentRevisionError`, + /// 40106) rather than overwrite it, and the caller reads the proposal + /// again. Platform also refuses an edit more than two hours after the + /// proposal was created, and one that leaves it with neither a + /// description document nor a url. + /// + /// # Errors + /// * [`PlatformWalletError::DecisionProposalNotFound`] when there is + /// no such proposal; + /// * [`PlatformWalletError::InvalidParameter`] when the proposal + /// belongs to another identity, or the edit changes nothing; + /// * [`PlatformWalletError::Sdk`] for SDK and Platform failures, + /// Platform's refusals included. + pub async fn edit_multiple_choice_proposal_with_signer( + &self, + owner_identity_id: &Identifier, + proposal_id: &Identifier, + edit: &MultipleChoiceProposalEdit, + signer: &S, + ) -> Result + where + S: Signer + Send + Sync, + { + let document_type = self + .decision_proposals_document_type(MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME) + .await?; + let read = self + .sdk + .fetch_multiple_choice_proposal(*proposal_id) + .await?; + let replacement = + multiple_choice_proposal_replacement(owner_identity_id, proposal_id, read, edit)?; + let signing_key = self + .select_document_signing_key(owner_identity_id, &document_type, signer) + .await?; + Ok(self + .put_document_keeping_owner_balance( + &replacement, + document_type, + None, + signing_key, + signer, + None, + ) + .await?) + } + + /// Enter the choice `input` describes, owned by `owner_identity_id`, + /// for the multiple choice proposal it names, and return it as + /// Platform stored it. + /// + /// rs-sdk builds the choice (`Sdk::build_choice`), and its put reads + /// the fund of the contest among the proposal's choices just before + /// it is signed and states it (`Sdk::choice_fund_to_join`, doubled + /// once the vote holds 250 choices and again for every 50 more); the + /// owner pays it on top of the fees. The first choice opens the vote. + /// The transition is signed and the owner's proven balance kept like + /// [`Self::create_multiple_choice_proposal_with_signer`]. Platform + /// refuses a choice for a proposal that is not open from anyone but + /// its owner, and one entered once the vote's join window closed. The + /// choice's id, which a masternode vote towards it names, is the id of + /// the returned document. + /// + /// A network below protocol version 15 has no decision proposals + /// contract, which is an error. SDK and Platform failures, a refusal + /// included, arrive as [`PlatformWalletError::Sdk`]. + pub async fn enter_choice_with_signer( + &self, + owner_identity_id: &Identifier, + input: &ChoiceInput, + signer: &S, + ) -> Result + where + S: Signer + Send + Sync, + { + let document_type = self + .decision_proposals_document_type(CHOICE_DOCUMENT_TYPE_NAME) + .await?; + let DecisionProposalDocument { document, entropy } = + self.sdk.build_choice(*owner_identity_id, input).await?; + let signing_key = self + .select_document_signing_key(owner_identity_id, &document_type, signer) + .await?; + Ok(self + .put_document_keeping_owner_balance( + &document, + document_type, + Some(entropy.to_buffer()), + signing_key, + signer, + None, + ) + .await?) + } +} + +/// The document an edit of the multiple choice proposal `proposal_id` +/// puts: `read`, the proposal as read once for this edit, with what `edit` +/// changes and the revision after the one read. A proposal that is not +/// there, or that belongs to an identity other than `owner_identity_id`, +/// is refused. +fn multiple_choice_proposal_replacement( + owner_identity_id: &Identifier, + proposal_id: &Identifier, + read: Option, + edit: &MultipleChoiceProposalEdit, +) -> Result { + let proposal = read.ok_or(PlatformWalletError::DecisionProposalNotFound { + proposal_id: *proposal_id, + })?; + if proposal.owner_id() != *owner_identity_id { + return Err(PlatformWalletError::InvalidParameter(format!( + "multiple choice proposal {proposal_id} belongs to identity {}, not to \ + {owner_identity_id}", + proposal.owner_id() + ))); + } + build_multiple_choice_proposal_edit( + &DECISION_PROPOSALS_CONTRACT_ID, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + &proposal, + edit, + ) + .map_err(|error| match error { + // rs-sdk refuses the edit itself (one that changes nothing) with + // its own text; anything else keeps its SDK error. + dash_sdk::Error::Generic(message) => PlatformWalletError::InvalidParameter(message), + other => PlatformWalletError::Sdk(other), + }) +} + +#[cfg(test)] +mod tests { + use super::super::decision_proposal::tests::{ + owner, proposals_contract, proposals_sdk, FixedSignatureSigner, STORED_NONCE, + }; + use super::super::signing_key::tests::{ + available, identity, lock_checking_signer, wallet_with_signing_keys_on, + }; + use super::*; + use crate::error::SIGNER_KEY_UNAVAILABLE_PREFIX; + use crate::wallet::persister::NoPlatformPersistence; + use dash_sdk::dapi_grpc::platform::v0::{ + GetContestedResourceVoteStateRequest, GetDocumentsRequest, + }; + use dash_sdk::drive::config::DEFAULT_QUERY_LIMIT; + use dash_sdk::drive::query::vote_poll_vote_state_query::{ + ContestedDocumentVotePollDriveQuery, ContestedDocumentVotePollDriveQueryResultType, + }; + use dash_sdk::platform::decision_proposals::multiple_choice::{ + build_multiple_choice_proposal_document, multiple_choice_proposal_vote_poll, + DescriptionDocument, + }; + use dash_sdk::platform::transition::broadcast_request::BroadcastRequestForStateTransition; + use dash_sdk::platform::{DocumentQuery, Query}; + use dash_sdk::query_types::{Contenders, IdentityContractNonceFetcher}; + use dpp::data_contract::accessors::v0::DataContractV0Getters; + use dpp::decision_proposal::multiple_choice::proposal_properties; + use dpp::document::{DocumentV0Setters, INITIAL_REVISION}; + use dpp::identity::accessors::IdentityGettersV0; + use dpp::identity::{KeyType, Purpose, SecurityLevel}; + use dpp::platform_value::{Bytes32, Value}; + use dpp::state_transition::batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; + use dpp::state_transition::batch_transition::BatchTransition; + use dpp::version::PlatformVersion; + use dpp::voting::contender_structs::ContenderWithSerializedDocument; + use dpp::ProtocolError; + use std::sync::Arc; + + const CREATED_AT: u64 = 1_700_000_000_000; + const NEW_URL: &str = "https://forum.dash.org/t/block-size-4mb"; + + fn description_document() -> DescriptionDocument { + DescriptionDocument { + id: Identifier::from([5; 32]), + contract_id: Identifier::from([6; 32]), + document_type: "post".to_string(), + } + } + + fn input() -> MultipleChoiceProposalInput { + MultipleChoiceProposalInput { + title: "Which block size?".to_string(), + description_document: Some(description_document()), + url: Some("https://forum.dash.org/t/block-size".to_string()), + open: true, + } + } + + fn choice_input() -> ChoiceInput { + ChoiceInput { + proposal_id: Identifier::from([7; 32]), + title: "Double it".to_string(), + description: Some("Twice the size it is today.".to_string()), + } + } + + /// A multiple choice proposal of `owner_id` built by rs-sdk, as + /// Platform stores it at its first revision. + fn stored_proposal(owner_id: Identifier) -> Document { + let mut document = build_multiple_choice_proposal_document( + &proposals_contract(), + owner_id, + &input(), + Bytes32::new([9; 32]), + ) + .expect("builds") + .document; + document.set_created_at(Some(CREATED_AT)); + document.set_updated_at(Some(CREATED_AT)); + document + } + + /// Points the proposal at its url alone, with a new url. + fn readdress() -> MultipleChoiceProposalEdit { + MultipleChoiceProposalEdit { + description_document: Some(None), + url: Some(Some(NEW_URL.to_string())), + ..Default::default() + } + } + + /// The query rs-sdk reads the proposal `proposal_id` with. + fn proposal_query(proposal_id: Identifier) -> DocumentQuery { + DocumentQuery::new( + proposals_contract(), + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, + ) + .expect("the multiple choice proposal type") + .with_document_id(&proposal_id) + } + + /// [`proposals_sdk`] answering a read of the proposal `proposal_id` + /// with `stored`. + async fn sdk_storing(proposal_id: Identifier, stored: Option) -> dash_sdk::Sdk { + let mut sdk = proposals_sdk(); + sdk.mock() + .expect_fetch(proposal_query(proposal_id), stored) + .await + .expect("expects the proposal read"); + sdk + } + + /// Times the proposal `proposal_id` was read through `sdk`. + async fn times_read(sdk: &mut dash_sdk::Sdk, proposal_id: Identifier) -> usize { + let request: GetDocumentsRequest = Query::::query( + &proposal_query(proposal_id), + &sdk.query_settings(), + ) + .expect("encodes"); + sdk.mock().request_count(&request).await + } + + /// The query the put of a choice for `proposal_id` counts the choices + /// already entered with, to price the fund it states. + fn contest_fund_query(proposal_id: Identifier) -> ContestedDocumentVotePollDriveQuery { + ContestedDocumentVotePollDriveQuery { + vote_poll: multiple_choice_proposal_vote_poll(proposal_id), + result_type: ContestedDocumentVotePollDriveQueryResultType::VoteTally, + offset: None, + limit: Some(DEFAULT_QUERY_LIMIT), + start_at: None, + allow_include_locked_and_abstaining_vote_tally: false, + } + } + + /// The owner's first key, the one the wallet signs with. + fn owners_first_key() -> IdentityPublicKey { + identity( + Purpose::AUTHENTICATION, + SecurityLevel::CRITICAL, + KeyType::ECDSA_SECP256K1, + ) + .public_keys() + .get(&1) + .expect("the owner's first key") + .clone() + } + + #[test] + fn should_move_the_proposal_read_to_its_next_revision_with_only_the_edited_fields() { + let read = stored_proposal(owner()); + let replacement = multiple_choice_proposal_replacement( + &owner(), + &read.id(), + Some(read.clone()), + &readdress(), + ) + .expect("edits"); + + assert_eq!(replacement.id(), read.id()); + assert_eq!(replacement.owner_id(), owner()); + assert_eq!(replacement.revision(), Some(INITIAL_REVISION + 1)); + assert_eq!(replacement.created_at(), Some(CREATED_AT)); + let mut expected = read.properties().clone(); + for property in [ + proposal_properties::DESCRIPTION_ID, + proposal_properties::DESCRIPTION_CONTRACT_ID, + proposal_properties::DESCRIPTION_DOCUMENT_TYPE, + ] { + expected.remove(property); + } + expected.insert( + proposal_properties::URL.to_string(), + Value::Text(NEW_URL.to_string()), + ); + assert_eq!(replacement.properties(), &expected); + } + + #[test] + fn should_refuse_an_edit_that_changes_nothing() { + let read = stored_proposal(owner()); + let error = multiple_choice_proposal_replacement( + &owner(), + &read.id(), + Some(read.clone()), + &MultipleChoiceProposalEdit { + title: Some(input().title), + description_document: Some(Some(description_document())), + url: Some(input().url), + }, + ) + .expect_err("changes nothing"); + assert!( + matches!(error, PlatformWalletError::InvalidParameter(ref message) + if message.contains("changes nothing")), + "{error:?}" + ); + } + + /// The edit reads the proposal once, then puts exactly that document + /// at the revision after the one read: the broadcast the put sends is + /// the replace built from it, signed with the owner's first eligible + /// key at the next identity contract nonce. The mock answers no + /// broadcast, so the put fails after sending it. + #[tokio::test] + async fn should_put_the_proposal_read_once_at_the_revision_after_it() { + let read = stored_proposal(owner()); + let proposal_id = read.id(); + let mut sdk = sdk_storing(proposal_id, Some(read.clone())).await; + sdk.mock() + .expect_fetch( + (owner(), DECISION_PROPOSALS_CONTRACT_ID), + Some(IdentityContractNonceFetcher(STORED_NONCE)), + ) + .await + .expect("expects the nonce read"); + let wallet = + wallet_with_signing_keys_on(sdk.clone(), Arc::new(NoPlatformPersistence)).await; + + let error = wallet + .identity() + .edit_multiple_choice_proposal_with_signer( + &owner(), + &proposal_id, + &readdress(), + &FixedSignatureSigner, + ) + .await + .expect_err("the mock answers no broadcast"); + assert!(matches!(error, PlatformWalletError::Sdk(_)), "{error:?}"); + assert_eq!(times_read(&mut sdk, proposal_id).await, 1); + + // The proposal as the read returned it: the mock answers with the + // document re-encoded, so its values come back as Platform returns + // them rather than as the builder made them. + let returned = sdk + .fetch_multiple_choice_proposal(proposal_id) + .await + .expect("reads") + .expect("the stored proposal"); + let contract = proposals_contract(); + let document_type = contract + .document_type_for_name(MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME) + .expect("the multiple choice proposal type"); + let mut put_document = returned; + for property in [ + proposal_properties::DESCRIPTION_ID, + proposal_properties::DESCRIPTION_CONTRACT_ID, + proposal_properties::DESCRIPTION_DOCUMENT_TYPE, + ] { + put_document.remove(property); + } + put_document.set(proposal_properties::URL, Value::Text(NEW_URL.to_string())); + put_document.set_revision(Some(INITIAL_REVISION + 1)); + let replace = BatchTransition::new_document_replacement_transition_from_document( + put_document, + document_type, + &owners_first_key(), + STORED_NONCE + 1, + 0, + None, + &FixedSignatureSigner, + PlatformVersion::latest(), + None, + ) + .await + .expect("the replace"); + let broadcast = replace + .broadcast_request_for_state_transition() + .expect("serializes"); + assert!( + sdk.mock().request_count(&broadcast).await > 0, + "the put must broadcast the replace of the proposal as read, at revision {}", + INITIAL_REVISION + 1 + ); + } + + #[tokio::test] + async fn should_refuse_to_edit_a_proposal_that_does_not_exist() { + let proposal_id = Identifier::from([4; 32]); + let mut sdk = sdk_storing(proposal_id, None).await; + let wallet = + wallet_with_signing_keys_on(sdk.clone(), Arc::new(NoPlatformPersistence)).await; + + let error = wallet + .identity() + .edit_multiple_choice_proposal_with_signer( + &owner(), + &proposal_id, + &readdress(), + &available(&[]), + ) + .await + .expect_err("no such proposal"); + assert!( + matches!(error, PlatformWalletError::DecisionProposalNotFound { proposal_id: id } + if id == proposal_id), + "{error:?}" + ); + assert_eq!(times_read(&mut sdk, proposal_id).await, 1); + } + + #[tokio::test] + async fn should_refuse_to_edit_a_proposal_of_another_identity() { + let read = stored_proposal(Identifier::from([3; 32])); + let proposal_id = read.id(); + let sdk = sdk_storing(proposal_id, Some(read)).await; + let wallet = wallet_with_signing_keys_on(sdk, Arc::new(NoPlatformPersistence)).await; + + let error = wallet + .identity() + .edit_multiple_choice_proposal_with_signer( + &owner(), + &proposal_id, + &readdress(), + &available(&[]), + ) + .await + .expect_err("another identity's proposal"); + assert!( + matches!(error, PlatformWalletError::InvalidParameter(ref message) + if message.contains("belongs to identity")), + "{error:?}" + ); + } + + /// The create builds the proposal through rs-sdk, then asks the signer + /// for a key with the wallet manager lock released: a signer that holds + /// no key keeps the structured key-unavailable failure, and an owner + /// the wallet does not hold is refused. + #[tokio::test] + async fn should_create_only_for_an_owner_with_a_key_the_signer_holds() { + let wallet = + wallet_with_signing_keys_on(proposals_sdk(), Arc::new(NoPlatformPersistence)).await; + let signer = lock_checking_signer(wallet.identity()); + + let error = wallet + .identity() + .create_multiple_choice_proposal_with_signer(&owner(), &input(), &signer) + .await + .expect_err("no key available"); + assert!( + matches!(error, PlatformWalletError::Sdk(dash_sdk::Error::Protocol(ProtocolError::Generic(ref message))) + if message.starts_with(SIGNER_KEY_UNAVAILABLE_PREFIX)), + "{error:?}" + ); + + let stranger = Identifier::from([5; 32]); + let error = wallet + .identity() + .create_multiple_choice_proposal_with_signer(&stranger, &input(), &available(&[1])) + .await + .expect_err("not an identity of this wallet"); + assert!( + matches!(error, PlatformWalletError::IdentityNotFound(id) if id == stranger), + "{error:?}" + ); + } + + /// Entering a choice selects its key as a proposal create does: a + /// signer that holds no key keeps the structured key-unavailable + /// failure, and an owner the wallet does not hold is refused. + #[tokio::test] + async fn should_enter_a_choice_only_for_an_owner_with_a_key_the_signer_holds() { + let wallet = + wallet_with_signing_keys_on(proposals_sdk(), Arc::new(NoPlatformPersistence)).await; + let signer = lock_checking_signer(wallet.identity()); + + let error = wallet + .identity() + .enter_choice_with_signer(&owner(), &choice_input(), &signer) + .await + .expect_err("no key available"); + assert!( + matches!(error, PlatformWalletError::Sdk(dash_sdk::Error::Protocol(ProtocolError::Generic(ref message))) + if message.starts_with(SIGNER_KEY_UNAVAILABLE_PREFIX)), + "{error:?}" + ); + + let stranger = Identifier::from([5; 32]); + let error = wallet + .identity() + .enter_choice_with_signer(&stranger, &choice_input(), &available(&[1])) + .await + .expect_err("not an identity of this wallet"); + assert!( + matches!(error, PlatformWalletError::IdentityNotFound(id) if id == stranger), + "{error:?}" + ); + } + + /// The put of a choice counts the choices the vote already holds, to + /// state the fund of the contest, before it reserves the identity + /// contract nonce and broadcasts. The mock holds no choice yet and + /// answers no broadcast, so the put fails after sending it. + #[tokio::test] + async fn should_read_the_contest_fund_before_putting_a_choice() { + let proposal_id = choice_input().proposal_id; + let mut sdk = proposals_sdk(); + sdk.mock() + .expect_fetch_many::<_, ContenderWithSerializedDocument, _, Contenders>( + contest_fund_query(proposal_id), + Some(Contenders::default()), + ) + .await + .expect("expects the contest read"); + sdk.mock() + .expect_fetch( + (owner(), DECISION_PROPOSALS_CONTRACT_ID), + Some(IdentityContractNonceFetcher(STORED_NONCE)), + ) + .await + .expect("expects the nonce read"); + let wallet = + wallet_with_signing_keys_on(sdk.clone(), Arc::new(NoPlatformPersistence)).await; + + let error = wallet + .identity() + .enter_choice_with_signer(&owner(), &choice_input(), &FixedSignatureSigner) + .await + .expect_err("the mock answers no broadcast"); + // The put got as far as the broadcast, which the mock does not answer + assert!( + matches!(error, PlatformWalletError::Sdk(_)) + && format!("{error:?}").contains("BroadcastStateTransitionRequest"), + "{error:?}" + ); + + let contest_read: GetContestedResourceVoteStateRequest = + Query::::query( + &contest_fund_query(proposal_id), + &sdk.query_settings(), + ) + .expect("encodes"); + assert_eq!(sdk.mock().request_count(&contest_read).await, 1); + } +} diff --git a/packages/rs-sdk-ffi/src/decision_proposal/json.rs b/packages/rs-sdk-ffi/src/decision_proposal/json.rs index 84c7f10b88e..30fcb853251 100644 --- a/packages/rs-sdk-ffi/src/decision_proposal/json.rs +++ b/packages/rs-sdk-ffi/src/decision_proposal/json.rs @@ -67,7 +67,7 @@ pub(super) fn proposals_json(documents: Documents) -> Result JsonValue { +pub(super) fn block_json(block: &BlockInfo) -> JsonValue { json!({ "height": block.height, "coreHeight": block.core_height, diff --git a/packages/rs-sdk-ffi/src/decision_proposal/mod.rs b/packages/rs-sdk-ffi/src/decision_proposal/mod.rs index 5f7491b5843..877ef814515 100644 --- a/packages/rs-sdk-ffi/src/decision_proposal/mod.rs +++ b/packages/rs-sdk-ffi/src/decision_proposal/mod.rs @@ -27,9 +27,11 @@ //! contest (see `crate::voting::masternode_vote`). mod json; +mod multiple_choice; mod queries; mod transitions; +pub use multiple_choice::*; pub use queries::*; pub use transitions::*; diff --git a/packages/rs-sdk-ffi/src/decision_proposal/multiple_choice/json.rs b/packages/rs-sdk-ffi/src/decision_proposal/multiple_choice/json.rs new file mode 100644 index 00000000000..5a8de4932dc --- /dev/null +++ b/packages/rs-sdk-ffi/src/decision_proposal/multiple_choice/json.rs @@ -0,0 +1,490 @@ +//! The JSON the multiple choice proposal functions return, one shape per kind, written from +//! the rs-sdk types. Field names follow the wasm bindings +//! (`packages/wasm-sdk/src/decision_proposals/multiple_choice.rs`) and the yes/no proposal +//! JSON of `super::super::json`: camelCase, base58 ids, absent values as null. + +use super::super::json::block_json; +use crate::FFIError; +use dash_sdk::dpp::document::{Document, DocumentV0Getters}; +use dash_sdk::dpp::platform_value::string_encoding::Encoding; +use dash_sdk::dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use dash_sdk::platform::decision_proposals::multiple_choice::{ + Choice, MultipleChoiceProposal, MultipleChoiceProposalVote, MultipleChoiceVoteChoice, +}; +use drive_proof_verifier::types::Documents; +use serde::Serialize; +use serde_json::{json, Value as JsonValue}; + +/// The document a multiple choice proposal points at. +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +struct DescriptionDocumentJson<'a> { + /// The document, base58. + id: String, + /// The contract it lives in, base58. + contract_id: String, + document_type: &'a str, +} + +/// A multiple choice proposal as every multiple choice proposal read returns it. +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +struct MultipleChoiceProposalJson<'a> { + /// The proposal's id, base58. + id: String, + /// The proposer, base58. + owner_id: String, + revision: Option, + /// Milliseconds since the Unix epoch. + created_at: Option, + /// Milliseconds since the Unix epoch. + updated_at: Option, + title: &'a str, + description_document: Option>, + url: Option<&'a str>, + open: bool, +} + +/// A choice as every read of one returns it. +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +struct ChoiceJson<'a> { + /// The choice's id, base58: the id a masternode vote towards it names. + id: String, + /// The identity that entered it, base58. + owner_id: String, + /// The proposal it answers, base58. + proposal_id: String, + revision: Option, + /// Milliseconds since the Unix epoch. + created_at: Option, + /// Milliseconds since the Unix epoch. + updated_at: Option, + title: &'a str, + description: Option<&'a str>, +} + +/// `document`, a `multipleChoiceProposal` document, as the proposal JSON object. +pub(super) fn multiple_choice_proposal_json(document: Document) -> Result { + let proposal = MultipleChoiceProposal::from_document(document)?; + let document = &proposal.document; + Ok(serde_json::to_value(MultipleChoiceProposalJson { + id: document.id().to_string(Encoding::Base58), + owner_id: document.owner_id().to_string(Encoding::Base58), + revision: document.revision(), + created_at: document.created_at(), + updated_at: document.updated_at(), + title: &proposal.title, + description_document: proposal.description_document.as_ref().map(|described| { + DescriptionDocumentJson { + id: described.id.to_string(Encoding::Base58), + contract_id: described.contract_id.to_string(Encoding::Base58), + document_type: &described.document_type, + } + }), + url: proposal.url.as_deref(), + open: proposal.open, + })?) +} + +/// One page of a listing as a JSON array of proposals, in the listing's order. +pub(super) fn multiple_choice_proposals_json(documents: Documents) -> Result { + documents + .into_values() + .flatten() + .map(multiple_choice_proposal_json) + .collect::, _>>() + .map(JsonValue::Array) +} + +/// `choice` as the choice JSON object. +fn choice_json(choice: &Choice) -> Result { + let document = &choice.document; + Ok(serde_json::to_value(ChoiceJson { + id: document.id().to_string(Encoding::Base58), + owner_id: document.owner_id().to_string(Encoding::Base58), + proposal_id: choice.proposal_id.to_string(Encoding::Base58), + revision: document.revision(), + created_at: document.created_at(), + updated_at: document.updated_at(), + title: &choice.title, + description: choice.description.as_deref(), + })?) +} + +/// `document`, a `choice` document, as the choice JSON object. +pub(super) fn choice_document_json(document: Document) -> Result { + choice_json(&Choice::from_document(document)?) +} + +/// The vote among a proposal's choices: every choice by id with its tally, the other +/// tallies, and how the vote ended once it did. +pub(super) fn multiple_choice_proposal_vote_json( + vote: &MultipleChoiceProposalVote, +) -> Result { + let choices = vote + .choices + .iter() + .map(|(choice_id, choice_in_vote)| { + Ok(json!({ + "id": choice_id.to_string(Encoding::Base58), + "choice": choice_in_vote.choice.as_ref().map(choice_json).transpose()?, + "voteTally": choice_in_vote.vote_tally, + })) + }) + .collect::, FFIError>>()?; + let result = vote.winner.as_ref().map(|(winner, finalization_block)| { + let outcome = match winner { + ContestedDocumentVotePollWinnerInfo::WonByIdentity(_) => "keptChoice", + ContestedDocumentVotePollWinnerInfo::Locked => "noneOfTheChoices", + ContestedDocumentVotePollWinnerInfo::NoWinner => "noWinner", + }; + json!({ + "outcome": outcome, + "keptChoiceId": vote + .kept_choice_id() + .map(|choice_id| choice_id.to_string(Encoding::Base58)), + "finalizationBlock": block_json(finalization_block), + }) + }); + Ok(json!({ + "choices": choices, + "abstainVoteTally": vote.abstain_vote_tally, + "noneOfTheChoicesVoteTally": vote.none_of_the_choices_vote_tally, + "result": result, + })) +} + +/// The name a masternode's answer is written with: `"choice"`, `"noneOfTheChoices"` or +/// `"abstain"`. +pub(super) fn vote_choice_name(vote_choice: &MultipleChoiceVoteChoice) -> &'static str { + match vote_choice { + MultipleChoiceVoteChoice::Choice(_) => "choice", + MultipleChoiceVoteChoice::NoneOfTheChoices => "noneOfTheChoices", + MultipleChoiceVoteChoice::Abstain => "abstain", + } +} + +/// A masternode's answer; `None` when it has not voted in the vote. +pub(super) fn masternode_vote_json( + vote_choice: Option, +) -> Option { + vote_choice.map(|vote_choice| { + let choice_id = match vote_choice { + MultipleChoiceVoteChoice::Choice(choice_id) => { + Some(choice_id.to_string(Encoding::Base58)) + } + MultipleChoiceVoteChoice::NoneOfTheChoices | MultipleChoiceVoteChoice::Abstain => None, + }; + json!({ + "choice": vote_choice_name(&vote_choice), + "choiceId": choice_id, + }) + }) +} + +#[cfg(test)] +mod tests { + use super::super::super::json::tests::{proposals_contract, CREATED_AT}; + use super::*; + use dash_sdk::dpp::block::block_info::BlockInfo; + use dash_sdk::dpp::block::epoch::Epoch; + use dash_sdk::dpp::decision_proposal::multiple_choice::proposal_properties; + use dash_sdk::dpp::document::DocumentV0Setters; + use dash_sdk::dpp::platform_value::{Bytes32, Identifier}; + use dash_sdk::platform::decision_proposals::multiple_choice::{ + build_choice_document, build_multiple_choice_proposal_document, ChoiceInVote, ChoiceInput, + DescriptionDocument, MultipleChoiceProposalInput, + }; + use std::collections::BTreeMap; + + fn base58(id: Identifier) -> String { + id.to_string(Encoding::Base58) + } + + fn input() -> MultipleChoiceProposalInput { + MultipleChoiceProposalInput { + title: "Which block size?".to_string(), + description_document: Some(DescriptionDocument { + id: Identifier::from([5; 32]), + contract_id: Identifier::from([6; 32]), + document_type: "post".to_string(), + }), + url: Some("https://forum.dash.org/t/block-size".to_string()), + open: true, + } + } + + /// A multiple choice proposal of identity `[3; 32]` built by rs-sdk, as Platform stores + /// it. + fn stored_proposal(input: &MultipleChoiceProposalInput) -> Document { + let mut document = build_multiple_choice_proposal_document( + &proposals_contract(), + Identifier::from([3; 32]), + input, + Bytes32::new([9; 32]), + ) + .expect("builds") + .document; + document.set_created_at(Some(CREATED_AT)); + document.set_updated_at(Some(CREATED_AT)); + document + } + + /// A choice of identity `[4; 32]` for the proposal `[7; 32]`, as Platform stores it. + fn stored_choice(description: Option<&str>) -> Document { + let mut document = build_choice_document( + &proposals_contract(), + Identifier::from([4; 32]), + &ChoiceInput { + proposal_id: Identifier::from([7; 32]), + title: "Double it".to_string(), + description: description.map(str::to_string), + }, + Bytes32::new([8; 32]), + ) + .expect("builds") + .document; + document.set_created_at(Some(CREATED_AT)); + document + } + + fn block(height: u64) -> BlockInfo { + BlockInfo { + time_ms: 1_000 * height, + height, + core_height: 42, + epoch: Epoch::new(3).expect("an epoch"), + } + } + + #[test] + fn should_write_a_proposal_with_every_field() { + let document = stored_proposal(&input()); + let id = document.id(); + assert_eq!( + multiple_choice_proposal_json(document).expect("a proposal"), + json!({ + "id": base58(id), + "ownerId": base58(Identifier::from([3; 32])), + "revision": 1, + "createdAt": CREATED_AT, + "updatedAt": CREATED_AT, + "title": "Which block size?", + "descriptionDocument": { + "id": base58(Identifier::from([5; 32])), + "contractId": base58(Identifier::from([6; 32])), + "documentType": "post", + }, + "url": "https://forum.dash.org/t/block-size", + "open": true, + }) + ); + } + + #[test] + fn should_write_an_absent_description_document_and_url_as_null() { + let document = stored_proposal(&MultipleChoiceProposalInput { + description_document: None, + url: None, + open: false, + ..input() + }); + let proposal = multiple_choice_proposal_json(document).expect("a proposal"); + assert_eq!(proposal["descriptionDocument"], JsonValue::Null); + assert_eq!(proposal["url"], JsonValue::Null); + assert_eq!(proposal["open"], json!(false)); + } + + #[test] + fn should_refuse_a_document_that_is_not_a_multiple_choice_proposal() { + let mut document = stored_proposal(&input()); + document.remove(proposal_properties::TITLE); + assert!(multiple_choice_proposal_json(document).is_err()); + assert!(choice_document_json(stored_proposal(&input())).is_err()); + } + + #[test] + fn should_write_a_listing_in_its_order_without_absent_entries() { + let first = stored_proposal(&input()); + let mut second = stored_proposal(&input()); + second.set_id(Identifier::from([1; 32])); + let documents: Documents = [ + (first.id(), Some(first.clone())), + (Identifier::from([2; 32]), None), + (second.id(), Some(second.clone())), + ] + .into_iter() + .collect(); + let listing = multiple_choice_proposals_json(documents).expect("proposals"); + let ids: Vec<&str> = listing + .as_array() + .expect("an array") + .iter() + .map(|proposal| proposal["id"].as_str().expect("an id")) + .collect(); + assert_eq!(ids, [base58(first.id()), base58(second.id())]); + assert_eq!( + multiple_choice_proposals_json(Documents::default()).expect("empty"), + json!([]) + ); + } + + #[test] + fn should_write_a_choice_with_every_field_and_an_absent_description_as_null() { + let document = stored_choice(Some("Twice the size it is today.")); + let id = document.id(); + assert_eq!( + choice_document_json(document).expect("a choice"), + json!({ + "id": base58(id), + "ownerId": base58(Identifier::from([4; 32])), + "proposalId": base58(Identifier::from([7; 32])), + "revision": null, + "createdAt": CREATED_AT, + "updatedAt": null, + "title": "Double it", + "description": "Twice the size it is today.", + }) + ); + assert_eq!( + choice_document_json(stored_choice(None)).expect("a choice")["description"], + JsonValue::Null + ); + } + + #[test] + fn should_write_a_running_vote_with_its_choices_and_tallies() { + let double = stored_choice(Some("Twice the size it is today.")); + let left_id = Identifier::from([2; 32]); + let vote = MultipleChoiceProposalVote { + choices: BTreeMap::from([ + ( + double.id(), + ChoiceInVote { + choice: Some(Choice::from_document(double.clone()).expect("reads")), + vote_tally: Some(12), + }, + ), + ( + left_id, + ChoiceInVote { + choice: None, + vote_tally: None, + }, + ), + ]), + abstain_vote_tally: Some(3), + none_of_the_choices_vote_tally: Some(1), + winner: None, + }; + // The choices are written in the order of their ids + let mut choices = vec![ + ( + double.id(), + json!({ + "id": base58(double.id()), + "choice": choice_document_json(double.clone()).expect("a choice"), + "voteTally": 12, + }), + ), + ( + left_id, + json!({"id": base58(left_id), "choice": null, "voteTally": null}), + ), + ]; + choices.sort_by_key(|(id, _)| *id); + let choices: Vec = choices.into_iter().map(|(_, choice)| choice).collect(); + assert_eq!( + multiple_choice_proposal_vote_json(&vote).expect("writes"), + json!({ + "choices": choices, + "abstainVoteTally": 3, + "noneOfTheChoicesVoteTally": 1, + "result": null, + }) + ); + } + + #[test] + fn should_write_how_a_finished_vote_ended() { + let kept_id = Identifier::from([2; 32]); + let finished = |winner| MultipleChoiceProposalVote { + choices: BTreeMap::from([( + kept_id, + ChoiceInVote { + choice: None, + vote_tally: Some(9), + }, + )]), + abstain_vote_tally: None, + none_of_the_choices_vote_tally: Some(4), + winner: Some((winner, block(9))), + }; + let finalization_block = + json!({"height": 9, "coreHeight": 42, "timeMs": 9_000, "epoch": 3}); + for (winner, outcome, kept_choice_id) in [ + ( + ContestedDocumentVotePollWinnerInfo::WonByIdentity(kept_id), + "keptChoice", + json!(base58(kept_id)), + ), + ( + ContestedDocumentVotePollWinnerInfo::Locked, + "noneOfTheChoices", + JsonValue::Null, + ), + ( + ContestedDocumentVotePollWinnerInfo::NoWinner, + "noWinner", + JsonValue::Null, + ), + ] { + assert_eq!( + multiple_choice_proposal_vote_json(&finished(winner)).expect("writes"), + json!({ + "choices": [{"id": base58(kept_id), "choice": null, "voteTally": 9}], + "abstainVoteTally": null, + "noneOfTheChoicesVoteTally": 4, + "result": { + "outcome": outcome, + "keptChoiceId": kept_choice_id, + "finalizationBlock": finalization_block, + }, + }) + ); + } + } + + #[test] + fn should_write_a_vote_with_no_choice_as_empty() { + assert_eq!( + multiple_choice_proposal_vote_json(&MultipleChoiceProposalVote::default()) + .expect("writes"), + json!({ + "choices": [], + "abstainVoteTally": null, + "noneOfTheChoicesVoteTally": null, + "result": null, + }) + ); + } + + #[test] + fn should_write_a_masternode_answer() { + let choice_id = Identifier::from([9; 32]); + assert_eq!( + masternode_vote_json(Some(MultipleChoiceVoteChoice::Choice(choice_id))), + Some(json!({"choice": "choice", "choiceId": base58(choice_id)})) + ); + assert_eq!( + masternode_vote_json(Some(MultipleChoiceVoteChoice::NoneOfTheChoices)), + Some(json!({"choice": "noneOfTheChoices", "choiceId": null})) + ); + assert_eq!( + masternode_vote_json(Some(MultipleChoiceVoteChoice::Abstain)), + Some(json!({"choice": "abstain", "choiceId": null})) + ); + assert_eq!(masternode_vote_json(None), None); + } +} diff --git a/packages/rs-sdk-ffi/src/decision_proposal/multiple_choice/mod.rs b/packages/rs-sdk-ffi/src/decision_proposal/multiple_choice/mod.rs new file mode 100644 index 00000000000..abf3ab2d65d --- /dev/null +++ b/packages/rs-sdk-ffi/src/decision_proposal/multiple_choice/mod.rs @@ -0,0 +1,795 @@ +//! Multiple choice proposals (protocol version 15): questions whose answers are the choices +//! entered for them, as `multipleChoiceProposal` and `choice` documents of the decision +//! proposals system contract. Thin bindings over +//! `dash_sdk::platform::decision_proposals::multiple_choice`: rs-sdk decides everything +//! (which documents are proposals and choices, the vote's contest, the funds and fees); these +//! functions read C arguments, call it, and write the result. +//! +//! # Creating, editing and entering choices +//! +//! Through the platform wallet, which signs with the owner's identity keys: +//! `platform_wallet_multiple_choice_proposal_create`, `_edit` and `_enter_choice` in +//! `rs-platform-wallet-ffi`. Creating a proposal costs the processing fee +//! [`dash_sdk_multiple_choice_proposal_get_processing_fee`] reads, on top of the fees; a choice +//! states the contest fund [`dash_sdk_multiple_choice_proposal_get_choice_fund_to_join`] reads. +//! +//! # Reading +//! +//! The reads return JSON, null when what they read is absent. A proposal is always the same +//! object (see [`dash_sdk_multiple_choice_proposal_fetch`]), and so is a choice (see +//! [`dash_sdk_multiple_choice_proposal_get_kept_choice`]); the listings return arrays of +//! proposals. +//! +//! # Voting +//! +//! The choices contend in a masternode vote, in which a choice is named by its document id. +//! [`dash_sdk_multiple_choice_proposal_cast_vote`] answers for a masternode from its voting +//! private key and pro_tx_hash, exactly as `dash_sdk_decision_proposal_cast_vote` answers a +//! yes/no proposal (see `crate::voting::masternode_vote`). + +mod json; + +use self::json::{ + choice_document_json, masternode_vote_json, multiple_choice_proposal_json, + multiple_choice_proposal_vote_json, multiple_choice_proposals_json, +}; +use super::queries::page; +use super::{json_result, optional_identifier, required_identifier, sdk_wrapper, string_result}; +use crate::types::{FFINetwork, SDKHandle}; +use crate::voting::masternode_vote::{pro_tx_hash_from_wire_order, MasternodeVoter}; +use crate::{DashSDKResult, FFIError}; +use dash_sdk::platform::decision_proposals::multiple_choice::{ + multiple_choice_proposal_vote, MultipleChoiceVoteChoice, +}; +use serde_json::Value as JsonValue; +use std::ffi::c_char; + +/// The answer of a masternode's vote among a multiple choice proposal's choices, the +/// `vote_choice` byte of `dash_sdk_multiple_choice_proposal_cast_vote`: `0` = for the choice +/// `choice_id` names, `1` = none of the choices, `2` = abstain. +/// +/// The FFI parameter is a plain `u8`, not this enum: a C caller can pass any byte, and an +/// out-of-range value read as a `#[repr(u8)]` enum is undefined behavior. The byte is +/// compared with these discriminants, and any other value is refused with +/// `InvalidParameter`. Not exported to the C header for that reason; Swift and Kotlin mirror +/// the three values. +#[repr(u8)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum MultipleChoiceVoteChoiceFFI { + Choice = 0, + NoneOfTheChoices = 1, + Abstain = 2, +} + +/// The answer the `vote_choice` byte and `choice_id` name. `choice_id` names the choice for +/// `0` and must be null for the other answers. +/// +/// # Safety +/// `choice_id` must be null or point to a NUL-terminated string. +unsafe fn vote_choice_from_ffi( + vote_choice: u8, + choice_id: *const c_char, +) -> Result { + let choice_id = optional_identifier(choice_id, "choice_id")?; + match (vote_choice, choice_id) { + (x, Some(choice_id)) if x == MultipleChoiceVoteChoiceFFI::Choice as u8 => { + Ok(MultipleChoiceVoteChoice::Choice(choice_id)) + } + (x, None) if x == MultipleChoiceVoteChoiceFFI::Choice as u8 => Err( + FFIError::InvalidParameter("choice_id is null for a vote for a choice".to_string()), + ), + (x, None) if x == MultipleChoiceVoteChoiceFFI::NoneOfTheChoices as u8 => { + Ok(MultipleChoiceVoteChoice::NoneOfTheChoices) + } + (x, None) if x == MultipleChoiceVoteChoiceFFI::Abstain as u8 => { + Ok(MultipleChoiceVoteChoice::Abstain) + } + (x, Some(_)) + if x == MultipleChoiceVoteChoiceFFI::NoneOfTheChoices as u8 + || x == MultipleChoiceVoteChoiceFFI::Abstain as u8 => + { + Err(FFIError::InvalidParameter(format!( + "choice_id must be null for vote_choice {x}, which names no choice" + ))) + } + (other, _) => Err(FFIError::InvalidParameter(format!( + "vote_choice must be 0 (a choice), 1 (none of the choices) or 2 (abstain); got \ + {other}" + ))), + } +} + +/// Fetches a multiple choice proposal by id. +/// +/// # Parameters +/// * `sdk_handle` - Handle to the SDK instance. +/// * `proposal_id` - The proposal's id, base58. +/// +/// # Returns +/// The proposal as a JSON object, or no data when there is none: +/// +/// ```json +/// {"id": "", "ownerId": "", "revision": 1, +/// "createdAt": 1700000000000, "updatedAt": 1700000000000, +/// "title": "Which block size?", +/// "descriptionDocument": {"id": "", "contractId": "", "documentType": "post"}, +/// "url": "https://forum.dash.org/t/block-size", "open": true} +/// ``` +/// +/// `descriptionDocument` and `url` are null when the proposal has none (it has at least one); +/// `revision`, `createdAt` and `updatedAt` are null when the document does not carry them. +/// Times are milliseconds since the Unix epoch. `open` says whether anyone may enter choices +/// (only the owner may when it is false). Every listing returns proposals in this shape. +/// Free the string with `dash_sdk_string_free`. +/// +/// # Safety +/// - `sdk_handle` must be a valid pointer to an initialized `SDKHandle`. +/// - `proposal_id` must be a valid pointer to a NUL-terminated string for the duration of the +/// call. +#[no_mangle] +pub unsafe extern "C" fn dash_sdk_multiple_choice_proposal_fetch( + sdk_handle: *const SDKHandle, + proposal_id: *const c_char, +) -> DashSDKResult { + json_result(fetch_inner(sdk_handle, proposal_id)) +} + +unsafe fn fetch_inner( + sdk_handle: *const SDKHandle, + proposal_id: *const c_char, +) -> Result, FFIError> { + let wrapper = sdk_wrapper(sdk_handle)?; + let proposal_id = required_identifier(proposal_id, "proposal_id")?; + wrapper + .runtime + .block_on(wrapper.sdk.fetch_multiple_choice_proposal(proposal_id))? + .map(multiple_choice_proposal_json) + .transpose() +} + +/// Lists one page of an identity's multiple choice proposals, in the order it filed them. +/// +/// # Parameters +/// * `sdk_handle` - Handle to the SDK instance. +/// * `owner_id` - The proposer's identity id, base58. +/// * `limit` - The most proposals to return, at most 100; 0 for 100. +/// * `start_after` - The id (base58) of the last proposal of the previous page; null for the +/// first page. +/// +/// # Returns +/// A JSON array of proposals in the shape `dash_sdk_multiple_choice_proposal_fetch` returns, +/// `[]` when there is none. A page shorter than the limit is the last. Free the string with +/// `dash_sdk_string_free`. +/// +/// # Safety +/// - `sdk_handle` must be a valid pointer to an initialized `SDKHandle`. +/// - `owner_id` must be a valid pointer to a NUL-terminated string, and `start_after` null or +/// one, for the duration of the call. +#[no_mangle] +pub unsafe extern "C" fn dash_sdk_multiple_choice_proposal_list_by_owner( + sdk_handle: *const SDKHandle, + owner_id: *const c_char, + limit: u32, + start_after: *const c_char, +) -> DashSDKResult { + json_result(list_by_owner_inner( + sdk_handle, + owner_id, + limit, + start_after, + )) +} + +unsafe fn list_by_owner_inner( + sdk_handle: *const SDKHandle, + owner_id: *const c_char, + limit: u32, + start_after: *const c_char, +) -> Result, FFIError> { + let wrapper = sdk_wrapper(sdk_handle)?; + let owner_id = required_identifier(owner_id, "owner_id")?; + let page = page(limit, start_after)?; + let documents = wrapper.runtime.block_on( + wrapper + .sdk + .fetch_multiple_choice_proposals_by_owner(owner_id, page), + )?; + multiple_choice_proposals_json(documents).map(Some) +} + +/// Lists one page of every multiple choice proposal, newest first. +/// +/// # Parameters +/// * `sdk_handle` - Handle to the SDK instance. +/// * `limit` - The most proposals to return, at most 100; 0 for 100. +/// * `start_after` - The id (base58) of the last proposal of the previous page; null for the +/// first page. +/// +/// # Returns +/// A JSON array of proposals in the shape `dash_sdk_multiple_choice_proposal_fetch` returns, +/// `[]` when there is none. Free the string with `dash_sdk_string_free`. +/// +/// # Safety +/// - `sdk_handle` must be a valid pointer to an initialized `SDKHandle`. +/// - `start_after` must be null or a valid pointer to a NUL-terminated string for the duration +/// of the call. +#[no_mangle] +pub unsafe extern "C" fn dash_sdk_multiple_choice_proposal_list_by_created_at( + sdk_handle: *const SDKHandle, + limit: u32, + start_after: *const c_char, +) -> DashSDKResult { + json_result(list_by_created_at_inner(sdk_handle, limit, start_after)) +} + +unsafe fn list_by_created_at_inner( + sdk_handle: *const SDKHandle, + limit: u32, + start_after: *const c_char, +) -> Result, FFIError> { + let wrapper = sdk_wrapper(sdk_handle)?; + let page = page(limit, start_after)?; + let documents = wrapper.runtime.block_on( + wrapper + .sdk + .fetch_multiple_choice_proposals_by_created_at(page), + )?; + multiple_choice_proposals_json(documents).map(Some) +} + +/// The vote among a multiple choice proposal's choices: every choice with its tally while the +/// vote runs, and how it ended with every choice's final tally once it did. +/// +/// # Parameters +/// * `sdk_handle` - Handle to the SDK instance. +/// * `proposal_id` - The proposal's id, base58. +/// +/// # Returns +/// A JSON object. While the vote runs: +/// +/// ```json +/// {"choices": [{"id": "", +/// "choice": {"id": "", "ownerId": "", +/// "proposalId": "", "revision": null, +/// "createdAt": 1700000000000, "updatedAt": null, +/// "title": "Double it", +/// "description": "Twice the size it is today."}, +/// "voteTally": 12}], +/// "abstainVoteTally": 3, "noneOfTheChoicesVoteTally": 1, "result": null} +/// ``` +/// +/// `choices` is ordered by choice id, and `[]` for a proposal no choice was entered for. Each +/// `id` is the choice's document id, the one a vote for it names; `choice` is the choice in +/// the shape `dash_sdk_multiple_choice_proposal_get_kept_choice` returns, null once the vote +/// ended (the choices not kept are gone, and the kept one is read with that function). The +/// tallies are null when Platform does not report them. Once the vote ended, `result` is +/// `{"outcome": "keptChoice" | "noneOfTheChoices" | "noWinner", "keptChoiceId": "", +/// "finalizationBlock": {"height": 9, "coreHeight": 42, "timeMs": 9000, "epoch": 3}}`, with +/// `keptChoiceId` null unless `outcome` is `"keptChoice"`. Free the string with +/// `dash_sdk_string_free`. +/// +/// # Safety +/// - `sdk_handle` must be a valid pointer to an initialized `SDKHandle`. +/// - `proposal_id` must be a valid pointer to a NUL-terminated string for the duration of the +/// call. +#[no_mangle] +pub unsafe extern "C" fn dash_sdk_multiple_choice_proposal_get_vote( + sdk_handle: *const SDKHandle, + proposal_id: *const c_char, +) -> DashSDKResult { + json_result(get_vote_inner(sdk_handle, proposal_id)) +} + +unsafe fn get_vote_inner( + sdk_handle: *const SDKHandle, + proposal_id: *const c_char, +) -> Result, FFIError> { + let wrapper = sdk_wrapper(sdk_handle)?; + let proposal_id = required_identifier(proposal_id, "proposal_id")?; + let vote = wrapper + .runtime + .block_on(wrapper.sdk.fetch_multiple_choice_proposal_vote(proposal_id))?; + multiple_choice_proposal_vote_json(&vote).map(Some) +} + +/// The choice the finished vote of a multiple choice proposal kept, an ordinary document of +/// the identity that entered it. +/// +/// # Parameters +/// * `sdk_handle` - Handle to the SDK instance. +/// * `proposal_id` - The proposal's id, base58. +/// +/// # Returns +/// The choice as a JSON object, or no data while the vote runs, when it kept none of the +/// choices, and for a proposal no choice was entered for: +/// +/// ```json +/// {"id": "", "ownerId": "", "proposalId": "", "revision": null, +/// "createdAt": 1700000000000, "updatedAt": null, +/// "title": "Double it", "description": "Twice the size it is today."} +/// ``` +/// +/// `description` is null when the choice has none; `revision`, `createdAt` and `updatedAt` +/// are null when the document does not carry them. Free the string with +/// `dash_sdk_string_free`. +/// +/// # Safety +/// - `sdk_handle` must be a valid pointer to an initialized `SDKHandle`. +/// - `proposal_id` must be a valid pointer to a NUL-terminated string for the duration of the +/// call. +#[no_mangle] +pub unsafe extern "C" fn dash_sdk_multiple_choice_proposal_get_kept_choice( + sdk_handle: *const SDKHandle, + proposal_id: *const c_char, +) -> DashSDKResult { + json_result(get_kept_choice_inner(sdk_handle, proposal_id)) +} + +unsafe fn get_kept_choice_inner( + sdk_handle: *const SDKHandle, + proposal_id: *const c_char, +) -> Result, FFIError> { + let wrapper = sdk_wrapper(sdk_handle)?; + let proposal_id = required_identifier(proposal_id, "proposal_id")?; + wrapper + .runtime + .block_on(wrapper.sdk.fetch_kept_choice(proposal_id))? + .map(choice_document_json) + .transpose() +} + +/// The answer a masternode gave in the vote among a multiple choice proposal's choices. +/// +/// # Parameters +/// * `sdk_handle` - Handle to the SDK instance. +/// * `voter_pro_tx_hash` - Pointer to the masternode's 32-byte pro_tx_hash in wire order, the +/// same bytes `dash_sdk_multiple_choice_proposal_cast_vote` takes (the reverse of the hex +/// Core displays). They are reversed here, as for the vote. +/// * `proposal_id` - The proposal's id, base58. +/// +/// # Returns +/// `{"choice": "choice", "choiceId": ""}` for a vote for a choice, or +/// `{"choice": "noneOfTheChoices" | "abstain", "choiceId": null}`; no data when the +/// masternode has not voted in it, and once the vote ended. Free the string with +/// `dash_sdk_string_free`. +/// +/// # Safety +/// - `sdk_handle` must be a valid pointer to an initialized `SDKHandle`. +/// - `voter_pro_tx_hash` must point to 32 readable bytes and `proposal_id` to a +/// NUL-terminated string for the duration of the call. +#[no_mangle] +pub unsafe extern "C" fn dash_sdk_multiple_choice_proposal_get_masternode_vote( + sdk_handle: *const SDKHandle, + voter_pro_tx_hash: *const u8, + proposal_id: *const c_char, +) -> DashSDKResult { + json_result(get_masternode_vote_inner( + sdk_handle, + voter_pro_tx_hash, + proposal_id, + )) +} + +unsafe fn get_masternode_vote_inner( + sdk_handle: *const SDKHandle, + voter_pro_tx_hash: *const u8, + proposal_id: *const c_char, +) -> Result, FFIError> { + let wrapper = sdk_wrapper(sdk_handle)?; + let pro_tx_hash = pro_tx_hash_from_wire_order(voter_pro_tx_hash)?; + let proposal_id = required_identifier(proposal_id, "proposal_id")?; + let vote_choice = wrapper.runtime.block_on( + wrapper + .sdk + .fetch_masternode_multiple_choice_vote(pro_tx_hash, proposal_id), + )?; + Ok(masternode_vote_json(vote_choice)) +} + +/// What creating one multiple choice proposal adds to the processing fee of its batch, which +/// Platform charges the owner on top of the fees; the create does not state it. A network +/// below protocol version 15 has no multiple choice proposals, which is an error. +/// +/// # Parameters +/// * `sdk_handle` - Handle to the SDK instance. +/// +/// # Returns +/// The fee in credits as a decimal string (not JSON), for example `"20000000000"`. Free it +/// with `dash_sdk_string_free`. +/// +/// # Safety +/// - `sdk_handle` must be a valid pointer to an initialized `SDKHandle`. +#[no_mangle] +pub unsafe extern "C" fn dash_sdk_multiple_choice_proposal_get_processing_fee( + sdk_handle: *const SDKHandle, +) -> DashSDKResult { + string_result(get_processing_fee_inner(sdk_handle)) +} + +unsafe fn get_processing_fee_inner( + sdk_handle: *const SDKHandle, +) -> Result, FFIError> { + let wrapper = sdk_wrapper(sdk_handle)?; + let fee = wrapper + .runtime + .block_on(wrapper.sdk.multiple_choice_proposal_processing_fee())?; + Ok(Some(fee.to_string())) +} + +/// The fund a choice entered now for a multiple choice proposal pays: the contest's fund, +/// doubled once the vote holds 250 choices and again for every 50 more. The put of a choice +/// reads and states it itself; this is for showing it beforehand. +/// +/// # Parameters +/// * `sdk_handle` - Handle to the SDK instance. +/// * `proposal_id` - The proposal's id, base58. +/// +/// # Returns +/// The fund in credits as a decimal string (not JSON), for example `"10000000000"`. Free it +/// with `dash_sdk_string_free`. +/// +/// # Safety +/// - `sdk_handle` must be a valid pointer to an initialized `SDKHandle`. +/// - `proposal_id` must be a valid pointer to a NUL-terminated string for the duration of the +/// call. +#[no_mangle] +pub unsafe extern "C" fn dash_sdk_multiple_choice_proposal_get_choice_fund_to_join( + sdk_handle: *const SDKHandle, + proposal_id: *const c_char, +) -> DashSDKResult { + string_result(get_choice_fund_to_join_inner(sdk_handle, proposal_id)) +} + +unsafe fn get_choice_fund_to_join_inner( + sdk_handle: *const SDKHandle, + proposal_id: *const c_char, +) -> Result, FFIError> { + let wrapper = sdk_wrapper(sdk_handle)?; + let proposal_id = required_identifier(proposal_id, "proposal_id")?; + let fund = wrapper + .runtime + .block_on(wrapper.sdk.choice_fund_to_join(proposal_id))?; + Ok(Some(fund.to_string())) +} + +/// Votes in the vote among a multiple choice proposal's choices for a masternode: builds the +/// vote, signs it with the masternode voting key derived from `voting_private_key`, +/// broadcasts it for `voter_pro_tx_hash` and waits for the response. Every argument is read +/// before anything reaches the network. +/// +/// The signer, the voting key and the voter identity are derived exactly as +/// `dash_sdk_decision_proposal_cast_vote` derives them, and a refused voting key is explained +/// the same way. +/// +/// # Parameters +/// * `sdk_handle` - Handle to the SDK instance. +/// * `proposal_id` - The proposal's id, base58. +/// * `vote_choice` - `0` = for the choice `choice_id` names, `1` = none of the choices (keeps +/// no choice when these votes outnumber the leading choice), `2` = abstain. Any other value +/// is refused with `InvalidParameter`. +/// * `choice_id` - The document id (base58) of the choice voted for, not the id of the +/// identity that entered it. Required for `vote_choice` `0` and null otherwise; anything +/// else is refused with `InvalidParameter`. +/// * `voter_pro_tx_hash` - Pointer to the masternode's 32-byte pro_tx_hash in wire order, as +/// `dash_sdk_decision_proposal_cast_vote` takes it (NOT the byte order of the hex Core +/// displays, which is its reverse). The bytes are reversed here. +/// * `voting_private_key` - Pointer to the 32-byte masternode voting private key. It never +/// leaves this call. +/// * `network` - The network, used for the WIF encoding inside the signer only. +/// +/// # Returns +/// No data on success, or an error. A vote from a wallet that is not a masternode fails with +/// a no-voter-identity error from Platform, the expected outcome. +/// +/// # Safety +/// - `sdk_handle` must be a valid pointer to an initialized `SDKHandle`. +/// - `proposal_id` must be a valid pointer to a NUL-terminated string, and `choice_id` null or +/// one. +/// - `voter_pro_tx_hash` and `voting_private_key` must each point to 32 readable bytes. All +/// must stay valid for the duration of the call. +#[no_mangle] +pub unsafe extern "C" fn dash_sdk_multiple_choice_proposal_cast_vote( + sdk_handle: *const SDKHandle, + proposal_id: *const c_char, + vote_choice: u8, + choice_id: *const c_char, + voter_pro_tx_hash: *const u8, + voting_private_key: *const u8, + network: FFINetwork, +) -> DashSDKResult { + match cast_vote_inner( + sdk_handle, + proposal_id, + vote_choice, + choice_id, + voter_pro_tx_hash, + voting_private_key, + network, + ) { + Ok(()) => DashSDKResult::success(std::ptr::null_mut()), + Err(error) => DashSDKResult::error(error.into()), + } +} + +unsafe fn cast_vote_inner( + sdk_handle: *const SDKHandle, + proposal_id: *const c_char, + vote_choice: u8, + choice_id: *const c_char, + voter_pro_tx_hash: *const u8, + voting_private_key: *const u8, + network: FFINetwork, +) -> Result<(), FFIError> { + let wrapper = sdk_wrapper(sdk_handle)?; + let proposal_id = required_identifier(proposal_id, "proposal_id")?; + let vote_choice = vote_choice_from_ffi(vote_choice, choice_id)?; + let voter = MasternodeVoter::from_raw(voter_pro_tx_hash, voting_private_key, network)?; + let vote = multiple_choice_proposal_vote(proposal_id, vote_choice); + wrapper + .runtime + .block_on(voter.put_vote(&wrapper.sdk, &vote)) +} + +#[cfg(test)] +mod tests { + use super::json::vote_choice_name; + use super::*; + use crate::test_utils::test_utils::{create_mock_sdk_handle, destroy_mock_sdk_handle}; + use crate::{dash_sdk_error_free, DashSDKErrorCode}; + use dash_sdk::dpp::platform_value::string_encoding::Encoding; + use dash_sdk::dpp::platform_value::Identifier; + use std::ffi::CString; + + /// `result` failed with `InvalidParameter`; its error is freed. + unsafe fn assert_invalid_parameter(result: DashSDKResult) { + assert!(result.data.is_null()); + assert!(!result.error.is_null(), "expected an error"); + let code = (*result.error).code; + dash_sdk_error_free(result.error); + assert_eq!(code, DashSDKErrorCode::InvalidParameter); + } + + fn base58(id: Identifier) -> CString { + CString::new(id.to_string(Encoding::Base58)).expect("no NUL") + } + + #[test] + fn should_map_each_vote_choice_byte_and_refuse_the_rest() { + let choice_id = Identifier::new([9; 32]); + let choice = base58(choice_id); + let not_base58 = CString::new("0OIl").expect("no NUL"); + unsafe { + assert_eq!( + vote_choice_from_ffi(0, choice.as_ptr()).ok(), + Some(MultipleChoiceVoteChoice::Choice(choice_id)) + ); + assert_eq!( + vote_choice_from_ffi(1, std::ptr::null()).ok(), + Some(MultipleChoiceVoteChoice::NoneOfTheChoices) + ); + assert_eq!( + vote_choice_from_ffi(2, std::ptr::null()).ok(), + Some(MultipleChoiceVoteChoice::Abstain) + ); + for (byte, choice_id) in [ + // A vote for a choice names it + (0, std::ptr::null()), + (0, not_base58.as_ptr()), + // The other answers name none + (1, choice.as_ptr()), + (2, choice.as_ptr()), + (3, std::ptr::null()), + (3, choice.as_ptr()), + (u8::MAX, std::ptr::null()), + ] { + assert!( + matches!( + vote_choice_from_ffi(byte, choice_id), + Err(FFIError::InvalidParameter(_)) + ), + "vote_choice {byte}" + ); + } + // The byte and the name a masternode's answer is read back with agree + for (byte, choice_id, name) in [ + (0, choice.as_ptr(), "choice"), + (1, std::ptr::null(), "noneOfTheChoices"), + (2, std::ptr::null(), "abstain"), + ] { + assert_eq!( + vote_choice_name(&vote_choice_from_ffi(byte, choice_id).expect("an answer")), + name + ); + } + } + } + + /// Every read refuses a null SDK handle, a null or non-base58 id and a null pro_tx_hash + /// before anything reaches the network. + #[test] + fn should_refuse_missing_or_malformed_arguments_before_any_request() { + let handle = create_mock_sdk_handle(); + let id = base58(Identifier::new([4; 32])); + let not_base58 = CString::new("not base58: 0OIl").expect("no NUL"); + let pro_tx_hash = [1u8; 32]; + unsafe { + for proposal_id in [std::ptr::null(), not_base58.as_ptr()] { + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_fetch( + handle, + proposal_id, + )); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_list_by_owner( + handle, + proposal_id, + 0, + std::ptr::null(), + )); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_get_vote( + handle, + proposal_id, + )); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_get_kept_choice( + handle, + proposal_id, + )); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_get_masternode_vote( + handle, + pro_tx_hash.as_ptr(), + proposal_id, + )); + assert_invalid_parameter( + dash_sdk_multiple_choice_proposal_get_choice_fund_to_join(handle, proposal_id), + ); + } + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_list_by_owner( + handle, + id.as_ptr(), + 0, + not_base58.as_ptr(), + )); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_list_by_created_at( + handle, + 0, + not_base58.as_ptr(), + )); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_get_masternode_vote( + handle, + std::ptr::null(), + id.as_ptr(), + )); + + let no_sdk = std::ptr::null(); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_fetch(no_sdk, id.as_ptr())); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_list_by_owner( + no_sdk, + id.as_ptr(), + 0, + std::ptr::null(), + )); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_list_by_created_at( + no_sdk, + 0, + std::ptr::null(), + )); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_get_vote( + no_sdk, + id.as_ptr(), + )); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_get_kept_choice( + no_sdk, + id.as_ptr(), + )); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_get_masternode_vote( + no_sdk, + pro_tx_hash.as_ptr(), + id.as_ptr(), + )); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_get_processing_fee(no_sdk)); + assert_invalid_parameter(dash_sdk_multiple_choice_proposal_get_choice_fund_to_join( + no_sdk, + id.as_ptr(), + )); + destroy_mock_sdk_handle(handle); + } + } + + /// The vote reads every argument before it reaches the network. + #[test] + fn should_refuse_a_vote_with_unreadable_arguments() { + let handle = create_mock_sdk_handle(); + let proposal_id = base58(Identifier::new([4; 32])); + let choice_id = base58(Identifier::new([9; 32])); + let not_base58 = CString::new("0OIl").expect("no NUL"); + let pro_tx_hash = [1u8; 32]; + let voting_key = [2u8; 32]; + let zero_key = [0u8; 32]; + unsafe { + for result in [ + dash_sdk_multiple_choice_proposal_cast_vote( + std::ptr::null(), + proposal_id.as_ptr(), + 0, + choice_id.as_ptr(), + pro_tx_hash.as_ptr(), + voting_key.as_ptr(), + FFINetwork::Testnet, + ), + dash_sdk_multiple_choice_proposal_cast_vote( + handle, + std::ptr::null(), + 0, + choice_id.as_ptr(), + pro_tx_hash.as_ptr(), + voting_key.as_ptr(), + FFINetwork::Testnet, + ), + dash_sdk_multiple_choice_proposal_cast_vote( + handle, + not_base58.as_ptr(), + 0, + choice_id.as_ptr(), + pro_tx_hash.as_ptr(), + voting_key.as_ptr(), + FFINetwork::Testnet, + ), + dash_sdk_multiple_choice_proposal_cast_vote( + handle, + proposal_id.as_ptr(), + 0, + std::ptr::null(), + pro_tx_hash.as_ptr(), + voting_key.as_ptr(), + FFINetwork::Testnet, + ), + dash_sdk_multiple_choice_proposal_cast_vote( + handle, + proposal_id.as_ptr(), + 2, + choice_id.as_ptr(), + pro_tx_hash.as_ptr(), + voting_key.as_ptr(), + FFINetwork::Testnet, + ), + dash_sdk_multiple_choice_proposal_cast_vote( + handle, + proposal_id.as_ptr(), + 3, + std::ptr::null(), + pro_tx_hash.as_ptr(), + voting_key.as_ptr(), + FFINetwork::Testnet, + ), + dash_sdk_multiple_choice_proposal_cast_vote( + handle, + proposal_id.as_ptr(), + 1, + std::ptr::null(), + std::ptr::null(), + voting_key.as_ptr(), + FFINetwork::Testnet, + ), + dash_sdk_multiple_choice_proposal_cast_vote( + handle, + proposal_id.as_ptr(), + 1, + std::ptr::null(), + pro_tx_hash.as_ptr(), + std::ptr::null(), + FFINetwork::Testnet, + ), + dash_sdk_multiple_choice_proposal_cast_vote( + handle, + proposal_id.as_ptr(), + 2, + std::ptr::null(), + pro_tx_hash.as_ptr(), + zero_key.as_ptr(), + FFINetwork::Testnet, + ), + ] { + assert_invalid_parameter(result); + } + destroy_mock_sdk_handle(handle); + } + } +} diff --git a/packages/rs-sdk-ffi/src/decision_proposal/queries.rs b/packages/rs-sdk-ffi/src/decision_proposal/queries.rs index d1506c8cbae..cd9b5e4bf43 100644 --- a/packages/rs-sdk-ffi/src/decision_proposal/queries.rs +++ b/packages/rs-sdk-ffi/src/decision_proposal/queries.rs @@ -23,7 +23,10 @@ use std::ffi::c_char; /// /// # Safety /// `start_after` must be null or point to a NUL-terminated string. -unsafe fn page(limit: u32, start_after: *const c_char) -> Result { +pub(super) unsafe fn page( + limit: u32, + start_after: *const c_char, +) -> Result { Ok(DocumentsPage { limit: (limit > 0).then_some(limit), start_after: optional_identifier(start_after, "start_after")?, diff --git a/packages/rs-unified-sdk-jni/src/decision_proposals.rs b/packages/rs-unified-sdk-jni/src/decision_proposals.rs index dcba5e51fa7..c9017c5fb88 100644 --- a/packages/rs-unified-sdk-jni/src/decision_proposals.rs +++ b/packages/rs-unified-sdk-jni/src/decision_proposals.rs @@ -39,14 +39,18 @@ use std::ffi::{CStr, CString}; use std::os::raw::c_char; use std::ptr; -// ── Marshalling helpers ────────────────────────────────────────────────── +// ── Marshalling helpers (shared with `crate::multiple_choice_proposals`) ─ /// Read a nullable JVM string into an owned `CString`. /// /// `Some(None)` for a null string, `Some(Some(_))` for a string, and `None` after throwing /// for a string JNI cannot read or one holding a NUL byte (the caller bails out). An /// unreadable string is never mistaken for an absent one. -fn read_optional_cstring(env: &mut JNIEnv, s: &JString, field: &str) -> Option> { +pub(crate) fn read_optional_cstring( + env: &mut JNIEnv, + s: &JString, + field: &str, +) -> Option> { if s.is_null() { return Some(None); } @@ -69,7 +73,7 @@ fn read_optional_cstring(env: &mut JNIEnv, s: &JString, field: &str) -> Option Option { +pub(crate) fn read_cstring(env: &mut JNIEnv, s: &JString, field: &str) -> Option { match read_optional_cstring(env, s, field)? { Some(c) => Some(c), None => { @@ -80,13 +84,13 @@ fn read_cstring(env: &mut JNIEnv, s: &JString, field: &str) -> Option { } /// The pointer the C functions take for an optional string: null for `None`. -fn c_ptr(value: &Option) -> *const c_char { +pub(crate) fn c_ptr(value: &Option) -> *const c_char { value.as_ref().map_or(ptr::null(), |s| s.as_ptr()) } /// Read a required 32-byte array; throws and returns `None` for a null array or any other /// length (the C functions read exactly 32 bytes through the pointer). -fn read_bytes32(env: &mut JNIEnv, arr: &JByteArray, field: &str) -> Option<[u8; 32]> { +pub(crate) fn read_bytes32(env: &mut JNIEnv, arr: &JByteArray, field: &str) -> Option<[u8; 32]> { let bytes = match env.convert_byte_array(arr) { Ok(b) => b, Err(_) => { @@ -110,7 +114,7 @@ fn read_bytes32(env: &mut JNIEnv, arr: &JByteArray, field: &str) -> Option<[u8; /// Secret-key sibling of [`read_bytes32`]: the returned buffer is scrubbed on drop and the /// intermediate JNI copy is zeroized before it is dropped. For the voting private key only. -fn read_key32_zeroizing( +pub(crate) fn read_key32_zeroizing( env: &mut JNIEnv, arr: &JByteArray, field: &str, @@ -139,7 +143,7 @@ fn read_key32_zeroizing( /// `value` as the unsigned C type `T`; throws and returns `None` for a value `T` cannot /// hold (negative, or too large) instead of wrapping it into a different, valid one. -fn to_unsigned>(env: &mut JNIEnv, value: i64, field: &str) -> Option { +pub(crate) fn to_unsigned>(env: &mut JNIEnv, value: i64, field: &str) -> Option { match T::try_from(value) { Ok(converted) => Some(converted), Err(_) => { @@ -155,7 +159,7 @@ fn to_unsigned>(env: &mut JNIEnv, value: i64, field: &str) -> Op /// # Safety /// `result` must be a `DashSDKResult` freshly returned by an rs-sdk-ffi function whose /// success payload is a `char*` or no data. -unsafe fn string_or_null(env: &mut JNIEnv, result: DashSDKResult) -> jstring { +pub(crate) unsafe fn string_or_null(env: &mut JNIEnv, result: DashSDKResult) -> jstring { unwrap_string(env, result) .map(|s| s.into_raw()) .unwrap_or(ptr::null_mut()) @@ -174,7 +178,7 @@ unsafe fn static_string(env: &mut JNIEnv, value: *const c_char) -> jstring { /// Whether `arr` is a non-null `byte[len]`. Clears the exception a failed length read /// leaves; the caller throws. -fn is_byte_array_of_len(env: &mut JNIEnv, arr: &JByteArray, len: i32) -> bool { +pub(crate) fn is_byte_array_of_len(env: &mut JNIEnv, arr: &JByteArray, len: i32) -> bool { if arr.is_null() { return false; } @@ -194,7 +198,11 @@ fn is_byte_array_of_len(env: &mut JNIEnv, arr: &JByteArray, len: i32) -> bool { /// /// # Safety /// `json` must be null or a string the platform wallet allocated and nothing else frees. -unsafe fn take_wallet_json(env: &mut JNIEnv, json: *mut c_char, call: &str) -> Option { +pub(crate) unsafe fn take_wallet_json( + env: &mut JNIEnv, + json: *mut c_char, + call: &str, +) -> Option { if json.is_null() { throw_sdk_exception( env, @@ -704,7 +712,7 @@ pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_DecisionProposalsNati } #[cfg(test)] -mod tests { +pub(crate) mod tests { const DECISION_PROPOSALS_NATIVE_KT: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/../kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/DecisionProposalsNative.kt" @@ -713,10 +721,16 @@ mod tests { /// The parameter types and the return type of `external fun {name}(...)` in /// `DecisionProposalsNative.kt`. fn kotlin_signature(name: &str) -> (Vec, String) { - let declaration = DECISION_PROPOSALS_NATIVE_KT + kotlin_signature_in(DECISION_PROPOSALS_NATIVE_KT, name) + } + + /// The parameter types and the return type of `external fun {name}(...)` in the Kotlin + /// source `kotlin`, the text of a `*Native.kt` file. + pub(crate) fn kotlin_signature_in(kotlin: &str, name: &str) -> (Vec, String) { + let declaration = kotlin .split(&format!("external fun {name}(")) .nth(1) - .unwrap_or_else(|| panic!("DecisionProposalsNative.kt declares {name}")); + .unwrap_or_else(|| panic!("the Kotlin native object declares {name}")); let (parameters, rest) = declaration .split_once(')') .expect("the parameter list closes"); diff --git a/packages/rs-unified-sdk-jni/src/lib.rs b/packages/rs-unified-sdk-jni/src/lib.rs index aaa43632342..b8450bdaa34 100644 --- a/packages/rs-unified-sdk-jni/src/lib.rs +++ b/packages/rs-unified-sdk-jni/src/lib.rs @@ -22,6 +22,7 @@ mod events; mod funding; mod identity; mod mnemonic; +mod multiple_choice_proposals; mod parse_state_transition; mod persistence; mod pubkey_rows; diff --git a/packages/rs-unified-sdk-jni/src/multiple_choice_proposals.rs b/packages/rs-unified-sdk-jni/src/multiple_choice_proposals.rs new file mode 100644 index 00000000000..892a9a78730 --- /dev/null +++ b/packages/rs-unified-sdk-jni/src/multiple_choice_proposals.rs @@ -0,0 +1,812 @@ +//! JNI exports for multiple choice proposals (protocol version 15): questions whose answers +//! are the choices entered for them, as `multipleChoiceProposal` and `choice` documents of +//! the decision proposals system contract. Each export marshals ONE C function: a +//! `dash_sdk_multiple_choice_proposal_*` function of `rs-sdk-ffi` (the reads, the two amounts +//! and the masternode vote), or `platform_wallet_multiple_choice_proposal_create` / `_edit` / +//! `_enter_choice` of `platform-wallet-ffi` (the writes, which the platform wallet builds, +//! signs, broadcasts and confirms itself). It reads the JVM arguments, calls the C function, +//! copies the result into a JVM value and frees every Rust allocation the result carried +//! before returning. +//! +//! Errors and argument checks follow `crate::decision_proposals`, whose marshalling helpers +//! these exports share: a `DashSDKResult` error and a `PlatformWalletFFIResult` error each +//! throw `DashSDKException` by their crate's convention, and only an argument the JVM value +//! cannot carry into the C type (a null required string, a byte array of the wrong length, a +//! number out of the C type's range) is refused here, with code 1 (`InvalidParameter`). +//! +//! Kotlin counterpart: `org.dashfoundation.dashsdk.ffi.MultipleChoiceProposalsNative`. + +use crate::decision_proposals::{ + c_ptr, is_byte_array_of_len, read_bytes32, read_cstring, read_key32_zeroizing, + read_optional_cstring, string_or_null, take_wallet_json, to_unsigned, +}; +use crate::results::take_error; +use crate::support::{guard, net_from_ord, take_pwffi_error, throw_sdk_exception}; +use jni::objects::{JByteArray, JClass, JString}; +use jni::sys::{jboolean, jbyte, jint, jlong, jstring}; +use jni::JNIEnv; +use platform_wallet_ffi::handle::Handle; +use platform_wallet_ffi::{ + platform_wallet_multiple_choice_proposal_create, platform_wallet_multiple_choice_proposal_edit, + platform_wallet_multiple_choice_proposal_enter_choice, ChoiceParamsFFI, DescriptionDocumentFFI, + MultipleChoiceProposalEditFFI, MultipleChoiceProposalParamsFFI, +}; +use rs_sdk_ffi::{ + dash_sdk_multiple_choice_proposal_cast_vote, dash_sdk_multiple_choice_proposal_fetch, + dash_sdk_multiple_choice_proposal_get_choice_fund_to_join, + dash_sdk_multiple_choice_proposal_get_kept_choice, + dash_sdk_multiple_choice_proposal_get_masternode_vote, + dash_sdk_multiple_choice_proposal_get_processing_fee, + dash_sdk_multiple_choice_proposal_get_vote, + dash_sdk_multiple_choice_proposal_list_by_created_at, + dash_sdk_multiple_choice_proposal_list_by_owner, SDKHandle, SignerHandle, +}; +use std::ffi::CString; +use std::os::raw::c_char; +use std::ptr; + +// ── Marshalling helpers ────────────────────────────────────────────────── + +/// Read a nullable 32-byte array. +/// +/// `Some(None)` for a null array, `Some(Some(_))` for one of 32 bytes, and `None` after +/// throwing for any other length (the caller bails out). +fn read_optional_bytes32( + env: &mut JNIEnv, + arr: &JByteArray, + field: &str, +) -> Option> { + if arr.is_null() { + return Some(None); + } + read_bytes32(env, arr, field).map(Some) +} + +/// The three parts of a description document as the JVM handed them over, each absent when +/// its argument was null. They are kept here for as long as the C struct points into them. +struct DescriptionDocumentArgs { + id: Option<[u8; 32]>, + contract_id: Option<[u8; 32]>, + document_type: Option, +} + +impl DescriptionDocumentArgs { + /// Read the three arguments; `None` after throwing for one the C type cannot carry. + fn read( + env: &mut JNIEnv, + id: &JByteArray, + contract_id: &JByteArray, + document_type: &JString, + ) -> Option { + Some(Self { + id: read_optional_bytes32(env, id, "descriptionDocumentId")?, + contract_id: read_optional_bytes32(env, contract_id, "descriptionDocumentContractId")?, + document_type: read_optional_cstring(env, document_type, "descriptionDocumentType")?, + }) + } + + /// The C struct pointing at these parts: `None` (a null `description_document`) when all + /// three are absent, and otherwise a struct whose pointer is null for each absent part, + /// which the platform wallet refuses. + fn as_ffi(&self) -> Option { + if self.id.is_none() && self.contract_id.is_none() && self.document_type.is_none() { + return None; + } + Some(DescriptionDocumentFFI { + id: self.id.as_ref().map_or(ptr::null(), |id| id.as_ptr()), + contract_id: self + .contract_id + .as_ref() + .map_or(ptr::null(), |contract_id| contract_id.as_ptr()), + document_type: c_ptr(&self.document_type), + }) + } +} + +/// The pointer the C structs take for an optional description document: null for `None`. +fn description_document_ptr( + described: &Option, +) -> *const DescriptionDocumentFFI { + described + .as_ref() + .map_or(ptr::null(), |described| described as *const _) +} + +/// Write the id a paid create handed back into `out_id`, a `byte[32]` checked before the +/// create. Throws and returns `false` when the write still fails, with a message that says +/// `what` exists so that a caller does not retry a paid create. +fn write_created_id(env: &mut JNIEnv, out_id: &JByteArray, id: [u8; 32], what: &str) -> bool { + let id = id.map(|b| b as jbyte); + if env.set_byte_array_region(out_id, 0, &id).is_err() { + let _ = env.exception_clear(); + throw_sdk_exception( + env, + 99, + &format!("{what} was created, but its id could not be returned"), + ); + return false; + } + true +} + +// ── Create, edit and enter a choice (platform wallet) ──────────────────── + +/// Create + broadcast a multiple choice proposal of `ownerId`, signed via `signerHandle`: +/// the JNI bridge over `platform_wallet_multiple_choice_proposal_create`. The wallet builds +/// the proposal, picks the signing key itself, broadcasts and waits for Platform to confirm; +/// Platform charges the owner the multiple choice proposal processing fee on top of the fees. +/// +/// The description document is its three arguments together, all null for none; `url` may be +/// null (no url). `outProposalId` must be a non-null `byte[32]`, checked before anything is +/// broadcast so that the id of a paid create can always be written back; it receives the +/// proposal's id. +/// +/// Returns the confirmed document's canonical JSON, its Rust string freed here. Null after +/// throwing; a refusal by Platform carries its consensus code. +#[no_mangle] +#[allow(clippy::too_many_arguments)] +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_MultipleChoiceProposalsNative_create( + mut env: JNIEnv, + _class: JClass, + wallet_handle: jlong, + owner_id: JByteArray, + title: JString, + description_document_id: JByteArray, + description_document_contract_id: JByteArray, + description_document_type: JString, + url: JString, + open: jboolean, + signer_handle: jlong, + out_proposal_id: JByteArray, +) -> jstring { + guard(&mut env, ptr::null_mut(), |env| { + // Checked before the paid create: once it succeeded, writing the id back into a + // validated array allocates nothing and cannot go out of bounds. + if !is_byte_array_of_len(env, &out_proposal_id, 32) { + throw_sdk_exception(env, 1, "outProposalId must be a non-null byte[32]"); + return ptr::null_mut(); + } + let Some(owner) = read_bytes32(env, &owner_id, "ownerId") else { + return ptr::null_mut(); + }; + let Some(title) = read_cstring(env, &title, "title") else { + return ptr::null_mut(); + }; + let Some(described) = DescriptionDocumentArgs::read( + env, + &description_document_id, + &description_document_contract_id, + &description_document_type, + ) else { + return ptr::null_mut(); + }; + let Some(url) = read_optional_cstring(env, &url, "url") else { + return ptr::null_mut(); + }; + + let described = described.as_ffi(); + let params = MultipleChoiceProposalParamsFFI { + title: title.as_ptr(), + description_document: description_document_ptr(&described), + url: c_ptr(&url), + open: open != 0, + }; + let mut proposal_id = [0u8; 32]; + let mut out_json: *mut c_char = ptr::null_mut(); + // SAFETY: `owner` and `proposal_id` are 32 bytes, `params` and everything it points + // to outlive the call, and the signer handle is the Kotlin manager's live signer. + let result = unsafe { + platform_wallet_multiple_choice_proposal_create( + wallet_handle as Handle, + owner.as_ptr(), + ¶ms, + signer_handle as *mut SignerHandle, + proposal_id.as_mut_ptr(), + &mut out_json, + ) + }; + if take_pwffi_error(env, result) { + return ptr::null_mut(); + } + // SAFETY: on success `out_json` is the wallet's string, freed by this call only. + let Some(json) = + (unsafe { take_wallet_json(env, out_json, "multiple choice proposal create") }) + else { + return ptr::null_mut(); + }; + if !write_created_id( + env, + &out_proposal_id, + proposal_id, + "the multiple choice proposal", + ) { + return ptr::null_mut(); + } + env.new_string(json) + .map(|s| s.into_raw()) + .unwrap_or(ptr::null_mut()) + }) +} + +/// Give the multiple choice proposal `proposalId` of `ownerId` what the arguments change and +/// broadcast the replace, signed via `signerHandle`: the JNI bridge over +/// `platform_wallet_multiple_choice_proposal_edit`. The wallet reads the proposal once, edits +/// it at the revision after the one read and picks the signing key as the create does; if +/// another edit landed in between, Platform refuses this one (consensus code 40106) rather +/// than overwrite it. +/// +/// `title` and `url` null keep their value, and so do the three description document +/// arguments when all are null; `removeDescriptionDocument` and `removeUrl` remove theirs +/// (the wallet refuses either together with a new value). `ownerId` and `proposalId` are +/// 32-byte ids. +/// +/// Returns the confirmed document's canonical JSON at its new revision, its Rust string +/// freed here. Null after throwing; a proposal that does not exist is the wallet's +/// `NotFound`. +#[no_mangle] +#[allow(clippy::too_many_arguments)] +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_MultipleChoiceProposalsNative_edit( + mut env: JNIEnv, + _class: JClass, + wallet_handle: jlong, + owner_id: JByteArray, + proposal_id: JByteArray, + title: JString, + description_document_id: JByteArray, + description_document_contract_id: JByteArray, + description_document_type: JString, + remove_description_document: jboolean, + url: JString, + remove_url: jboolean, + signer_handle: jlong, +) -> jstring { + guard(&mut env, ptr::null_mut(), |env| { + let Some(owner) = read_bytes32(env, &owner_id, "ownerId") else { + return ptr::null_mut(); + }; + let Some(proposal) = read_bytes32(env, &proposal_id, "proposalId") else { + return ptr::null_mut(); + }; + let Some(title) = read_optional_cstring(env, &title, "title") else { + return ptr::null_mut(); + }; + let Some(described) = DescriptionDocumentArgs::read( + env, + &description_document_id, + &description_document_contract_id, + &description_document_type, + ) else { + return ptr::null_mut(); + }; + let Some(url) = read_optional_cstring(env, &url, "url") else { + return ptr::null_mut(); + }; + + let described = described.as_ffi(); + let edit = MultipleChoiceProposalEditFFI { + title: c_ptr(&title), + description_document: description_document_ptr(&described), + remove_description_document: remove_description_document != 0, + url: c_ptr(&url), + remove_url: remove_url != 0, + }; + let mut out_json: *mut c_char = ptr::null_mut(); + // SAFETY: `owner` and `proposal` are 32 bytes, `edit` and everything it points to + // outlive the call, and the signer handle is the Kotlin manager's live signer. + let result = unsafe { + platform_wallet_multiple_choice_proposal_edit( + wallet_handle as Handle, + owner.as_ptr(), + proposal.as_ptr(), + &edit, + signer_handle as *mut SignerHandle, + &mut out_json, + ) + }; + if take_pwffi_error(env, result) { + return ptr::null_mut(); + } + // SAFETY: on success `out_json` is the wallet's string, freed by this call only. + let Some(json) = + (unsafe { take_wallet_json(env, out_json, "multiple choice proposal edit") }) + else { + return ptr::null_mut(); + }; + env.new_string(json) + .map(|s| s.into_raw()) + .unwrap_or(ptr::null_mut()) + }) +} + +/// Enter a choice of `ownerId` for the multiple choice proposal `proposalId` and broadcast +/// it, signed via `signerHandle`: the JNI bridge over +/// `platform_wallet_multiple_choice_proposal_enter_choice`. The wallet builds the choice, +/// whose put states the fund of the contest among the proposal's choices (paid by the owner +/// on top of the fees), picks the signing key, broadcasts and waits for Platform to confirm. +/// +/// `description` may be null (none). `outChoiceId` must be a non-null `byte[32]`, checked +/// before anything is broadcast; it receives the choice's id, the id a masternode vote +/// towards it names. +/// +/// Returns the confirmed document's canonical JSON, its Rust string freed here. Null after +/// throwing; a refusal by Platform carries its consensus code. +#[no_mangle] +#[allow(clippy::too_many_arguments)] +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_MultipleChoiceProposalsNative_enterChoice( + mut env: JNIEnv, + _class: JClass, + wallet_handle: jlong, + owner_id: JByteArray, + proposal_id: JByteArray, + title: JString, + description: JString, + signer_handle: jlong, + out_choice_id: JByteArray, +) -> jstring { + guard(&mut env, ptr::null_mut(), |env| { + // Checked before the paid put, as the create checks its out-array. + if !is_byte_array_of_len(env, &out_choice_id, 32) { + throw_sdk_exception(env, 1, "outChoiceId must be a non-null byte[32]"); + return ptr::null_mut(); + } + let Some(owner) = read_bytes32(env, &owner_id, "ownerId") else { + return ptr::null_mut(); + }; + let Some(proposal) = read_bytes32(env, &proposal_id, "proposalId") else { + return ptr::null_mut(); + }; + let Some(title) = read_cstring(env, &title, "title") else { + return ptr::null_mut(); + }; + let Some(description) = read_optional_cstring(env, &description, "description") else { + return ptr::null_mut(); + }; + + let params = ChoiceParamsFFI { + title: title.as_ptr(), + description: c_ptr(&description), + }; + let mut choice_id = [0u8; 32]; + let mut out_json: *mut c_char = ptr::null_mut(); + // SAFETY: `owner`, `proposal` and `choice_id` are 32 bytes, `params` and the strings + // it points to outlive the call, and the signer handle is the Kotlin manager's live + // signer. + let result = unsafe { + platform_wallet_multiple_choice_proposal_enter_choice( + wallet_handle as Handle, + owner.as_ptr(), + proposal.as_ptr(), + ¶ms, + signer_handle as *mut SignerHandle, + choice_id.as_mut_ptr(), + &mut out_json, + ) + }; + if take_pwffi_error(env, result) { + return ptr::null_mut(); + } + // SAFETY: on success `out_json` is the wallet's string, freed by this call only. + let Some(json) = + (unsafe { take_wallet_json(env, out_json, "multiple choice proposal enter choice") }) + else { + return ptr::null_mut(); + }; + if !write_created_id(env, &out_choice_id, choice_id, "the choice") { + return ptr::null_mut(); + } + env.new_string(json) + .map(|s| s.into_raw()) + .unwrap_or(ptr::null_mut()) + }) +} + +// ── Reads ──────────────────────────────────────────────────────────────── + +/// A multiple choice proposal by id as the proposal JSON object +/// (`dash_sdk_multiple_choice_proposal_fetch`); null when there is none, and after throwing. +#[no_mangle] +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_MultipleChoiceProposalsNative_fetch( + mut env: JNIEnv, + _class: JClass, + sdk: jlong, + proposal_id: JString, +) -> jstring { + guard(&mut env, ptr::null_mut(), |env| { + let Some(id) = read_cstring(env, &proposal_id, "proposalId") else { + return ptr::null_mut(); + }; + unsafe { + let result = + dash_sdk_multiple_choice_proposal_fetch(sdk as *const SDKHandle, id.as_ptr()); + string_or_null(env, result) + } + }) +} + +/// One page of an identity's multiple choice proposals in filing order +/// (`dash_sdk_multiple_choice_proposal_list_by_owner`), as a JSON array of proposals. `limit` +/// 0 is Platform's cap of 100; `startAfter` (base58) is null for the first page. Null after +/// throwing. +#[no_mangle] +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_MultipleChoiceProposalsNative_listByOwner( + mut env: JNIEnv, + _class: JClass, + sdk: jlong, + owner_id: JString, + limit: jint, + start_after: JString, +) -> jstring { + guard(&mut env, ptr::null_mut(), |env| { + let Some(owner) = read_cstring(env, &owner_id, "ownerId") else { + return ptr::null_mut(); + }; + let Some(limit) = to_unsigned(env, limit.into(), "limit") else { + return ptr::null_mut(); + }; + let Some(start_after) = read_optional_cstring(env, &start_after, "startAfter") else { + return ptr::null_mut(); + }; + unsafe { + let result = dash_sdk_multiple_choice_proposal_list_by_owner( + sdk as *const SDKHandle, + owner.as_ptr(), + limit, + c_ptr(&start_after), + ); + string_or_null(env, result) + } + }) +} + +/// One page of every multiple choice proposal, newest first +/// (`dash_sdk_multiple_choice_proposal_list_by_created_at`), as a JSON array of proposals. +/// Paging as for `listByOwner`. Null after throwing. +#[no_mangle] +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_MultipleChoiceProposalsNative_listByCreatedAt( + mut env: JNIEnv, + _class: JClass, + sdk: jlong, + limit: jint, + start_after: JString, +) -> jstring { + guard(&mut env, ptr::null_mut(), |env| { + let Some(limit) = to_unsigned(env, limit.into(), "limit") else { + return ptr::null_mut(); + }; + let Some(start_after) = read_optional_cstring(env, &start_after, "startAfter") else { + return ptr::null_mut(); + }; + unsafe { + let result = dash_sdk_multiple_choice_proposal_list_by_created_at( + sdk as *const SDKHandle, + limit, + c_ptr(&start_after), + ); + string_or_null(env, result) + } + }) +} + +/// The vote among a proposal's choices as JSON (`dash_sdk_multiple_choice_proposal_get_vote`): +/// every choice with its tally, the other tallies, and how the vote ended once it did. Null +/// after throwing. +#[no_mangle] +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_MultipleChoiceProposalsNative_getVote( + mut env: JNIEnv, + _class: JClass, + sdk: jlong, + proposal_id: JString, +) -> jstring { + guard(&mut env, ptr::null_mut(), |env| { + let Some(id) = read_cstring(env, &proposal_id, "proposalId") else { + return ptr::null_mut(); + }; + unsafe { + let result = + dash_sdk_multiple_choice_proposal_get_vote(sdk as *const SDKHandle, id.as_ptr()); + string_or_null(env, result) + } + }) +} + +/// The choice a proposal's finished vote kept, as the choice JSON object +/// (`dash_sdk_multiple_choice_proposal_get_kept_choice`); null while the vote runs and when +/// it kept none, and after throwing. +#[no_mangle] +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_MultipleChoiceProposalsNative_getKeptChoice( + mut env: JNIEnv, + _class: JClass, + sdk: jlong, + proposal_id: JString, +) -> jstring { + guard(&mut env, ptr::null_mut(), |env| { + let Some(id) = read_cstring(env, &proposal_id, "proposalId") else { + return ptr::null_mut(); + }; + unsafe { + let result = dash_sdk_multiple_choice_proposal_get_kept_choice( + sdk as *const SDKHandle, + id.as_ptr(), + ); + string_or_null(env, result) + } + }) +} + +/// A masternode's answer in the vote among a proposal's choices, `{"choice", "choiceId"}` +/// (`dash_sdk_multiple_choice_proposal_get_masternode_vote`); null when it has not voted or +/// the vote ended, and after throwing. `voterProTxHash` is the 32-byte pro_tx_hash in wire +/// order, the same bytes `castVote` takes. +#[no_mangle] +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_MultipleChoiceProposalsNative_getMasternodeVote( + mut env: JNIEnv, + _class: JClass, + sdk: jlong, + voter_pro_tx_hash: JByteArray, + proposal_id: JString, +) -> jstring { + guard(&mut env, ptr::null_mut(), |env| { + let Some(pro_tx_hash) = read_bytes32(env, &voter_pro_tx_hash, "voterProTxHash") else { + return ptr::null_mut(); + }; + let Some(id) = read_cstring(env, &proposal_id, "proposalId") else { + return ptr::null_mut(); + }; + unsafe { + let result = dash_sdk_multiple_choice_proposal_get_masternode_vote( + sdk as *const SDKHandle, + pro_tx_hash.as_ptr(), + id.as_ptr(), + ); + string_or_null(env, result) + } + }) +} + +/// What creating one multiple choice proposal adds to the processing fee of its batch, in +/// credits as a decimal string, not JSON +/// (`dash_sdk_multiple_choice_proposal_get_processing_fee`). Null after throwing. +#[no_mangle] +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_MultipleChoiceProposalsNative_getProcessingFee( + mut env: JNIEnv, + _class: JClass, + sdk: jlong, +) -> jstring { + guard(&mut env, ptr::null_mut(), |env| unsafe { + let result = dash_sdk_multiple_choice_proposal_get_processing_fee(sdk as *const SDKHandle); + string_or_null(env, result) + }) +} + +/// The fund a choice entered now for a proposal pays, in credits as a decimal string, not +/// JSON (`dash_sdk_multiple_choice_proposal_get_choice_fund_to_join`). Null after throwing. +#[no_mangle] +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_MultipleChoiceProposalsNative_getChoiceFundToJoin( + mut env: JNIEnv, + _class: JClass, + sdk: jlong, + proposal_id: JString, +) -> jstring { + guard(&mut env, ptr::null_mut(), |env| { + let Some(id) = read_cstring(env, &proposal_id, "proposalId") else { + return ptr::null_mut(); + }; + unsafe { + let result = dash_sdk_multiple_choice_proposal_get_choice_fund_to_join( + sdk as *const SDKHandle, + id.as_ptr(), + ); + string_or_null(env, result) + } + }) +} + +// ── Vote ───────────────────────────────────────────────────────────────── + +/// Vote among a multiple choice proposal's choices for a masternode and wait for the +/// response (`dash_sdk_multiple_choice_proposal_cast_vote`). +/// +/// * `voteChoice` - `0` for the choice `choiceId` names, `1` none of the choices, `2` +/// abstain; rs-sdk-ffi refuses any other value. A value outside `u8` is refused here +/// rather than wrapped onto a valid answer. +/// * `choiceId` - the document id (base58) of the choice voted for, null for the answers +/// that name none; rs-sdk-ffi refuses a missing or a superfluous one. +/// * `voterProTxHash` / `votingPrivateKey` - each a 32-byte `byte[]`; the pro_tx_hash in wire +/// order, as for `DecisionProposalsNative.castVote`. The key is read through a zeroizing +/// buffer. +/// * `networkOrd` - `Network.ffiValue`, used for the signer's WIF encoding only. +/// +/// Returns nothing on success; throws on error. A vote from a wallet that is not a +/// masternode is refused by Platform (no voter identity), the expected outcome. +#[no_mangle] +#[allow(clippy::too_many_arguments)] +pub extern "system" fn Java_org_dashfoundation_dashsdk_ffi_MultipleChoiceProposalsNative_castVote( + mut env: JNIEnv, + _class: JClass, + sdk: jlong, + proposal_id: JString, + vote_choice: jint, + choice_id: JString, + voter_pro_tx_hash: JByteArray, + voting_private_key: JByteArray, + network_ord: jint, +) { + guard(&mut env, (), |env| { + let Some(id) = read_cstring(env, &proposal_id, "proposalId") else { + return; + }; + let Some(choice) = to_unsigned(env, vote_choice.into(), "voteChoice") else { + return; + }; + let Some(choice_id) = read_optional_cstring(env, &choice_id, "choiceId") else { + return; + }; + let Some(pro_tx_hash) = read_bytes32(env, &voter_pro_tx_hash, "voterProTxHash") else { + return; + }; + let Some(voting_key) = read_key32_zeroizing(env, &voting_private_key, "votingPrivateKey") + else { + return; + }; + let result = unsafe { + dash_sdk_multiple_choice_proposal_cast_vote( + sdk as *const SDKHandle, + id.as_ptr(), + choice, + c_ptr(&choice_id), + pro_tx_hash.as_ptr(), + voting_key.as_ptr(), + net_from_ord(network_ord), + ) + }; + // Success carries no payload; take_error throws and frees on error. + unsafe { take_error(env, &result) }; + }) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::decision_proposals::tests::kotlin_signature_in; + use std::ffi::CStr; + + const MULTIPLE_CHOICE_PROPOSALS_NATIVE_KT: &str = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/MultipleChoiceProposalsNative.kt" + )); + + /// The parameter types and the return type of `external fun {name}(...)` in + /// `MultipleChoiceProposalsNative.kt`. + fn kotlin_signature(name: &str) -> (Vec, String) { + kotlin_signature_in(MULTIPLE_CHOICE_PROPOSALS_NATIVE_KT, name) + } + + fn types(types: [&str; N]) -> Vec { + types.map(String::from).to_vec() + } + + /// JNI binds an export by its name alone: a Kotlin declaration whose parameters drifted + /// from the export's would hand it the wrong JVM values at run time, which only an + /// instrumented test would otherwise catch. The wallet writes take the most arguments, + /// and the last of the two that create a document is the id out-array. + #[test] + fn should_declare_the_multiple_choice_wallet_writes_as_the_exports_take_them() { + assert_eq!( + kotlin_signature("create"), + ( + types([ + "Long", // wallet_handle + "ByteArray", // owner_id + "String", // title + "ByteArray?", // description_document_id + "ByteArray?", // description_document_contract_id + "String?", // description_document_type + "String?", // url + "Boolean", // open + "Long", // signer_handle + "ByteArray", // out_proposal_id + ]), + "String".to_string() + ) + ); + assert_eq!( + kotlin_signature("edit"), + ( + types([ + "Long", // wallet_handle + "ByteArray", // owner_id + "ByteArray", // proposal_id + "String?", // title + "ByteArray?", // description_document_id + "ByteArray?", // description_document_contract_id + "String?", // description_document_type + "Boolean", // remove_description_document + "String?", // url + "Boolean", // remove_url + "Long", // signer_handle + ]), + "String".to_string() + ) + ); + assert_eq!( + kotlin_signature("enterChoice"), + ( + types([ + "Long", // wallet_handle + "ByteArray", // owner_id + "ByteArray", // proposal_id + "String", // title + "String?", // description + "Long", // signer_handle + "ByteArray", // out_choice_id + ]), + "String".to_string() + ) + ); + } + + /// The vote takes the choice id between the answer and the masternode's credentials. + #[test] + fn should_declare_the_multiple_choice_vote_as_the_export_takes_it() { + assert_eq!( + kotlin_signature("castVote"), + ( + types([ + "Long", // sdk + "String", // proposal_id + "Int", // vote_choice + "String?", // choice_id + "ByteArray", // voter_pro_tx_hash + "ByteArray", // voting_private_key + "Int", // network_ord + ]), + "Unit".to_string() + ) + ); + } + + /// No description document is a null struct pointer, never a struct of null fields: the + /// platform wallet reads the first as "none" and refuses the second. + #[test] + fn should_pass_no_multiple_choice_description_document_as_a_null_pointer() { + let absent = DescriptionDocumentArgs { + id: None, + contract_id: None, + document_type: None, + }; + let described = absent.as_ffi(); + assert!(described.is_none()); + assert!(description_document_ptr(&described).is_null()); + } + + #[test] + fn should_point_the_multiple_choice_description_document_at_each_part_given() { + let complete = DescriptionDocumentArgs { + id: Some([5; 32]), + contract_id: Some([6; 32]), + document_type: Some(CString::new("post").expect("no NUL")), + }; + let described = complete.as_ffi(); + let pointer = description_document_ptr(&described); + assert!(!pointer.is_null()); + // SAFETY: `pointer` points into `described`, whose fields point into `complete`; + // both are alive here. + unsafe { + let read = &*pointer; + assert_eq!(std::slice::from_raw_parts(read.id, 32), [5u8; 32]); + assert_eq!(std::slice::from_raw_parts(read.contract_id, 32), [6u8; 32]); + assert_eq!(CStr::from_ptr(read.document_type).to_bytes(), b"post"); + } + + // A part left out reaches the platform wallet as a null field, which it refuses. + let partial = DescriptionDocumentArgs { + id: Some([5; 32]), + contract_id: None, + document_type: None, + }; + let described = partial.as_ffi().expect("a struct for a partial document"); + assert!(!described.id.is_null()); + assert!(described.contract_id.is_null()); + assert!(described.document_type.is_null()); + } +} diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWalletMultipleChoiceProposals.swift b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWalletMultipleChoiceProposals.swift new file mode 100644 index 00000000000..08906713af4 --- /dev/null +++ b/packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWalletMultipleChoiceProposals.swift @@ -0,0 +1,261 @@ +import Foundation +import DashSDKFFI + +// MARK: - Multiple choice proposals (protocol version 15) +// +// Creating and editing a multiple choice proposal and entering a choice are +// platform wallet operations (`platform_wallet_multiple_choice_proposal_create`, +// `_edit` and `_enter_choice`, over +// `IdentityWallet::create_multiple_choice_proposal_with_signer`, +// `edit_multiple_choice_proposal_with_signer` and `enter_choice_with_signer`). +// rs-sdk and the wallet decide everything: the documents' properties, the +// contest fund a choice states, the signing key, refusing an edit that +// changes nothing, and the revision an edit is put at. These wrappers marshal +// the arguments in and the confirmed document out; the signing key never +// crosses into Swift logic, the `KeychainSigner` trampoline services the +// signature on demand. + +extension ManagedPlatformWallet { + /// Create + broadcast a multiple choice proposal of `ownerIdentityId` + /// asking what `params` says. Returns the proposal's 32-byte id and the + /// confirmed document's canonical JSON (the shape + /// ``createDocument(ownerIdentityId:contractId:documentType:propertiesJSON:signer:maxContestFund:)`` + /// returns) once Platform confirms the transition. + /// + /// rs-sdk builds the proposal. Platform charges the owner the multiple + /// choice proposal processing fee + /// (``SDK/multipleChoiceProposalProcessingFee()``, 0.2 Dash) on top of + /// the fees; the create does not state it. The wallet signs with the + /// owner's first AUTHENTICATION + ECDSA key at a security level the + /// `multipleChoiceProposal` type accepts that `signer` holds. Platform + /// judges the title, the description document and the url; nothing is + /// checked here. A network below protocol version 15 has no decision + /// proposals, which is an error. + /// + /// Lifetime contract: as `createDocument`, the `signer` is pinned with + /// `withExtendedLifetime` across the synchronous FFI call (Rust holds a + /// `passUnretained` ctx pointer to it), and so is the wallet, whose + /// deinit destroys the handle the call uses. + /// + /// - Parameters: + /// - ownerIdentityId: The proposer's 32-byte identity id. + /// - params: The question. + /// - signer: Signs the create. + /// - Throws: `PlatformWalletError.invalidParameter` for an id that is not + /// 32 bytes or a string holding a NUL character; a refusal by Platform + /// as `PlatformWalletError.consensusRejection`, with its consensus code. + public func createMultipleChoiceProposal( + ownerIdentityId: Identifier, + params: MultipleChoiceProposalParams, + signer: KeychainSigner + ) async throws -> (Identifier, String) { + // The FFI reads exactly 32 bytes of the identifier. + guard ownerIdentityId.count == 32 else { + throw PlatformWalletError.invalidParameter("ownerIdentityId must be exactly 32 bytes") + } + let handle = self.handle + let signerHandle = signer.handle + let ownerBytes = [UInt8](ownerIdentityId) + return try await Task.detached(priority: .userInitiated) { [self] in + var proposalIdBytes = [UInt8](repeating: 0, count: 32) + // Receives an owned canonical-document JSON C string on success; + // freed with `platform_wallet_string_free` below. + var documentJsonPtr: UnsafeMutablePointer? = nil + defer { if let p = documentJsonPtr { platform_wallet_string_free(p) } } + + // Pin the wallet and `signer` for the whole FFI call (see + // `createDocument` for why a bare `_ = signer` is unreliable + // under -O): a wallet deinit mid-call would destroy the handle + // the FFI is still using. Rust reads the params synchronously + // inside the call, so the `withFFI` scope is long enough. + let result = try withExtendedLifetime((self, signer)) { + try ownerBytes.withUnsafeBufferPointer { ownerBp -> PlatformWalletFFIResult in + try params.withFFI { paramsPtr in + proposalIdBytes.withUnsafeMutableBufferPointer { outBp in + platform_wallet_multiple_choice_proposal_create( + handle, + ownerBp.baseAddress!, + paramsPtr, + signerHandle, + outBp.baseAddress!, + &documentJsonPtr + ) + } + } + } + } + + try result.check() + // On success the Rust side always writes the JSON; a null pointer + // is an FFI contract violation, not an empty proposal. + guard let jsonPtr = documentJsonPtr else { + throw PlatformWalletError.walletOperation( + "multiple_choice_proposal_create returned no canonical document JSON" + ) + } + return (Data(proposalIdBytes), String(cString: jsonPtr)) + }.value + } + + /// Give the multiple choice proposal `proposalId` of `ownerIdentityId` + /// what `edit` changes, and broadcast the replace. Returns the confirmed + /// document's canonical JSON, at its new revision, once Platform confirms + /// the transition. + /// + /// The wallet reads the proposal once, applies the edit with rs-sdk + /// (which refuses an edit that changes nothing) and puts it at the + /// revision after the one read, signed with a key chosen as + /// ``createMultipleChoiceProposal(ownerIdentityId:params:signer:)`` + /// chooses it. It never reads the proposal again before the put: if + /// another edit lands in between, Platform refuses this one instead of + /// overwriting it (consensus code 40106, `InvalidDocumentRevisionError`), + /// and the caller reads the proposal again before offering the edit anew. + /// Platform also refuses an edit more than two hours after the proposal + /// was created, and one that leaves it with neither a description + /// document nor a url. + /// + /// Lifetime contract: the wallet and the `signer` are pinned with + /// `withExtendedLifetime` across the synchronous FFI call, as the create + /// pins them. + /// + /// - Parameters: + /// - ownerIdentityId: The proposer's 32-byte identity id. + /// - proposalId: The proposal's 32-byte id. + /// - edit: What changes. + /// - signer: Signs the replace. + /// - Throws: `PlatformWalletError.notFound` when there is no such + /// proposal; `PlatformWalletError.invalidParameter` for an id that is + /// not 32 bytes, a string holding a NUL character, a proposal of another + /// identity or an edit that changes nothing; a refusal by Platform as + /// `PlatformWalletError.consensusRejection`, with its consensus code. + public func editMultipleChoiceProposal( + ownerIdentityId: Identifier, + proposalId: Identifier, + edit: MultipleChoiceProposalEdit, + signer: KeychainSigner + ) async throws -> String { + // The FFI reads exactly 32 bytes of each identifier. + guard ownerIdentityId.count == 32 else { + throw PlatformWalletError.invalidParameter("ownerIdentityId must be exactly 32 bytes") + } + guard proposalId.count == 32 else { + throw PlatformWalletError.invalidParameter("proposalId must be exactly 32 bytes") + } + let handle = self.handle + let signerHandle = signer.handle + let ownerBytes = [UInt8](ownerIdentityId) + let proposalBytes = [UInt8](proposalId) + return try await Task.detached(priority: .userInitiated) { [self] in + var documentJsonPtr: UnsafeMutablePointer? = nil + defer { if let p = documentJsonPtr { platform_wallet_string_free(p) } } + + // Pin the wallet and `signer` for the whole FFI call, as the + // create does. + let result = try withExtendedLifetime((self, signer)) { + try ownerBytes.withUnsafeBufferPointer { ownerBp -> PlatformWalletFFIResult in + try proposalBytes.withUnsafeBufferPointer { proposalBp -> PlatformWalletFFIResult in + try edit.withFFI { editPtr in + platform_wallet_multiple_choice_proposal_edit( + handle, + ownerBp.baseAddress!, + proposalBp.baseAddress!, + editPtr, + signerHandle, + &documentJsonPtr + ) + } + } + } + } + + try result.check() + guard let jsonPtr = documentJsonPtr else { + throw PlatformWalletError.walletOperation( + "multiple_choice_proposal_edit returned no canonical document JSON" + ) + } + return String(cString: jsonPtr) + }.value + } + + /// Enter the choice `params` describes, owned by `ownerIdentityId`, for + /// the multiple choice proposal `proposalId`, and broadcast it. Returns + /// the choice's 32-byte id (the id a masternode vote for it names) and + /// the confirmed document's canonical JSON once Platform confirms the + /// transition. + /// + /// rs-sdk builds the choice; its put reads the fund of the contest among + /// the proposal's choices just before it is signed and states it + /// (``SDK/multipleChoiceProposalChoiceFundToJoin(proposalId:)`` reads the + /// same amount), which the owner pays on top of the fees. The first + /// choice opens the vote. Platform refuses a choice for a proposal that + /// is not open from anyone but its owner, and one entered once the vote's + /// join window closed. A choice is never edited. + /// + /// Lifetime contract: the wallet and the `signer` are pinned with + /// `withExtendedLifetime` across the synchronous FFI call, as the create + /// pins them. + /// + /// - Parameters: + /// - ownerIdentityId: The 32-byte id of the identity entering the + /// choice. + /// - proposalId: The proposal's 32-byte id. + /// - params: The answer. + /// - signer: Signs the create. + /// - Throws: `PlatformWalletError.invalidParameter` for an id that is not + /// 32 bytes or a string holding a NUL character; a refusal by Platform + /// as `PlatformWalletError.consensusRejection`, with its consensus code. + public func enterMultipleChoiceProposalChoice( + ownerIdentityId: Identifier, + proposalId: Identifier, + params: ProposalChoiceParams, + signer: KeychainSigner + ) async throws -> (Identifier, String) { + // The FFI reads exactly 32 bytes of each identifier. + guard ownerIdentityId.count == 32 else { + throw PlatformWalletError.invalidParameter("ownerIdentityId must be exactly 32 bytes") + } + guard proposalId.count == 32 else { + throw PlatformWalletError.invalidParameter("proposalId must be exactly 32 bytes") + } + let handle = self.handle + let signerHandle = signer.handle + let ownerBytes = [UInt8](ownerIdentityId) + let proposalBytes = [UInt8](proposalId) + return try await Task.detached(priority: .userInitiated) { [self] in + var choiceIdBytes = [UInt8](repeating: 0, count: 32) + var documentJsonPtr: UnsafeMutablePointer? = nil + defer { if let p = documentJsonPtr { platform_wallet_string_free(p) } } + + // Pin the wallet and `signer` for the whole FFI call, as the + // create does. + let result = try withExtendedLifetime((self, signer)) { + try ownerBytes.withUnsafeBufferPointer { ownerBp -> PlatformWalletFFIResult in + try proposalBytes.withUnsafeBufferPointer { proposalBp -> PlatformWalletFFIResult in + try params.withFFI { paramsPtr in + choiceIdBytes.withUnsafeMutableBufferPointer { outBp in + platform_wallet_multiple_choice_proposal_enter_choice( + handle, + ownerBp.baseAddress!, + proposalBp.baseAddress!, + paramsPtr, + signerHandle, + outBp.baseAddress!, + &documentJsonPtr + ) + } + } + } + } + } + + try result.check() + guard let jsonPtr = documentJsonPtr else { + throw PlatformWalletError.walletOperation( + "multiple_choice_proposal_enter_choice returned no canonical document JSON" + ) + } + return (Data(choiceIdBytes), String(cString: jsonPtr)) + }.value + } +} diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/Voting/MultipleChoiceProposal.swift b/packages/swift-sdk/Sources/SwiftDashSDK/Voting/MultipleChoiceProposal.swift new file mode 100644 index 00000000000..10c12acb943 --- /dev/null +++ b/packages/swift-sdk/Sources/SwiftDashSDK/Voting/MultipleChoiceProposal.swift @@ -0,0 +1,437 @@ +import Foundation +import DashSDKFFI + +// MARK: - Proposal + +/// A multiple choice proposal: a question an identity puts to the +/// masternodes, answered by the choices entered for it. Decoded from the JSON +/// every multiple choice proposal read returns +/// (`dash_sdk_multiple_choice_proposal_fetch` and the two listings). +public struct MultipleChoiceProposal: Decodable, Sendable, Equatable, Hashable, Identifiable { + /// The document a proposal points at for what is being decided. + public struct DescriptionDocument: Decodable, Sendable, Equatable, Hashable { + /// The document's id, base58. + public let id: String + /// The id of the contract it lives in, base58. + public let contractId: String + /// Its document type. + public let documentType: String + } + + /// The proposal's id, base58. + public let id: String + /// The proposer's identity id, base58. + public let ownerId: String + /// `nil` when the document does not carry it. + public let revision: UInt64? + /// Milliseconds since the Unix epoch; `nil` when the document does not + /// carry it. + public let createdAtMs: UInt64? + /// Milliseconds since the Unix epoch; `nil` when the document does not + /// carry it. + public let updatedAtMs: UInt64? + /// The question, in one line. + public let title: String + /// The document saying what is being decided; `nil` when it has none. + public let descriptionDocument: DescriptionDocument? + /// Where what is being decided is described or discussed; `nil` when it + /// has none. + public let url: String? + /// Whether anyone may enter choices; only the proposer may when `false`. + public let open: Bool + + private enum CodingKeys: String, CodingKey { + case id + case ownerId + case revision + case createdAtMs = "createdAt" + case updatedAtMs = "updatedAt" + case title + case descriptionDocument + case url + case open + } + + /// When the proposal was created, if the document carries it. + public var createdAt: Date? { createdAtMs.map(Date.init(millisecondsSince1970:)) } + /// When the proposal was last edited, if the document carries it. + public var updatedAt: Date? { updatedAtMs.map(Date.init(millisecondsSince1970:)) } +} + +// MARK: - Choice + +/// A choice entered for a multiple choice proposal: one answer the +/// masternodes may vote for. Decoded from the choice JSON +/// (`dash_sdk_multiple_choice_proposal_get_kept_choice`, and each running +/// choice of ``MultipleChoiceProposalVote``). +public struct ProposalChoice: Decodable, Sendable, Equatable, Hashable, Identifiable { + /// The choice's document id, base58: the id a vote for it names. + public let id: String + /// The identity that entered it, base58. + public let ownerId: String + /// The proposal it answers, base58. + public let proposalId: String + /// `nil` when the document does not carry it. + public let revision: UInt64? + /// Milliseconds since the Unix epoch; `nil` when the document does not + /// carry it. + public let createdAtMs: UInt64? + /// Milliseconds since the Unix epoch; `nil` when the document does not + /// carry it. + public let updatedAtMs: UInt64? + /// The answer, in one line. + public let title: String + /// What voting for the answer means; `nil` when it has none. + public let description: String? + + private enum CodingKeys: String, CodingKey { + case id + case ownerId + case proposalId + case revision + case createdAtMs = "createdAt" + case updatedAtMs = "updatedAt" + case title + case description + } + + /// When the choice was entered, if the document carries it. + public var createdAt: Date? { createdAtMs.map(Date.init(millisecondsSince1970:)) } +} + +// MARK: - Vote + +/// The vote among a multiple choice proposal's choices +/// (`dash_sdk_multiple_choice_proposal_get_vote`). +public struct MultipleChoiceProposalVote: Decodable, Sendable, Equatable { + /// One choice in the vote. + public struct ChoiceInVote: Decodable, Sendable, Equatable, Identifiable { + /// The choice's document id, base58: the id a vote for it names. + public let id: String + /// The choice while the vote runs; `nil` once it ended (the choices + /// not kept are gone, and the kept one is read with + /// ``SDK/multipleChoiceProposalKeptChoice(proposalId:)``). + public let choice: ProposalChoice? + /// The votes for it; `nil` when Platform does not report it. + public let voteTally: UInt32? + } + + /// How a finished vote ended. + public enum Outcome: String, Decodable, Sendable, Equatable { + /// The choice ``Result/keptChoiceId`` names was kept. + case keptChoice + /// The votes for none of the choices outnumbered the leading choice; + /// no choice was kept. + case noneOfTheChoices + /// No choice won; none was kept. + case noWinner + } + + /// The record of a finished vote. + public struct Result: Decodable, Sendable, Equatable { + public let outcome: Outcome + /// The kept choice's id, base58; `nil` unless ``outcome`` is + /// ``Outcome/keptChoice``. + public let keptChoiceId: String? + /// The block the vote was closed in. + public let finalizationBlock: PlatformBlockInfo + } + + /// Every choice, ordered by choice id; empty for a proposal no choice + /// was entered for. + public let choices: [ChoiceInVote] + /// The abstaining votes; `nil` when Platform does not report them. + public let abstainVoteTally: UInt32? + /// The votes for none of the choices; `nil` when Platform does not + /// report them. + public let noneOfTheChoicesVoteTally: UInt32? + /// How the vote ended; `nil` while it runs. + public let result: Result? +} + +/// A masternode's answer in the vote among a multiple choice proposal's +/// choices, as rs-sdk's `MultipleChoiceVoteChoice`. +/// +/// Decodes the masternode-answer JSON +/// (`dash_sdk_multiple_choice_proposal_get_masternode_vote`): +/// `{"choice": "choice" | "noneOfTheChoices" | "abstain", "choiceId": ...}`. +/// ``ffiTag`` and ``choiceId`` are the `vote_choice` byte and `choice_id` +/// string `dash_sdk_multiple_choice_proposal_cast_vote` takes. +public enum MultipleChoiceVoteChoice: Decodable, Sendable, Equatable, Hashable { + /// For the choice whose document id (base58) is `id`, not the id of the + /// identity that entered it. + case choice(id: String) + /// For none of the choices: keeps no choice when these votes outnumber + /// the leading choice. + case noneOfTheChoices + case abstain + + /// The `vote_choice` byte passed across the FFI. The C parameter is a + /// plain `uint8_t` with no enum in the header, so the three values are + /// mirrored here and must agree with `MultipleChoiceVoteChoiceFFI` in + /// `packages/rs-sdk-ffi/src/decision_proposal/multiple_choice/mod.rs`: + /// `Choice = 0`, `NoneOfTheChoices = 1`, `Abstain = 2`. + var ffiTag: UInt8 { + switch self { + case .choice: return 0 + case .noneOfTheChoices: return 1 + case .abstain: return 2 + } + } + + /// The choice voted for, base58; `nil` for the answers that name none + /// (the FFI requires a null `choice_id` then). + public var choiceId: String? { + guard case .choice(let id) = self else { return nil } + return id + } + + private enum CodingKeys: String, CodingKey { + case choice + case choiceId + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let name = try container.decode(String.self, forKey: .choice) + switch name { + case "choice": + self = .choice(id: try container.decode(String.self, forKey: .choiceId)) + case "noneOfTheChoices": + self = .noneOfTheChoices + case "abstain": + self = .abstain + default: + throw DecodingError.dataCorruptedError( + forKey: .choice, + in: container, + debugDescription: "Unknown multiple choice vote answer \(name)" + ) + } + } +} + +// MARK: - Params + +/// The document a new or edited multiple choice proposal points at +/// (`DescriptionDocumentFFI`). Platform judges whether it may be pointed at; +/// nothing is checked here. +public struct DescriptionDocumentParams: Sendable, Equatable { + /// The document's 32-byte id. + public var id: Identifier + /// The 32-byte id of the contract it lives in. + public var contractId: Identifier + /// Its document type. + public var documentType: String + + public init(id: Identifier, contractId: Identifier, documentType: String) { + self.id = id + self.contractId = contractId + self.documentType = documentType + } +} + +/// The question of a new multiple choice proposal, as +/// `ManagedPlatformWallet.createMultipleChoiceProposal` passes it on +/// (`MultipleChoiceProposalParamsFFI`). Platform judges every value when the +/// proposal is created; nothing is checked here. +public struct MultipleChoiceProposalParams: Sendable, Equatable { + /// The question, in one line. + public var title: String + /// The document saying what is being decided; `nil` for none. + public var descriptionDocument: DescriptionDocumentParams? + /// Where what is being decided is described or discussed; `nil` for + /// none. + public var url: String? + /// Whether anyone may enter choices; only the proposer may when `false`. + /// It never changes. + public var open: Bool + + public init( + title: String, + descriptionDocument: DescriptionDocumentParams? = nil, + url: String? = nil, + open: Bool + ) { + self.title = title + self.descriptionDocument = descriptionDocument + self.url = url + self.open = open + } +} + +/// What a stored multiple choice proposal changes to, as +/// `ManagedPlatformWallet.editMultipleChoiceProposal` passes it on +/// (`MultipleChoiceProposalEditFFI`). A field left `nil` (or `.keep`) keeps +/// its value. rs-sdk refuses an edit that changes nothing; Platform accepts +/// an edit only within its window after the proposal was created, and never +/// a change to whether it is open. +public struct MultipleChoiceProposalEdit: Sendable, Equatable { + /// What happens to an optional field. + public enum Change: Sendable, Equatable { + /// Keep the value as it is (or keep having none). + case keep + /// Set the value. + case set(Value) + /// Remove the value. + case remove + } + + /// The new title; `nil` keeps it. + public var title: String? + /// The description document change. + public var descriptionDocument: Change + /// The url change. + public var url: Change + + public init( + title: String? = nil, + descriptionDocument: Change = .keep, + url: Change = .keep + ) { + self.title = title + self.descriptionDocument = descriptionDocument + self.url = url + } +} + +/// An answer to enter for a multiple choice proposal, as +/// `ManagedPlatformWallet.enterMultipleChoiceProposalChoice` passes it on +/// (`ChoiceParamsFFI`). Platform judges every value; nothing is checked here. +public struct ProposalChoiceParams: Sendable, Equatable { + /// The answer, in one line. + public var title: String + /// What voting for the answer means; `nil` for none. + public var description: String? + + public init(title: String, description: String? = nil) { + self.title = title + self.description = description + } +} + +// MARK: - FFI marshalling + +/// Run `body` with `document` as a `DescriptionDocumentFFI`, or with `nil` +/// when `document` is `nil`. The FFI reads exactly 32 bytes through each id +/// pointer, so an id of another length is refused before any pointer is +/// made; the document type goes through ``withDecisionProposalCString(_:field:invalid:_:)``. +func withDescriptionDocumentFFI( + _ document: DescriptionDocumentParams?, + _ body: (UnsafePointer?) throws -> R +) throws -> R { + guard let document else { return try body(nil) } + guard document.id.count == 32 else { + throw PlatformWalletError.invalidParameter("descriptionDocument.id must be exactly 32 bytes") + } + guard document.contractId.count == 32 else { + throw PlatformWalletError.invalidParameter( + "descriptionDocument.contractId must be exactly 32 bytes" + ) + } + let idBytes = [UInt8](document.id) + let contractIdBytes = [UInt8](document.contractId) + return try idBytes.withUnsafeBufferPointer { idBp in + try contractIdBytes.withUnsafeBufferPointer { contractBp in + try withDecisionProposalCString( + document.documentType, + field: "descriptionDocument.documentType", + invalid: PlatformWalletError.invalidParameter + ) { documentTypePtr in + let ffi = DescriptionDocumentFFI( + id: idBp.baseAddress, + contract_id: contractBp.baseAddress, + document_type: documentTypePtr + ) + return try withUnsafePointer(to: ffi) { try body($0) } + } + } + } +} + +extension MultipleChoiceProposalParams { + /// Run `body` with these params as a `MultipleChoiceProposalParamsFFI` + /// whose pointers stay valid for the call. A string holding a NUL or an + /// id that is not 32 bytes is refused with + /// `PlatformWalletError.invalidParameter` before `body` runs. + func withFFI(_ body: (UnsafePointer) throws -> R) throws -> R { + try withDecisionProposalCString( + title, field: "title", invalid: PlatformWalletError.invalidParameter + ) { titlePtr in + try withDescriptionDocumentFFI(descriptionDocument) { documentPtr in + try withDecisionProposalCString( + url, field: "url", invalid: PlatformWalletError.invalidParameter + ) { urlPtr in + let ffi = MultipleChoiceProposalParamsFFI( + title: titlePtr, + description_document: documentPtr, + url: urlPtr, + open: open + ) + return try withUnsafePointer(to: ffi) { try body($0) } + } + } + } + } +} + +extension MultipleChoiceProposalEdit.Change { + /// The change as the FFI writes it: the value to set (`nil` to keep or + /// remove) beside the remove flag. + var ffiParts: (value: Value?, remove: Bool) { + switch self { + case .keep: return (nil, false) + case .set(let value): return (value, false) + case .remove: return (nil, true) + } + } +} + +extension MultipleChoiceProposalEdit { + /// Run `body` with this edit as a `MultipleChoiceProposalEditFFI` whose + /// pointers stay valid for the call. `MultipleChoiceProposalEditFFI` + /// says "remove" with a flag beside a null value, so a `.set` never + /// raises the flag and a `.remove` never carries a value. A string + /// holding a NUL or an id that is not 32 bytes is refused with + /// `PlatformWalletError.invalidParameter` before `body` runs. + func withFFI(_ body: (UnsafePointer) throws -> R) throws -> R { + let documentChange = self.descriptionDocument.ffiParts + let urlChange = self.url.ffiParts + return try withDecisionProposalCString( + title, field: "title", invalid: PlatformWalletError.invalidParameter + ) { titlePtr in + try withDescriptionDocumentFFI(documentChange.value) { documentPtr in + try withDecisionProposalCString( + urlChange.value, field: "url", invalid: PlatformWalletError.invalidParameter + ) { urlPtr in + let ffi = MultipleChoiceProposalEditFFI( + title: titlePtr, + description_document: documentPtr, + remove_description_document: documentChange.remove, + url: urlPtr, + remove_url: urlChange.remove + ) + return try withUnsafePointer(to: ffi) { try body($0) } + } + } + } + } +} + +extension ProposalChoiceParams { + /// Run `body` with these params as a `ChoiceParamsFFI` whose pointers + /// stay valid for the call. A string holding a NUL is refused with + /// `PlatformWalletError.invalidParameter` before `body` runs. + func withFFI(_ body: (UnsafePointer) throws -> R) throws -> R { + try withDecisionProposalCString( + title, field: "title", invalid: PlatformWalletError.invalidParameter + ) { titlePtr in + try withDecisionProposalCString( + description, field: "description", invalid: PlatformWalletError.invalidParameter + ) { descriptionPtr in + let ffi = ChoiceParamsFFI(title: titlePtr, description: descriptionPtr) + return try withUnsafePointer(to: ffi) { try body($0) } + } + } + } +} diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/Voting/SDK+DecisionProposals.swift b/packages/swift-sdk/Sources/SwiftDashSDK/Voting/SDK+DecisionProposals.swift index 11ae35fc1e7..985007c0a26 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/Voting/SDK+DecisionProposals.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/Voting/SDK+DecisionProposals.swift @@ -261,9 +261,9 @@ extension SDK { // MARK: - FFI result handling /// Takes ownership of the `DashSDKResult`s the decision proposal functions -/// return: every owned string and error is freed on every path, so only -/// Swift values leave these functions. -private enum DecisionProposalFFI { +/// (yes/no and multiple choice) return: every owned string and error is +/// freed on every path, so only Swift values leave these functions. +enum DecisionProposalFFI { /// Throw the typed FFI error, freeing it. static func throwIfFailed(_ result: DashSDKResult) throws { guard let error = result.error else { return } diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/Voting/SDK+MultipleChoiceProposals.swift b/packages/swift-sdk/Sources/SwiftDashSDK/Voting/SDK+MultipleChoiceProposals.swift new file mode 100644 index 00000000000..7aac79fdf10 --- /dev/null +++ b/packages/swift-sdk/Sources/SwiftDashSDK/Voting/SDK+MultipleChoiceProposals.swift @@ -0,0 +1,312 @@ +import Foundation +import DashSDKFFI + +// MARK: - Multiple choice proposals (protocol version 15) +// +// Thin bridges over the `dash_sdk_multiple_choice_proposal_*` functions of +// `rs-sdk-ffi`, which call +// `dash_sdk::platform::decision_proposals::multiple_choice`. rs-sdk decides +// everything: which documents are proposals and choices, the vote's +// contest, the fee and the fund. These wrappers marshal arguments in and +// decode the JSON out. Every string goes to C through +// ``withDecisionProposalCString(_:field:invalid:_:)``, which refuses one +// with an embedded NUL. +// +// Every read and the vote park their thread inside Rust until DAPI answers, +// so they run on the shared Platform query queue +// (``SDK/performBlockingQuery(_:)``) and the caller only awaits. +// +// Creating and editing a proposal and entering a choice are platform wallet +// operations: `ManagedPlatformWallet.createMultipleChoiceProposal`, +// `editMultipleChoiceProposal` and `enterMultipleChoiceProposalChoice`. + +extension SDK { + + // MARK: - Reads + + /// The multiple choice proposal `id` names, or `nil` when there is none + /// (`dash_sdk_multiple_choice_proposal_fetch`). + /// + /// - Parameter id: The proposal's id, base58. + public nonisolated func multipleChoiceProposal(id: String) async throws -> MultipleChoiceProposal? { + try await performBlockingQuery { handle in + let result = try withDecisionProposalCString( + id, field: "id", invalid: SDKError.invalidParameter + ) { idPtr in + dash_sdk_multiple_choice_proposal_fetch(handle, idPtr) + } + return try DecisionProposalFFI.consumeString(result).map { + try DecisionProposalJSON.decode(MultipleChoiceProposal.self, from: $0) + } + } + } + + /// One page of an identity's multiple choice proposals, in the order it + /// filed them (`dash_sdk_multiple_choice_proposal_list_by_owner`). + /// + /// - Parameters: + /// - ownerId: The proposer's identity id, base58. + /// - limit: The most proposals to return; `nil` for Platform's cap. + /// - startAfter: The id (base58) of the last proposal of the previous + /// page; `nil` for the first page. + /// - Returns: The page; one shorter than `limit` is the last. + public nonisolated func multipleChoiceProposalsByOwner( + ownerId: String, + limit: UInt32? = nil, + startAfter: String? = nil + ) async throws -> [MultipleChoiceProposal] { + try await performBlockingQuery { handle in + let result = try withDecisionProposalCString( + ownerId, field: "ownerId", invalid: SDKError.invalidParameter + ) { ownerPtr in + try withDecisionProposalCString( + startAfter, field: "startAfter", invalid: SDKError.invalidParameter + ) { startAfterPtr in + // 0 is the FFI's "Platform's cap". + dash_sdk_multiple_choice_proposal_list_by_owner( + handle, ownerPtr, limit ?? 0, startAfterPtr) + } + } + return try DecisionProposalFFI.consumeMultipleChoiceListing( + result, function: "dash_sdk_multiple_choice_proposal_list_by_owner") + } + } + + /// One page of every multiple choice proposal, newest first + /// (`dash_sdk_multiple_choice_proposal_list_by_created_at`). + /// + /// - Parameters: + /// - limit: The most proposals to return; `nil` for Platform's cap. + /// - startAfter: The id (base58) of the last proposal of the previous + /// page; `nil` for the first page. + public nonisolated func multipleChoiceProposalsByCreatedAt( + limit: UInt32? = nil, + startAfter: String? = nil + ) async throws -> [MultipleChoiceProposal] { + try await performBlockingQuery { handle in + let result = try withDecisionProposalCString( + startAfter, field: "startAfter", invalid: SDKError.invalidParameter + ) { startAfterPtr in + dash_sdk_multiple_choice_proposal_list_by_created_at(handle, limit ?? 0, startAfterPtr) + } + return try DecisionProposalFFI.consumeMultipleChoiceListing( + result, function: "dash_sdk_multiple_choice_proposal_list_by_created_at") + } + } + + /// The vote among a multiple choice proposal's choices: every choice with + /// its tally while the vote runs, and how it ended once it did + /// (`dash_sdk_multiple_choice_proposal_get_vote`). + /// + /// - Parameter proposalId: The proposal's id, base58. + public nonisolated func multipleChoiceProposalVote( + proposalId: String + ) async throws -> MultipleChoiceProposalVote { + try await performBlockingQuery { handle in + let result = try withDecisionProposalCString( + proposalId, field: "proposalId", invalid: SDKError.invalidParameter + ) { idPtr in + dash_sdk_multiple_choice_proposal_get_vote(handle, idPtr) + } + guard let json = try DecisionProposalFFI.consumeString(result) else { + throw SDKError.internalError("dash_sdk_multiple_choice_proposal_get_vote returned no data") + } + return try DecisionProposalJSON.decode(MultipleChoiceProposalVote.self, from: json) + } + } + + /// The choice the finished vote of a multiple choice proposal kept, or + /// `nil` while the vote runs, when it kept none of the choices, and for a + /// proposal no choice was entered for + /// (`dash_sdk_multiple_choice_proposal_get_kept_choice`). + /// + /// - Parameter proposalId: The proposal's id, base58. + public nonisolated func multipleChoiceProposalKeptChoice( + proposalId: String + ) async throws -> ProposalChoice? { + try await performBlockingQuery { handle in + let result = try withDecisionProposalCString( + proposalId, field: "proposalId", invalid: SDKError.invalidParameter + ) { idPtr in + dash_sdk_multiple_choice_proposal_get_kept_choice(handle, idPtr) + } + return try DecisionProposalFFI.consumeString(result).map { + try DecisionProposalJSON.decode(ProposalChoice.self, from: $0) + } + } + } + + /// A masternode's answer in the vote among a multiple choice proposal's + /// choices, or `nil` when it has not voted in it or the vote has ended + /// (`dash_sdk_multiple_choice_proposal_get_masternode_vote`). + /// + /// - Parameters: + /// - proposalId: The proposal's id, base58. + /// - proTxHash: The masternode's 32-byte pro_tx_hash in **wire order**, + /// the same bytes + /// ``castMultipleChoiceProposalVote(proposalId:choice:proTxHash:votingPrivateKey:)`` + /// takes. + public nonisolated func multipleChoiceProposalMasternodeVote( + proposalId: String, + proTxHash: Data + ) async throws -> MultipleChoiceVoteChoice? { + // The FFI reads exactly 32 bytes through the pointer. + guard proTxHash.count == 32 else { + throw SDKError.invalidParameter("proTxHash must be exactly 32 bytes") + } + return try await performBlockingQuery { handle in + let result = try proTxHash.withUnsafeBytes { proTxPtr in + try withDecisionProposalCString( + proposalId, field: "proposalId", invalid: SDKError.invalidParameter + ) { idPtr in + dash_sdk_multiple_choice_proposal_get_masternode_vote( + handle, + proTxPtr.bindMemory(to: UInt8.self).baseAddress, + idPtr + ) + } + } + return try DecisionProposalFFI.consumeString(result).map { + try DecisionProposalJSON.decode(MultipleChoiceVoteChoice.self, from: $0) + } + } + } + + // MARK: - Fee and fund + + /// What creating one multiple choice proposal adds to the processing fee + /// of its batch, in credits, which Platform charges the proposer on top + /// of the fees (`dash_sdk_multiple_choice_proposal_get_processing_fee`). + /// A network below protocol version 15 has no multiple choice proposals, + /// which is an error. + public nonisolated func multipleChoiceProposalProcessingFee() async throws -> UInt64 { + try await performBlockingQuery { handle in + try DecisionProposalFFI.consumeCredits( + dash_sdk_multiple_choice_proposal_get_processing_fee(handle), + function: "dash_sdk_multiple_choice_proposal_get_processing_fee" + ) + } + } + + /// The fund, in credits, a choice entered now for the multiple choice + /// proposal `proposalId` states + /// (`dash_sdk_multiple_choice_proposal_get_choice_fund_to_join`). The + /// choice's put reads and states it itself; this is for showing it + /// beforehand. + /// + /// - Parameter proposalId: The proposal's id, base58. + public nonisolated func multipleChoiceProposalChoiceFundToJoin( + proposalId: String + ) async throws -> UInt64 { + try await performBlockingQuery { handle in + let result = try withDecisionProposalCString( + proposalId, field: "proposalId", invalid: SDKError.invalidParameter + ) { idPtr in + dash_sdk_multiple_choice_proposal_get_choice_fund_to_join(handle, idPtr) + } + return try DecisionProposalFFI.consumeCredits( + result, function: "dash_sdk_multiple_choice_proposal_get_choice_fund_to_join") + } + } + + // MARK: - Vote + + /// Vote in the vote among a multiple choice proposal's choices for a + /// masternode and wait for Platform's response + /// (`dash_sdk_multiple_choice_proposal_cast_vote`). + /// + /// The vote is built, signed with the masternode voting key derived from + /// `votingPrivateKey` and broadcast on the Rust side, exactly as + /// ``castDecisionProposalVote(proposalId:choice:proTxHash:votingPrivateKey:)`` + /// does for a yes/no proposal. A wallet that is not a masternode has no + /// voter identity, so Platform refuses its vote. + /// + /// - Parameters: + /// - proposalId: The proposal's id, base58. + /// - choice: For a choice (by its document id), for none of the + /// choices, or abstain. + /// - proTxHash: The masternode's 32-byte pro_tx_hash in **wire order**, + /// not the byte order of the hex Core displays (see + /// ``castContestedResourceVote(dataContractId:documentTypeName:indexName:indexValues:choice:proTxHash:votingPrivateKey:)``). + /// - votingPrivateKey: The masternode's 32-byte voting private key. It + /// is not retained. + public nonisolated func castMultipleChoiceProposalVote( + proposalId: String, + choice: MultipleChoiceVoteChoice, + proTxHash: Data, + votingPrivateKey: Data + ) async throws { + // The FFI reads exactly 32 bytes through each pointer. + guard proTxHash.count == 32 else { + throw SDKError.invalidParameter("proTxHash must be exactly 32 bytes") + } + guard votingPrivateKey.count == 32 else { + throw SDKError.invalidParameter("votingPrivateKey must be exactly 32 bytes") + } + let voteChoice = choice.ffiTag + let choiceId = choice.choiceId + let networkValue = network.ffiValue + + try await performBlockingQuery { handle in + let result = try proTxHash.withUnsafeBytes { proTxPtr in + try votingPrivateKey.withUnsafeBytes { keyPtr in + try withDecisionProposalCString( + proposalId, field: "proposalId", invalid: SDKError.invalidParameter + ) { idPtr in + try withDecisionProposalCString( + choiceId, field: "choiceId", invalid: SDKError.invalidParameter + ) { choiceIdPtr in + dash_sdk_multiple_choice_proposal_cast_vote( + handle, + idPtr, + voteChoice, + choiceIdPtr, + proTxPtr.bindMemory(to: UInt8.self).baseAddress, + keyPtr.bindMemory(to: UInt8.self).baseAddress, + networkValue + ) + } + } + } + } + // No data on success. + _ = try DecisionProposalFFI.consumeString(result) + } + } +} + +// MARK: - FFI result handling + +extension DecisionProposalFFI { + /// A multiple choice listing page: a JSON array, `[]` when empty and + /// never no data. + static func consumeMultipleChoiceListing( + _ result: DashSDKResult, + function: String + ) throws -> [MultipleChoiceProposal] { + guard let json = try consumeString(result) else { + throw SDKError.internalError("\(function) returned no data") + } + return try DecisionProposalJSON.decode([MultipleChoiceProposal].self, from: json) + } + + /// An amount of credits, written by the FFI as a decimal string (not + /// JSON). + static func consumeCredits(_ result: DashSDKResult, function: String) throws -> UInt64 { + guard let string = try consumeString(result) else { + throw SDKError.internalError("\(function) returned no data") + } + return try DecisionProposalJSON.credits(from: string) + } +} + +extension DecisionProposalJSON { + /// The credits `string` writes as a decimal number, the form the fee and + /// fund reads return. + static func credits(from string: String) throws -> UInt64 { + guard let credits = UInt64(string) else { + throw SDKError.serializationError("Not an amount of credits: \(string)") + } + return credits + } +} diff --git a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DecisionProposals/MultipleChoiceProposalDetailView.swift b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DecisionProposals/MultipleChoiceProposalDetailView.swift new file mode 100644 index 00000000000..3a829785c84 --- /dev/null +++ b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DecisionProposals/MultipleChoiceProposalDetailView.swift @@ -0,0 +1,603 @@ +import SwiftUI +import SwiftData +import SwiftDashSDK + +/// One multiple choice proposal: its question, its choices with their +/// tallies while the vote runs, how the vote ended and the kept choice once +/// it did, a masternode vote, entering a choice, and the edit for a proposal +/// a local identity filed. +/// +/// Everything shown is read from Platform through the `SDK` multiple choice +/// proposal wrappers on appear and on pull-to-refresh. Whether a vote, a +/// choice or an edit is accepted is Platform's call; this screen only +/// collects input and shows the outcome. +struct MultipleChoiceProposalDetailView: View { + @EnvironmentObject var appState: AppState + @EnvironmentObject var walletManager: PlatformWalletManager + @Query private var identities: [PersistentIdentity] + + @State private var proposal: MultipleChoiceProposal + @State private var vote: MultipleChoiceProposalVote? + /// `true` once the vote has been read, so "no choices" is not shown while + /// it is still loading. + @State private var voteLoaded = false + /// `true` when the last read of the vote failed. An earlier read stays on + /// screen; without one, the vote shows as unavailable. + @State private var voteLoadFailed = false + @State private var keptChoice: ProposalChoice? + @State private var isRefreshing = false + @State private var errorMessage: String? + + @State private var showVoteSheet = false + @State private var showEnterChoiceSheet = false + @State private var showEditSheet = false + /// Banner after a vote, a choice or an edit. + @State private var actionMessage: String? + + init(proposal: MultipleChoiceProposal) { + _proposal = State(initialValue: proposal) + } + + /// The proposer, when it is an identity on this device held by a loaded + /// wallet, so it can sign an edit. + private var localOwner: PersistentIdentity? { + identities.first { + $0.network == appState.currentNetwork + && $0.wallet != nil + && $0.identityIdBase58 == proposal.ownerId + } + } + + /// Identities on this device held by a loaded wallet, which can sign a + /// choice. + private var localSigners: [PersistentIdentity] { + identities.filter { $0.network == appState.currentNetwork && $0.wallet != nil } + } + + /// The choices a vote can name: the running ones the vote read. + private var votableChoices: [ProposalChoice] { + vote?.choices.compactMap(\.choice) ?? [] + } + + var body: some View { + List { + if let errorMessage { + Section { + Label(errorMessage, systemImage: "exclamationmark.triangle") + .font(.caption) + .foregroundColor(.orange) + } + } + + proposalSection + choicesSection + resultSection + actionsSection + } + .navigationTitle("Proposal") + .navigationBarTitleDisplayMode(.inline) + .refreshable { + await refresh() + } + .task { + await refresh() + } + .sheet(isPresented: $showVoteSheet) { + MultipleChoiceProposalVoteSheet( + proposalId: proposal.id, + proposalTitle: proposal.title, + choices: votableChoices + ) { message in + actionMessage = message + Task { await refresh() } + } + .environmentObject(appState) + } + .sheet(isPresented: $showEnterChoiceSheet, onDismiss: { Task { await refresh() } }) { + EnterProposalChoiceView(proposal: proposal) { message in + actionMessage = message + } + .environmentObject(appState) + .environmentObject(walletManager) + } + // Read the proposal again however the sheet closes: a refused edit + // may have found it changed, and the form then shows the newer text. + .sheet(isPresented: $showEditSheet, onDismiss: { Task { await refresh() } }) { + if let owner = localOwner { + EditMultipleChoiceProposalView(proposal: proposal, owner: owner) { message in + actionMessage = message + } + .environmentObject(appState) + .environmentObject(walletManager) + } + } + } + + // MARK: - Sections + + private var proposalSection: some View { + Section("Proposal") { + Text(proposal.title) + .font(.headline) + .fixedSize(horizontal: false, vertical: true) + if let urlString = proposal.url { + if let url = URL(string: urlString) { + Link(urlString, destination: url) + .font(.caption) + } else { + Text(urlString) + .font(.caption) + } + } + if let document = proposal.descriptionDocument { + DetailRow(label: "Description document", value: document.id) + DetailRow(label: "Its contract", value: document.contractId) + DetailRow(label: "Its document type", value: document.documentType) + } + DetailRow( + label: "Who may enter choices", + value: proposal.open ? "Anyone" : "Only the proposer" + ) + DetailRow(label: "Proposal ID", value: proposal.id) + DetailRow( + label: "Proposer", + value: localOwner.map { "\($0.alias ?? $0.identityIdBase58) (this device)" } + ?? proposal.ownerId + ) + if let revision = proposal.revision { + DetailRow(label: "Revision", value: "\(revision)") + } + if let createdAt = proposal.createdAt { + DetailRow(label: "Created", value: createdAt.formatted(date: .abbreviated, time: .shortened)) + } + if let updatedAt = proposal.updatedAt, updatedAt != proposal.createdAt { + DetailRow(label: "Edited", value: updatedAt.formatted(date: .abbreviated, time: .shortened)) + } + } + } + + @ViewBuilder + private var choicesSection: some View { + Section { + if !voteLoaded && !voteLoadFailed { + HStack { + ProgressView() + Text("Loading choices…") + .font(.caption) + .foregroundColor(.secondary) + } + } else if let vote { + if vote.choices.isEmpty { + Text("No choice has been entered yet. The first choice opens the vote.") + .font(.caption) + .foregroundColor(.secondary) + } + ForEach(vote.choices) { entry in + choiceRow(entry) + } + if let tally = vote.noneOfTheChoicesVoteTally { + tallyRow("None of the choices", systemImage: "nosign", value: tally, color: .red) + } + if let tally = vote.abstainVoteTally { + tallyRow("Abstain", systemImage: "minus.circle", value: tally, color: .gray) + } + } else { + Text("The vote could not be read.") + .font(.caption) + .foregroundColor(.secondary) + } + } header: { + Text("Choices") + } footer: { + Text("Each choice is named by its document id. A vote counts a masternode 1 and an evonode 4.") + } + } + + @ViewBuilder + private var resultSection: some View { + if let result = vote?.result { + Section("Result") { + HStack { + Label("Outcome", systemImage: "flag.fill") + Spacer() + Text(Self.describe(result.outcome)) + .foregroundColor(result.outcome == .keptChoice ? .green : .red) + } + if let keptChoiceId = result.keptChoiceId { + DetailRow(label: "Kept choice ID", value: keptChoiceId) + } + if let keptChoice { + VStack(alignment: .leading, spacing: 4) { + Text(keptChoice.title) + .font(.headline) + if let description = keptChoice.description { + Text(description) + .font(.body) + .fixedSize(horizontal: false, vertical: true) + } + } + DetailRow(label: "Entered by", value: keptChoice.ownerId) + } + DetailRow( + label: "Closed", + value: "Block \(result.finalizationBlock.height), epoch \(result.finalizationBlock.epoch), \(result.finalizationBlock.time.formatted(date: .abbreviated, time: .shortened))" + ) + } + } + } + + private var actionsSection: some View { + Section("Actions") { + if let message = actionMessage { + Label(message, systemImage: "checkmark.circle.fill") + .font(.caption) + .foregroundColor(.green) + } + + Button { + actionMessage = nil + showVoteSheet = true + } label: { + Label("Vote as Masternode…", systemImage: "hand.raised.fill") + } + // An ended vote keeps no votes; Platform refuses one. + .disabled(appState.sdk == nil || vote?.result != nil) + .accessibilityIdentifier("multipleChoiceProposal.vote") + + Button { + actionMessage = nil + showEnterChoiceSheet = true + } label: { + Label("Enter a Choice…", systemImage: "plus.bubble") + } + .disabled(appState.sdk == nil || localSigners.isEmpty || vote?.result != nil) + .accessibilityIdentifier("multipleChoiceProposal.enterChoice") + + if localOwner != nil { + Button { + actionMessage = nil + showEditSheet = true + } label: { + Label("Edit…", systemImage: "pencil") + } + .disabled(appState.sdk == nil) + .accessibilityIdentifier("multipleChoiceProposal.edit") + + Text("Platform accepts an edit of the title, url and description document for two hours after the proposal is created. Whether it is open never changes.") + .font(.caption2) + .foregroundColor(.secondary) + } + + Text("Only masternodes vote, with the voting key of a pro_tx_hash. A choice is never edited; entering one pays the contest fund on top of the fees.") + .font(.caption2) + .foregroundColor(.secondary) + } + } + + // MARK: - Rows + + private func choiceRow(_ entry: MultipleChoiceProposalVote.ChoiceInVote) -> some View { + HStack(alignment: .top) { + VStack(alignment: .leading, spacing: 2) { + Text(entry.choice?.title ?? "Choice no longer stored") + .font(.subheadline) + .foregroundColor(entry.choice == nil ? .secondary : .primary) + if let description = entry.choice?.description { + Text(description) + .font(.caption) + .foregroundColor(.secondary) + .fixedSize(horizontal: false, vertical: true) + } + Text(entry.id) + .font(.system(.caption2, design: .monospaced)) + .foregroundColor(.secondary) + .lineLimit(1) + .truncationMode(.middle) + } + Spacer() + Text(entry.voteTally.map { "\($0)" } ?? "-") + .font(.headline) + } + .accessibilityIdentifier("multipleChoiceProposal.choice.\(entry.id)") + } + + private func tallyRow(_ title: String, systemImage: String, value: UInt32, color: Color) -> some View { + HStack { + Label(title, systemImage: systemImage) + .foregroundColor(color) + Spacer() + Text("\(value)") + .font(.headline) + } + } + + private static func describe(_ outcome: MultipleChoiceProposalVote.Outcome) -> String { + switch outcome { + case .keptChoice: return "A choice was kept" + case .noneOfTheChoices: return "None of the choices" + case .noWinner: return "No winner" + } + } + + // MARK: - Refresh + + /// Read the proposal, its vote and its kept choice. Each read stands on + /// its own, so one failing still shows what the others returned. + private func refresh() async { + guard !isRefreshing else { return } + guard let sdk = appState.sdk else { + errorMessage = "SDK not initialized" + return + } + isRefreshing = true + defer { isRefreshing = false } + + let id = proposal.id + async let fetched = captureResult { try await sdk.multipleChoiceProposal(id: id) } + async let voteValue = captureResult { try await sdk.multipleChoiceProposalVote(proposalId: id) } + async let kept = captureResult { try await sdk.multipleChoiceProposalKeptChoice(proposalId: id) } + + var failures: [String] = [] + switch await fetched { + case .success(let value?): + proposal = value + case .success(nil): + failures.append("Platform no longer has this proposal.") + case .failure(let error): + failures.append("Proposal: \(error.localizedDescription)") + } + switch await voteValue { + case .success(let value): + vote = value + voteLoaded = true + voteLoadFailed = false + case .failure(let error): + voteLoadFailed = true + failures.append("Vote: \(error.localizedDescription)") + } + switch await kept { + case .success(let value): + keptChoice = value + case .failure(let error): + failures.append("Kept choice: \(error.localizedDescription)") + } + errorMessage = failures.isEmpty ? nil : failures.joined(separator: "\n") + } +} + +/// `operation`'s outcome as a `Result`, so reads started together can fail +/// on their own. +private func captureResult( + _ operation: @Sendable () async throws -> T +) async -> Result { + do { + return .success(try await operation()) + } catch { + return .failure(error) + } +} + +// MARK: - Masternode vote + +/// Picks the answer and takes the masternode credentials, the same way the +/// yes/no vote sheet does: the pro_tx_hash and the voting private key as +/// hex, the key in a secure field and never stored. Also reads the +/// masternode's current answer. +private struct MultipleChoiceProposalVoteSheet: View { + let proposalId: String + let proposalTitle: String + /// The running choices, as the vote read them. + let choices: [ProposalChoice] + /// Called with a summary once Platform accepted the vote. + let onVoted: (String) -> Void + + @EnvironmentObject var appState: AppState + @Environment(\.dismiss) private var dismiss + + /// What the picker holds. + private enum Answer: Hashable { + case choice(String) + case noneOfTheChoices + case abstain + } + + @State private var answer: Answer? + @State private var proTxHashHex = "" + @State private var votingKeyHex = "" + @State private var isCasting = false + @State private var isLookingUp = false + @State private var message: String? + @State private var messageIsError = false + + private var voteChoice: MultipleChoiceVoteChoice? { + switch answer { + case .choice(let id): return .choice(id: id) + case .noneOfTheChoices: return .noneOfTheChoices + case .abstain: return .abstain + case nil: return nil + } + } + + var body: some View { + NavigationStack { + Form { + Section("Voting on") { + Text(proposalTitle) + .font(.headline) + } + + Section { + Picker("Answer", selection: $answer) { + Text("Select an answer").tag(Answer?.none) + ForEach(choices) { choice in + Text(choice.title).tag(Answer?.some(.choice(choice.id))) + } + Text("None of the choices").tag(Answer?.some(.noneOfTheChoices)) + Text("Abstain").tag(Answer?.some(.abstain)) + } + .pickerStyle(.inline) + .labelsHidden() + .accessibilityIdentifier("multipleChoiceProposalVote.choice") + } header: { + Text("Your Answer") + } footer: { + Text("When the vote ends the choice with the most votes is kept, unless the votes for none of the choices outnumber it.") + } + + Section { + TextField("pro_tx_hash (64 hex chars)", text: $proTxHashHex) + .font(.system(.caption, design: .monospaced)) + .autocorrectionDisabled() + .textInputAutocapitalization(.never) + .accessibilityIdentifier("multipleChoiceProposalVote.proTxHash") + SecureField("voting private key (64 hex chars)", text: $votingKeyHex) + .font(.system(.caption, design: .monospaced)) + .autocorrectionDisabled() + .textInputAutocapitalization(.never) + .accessibilityIdentifier("multipleChoiceProposalVote.votingKey") + } header: { + Text("Masternode Credentials") + } footer: { + Text("The pro_tx_hash goes in wire order, the reverse of the hex Core displays. The voting public key and signer are derived from the private key on the Rust side; the key bytes are not stored.") + } + + Section { + Button { + Task { await castVote() } + } label: { + if isCasting { + HStack { + ProgressView() + Text("Broadcasting…") + } + } else { + Text("Submit Vote") + } + } + .disabled( + isCasting || isLookingUp || voteChoice == nil + || proTxHashHex.isEmpty || votingKeyHex.isEmpty + ) + .accessibilityIdentifier("multipleChoiceProposalVote.submit") + + Button { + Task { await lookUpAnswer() } + } label: { + if isLookingUp { + HStack { + ProgressView() + Text("Reading…") + } + } else { + Text("Read This Masternode's Answer") + } + } + .disabled(isCasting || isLookingUp || proTxHashHex.isEmpty) + .accessibilityIdentifier("multipleChoiceProposalVote.lookUp") + + if let message { + Text(message) + .font(.caption) + .foregroundColor(messageIsError ? .orange : .secondary) + } + } + } + .navigationTitle("Vote") + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .cancellationAction) { + Button("Cancel") { dismiss() } + .disabled(isCasting) + } + } + .interactiveDismissDisabled(isCasting) + } + } + + /// Decode a 32-byte value typed as 64 hex characters. `Data(hexString:)` + /// drops a trailing odd nibble, so the length is checked first, as on the + /// yes/no vote sheet. + private static func decode32(_ hex: String) -> Data? { + let trimmed = hex.trimmingCharacters(in: .whitespacesAndNewlines) + guard trimmed.count == 64, let data = Data(hexString: trimmed), data.count == 32 else { + return nil + } + return data + } + + private func describe(_ choice: MultipleChoiceVoteChoice) -> String { + switch choice { + case .choice(let id): + return choices.first { $0.id == id }.map { "\"\($0.title)\"" } ?? "the choice \(id)" + case .noneOfTheChoices: + return "none of the choices" + case .abstain: + return "abstain" + } + } + + private func castVote() async { + guard let sdk = appState.sdk else { + show("SDK not initialized", isError: true) + return + } + guard let choice = voteChoice else { + show("Select an answer.", isError: true) + return + } + guard let proTxHash = Self.decode32(proTxHashHex) else { + show("pro_tx_hash must be 32 bytes (64 hex characters).", isError: true) + return + } + guard let votingKey = Self.decode32(votingKeyHex) else { + show("Voting private key must be 32 bytes (64 hex characters).", isError: true) + return + } + + isCasting = true + defer { isCasting = false } + do { + try await sdk.castMultipleChoiceProposalVote( + proposalId: proposalId, + choice: choice, + proTxHash: proTxHash, + votingPrivateKey: votingKey + ) + onVoted("Vote for \(describe(choice)) accepted by Platform.") + dismiss() + } catch { + show("Vote rejected: \(error.localizedDescription)", isError: true) + } + } + + private func lookUpAnswer() async { + guard let sdk = appState.sdk else { + show("SDK not initialized", isError: true) + return + } + guard let proTxHash = Self.decode32(proTxHashHex) else { + show("pro_tx_hash must be 32 bytes (64 hex characters).", isError: true) + return + } + + isLookingUp = true + defer { isLookingUp = false } + do { + if let current = try await sdk.multipleChoiceProposalMasternodeVote( + proposalId: proposalId, + proTxHash: proTxHash + ) { + show("Current answer: \(describe(current)).", isError: false) + } else { + show("This masternode has no answer in the vote (none yet, or the vote has ended).", isError: false) + } + } catch { + show("Reading the answer failed: \(error.localizedDescription)", isError: true) + } + } + + private func show(_ text: String, isError: Bool) { + message = text + messageIsError = isError + } +} diff --git a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DecisionProposals/MultipleChoiceProposalFormViews.swift b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DecisionProposals/MultipleChoiceProposalFormViews.swift new file mode 100644 index 00000000000..8ee1615fabf --- /dev/null +++ b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DecisionProposals/MultipleChoiceProposalFormViews.swift @@ -0,0 +1,794 @@ +import SwiftUI +import SwiftData +import SwiftDashSDK + +// MARK: - Shared input + +/// An amount of credits as Dash, for display (1 Dash = 100,000,000,000 +/// credits). +func multipleChoiceProposalDash(_ credits: UInt64) -> String { + let dash = Double(credits) / 100_000_000_000 + return "\(dash.formatted(.number.precision(.fractionLength(0...8)))) Dash" +} + +/// The three text fields naming a description document, as typed. +struct DescriptionDocumentInput: Equatable { + var id = "" + var contractId = "" + var documentType = "" + + init() {} + + init(_ document: MultipleChoiceProposal.DescriptionDocument?) { + id = document?.id ?? "" + contractId = document?.contractId ?? "" + documentType = document?.documentType ?? "" + } + + private var trimmed: (id: String, contractId: String, documentType: String) { + ( + id.trimmingCharacters(in: .whitespacesAndNewlines), + contractId.trimmingCharacters(in: .whitespacesAndNewlines), + documentType.trimmingCharacters(in: .whitespacesAndNewlines) + ) + } + + /// Whether every field is empty: no description document. + var isEmpty: Bool { + let fields = trimmed + return fields.id.isEmpty && fields.contractId.isEmpty && fields.documentType.isEmpty + } + + /// Whether the fields name `document`. + func matches(_ document: MultipleChoiceProposal.DescriptionDocument?) -> Bool { + let fields = trimmed + guard let document else { return isEmpty } + return fields.id == document.id + && fields.contractId == document.contractId + && fields.documentType == document.documentType + } + + /// The fields as the SDK params, `nil` when they are all empty. Throws + /// when an id is not base58; Platform judges the rest. + func params() throws -> DescriptionDocumentParams? { + guard !isEmpty else { return nil } + let fields = trimmed + guard let id = Data.identifier(fromBase58: fields.id) else { + throw DescriptionDocumentInputError.notBase58("document id") + } + guard let contractId = Data.identifier(fromBase58: fields.contractId) else { + throw DescriptionDocumentInputError.notBase58("contract id") + } + return DescriptionDocumentParams(id: id, contractId: contractId, documentType: fields.documentType) + } +} + +enum DescriptionDocumentInputError: LocalizedError { + case notBase58(String) + + var errorDescription: String? { + switch self { + case .notBase58(let field): + return "The description document's \(field) is not a base58 identifier." + } + } +} + +/// The text fields of a ``DescriptionDocumentInput``. +private struct DescriptionDocumentFields: View { + @Binding var input: DescriptionDocumentInput + let identifierPrefix: String + + var body: some View { + TextField("Document ID (base58)", text: $input.id) + .font(.system(.caption, design: .monospaced)) + .autocorrectionDisabled() + .textInputAutocapitalization(.never) + .accessibilityIdentifier("\(identifierPrefix).descriptionDocumentId") + TextField("Contract ID (base58)", text: $input.contractId) + .font(.system(.caption, design: .monospaced)) + .autocorrectionDisabled() + .textInputAutocapitalization(.never) + .accessibilityIdentifier("\(identifierPrefix).descriptionDocumentContractId") + TextField("Document type", text: $input.documentType) + .autocorrectionDisabled() + .textInputAutocapitalization(.never) + .accessibilityIdentifier("\(identifierPrefix).descriptionDocumentType") + } +} + +// MARK: - Create + +/// Files a new multiple choice proposal for an identity held by a loaded +/// wallet. +/// +/// The platform wallet creates it +/// (`ManagedPlatformWallet.createMultipleChoiceProposal`): rs-sdk builds the +/// proposal and the wallet chooses and uses the signing key on the Rust side +/// through the `KeychainSigner`. Platform judges the title, the description +/// document and the url, and charges the processing fee shown here (read +/// from the SDK); this form only collects the input. +struct CreateMultipleChoiceProposalView: View { + /// Called with the new proposal's id (base58) once Platform confirmed it. + let onCreated: (String) -> Void + + @EnvironmentObject var appState: AppState + @EnvironmentObject var walletManager: PlatformWalletManager + @Environment(\.modelContext) private var modelContext + @Environment(\.dismiss) private var dismiss + @Query private var identities: [PersistentIdentity] + + /// Base58 id of the proposer. + @State private var selectedOwnerId = "" + @State private var title = "" + @State private var url = "" + @State private var descriptionDocument = DescriptionDocumentInput() + @State private var open = true + + /// The processing fee in credits, once read. + @State private var processingFee: UInt64? + @State private var processingFeeError: String? + + @State private var isSubmitting = false + @State private var submitError: String? + @State private var createdProposalId: String? + + /// Identities on the active network held by a loaded wallet, so a + /// `KeychainSigner` can sign for them. + private var ownerIdentities: [PersistentIdentity] { + identities.filter { $0.network == appState.currentNetwork && $0.wallet != nil } + } + + private var selectedOwner: PersistentIdentity? { + ownerIdentities.first { $0.identityIdBase58 == selectedOwnerId } + } + + private var managedWallet: ManagedPlatformWallet? { + guard let walletId = selectedOwner?.wallet?.walletId else { return nil } + return walletManager.wallet(for: walletId) + } + + var body: some View { + NavigationStack { + Form { + if let createdProposalId { + successSection(proposalId: createdProposalId) + } else { + ownerSection + questionSection + descriptionDocumentSection + submitSection + } + } + .navigationTitle("New Proposal") + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + Button(createdProposalId == nil ? "Cancel" : "Done") { dismiss() } + .disabled(isSubmitting) + } + } + // The broadcast is not idempotent; keep the sheet up until it ends. + .interactiveDismissDisabled(isSubmitting) + .alert( + "Create failed", + isPresented: Binding( + get: { submitError != nil }, + set: { if !$0 { submitError = nil } } + ) + ) { + Button("OK", role: .cancel) {} + } message: { + Text(submitError ?? "") + } + .onAppear { + if selectedOwnerId.isEmpty, let first = ownerIdentities.first { + selectedOwnerId = first.identityIdBase58 + } + } + .task { + await loadProcessingFee() + } + } + } + + // MARK: - Sections + + private var ownerSection: some View { + Section { + Picker("Proposer", selection: $selectedOwnerId) { + Text("Select identity").tag("") + ForEach(ownerIdentities) { identity in + Text(identity.alias ?? identity.identityIdBase58) + .tag(identity.identityIdBase58) + } + } + .accessibleFormPicker("createMultipleChoiceProposal.ownerPicker") + .disabled(isSubmitting) + + HStack { + Text("Processing fee") + Spacer() + if let processingFee { + Text(multipleChoiceProposalDash(processingFee)) + .foregroundColor(.secondary) + .accessibilityIdentifier("createMultipleChoiceProposal.processingFee") + } else if processingFeeError != nil { + Text("Unavailable") + .foregroundColor(.orange) + } else { + ProgressView().controlSize(.small) + } + } + } header: { + Text("Proposer") + } footer: { + if let processingFeeError { + Text("The processing fee could not be read: \(processingFeeError)") + } else { + Text("Platform charges this identity the processing fee on top of the fees when the proposal is created.") + } + } + } + + private var questionSection: some View { + Section { + TextField("Title: the question, in one line", text: $title) + .accessibilityIdentifier("createMultipleChoiceProposal.title") + TextField("URL where it is described or discussed", text: $url) + .keyboardType(.URL) + .autocorrectionDisabled() + .textInputAutocapitalization(.never) + .accessibilityIdentifier("createMultipleChoiceProposal.url") + Toggle("Anyone may enter choices", isOn: $open) + .accessibilityIdentifier("createMultipleChoiceProposal.open") + } header: { + Text("Question") + } footer: { + Text("When it is off, only the proposer may enter choices. This never changes after the proposal is created; the title, url and description document can be edited for two hours.") + } + .disabled(isSubmitting) + } + + private var descriptionDocumentSection: some View { + Section { + DescriptionDocumentFields( + input: $descriptionDocument, + identifierPrefix: "createMultipleChoiceProposal" + ) + } header: { + Text("Description Document (optional)") + } footer: { + Text("A document saying what is being decided. Platform requires a description document, a url, or both, and accepts only a document its contract's elected team may delete.") + } + .disabled(isSubmitting) + } + + private var submitSection: some View { + Section { + Button { + submit() + } label: { + HStack { + if isSubmitting { + ProgressView() + .controlSize(.small) + Text("Broadcasting…") + } else { + Text("Create / Broadcast") + } + } + .frame(maxWidth: .infinity) + } + .buttonStyle(.borderedProminent) + .accessibilityIdentifier("createMultipleChoiceProposal.submitButton") + .disabled(isSubmitting || managedWallet == nil) + } + } + + private func successSection(proposalId: String) -> some View { + Section { + VStack(alignment: .leading, spacing: 8) { + Label("Proposal created", systemImage: "checkmark.seal.fill") + .foregroundColor(.green) + .font(.headline) + HStack(alignment: .top) { + Text("ID:") + .foregroundColor(.secondary) + Text(proposalId) + .font(.system(.caption, design: .monospaced)) + .lineLimit(2) + .truncationMode(.middle) + } + Button { + dismiss() + } label: { + Text("Done") + .frame(maxWidth: .infinity) + } + .buttonStyle(.borderedProminent) + .accessibilityIdentifier("createMultipleChoiceProposal.doneButton") + .padding(.top, 4) + } + } + } + + // MARK: - Actions + + private func loadProcessingFee() async { + guard let sdk = appState.sdk else { + processingFeeError = "SDK not initialized" + return + } + do { + processingFee = try await sdk.multipleChoiceProposalProcessingFee() + processingFeeError = nil + } catch { + processingFeeError = error.localizedDescription + } + } + + private func submit() { + guard let owner = selectedOwner, let wallet = managedWallet else { + submitError = DocumentActionError.noWallet.localizedDescription + return + } + let document: DescriptionDocumentParams? + do { + document = try descriptionDocument.params() + } catch { + submitError = error.localizedDescription + return + } + + let trimmedURL = url.trimmingCharacters(in: .whitespacesAndNewlines) + let params = MultipleChoiceProposalParams( + title: title, + descriptionDocument: document, + url: trimmedURL.isEmpty ? nil : trimmedURL, + open: open + ) + let ownerId = owner.identityId + // Fresh `KeychainSigner` per submit, as `CreateDocumentView` does. + let signer = KeychainSigner(modelContainer: modelContext.container) + + isSubmitting = true + Task { + do { + let (proposalId, _) = try await wallet.createMultipleChoiceProposal( + ownerIdentityId: ownerId, + params: params, + signer: signer + ) + let proposalIdBase58 = proposalId.toBase58String() + createdProposalId = proposalIdBase58 + onCreated(proposalIdBase58) + } catch { + submitError = error.localizedDescription + } + isSubmitting = false + } + } +} + +// MARK: - Edit + +/// Changes the title, url or description document of a proposal a local +/// identity filed. +/// +/// The platform wallet edits it +/// (`ManagedPlatformWallet.editMultipleChoiceProposal`): it reads the +/// proposal, rs-sdk applies the edit (refusing one that changes nothing) and +/// the wallet chooses the signing key and puts the proposal at the revision +/// after the one it read. Platform refuses the edit outside the edit window, +/// one that leaves the proposal with neither a description document nor a +/// url, and one made after another edit landed after that read. +/// +/// After any failure the form reads the proposal again. When Platform's copy +/// differs from the one the form was opened on, the form shows that copy in +/// place of the fields, so the next try starts from it. +struct EditMultipleChoiceProposalView: View { + let owner: PersistentIdentity + /// Called with a summary once Platform confirmed the edit. + let onEdited: (String) -> Void + + @EnvironmentObject var appState: AppState + @EnvironmentObject var walletManager: PlatformWalletManager + @Environment(\.modelContext) private var modelContext + @Environment(\.dismiss) private var dismiss + + /// The proposal as last read, which the fields were filled from. + @State private var proposal: MultipleChoiceProposal + @State private var title: String + @State private var url: String + @State private var descriptionDocument: DescriptionDocumentInput + @State private var isSubmitting = false + @State private var submitError: String? + + init(proposal: MultipleChoiceProposal, owner: PersistentIdentity, onEdited: @escaping (String) -> Void) { + self.owner = owner + self.onEdited = onEdited + _proposal = State(initialValue: proposal) + _title = State(initialValue: proposal.title) + _url = State(initialValue: proposal.url ?? "") + _descriptionDocument = State(initialValue: DescriptionDocumentInput(proposal.descriptionDocument)) + } + + private var managedWallet: ManagedPlatformWallet? { + guard let walletId = owner.wallet?.walletId else { return nil } + return walletManager.wallet(for: walletId) + } + + var body: some View { + NavigationStack { + Form { + Section { + TextField("Title", text: $title) + .accessibilityIdentifier("editMultipleChoiceProposal.title") + TextField("URL (empty for none)", text: $url) + .keyboardType(.URL) + .autocorrectionDisabled() + .textInputAutocapitalization(.never) + .accessibilityIdentifier("editMultipleChoiceProposal.url") + } header: { + Text("Question") + } + .disabled(isSubmitting) + + Section { + DescriptionDocumentFields( + input: $descriptionDocument, + identifierPrefix: "editMultipleChoiceProposal" + ) + } header: { + Text("Description Document") + } footer: { + Text("Empty every field to remove it. Only the title, url and description document can change, and only for two hours after the proposal was created.") + } + .disabled(isSubmitting) + + Section { + Button { + submit() + } label: { + HStack { + if isSubmitting { + ProgressView() + .controlSize(.small) + Text("Broadcasting…") + } else { + Text("Replace / Broadcast") + } + } + .frame(maxWidth: .infinity) + } + .buttonStyle(.borderedProminent) + .accessibilityIdentifier("editMultipleChoiceProposal.submitButton") + .disabled(isSubmitting || managedWallet == nil) + } + } + .navigationTitle("Edit Proposal") + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + Button("Cancel") { dismiss() } + .disabled(isSubmitting) + } + } + .interactiveDismissDisabled(isSubmitting) + .alert( + "Edit failed", + isPresented: Binding( + get: { submitError != nil }, + set: { if !$0 { submitError = nil } } + ) + ) { + Button("OK", role: .cancel) {} + } message: { + Text(submitError ?? "") + } + } + } + + private func submit() { + guard let wallet = managedWallet else { + submitError = DocumentActionError.noWallet.localizedDescription + return + } + guard let proposalId = Data.identifier(fromBase58: proposal.id), proposalId.count == 32 else { + submitError = "The proposal id is not a 32-byte base58 identifier." + return + } + + // Only the fields the user changed from the proposal this form shows + // are sent: an untouched field must not write back the value it was + // opened with over a newer edit by another client. An emptied field + // removes the value. + let trimmedURL = url.trimmingCharacters(in: .whitespacesAndNewlines) + let urlChange: MultipleChoiceProposalEdit.Change + if trimmedURL == (proposal.url ?? "") { + urlChange = .keep + } else if trimmedURL.isEmpty { + urlChange = .remove + } else { + urlChange = .set(trimmedURL) + } + let documentChange: MultipleChoiceProposalEdit.Change + if descriptionDocument.matches(proposal.descriptionDocument) { + documentChange = .keep + } else { + do { + if let document = try descriptionDocument.params() { + documentChange = .set(document) + } else { + documentChange = .remove + } + } catch { + submitError = error.localizedDescription + return + } + } + let edit = MultipleChoiceProposalEdit( + title: title == proposal.title ? nil : title, + descriptionDocument: documentChange, + url: urlChange + ) + let ownerId = owner.identityId + let signer = KeychainSigner(modelContainer: modelContext.container) + + isSubmitting = true + Task { + do { + _ = try await wallet.editMultipleChoiceProposal( + ownerIdentityId: ownerId, + proposalId: proposalId, + edit: edit, + signer: signer + ) + onEdited("Edit accepted by Platform.") + isSubmitting = false + dismiss() + } catch { + let reloadNote = await reloadAfterFailure() + submitError = [error.localizedDescription, reloadNote] + .compactMap { $0 } + .joined(separator: "\n\n") + isSubmitting = false + } + } + } + + /// Read the proposal again after a failed edit. When Platform's copy + /// differs from the one the fields were filled from, take it and refill + /// the fields. Returns what the person should know about the reload, or + /// `nil` when there is nothing to add. + private func reloadAfterFailure() async -> String? { + guard let sdk = appState.sdk else { return nil } + do { + guard let current = try await sdk.multipleChoiceProposal(id: proposal.id) else { + return "Platform no longer has this proposal." + } + guard current != proposal else { return nil } + proposal = current + title = current.title + url = current.url ?? "" + descriptionDocument = DescriptionDocumentInput(current.descriptionDocument) + let revision = current.revision.map { " (revision \($0))" } ?? "" + return "Platform's copy of the proposal changed since this form was opened; the form now shows it\(revision)." + } catch { + return "The proposal could not be read again: \(error.localizedDescription)" + } + } +} + +// MARK: - Enter a choice + +/// Enters an answer for a multiple choice proposal, owned by an identity +/// held by a loaded wallet. +/// +/// The platform wallet enters it +/// (`ManagedPlatformWallet.enterMultipleChoiceProposalChoice`): rs-sdk builds +/// the choice and its put states the contest fund shown here (read from the +/// SDK). Platform decides who may enter a choice and until when; this form +/// only collects the answer. +struct EnterProposalChoiceView: View { + let proposal: MultipleChoiceProposal + /// Called with a summary once Platform confirmed the choice. + let onEntered: (String) -> Void + + @EnvironmentObject var appState: AppState + @EnvironmentObject var walletManager: PlatformWalletManager + @Environment(\.modelContext) private var modelContext + @Environment(\.dismiss) private var dismiss + @Query private var identities: [PersistentIdentity] + + /// Base58 id of the identity entering the choice. + @State private var selectedOwnerId = "" + @State private var title = "" + @State private var description = "" + + /// The contest fund in credits, once read. + @State private var fund: UInt64? + @State private var fundError: String? + + @State private var isSubmitting = false + @State private var submitError: String? + + /// Identities on the active network held by a loaded wallet, so a + /// `KeychainSigner` can sign for them. + private var ownerIdentities: [PersistentIdentity] { + identities.filter { $0.network == appState.currentNetwork && $0.wallet != nil } + } + + private var selectedOwner: PersistentIdentity? { + ownerIdentities.first { $0.identityIdBase58 == selectedOwnerId } + } + + private var managedWallet: ManagedPlatformWallet? { + guard let walletId = selectedOwner?.wallet?.walletId else { return nil } + return walletManager.wallet(for: walletId) + } + + var body: some View { + NavigationStack { + Form { + Section("Answering") { + Text(proposal.title) + .font(.headline) + } + + Section { + Picker("Entered by", selection: $selectedOwnerId) { + Text("Select identity").tag("") + ForEach(ownerIdentities) { identity in + Text(identity.alias ?? identity.identityIdBase58) + .tag(identity.identityIdBase58) + } + } + .accessibleFormPicker("enterProposalChoice.ownerPicker") + + HStack { + Text("Contest fund") + Spacer() + if let fund { + Text(multipleChoiceProposalDash(fund)) + .foregroundColor(.secondary) + .accessibilityIdentifier("enterProposalChoice.fund") + } else if fundError != nil { + Text("Unavailable") + .foregroundColor(.orange) + } else { + ProgressView().controlSize(.small) + } + } + } header: { + Text("Identity") + } footer: { + if let fundError { + Text("The contest fund could not be read: \(fundError)") + } else if proposal.open { + Text("Entering a choice pays the contest fund from this identity's credits, on top of the fees. The amount is read again when the choice is signed.") + } else { + Text("Only the proposer may enter choices for this proposal. Entering a choice pays the contest fund on top of the fees.") + } + } + .disabled(isSubmitting) + + Section { + TextField("Title: the answer, in one line", text: $title) + .accessibilityIdentifier("enterProposalChoice.title") + TextField("What voting for it means (optional)", text: $description, axis: .vertical) + .lineLimit(3...10) + .accessibilityIdentifier("enterProposalChoice.description") + } header: { + Text("Choice") + } footer: { + Text("A choice is never edited after it is entered.") + } + .disabled(isSubmitting) + + Section { + Button { + submit() + } label: { + HStack { + if isSubmitting { + ProgressView() + .controlSize(.small) + Text("Broadcasting…") + } else { + Text("Enter / Broadcast") + } + } + .frame(maxWidth: .infinity) + } + .buttonStyle(.borderedProminent) + .accessibilityIdentifier("enterProposalChoice.submitButton") + .disabled(isSubmitting || managedWallet == nil) + } + } + .navigationTitle("Enter a Choice") + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + Button("Cancel") { dismiss() } + .disabled(isSubmitting) + } + } + // The broadcast is not idempotent; keep the sheet up until it ends. + .interactiveDismissDisabled(isSubmitting) + .alert( + "Entering the choice failed", + isPresented: Binding( + get: { submitError != nil }, + set: { if !$0 { submitError = nil } } + ) + ) { + Button("OK", role: .cancel) {} + } message: { + Text(submitError ?? "") + } + .onAppear { + if selectedOwnerId.isEmpty { + // Start on the proposer when it is local, else the first + // local identity. + selectedOwnerId = ownerIdentities.first { $0.identityIdBase58 == proposal.ownerId }? + .identityIdBase58 ?? ownerIdentities.first?.identityIdBase58 ?? "" + } + } + .task { + await loadFund() + } + } + } + + private func loadFund() async { + guard let sdk = appState.sdk else { + fundError = "SDK not initialized" + return + } + do { + fund = try await sdk.multipleChoiceProposalChoiceFundToJoin(proposalId: proposal.id) + fundError = nil + } catch { + fundError = error.localizedDescription + } + } + + private func submit() { + guard let owner = selectedOwner, let wallet = managedWallet else { + submitError = DocumentActionError.noWallet.localizedDescription + return + } + guard let proposalId = Data.identifier(fromBase58: proposal.id), proposalId.count == 32 else { + submitError = "The proposal id is not a 32-byte base58 identifier." + return + } + + let trimmedDescription = description.trimmingCharacters(in: .whitespacesAndNewlines) + let params = ProposalChoiceParams( + title: title, + description: trimmedDescription.isEmpty ? nil : description + ) + let ownerId = owner.identityId + let signer = KeychainSigner(modelContainer: modelContext.container) + + isSubmitting = true + Task { + do { + let (choiceId, _) = try await wallet.enterMultipleChoiceProposalChoice( + ownerIdentityId: ownerId, + proposalId: proposalId, + params: params, + signer: signer + ) + onEntered("Choice \(choiceId.toBase58String()) accepted by Platform.") + isSubmitting = false + dismiss() + } catch { + submitError = error.localizedDescription + isSubmitting = false + } + } + } +} diff --git a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DecisionProposals/MultipleChoiceProposalsView.swift b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DecisionProposals/MultipleChoiceProposalsView.swift new file mode 100644 index 00000000000..7d029f0fd25 --- /dev/null +++ b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DecisionProposals/MultipleChoiceProposalsView.swift @@ -0,0 +1,259 @@ +import SwiftUI +import SwiftData +import SwiftDashSDK + +/// Multiple choice proposals (protocol version 15): questions any identity +/// puts to the masternodes, answered by the choices entered for them. +/// +/// Lists them two ways, each one Platform listing read a page at a time: the +/// ones a local identity filed, and the newest. Drills into +/// ``MultipleChoiceProposalDetailView`` for the choices, the vote, entering a +/// choice and the edit, and creates new ones with +/// ``CreateMultipleChoiceProposalView``. Every read goes through the `SDK` +/// multiple choice proposal wrappers; nothing here decides what a proposal +/// is. +struct MultipleChoiceProposalsView: View { + @EnvironmentObject var appState: AppState + @EnvironmentObject var walletManager: PlatformWalletManager + @Query private var identities: [PersistentIdentity] + + private enum Listing: String, CaseIterable, Identifiable { + case mine = "Mine" + case newest = "Newest" + + var id: String { rawValue } + + var footer: String { + switch self { + case .mine: + return "Proposals the selected identity filed, in the order it filed them." + case .newest: + return "Every multiple choice proposal, newest first." + } + } + } + + /// Proposals per page. + private static let pageSize: UInt32 = 20 + + @State private var listing: Listing = .newest + /// Base58 id of the identity whose proposals "Mine" lists. + @State private var selectedOwnerId = "" + @State private var proposals: [MultipleChoiceProposal] = [] + /// `false` once a page came back shorter than the page size (the last). + @State private var hasMore = false + @State private var isLoading = false + @State private var errorMessage: String? + /// Bumped on every fresh load so a page that arrives late for a previous + /// listing is dropped instead of mixed in. + @State private var loadGeneration = 0 + @State private var showCreate = false + + /// Identities on the active network, for the "Mine" listing. + private var localIdentities: [PersistentIdentity] { + identities.filter { $0.network == appState.currentNetwork } + } + + var body: some View { + List { + Section { + Picker("Listing", selection: $listing) { + ForEach(Listing.allCases) { value in + Text(value.rawValue).tag(value) + } + } + .pickerStyle(.segmented) + .accessibilityIdentifier("multipleChoiceProposals.listing") + + if listing == .mine { + Picker("Identity", selection: $selectedOwnerId) { + Text("Select identity").tag("") + ForEach(localIdentities) { identity in + Text(identity.alias ?? identity.identityIdBase58) + .tag(identity.identityIdBase58) + } + } + .accessibilityIdentifier("multipleChoiceProposals.ownerPicker") + } + } footer: { + Text(listing.footer) + } + + if let errorMessage { + Section { + Label(errorMessage, systemImage: "exclamationmark.triangle") + .font(.caption) + .foregroundColor(.orange) + } + } + + Section("Proposals") { + if proposals.isEmpty { + if isLoading { + HStack { + ProgressView() + Text("Loading proposals…") + .font(.caption) + .foregroundColor(.secondary) + } + } else if listing == .mine && selectedOwnerId.isEmpty { + Text("Select an identity to list its proposals.") + .font(.caption) + .foregroundColor(.secondary) + } else { + Text("No proposals") + .font(.caption) + .foregroundColor(.secondary) + } + } else { + ForEach(proposals) { proposal in + NavigationLink( + destination: MultipleChoiceProposalDetailView(proposal: proposal) + ) { + MultipleChoiceProposalRow(proposal: proposal) + } + .accessibilityIdentifier("multipleChoiceProposals.row.\(proposal.id)") + } + + if hasMore { + Button { + Task { await loadNextPage() } + } label: { + HStack { + if isLoading { + ProgressView().controlSize(.small) + } + Text("Load More") + } + .frame(maxWidth: .infinity) + } + .disabled(isLoading) + .accessibilityIdentifier("multipleChoiceProposals.loadMore") + } + } + } + } + .navigationTitle("Multiple Choice Proposals") + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .navigationBarTrailing) { + Button { + showCreate = true + } label: { + Image(systemName: "plus") + } + .disabled(appState.sdk == nil) + .accessibilityLabel("New multiple choice proposal") + .accessibilityIdentifier("multipleChoiceProposals.create") + } + } + .refreshable { + await reload() + } + .task(id: "\(listing.rawValue)|\(selectedOwnerId)") { + await reload() + } + .onChange(of: listing) { _, newListing in + // Start "Mine" on the first local identity rather than empty. + if newListing == .mine, selectedOwnerId.isEmpty, + let first = localIdentities.first { + selectedOwnerId = first.identityIdBase58 + } + } + .sheet(isPresented: $showCreate) { + CreateMultipleChoiceProposalView { _ in + Task { await reload() } + } + .environmentObject(appState) + .environmentObject(walletManager) + } + } + + // MARK: - Loading + + /// Load the first page of the current listing. + private func reload() async { + loadGeneration += 1 + proposals = [] + hasMore = false + errorMessage = nil + if listing == .mine && selectedOwnerId.isEmpty { return } + await load(startAfter: nil, generation: loadGeneration) + } + + /// Load the page after the last proposal shown. + private func loadNextPage() async { + guard let last = proposals.last else { return } + await load(startAfter: last.id, generation: loadGeneration) + } + + private func load(startAfter: String?, generation: Int) async { + guard let sdk = appState.sdk else { + errorMessage = "SDK not initialized" + return + } + isLoading = true + defer { isLoading = false } + + do { + let page: [MultipleChoiceProposal] + switch listing { + case .mine: + page = try await sdk.multipleChoiceProposalsByOwner( + ownerId: selectedOwnerId, + limit: Self.pageSize, + startAfter: startAfter + ) + case .newest: + page = try await sdk.multipleChoiceProposalsByCreatedAt( + limit: Self.pageSize, + startAfter: startAfter + ) + } + guard generation == loadGeneration else { return } + proposals.append(contentsOf: page) + // A page shorter than the page size is the last one. + hasMore = page.count == Int(Self.pageSize) + } catch { + guard generation == loadGeneration else { return } + errorMessage = "Loading failed: \(error.localizedDescription)" + } + } +} + +/// One proposal in a listing. +private struct MultipleChoiceProposalRow: View { + let proposal: MultipleChoiceProposal + + var body: some View { + VStack(alignment: .leading, spacing: 4) { + Text(proposal.title) + .font(.headline) + .lineLimit(2) + HStack(spacing: 12) { + if let createdAt = proposal.createdAt { + Label { + Text(createdAt, style: .date) + } icon: { + Image(systemName: "calendar") + } + } + Label( + proposal.open ? "Open" : "Owner only", + systemImage: proposal.open ? "person.3" : "person" + ) + if proposal.descriptionDocument != nil { + Label("Document", systemImage: "doc.text") + } + } + .font(.caption) + .foregroundColor(.secondary) + Text(proposal.id) + .font(.system(.caption2, design: .monospaced)) + .foregroundColor(.secondary) + .lineLimit(1) + .truncationMode(.middle) + } + .padding(.vertical, 2) + } +} diff --git a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/PlatformQueriesView.swift b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/PlatformQueriesView.swift index ff0aa774cd2..fd9acc44786 100644 --- a/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/PlatformQueriesView.swift +++ b/packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/PlatformQueriesView.swift @@ -129,6 +129,19 @@ struct QueryCategoryDetailView: View { .padding(.vertical, 4) } .accessibilityIdentifier("votingQueries.decisionProposalsLink") + } else if query.name == "multipleChoiceProposals" { + NavigationLink(destination: MultipleChoiceProposalsView()) { + VStack(alignment: .leading, spacing: 4) { + Text(query.label) + .font(.headline) + Text(query.description) + .font(.caption) + .foregroundColor(.secondary) + .lineLimit(2) + } + .padding(.vertical, 4) + } + .accessibilityIdentifier("votingQueries.multipleChoiceProposalsLink") } else if query.name == "testDPNSQueries" { NavigationLink(destination: DPNSTestView()) { VStack(alignment: .leading, spacing: 4) { @@ -209,6 +222,7 @@ struct QueryCategoryDetailView: View { case .voting: return [ QueryDefinition(name: "decisionProposals", label: "Decision Proposals", description: "Browse, file, edit and vote on yes/no questions put to the masternodes (protocol version 15)"), + QueryDefinition(name: "multipleChoiceProposals", label: "Multiple Choice Proposals", description: "Browse, file, edit, enter choices for and vote on questions with several answers (protocol version 15)"), QueryDefinition(name: "getContestedResources", label: "Get Contested Resources", description: "Get list of contested resources"), QueryDefinition(name: "getContestedResourceVoteState", label: "Get Contested Resource Vote State", description: "Get the current vote state for a contested resource"), QueryDefinition(name: "getContestedResourceVotersForIdentity", label: "Get Contested Resource Voters for Identity", description: "Get voters who voted for a specific identity in a contested resource"), diff --git a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/MultipleChoiceProposalDecodingTests.swift b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/MultipleChoiceProposalDecodingTests.swift new file mode 100644 index 00000000000..03bad85248e --- /dev/null +++ b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/MultipleChoiceProposalDecodingTests.swift @@ -0,0 +1,269 @@ +import Foundation +import XCTest +@testable import SwiftDashSDK + +/// Hermetic tests for the multiple choice proposal JSON the `rs-sdk-ffi` +/// `dash_sdk_multiple_choice_proposal_*` reads return, decoded by +/// `DecisionProposalJSON` exactly as the `SDK` wrappers decode it, and for the +/// `vote_choice` byte and `choice_id` `dash_sdk_multiple_choice_proposal_cast_vote` +/// takes. +/// +/// The payloads mirror the shapes the FFI's +/// `packages/rs-sdk-ffi/src/decision_proposal/multiple_choice/json.rs` writes +/// (and its tests pin). No SDK handle, no network. +final class MultipleChoiceProposalDecodingTests: XCTestCase { + private let createdAt: UInt64 = 1_700_000_000_000 + private let proposalId = "4EfA9Jrvv3nnCFdSf7fad59851iiTRZ6Wcu6YVJ4iSeF" + private let ownerId = "CQgw5i7y2Y4Ns6rTgV6cq7MhQ7b4oJxEf1vsaFgM2KXJ" + private let choiceId = "8wtF3Sji4LR7gRmmSPXuQbqWf9GmgPJyDukTEBpHmh5K" + private let otherChoiceId = "11111111111111111111111111111111" + + private func decode(_ type: T.Type, _ json: String) throws -> T { + try DecisionProposalJSON.decode(type, from: json) + } + + private func proposalJSON(descriptionDocument: String, url: String, open: Bool = true) -> String { + """ + {"id":"\(proposalId)","ownerId":"\(ownerId)",\ + "revision":1,"createdAt":\(createdAt),"updatedAt":\(createdAt),\ + "title":"Which block size?",\ + "descriptionDocument":\(descriptionDocument),"url":\(url),"open":\(open)} + """ + } + + private var descriptionDocumentJSON: String { + #"{"id":"\#(otherChoiceId)","contractId":"\#(ownerId)","documentType":"post"}"# + } + + private func choiceJSON(id: String, description: String) -> String { + """ + {"id":"\(id)","ownerId":"\(ownerId)","proposalId":"\(proposalId)",\ + "revision":null,"createdAt":\(createdAt),"updatedAt":null,\ + "title":"Double it","description":\(description)} + """ + } + + // MARK: - Proposal + + func testShouldDecodeAProposalWithEveryField() throws { + let proposal = try decode( + MultipleChoiceProposal.self, + proposalJSON( + descriptionDocument: descriptionDocumentJSON, + url: #""https://forum.dash.org/t/block-size""# + ) + ) + + XCTAssertEqual(proposal.id, proposalId) + XCTAssertEqual(proposal.ownerId, ownerId) + XCTAssertEqual(proposal.revision, 1) + XCTAssertEqual(proposal.createdAtMs, createdAt) + XCTAssertEqual(proposal.updatedAtMs, createdAt) + XCTAssertEqual(proposal.createdAt, Date(timeIntervalSince1970: 1_700_000_000)) + XCTAssertEqual(proposal.title, "Which block size?") + XCTAssertEqual(proposal.descriptionDocument?.id, otherChoiceId) + XCTAssertEqual(proposal.descriptionDocument?.contractId, ownerId) + XCTAssertEqual(proposal.descriptionDocument?.documentType, "post") + XCTAssertEqual(proposal.url, "https://forum.dash.org/t/block-size") + XCTAssertTrue(proposal.open) + } + + func testShouldDecodeAnAbsentDescriptionDocumentAndUrlAsNil() throws { + let proposal = try decode( + MultipleChoiceProposal.self, + proposalJSON(descriptionDocument: "null", url: "null", open: false) + ) + + XCTAssertNil(proposal.descriptionDocument) + XCTAssertNil(proposal.url) + XCTAssertFalse(proposal.open) + } + + func testShouldDecodeNullSystemFieldsAsAbsent() throws { + let json = """ + {"id":"\(proposalId)","ownerId":"\(ownerId)",\ + "revision":null,"createdAt":null,"updatedAt":null,\ + "title":"t","descriptionDocument":null,"url":"https://dash.org","open":true} + """ + let proposal = try decode(MultipleChoiceProposal.self, json) + + XCTAssertNil(proposal.revision) + XCTAssertNil(proposal.createdAtMs) + XCTAssertNil(proposal.createdAt) + XCTAssertNil(proposal.updatedAtMs) + XCTAssertNil(proposal.updatedAt) + } + + func testShouldDecodeAListingInItsOrder() throws { + let first = proposalJSON(descriptionDocument: "null", url: #""https://dash.org""#) + let second = first.replacingOccurrences(of: proposalId, with: otherChoiceId) + let listing = try decode([MultipleChoiceProposal].self, "[\(first),\(second)]") + + XCTAssertEqual(listing.map(\.id), [proposalId, otherChoiceId]) + XCTAssertEqual(try decode([MultipleChoiceProposal].self, "[]"), []) + } + + func testShouldRefuseAProposalMissingARequiredField() { + let json = proposalJSON(descriptionDocument: "null", url: "null") + .replacingOccurrences(of: #","open":true"#, with: "") + + XCTAssertThrowsError(try decode(MultipleChoiceProposal.self, json)) { error in + guard case SDKError.serializationError = error else { + return XCTFail("expected a serialization error, got \(error)") + } + } + } + + // MARK: - Choice + + func testShouldDecodeAChoiceWithEveryField() throws { + let choice = try decode( + ProposalChoice.self, + choiceJSON(id: choiceId, description: #""Twice the size it is today.""#) + ) + + XCTAssertEqual(choice.id, choiceId) + XCTAssertEqual(choice.ownerId, ownerId) + XCTAssertEqual(choice.proposalId, proposalId) + XCTAssertNil(choice.revision) + XCTAssertEqual(choice.createdAtMs, createdAt) + XCTAssertEqual(choice.createdAt, Date(timeIntervalSince1970: 1_700_000_000)) + XCTAssertNil(choice.updatedAtMs) + XCTAssertEqual(choice.title, "Double it") + XCTAssertEqual(choice.description, "Twice the size it is today.") + } + + func testShouldDecodeAChoiceWithoutADescription() throws { + let choice = try decode(ProposalChoice.self, choiceJSON(id: choiceId, description: "null")) + + XCTAssertNil(choice.description) + XCTAssertEqual(choice.title, "Double it") + } + + // MARK: - Vote + + func testShouldDecodeARunningVoteWithItsChoicesAndTallies() throws { + let json = """ + {"choices":[\ + {"id":"\(otherChoiceId)","choice":null,"voteTally":null},\ + {"id":"\(choiceId)","choice":\(choiceJSON(id: choiceId, description: "null")),"voteTally":12}],\ + "abstainVoteTally":3,"noneOfTheChoicesVoteTally":1,"result":null} + """ + let vote = try decode(MultipleChoiceProposalVote.self, json) + + XCTAssertEqual(vote.choices.map(\.id), [otherChoiceId, choiceId]) + XCTAssertNil(vote.choices[0].choice) + XCTAssertNil(vote.choices[0].voteTally) + XCTAssertEqual(vote.choices[1].choice?.id, choiceId) + XCTAssertEqual(vote.choices[1].choice?.title, "Double it") + XCTAssertEqual(vote.choices[1].voteTally, 12) + XCTAssertEqual(vote.abstainVoteTally, 3) + XCTAssertEqual(vote.noneOfTheChoicesVoteTally, 1) + XCTAssertNil(vote.result) + } + + func testShouldDecodeHowAFinishedVoteEnded() throws { + for (outcomeName, outcome, keptChoiceId) in [ + ("keptChoice", MultipleChoiceProposalVote.Outcome.keptChoice, #""\#(choiceId)""#), + ("noneOfTheChoices", .noneOfTheChoices, "null"), + ("noWinner", .noWinner, "null"), + ] { + let json = """ + {"choices":[{"id":"\(choiceId)","choice":null,"voteTally":9}],\ + "abstainVoteTally":null,"noneOfTheChoicesVoteTally":4,\ + "result":{"outcome":"\(outcomeName)","keptChoiceId":\(keptChoiceId),\ + "finalizationBlock":{"height":9,"coreHeight":42,"timeMs":9000,"epoch":3}}} + """ + let vote = try decode(MultipleChoiceProposalVote.self, json) + let result = try XCTUnwrap(vote.result, outcomeName) + + XCTAssertEqual(result.outcome, outcome) + XCTAssertEqual(result.keptChoiceId, outcome == .keptChoice ? choiceId : nil) + XCTAssertEqual(result.finalizationBlock.height, 9) + XCTAssertEqual(result.finalizationBlock.coreHeight, 42) + XCTAssertEqual(result.finalizationBlock.timeMs, 9000) + XCTAssertEqual(result.finalizationBlock.epoch, 3) + XCTAssertEqual(result.finalizationBlock.time, Date(timeIntervalSince1970: 9)) + XCTAssertEqual(vote.choices.first?.voteTally, 9) + XCTAssertNil(vote.choices.first?.choice) + XCTAssertNil(vote.abstainVoteTally) + XCTAssertEqual(vote.noneOfTheChoicesVoteTally, 4) + } + } + + func testShouldDecodeAVoteWithNoChoiceAsEmpty() throws { + let vote = try decode( + MultipleChoiceProposalVote.self, + #"{"choices":[],"abstainVoteTally":null,"noneOfTheChoicesVoteTally":null,"result":null}"# + ) + + XCTAssertEqual(vote.choices, []) + XCTAssertNil(vote.abstainVoteTally) + XCTAssertNil(vote.noneOfTheChoicesVoteTally) + XCTAssertNil(vote.result) + } + + func testShouldRefuseAnUnknownOutcome() { + let json = """ + {"choices":[],"abstainVoteTally":null,"noneOfTheChoicesVoteTally":null,\ + "result":{"outcome":"locked","keptChoiceId":null,\ + "finalizationBlock":{"height":9,"coreHeight":42,"timeMs":9000,"epoch":3}}} + """ + + XCTAssertThrowsError(try decode(MultipleChoiceProposalVote.self, json)) + } + + // MARK: - Masternode answer and vote choice + + func testShouldDecodeAMasternodeAnswerForEveryChoice() throws { + XCTAssertEqual( + try decode(MultipleChoiceVoteChoice.self, #"{"choice":"choice","choiceId":"\#(choiceId)"}"#), + .choice(id: choiceId) + ) + XCTAssertEqual( + try decode(MultipleChoiceVoteChoice.self, #"{"choice":"noneOfTheChoices","choiceId":null}"#), + .noneOfTheChoices + ) + XCTAssertEqual( + try decode(MultipleChoiceVoteChoice.self, #"{"choice":"abstain","choiceId":null}"#), + .abstain + ) + } + + func testShouldRefuseAMasternodeAnswerThatCannotBeRead() { + // A vote for a choice that names none, and an unknown answer. + XCTAssertThrowsError( + try decode(MultipleChoiceVoteChoice.self, #"{"choice":"choice","choiceId":null}"#) + ) + XCTAssertThrowsError( + try decode(MultipleChoiceVoteChoice.self, #"{"choice":"lock","choiceId":null}"#) + ) + } + + /// The `vote_choice` byte must agree with `MultipleChoiceVoteChoiceFFI` in + /// `rs-sdk-ffi`: a choice 0, none of the choices 1, abstain 2. The FFI + /// requires `choice_id` for 0 and a null one otherwise. + func testShouldEncodeTheVoteChoicesAsTheFFIBytesAndChoiceId() { + XCTAssertEqual(MultipleChoiceVoteChoice.choice(id: choiceId).ffiTag, 0) + XCTAssertEqual(MultipleChoiceVoteChoice.noneOfTheChoices.ffiTag, 1) + XCTAssertEqual(MultipleChoiceVoteChoice.abstain.ffiTag, 2) + + XCTAssertEqual(MultipleChoiceVoteChoice.choice(id: choiceId).choiceId, choiceId) + XCTAssertNil(MultipleChoiceVoteChoice.noneOfTheChoices.choiceId) + XCTAssertNil(MultipleChoiceVoteChoice.abstain.choiceId) + } + + // MARK: - Credits + + func testShouldReadTheFeeAndFundAsDecimalCredits() throws { + XCTAssertEqual(try DecisionProposalJSON.credits(from: "20000000000"), 20_000_000_000) + XCTAssertEqual(try DecisionProposalJSON.credits(from: "18446744073709551615"), UInt64.max) + for notCredits in ["", "-1", "1.5", "\"20000000000\"", "18446744073709551616"] { + XCTAssertThrowsError(try DecisionProposalJSON.credits(from: notCredits), notCredits) { error in + guard case SDKError.serializationError = error else { + return XCTFail("expected a serialization error, got \(error)") + } + } + } + } +} diff --git a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/MultipleChoiceProposalMarshallingTests.swift b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/MultipleChoiceProposalMarshallingTests.swift new file mode 100644 index 00000000000..1ec4928d0d4 --- /dev/null +++ b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/MultipleChoiceProposalMarshallingTests.swift @@ -0,0 +1,207 @@ +import Foundation +import XCTest +@testable import SwiftDashSDK + +/// Hermetic tests for the C structs the multiple choice proposal wallet +/// wrappers hand to `platform_wallet_multiple_choice_proposal_*` +/// (`MultipleChoiceProposalParamsFFI`, `MultipleChoiceProposalEditFFI`, +/// `ChoiceParamsFFI`, `DescriptionDocumentFFI`). Each string goes through +/// `withDecisionProposalCString`, so one holding U+0000 is refused rather +/// than handed over cut short; each id must be the 32 bytes the Rust side +/// reads. No FFI call is made. +final class MultipleChoiceProposalMarshallingTests: XCTestCase { + private let documentId = Data(repeating: 5, count: 32) + private let contractId = Data(repeating: 6, count: 32) + + private var descriptionDocument: DescriptionDocumentParams { + DescriptionDocumentParams(id: documentId, contractId: contractId, documentType: "post") + } + + /// The string `pointer` holds up to its NUL terminator; `nil` for null. + private func string(_ pointer: UnsafePointer?) -> String? { + pointer.map { String(cString: $0) } + } + + /// The 32 bytes `pointer` holds; `nil` for null. + private func bytes32(_ pointer: UnsafePointer?) -> Data? { + pointer.map { Data(bytes: $0, count: 32) } + } + + /// The description document `pointer` holds, read as the Rust side reads + /// it; `nil` for null. + private func readDescriptionDocument( + _ pointer: UnsafePointer? + ) -> DescriptionDocumentParams? { + guard let document = pointer?.pointee else { return nil } + return DescriptionDocumentParams( + id: bytes32(document.id) ?? Data(), + contractId: bytes32(document.contract_id) ?? Data(), + documentType: string(document.document_type) ?? "" + ) + } + + /// `body` refuses with `PlatformWalletError.invalidParameter` naming + /// `field`, without running the marshalled body. + private func assertRefused( + field: String, + file: StaticString = #filePath, + line: UInt = #line, + _ body: (_ bodyRan: inout Bool) throws -> Void + ) { + var bodyRan = false + XCTAssertThrowsError(try body(&bodyRan), file: file, line: line) { error in + guard case PlatformWalletError.invalidParameter(let message) = error else { + return XCTFail("expected PlatformWalletError.invalidParameter, got \(error)", file: file, line: line) + } + XCTAssertTrue(message.hasPrefix("\(field) "), message, file: file, line: line) + } + XCTAssertFalse(bodyRan, "a refused value must not reach C", file: file, line: line) + } + + // MARK: - Create params + + func testShouldHandOverEveryCreateParam() throws { + let params = MultipleChoiceProposalParams( + title: "Which block size? 是 ✓", + descriptionDocument: descriptionDocument, + url: "https://forum.dash.org/t/block-size", + open: true + ) + try params.withFFI { ffi in + XCTAssertEqual(string(ffi.pointee.title), "Which block size? 是 ✓") + XCTAssertEqual(readDescriptionDocument(ffi.pointee.description_document), descriptionDocument) + XCTAssertEqual(string(ffi.pointee.url), "https://forum.dash.org/t/block-size") + XCTAssertTrue(ffi.pointee.open) + } + } + + func testShouldHandOverAbsentCreateParamsAsNullPointers() throws { + let params = MultipleChoiceProposalParams(title: "t", open: false) + try params.withFFI { ffi in + XCTAssertEqual(string(ffi.pointee.title), "t") + XCTAssertNil(ffi.pointee.description_document) + XCTAssertNil(ffi.pointee.url) + XCTAssertFalse(ffi.pointee.open) + } + } + + func testShouldRefuseACreateParamHoldingANUL() { + assertRefused(field: "title") { bodyRan in + try MultipleChoiceProposalParams(title: "Which\0", open: true).withFFI { _ in bodyRan = true } + } + assertRefused(field: "url") { bodyRan in + try MultipleChoiceProposalParams(title: "t", url: "https://\0", open: true) + .withFFI { _ in bodyRan = true } + } + var document = descriptionDocument + document.documentType = "po\0st" + assertRefused(field: "descriptionDocument.documentType") { bodyRan in + try MultipleChoiceProposalParams(title: "t", descriptionDocument: document, open: true) + .withFFI { _ in bodyRan = true } + } + } + + func testShouldRefuseADescriptionDocumentIdThatIsNot32Bytes() { + var shortId = descriptionDocument + shortId.id = Data(repeating: 5, count: 31) + assertRefused(field: "descriptionDocument.id") { bodyRan in + try MultipleChoiceProposalParams(title: "t", descriptionDocument: shortId, open: true) + .withFFI { _ in bodyRan = true } + } + var longContractId = descriptionDocument + longContractId.contractId = Data(repeating: 6, count: 33) + assertRefused(field: "descriptionDocument.contractId") { bodyRan in + try MultipleChoiceProposalParams(title: "t", descriptionDocument: longContractId, open: true) + .withFFI { _ in bodyRan = true } + } + } + + // MARK: - Edit + + func testShouldHandOverAnEditThatKeepsEverythingAsNullsWithoutFlags() throws { + try MultipleChoiceProposalEdit().withFFI { ffi in + XCTAssertNil(ffi.pointee.title) + XCTAssertNil(ffi.pointee.description_document) + XCTAssertFalse(ffi.pointee.remove_description_document) + XCTAssertNil(ffi.pointee.url) + XCTAssertFalse(ffi.pointee.remove_url) + } + } + + func testShouldHandOverAnEditThatSetsEveryField() throws { + let edit = MultipleChoiceProposalEdit( + title: "New title", + descriptionDocument: .set(descriptionDocument), + url: .set("https://dash.org") + ) + try edit.withFFI { ffi in + XCTAssertEqual(string(ffi.pointee.title), "New title") + XCTAssertEqual(readDescriptionDocument(ffi.pointee.description_document), descriptionDocument) + XCTAssertFalse(ffi.pointee.remove_description_document) + XCTAssertEqual(string(ffi.pointee.url), "https://dash.org") + XCTAssertFalse(ffi.pointee.remove_url) + } + } + + /// A removal is a null value beside a raised flag; the FFI refuses a + /// value together with its flag. + func testShouldHandOverARemovalAsANullBesideItsFlag() throws { + try MultipleChoiceProposalEdit(descriptionDocument: .remove).withFFI { ffi in + XCTAssertNil(ffi.pointee.description_document) + XCTAssertTrue(ffi.pointee.remove_description_document) + XCTAssertNil(ffi.pointee.url) + XCTAssertFalse(ffi.pointee.remove_url) + } + try MultipleChoiceProposalEdit(url: .remove).withFFI { ffi in + XCTAssertNil(ffi.pointee.description_document) + XCTAssertFalse(ffi.pointee.remove_description_document) + XCTAssertNil(ffi.pointee.url) + XCTAssertTrue(ffi.pointee.remove_url) + } + } + + func testShouldRefuseAnEditHoldingANULOrAShortId() { + assertRefused(field: "title") { bodyRan in + try MultipleChoiceProposalEdit(title: "\0").withFFI { _ in bodyRan = true } + } + assertRefused(field: "url") { bodyRan in + try MultipleChoiceProposalEdit(url: .set("a\0b")).withFFI { _ in bodyRan = true } + } + var shortId = descriptionDocument + shortId.id = Data() + assertRefused(field: "descriptionDocument.id") { bodyRan in + try MultipleChoiceProposalEdit(descriptionDocument: .set(shortId)).withFFI { _ in bodyRan = true } + } + } + + // MARK: - Choice + + func testShouldHandOverAChoice() throws { + try ProposalChoiceParams(title: "Double it", description: "Twice the size.").withFFI { ffi in + XCTAssertEqual(string(ffi.pointee.title), "Double it") + XCTAssertEqual(string(ffi.pointee.description), "Twice the size.") + } + try ProposalChoiceParams(title: "Keep it").withFFI { ffi in + XCTAssertEqual(string(ffi.pointee.title), "Keep it") + XCTAssertNil(ffi.pointee.description) + } + } + + func testShouldRefuseAChoiceHoldingANUL() { + assertRefused(field: "title") { bodyRan in + try ProposalChoiceParams(title: "Double\0it").withFFI { _ in bodyRan = true } + } + assertRefused(field: "description") { bodyRan in + try ProposalChoiceParams(title: "t", description: "\0").withFFI { _ in bodyRan = true } + } + } + + func testShouldPassTheBodysErrorThroughUnchanged() { + struct BodyError: Error, Equatable {} + XCTAssertThrowsError( + try ProposalChoiceParams(title: "t").withFFI { _ in throw BodyError() } + ) { error in + XCTAssertEqual(error as? BodyError, BodyError()) + } + } +} From adfa029b3c01b70a9ccb9e3f610fca55e80cc127 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Sat, 14 Nov 2026 06:46:13 +0700 Subject: [PATCH 26/26] fix(platform)!: the token marketplace starts with protocol version 16, not 15 (#5910) Co-authored-by: Claude Fable 5.2 Co-authored-by: Lil Claw --- Cargo.lock | 1 + .../src/data-model/non-transferable-tokens.md | 2 +- book/src/data-model/token-marketplace.md | 14 +- packages/data-contracts/src/lib.rs | 6 +- packages/rs-dpp/Cargo.toml | 5 + .../src/balances/total_tokens_balance/mod.rs | 4 +- .../token_configuration/mod.rs | 79 ++++-- .../token_marketplace_rules/v0/mod.rs | 4 +- packages/rs-dpp/src/system_data_contracts.rs | 20 +- .../fixtures/stored_contracts/stored.jsonl | 1 - .../tests/stored_contract_compatibility.rs | 6 +- .../create_genesis_state/v1/mod.rs | 19 +- .../v0/mod.rs | 240 +++--------------- .../v3/mod.rs | 2 +- .../processor/traits/is_allowed.rs | 108 ++++---- .../structure_v0/mod.rs | 3 +- .../batch/data_triggers/bindings/list/mod.rs | 13 +- .../data_triggers/bindings/list/v3/mod.rs | 3 +- .../tests/document/commit_reveal_lookup.rs | 26 +- .../batch/tests/document/deletion.rs | 5 +- .../batch/tests/document/dpns.rs | 6 +- .../batch/tests/document/dpns_v3.rs | 5 +- .../batch/tests/document/replacement.rs | 5 +- .../tests/document/token_market_orders.rs | 17 +- .../batch/tests/token/burn/mod.rs | 8 +- .../batch/tests/token/direct_selling/mod.rs | 8 +- .../batch/tests/token/non_transferable/mod.rs | 61 ++--- .../token/shielded/nullifier_batch_guard.rs | 24 +- .../tests/restore_constraints.rs | 7 +- .../contract_structure_error_tests.rs | 16 ++ .../contract_structure_error_tests.rs | 13 + packages/rs-drive/grovedb-structure.json | 20 +- .../rs-drive/src/cache/system_contracts.rs | 33 ++- .../fee_pots/estimated_costs/v1/mod.rs | 2 +- .../estimation_costs/for_balances/v1/mod.rs | 2 +- .../src/drive/initialization/v5/mod.rs | 10 +- .../prefunded_specialized_balances/mod.rs | 2 +- .../structure.rs | 2 +- .../calculate_total_tokens_balance/v0/mod.rs | 2 +- .../calculate_total_tokens_balance/v1/mod.rs | 2 +- .../calculate_total_tokens_balance/v2/mod.rs | 2 +- packages/rs-drive/src/drive/tokens/mod.rs | 2 +- .../order_escrow/estimated_costs/v0/mod.rs | 2 +- .../drive/tokens/order_escrow/insert_trees.rs | 8 +- .../src/drive/tokens/order_escrow/mod.rs | 80 +++--- packages/rs-drive/src/drive/tokens/paths.rs | 4 +- .../rs-drive/src/drive/tokens/structure.rs | 4 +- packages/rs-drive/src/structure/tests.rs | 9 +- .../document/verify_document_history/tests.rs | 6 +- .../drive_abci_validation_versions/v11.rs | 5 +- .../drive_token_method_versions/mod.rs | 4 +- .../drive_token_method_versions/v1.rs | 2 +- .../drive_token_method_versions/v3.rs | 4 +- .../src/version/drive_versions/v10.rs | 53 +--- .../feature_initial_protocol_versions.rs | 15 +- .../src/version/mocks/mod.rs | 1 + .../src/version/mocks/v5_test.rs | 79 ++++++ .../src/version/protocol_version.rs | 14 +- .../system_data_contract_versions/mod.rs | 2 +- .../system_data_contract_versions/v4.rs | 9 +- .../rs-platform-version/src/version/v15.rs | 62 +++-- .../Cargo.toml | 7 + .../src/local.rs | 18 +- .../src/provider.rs | 46 ++-- .../src/system_contracts.rs | 37 +-- .../src/verified_provider.rs | 28 +- .../Persistence/Types/TokenTypes.swift | 2 +- .../DataContractParserTradeModeTests.swift | 2 +- packages/token-market-contract/Cargo.toml | 5 + packages/token-market-contract/README.md | 9 +- packages/token-market-contract/src/lib.rs | 30 ++- .../src/tokens/configuration/trade_mode.rs | 3 +- 72 files changed, 712 insertions(+), 648 deletions(-) create mode 100644 packages/rs-platform-version/src/version/mocks/v5_test.rs diff --git a/Cargo.lock b/Cargo.lock index e3097c08145..99233b4a698 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6643,6 +6643,7 @@ dependencies = [ "hex", "js-sys", "lru", + "platform-version", "reqwest 0.12.28", "rs-dapi-client", "serde", diff --git a/book/src/data-model/non-transferable-tokens.md b/book/src/data-model/non-transferable-tokens.md index 800043a1783..ba1a3d1b079 100644 --- a/book/src/data-model/non-transferable-tokens.md +++ b/book/src/data-model/non-transferable-tokens.md @@ -46,7 +46,7 @@ contract update cannot change an existing token's configuration. | A document type of the token's own contract charging it with `effect: 0` (pay the contract owner) | `NonTransferableTokenPaymentMustBurnError` (10280) | Contract create and update, when the document type is parsed. A document payment refuses it again (`TokenNotTransferableError`, 40726) from the configuration the contract already carries, so a contract that bypassed registration cannot pay with it either | | A document type of another contract charging it | `TokenNotTransferableError` (40726) | Contract create and update state validation, which already reads the token's contract to check the token exists. Such a cost always pays the contract owner, since another contract's token cannot be burned (10261) | | `hasShieldedPool: true` | `NonTransferableTokenShieldedPoolError` (10279) | Contract create and update, before anything is charged | -| `marketplaceRules.tradeMode: Tradeable` (protocol version 15) | `NonTransferableTokenTradeableError` (10281) | Contract create and update, before anything is charged, and the batch advanced structure validation of a `TokenConfigUpdate` that makes the token tradeable: the mempool refuses it, and a block charges the signer and bumps the nonce | +| `marketplaceRules.tradeMode: Tradeable` (protocol version 16; refused as not active before it) | `NonTransferableTokenTradeableError` (10281) | Contract create and update, before anything is charged, and the batch advanced structure validation of a `TokenConfigUpdate` that makes the token tradeable: the mempool refuses it, and a block charges the signer and bumps the nonce | A shielded pool is refused because a note spent inside the pool can be unshielded to any identity, so shielding and unshielding would move the token between holders. The diff --git a/book/src/data-model/token-marketplace.md b/book/src/data-model/token-marketplace.md index 25d52b69cae..dea63942bc0 100644 --- a/book/src/data-model/token-marketplace.md +++ b/book/src/data-model/token-marketplace.md @@ -1,7 +1,9 @@ # Token Marketplace -From protocol version 15 a token can be tradeable: its holders can sell it to each other on -Platform at a price they set, and anyone can make an offer for it. Nobody has to trust the other +From protocol version 16 a token can be tradeable: its holders can sell it to each other on +Platform at a price they set, and anyone can make an offer for it. Nothing of the market exists +before that version: no escrow tree, no token market contract and no tradeable token. Nobody has +to trust the other side. The tokens a seller lists and the credits a buyer offers are held in escrow until the order is filled or cancelled, so a fill always delivers what the order promised. @@ -43,8 +45,8 @@ created tradeable becomes tradeable only if its issuer kept the right to change | Rule | Refused with | Where | |---|---|---| -| `Tradeable` before protocol version 15 | `StateTransitionNotActiveError` (10603), as `TokenTradeModeTradeable` on a contract and `TokenConfigUpdateMarketplaceTradeModeTradeable` on an update | Contract create and update, and the batch carrying the update, before anything is charged. Software older than protocol version 15 cannot decode the mode, so this is the refusal it gives too | -| `Tradeable` on a [non-transferable token](non-transferable-tokens.md) | `NonTransferableTokenTradeableError` (10281) | Contract create and update before anything is charged, and the advanced structure validation of a `TokenConfigUpdate`, which charges the signer and runs in check_tx too, so the mempool refuses the update | +| `Tradeable` before protocol version 16 | `StateTransitionNotActiveError` (10603), as `TokenTradeModeTradeable` on a contract and `TokenConfigUpdateMarketplaceTradeModeTradeable` on an update | Contract create and update, and the batch carrying the update, before anything is charged. Software older than protocol version 15 cannot decode the mode, so this is the refusal it gives too. Protocol version 15 decodes the mode and gives the same refusal: it has no transitions that place or fill an order, so no contract stores the mode before they exist | +| `Tradeable` on a [non-transferable token](non-transferable-tokens.md), from protocol version 16 | `NonTransferableTokenTradeableError` (10281) | Contract create and update before anything is charged, and the advanced structure validation of a `TokenConfigUpdate`, which charges the signer and runs in check_tx too, so the mempool refuses the update | A non-transferable token cannot be tradeable because filling a listing or an offer moves the token from the seller to the buyer, which is the transfer the token refuses. `transferable` is fixed @@ -53,8 +55,8 @@ when the token is created, so the trade mode is the only half of the rule an upd ## Where orders and escrow live Open orders are documents of the token market system contract -(`AE6yYq65VdfGCg2MSyV9vV7cWGiFWjbwBuy7THesDh4e`), registered at genesis from protocol version 15 -and inserted by the upgrade to 15. It has two document types, `ask` (a listing) and `bid` (an +(`AE6yYq65VdfGCg2MSyV9vV7cWGiFWjbwBuy7THesDh4e`), registered at genesis from protocol version 16 +and inserted by the upgrade to 16. It has two document types, `ask` (a listing) and `bid` (an offer), each with three indexes: | Index | Properties | Serves | diff --git a/packages/data-contracts/src/lib.rs b/packages/data-contracts/src/lib.rs index 7ee3f71f725..b4343a1d263 100644 --- a/packages/data-contracts/src/lib.rs +++ b/packages/data-contracts/src/lib.rs @@ -67,9 +67,9 @@ pub enum SystemDataContract { /// vote poll it funds (protocol version 15). Registered from protocol version 15 on: /// registered at genesis by chains born at 15 and inserted by the upgrade to 15. DecisionProposals = 11, - /// The open listings and offers of the token marketplace (protocol version 15). Registered - /// from protocol version 15 on: registered at genesis by chains born at 15 and inserted by - /// the upgrade to 15. + /// The open listings and offers of the token marketplace (protocol version 16). Registered + /// from protocol version 16 on: registered at genesis by chains born at 16 and inserted by + /// the upgrade to 16. TokenMarket = 12, } diff --git a/packages/rs-dpp/Cargo.toml b/packages/rs-dpp/Cargo.toml index 19df88f7b42..2fb61ac1afd 100644 --- a/packages/rs-dpp/Cargo.toml +++ b/packages/rs-dpp/Cargo.toml @@ -96,6 +96,11 @@ tracing = { version = "0.1.41" } grovedb-commitment-tree = { workspace = true, optional = true } [dev-dependencies] +# The test platform versions: the token marketplace is tested under one until protocol version +# 16 has tables. +platform-version = { path = "../rs-platform-version", features = [ + "mock-versions", +] } tokio = { version = "1.40", features = ["full"] } pretty_assertions = { version = "1.4.1" } dpp = { path = ".", default-features = false, features = [ diff --git a/packages/rs-dpp/src/balances/total_tokens_balance/mod.rs b/packages/rs-dpp/src/balances/total_tokens_balance/mod.rs index d29cc435c1b..b0bc14dc2b7 100644 --- a/packages/rs-dpp/src/balances/total_tokens_balance/mod.rs +++ b/packages/rs-dpp/src/balances/total_tokens_balance/mod.rs @@ -12,7 +12,7 @@ pub struct TotalTokensBalance { /// all the tokens held in token shielded pools (0 before protocol version 14) pub total_token_shielded_pool_balances: SumTokenAmount, /// all the tokens the token marketplace holds in escrow for open listings (0 before - /// protocol version 15) + /// protocol version 16) pub total_token_order_escrow_balances: SumTokenAmount, } @@ -72,7 +72,7 @@ impl TotalTokensBalance { } // Every protocol version runs this check. The escrow term is zero below protocol - // version 15, where `calculate_total_tokens_balance` 0 and 1 report none, so this + // version 16, where `calculate_total_tokens_balance` 0 and 1 report none, so this // refusal and its share of the sum below cannot change their verdict. if total_token_order_escrow_balances < 0 { return Err(ProtocolError::CriticalCorruptedCreditsCodeExecution( diff --git a/packages/rs-dpp/src/data_contract/associated_token/token_configuration/mod.rs b/packages/rs-dpp/src/data_contract/associated_token/token_configuration/mod.rs index f022ecc2f2c..e12c5867ad7 100644 --- a/packages/rs-dpp/src/data_contract/associated_token/token_configuration/mod.rs +++ b/packages/rs-dpp/src/data_contract/associated_token/token_configuration/mod.rs @@ -156,10 +156,12 @@ impl TokenConfiguration { } /// A tradeable token (`marketplaceRules.tradeMode` `Tradeable`) is admitted from protocol - /// version 15 (`TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION`): below it the mode is refused as - /// not active, the refusal software that predates the marketplace gives by failing to decode - /// it. A tradeable token must also be transferable, since filling a listing or an offer moves - /// the token from one identity to another. Checked on contract create and update. + /// version 16 (`TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION`): below it the mode is + /// refused as not active. Software that predates protocol version 15 gives that refusal by + /// failing to decode the mode; protocol version 15 decodes it and refuses it here, as it has + /// no way to trade a token. A tradeable token must also be transferable, since filling a + /// listing or an offer moves the token from one identity to another. Checked on contract + /// create and update. pub fn validate_marketplace_rules( &self, token_contract_position: TokenContractPosition, @@ -1212,6 +1214,7 @@ mod marketplace_rules_tests { use crate::data_contract::associated_token::token_configuration_item::TokenConfigurationChangeItem; use crate::data_contract::associated_token::token_marketplace_rules::accessors::v0::TokenMarketplaceRulesV0Setters; use crate::data_contract::associated_token::token_marketplace_rules::v0::TokenTradeMode; + use platform_version::version::mocks::v5_test::TEST_PROTOCOL_VERSION_5; fn not_tradeable() -> TokenConfiguration { TokenConfiguration::V0(TokenConfigurationV0::default_most_restrictive()) @@ -1229,6 +1232,15 @@ mod marketplace_rules_tests { PlatformVersion::get(14).expect("expected protocol version 14") } + /// The protocol version that admits a tradeable token. While it has no tables of its own, + /// the test version that selects the token marketplace stands in for it; once it has them, + /// they are the ones used. + fn protocol_version_admitting_tradeable() -> &'static PlatformVersion { + PlatformVersion::get(TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION) + .or_else(|_| PlatformVersion::get(TEST_PROTOCOL_VERSION_5)) + .expect("expected a version that admits a tradeable token") + } + #[test] fn should_accept_a_token_that_is_not_tradeable_at_every_protocol_version() { let configurations = BTreeMap::from([(0, not_tradeable())]); @@ -1237,31 +1249,43 @@ mod marketplace_rules_tests { } } + /// Protocol version 15 decodes the mode, creates the marketplace's state and still refuses + /// the mode: every version below the one that admits it does. #[test] - fn should_refuse_a_tradeable_token_as_not_active_before_protocol_version_15() { + fn should_refuse_a_tradeable_token_as_not_active_before_protocol_version_16() { let configurations = BTreeMap::from([(1, tradeable())]); - let result = validate_token_configurations(&configurations, protocol_version_14()); - match result.errors.as_slice() { - [error - @ ConsensusError::BasicError(BasicError::StateTransitionNotActiveError(inner))] => { - assert_eq!(inner.state_transition_type(), "TokenTradeModeTradeable"); - assert_eq!(inner.current_protocol_version(), 14); - assert_eq!( - inner.required_protocol_version(), - TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION - ); - assert_eq!(error.code(), 10603); + let protocol_version_15 = PlatformVersion::get(15).expect("expected protocol version 15"); + for platform_version in [protocol_version_14(), protocol_version_15] { + let result = validate_token_configurations(&configurations, platform_version); + match result.errors.as_slice() { + [error @ ConsensusError::BasicError(BasicError::StateTransitionNotActiveError( + inner, + ))] => { + assert_eq!(inner.state_transition_type(), "TokenTradeModeTradeable"); + assert_eq!( + inner.current_protocol_version(), + platform_version.protocol_version + ); + assert_eq!( + inner.required_protocol_version(), + TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION + ); + assert_eq!(inner.required_protocol_version(), 16); + assert_eq!(error.code(), 10603); + } + other => panic!("expected StateTransitionNotActiveError, got {other:?}"), } - other => panic!("expected StateTransitionNotActiveError, got {other:?}"), } } #[test] - fn should_accept_a_tradeable_transferable_token_from_protocol_version_15() { + fn should_accept_a_tradeable_transferable_token_from_protocol_version_16() { let configurations = BTreeMap::from([(0, tradeable())]); - assert!( - validate_token_configurations(&configurations, PlatformVersion::latest()).is_valid() - ); + assert!(validate_token_configurations( + &configurations, + protocol_version_admitting_tradeable() + ) + .is_valid()); } #[test] @@ -1269,7 +1293,8 @@ mod marketplace_rules_tests { let mut configuration = tradeable(); configuration.set_transferable(false); let configurations = BTreeMap::from([(3, configuration)]); - let result = validate_token_configurations(&configurations, PlatformVersion::latest()); + let result = + validate_token_configurations(&configurations, protocol_version_admitting_tradeable()); match result.errors.as_slice() { [error @ ConsensusError::BasicError(BasicError::NonTransferableTokenTradeableError( inner, @@ -1288,12 +1313,10 @@ mod marketplace_rules_tests { fn should_refuse_making_a_non_transferable_token_tradeable_through_its_configuration_item() { let mut configuration = not_tradeable(); configuration.set_transferable(false); + let platform_version = protocol_version_admitting_tradeable(); - let proposed = configuration.validate_trade_mode( - &TokenTradeMode::Tradeable, - 0, - PlatformVersion::latest(), - ); + let proposed = + configuration.validate_trade_mode(&TokenTradeMode::Tradeable, 0, platform_version); assert!(matches!( proposed.errors.as_slice(), [ConsensusError::BasicError( @@ -1304,7 +1327,7 @@ mod marketplace_rules_tests { configuration.apply_token_configuration_item( TokenConfigurationChangeItem::MarketplaceTradeMode(TokenTradeMode::Tradeable), ); - let applied = configuration.validate_marketplace_rules(0, PlatformVersion::latest()); + let applied = configuration.validate_marketplace_rules(0, platform_version); assert_eq!(applied.errors, proposed.errors); } diff --git a/packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/v0/mod.rs b/packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/v0/mod.rs index 370f9981d68..929570c8134 100644 --- a/packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/v0/mod.rs @@ -29,8 +29,8 @@ pub enum TokenTradeMode { NotTradeable, /// Holders may list the token at a price and make offers for it: listed tokens and offered /// credits are held in escrow until the order is filled or cancelled. Admitted from protocol - /// version 15 (`TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION`), and only on a transferable - /// token, since every fill moves the token from one identity to another. + /// version 16 (`TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION`), and only on a + /// transferable token, since every fill moves the token from one identity to another. Tradeable, } diff --git a/packages/rs-dpp/src/system_data_contracts.rs b/packages/rs-dpp/src/system_data_contracts.rs index 4c26d2df695..cd374605a75 100644 --- a/packages/rs-dpp/src/system_data_contracts.rs +++ b/packages/rs-dpp/src/system_data_contracts.rs @@ -1817,6 +1817,7 @@ mod token_market_tests { use crate::document::transfer::Transferable; use crate::nft::TradeMode; use crate::system_data_contracts::token_market_contract::v1::document_types::{ask, bid}; + use platform_version::version::mocks::v5_test::TEST_PLATFORM_V5; /// The order types are what the marketplace transitions rely on: only they create orders, /// orders stay mutable and deletable so a partial fill can rewrite them and a close can @@ -1824,8 +1825,10 @@ mod token_market_tests { /// `depth` index sums what the order holds in escrow. #[test] fn should_load_the_order_types_the_marketplace_writes() { + // The token marketplace starts with protocol version 16, which has no tables yet: the + // test version that selects it stands in. let contract = - load_system_data_contract(SystemDataContract::TokenMarket, PlatformVersion::latest()) + load_system_data_contract(SystemDataContract::TokenMarket, &TEST_PLATFORM_V5) .expect("the token market contract loads with full validation"); assert_eq!(contract.id(), token_market_contract::ID); assert_eq!(contract.owner_id(), token_market_contract::OWNER_ID); @@ -1908,10 +1911,15 @@ mod token_market_tests { } #[test] - fn should_not_exist_before_protocol_version_15() { - let platform_version = PlatformVersion::get(14).expect("protocol version 14"); - assert!( - load_system_data_contract(SystemDataContract::TokenMarket, platform_version).is_err() - ); + fn should_not_exist_before_protocol_version_16() { + for protocol_version in [14, 15] { + let platform_version = + PlatformVersion::get(protocol_version).expect("expected the protocol version"); + assert!( + load_system_data_contract(SystemDataContract::TokenMarket, platform_version) + .is_err(), + "protocol version {protocol_version}" + ); + } } } diff --git a/packages/rs-dpp/tests/fixtures/stored_contracts/stored.jsonl b/packages/rs-dpp/tests/fixtures/stored_contracts/stored.jsonl index 7ea1e4380ea..a3fc2ace36c 100644 --- a/packages/rs-dpp/tests/fixtures/stored_contracts/stored.jsonl +++ b/packages/rs-dpp/tests/fixtures/stored_contracts/stored.jsonl @@ -9,7 +9,6 @@ {"contract":"system AppConnect","sha256":"4d6dd642c6f74fe2fcfd04696bd8d58b8ca418586619301b235fe7729f73c09a","indexStructures":"05f449543911990d081569c8124f9fbb312a5d3dcbbe045d6f7dfb0a14dd8da4","bytes":"Au+WDqVpcuutvviifvfaXIH/S7OKApaXRX4k2kK3m1S3AgAAAAABAQAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARBsb2dpbktleVJlc3BvbnNlFgsSBHR5cGUSBm9iamVjdBIQZG9jdW1lbnRzTXV0YWJsZRMAEgxjYW5CZURlbGV0ZWQTARIXY3JlYXRpb25SZXN0cmljdGlvbk1vZGUCABIHaW5kaWNlcxUBFgISBG5hbWUSCWJ5UmVxdWVzdBIIdGVybWluYWwVAhIWYXBwRXBoZW1lcmFsUHViS2V5SGFzaBIIJG93bmVySWQSCnByb3BlcnRpZXMWAxIWYXBwRXBoZW1lcmFsUHViS2V5SGFzaBYGEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAhQSCG1heEl0ZW1zAhQSC2Rlc2NyaXB0aW9uEl5oYXNoMTYwIG9mIHRoZSBlcGhlbWVyYWwgcHVibGljIGtleSB0aGUgYXBwIHB1dCBpbiBpdHMgY29ubmVjdCByZXF1ZXN0OyBpZGVudGlmaWVzIHRoZSByZXF1ZXN0Eghwb3NpdGlvbgIAEhV3YWxsZXRFcGhlbWVyYWxQdWJLZXkWBhIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIhEghtYXhJdGVtcwIhEgtkZXNjcmlwdGlvbhJ5VGhlIHdhbGxldCdzIGNvbXByZXNzZWQgZXBoZW1lcmFsIHB1YmxpYyBrZXk7IHRoZSBhcHAgZGVyaXZlcyB0aGUgc2hhcmVkIHNlY3JldCBmcm9tIGl0IGFuZCBpdHMgb3duIGVwaGVtZXJhbCBwcml2YXRlIGtleRIIcG9zaXRpb24CARIQZW5jcnlwdGVkUGF5bG9hZBYGEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAjwSCG1heEl0ZW1zAvsCPBILZGVzY3JpcHRpb24SrVRoZSBncmFudGVkIHByaXZhdGUga2V5cyBlbmNyeXB0ZWQgdG8gdGhlIGFwcDogYSAyOC1ieXRlIGVudmVsb3BlIHBsdXMgMzIgYnl0ZXMgcGVyIGtleSwgb25lIHRvIHNldmVudGVlbiBrZXlzICh0aGUgc2Vzc2lvbiBrZXkgcGx1cyB1cCB0byBlaWdodCBiaW5kaW5ncyB3aXRoIGJvdGggcHVycG9zZXMpEghwb3NpdGlvbgICEghyZXF1aXJlZBUDEhZhcHBFcGhlbWVyYWxQdWJLZXlIYXNoEhV3YWxsZXRFcGhlbWVyYWxQdWJLZXkSEGVuY3J5cHRlZFBheWxvYWQSC2Rlc2NyaXB0aW9uEvsBDEEgd2FsbGV0J3MgcmVzcG9uc2UgYWZ0ZXIgYXBwcm92aW5nIGEgbG9naW4gcmVxdWVzdC4gVGhlIGZsYXQgZW50cnkgaXMga2V5ZWQgYnkgdGhlIHJlcXVlc3QgaGFzaCBhbmQgd2FsbGV0IGlkZW50aXR5LCBzbyBvdGhlciBpZGVudGl0aWVzIGNhbm5vdCBibG9jayBpdHMgd3JpdGUuIE9uIHJlLWxvZ2luIHRoZSB3YWxsZXQgZGVsZXRlcyBpdHMgcHJldmlvdXMgcmVzcG9uc2UgYnkgdmFsdWVzIGFuZCBjcmVhdGVzIGEgcmVzcG9uc2UgZm9yIHRoZSBuZXcgcmVxdWVzdC4SFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASCWluZGV4T25seRMBEgxlbnRyeVBheWxvYWQVAhIVd2FsbGV0RXBoZW1lcmFsUHViS2V5EhBlbmNyeXB0ZWRQYXlsb2FkAAAAAAAAAAAAAAEQbG9naW5LZXlSZXNwb25zZQADFmFwcEVwaGVtZXJhbFB1YktleUhhc2gMARQBFAEAAAAAAAAVd2FsbGV0RXBoZW1lcmFsUHViS2V5DAEhASEBAAAAAAAAEGVuY3J5cHRlZFBheWxvYWQMATwB+wI8AQAAAAAAAAMWYXBwRXBoZW1lcmFsUHViS2V5SGFzaAwBFAEUAQAAAAAAABV3YWxsZXRFcGhlbWVyYWxQdWJLZXkMASEBIQEAAAAAAAAQZW5jcnlwdGVkUGF5bG9hZAwBPAH7AjwBAAAAAAAAAQlieVJlcXVlc3QJYnlSZXF1ZXN0AAABAAAAAAAAAAAAAAAAAAECFmFwcEVwaGVtZXJhbFB1YktleUhhc2gIJG93bmVySWQAAAAAAAAAAAMWYXBwRXBoZW1lcmFsUHViS2V5SGFzaBBlbmNyeXB0ZWRQYXlsb2FkFXdhbGxldEVwaGVtZXJhbFB1YktleQMWYXBwRXBoZW1lcmFsUHViS2V5SGFzaBBlbmNyeXB0ZWRQYXlsb2FkFXdhbGxldEVwaGVtZXJhbFB1YktleQAAAAACEGVuY3J5cHRlZFBheWxvYWQVd2FsbGV0RXBoZW1lcmFsUHViS2V5AAAAAAABAAAAAAAAAgAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAACAM0AAQACAAABAQMWYXBwRXBoZW1lcmFsUHViS2V5SGFzaAABAAMAAAABAAABFAEUAAEAAAAVd2FsbGV0RXBoZW1lcmFsUHViS2V5AAEAAwAAAAEAAAEhASEAAQAAABBlbmNyeXB0ZWRQYXlsb2FkAAEAAwAAAAEAAAE8AfsCPAABAAAAAQABAxZhcHBFcGhlbWVyYWxQdWJLZXlIYXNoFXdhbGxldEVwaGVtZXJhbFB1YktleRBlbmNyeXB0ZWRQYXlsb2FkAAAAAAAAAAAA"} {"contract":"system ModerationCharters","sha256":"08e879d58b351ca5dbb3beb72f0c2905679a24233c4aef7682a5cf4d7bae24cb","indexStructures":"959daf512c8055ab2f16c63e84b5ca8cbf1fba87c461bbc30279be340c74ad35","bytes":"AsUG5khqxlKB/YcrVrm2EXCkf2AFa7mcLg4Kbe1N5PiBAgAAAAABAQAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABw5hZGRlZE1vZGVyYXRvchYIEgR0eXBlEgZvYmplY3QSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwESB2luZGljZXMVARYDEgRuYW1lEhZieUVsZWN0ZWRDaGFydGVyTWVtYmVyEgpwcm9wZXJ0aWVzFQIWARIQZWxlY3RlZENoYXJ0ZXJJZBIDYXNjFgESCG1lbWJlcklkEgNhc2MSBnVuaXF1ZRMBEgpwcm9wZXJ0aWVzFgMSEGVsZWN0ZWRDaGFydGVySWQWCBIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIgEghtYXhJdGVtcwIgEhBjb250ZW50TWVkaWFUeXBlEiFhcHBsaWNhdGlvbi94LmRhc2guZHBwLmlkZW50aWZpZXISCHJlZmVyc1RvFgMSBHR5cGUSEXBlcm1hbmVudERvY3VtZW50Egxkb2N1bWVudFR5cGUSDmVsZWN0ZWRDaGFydGVyEgV3aGVyZRYCEggkb3duZXJJZBIIJG93bmVySWQSEnN1Ym1pdHRlZENoYXJ0ZXJJZBISc3VibWl0dGVkQ2hhcnRlcklkEgtkZXNjcmlwdGlvbhIrVGhlIHNlYXRlZCBjaGFydGVyOyBvbmx5IGl0cyBsZWFkZXIgbWF5IGFkZBIIcG9zaXRpb24CABISc3VibWl0dGVkQ2hhcnRlcklkFgYSBHR5cGUSBWFycmF5EglieXRlQXJyYXkTARIIbWluSXRlbXMCIBIIbWF4SXRlbXMCIBIQY29udGVudE1lZGlhVHlwZRIhYXBwbGljYXRpb24veC5kYXNoLmRwcC5pZGVudGlmaWVyEghwb3NpdGlvbgIBEghtZW1iZXJJZBYJEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAiASEGNvbnRlbnRNZWRpYVR5cGUSIWFwcGxpY2F0aW9uL3guZGFzaC5kcHAuaWRlbnRpZmllchIMZGlzdGluY3RGcm9tEggkb3duZXJJZBIIcmVmZXJzVG8WAxIEdHlwZRIRcGVybWFuZW50RG9jdW1lbnQSDGRvY3VtZW50VHlwZRILam9pblJlcXVlc3QSBmZpbmRCeRYCEhJzdWJtaXR0ZWRDaGFydGVySWQSEnN1Ym1pdHRlZENoYXJ0ZXJJZBIIJG93bmVySWQSAS4SC2Rlc2NyaXB0aW9uEitBbiBpZGVudGl0eSB0aGF0IGFza2VkIHRvIGpvaW4gdGhlIHByb3Bvc2FsEghwb3NpdGlvbgICEghyZXF1aXJlZBUEEgokY3JlYXRlZEF0EhBlbGVjdGVkQ2hhcnRlcklkEhJzdWJtaXR0ZWRDaGFydGVySWQSCG1lbWJlcklkEhRhZGRpdGlvbmFsUHJvcGVydGllcxMAEgtkZXNjcmlwdGlvbhKJQSBtZW1iZXIgdGhlIGxlYWRlciBhZGRzIGFmdGVyIHRoZSBlbGVjdGlvbiwgYXQgbW9zdCB0aGUgdGFyZ2V0J3MgbWF4QWRkZWRNb2RlcmF0b3JzIGF0IGEgdGltZTsgZGVsZXRpbmcgaXQgdGFrZXMgdGhlIG1lbWJlciBvZmYgdGhlIHRlYW0OZWxlY3RlZENoYXJ0ZXIWCBIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASDGNhbkJlRGVsZXRlZBMAEgdpbmRpY2VzFQIWBBIEbmFtZRIQYnlUYXJnZXRDb250cmFjdBIKcHJvcGVydGllcxUBFgESEHRhcmdldENvbnRyYWN0SWQSA2FzYxIGdW5pcXVlEwESCWNvbnRlc3RlZBYCEgpyZXNvbHV0aW9uAgESC2Rlc2NyaXB0aW9uEh9Db250ZXN0IGZvciB0aGUgbW9kZXJhdGlvbiBzZWF0FgISBG5hbWUSEmJ5U3VibWl0dGVkQ2hhcnRlchIKcHJvcGVydGllcxUBFgESEnN1Ym1pdHRlZENoYXJ0ZXJJZBIDYXNjEgpwcm9wZXJ0aWVzFgMSEHRhcmdldENvbnRyYWN0SWQWBxIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIgEghtYXhJdGVtcwIgEhBjb250ZW50TWVkaWFUeXBlEiFhcHBsaWNhdGlvbi94LmRhc2guZHBwLmlkZW50aWZpZXISCHJlZmVyc1RvFgISBHR5cGUSCGNvbnRyYWN0EhRjb250cmFjdFJlcXVpcmVtZW50cxYBEgptb2RlcmF0aW9uEgxlbGVjdGlvbk9wZW4SCHBvc2l0aW9uAgASEnN1Ym1pdHRlZENoYXJ0ZXJJZBYHEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAiASEGNvbnRlbnRNZWRpYVR5cGUSIWFwcGxpY2F0aW9uL3guZGFzaC5kcHAuaWRlbnRpZmllchIIcmVmZXJzVG8WAxIEdHlwZRIRcGVybWFuZW50RG9jdW1lbnQSDGRvY3VtZW50VHlwZRIQc3VibWl0dGVkQ2hhcnRlchIFd2hlcmUWAhIIJG93bmVySWQSCCRvd25lcklkEhB0YXJnZXRDb250cmFjdElkEhB0YXJnZXRDb250cmFjdElkEghwb3NpdGlvbgIBEgdtZW1iZXJzFgcSBHR5cGUSBWFycmF5EghtaW5JdGVtcwIAEghtYXhJdGVtcwIPEgt1bmlxdWVJdGVtcxMBEgVpdGVtcxYHEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAiASEGNvbnRlbnRNZWRpYVR5cGUSIWFwcGxpY2F0aW9uL3guZGFzaC5kcHAuaWRlbnRpZmllchIMZGlzdGluY3RGcm9tEggkb3duZXJJZBIIcmVmZXJzVG8WAxIEdHlwZRIRcGVybWFuZW50RG9jdW1lbnQSDGRvY3VtZW50VHlwZRILam9pblJlcXVlc3QSBmZpbmRCeRYCEhJzdWJtaXR0ZWRDaGFydGVySWQSEnN1Ym1pdHRlZENoYXJ0ZXJJZBIIJG93bmVySWQSAS4SC2Rlc2NyaXB0aW9uEjFUZWFtIGJlc2lkZXMgdGhlIGxlYWRlciwgZWFjaCB3aXRoIGEgam9pbiByZXF1ZXN0Eghwb3NpdGlvbgICEghyZXF1aXJlZBUEEgokY3JlYXRlZEF0EhB0YXJnZXRDb250cmFjdElkEhJzdWJtaXR0ZWRDaGFydGVySWQSB21lbWJlcnMSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASC2Rlc2NyaXB0aW9uEihBIHByb3Bvc2FsIHB1dCB0byB0aGUgdm90ZSB3aXRoIGl0cyB0ZWFtC2pvaW5SZXF1ZXN0FgkSBHR5cGUSBm9iamVjdBIQZG9jdW1lbnRzTXV0YWJsZRMAEgxjYW5CZURlbGV0ZWQTABIkcmVxdWlyZXNJZGVudGl0eUVuY3J5cHRpb25Cb3VuZGVkS2V5AgESB2luZGljZXMVAhYDEgRuYW1lEhJieVN1Ym1pdHRlZENoYXJ0ZXISCnByb3BlcnRpZXMVAhYBEhJzdWJtaXR0ZWRDaGFydGVySWQSA2FzYxYBEggkb3duZXJJZBIDYXNjEgZ1bmlxdWUTARYCEgRuYW1lEgdieU93bmVyEgpwcm9wZXJ0aWVzFQEWARIIJG93bmVySWQSA2FzYxIKcHJvcGVydGllcxYFEhJzdWJtaXR0ZWRDaGFydGVySWQWBxIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIgEghtYXhJdGVtcwIgEhBjb250ZW50TWVkaWFUeXBlEiFhcHBsaWNhdGlvbi94LmRhc2guZHBwLmlkZW50aWZpZXISCHJlZmVyc1RvFgMSBHR5cGUSEXBlcm1hbmVudERvY3VtZW50Egxkb2N1bWVudFR5cGUSEHN1Ym1pdHRlZENoYXJ0ZXISBXdoZXJlFgESCCRvd25lcklkEgtyZWNpcGllbnRJZBIIcG9zaXRpb24CABILcmVjaXBpZW50SWQWCBIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIgEghtYXhJdGVtcwIgEhBjb250ZW50TWVkaWFUeXBlEiFhcHBsaWNhdGlvbi94LmRhc2guZHBwLmlkZW50aWZpZXISCHJlZmVyc1RvFgMSBHR5cGUSEWlkZW50aXR5UHVibGljS2V5Eg1rZXlJZFByb3BlcnR5Eg5yZWNpcGllbnRLZXlJZBIPa2V5UmVxdWlyZW1lbnRzFgISB3B1cnBvc2USCmRlY3J5cHRpb24SB2JvdW5kVG8SEHN1Ym1pdHRlZENoYXJ0ZXISC2Rlc2NyaXB0aW9uEhVUaGUgcHJvcG9zYWwncyBsZWFkZXISCHBvc2l0aW9uAgESDnJlY2lwaWVudEtleUlkFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQL8/////xIIcG9zaXRpb24CAhILc2VuZGVyS2V5SWQWBRIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAvz/////EghyZWZlcnNUbxYDEgR0eXBlEhFpZGVudGl0eVB1YmxpY0tleRIQaWRlbnRpdHlQcm9wZXJ0eRIIJG93bmVySWQSD2tleVJlcXVpcmVtZW50cxYCEgdwdXJwb3NlEgplbmNyeXB0aW9uEgdib3VuZFRvEgtqb2luUmVxdWVzdBIIcG9zaXRpb24CAxIQZW5jcnlwdGVkTWVzc2FnZRYHEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAvsEEBIMZW5jcnlwdGVkRm9yFgQSCXJlY2lwaWVudBILcmVjaXBpZW50SWQSDHJlY2lwaWVudEtleRIOcmVjaXBpZW50S2V5SWQSCXNlbmRlcktleRILc2VuZGVyS2V5SWQSBnNjaGVtZRIZZWNkaC1zZWNwMjU2azEtYWVzMjU2LWNiYxILZGVzY3JpcHRpb24SG1JlYWRhYmxlIGJ5IHRoZSBsZWFkZXIgb25seRIIcG9zaXRpb24CBBIIcmVxdWlyZWQVBhIKJGNyZWF0ZWRBdBISc3VibWl0dGVkQ2hhcnRlcklkEgtyZWNpcGllbnRJZBIOcmVjaXBpZW50S2V5SWQSC3NlbmRlcktleUlkEhBlbmNyeXB0ZWRNZXNzYWdlEhRhZGRpdGlvbmFsUHJvcGVydGllcxMAEgtkZXNjcmlwdGlvbhIiQW4gb2ZmZXIgdG8gam9pbiBhIHByb3Bvc2FsJ3MgdGVhbQZyZWFzb24WCBIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASDGNhbkJlRGVsZXRlZBMAEgdpbmRpY2VzFQEWAxIEbmFtZRILYnlPd25lckNvZGUSCnByb3BlcnRpZXMVAhYBEggkb3duZXJJZBIDYXNjFgESBGNvZGUSA2FzYxIGdW5pcXVlEwESCnByb3BlcnRpZXMWAxIEY29kZRYGEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIDEgltYXhMZW5ndGgCAxIHcGF0dGVybhIKXltBLVpdezN9JBILZGVzY3JpcHRpb24SKVRocmVlIHVwcGVyY2FzZSBsZXR0ZXJzLCB1bmlxdWUgcGVyIG93bmVyEghwb3NpdGlvbgIAEgVsYWJlbBYEEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgCQBIIcG9zaXRpb24CARILZGVzY3JpcHRpb24WBBIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCARIJbWF4TGVuZ3RoAvsEABIIcG9zaXRpb24CAhIIcmVxdWlyZWQVAxIKJGNyZWF0ZWRBdBIEY29kZRIFbGFiZWwSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASC2Rlc2NyaXB0aW9uEiBBIGdyb3VuZCBmb3IgYSBtb2RlcmF0aW9uIGFjdGlvbhByZW1vdmVkTW9kZXJhdG9yFggSBHR5cGUSBm9iamVjdBIQZG9jdW1lbnRzTXV0YWJsZRMAEgxjYW5CZURlbGV0ZWQTARIHaW5kaWNlcxUBFgMSBG5hbWUSFmJ5RWxlY3RlZENoYXJ0ZXJNZW1iZXISCnByb3BlcnRpZXMVAhYBEhBlbGVjdGVkQ2hhcnRlcklkEgNhc2MWARIIbWVtYmVySWQSA2FzYxIGdW5pcXVlEwESCnByb3BlcnRpZXMWAhIQZWxlY3RlZENoYXJ0ZXJJZBYIEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAiASEGNvbnRlbnRNZWRpYVR5cGUSIWFwcGxpY2F0aW9uL3guZGFzaC5kcHAuaWRlbnRpZmllchIIcmVmZXJzVG8WAxIEdHlwZRIRcGVybWFuZW50RG9jdW1lbnQSDGRvY3VtZW50VHlwZRIOZWxlY3RlZENoYXJ0ZXISBXdoZXJlFgESCCRvd25lcklkEggkb3duZXJJZBILZGVzY3JpcHRpb24SLlRoZSBzZWF0ZWQgY2hhcnRlcjsgb25seSBpdHMgbGVhZGVyIG1heSByZW1vdmUSCHBvc2l0aW9uAgASCG1lbWJlcklkFgkSBHR5cGUSBWFycmF5EglieXRlQXJyYXkTARIIbWluSXRlbXMCIBIIbWF4SXRlbXMCIBIQY29udGVudE1lZGlhVHlwZRIhYXBwbGljYXRpb24veC5kYXNoLmRwcC5pZGVudGlmaWVyEgxkaXN0aW5jdEZyb20SCCRvd25lcklkEghyZWZlcnNUbxYEEgR0eXBlEhFwZXJtYW5lbnREb2N1bWVudBIMZG9jdW1lbnRUeXBlEg5lbGVjdGVkQ2hhcnRlchIGZmluZEJ5FgESAyRpZBIQZWxlY3RlZENoYXJ0ZXJJZBIGaW5MaXN0EgdtZW1iZXJzEgtkZXNjcmlwdGlvbhJUQW4gZWxlY3RlZCBtZW1iZXIgb2YgdGhlIGNoYXJ0ZXI7IGFuIGFkZGVkIG9uZSBpcyB0YWtlbiBvZmYgYnkgZGVsZXRpbmcgaXRzIGFkZGl0aW9uEghwb3NpdGlvbgIBEghyZXF1aXJlZBUDEgokY3JlYXRlZEF0EhBlbGVjdGVkQ2hhcnRlcklkEghtZW1iZXJJZBIUYWRkaXRpb25hbFByb3BlcnRpZXMTABILZGVzY3JpcHRpb24SS0FuIGVsZWN0ZWQgbWVtYmVyIHRoZSBsZWFkZXIgdGFrZXMgb2ZmIHRoZSB0ZWFtOyBkZWxldGluZyBpdCBwdXRzIHRoZW0gYmFjaxJyZXNpZ25hdGlvblJlcXVlc3QWCRIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASDGNhbkJlRGVsZXRlZBMBEg1vd25lclJlZmVyc1RvFgESBWFueU9mFQIWBBIEdHlwZRIRcGVybWFuZW50RG9jdW1lbnQSDGRvY3VtZW50VHlwZRIOZWxlY3RlZENoYXJ0ZXISBmZpbmRCeRYBEgMkaWQSEGVsZWN0ZWRDaGFydGVySWQSBmluTGlzdBIHbWVtYmVycxYDEgR0eXBlEhFkZWxldGFibGVEb2N1bWVudBIMZG9jdW1lbnRUeXBlEg5hZGRlZE1vZGVyYXRvchIGZmluZEJ5FgISEGVsZWN0ZWRDaGFydGVySWQSEGVsZWN0ZWRDaGFydGVySWQSCG1lbWJlcklkEgEuEgdpbmRpY2VzFQEWAxIEbmFtZRIVYnlFbGVjdGVkQ2hhcnRlck93bmVyEgpwcm9wZXJ0aWVzFQIWARIQZWxlY3RlZENoYXJ0ZXJJZBIDYXNjFgESCCRvd25lcklkEgNhc2MSBnVuaXF1ZRMBEgpwcm9wZXJ0aWVzFgUSEGVsZWN0ZWRDaGFydGVySWQWBxIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIgEghtYXhJdGVtcwIgEhBjb250ZW50TWVkaWFUeXBlEiFhcHBsaWNhdGlvbi94LmRhc2guZHBwLmlkZW50aWZpZXISCHJlZmVyc1RvFgMSBHR5cGUSEXBlcm1hbmVudERvY3VtZW50Egxkb2N1bWVudFR5cGUSDmVsZWN0ZWRDaGFydGVyEgV3aGVyZRYBEggkb3duZXJJZBILcmVjaXBpZW50SWQSCHBvc2l0aW9uAgASC3JlY2lwaWVudElkFggSBHR5cGUSBWFycmF5EglieXRlQXJyYXkTARIIbWluSXRlbXMCIBIIbWF4SXRlbXMCIBIQY29udGVudE1lZGlhVHlwZRIhYXBwbGljYXRpb24veC5kYXNoLmRwcC5pZGVudGlmaWVyEghyZWZlcnNUbxYDEgR0eXBlEhFpZGVudGl0eVB1YmxpY0tleRINa2V5SWRQcm9wZXJ0eRIOcmVjaXBpZW50S2V5SWQSD2tleVJlcXVpcmVtZW50cxYCEgdwdXJwb3NlEgpkZWNyeXB0aW9uEgdib3VuZFRvEhBzdWJtaXR0ZWRDaGFydGVyEgtkZXNjcmlwdGlvbhIKVGhlIGxlYWRlchIIcG9zaXRpb24CARIOcmVjaXBpZW50S2V5SWQWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAvz/////Eghwb3NpdGlvbgICEgtzZW5kZXJLZXlJZBYFEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASB21heGltdW0C/P////8SCHJlZmVyc1RvFgMSBHR5cGUSEWlkZW50aXR5UHVibGljS2V5EhBpZGVudGl0eVByb3BlcnR5Eggkb3duZXJJZBIPa2V5UmVxdWlyZW1lbnRzFgISB3B1cnBvc2USCmVuY3J5cHRpb24SB2JvdW5kVG8SC2pvaW5SZXF1ZXN0Eghwb3NpdGlvbgIDEhBlbmNyeXB0ZWRNZXNzYWdlFgcSBHR5cGUSBWFycmF5EglieXRlQXJyYXkTARIIbWluSXRlbXMCIBIIbWF4SXRlbXMC+wQQEgxlbmNyeXB0ZWRGb3IWBBIJcmVjaXBpZW50EgtyZWNpcGllbnRJZBIMcmVjaXBpZW50S2V5Eg5yZWNpcGllbnRLZXlJZBIJc2VuZGVyS2V5EgtzZW5kZXJLZXlJZBIGc2NoZW1lEhllY2RoLXNlY3AyNTZrMS1hZXMyNTYtY2JjEgtkZXNjcmlwdGlvbhIyV2h5IHRoZSBtZW1iZXIgbGVhdmVzLCByZWFkYWJsZSBieSB0aGUgbGVhZGVyIG9ubHkSCHBvc2l0aW9uAgQSCHJlcXVpcmVkFQYSCiRjcmVhdGVkQXQSEGVsZWN0ZWRDaGFydGVySWQSC3JlY2lwaWVudElkEg5yZWNpcGllbnRLZXlJZBILc2VuZGVyS2V5SWQSEGVuY3J5cHRlZE1lc3NhZ2USFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASC2Rlc2NyaXB0aW9uElhBIG1lbWJlciBhc2tpbmcgdG8gbGVhdmU7IHRoZSBsZWFkZXIgcmVtb3ZlcyB0aGVtLCBhbmQgZGVsZXRpbmcgaXQgd2l0aGRyYXdzIHRoZSByZXF1ZXN0EHN1Ym1pdHRlZENoYXJ0ZXIWChIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASDGNhbkJlRGVsZXRlZBMAEiRyZXF1aXJlc0lkZW50aXR5RGVjcnlwdGlvbkJvdW5kZWRLZXkCARIHaW5kaWNlcxUCFgISBG5hbWUSEGJ5VGFyZ2V0Q29udHJhY3QSCnByb3BlcnRpZXMVAhYBEhB0YXJnZXRDb250cmFjdElkEgNhc2MWARIKJGNyZWF0ZWRBdBIDYXNjFgISBG5hbWUSB2J5T3duZXISCnByb3BlcnRpZXMVARYBEggkb3duZXJJZBIDYXNjEgpwcm9wZXJ0aWVzFgUSEHRhcmdldENvbnRyYWN0SWQWCBIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIgEghtYXhJdGVtcwIgEhBjb250ZW50TWVkaWFUeXBlEiFhcHBsaWNhdGlvbi94LmRhc2guZHBwLmlkZW50aWZpZXISCHJlZmVyc1RvFgISBHR5cGUSCGNvbnRyYWN0EhRjb250cmFjdFJlcXVpcmVtZW50cxYBEgptb2RlcmF0aW9uEgdlbGVjdGVkEgtkZXNjcmlwdGlvbhIYVGhlIGNvbnRyYWN0IHRvIG1vZGVyYXRlEghwb3NpdGlvbgIAEgtkZXNjcmlwdGlvbhYFEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgC+xAAEghtYXhCeXRlcwL7EAASCHBvc2l0aW9uAgESB3JlYXNvbnMWBxIEdHlwZRIFYXJyYXkSCG1pbkl0ZW1zAgASCG1heEl0ZW1zAkASC3VuaXF1ZUl0ZW1zEwESBWl0ZW1zFgYSBHR5cGUSBWFycmF5EglieXRlQXJyYXkTARIIbWluSXRlbXMCIBIIbWF4SXRlbXMCIBIQY29udGVudE1lZGlhVHlwZRIhYXBwbGljYXRpb24veC5kYXNoLmRwcC5pZGVudGlmaWVyEghyZWZlcnNUbxYCEgR0eXBlEhFwZXJtYW5lbnREb2N1bWVudBIMZG9jdW1lbnRUeXBlEgZyZWFzb24SC2Rlc2NyaXB0aW9uEjVSZWFzb25zIHRoZSB0ZWFtIG1heSBhY3Qgb247IG5vbmUgbWVhbnMgaXQgY2Fubm90IGFjdBIIcG9zaXRpb24CAhIPbW9kZXJhdG9yc1NoYXJlFgUSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQJkEgtkZXNjcmlwdGlvbhJPUGVyY2VudCBvZiB0aGUgZGVjbGFyZWQgbW9kZXJhdG9ycyBmZWUgdGFrZW47IGFic2VudCBpcyAxMDAsIDAgdGFrZXMgbm8gcmV3YXJkcxIIcG9zaXRpb24CAxILcmV3YXJkU3BsaXQWBhIEdHlwZRIGb2JqZWN0Egpwcm9wZXJ0aWVzFgMSBmxlYWRlchYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASB21heGltdW0CZBIIcG9zaXRpb24CABIFZXF1YWwWBRIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAmQSC2Rlc2NyaXB0aW9uEiVTcGxpdCBlcXVhbGx5IGFtb25nIHRoZSBvdGhlciBtZW1iZXJzEghwb3NpdGlvbgIBEgdhY3Rpb25zFgUSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQJkEgtkZXNjcmlwdGlvbhIVU3BsaXQgYnkgYWN0aW9uIGNvdW50Eghwb3NpdGlvbgICEghyZXF1aXJlZBUDEgZsZWFkZXISBWVxdWFsEgdhY3Rpb25zEhRhZGRpdGlvbmFsUHJvcGVydGllcxMAEgtkZXNjcmlwdGlvbhIaUGVyY2VudGFnZXMgc3VtbWluZyB0byAxMDASCHBvc2l0aW9uAgQSCHJlcXVpcmVkFQUSCiRjcmVhdGVkQXQSEHRhcmdldENvbnRyYWN0SWQSC2Rlc2NyaXB0aW9uEgdyZWFzb25zEgtyZXdhcmRTcGxpdBITcHJvcGVydHlDb25zdHJhaW50cxYBEhJyZXdhcmRTcGxpdElzV2hvbGUWARIFZXF1YWwVAhYBEgNhZGQVAxIScmV3YXJkU3BsaXQubGVhZGVyEhFyZXdhcmRTcGxpdC5lcXVhbBITcmV3YXJkU3BsaXQuYWN0aW9ucwJkEhRhZGRpdGlvbmFsUHJvcGVydGllcxMAEgtkZXNjcmlwdGlvbhIhQSBwcm9wb3NhbCB0byBtb2RlcmF0ZSBhIGNvbnRyYWN0AAAAAAAAAAAAAAcOYWRkZWRNb2RlcmF0b3IAAxBlbGVjdGVkQ2hhcnRlcklkEwMADmVsZWN0ZWRDaGFydGVyAggkb3duZXJJZAgkb3duZXJJZBJzdWJtaXR0ZWRDaGFydGVySWQSc3VibWl0dGVkQ2hhcnRlcklkAAEAAAAAAAASc3VibWl0dGVkQ2hhcnRlcklkDQEAAAAAAAAIbWVtYmVySWQTBgALam9pblJlcXVlc3QAAAIIJG93bmVySWQAEnN1Ym1pdHRlZENoYXJ0ZXJJZAISc3VibWl0dGVkQ2hhcnRlcklkAAAAAQAAAQAAAAADEGVsZWN0ZWRDaGFydGVySWQTAwAOZWxlY3RlZENoYXJ0ZXICCCRvd25lcklkCCRvd25lcklkEnN1Ym1pdHRlZENoYXJ0ZXJJZBJzdWJtaXR0ZWRDaGFydGVySWQAAQAAAAAAABJzdWJtaXR0ZWRDaGFydGVySWQNAQAAAAAAAAhtZW1iZXJJZBMGAAtqb2luUmVxdWVzdAAAAggkb3duZXJJZAASc3VibWl0dGVkQ2hhcnRlcklkAhJzdWJtaXR0ZWRDaGFydGVySWQAAAABAAABAAAAAAEWYnlFbGVjdGVkQ2hhcnRlck1lbWJlchZieUVsZWN0ZWRDaGFydGVyTWVtYmVyAhBlbGVjdGVkQ2hhcnRlcklkAQhtZW1iZXJJZAEBAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAMQZWxlY3RlZENoYXJ0ZXJJZAhtZW1iZXJJZBJzdWJtaXR0ZWRDaGFydGVySWQABAokY3JlYXRlZEF0EGVsZWN0ZWRDaGFydGVySWQIbWVtYmVySWQSc3VibWl0dGVkQ2hhcnRlcklkAAAAAAAAAAAAAAEAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAqQABAAIAAAEBAxBlbGVjdGVkQ2hhcnRlcklkAAEAAwAAAAEAAAEgASAAAQAAABJzdWJtaXR0ZWRDaGFydGVySWQAAQADAAAAAQAAASABIAABAAAACG1lbWJlcklkAAEAAwAAAAEAAAEgASAAAQAAAAEAAQMQZWxlY3RlZENoYXJ0ZXJJZBJzdWJtaXR0ZWRDaGFydGVySWQIbWVtYmVySWQAAAAAAAAAAAAOZWxlY3RlZENoYXJ0ZXIAAxB0YXJnZXRDb250cmFjdElkEwEBAQAAAAAAAAEAAAAAAAASc3VibWl0dGVkQ2hhcnRlcklkEwMAEHN1Ym1pdHRlZENoYXJ0ZXICCCRvd25lcklkCCRvd25lcklkEHRhcmdldENvbnRyYWN0SWQQdGFyZ2V0Q29udHJhY3RJZAABAAAAAAAAB21lbWJlcnMUEwYAC2pvaW5SZXF1ZXN0AAACCCRvd25lcklkABJzdWJtaXR0ZWRDaGFydGVySWQCEnN1Ym1pdHRlZENoYXJ0ZXJJZAAAAAAAAAEADwEBAAABAAAAAAMQdGFyZ2V0Q29udHJhY3RJZBMBAQEAAAAAAAABAAAAAAAAEnN1Ym1pdHRlZENoYXJ0ZXJJZBMDABBzdWJtaXR0ZWRDaGFydGVyAggkb3duZXJJZAgkb3duZXJJZBB0YXJnZXRDb250cmFjdElkEHRhcmdldENvbnRyYWN0SWQAAQAAAAAAAAdtZW1iZXJzFBMGAAtqb2luUmVxdWVzdAAAAggkb3duZXJJZAASc3VibWl0dGVkQ2hhcnRlcklkAhJzdWJtaXR0ZWRDaGFydGVySWQAAAAAAAABAA8BAQAAAQAAAAACEmJ5U3VibWl0dGVkQ2hhcnRlchJieVN1Ym1pdHRlZENoYXJ0ZXIBEnN1Ym1pdHRlZENoYXJ0ZXJJZAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAEGJ5VGFyZ2V0Q29udHJhY3QQYnlUYXJnZXRDb250cmFjdAEQdGFyZ2V0Q29udHJhY3RJZAEBAQEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAwltZW1iZXJzW10Sc3VibWl0dGVkQ2hhcnRlcklkEHRhcmdldENvbnRyYWN0SWQABAokY3JlYXRlZEF0B21lbWJlcnMSc3VibWl0dGVkQ2hhcnRlcklkEHRhcmdldENvbnRyYWN0SWQAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgC7AAEAAgAAAQEDEHRhcmdldENvbnRyYWN0SWQAAQADAAAAAQAAASABIAABAAAAEnN1Ym1pdHRlZENoYXJ0ZXJJZAABAAMAAAABAAABIAEgAAEAAAAHbWVtYmVycwABAAMAAAABAQABAAMAAAABAAABIAEgAAEAAAAAAQABDwEBAAAAAAEAAQMQdGFyZ2V0Q29udHJhY3RJZBJzdWJtaXR0ZWRDaGFydGVySWQHbWVtYmVycwAAAAAAAAAAAAtqb2luUmVxdWVzdAAFEnN1Ym1pdHRlZENoYXJ0ZXJJZBMDABBzdWJtaXR0ZWRDaGFydGVyAQtyZWNpcGllbnRJZAgkb3duZXJJZAABAAAAAAAAC3JlY2lwaWVudElkEwQOcmVjaXBpZW50S2V5SWQBAgEQc3VibWl0dGVkQ2hhcnRlcgEAAAAAAAAOcmVjaXBpZW50S2V5SWQEAQAAAAAAAAtzZW5kZXJLZXlJZBUAAQEBC2pvaW5SZXF1ZXN0AQAAAAAAABBlbmNyeXB0ZWRNZXNzYWdlDAEgAfsEEAEAAAABAQtyZWNpcGllbnRJZA5yZWNpcGllbnRLZXlJZAtzZW5kZXJLZXlJZAAAAAUSc3VibWl0dGVkQ2hhcnRlcklkEwMAEHN1Ym1pdHRlZENoYXJ0ZXIBC3JlY2lwaWVudElkCCRvd25lcklkAAEAAAAAAAALcmVjaXBpZW50SWQTBA5yZWNpcGllbnRLZXlJZAECARBzdWJtaXR0ZWRDaGFydGVyAQAAAAAAAA5yZWNpcGllbnRLZXlJZAQBAAAAAAAAC3NlbmRlcktleUlkFQABAQELam9pblJlcXVlc3QBAAAAAAAAEGVuY3J5cHRlZE1lc3NhZ2UMASAB+wQQAQAAAAEBC3JlY2lwaWVudElkDnJlY2lwaWVudEtleUlkC3NlbmRlcktleUlkAAAAAgdieU93bmVyB2J5T3duZXIBCCRvd25lcklkAQABAAAAAAAAAAAAAAAAAAAAAAAAAAASYnlTdWJtaXR0ZWRDaGFydGVyEmJ5U3VibWl0dGVkQ2hhcnRlcgISc3VibWl0dGVkQ2hhcnRlcklkAQgkb3duZXJJZAEBAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAILcmVjaXBpZW50SWQSc3VibWl0dGVkQ2hhcnRlcklkARBlbmNyeXB0ZWRNZXNzYWdlBgokY3JlYXRlZEF0EGVuY3J5cHRlZE1lc3NhZ2ULcmVjaXBpZW50SWQOcmVjaXBpZW50S2V5SWQLc2VuZGVyS2V5SWQSc3VibWl0dGVkQ2hhcnRlcklkAAAAAAAAAAAAAAAAAAAAAQEAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAPsBQgABAAIAAAEBBRJzdWJtaXR0ZWRDaGFydGVySWQAAQADAAAAAQAAASABIAABAAAAC3JlY2lwaWVudElkAAEAAwAAAAEAAAEgASAAAQAAAA5yZWNpcGllbnRLZXlJZAABAAYAAAAAAAEBAgABAvz/////AAAAAAtzZW5kZXJLZXlJZAABAAYAAAAAAAEBAgABAvz/////AAAAABBlbmNyeXB0ZWRNZXNzYWdlAAEAAwAAAAEAAAEgAfsEEAABAAABAAEBC3JlY2lwaWVudElkDnJlY2lwaWVudEtleUlkC3NlbmRlcktleUlkAAEAAQUSc3VibWl0dGVkQ2hhcnRlcklkC3JlY2lwaWVudElkDnJlY2lwaWVudEtleUlkC3NlbmRlcktleUlkEGVuY3J5cHRlZE1lc3NhZ2UAAAAAAAAAAAAGcmVhc29uAAMEY29kZQsBAwEDAAEAAAAAAAAFbGFiZWwLAQEBQAABAAAAAAAAC2Rlc2NyaXB0aW9uCwEBAfsEAAAAAAAAAAAAAwRjb2RlCwEDAQMAAQAAAAAAAAVsYWJlbAsBAQFAAAEAAAAAAAALZGVzY3JpcHRpb24LAQEB+wQAAAAAAAAAAAABC2J5T3duZXJDb2RlC2J5T3duZXJDb2RlAggkb3duZXJJZAEEY29kZQEBAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwokY3JlYXRlZEF0BGNvZGUFbGFiZWwAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgB4AAEAAgAAAQEDBGNvZGUAAQAFAAAAAAEBAwEDAAEKXltBLVpdezN9JAAABWxhYmVsAAEABQAAAAABAQEBQAAAAAALZGVzY3JpcHRpb24AAQAFAAAAAAEBAQH7BAAAAAAAAQABAgRjb2RlBWxhYmVsAAAAAAAAAAAAEHJlbW92ZWRNb2RlcmF0b3IAAhBlbGVjdGVkQ2hhcnRlcklkEwMADmVsZWN0ZWRDaGFydGVyAQgkb3duZXJJZAgkb3duZXJJZAABAAAAAAAACG1lbWJlcklkEwkADmVsZWN0ZWRDaGFydGVyARBlbGVjdGVkQ2hhcnRlcklkAyRpZAAHbWVtYmVycwEAAAEAAAAAAhBlbGVjdGVkQ2hhcnRlcklkEwMADmVsZWN0ZWRDaGFydGVyAQgkb3duZXJJZAgkb3duZXJJZAABAAAAAAAACG1lbWJlcklkEwkADmVsZWN0ZWRDaGFydGVyARBlbGVjdGVkQ2hhcnRlcklkAyRpZAAHbWVtYmVycwEAAAEAAAAAARZieUVsZWN0ZWRDaGFydGVyTWVtYmVyFmJ5RWxlY3RlZENoYXJ0ZXJNZW1iZXICEGVsZWN0ZWRDaGFydGVySWQBCG1lbWJlcklkAQEBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhBlbGVjdGVkQ2hhcnRlcklkCG1lbWJlcklkAAMKJGNyZWF0ZWRBdBBlbGVjdGVkQ2hhcnRlcklkCG1lbWJlcklkAAAAAAAAAAAAAAEAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAcAABAAIAAAEBAhBlbGVjdGVkQ2hhcnRlcklkAAEAAwAAAAEAAAEgASAAAQAAAAhtZW1iZXJJZAABAAMAAAABAAABIAEgAAEAAAABAAECEGVsZWN0ZWRDaGFydGVySWQIbWVtYmVySWQAAAAAAAAAAAAScmVzaWduYXRpb25SZXF1ZXN0AAUQZWxlY3RlZENoYXJ0ZXJJZBMDAA5lbGVjdGVkQ2hhcnRlcgELcmVjaXBpZW50SWQIJG93bmVySWQAAQAAAAAAAAtyZWNpcGllbnRJZBMEDnJlY2lwaWVudEtleUlkAQIBEHN1Ym1pdHRlZENoYXJ0ZXIBAAAAAAAADnJlY2lwaWVudEtleUlkBAEAAAAAAAALc2VuZGVyS2V5SWQVAAEBAQtqb2luUmVxdWVzdAEAAAAAAAAQZW5jcnlwdGVkTWVzc2FnZQwBIAH7BBABAAAAAQELcmVjaXBpZW50SWQOcmVjaXBpZW50S2V5SWQLc2VuZGVyS2V5SWQAAAAFEGVsZWN0ZWRDaGFydGVySWQTAwAOZWxlY3RlZENoYXJ0ZXIBC3JlY2lwaWVudElkCCRvd25lcklkAAEAAAAAAAALcmVjaXBpZW50SWQTBA5yZWNpcGllbnRLZXlJZAECARBzdWJtaXR0ZWRDaGFydGVyAQAAAAAAAA5yZWNpcGllbnRLZXlJZAQBAAAAAAAAC3NlbmRlcktleUlkFQABAQELam9pblJlcXVlc3QBAAAAAAAAEGVuY3J5cHRlZE1lc3NhZ2UMASAB+wQQAQAAAAEBC3JlY2lwaWVudElkDnJlY2lwaWVudEtleUlkC3NlbmRlcktleUlkAAAAARVieUVsZWN0ZWRDaGFydGVyT3duZXIVYnlFbGVjdGVkQ2hhcnRlck93bmVyAhBlbGVjdGVkQ2hhcnRlcklkAQgkb3duZXJJZAEBAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAIQZWxlY3RlZENoYXJ0ZXJJZAtyZWNpcGllbnRJZAEQZW5jcnlwdGVkTWVzc2FnZQYKJGNyZWF0ZWRBdBBlbGVjdGVkQ2hhcnRlcklkEGVuY3J5cHRlZE1lc3NhZ2ULcmVjaXBpZW50SWQOcmVjaXBpZW50S2V5SWQLc2VuZGVyS2V5SWQAAAAAAAAAAAAAAQAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQcCCQAOZWxlY3RlZENoYXJ0ZXIBEGVsZWN0ZWRDaGFydGVySWQDJGlkAAdtZW1iZXJzCgAOYWRkZWRNb2RlcmF0b3IAAAIQZWxlY3RlZENoYXJ0ZXJJZAIQZWxlY3RlZENoYXJ0ZXJJZAhtZW1iZXJJZAAAAAAAAAAAAAIA+wE+AAEAAgAAAQEFEGVsZWN0ZWRDaGFydGVySWQAAQADAAAAAQAAASABIAABAAAAC3JlY2lwaWVudElkAAEAAwAAAAEAAAEgASAAAQAAAA5yZWNpcGllbnRLZXlJZAABAAYAAAAAAAEBAgABAvz/////AAAAAAtzZW5kZXJLZXlJZAABAAYAAAAAAAEBAgABAvz/////AAAAABBlbmNyeXB0ZWRNZXNzYWdlAAEAAwAAAAEAAAEgAfsEEAABAAABAAEBC3JlY2lwaWVudElkDnJlY2lwaWVudEtleUlkC3NlbmRlcktleUlkAAEAAQUQZWxlY3RlZENoYXJ0ZXJJZAtyZWNpcGllbnRJZA5yZWNpcGllbnRLZXlJZAtzZW5kZXJLZXlJZBBlbmNyeXB0ZWRNZXNzYWdlAAAAAAAAAAAAEHN1Ym1pdHRlZENoYXJ0ZXIABRB0YXJnZXRDb250cmFjdElkEwEBAAAAAAAAAAEAAAAAAAALZGVzY3JpcHRpb24LAQEB+xAAAfsQAAEAAAAAAAAHcmVhc29ucxQTAwAGcmVhc29uAAAAAAABAEABAQAAAAAAAA9tb2RlcmF0b3JzU2hhcmUIAAAAAAAAAAtyZXdhcmRTcGxpdBADBmxlYWRlcggBAAAAAAAABWVxdWFsCAEAAAAAAAAHYWN0aW9ucwgBAAAAAAAAAQAAAAAAAAcQdGFyZ2V0Q29udHJhY3RJZBMBAQAAAAAAAAABAAAAAAAAC2Rlc2NyaXB0aW9uCwEBAfsQAAH7EAABAAAAAAAAB3JlYXNvbnMUEwMABnJlYXNvbgAAAAAAAQBAAQEAAAAAAAAPbW9kZXJhdG9yc1NoYXJlCAAAAAAAAAATcmV3YXJkU3BsaXQuYWN0aW9ucwgBAAAAAAAAEXJld2FyZFNwbGl0LmVxdWFsCAEAAAAAAAAScmV3YXJkU3BsaXQubGVhZGVyCAEAAAAAAAACB2J5T3duZXIHYnlPd25lcgEIJG93bmVySWQBAAEAAAAAAAAAAAAAAAAAAAAAAAAAABBieVRhcmdldENvbnRyYWN0EGJ5VGFyZ2V0Q29udHJhY3QCEHRhcmdldENvbnRyYWN0SWQBCiRjcmVhdGVkQXQBAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAACCXJlYXNvbnNbXRB0YXJnZXRDb250cmFjdElkAAgKJGNyZWF0ZWRBdAtkZXNjcmlwdGlvbgdyZWFzb25zC3Jld2FyZFNwbGl0E3Jld2FyZFNwbGl0LmFjdGlvbnMRcmV3YXJkU3BsaXQuZXF1YWwScmV3YXJkU3BsaXQubGVhZGVyEHRhcmdldENvbnRyYWN0SWQAAAAAAAAAAAAAAAAAAAAAAQECAAAAAAAAAAAAAAAAAAAAAAAAAAAAARJyZXdhcmRTcGxpdElzV2hvbGUAAAYDARJyZXdhcmRTcGxpdC5sZWFkZXIAARFyZXdhcmRTcGxpdC5lcXVhbAABE3Jld2FyZFNwbGl0LmFjdGlvbnMAAMgAAAACAPsBZgABAAIAAAEBBRB0YXJnZXRDb250cmFjdElkAAEAAwAAAAEAAAEgASAAAQAAAAtkZXNjcmlwdGlvbgABAAUAAAAAAQEBAfsQAAH7EAAAAAAHcmVhc29ucwABAAMAAAABAQABAAMAAAABAAABIAEgAAEAAAAAAQABQAEBAAAAAA9tb2RlcmF0b3JzU2hhcmUAAQAGAAAAAAABAQIAAQJkAAAAAAtyZXdhcmRTcGxpdAABAAIAAAEBAwZsZWFkZXIAAQAGAAAAAAABAQIAAQJkAAAAAAVlcXVhbAABAAYAAAAAAAEBAgABAmQAAAAAB2FjdGlvbnMAAQAGAAAAAAABAQIAAQJkAAAAAAEAAQMGbGVhZGVyBWVxdWFsB2FjdGlvbnMAAAAAAAAAAQABBBB0YXJnZXRDb250cmFjdElkC2Rlc2NyaXB0aW9uB3JlYXNvbnMLcmV3YXJkU3BsaXQAAAAAAAAAAAA="} {"contract":"system DecisionProposals","sha256":"ad1fd3ed595e76cb6cbb2f4c0d6493bf9c9d66d2a7f4f84c2d5742089fd7a895","indexStructures":"0b3ce0e20cde7b45a89351adea5ee84da634ab0b36268c00891c7917a5969bc8","bytes":"AihRCgKmaz7aBrhvyubaqp21d2bTw3JcyFpYzR6uMcvIAgAAAAABAQAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwZjaG9pY2UWCRIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASDGNhbkJlRGVsZXRlZBMAEgdpbmRpY2VzFQEWBBIEbmFtZRIKYnlQcm9wb3NhbBIKcHJvcGVydGllcxUBFgESCnByb3Bvc2FsSWQSA2FzYxIGdW5pcXVlEwESCWNvbnRlc3RlZBYCEgpyZXNvbHV0aW9uAgISC2Rlc2NyaXB0aW9uEn1UaGUgY2hvaWNlcyBlbnRlcmVkIGZvciBvbmUgbXVsdGlwbGUgY2hvaWNlIHByb3Bvc2FsIGNvbnRlbmQgaW4gYSBtYXN0ZXJub2RlIHZvdGUsIGVhY2ggb24gaXRzIG93bjsgYSBsb2NrIG1lYW5zIG5vbmUgb2YgdGhlbRIKcHJvcGVydGllcxYDEgpwcm9wb3NhbElkFggSBHR5cGUSBWFycmF5EglieXRlQXJyYXkTARIIbWluSXRlbXMCIBIIbWF4SXRlbXMCIBIQY29udGVudE1lZGlhVHlwZRIhYXBwbGljYXRpb24veC5kYXNoLmRwcC5pZGVudGlmaWVyEghyZWZlcnNUbxYCEgR0eXBlEhFwZXJtYW5lbnREb2N1bWVudBIMZG9jdW1lbnRUeXBlEhZtdWx0aXBsZUNob2ljZVByb3Bvc2FsEgtkZXNjcmlwdGlvbhIxVGhlIG11bHRpcGxlIGNob2ljZSBwcm9wb3NhbCB0aGlzIGlzIGFuIGFuc3dlciB0bxIIcG9zaXRpb24CABIFdGl0bGUWBhIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCARIJbWF4TGVuZ3RoAoASCG1heEJ5dGVzAvsCABILZGVzY3JpcHRpb24SF1RoZSBhbnN3ZXIsIGluIG9uZSBsaW5lEghwb3NpdGlvbgIBEgtkZXNjcmlwdGlvbhYGEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgC+xAAEghtYXhCeXRlcwL7EAASC2Rlc2NyaXB0aW9uEiFXaGF0IHZvdGluZyBmb3IgdGhpcyBhbnN3ZXIgbWVhbnMSCHBvc2l0aW9uAgISCHJlcXVpcmVkFQMSCiRjcmVhdGVkQXQSCnByb3Bvc2FsSWQSBXRpdGxlEhNwcm9wZXJ0eUNvbnN0cmFpbnRzFgESI2Nsb3NlZFByb3Bvc2FsVGFrZXNJdHNPd25lcnNDaG9pY2VzFgESBmlmVGhlbhUCFgESBWVxdWFsFQIWARIKcmVmZXJlbmNlZBUCEgpwcm9wb3NhbElkEgRvcGVuAgAWARIFZXF1YWwVAhYBEgpyZWZlcmVuY2VkFQISCnByb3Bvc2FsSWQSCCRvd25lcklkEggkb3duZXJJZBIUYWRkaXRpb25hbFByb3BlcnRpZXMTABILZGVzY3JpcHRpb24SxEFuIGFuc3dlciB0byBhIG11bHRpcGxlIGNob2ljZSBwcm9wb3NhbC4gRW50ZXJpbmcgb25lIG9wZW5zIHRoZSBtYXN0ZXJub2RlIHZvdGUgYW1vbmcgdGhlIHByb3Bvc2FsJ3MgY2hvaWNlcywgb3Igam9pbnMgaXQ7IGFuIGlkZW50aXR5IG1heSBlbnRlciBzZXZlcmFsLCBhbmQgdGhlIGNob2ljZSB3aXRoIHRoZSBtb3N0IHZvdGVzIGlzIGtlcHQWbXVsdGlwbGVDaG9pY2VQcm9wb3NhbBYLEgR0eXBlEgZvYmplY3QSEGRvY3VtZW50c011dGFibGUTARIUZG9jdW1lbnRzS2VlcEhpc3RvcnkTARIMY2FuQmVEZWxldGVkEwASB2luZGljZXMVAhYCEgRuYW1lEgdieU93bmVyEgpwcm9wZXJ0aWVzFQIWARIIJG93bmVySWQSA2FzYxYBEgokY3JlYXRlZEF0EgNhc2MWAhIEbmFtZRILYnlDcmVhdGVkQXQSCnByb3BlcnRpZXMVARYBEgokY3JlYXRlZEF0EgNhc2MSCnByb3BlcnRpZXMWBhIFdGl0bGUWBhIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCARIJbWF4TGVuZ3RoAoASCG1heEJ5dGVzAvsCABILZGVzY3JpcHRpb24SGVRoZSBxdWVzdGlvbiwgaW4gb25lIGxpbmUSCHBvc2l0aW9uAgASDWRlc2NyaXB0aW9uSWQWCBIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIgEghtYXhJdGVtcwIgEhBjb250ZW50TWVkaWFUeXBlEiFhcHBsaWNhdGlvbi94LmRhc2guZHBwLmlkZW50aWZpZXISCHJlZmVyc1RvFgQSBHR5cGUSEW1vZGVyYXRlZERvY3VtZW50Egpjb250cmFjdElkEhskc2VsZi5kZXNjcmlwdGlvbkNvbnRyYWN0SWQSDGRvY3VtZW50VHlwZRIdJHNlbGYuZGVzY3JpcHRpb25Eb2N1bWVudFR5cGUSGGRvY3VtZW50VHlwZVJlcXVpcmVtZW50cxYDEgR3aGVuFgESBWFsbE9mFQIWARIIY29udGFpbnMVAhIRJGVsZWN0ZWRBYmlsaXRpZXMWARIFY29uc3QSD2RlbGV0ZURvY3VtZW50cxYBEgVhbnlPZhUCFgESBmFic2VudBIgJG1vZGVyYXRvckFiaWxpdGllcy5kZWxldGVXaXRoaW4WARIFYWxsT2YVAhYBEgdwcmVzZW50EiEkbW9kZXJhdG9yQWJpbGl0aWVzLmRlbGV0ZVNldHRsZWQWARIGYWJzZW50EjokbW9kZXJhdG9yQWJpbGl0aWVzLmRlbGV0ZVNldHRsZWQuYXBwcm92ZXJzUHJlZGF0ZURvY3VtZW50Egpwcm9wZXJ0aWVzFgISBGJvZHkWAxIEbmFtZRIEJGFueRIEdHlwZRIGc3RyaW5nEgR3aGVuFgESBWFsbE9mFQIWARIDbm90FgESCGNvbnRhaW5zFQISJSRtb2RlcmF0b3JBYmlsaXRpZXMuZGVsZXRlS2VlcHNGaWVsZHMSCSRwcm9wZXJ0eRYBEgNub3QWARIIY29udGFpbnMVAhIgJG1vZGVyYXRvckFiaWxpdGllcy5jaGFuZ2VGaWVsZHMSCSRwcm9wZXJ0eRIJYm9keUJ5dGVzFgQSBG5hbWUSBCRhbnkSBHR5cGUSBWFycmF5EglieXRlQXJyYXkTARIEd2hlbhYBEgVhbGxPZhUCFgESA25vdBYBEghjb250YWlucxUCEiUkbW9kZXJhdG9yQWJpbGl0aWVzLmRlbGV0ZUtlZXBzRmllbGRzEgkkcHJvcGVydHkWARIDbm90FgESCGNvbnRhaW5zFQISICRtb2RlcmF0b3JBYmlsaXRpZXMuY2hhbmdlRmllbGRzEgkkcHJvcGVydHkSB3JlcXVpcmUWARIFYW55T2YVAhIEYm9keRIJYm9keUJ5dGVzEgtkZXNjcmlwdGlvbhL7AVJUaGUgZG9jdW1lbnQgc2F5aW5nIHdoYXQgaXMgYmVpbmcgZGVjaWRlZCwgd2hlbiB0aGUgcHJvcG9zYWwgcG9pbnRzIGF0IG9uZTogYSBkb2N1bWVudCBvZiBhIG1vZGVyYXRlZCB0eXBlIGl0cyBjb250cmFjdCdzIGVsZWN0ZWQgdGVhbSBtYXkgZGVsZXRlLCBhdCBhbnkgdGltZSBhZnRlciBpdCBpcyB3cml0dGVuLCBob2xkaW5nIHRleHQgaXRzIGF1dGhvciB3cm90ZSB0aGF0IHRoZSByZW1vdmFsIHRha2VzIGF3YXkgd2l0aCBpdC4gTGVmdCBvdXQsIHdpdGggdGhlIHR3byBwcm9wZXJ0aWVzIG5hbWluZyB3aGVyZSBpdCBsaXZlcywgYnkgYSBwcm9wb3NhbCBkZXNjcmliZWQgYXQgaXRzIHVybBIIcG9zaXRpb24CARIVZGVzY3JpcHRpb25Db250cmFjdElkFggSBHR5cGUSBWFycmF5EglieXRlQXJyYXkTARIIbWluSXRlbXMCIBIIbWF4SXRlbXMCIBIQY29udGVudE1lZGlhVHlwZRIhYXBwbGljYXRpb24veC5kYXNoLmRwcC5pZGVudGlmaWVyEghyZWZlcnNUbxYCEgR0eXBlEghjb250cmFjdBIUY29udHJhY3RSZXF1aXJlbWVudHMWAhIKbW9kZXJhdGlvbhIHZWxlY3RlZBIOb3duZXJQcm90ZWN0ZWQTABILZGVzY3JpcHRpb24StFRoZSBjb250cmFjdCB0aGUgZGVzY3JpcHRpb24gZG9jdW1lbnQgbGl2ZXMgaW4sIG9uZSB3aG9zZSBtb2RlcmF0b3JzIHRoZSBtYXN0ZXJub2RlcyBlbGVjdCBhbmQgd2hvc2Ugb3duZXIgdGhleSBtYXkgbW9kZXJhdGUgbGlrZSBhbnlvbmUuIEdpdmVuIHdpdGggZGVzY3JpcHRpb25JZCwgYW5kIG9ubHkgd2l0aCBpdBIIcG9zaXRpb24CAhIXZGVzY3JpcHRpb25Eb2N1bWVudFR5cGUWBRIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCARIJbWF4TGVuZ3RoAkASC2Rlc2NyaXB0aW9uEllUaGUgZG9jdW1lbnQgdHlwZSBvZiB0aGUgZGVzY3JpcHRpb24gZG9jdW1lbnQuIEdpdmVuIHdpdGggZGVzY3JpcHRpb25JZCwgYW5kIG9ubHkgd2l0aCBpdBIIcG9zaXRpb24CAxIDdXJsFgcSBHR5cGUSBnN0cmluZxIGZm9ybWF0EgN1cmkSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgC+wIAEghtYXhCeXRlcwL7AgASC2Rlc2NyaXB0aW9uErJXaGVyZSB3aGF0IGlzIGJlaW5nIGRlY2lkZWQgaXMgZGVzY3JpYmVkLCBmb3IgYSBwcm9wb3NhbCB0aGF0IHBvaW50cyBhdCBubyBkZXNjcmlwdGlvbiBkb2N1bWVudDsgd2hlcmUgaXQgaXMgZGlzY3Vzc2VkLCBmb3Igb25lIHRoYXQgZG9lcy4gUmVxdWlyZWQgd2hlbiBkZXNjcmlwdGlvbklkIGlzIGxlZnQgb3V0Eghwb3NpdGlvbgIEEgRvcGVuFgMSBHR5cGUSB2Jvb2xlYW4SC2Rlc2NyaXB0aW9uElBXaGV0aGVyIGFueW9uZSBtYXkgZW50ZXIgY2hvaWNlczsgb25seSB0aGUgcHJvcG9zYWwncyBvd25lciBtYXkgd2hlbiBpdCBpcyBmYWxzZRIIcG9zaXRpb24CBRIIcmVxdWlyZWQVBBIKJGNyZWF0ZWRBdBIKJHVwZGF0ZWRBdBIFdGl0bGUSBG9wZW4SCWltbXV0YWJsZRUGEgRvcGVuFgISCHByb3BlcnR5EgV0aXRsZRIEd2hlbhYBEgtncmVhdGVyVGhhbhUCFgESCHN1YnRyYWN0FQISCiR1cGRhdGVkQXQSCiRjcmVhdGVkQXQC/ABt3QAWAhIIcHJvcGVydHkSDWRlc2NyaXB0aW9uSWQSBHdoZW4WARILZ3JlYXRlclRoYW4VAhYBEghzdWJ0cmFjdBUCEgokdXBkYXRlZEF0EgokY3JlYXRlZEF0AvwAbd0AFgISCHByb3BlcnR5EhVkZXNjcmlwdGlvbkNvbnRyYWN0SWQSBHdoZW4WARILZ3JlYXRlclRoYW4VAhYBEghzdWJ0cmFjdBUCEgokdXBkYXRlZEF0EgokY3JlYXRlZEF0AvwAbd0AFgISCHByb3BlcnR5EhdkZXNjcmlwdGlvbkRvY3VtZW50VHlwZRIEd2hlbhYBEgtncmVhdGVyVGhhbhUCFgESCHN1YnRyYWN0FQISCiR1cGRhdGVkQXQSCiRjcmVhdGVkQXQC/ABt3QAWAhIIcHJvcGVydHkSA3VybBIEd2hlbhYBEgtncmVhdGVyVGhhbhUCFgESCHN1YnRyYWN0FQISCiR1cGRhdGVkQXQSCiRjcmVhdGVkQXQC/ABt3QASE3Byb3BlcnR5Q29uc3RyYWludHMWAhIaZGVzY3JpYmVkQnlBRG9jdW1lbnRPckFVcmwWARIFYW55T2YVAhYBEgdwcmVzZW50Eg1kZXNjcmlwdGlvbklkFgESB3ByZXNlbnQSA3VybBIdZGVzY3JpcHRpb25Eb2N1bWVudE5hbWVkV2hvbGUWARICaW4VAhYBEgxjb3VudFByZXNlbnQVAxINZGVzY3JpcHRpb25JZBIVZGVzY3JpcHRpb25Db250cmFjdElkEhdkZXNjcmlwdGlvbkRvY3VtZW50VHlwZRUCAgACAxIUYWRkaXRpb25hbFByb3BlcnRpZXMTABILZGVzY3JpcHRpb24S+wItQSBxdWVzdGlvbiBwdXQgdG8gdGhlIG1hc3Rlcm5vZGVzIHdob3NlIGFuc3dlcnMgYXJlIHRoZSBjaG9pY2VzIGVudGVyZWQgZm9yIGl0LiBXaGF0IGlzIGJlaW5nIGRlY2lkZWQgaXMgc2FpZCBpbiBvbmUgb2YgdHdvIHBsYWNlcywgb3IgYm90aDogYSBkb2N1bWVudCB0aGUgcHJvcG9zYWwgcG9pbnRzIGF0LCBvZiBhIG1vZGVyYXRlZCB0eXBlIG9mIGEgY29udHJhY3Qgd2hvc2UgbW9kZXJhdG9ycyB0aGUgbWFzdGVybm9kZXMgZWxlY3QsIHNvIHRoYXQgdGhleSBjYW4gdGFrZSBpdCBkb3duOyBvciBhIHVybCwgd2hpY2ggbm90aGluZyBvbiBjaGFpbiBtb2RlcmF0ZXMuIEFueW9uZSBtYXkgZW50ZXIgY2hvaWNlcyB3aGVuIGl0IGlzIG9wZW4sIGFuZCBvbmx5IGl0cyBvd25lciB3aGVuIGl0IGlzIG5vdC4gSXRzIHRpdGxlLCB1cmwgYW5kIHRoZSBkZXNjcmlwdGlvbiBpdCBwb2ludHMgYXQgbWF5IGJlIGNoYW5nZWQgZm9yIHR3byBob3VycyBhZnRlciBpdCBpcyBjcmVhdGVkOyB3aGV0aGVyIGl0IGlzIG9wZW4gbmV2ZXIgY2hhbmdlcywgYW5kIGl0IGlzIG5ldmVyIGRlbGV0ZWQIcHJvcG9zYWwWChIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwESFGRvY3VtZW50c0tlZXBIaXN0b3J5EwESDGNhbkJlRGVsZXRlZBMAEgdpbmRpY2VzFQMWAhIEbmFtZRIJYnlFbmREYXRlEgpwcm9wZXJ0aWVzFQIWARIHZW5kRGF0ZRIDYXNjFgESCiRjcmVhdGVkQXQSA2FzYxYCEgRuYW1lEgdieU93bmVyEgpwcm9wZXJ0aWVzFQIWARIIJG93bmVySWQSA2FzYxYBEgokY3JlYXRlZEF0EgNhc2MWAhIEbmFtZRILYnlDcmVhdGVkQXQSCnByb3BlcnRpZXMVARYBEgokY3JlYXRlZEF0EgNhc2MSCnByb3BlcnRpZXMWBhIFdGl0bGUWBhIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCARIJbWF4TGVuZ3RoAoASCG1heEJ5dGVzAvsCABILZGVzY3JpcHRpb24SGVRoZSBxdWVzdGlvbiwgaW4gb25lIGxpbmUSCHBvc2l0aW9uAgASC2Rlc2NyaXB0aW9uFgYSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAgESCW1heExlbmd0aAL7EAASCG1heEJ5dGVzAvsQABILZGVzY3JpcHRpb24SGFdoYXQgYSB5ZXMgYW5kIGEgbm8gbWVhbhIIcG9zaXRpb24CARIDdXJsFgcSBHR5cGUSBnN0cmluZxIGZm9ybWF0EgN1cmkSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgC+wIAEghtYXhCeXRlcwL7AgASC2Rlc2NyaXB0aW9uEh9XaGVyZSB0aGUgcHJvcG9zYWwgaXMgZGlzY3Vzc2VkEghwb3NpdGlvbgICEgtwYXNzUGVyY2VudBYFEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAjISB21heGltdW0CUBILZGVzY3JpcHRpb24ScFRoZSBwcm9wb3NhbCBwYXNzZXMgd2hlbiB0aGUgeWVzIHZvdGluZyBwb3dlciBpcyBzdHJpY3RseSBtb3JlIHRoYW4gdGhpcyBwZXJjZW50IG9mIHRoZSB5ZXMgcGx1cyBubyB2b3RpbmcgcG93ZXISCHBvc2l0aW9uAgMSFW1pbmltdW1UdXJub3V0UGVyY2VudBYFEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASB21heGltdW0CMhILZGVzY3JpcHRpb24SilRoZSBsZWFzdCB5ZXMgcGx1cyBubyB2b3RpbmcgcG93ZXIgdGhlIHByb3Bvc2FsIG5lZWRzLCBhcyBhIHBlcmNlbnQgb2YgdGhlIG1hc3Rlcm5vZGUgbGlzdCdzIHRvdGFsIHZvdGluZyBwb3dlciB3aGVuIGl0IGNsb3Nlcywgcm91bmRlZCB1cBIIcG9zaXRpb24CBBIHZW5kRGF0ZRYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASC2Rlc2NyaXB0aW9uEjhXaGVuIHZvdGluZyBjbG9zZXMsIGluIG1pbGxpc2Vjb25kcyBzaW5jZSB0aGUgVW5peCBlcG9jaBIIcG9zaXRpb24CBRIIcmVxdWlyZWQVBxIKJGNyZWF0ZWRBdBIKJHVwZGF0ZWRBdBIFdGl0bGUSC2Rlc2NyaXB0aW9uEgtwYXNzUGVyY2VudBIVbWluaW11bVR1cm5vdXRQZXJjZW50EgdlbmREYXRlEglpbW11dGFibGUVBhILcGFzc1BlcmNlbnQSFW1pbmltdW1UdXJub3V0UGVyY2VudBIHZW5kRGF0ZRYCEghwcm9wZXJ0eRIFdGl0bGUSBHdoZW4WARILZ3JlYXRlclRoYW4VAhYBEghzdWJ0cmFjdBUCEgokdXBkYXRlZEF0EgokY3JlYXRlZEF0FgESA21pbhUCAvwFJlwAFgESBmRpdmlkZRUCFgESCHN1YnRyYWN0FQISB2VuZERhdGUSCiRjcmVhdGVkQXQCBRYCEghwcm9wZXJ0eRILZGVzY3JpcHRpb24SBHdoZW4WARILZ3JlYXRlclRoYW4VAhYBEghzdWJ0cmFjdBUCEgokdXBkYXRlZEF0EgokY3JlYXRlZEF0FgESA21pbhUCAvwFJlwAFgESBmRpdmlkZRUCFgESCHN1YnRyYWN0FQISB2VuZERhdGUSCiRjcmVhdGVkQXQCBRYCEghwcm9wZXJ0eRIDdXJsEgR3aGVuFgESC2dyZWF0ZXJUaGFuFQIWARIIc3VidHJhY3QVAhIKJHVwZGF0ZWRBdBIKJGNyZWF0ZWRBdBYBEgNtaW4VAgL8BSZcABYBEgZkaXZpZGUVAhYBEghzdWJ0cmFjdBUCEgdlbmREYXRlEgokY3JlYXRlZEF0AgUSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASC2Rlc2NyaXB0aW9uEvZBIHllcy9ubyBxdWVzdGlvbiBwdXQgdG8gdGhlIG1hc3Rlcm5vZGVzLiBDcmVhdGluZyBvbmUgb3BlbnMgaXRzIHZvdGUgcG9sbCwgZnVuZGVkIGJ5IGl0cyBvd25lci4gSXRzIHRpdGxlLCBkZXNjcmlwdGlvbiBhbmQgdXJsIG1heSBiZSBlZGl0ZWQgZm9yIGEgZGF5IGFmdGVyIGl0IGlzIGNyZWF0ZWQsIG9yIGEgZmlmdGggb2YgdGhlIHRpbWUgaXQgcnVucyBpZiB0aGF0IGlzIHNob3J0ZXI7IGl0cyBydWxlIG5ldmVyIGNoYW5nZXMAAAAAAAAAAAAAAwZjaG9pY2UAAwpwcm9wb3NhbElkEwMAFm11bHRpcGxlQ2hvaWNlUHJvcG9zYWwAAAEAAAAAAAAFdGl0bGULAQEBgAH7AgABAAAAAAAAC2Rlc2NyaXB0aW9uCwEBAfsQAAH7EAAAAAAAAAAAAwpwcm9wb3NhbElkEwMAFm11bHRpcGxlQ2hvaWNlUHJvcG9zYWwAAAEAAAAAAAAFdGl0bGULAQEBgAH7AgABAAAAAAAAC2Rlc2NyaXB0aW9uCwEBAfsQAAH7EAAAAAAAAAAAAQpieVByb3Bvc2FsCmJ5UHJvcG9zYWwBCnByb3Bvc2FsSWQBAQEBAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAEKcHJvcG9zYWxJZAADCiRjcmVhdGVkQXQKcHJvcG9zYWxJZAV0aXRsZQAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAEjY2xvc2VkUHJvcG9zYWxUYWtlc0l0c093bmVyc0Nob2ljZXMQAAABHSRyZWZlcmVuY2VkLnByb3Bvc2FsSWQuJC5vcGVuAAAABgAhJHJlZmVyZW5jZWQucHJvcG9zYWxJZC4kLiRvd25lcklkCCRvd25lcklkAAAAAAIAgQABAAIAAAEBAwpwcm9wb3NhbElkAAEAAwAAAAEAAAEgASAAAQAAAAV0aXRsZQABAAUAAAAAAQEBAYAB+wIAAAAAC2Rlc2NyaXB0aW9uAAEABQAAAAABAQEB+xAAAfsQAAAAAAEAAQIKcHJvcG9zYWxJZAV0aXRsZQAAAAAAAAAAABZtdWx0aXBsZUNob2ljZVByb3Bvc2FsAAYFdGl0bGULAQEBgAH7AgABAAAAAAAADWRlc2NyaXB0aW9uSWQTDAEVZGVzY3JpcHRpb25Db250cmFjdElkF2Rlc2NyaXB0aW9uRG9jdW1lbnRUeXBlAQIEYm9keQAAAAABBwIFAQQAAQUBBAEBCWJvZHlCeXRlcwABAAABBwIFAQQAAQUBBAEBAQECAARib2R5AAlib2R5Qnl0ZXMBBwIEAgIPZGVsZXRlRG9jdW1lbnRzBgILAAcCCgELAgAAAAAAAAAVZGVzY3JpcHRpb25Db250cmFjdElkEwEBAAAAAAAAAQAAAAAAAAAAF2Rlc2NyaXB0aW9uRG9jdW1lbnRUeXBlCwEBAUAAAAAAAAAAAAN1cmwLAQEB+wIAAfsCAAAAAAAAAAAEb3Blbg4BAAAAAAAABgV0aXRsZQsBAQGAAfsCAAEAAAAAAAANZGVzY3JpcHRpb25JZBMMARVkZXNjcmlwdGlvbkNvbnRyYWN0SWQXZGVzY3JpcHRpb25Eb2N1bWVudFR5cGUBAgRib2R5AAAAAAEHAgUBBAABBQEEAQEJYm9keUJ5dGVzAAEAAAEHAgUBBAABBQEEAQEBAQIABGJvZHkACWJvZHlCeXRlcwEHAgQCAg9kZWxldGVEb2N1bWVudHMGAgsABwIKAQsCAAAAAAAAABVkZXNjcmlwdGlvbkNvbnRyYWN0SWQTAQEAAAAAAAABAAAAAAAAAAAXZGVzY3JpcHRpb25Eb2N1bWVudFR5cGULAQEBQAAAAAAAAAAAA3VybAsBAQH7AgAB+wIAAAAAAAAAAARvcGVuDgEAAAAAAAACC2J5Q3JlYXRlZEF0C2J5Q3JlYXRlZEF0AQokY3JlYXRlZEF0AQABAAAAAAAAAAAAAAAAAAAAAAAAAAAHYnlPd25lcgdieU93bmVyAggkb3duZXJJZAEKJGNyZWF0ZWRBdAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAIVZGVzY3JpcHRpb25Db250cmFjdElkDWRlc2NyaXB0aW9uSWQABAokY3JlYXRlZEF0CiR1cGRhdGVkQXQEb3BlbgV0aXRsZQABBG9wZW4FFWRlc2NyaXB0aW9uQ29udHJhY3RJZAAECAUAAQAFAAAAAPwA27oAF2Rlc2NyaXB0aW9uRG9jdW1lbnRUeXBlAAQIBQABAAUAAAAA/ADbugANZGVzY3JpcHRpb25JZAAECAUAAQAFAAAAAPwA27oABXRpdGxlAAQIBQABAAUAAAAA/ADbugADdXJsAAQIBQABAAUAAAAA/ADbugAAAAEAAAABAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAACGmRlc2NyaWJlZEJ5QURvY3VtZW50T3JBVXJsDQILDWRlc2NyaXB0aW9uSWQLA3VybB1kZXNjcmlwdGlvbkRvY3VtZW50TmFtZWRXaG9sZQEDAw1kZXNjcmlwdGlvbklkFWRlc2NyaXB0aW9uQ29udHJhY3RJZBdkZXNjcmlwdGlvbkRvY3VtZW50VHlwZQIABgAAAAIA2wABAAIAAAEBBgV0aXRsZQABAAUAAAAAAQEBAYAB+wIAAAAADWRlc2NyaXB0aW9uSWQAAQADAAAAAQAAASABIAABAAAAFWRlc2NyaXB0aW9uQ29udHJhY3RJZAABAAMAAAABAAABIAEgAAEAAAAXZGVzY3JpcHRpb25Eb2N1bWVudFR5cGUAAQAFAAAAAAEBAQFAAAAAAAN1cmwAAQAFAAAAAAEBAQH7AgAB+wIAAAABAQkABG9wZW4AAQABAAAAAAAAAAEAAQIFdGl0bGUEb3BlbgAAAAAAAAAAAAhwcm9wb3NhbAAGBXRpdGxlCwEBAYAB+wIAAQAAAAAAAAtkZXNjcmlwdGlvbgsBAQH7EAAB+xAAAQAAAAAAAAN1cmwLAQEB+wIAAfsCAAAAAAAAAAALcGFzc1BlcmNlbnQIAQAAAAAAABVtaW5pbXVtVHVybm91dFBlcmNlbnQIAQAAAAAAAAdlbmREYXRlAgEAAAAAAAAGBXRpdGxlCwEBAYAB+wIAAQAAAAAAAAtkZXNjcmlwdGlvbgsBAQH7EAAB+xAAAQAAAAAAAAN1cmwLAQEB+wIAAfsCAAAAAAAAAAALcGFzc1BlcmNlbnQIAQAAAAAAABVtaW5pbXVtVHVybm91dFBlcmNlbnQIAQAAAAAAAAdlbmREYXRlAgEAAAAAAAADC2J5Q3JlYXRlZEF0C2J5Q3JlYXRlZEF0AQokY3JlYXRlZEF0AQABAAAAAAAAAAAAAAAAAAAAAAAAAAAJYnlFbmREYXRlCWJ5RW5kRGF0ZQIHZW5kRGF0ZQEKJGNyZWF0ZWRBdAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAB2J5T3duZXIHYnlPd25lcgIIJG93bmVySWQBCiRjcmVhdGVkQXQBAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcKJGNyZWF0ZWRBdAokdXBkYXRlZEF0C2Rlc2NyaXB0aW9uB2VuZERhdGUVbWluaW11bVR1cm5vdXRQZXJjZW50C3Bhc3NQZXJjZW50BXRpdGxlAAMHZW5kRGF0ZRVtaW5pbXVtVHVybm91dFBlcmNlbnQLcGFzc1BlcmNlbnQDC2Rlc2NyaXB0aW9uAAQIBQABAAUAAAAMAgD8Cky4AAkIAQdlbmREYXRlAAUAAAAACgV0aXRsZQAECAUAAQAFAAAADAIA/ApMuAAJCAEHZW5kRGF0ZQAFAAAAAAoDdXJsAAQIBQABAAUAAAAMAgD8Cky4AAkIAQdlbmREYXRlAAUAAAAACgAAAQAAAAEAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAPsBDwABAAIAAAEBBgV0aXRsZQABAAUAAAAAAQEBAYAB+wIAAAAAC2Rlc2NyaXB0aW9uAAEABQAAAAABAQEB+xAAAfsQAAAAAAN1cmwAAQAFAAAAAAEBAQH7AgAB+wIAAAABAQkAC3Bhc3NQZXJjZW50AAEABgAAAAAAAQECMgECUAAAAAAVbWluaW11bVR1cm5vdXRQZXJjZW50AAEABgAAAAAAAQECAAECMgAAAAAHZW5kRGF0ZQABAAYAAAAAAAEBAgAAAAAAAAEAAQUFdGl0bGULZGVzY3JpcHRpb24LcGFzc1BlcmNlbnQVbWluaW11bVR1cm5vdXRQZXJjZW50B2VuZERhdGUAAAAAAAAAAAA="} -{"contract":"system TokenMarket","sha256":"a76774b65159a4ff93874a556e72cd29a7d7d3aa35fcd972e76e3b2e85cf2d0e","indexStructures":"8ff1e8772d7b8e32e036dc6ef3324be80c0bd02177c35fac5f18419a6926d279","bytes":"AokUfSEJcaCMnscCt0vmRybVw0ENgSAKW+J05qRNZQCTAgAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgNhc2sWBxIEdHlwZRIGb2JqZWN0EgtkZXNjcmlwdGlvbhK5VG9rZW5zIGEgaG9sZGVyIG9mZmVycyBmb3Igc2FsZSBhdCBhIHByaWNlLiBXcml0dGVuIG9ubHkgYnkgdGhlIHRva2VuIG1hcmtldHBsYWNlIHRyYW5zaXRpb25zOiB0aGUgbGlzdGVkIHRva2VucyBhcmUgaGVsZCBpbiBlc2Nyb3cgdW5kZXIgdGhlIG9yZGVyJ3MgaWQgdW50aWwgaXQgaXMgZmlsbGVkIG9yIGNhbmNlbGxlZC4SF2NyZWF0aW9uUmVzdHJpY3Rpb25Nb2RlAgISB2luZGljZXMVAxYCEgRuYW1lEgRib29rEgpwcm9wZXJ0aWVzFQQWARIHdG9rZW5JZBIDYXNjFgESCGRlY2ltYWxzEgNhc2MWARIFcHJpY2USA2FzYxYBEgokY3JlYXRlZEF0EgNhc2MWBBIEbmFtZRIFZGVwdGgSCnByb3BlcnRpZXMVAxYBEgd0b2tlbklkEgNhc2MWARIIZGVjaW1hbHMSA2FzYxYBEgVwcmljZRIDYXNjEghzdW1tYWJsZRIJcmVtYWluaW5nEg1yYW5nZVN1bW1hYmxlEwEWAhIEbmFtZRIHYnlPd25lchIKcHJvcGVydGllcxUDFgESCCRvd25lcklkEgNhc2MWARIHdG9rZW5JZBIDYXNjFgESCiRjcmVhdGVkQXQSA2FzYxIKcHJvcGVydGllcxYFEgd0b2tlbklkFgcSBHR5cGUSBWFycmF5EglieXRlQXJyYXkTARIIbWluSXRlbXMCIBIIbWF4SXRlbXMCIBIQY29udGVudE1lZGlhVHlwZRIhYXBwbGljYXRpb24veC5kYXNoLmRwcC5pZGVudGlmaWVyEgtkZXNjcmlwdGlvbhIaVGhlIHRva2VuIHRoZSBvcmRlciBpcyBmb3ISCHBvc2l0aW9uAgASBXByaWNlFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CARILZGVzY3JpcHRpb24SYFRoZSBjcmVkaXRzIHRoZSBzZWxsZXIgYXNrcyBwZXIgd2hvbGUgdG9rZW4gKDEwIHRvIHRoZSBwb3dlciBvZiB0aGUgb3JkZXIncyBkZWNpbWFscyBiYXNlIHVuaXRzKRIIcG9zaXRpb24CARIGYW1vdW50FgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CARILZGVzY3JpcHRpb24SQVRoZSB0b2tlbiBhbW91bnQsIGluIGJhc2UgdW5pdHMsIGxpc3RlZCB3aGVuIHRoZSBvcmRlciB3YXMgcGxhY2VkEghwb3NpdGlvbgICEglyZW1haW5pbmcWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIBEgtkZXNjcmlwdGlvbhJcVGhlIHRva2VuIGFtb3VudCwgaW4gYmFzZSB1bml0cywgc3RpbGwgb3Blbi4gVGhlIG9yZGVyIGlzIGRlbGV0ZWQgd2hlbiBpdCBpcyBmaWxsZWQgZW50aXJlbHkSCHBvc2l0aW9uAgMSCGRlY2ltYWxzFgYSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQL7AP8SC2Rlc2NyaXB0aW9uEsVUaGUgdG9rZW4ncyBkZWNpbWFscyB3aGVuIHRoZSBvcmRlciB3YXMgcGxhY2VkLCBnZW5lcmF0ZWQgZnJvbSB0b2tlbklkOiB0aGUgcHJpY2UgaXMgcGVyIDEwIHRvIHRoZSBwb3dlciBvZiB0aGlzIG1hbnkgYmFzZSB1bml0cyBmb3IgdGhlIGxpZmUgb2YgdGhlIG9yZGVyLCBldmVuIGlmIHRoZSB0b2tlbidzIGRlY2ltYWxzIGNoYW5nZSBsYXRlchINZ2VuZXJhdGVkRnJvbRYCEghmdW5jdGlvbhITc3lzLnRva2Vucy5kZWNpbWFscxIGcGFyYW1zFQESB3Rva2VuSWQSCHBvc2l0aW9uAgQSCHJlcXVpcmVkFQcSB3Rva2VuSWQSBXByaWNlEgZhbW91bnQSCXJlbWFpbmluZxIIZGVjaW1hbHMSCiRjcmVhdGVkQXQSCiR1cGRhdGVkQXQSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwADYmlkFgcSBHR5cGUSBm9iamVjdBILZGVzY3JpcHRpb24Ss0FuIG9mZmVyIHRvIGJ1eSBhIHRva2VuIGF0IGEgcHJpY2UuIFdyaXR0ZW4gb25seSBieSB0aGUgdG9rZW4gbWFya2V0cGxhY2UgdHJhbnNpdGlvbnM6IHRoZSBvZmZlcmVkIGNyZWRpdHMgYXJlIGhlbGQgaW4gZXNjcm93IHVuZGVyIHRoZSBvcmRlcidzIGlkIHVudGlsIGl0IGlzIGZpbGxlZCBvciBjYW5jZWxsZWQuEhdjcmVhdGlvblJlc3RyaWN0aW9uTW9kZQICEgdpbmRpY2VzFQMWAhIEbmFtZRIEYm9vaxIKcHJvcGVydGllcxUEFgESB3Rva2VuSWQSA2FzYxYBEghkZWNpbWFscxIDYXNjFgESBXByaWNlEgNhc2MWARIKJGNyZWF0ZWRBdBIDYXNjFgQSBG5hbWUSBWRlcHRoEgpwcm9wZXJ0aWVzFQMWARIHdG9rZW5JZBIDYXNjFgESCGRlY2ltYWxzEgNhc2MWARIFcHJpY2USA2FzYxIIc3VtbWFibGUSBmVzY3JvdxINcmFuZ2VTdW1tYWJsZRMBFgISBG5hbWUSB2J5T3duZXISCnByb3BlcnRpZXMVAxYBEggkb3duZXJJZBIDYXNjFgESB3Rva2VuSWQSA2FzYxYBEgokY3JlYXRlZEF0EgNhc2MSCnByb3BlcnRpZXMWBhIHdG9rZW5JZBYHEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAiASEGNvbnRlbnRNZWRpYVR5cGUSIWFwcGxpY2F0aW9uL3guZGFzaC5kcHAuaWRlbnRpZmllchILZGVzY3JpcHRpb24SGlRoZSB0b2tlbiB0aGUgb3JkZXIgaXMgZm9yEghwb3NpdGlvbgIAEgVwcmljZRYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgESC2Rlc2NyaXB0aW9uEl9UaGUgY3JlZGl0cyB0aGUgYnV5ZXIgcGF5cyBwZXIgd2hvbGUgdG9rZW4gKDEwIHRvIHRoZSBwb3dlciBvZiB0aGUgb3JkZXIncyBkZWNpbWFscyBiYXNlIHVuaXRzKRIIcG9zaXRpb24CARIGYW1vdW50FgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CARILZGVzY3JpcHRpb24SQVRoZSB0b2tlbiBhbW91bnQsIGluIGJhc2UgdW5pdHMsIHdhbnRlZCB3aGVuIHRoZSBvcmRlciB3YXMgcGxhY2VkEghwb3NpdGlvbgICEglyZW1haW5pbmcWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIBEgtkZXNjcmlwdGlvbhJcVGhlIHRva2VuIGFtb3VudCwgaW4gYmFzZSB1bml0cywgc3RpbGwgb3Blbi4gVGhlIG9yZGVyIGlzIGRlbGV0ZWQgd2hlbiBpdCBpcyBmaWxsZWQgZW50aXJlbHkSCHBvc2l0aW9uAgMSBmVzY3JvdxYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASC2Rlc2NyaXB0aW9uEqFUaGUgY3JlZGl0cyBzdGlsbCBoZWxkIGluIGVzY3JvdyBmb3IgdGhlIG9yZGVyLiBUaGV5IGNvdmVyIHdoYXQgdGhlIG9wZW4gYW1vdW50IGNvc3RzIGF0IHRoZSBvcmRlcidzIHByaWNlOyB3aGF0IGlzIGxlZnQgb25jZSBpdCBpcyBmaWxsZWQgZ29lcyBiYWNrIHRvIHRoZSBidXllchIIcG9zaXRpb24CBBIIZGVjaW1hbHMWBhIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAvsA/xILZGVzY3JpcHRpb24SxVRoZSB0b2tlbidzIGRlY2ltYWxzIHdoZW4gdGhlIG9yZGVyIHdhcyBwbGFjZWQsIGdlbmVyYXRlZCBmcm9tIHRva2VuSWQ6IHRoZSBwcmljZSBpcyBwZXIgMTAgdG8gdGhlIHBvd2VyIG9mIHRoaXMgbWFueSBiYXNlIHVuaXRzIGZvciB0aGUgbGlmZSBvZiB0aGUgb3JkZXIsIGV2ZW4gaWYgdGhlIHRva2VuJ3MgZGVjaW1hbHMgY2hhbmdlIGxhdGVyEg1nZW5lcmF0ZWRGcm9tFgISCGZ1bmN0aW9uEhNzeXMudG9rZW5zLmRlY2ltYWxzEgZwYXJhbXMVARIHdG9rZW5JZBIIcG9zaXRpb24CBRIIcmVxdWlyZWQVCBIHdG9rZW5JZBIFcHJpY2USBmFtb3VudBIJcmVtYWluaW5nEghkZWNpbWFscxIGZXNjcm93EgokY3JlYXRlZEF0EgokdXBkYXRlZEF0EhRhZGRpdGlvbmFsUHJvcGVydGllcxMAAAAAAAAAAAAAAAIDYXNrAAUHdG9rZW5JZA0BAAAAAAAABXByaWNlAwEAAAAAAAAGYW1vdW50AwEAAAAAAAAJcmVtYWluaW5nAwEAAAAAAAAIZGVjaW1hbHMDAQAAAAABAgABB3Rva2VuSWQABQd0b2tlbklkDQEAAAAAAAAFcHJpY2UDAQAAAAAAAAZhbW91bnQDAQAAAAAAAAlyZW1haW5pbmcDAQAAAAAAAAhkZWNpbWFscwMBAAAAAAECAAEHdG9rZW5JZAADBGJvb2sEYm9vawQHdG9rZW5JZAEIZGVjaW1hbHMBBXByaWNlAQokY3JlYXRlZEF0AQABAAAAAAAAAAAAAAAAAAAAAAAAAAAHYnlPd25lcgdieU93bmVyAwgkb3duZXJJZAEHdG9rZW5JZAEKJGNyZWF0ZWRBdAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAABWRlcHRoBWRlcHRoAwd0b2tlbklkAQhkZWNpbWFscwEFcHJpY2UBAAEAAAABCXJlbWFpbmluZwEAAAAAAAAAAAAAAAAAAAAAAQd0b2tlbklkAAcKJGNyZWF0ZWRBdAokdXBkYXRlZEF0BmFtb3VudAhkZWNpbWFscwVwcmljZQlyZW1haW5pbmcHdG9rZW5JZAAAAAAAAAAAAAEBAAAAAgAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAMUAAQACAAABAQUHdG9rZW5JZAABAAMAAAABAAABIAEgAAEAAAAFcHJpY2UAAQAGAAAAAAABAQIBAAAAAAAGYW1vdW50AAEABgAAAAAAAQECAQAAAAAACXJlbWFpbmluZwABAAYAAAAAAAEBAgEAAAAAAAhkZWNpbWFscwABAAYAAAAAAAEBAgABAvsA/wAAAAABAAEFB3Rva2VuSWQFcHJpY2UGYW1vdW50CXJlbWFpbmluZwhkZWNpbWFscwAAAAAAAAAAAANiaWQABgd0b2tlbklkDQEAAAAAAAAFcHJpY2UDAQAAAAAAAAZhbW91bnQDAQAAAAAAAAlyZW1haW5pbmcDAQAAAAAAAAZlc2Nyb3cDAQAAAAAAAAhkZWNpbWFscwMBAAAAAAECAAEHdG9rZW5JZAAGB3Rva2VuSWQNAQAAAAAAAAVwcmljZQMBAAAAAAAABmFtb3VudAMBAAAAAAAACXJlbWFpbmluZwMBAAAAAAAABmVzY3JvdwMBAAAAAAAACGRlY2ltYWxzAwEAAAAAAQIAAQd0b2tlbklkAAMEYm9vawRib29rBAd0b2tlbklkAQhkZWNpbWFscwEFcHJpY2UBCiRjcmVhdGVkQXQBAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAdieU93bmVyB2J5T3duZXIDCCRvd25lcklkAQd0b2tlbklkAQokY3JlYXRlZEF0AQABAAAAAAAAAAAAAAAAAAAAAAAAAAAFZGVwdGgFZGVwdGgDB3Rva2VuSWQBCGRlY2ltYWxzAQVwcmljZQEAAQAAAAEGZXNjcm93AQAAAAAAAAAAAAAAAAAAAAABB3Rva2VuSWQACAokY3JlYXRlZEF0CiR1cGRhdGVkQXQGYW1vdW50CGRlY2ltYWxzBmVzY3JvdwVwcmljZQlyZW1haW5pbmcHdG9rZW5JZAAAAAAAAAAAAAEBAAAAAgAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAOUAAQACAAABAQYHdG9rZW5JZAABAAMAAAABAAABIAEgAAEAAAAFcHJpY2UAAQAGAAAAAAABAQIBAAAAAAAGYW1vdW50AAEABgAAAAAAAQECAQAAAAAACXJlbWFpbmluZwABAAYAAAAAAAEBAgEAAAAAAAZlc2Nyb3cAAQAGAAAAAAABAQIAAAAAAAAIZGVjaW1hbHMAAQAGAAAAAAABAQIAAQL7AP8AAAAAAQABBgd0b2tlbklkBXByaWNlBmFtb3VudAlyZW1haW5pbmcIZGVjaW1hbHMGZXNjcm93AAAAAAAAAAAA"} {"contract":"mainnet 2NZwXdb3wGQzbWQeQZHFAaL4GuQzuzF2v8iQfcKuUC5q","sha256":"f88948650030b46642a88f5bbe753b611fea8bc426736536ed92fcc34f046775","indexStructures":"4fe79ced8e35b61d7ebb7b90bd5e022c8ce761fd5f1ad500616b65d7ead95eb0","bytes":"AhRiISPCxl4HHAwk/78Fz+U539mkTynR9H2sHE/5Ej8cAAAAAAABAQAAAThF4gNxUKAYvnAU+jjyexfXrK+scXqTTb3Iz5asr4nFAAEFb2ZmZXIWBRIEdHlwZRIGb2JqZWN0EgdpbmRpY2VzFQUWAxIEbmFtZRIYdG9NZXRvTWVWaWF0b1V0b1VWaWFVUEF0Egpwcm9wZXJ0aWVzFQUWARIEdG9NZRIDYXNjFgESB3RvTWVWaWESA2FzYxYBEgN0b1USA2FzYxYBEgZ0b1VWaWESA2FzYxYBEgokdXBkYXRlZEF0EgNhc2MSBnVuaXF1ZRMAFgMSBG5hbWUSEXRvTWV0b1V0b1VWaWFVUEFUEgpwcm9wZXJ0aWVzFQQWARIEdG9NZRIDYXNjFgESA3RvVRIDYXNjFgESBnRvVVZpYRIDYXNjFgESCiR1cGRhdGVkQXQSA2FzYxIGdW5pcXVlEwAWAxIEbmFtZRISdG9NZXRvTWVWaWF0b1VVUEFUEgpwcm9wZXJ0aWVzFQQWARIEdG9NZRIDYXNjFgESB3RvTWVWaWESA2FzYxYBEgN0b1USA2FzYxYBEgokdXBkYXRlZEF0EgNhc2MSBnVuaXF1ZRMAFgMSBG5hbWUSC3RvTWV0b1VVUEFUEgpwcm9wZXJ0aWVzFQMWARIEdG9NZRIDYXNjFgESA3RvVRIDYXNjFgESCiR1cGRhdGVkQXQSA2FzYxIGdW5pcXVlEwAWAxIEbmFtZRITb3duZXJJZEFuZGNyZWF0ZWRBdBIKcHJvcGVydGllcxUCFgESCCRvd25lcklkEgNhc2MWARIKJGNyZWF0ZWRBdBIDYXNjEgZ1bmlxdWUTABIKcHJvcGVydGllcxYLEgR0b01lFgQSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAwASCW1heExlbmd0aANEEghwb3NpdGlvbgMAEgd0b01lVmlhFgQSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAwASCW1heExlbmd0aANEEghwb3NpdGlvbgMCEgp0b01lSGFuZGxlFgQSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAwASCW1heExlbmd0aANEEghwb3NpdGlvbgMEEgN0b1UWBBIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgDABIJbWF4TGVuZ3RoA0QSCHBvc2l0aW9uAwYSBnRvVVZpYRYEEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAMAEgltYXhMZW5ndGgDRBIIcG9zaXRpb24DCBIGZXhSYXRlFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0DABIHbWF4aW11bQP9AAASMJzlQAASCHBvc2l0aW9uAwoSC2luc3RydWN0aW9uFgQSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAwASCW1heExlbmd0aAP7BLASCHBvc2l0aW9uAwwSBm1pbkFtdBYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAwASB21heGltdW0D/QAAAdGpSiAAEghwb3NpdGlvbgMOEgZtYXhBbXQWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQMAEgdtYXhpbXVtA/0AAAHRqUogABIIcG9zaXRpb24DEBIGYWN0aXZlFgISBHR5cGUSB2Jvb2xlYW4SCHBvc2l0aW9uAxISB215U3RvcmUWAhIEdHlwZRIHYm9vbGVhbhIIcG9zaXRpb24DFBIIcmVxdWlyZWQVDRIEdG9NZRIHdG9NZVZpYRIKdG9NZUhhbmRsZRIDdG9VEgZ0b1VWaWESBmV4UmF0ZRILaW5zdHJ1Y3Rpb24SBm1pbkFtdBIGbWF4QW10EgZhY3RpdmUSB215U3RvcmUSCiRjcmVhdGVkQXQSCiR1cGRhdGVkQXQSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwAAAAAAAAAAAAAAAQVvZmZlcgALBHRvTWULAQABIgABAAAAAAAAB3RvTWVWaWELAQABIgABAAAAAAAACnRvTWVIYW5kbGULAQABIgABAAAAAAAAA3RvVQsBAAEiAAEAAAAAAAAGdG9VVmlhCwEAASIAAQAAAAAAAAZleFJhdGUDAQAAAAAAAAtpbnN0cnVjdGlvbgsBAAH7AlgAAQAAAAAAAAZtaW5BbXQDAQAAAAAAAAZtYXhBbXQDAQAAAAAAAAZhY3RpdmUOAQAAAAAAAAdteVN0b3JlDgEAAAAAAAALBHRvTWULAQABIgABAAAAAAAAB3RvTWVWaWELAQABIgABAAAAAAAACnRvTWVIYW5kbGULAQABIgABAAAAAAAAA3RvVQsBAAEiAAEAAAAAAAAGdG9VVmlhCwEAASIAAQAAAAAAAAZleFJhdGUDAQAAAAAAAAtpbnN0cnVjdGlvbgsBAAH7AlgAAQAAAAAAAAZtaW5BbXQDAQAAAAAAAAZtYXhBbXQDAQAAAAAAAAZhY3RpdmUOAQAAAAAAAAdteVN0b3JlDgEAAAAAAAAFE293bmVySWRBbmRjcmVhdGVkQXQTb3duZXJJZEFuZGNyZWF0ZWRBdAIIJG93bmVySWQBCiRjcmVhdGVkQXQBAAEAAAAAAAAAAAAAAAAAAAAAAAAAABJ0b01ldG9NZVZpYXRvVVVQQVQSdG9NZXRvTWVWaWF0b1VVUEFUBAR0b01lAQd0b01lVmlhAQN0b1UBCiR1cGRhdGVkQXQBAAEAAAAAAAAAAAAAAAAAAAAAAAAAABh0b01ldG9NZVZpYXRvVXRvVVZpYVVQQXQYdG9NZXRvTWVWaWF0b1V0b1VWaWFVUEF0BQR0b01lAQd0b01lVmlhAQN0b1UBBnRvVVZpYQEKJHVwZGF0ZWRBdAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAC3RvTWV0b1VVUEFUC3RvTWV0b1VVUEFUAwR0b01lAQN0b1UBCiR1cGRhdGVkQXQBAAEAAAAAAAAAAAAAAAAAAAAAAAAAABF0b01ldG9VdG9VVmlhVVBBVBF0b01ldG9VdG9VVmlhVVBBVAQEdG9NZQEDdG9VAQZ0b1VWaWEBCiR1cGRhdGVkQXQBAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0KJGNyZWF0ZWRBdAokdXBkYXRlZEF0BmFjdGl2ZQZleFJhdGULaW5zdHJ1Y3Rpb24GbWF4QW10Bm1pbkFtdAdteVN0b3JlBHRvTWUKdG9NZUhhbmRsZQd0b01lVmlhA3RvVQZ0b1VWaWEAAAAAAAAAAAABAQAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgD7AY4AAQACAAABAQsEdG9NZQABAAUAAAAAAQEAASIAAAAAB3RvTWVWaWEAAQAFAAAAAAEBAAEiAAAAAAp0b01lSGFuZGxlAAEABQAAAAABAQABIgAAAAADdG9VAAEABQAAAAABAQABIgAAAAAGdG9VVmlhAAEABQAAAAABAQABIgAAAAAGZXhSYXRlAAEABgAAAAAAAQECAAEC/QAACRhOcqAAAAAAAAtpbnN0cnVjdGlvbgABAAUAAAAAAQEAAfsCWAAAAAAGbWluQW10AAEABgAAAAAAAQECAAEC/QAAAOjUpRAAAAAAAAZtYXhBbXQAAQAGAAAAAAABAQIAAQL9AAAA6NSlEAAAAAAABmFjdGl2ZQABAAEAAAAAAAAAB215U3RvcmUAAQABAAAAAAAAAAEAAQsEdG9NZQd0b01lVmlhCnRvTWVIYW5kbGUDdG9VBnRvVVZpYQZleFJhdGULaW5zdHJ1Y3Rpb24GbWluQW10Bm1heEFtdAZhY3RpdmUHbXlTdG9yZQAAAAAAAAAAAA=="} {"contract":"mainnet 2UDyunHraJLbg1TqjYBHhVoaCetPKcy5aAVdGYxmWZga","sha256":"a3353b8902cb43493e3f2748ee49e9d30b41039ca87e7ef65c82b5b9cf7bcada","indexStructures":"74eaa293ce4381e8af811c0b929a7993cbe2ef218f2f7f9452e0f3dbf0d4ed03","bytes":"AhXVC/KBoXOMVjfhmUg5RJO8HV2kSxbGS8a+p1IpXs9fAAAAAAABAQAAASj+fLksRsQidDbOM1gGlYam9hkWlYmgY835HLI6FUqTAAEEbm90ZRYEEgR0eXBlEgZvYmplY3QSCnByb3BlcnRpZXMWARIHbWVzc2FnZRYDEgR0eXBlEgZzdHJpbmcSCW1heExlbmd0aAN+Eghwb3NpdGlvbgMAEgdpbmRpY2VzFQEWAxIEbmFtZRIHbWVzc2FnZRIKcHJvcGVydGllcxUBFgESB21lc3NhZ2USA2FzYxIGdW5pcXVlEwASFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwAAAAAAAAAAAAAAAQRub3RlAAEHbWVzc2FnZQsAAT8AAAAAAAAAAAEHbWVzc2FnZQsAAT8AAAAAAAAAAAEHbWVzc2FnZQdtZXNzYWdlAQdtZXNzYWdlAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIALQABAAIAAAEBAQdtZXNzYWdlAAEABQAAAAABAAE/AAAAAAEAAAAAAAAAAAAAAA=="} {"contract":"mainnet 2hdxAYHjecJyd5o1nDYqZnabN3f9ZqywKit2KUsEEo83","sha256":"06f6c76a08b9cec87a5ff9332db453a01d71f2590b2ee97f6ee781dc81ed22c1","indexStructures":"84a3291cdd8603ad82c4a90605f117775acfe5c1f4b078bde3ba9e9d0ed5e67a","bytes":"AhlEszYc95lpJlqvyxkehqFoYLXdlambfi9rduesib3oAAAAAAABAQAAAjUKspTG4VmUvLItWG9X30oWgDAlKQcBO3o6bkg/hpLtAAQFb2ZmZXIWBxIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwESDGNhbkJlRGVsZXRlZBMBEgpwcm9wZXJ0aWVzFgoSBHBhaXIWBBIEdHlwZRIGc3RyaW5nEgltYXhMZW5ndGgCIBILZGVzY3JpcHRpb24SNVRyYWRpbmcgcGFpciBsYWJlbCwgZS5nLiBERVhZL0RBU0ggb3IgREVYWS9PVEhFUlRPS0VOEghwb3NpdGlvbgIAEgRzaWRlFgUSBHR5cGUSBnN0cmluZxIJbWF4TGVuZ3RoAggSBGVudW0VAhIDYnV5EgRzZWxsEgtkZXNjcmlwdGlvbhJHTWFrZXIncyBzaWRlIGZyb20gdGhlIHBlcnNwZWN0aXZlIG9mIHRoZSBiYXNlIChmaXJzdCkgYXNzZXQgaW4gdGhlIHBhaXISCHBvc2l0aW9uAgESDmdpdmVDb250cmFjdElkFgUSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAioSCW1heExlbmd0aAIsEgtkZXNjcmlwdGlvbhI7RGF0YSBjb250cmFjdCBpZCBvZiB0aGUgdG9rZW4gdGhlIG1ha2VyIGlzIG9mZmVyaW5nIHRvIGdpdmUSCHBvc2l0aW9uAgISEWdpdmVUb2tlblBvc2l0aW9uFgUSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQL7//8SC2Rlc2NyaXB0aW9uEiRUb2tlbiBwb3NpdGlvbiB3aXRoaW4gZ2l2ZUNvbnRyYWN0SWQSCHBvc2l0aW9uAgMSCmdpdmVBbW91bnQWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIBEgtkZXNjcmlwdGlvbhIvQW1vdW50IChpbiBiYXNlIHVuaXRzKSB0aGUgbWFrZXIgb2ZmZXJzIHRvIGdpdmUSCHBvc2l0aW9uAgQSDndhbnRDb250cmFjdElkFgUSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAioSCW1heExlbmd0aAIsEgtkZXNjcmlwdGlvbhI3RGF0YSBjb250cmFjdCBpZCBvZiB0aGUgdG9rZW4gdGhlIG1ha2VyIHdhbnRzIGluIHJldHVybhIIcG9zaXRpb24CBRIRd2FudFRva2VuUG9zaXRpb24WBRIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAvv//xILZGVzY3JpcHRpb24SJFRva2VuIHBvc2l0aW9uIHdpdGhpbiB3YW50Q29udHJhY3RJZBIIcG9zaXRpb24CBhIKd2FudEFtb3VudBYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgESC2Rlc2NyaXB0aW9uEjBBbW91bnQgKGluIGJhc2UgdW5pdHMpIHRoZSBtYWtlciB3YW50cyBpbiByZXR1cm4SCHBvc2l0aW9uAgcSBnN0YXR1cxYFEgR0eXBlEgZzdHJpbmcSCW1heExlbmd0aAIQEgRlbnVtFQMSBG9wZW4SBmZpbGxlZBIJY2FuY2VsbGVkEgtkZXNjcmlwdGlvbhJYTGlmZWN5Y2xlIG9mIHRoZSBvZmZlci4gTk9URTogc2V0dGxlbWVudCBpcyBOT1QgcHJvdG9jb2wtYXRvbWljIChzZWUgUkVBRE1FIHRydXN0IG1vZGVsKRIIcG9zaXRpb24CCBIJY3JlYXRlZEF0FgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABILZGVzY3JpcHRpb24SOFVuaXggc2Vjb25kcywgZm9yIG5ld2VzdC1maXJzdCBicm93c2luZyBhY3Jvc3MgYWxsIHBhaXJzEghwb3NpdGlvbgIJEgdpbmRpY2VzFQMWAhIEbmFtZRIPYnlTdGF0dXNDcmVhdGVkEgpwcm9wZXJ0aWVzFQIWARIGc3RhdHVzEgNhc2MWARIJY3JlYXRlZEF0EgNhc2MWAhIEbmFtZRIMYnlQYWlyU3RhdHVzEgpwcm9wZXJ0aWVzFQIWARIEcGFpchIDYXNjFgESBnN0YXR1cxIDYXNjFgISBG5hbWUSCmJ5UGFpclNpZGUSCnByb3BlcnRpZXMVAhYBEgRwYWlyEgNhc2MWARIEc2lkZRIDYXNjEghyZXF1aXJlZBUKEgRwYWlyEgRzaWRlEg5naXZlQ29udHJhY3RJZBIRZ2l2ZVRva2VuUG9zaXRpb24SCmdpdmVBbW91bnQSDndhbnRDb250cmFjdElkEhF3YW50VG9rZW5Qb3NpdGlvbhIKd2FudEFtb3VudBIGc3RhdHVzEgljcmVhdGVkQXQSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwAJcHJpY2VUaWNrFgcSBHR5cGUSBm9iamVjdBIQZG9jdW1lbnRzTXV0YWJsZRMAEgxjYW5CZURlbGV0ZWQTABIKcHJvcGVydGllcxYGEg90b2tlbkNvbnRyYWN0SWQWBBIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCKhIJbWF4TGVuZ3RoAiwSCHBvc2l0aW9uAgASDXRva2VuUG9zaXRpb24WBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAvv//xIIcG9zaXRpb24CARIEcGFpchYDEgR0eXBlEgZzdHJpbmcSCW1heExlbmd0aAIgEghwb3NpdGlvbgICEgVwcmljZRYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASC2Rlc2NyaXB0aW9uEhFjcmVkaXRzIHBlciB0b2tlbhIIcG9zaXRpb24CAxIGdm9sdW1lFgMSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIIcG9zaXRpb24CBBICYXQWAxIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEghwb3NpdGlvbgIFEgdpbmRpY2VzFQEWAhIEbmFtZRILYnlUb2tlblRpbWUSCnByb3BlcnRpZXMVAhYBEg90b2tlbkNvbnRyYWN0SWQSA2FzYxYBEgJhdBIDYXNjEghyZXF1aXJlZBUEEg90b2tlbkNvbnRyYWN0SWQSDXRva2VuUG9zaXRpb24SBXByaWNlEgJhdBIUYWRkaXRpb25hbFByb3BlcnRpZXMTAAl0b2tlbkluZm8WBxIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwESDGNhbkJlRGVsZXRlZBMBEgpwcm9wZXJ0aWVzFgkSD3Rva2VuQ29udHJhY3RJZBYEEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIqEgltYXhMZW5ndGgCLBIIcG9zaXRpb24CABINdG9rZW5Qb3NpdGlvbhYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASB21heGltdW0C+///Eghwb3NpdGlvbgIBEgZzeW1ib2wWAxIEdHlwZRIGc3RyaW5nEgltYXhMZW5ndGgCEBIIcG9zaXRpb24CAhIEbmFtZRYDEgR0eXBlEgZzdHJpbmcSCW1heExlbmd0aAJAEghwb3NpdGlvbgIDEgtkZXNjcmlwdGlvbhYDEgR0eXBlEgZzdHJpbmcSCW1heExlbmd0aAL7AfQSCHBvc2l0aW9uAgQSCndlYnNpdGVVcmwWAxIEdHlwZRIGc3RyaW5nEgltYXhMZW5ndGgC+wEAEghwb3NpdGlvbgIFEgdpY29uVXJsFgMSBHR5cGUSBnN0cmluZxIJbWF4TGVuZ3RoAvsBABIIcG9zaXRpb24CBhIIdmVyaWZpZWQWAxIEdHlwZRIHYm9vbGVhbhILZGVzY3JpcHRpb24SHHZldHRlZCBieSB0aGUgY29udHJhY3Qgb3duZXISCHBvc2l0aW9uAgcSAmF0FgMSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIIcG9zaXRpb24CCBIHaW5kaWNlcxUBFgMSBG5hbWUSB2J5VG9rZW4SCnByb3BlcnRpZXMVAhYBEg90b2tlbkNvbnRyYWN0SWQSA2FzYxYBEg10b2tlblBvc2l0aW9uEgNhc2MSBnVuaXF1ZRMBEghyZXF1aXJlZBUEEg90b2tlbkNvbnRyYWN0SWQSDXRva2VuUG9zaXRpb24SBnN5bWJvbBICYXQSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwANdG9rZW5SZWdpc3RyeRYHEgR0eXBlEgZvYmplY3QSEGRvY3VtZW50c011dGFibGUTARIMY2FuQmVEZWxldGVkEwESCnByb3BlcnRpZXMWBRIPdG9rZW5Db250cmFjdElkFgUSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAioSCW1heExlbmd0aAIsEgtkZXNjcmlwdGlvbhI8RGF0YSBjb250cmFjdCBpZCBvZiB0aGUgdG9rZW4gYmVpbmcgcmVnaXN0ZXJlZCBmb3IgZGlzY292ZXJ5Eghwb3NpdGlvbgIAEg10b2tlblBvc2l0aW9uFgUSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQL7//8SC2Rlc2NyaXB0aW9uEiNUb2tlbiBwb3NpdGlvbiB3aXRoaW4gdGhhdCBjb250cmFjdBIIcG9zaXRpb24CARIGc3ltYm9sFgQSBHR5cGUSBnN0cmluZxIJbWF4TGVuZ3RoAhASC2Rlc2NyaXB0aW9uEhZTaG9ydCB0aWNrZXIgZS5nLiBERVhZEghwb3NpdGlvbgICEgRuYW1lFgMSBHR5cGUSBnN0cmluZxIJbWF4TGVuZ3RoAkASCHBvc2l0aW9uAgMSAmF0FgMSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIIcG9zaXRpb24CBBIHaW5kaWNlcxUCFgMSBG5hbWUSB2J5VG9rZW4SCnByb3BlcnRpZXMVAhYBEg90b2tlbkNvbnRyYWN0SWQSA2FzYxYBEg10b2tlblBvc2l0aW9uEgNhc2MSBnVuaXF1ZRMBFgISBG5hbWUSCGJ5U3ltYm9sEgpwcm9wZXJ0aWVzFQEWARIGc3ltYm9sEgNhc2MSCHJlcXVpcmVkFQUSD3Rva2VuQ29udHJhY3RJZBINdG9rZW5Qb3NpdGlvbhIGc3ltYm9sEgRuYW1lEgJhdBIUYWRkaXRpb25hbFByb3BlcnRpZXMTAAH9AAABnwMEJYYB/QAAAZ8DJtErAfwABfF2AfwABfGHAUkBSQAAAAAEBW9mZmVyAAoEcGFpcgsAASAAAQAAAAAAAARzaWRlCwABCAABAAAAAAAADmdpdmVDb250cmFjdElkCwEqASwAAQAAAAAAABFnaXZlVG9rZW5Qb3NpdGlvbgMBAAAAAAAACmdpdmVBbW91bnQDAQAAAAAAAA53YW50Q29udHJhY3RJZAsBKgEsAAEAAAAAAAARd2FudFRva2VuUG9zaXRpb24DAQAAAAAAAAp3YW50QW1vdW50AwEAAAAAAAAGc3RhdHVzCwABEAABAAAAAAAACWNyZWF0ZWRBdAMBAAAAAAAACgRwYWlyCwABIAABAAAAAAAABHNpZGULAAEIAAEAAAAAAAAOZ2l2ZUNvbnRyYWN0SWQLASoBLAABAAAAAAAAEWdpdmVUb2tlblBvc2l0aW9uAwEAAAAAAAAKZ2l2ZUFtb3VudAMBAAAAAAAADndhbnRDb250cmFjdElkCwEqASwAAQAAAAAAABF3YW50VG9rZW5Qb3NpdGlvbgMBAAAAAAAACndhbnRBbW91bnQDAQAAAAAAAAZzdGF0dXMLAAEQAAEAAAAAAAAJY3JlYXRlZEF0AwEAAAAAAAADCmJ5UGFpclNpZGUKYnlQYWlyU2lkZQIEcGFpcgEEc2lkZQEAAQAAAAAAAAAAAAAAAAAAAAAAAAAADGJ5UGFpclN0YXR1cwxieVBhaXJTdGF0dXMCBHBhaXIBBnN0YXR1cwEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAD2J5U3RhdHVzQ3JlYXRlZA9ieVN0YXR1c0NyZWF0ZWQCBnN0YXR1cwEJY3JlYXRlZEF0AQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKCWNyZWF0ZWRBdApnaXZlQW1vdW50DmdpdmVDb250cmFjdElkEWdpdmVUb2tlblBvc2l0aW9uBHBhaXIEc2lkZQZzdGF0dXMKd2FudEFtb3VudA53YW50Q29udHJhY3RJZBF3YW50VG9rZW5Qb3NpdGlvbgAAAAAAAAAAAAEBAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAPsB1gABAAIAAAEBCgRwYWlyAAEABQAAAAABAAEgAAAAAARzaWRlAAEABQECEgNidXkSBHNlbGwAAAABAAEIAAAAAA5naXZlQ29udHJhY3RJZAABAAUAAAAAAQEqASwAAAAAEWdpdmVUb2tlblBvc2l0aW9uAAEABgAAAAAAAQECAAEC+///AAAAAApnaXZlQW1vdW50AAEABgAAAAAAAQECAQAAAAAADndhbnRDb250cmFjdElkAAEABQAAAAABASoBLAAAAAARd2FudFRva2VuUG9zaXRpb24AAQAGAAAAAAABAQIAAQL7//8AAAAACndhbnRBbW91bnQAAQAGAAAAAAABAQIBAAAAAAAGc3RhdHVzAAEABQEDEgRvcGVuEgZmaWxsZWQSCWNhbmNlbGxlZAAAAAEAARAAAAAACWNyZWF0ZWRBdAABAAYAAAAAAAEBAgAAAAAAAAEAAQoEcGFpcgRzaWRlDmdpdmVDb250cmFjdElkEWdpdmVUb2tlblBvc2l0aW9uCmdpdmVBbW91bnQOd2FudENvbnRyYWN0SWQRd2FudFRva2VuUG9zaXRpb24Kd2FudEFtb3VudAZzdGF0dXMJY3JlYXRlZEF0AAAAAAAAAAAACXByaWNlVGljawAGD3Rva2VuQ29udHJhY3RJZAsBKgEsAAEAAAAAAAANdG9rZW5Qb3NpdGlvbgMBAAAAAAAABHBhaXILAAEgAAAAAAAAAAAFcHJpY2UDAQAAAAAAAAZ2b2x1bWUDAAAAAAAAAAJhdAMBAAAAAAAABg90b2tlbkNvbnRyYWN0SWQLASoBLAABAAAAAAAADXRva2VuUG9zaXRpb24DAQAAAAAAAARwYWlyCwABIAAAAAAAAAAABXByaWNlAwEAAAAAAAAGdm9sdW1lAwAAAAAAAAACYXQDAQAAAAAAAAELYnlUb2tlblRpbWULYnlUb2tlblRpbWUCD3Rva2VuQ29udHJhY3RJZAECYXQBAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQCYXQFcHJpY2UPdG9rZW5Db250cmFjdElkDXRva2VuUG9zaXRpb24AAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgDdAAEAAgAAAQEGD3Rva2VuQ29udHJhY3RJZAABAAUAAAAAAQEqASwAAAAADXRva2VuUG9zaXRpb24AAQAGAAAAAAABAQIAAQL7//8AAAAABHBhaXIAAQAFAAAAAAEAASAAAAAABXByaWNlAAEABgAAAAAAAQECAAAAAAAABnZvbHVtZQABAAYAAAAAAAEBAgAAAAAAAAJhdAABAAYAAAAAAAEBAgAAAAAAAAEAAQQPdG9rZW5Db250cmFjdElkDXRva2VuUG9zaXRpb24FcHJpY2UCYXQAAAAAAAAAAAAJdG9rZW5JbmZvAAkPdG9rZW5Db250cmFjdElkCwEqASwAAQAAAAAAAA10b2tlblBvc2l0aW9uAwEAAAAAAAAGc3ltYm9sCwABEAABAAAAAAAABG5hbWULAAFAAAAAAAAAAAALZGVzY3JpcHRpb24LAAH7AfQAAAAAAAAAAAp3ZWJzaXRlVXJsCwAB+wEAAAAAAAAAAAAHaWNvblVybAsAAfsBAAAAAAAAAAAACHZlcmlmaWVkDgAAAAAAAAACYXQDAQAAAAAAAAkPdG9rZW5Db250cmFjdElkCwEqASwAAQAAAAAAAA10b2tlblBvc2l0aW9uAwEAAAAAAAAGc3ltYm9sCwABEAABAAAAAAAABG5hbWULAAFAAAAAAAAAAAALZGVzY3JpcHRpb24LAAH7AfQAAAAAAAAAAAp3ZWJzaXRlVXJsCwAB+wEAAAAAAAAAAAAHaWNvblVybAsAAfsBAAAAAAAAAAAACHZlcmlmaWVkDgAAAAAAAAACYXQDAQAAAAAAAAEHYnlUb2tlbgdieVRva2VuAg90b2tlbkNvbnRyYWN0SWQBDXRva2VuUG9zaXRpb24BAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQCYXQGc3ltYm9sD3Rva2VuQ29udHJhY3RJZA10b2tlblBvc2l0aW9uAAAAAAAAAAAAAQEAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIA+wEtAAEAAgAAAQEJD3Rva2VuQ29udHJhY3RJZAABAAUAAAAAAQEqASwAAAAADXRva2VuUG9zaXRpb24AAQAGAAAAAAABAQIAAQL7//8AAAAABnN5bWJvbAABAAUAAAAAAQABEAAAAAAEbmFtZQABAAUAAAAAAQABQAAAAAALZGVzY3JpcHRpb24AAQAFAAAAAAEAAfsB9AAAAAAKd2Vic2l0ZVVybAABAAUAAAAAAQAB+wEAAAAAAAdpY29uVXJsAAEABQAAAAABAAH7AQAAAAAACHZlcmlmaWVkAAEAAQAAAAAAAAACYXQAAQAGAAAAAAABAQIAAAAAAAABAAEED3Rva2VuQ29udHJhY3RJZA10b2tlblBvc2l0aW9uBnN5bWJvbAJhdAAAAAAAAAAAAA10b2tlblJlZ2lzdHJ5AAUPdG9rZW5Db250cmFjdElkCwEqASwAAQAAAAAAAA10b2tlblBvc2l0aW9uAwEAAAAAAAAGc3ltYm9sCwABEAABAAAAAAAABG5hbWULAAFAAAEAAAAAAAACYXQDAQAAAAAAAAUPdG9rZW5Db250cmFjdElkCwEqASwAAQAAAAAAAA10b2tlblBvc2l0aW9uAwEAAAAAAAAGc3ltYm9sCwABEAABAAAAAAAABG5hbWULAAFAAAEAAAAAAAACYXQDAQAAAAAAAAIIYnlTeW1ib2wIYnlTeW1ib2wBBnN5bWJvbAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAB2J5VG9rZW4HYnlUb2tlbgIPdG9rZW5Db250cmFjdElkAQ10b2tlblBvc2l0aW9uAQEBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAmF0BG5hbWUGc3ltYm9sD3Rva2VuQ29udHJhY3RJZA10b2tlblBvc2l0aW9uAAAAAAAAAAAAAQEAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAyQABAAIAAAEBBQ90b2tlbkNvbnRyYWN0SWQAAQAFAAAAAAEBKgEsAAAAAA10b2tlblBvc2l0aW9uAAEABgAAAAAAAQECAAEC+///AAAAAAZzeW1ib2wAAQAFAAAAAAEAARAAAAAABG5hbWUAAQAFAAAAAAEAAUAAAAAAAmF0AAEABgAAAAAAAQECAAAAAAAAAQABBQ90b2tlbkNvbnRyYWN0SWQNdG9rZW5Qb3NpdGlvbgZzeW1ib2wEbmFtZQJhdAAAAAAAAAAAAA=="} diff --git a/packages/rs-dpp/tests/stored_contract_compatibility.rs b/packages/rs-dpp/tests/stored_contract_compatibility.rs index 8af237ff9b4..48f63e21971 100644 --- a/packages/rs-dpp/tests/stored_contract_compatibility.rs +++ b/packages/rs-dpp/tests/stored_contract_compatibility.rs @@ -44,8 +44,9 @@ const UPDATE: &str = "UPDATE_STORED_CONTRACT_FIXTURE"; const FIXTURE: &str = "tests/fixtures/stored_contracts/stored.jsonl"; -/// The system contracts protocol version 15 has: every slot but the reserved feature flags. -const SYSTEM_CONTRACTS: [SystemDataContract; 12] = [ +/// The system contracts protocol version 15 has: every slot but the reserved feature flags and +/// the token market contract, which arrives with the token marketplace in protocol version 16. +const SYSTEM_CONTRACTS: [SystemDataContract; 11] = [ SystemDataContract::Withdrawals, SystemDataContract::MasternodeRewards, SystemDataContract::DPNS, @@ -57,7 +58,6 @@ const SYSTEM_CONTRACTS: [SystemDataContract; 12] = [ SystemDataContract::AppConnect, SystemDataContract::ModerationCharters, SystemDataContract::DecisionProposals, - SystemDataContract::TokenMarket, ]; /// Contracts written for the fixture, in JSON, for what neither the system contracts nor the diff --git a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v1/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v1/mod.rs index 00263e4e8f7..3cf8c6cae1d 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v1/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v1/mod.rs @@ -99,8 +99,9 @@ impl Platform { ); } - // The token market contract activates with protocol version 15: a chain born at 15 - // registers it at genesis, an older chain gets it from `transition_to_version_15`. + // The token market contract activates with the token marketplace, at protocol version + // 16: a chain born at that version or later registers it at genesis, an older chain + // gets it from the upgrade to it. if platform_version.protocol_version >= TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION { system_data_contract_types.insert( SystemDataContract::TokenMarket, @@ -156,6 +157,7 @@ mod tests { use dpp::data_contracts::SystemDataContract; use dpp::prelude::Identifier; use drive::config::DriveConfig; + use platform_version::version::mocks::v5_test::TEST_PROTOCOL_VERSION_5; use platform_version::version::{PlatformVersion, INITIAL_PROTOCOL_VERSION}; #[test] @@ -330,14 +332,21 @@ mod tests { } } - /// The token market contract joins the genesis state at protocol version 15. + /// The token market contract joins the genesis state at protocol version 16, with the + /// token marketplace. That version has no tables yet, so the test version that selects + /// the marketplace stands in for it. #[test] - pub fn should_register_the_token_market_contract_only_from_protocol_version_15() { + pub fn should_register_the_token_market_contract_only_from_protocol_version_16() { let token_market_id = SystemDataContract::TokenMarket.id(); for (platform_version, expected) in [ (PlatformVersion::get(14).expect("protocol 14"), false), - (PlatformVersion::latest(), true), + (PlatformVersion::get(15).expect("protocol 15"), false), + ( + PlatformVersion::get(TEST_PROTOCOL_VERSION_5) + .expect("the token marketplace test version"), + true, + ), ] { let initial_protocol_version = platform_version.protocol_version; let platform = TestPlatformBuilder::new() diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v0/mod.rs index 17b31c0c2ab..8cab82658ba 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v0/mod.rs @@ -927,8 +927,7 @@ where /// trigger, re-store the DashPay contract whose v3 schema states the checks of /// both its data triggers, create the vote decisions trees that yes/no polls /// live in, insert the decision proposals contract whose proposals open those - /// polls, add the token marketplace: its escrow trees and the token market - /// contract, and reconcile the operator payouts of Platform's masternode list + /// polls, and reconcile the operator payouts of Platform's masternode list /// with Dash Core's. fn transition_to_version_15( &self, @@ -1007,30 +1006,6 @@ where platform_version, )?; - // Token marketplace escrow trees (v15 note 17): the BigSumTree under the Tokens tree of - // the tokens open listings hold, and the SumTree under the prefunded specialized - // balances of the credits open offers hold. The same helper builds them at genesis - // (`create_initial_state_structure_v5`), last, so both node populations build the same - // `[Tokens]` and `[PreFundedSpecializedBalances]` subtrees. - self.drive - .insert_token_order_escrow_trees(Some(transaction), platform_version)?; - - // Token market contract: the open listings and offers of the token marketplace, one - // system contract id on every network from this version. Fresh chains register it at - // genesis (`create_genesis_state` v1). Stored without storage flags, as genesis stores - // system contracts. - let token_market_contract = - load_system_data_contract(SystemDataContract::TokenMarket, platform_version)?; - - self.drive.apply_contract( - &token_market_contract, - *block_info, - true, - None, - Some(transaction), - platform_version, - )?; - Ok(()) } } @@ -4583,31 +4558,40 @@ mod tests { ); } - /// The token marketplace escrow trees are built by two paths that must coincide byte for - /// byte: `Drive::create_initial_state_structure_v5` at a v15 genesis and - /// `transition_to_version_15` on a chain upgraded from v14. + /// The token marketplace starts with protocol version 16: protocol version 15 creates + /// neither of its escrow trees nor the token market contract, at genesis or on the upgrade. #[test] - fn test_genesis_v15_and_upgrade_to_v15_build_identical_token_order_escrow_trees() { + fn should_not_create_the_token_marketplace_at_genesis_v15_or_on_the_upgrade_to_v15() { use drive::drive::prefunded_specialized_balances::PREFUNDED_BALANCES_FOR_TOKEN_ORDERS; use drive::drive::tokens::paths::TOKEN_ORDER_ESCROW_KEY; let platform_version_15 = PlatformVersion::get(15).expect("expected v15"); + let token_market_id = SystemDataContract::TokenMarket.id(); - let platform_a = TestPlatformBuilder::new() + let born_at_15 = TestPlatformBuilder::new() .with_initial_protocol_version(15) .build_with_mock_rpc() .with_no_core_masternodes() .set_genesis_state(); - let platform_b = TestPlatformBuilder::new() + let upgraded_to_15 = TestPlatformBuilder::new() .with_initial_protocol_version(14) .build_with_mock_rpc() .with_no_core_masternodes() .set_genesis_state(); - // A genuine v14 genesis has neither escrow tree yet. + let transaction = upgraded_to_15.drive.grove.start_transaction(); + upgraded_to_15 + .transition_to_version_15( + &mut PlatformState::clone(&upgraded_to_15.state.load()), + &BlockInfo::default(), + &transaction, + platform_version_15, + ) + .expect("upgrade: transition_to_version_15 should succeed"); + + for (platform, transaction) in [(&born_at_15, None), (&upgraded_to_15, Some(&transaction))] { - let txn = platform_b.drive.grove.start_transaction(); for (root, key) in [ (RootTree::Tokens as u8, TOKEN_ORDER_ESCROW_KEY), ( @@ -4616,186 +4600,44 @@ mod tests { ), ] { let root_path: [&[u8]; 1] = [&[root]]; - let escrow_root = platform_b.drive.grove.get( + let escrow_root = platform.drive.grove.get( SubtreePath::from(&root_path[..]), &[key], - Some(&txn), + transaction, &platform_version_15.drive.grove_version, ); assert!( escrow_root.value.is_err(), - "v14 genesis must not contain the escrow tree {key} under root {root}; got {:?}", + "protocol version 15 must not hold the escrow tree {key} under root {root}; got {:?}", escrow_root.value ); } - } - - let txn_b = platform_b.drive.grove.start_transaction(); - platform_b - .transition_to_version_15( - &mut PlatformState::clone(&platform_b.state.load()), - &BlockInfo::default(), - &txn_b, - platform_version_15, - ) - .expect("upgrade: transition_to_version_15 should succeed"); - let roots = [ - RootTree::Tokens as u8, - RootTree::PreFundedSpecializedBalances as u8, - ]; - // `collect_subtree_diffs` walks one subtree from its path, so each root is compared on - // its own. - let mut diffs = Vec::new(); - for root in roots { - diffs.extend(collect_subtree_diffs( - &platform_a, - &platform_b, - &txn_b, - vec![vec![root]], - )); - } - assert!( - diffs.is_empty(), - "CONSENSUS FORK: the [Tokens] or [PreFundedSpecializedBalances] subtree differs \ - between a fresh genesis-v15 node and an in-place-upgraded v15 node.\n{}", - diffs.join("\n"), - ); - - // The children agree; the Merk of each root holds the new key itself, so compare the - // root elements too, which carry its root key and sum. - let root_element = |platform: &crate::platform_types::platform::Platform< - crate::rpc::core::MockCoreRPCLike, - >, - root: u8, - txn: drive::grovedb::TransactionArg| { - platform - .drive - .grove - .get_raw( - drive::grovedb_path::SubtreePath::empty(), - &[root], - txn, - &platform_version_15.drive.grove_version, - ) - .unwrap() - .expect("expected to read the root element") - }; - for root in roots { - assert_eq!( - root_element(&platform_a, root, None), - root_element(&platform_b, root, Some(&txn_b)), - "CONSENSUS FORK: the Merk of root {root} is shaped differently on a fresh \ - genesis-v15 node and an in-place-upgraded one" + assert!( + platform + .drive + .fetch_contract( + token_market_id.to_buffer(), + None, + None, + transaction, + platform_version_15, + ) + .value + .expect("expected to query the token market contract") + .is_none(), + "protocol version 15 must not hold the token market contract" ); - } - - // The walks above compare decoded keys and elements, which carry no Merk hash: two - // subtrees holding the same entries in a differently balanced tree would pass them. - // A tree element's value hash in its parent Merk commits to the root hash of the Merk - // below it, and so to everything that subtree holds and how it is arranged; a raw proof - // of the root element yields it. GroveDB proves only committed state, so the upgrade is - // committed first. - platform_b - .drive - .grove - .commit_transaction(txn_b) - .unwrap() - .expect("expected to commit the upgrade"); - let subtree_hash = |platform: &crate::platform_types::platform::Platform< - crate::rpc::core::MockCoreRPCLike, - >, - root: u8| { - let grove_version = &platform_version_15.drive.grove_version; - let query = drive::grovedb::PathQuery::new_single_key(vec![], vec![root]); - let proof = platform + assert!(platform .drive - .grove - .get_proved_path_query(&query, None, None, grove_version) - .unwrap() - .expect("expected to prove the root element"); - let (_, proved) = - drive::grovedb::GroveDb::verify_query_raw(&proof, &query, grove_version) - .expect("expected the proof of the root element to verify"); - assert_eq!(proved.len(), 1, "expected the root element alone"); - proved[0].proof - }; - for root in roots { - assert_eq!( - subtree_hash(&platform_a, root), - subtree_hash(&platform_b, root), - "CONSENSUS FORK: root {root} authenticates to a different hash on a fresh \ - genesis-v15 node and an in-place-upgraded one" - ); + .cache + .system_data_contracts + .find_by_id(token_market_id, platform_version_15) + .expect("expected the lookup to succeed") + .is_none()); } } - #[test] - fn should_insert_the_token_market_contract_on_transition_to_version_15() { - use dpp::data_contract::accessors::v0::DataContractV0Getters; - - let platform = TestPlatformBuilder::new() - .with_initial_protocol_version(14) - .build_with_mock_rpc() - .with_no_core_masternodes() - .set_genesis_state(); - - let platform_version_14 = PlatformVersion::get(14).expect("expected platform version 14"); - let platform_version = PlatformVersion::get(15).expect("expected platform version 15"); - let token_market_id = SystemDataContract::TokenMarket.id(); - - let transaction = platform.drive.grove.start_transaction(); - - assert!( - platform - .drive - .fetch_contract( - token_market_id.to_buffer(), - None, - None, - Some(&transaction), - platform_version_14, - ) - .value - .expect("expected to query the token market contract") - .is_none(), - "the token market contract must not exist before transition_to_version_15" - ); - - platform - .transition_to_version_15( - &mut PlatformState::clone(&platform.state.load()), - &BlockInfo::default(), - &transaction, - platform_version, - ) - .expect("expected the transition to succeed"); - - let stored = platform - .drive - .fetch_contract( - token_market_id.to_buffer(), - None, - None, - Some(&transaction), - platform_version, - ) - .value - .expect("expected to fetch the token market contract") - .expect("the token market contract must exist after transition_to_version_15"); - - assert_eq!(stored.contract.id(), token_market_id); - assert_eq!(stored.contract.owner_id(), Identifier::from([0u8; 32])); - assert_eq!(stored.contract.document_types().len(), 2); - assert!(platform - .drive - .cache - .system_data_contracts - .find_by_id(token_market_id, platform_version) - .expect("expected the post-activation lookup to succeed") - .is_some()); - } - /// CONSENSUS-CRITICAL equivalence guard for the v11→v12 boundary. /// /// The `[ShieldedBalances]` subtree is built two ways that MUST be diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v3/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v3/mod.rs index 35e83fe7629..64cbae8f07a 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v3/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v3/mod.rs @@ -256,7 +256,7 @@ mod tests { .unwrap(); assert_eq!( hex::encode(root), - "e5d0618fe04440f521c7ae1f7e4f7ae1eabe62a12211538208faa5d4431f7404", + "eb3abfdbeb12039eaf6e9c45e8daafb8803482288090be30255faafac936948e", "activation includes the current system contracts and retained-history migration", ); roots.push(root); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/is_allowed.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/is_allowed.rs index 9fc1c20a620..2780f26f314 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/is_allowed.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/is_allowed.rs @@ -172,8 +172,10 @@ impl StateTransitionIsAllowedValidationV0 for StateTransition { } if platform_version.protocol_version < TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION { // The token marketplace: a configuration update that makes a token - // tradeable. Software older than the marketplace cannot decode one, so it - // is refused unpaid, as that software refuses it. + // tradeable. Software older than protocol version 15 cannot decode one, so + // it is refused unpaid, as that software refuses it. Protocol version 15 + // decodes one and refuses it the same way: it has no order transitions, + // and no contract may store the mode before they ship. if let Some(transition) = st.transitions_iter() .find_map(|transition| match transition { @@ -805,6 +807,7 @@ mod tests { use dpp::data_contract::associated_token::token_marketplace_rules::v0::TokenTradeMode; use dpp::platform_value::BinaryData; use dpp::prelude::IdentityNonce; + use dpp::version::mocks::v5_test::TEST_PROTOCOL_VERSION_5; use dpp::state_transition::batch_transition::batched_transition::token_config_update_transition::{TokenConfigUpdateTransition, TokenConfigUpdateTransitionV0}; use dpp::state_transition::batch_transition::batched_transition::BatchedTransition; use dpp::state_transition::batch_transition::BatchTransitionV1; @@ -812,9 +815,23 @@ mod tests { use dpp::tests::fixtures::get_data_contract_fixture; use platform_version::TryIntoPlatformVersioned; - fn protocol_version_14() -> &'static PlatformVersion { - PlatformVersion::get(TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION - 1) - .expect("the version before the token marketplace") +/// The versions that refuse a tradeable token: the last whose software cannot decode +/// the mode, and protocol version 15, which decodes it but creates none of its state. + fn protocol_versions_before_tradeable() -> [&'static PlatformVersion; 2] { + [ + PlatformVersion::get(14).expect("expected protocol version 14"), + PlatformVersion::get(TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION - 1) + .expect("the version before tradeable tokens"), + ] + } + + /// The protocol version that admits a tradeable token. While it has no tables of its own, + /// the test version that selects the token marketplace stands in for it; once it has them, + /// they are the ones used. + fn protocol_version_admitting_tradeable() -> &'static PlatformVersion { + PlatformVersion::get(TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION) + .or_else(|_| PlatformVersion::get(TEST_PROTOCOL_VERSION_5)) + .expect("expected a version that admits a tradeable token") } /// A batch whose only transition sets a token's trade mode to `trade_mode`. @@ -863,36 +880,38 @@ mod tests { } #[test] - fn should_refuse_making_a_token_tradeable_before_protocol_version_15() { - let result = trade_mode_update(TokenTradeMode::Tradeable) - .validate_is_allowed(protocol_version_14()) - .expect("should not error"); - assert_matches!( - result.errors.as_slice(), - [ConsensusError::BasicError(BasicError::StateTransitionNotActiveError(error))] - if error.state_transition_type() - == "TokenConfigUpdateMarketplaceTradeModeTradeable" - && error.current_protocol_version() == 14 - && error.required_protocol_version() - == TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION - ); + fn should_refuse_making_a_token_tradeable_before_protocol_version_16() { + for platform_version in protocol_versions_before_tradeable() { + let result = trade_mode_update(TokenTradeMode::Tradeable) + .validate_is_allowed(platform_version) + .expect("should not error"); + assert_matches!( + result.errors.as_slice(), + [ConsensusError::BasicError(BasicError::StateTransitionNotActiveError(error))] + if error.state_transition_type() + == "TokenConfigUpdateMarketplaceTradeModeTradeable" + && error.current_protocol_version() + == platform_version.protocol_version + && error.required_protocol_version() == 16 + ); + } } - /// Setting the trade mode to the only mode older software knows stays allowed. + /// Setting the trade mode to the mode every version knows stays allowed. #[test] - fn should_allow_setting_the_trade_mode_to_not_tradeable_before_protocol_version_15() { - let result = trade_mode_update(TokenTradeMode::NotTradeable) - .validate_is_allowed(protocol_version_14()) - .expect("should not error"); - assert!(result.is_valid(), "{:?}", result.errors); + fn should_allow_setting_the_trade_mode_to_not_tradeable_before_protocol_version_16() { + for platform_version in protocol_versions_before_tradeable() { + let result = trade_mode_update(TokenTradeMode::NotTradeable) + .validate_is_allowed(platform_version) + .expect("should not error"); + assert!(result.is_valid(), "{:?}", result.errors); + } } #[test] - fn should_allow_making_a_token_tradeable_from_protocol_version_15() { - let platform_version = PlatformVersion::get(TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION) - .expect("the version that introduced the token marketplace"); + fn should_allow_making_a_token_tradeable_from_protocol_version_16() { let result = trade_mode_update(TokenTradeMode::Tradeable) - .validate_is_allowed(platform_version) + .validate_is_allowed(protocol_version_admitting_tradeable()) .expect("should not error"); assert!(result.is_valid(), "{:?}", result.errors); } @@ -917,25 +936,26 @@ mod tests { } #[test] - fn should_refuse_a_contract_with_a_tradeable_token_before_protocol_version_15() { - let platform_version = protocol_version_14(); - let result = - contract_create_with_trade_mode(TokenTradeMode::Tradeable, platform_version) - .validate_is_allowed(platform_version) - .expect("should not error"); - assert_matches!( - result.errors.as_slice(), - [ConsensusError::BasicError(BasicError::StateTransitionNotActiveError(error))] - if error.state_transition_type() == "TokenTradeModeTradeable" - && error.required_protocol_version() - == TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION - ); + fn should_refuse_a_contract_with_a_tradeable_token_before_protocol_version_16() { + for platform_version in protocol_versions_before_tradeable() { + let result = + contract_create_with_trade_mode(TokenTradeMode::Tradeable, platform_version) + .validate_is_allowed(platform_version) + .expect("should not error"); + assert_matches!( + result.errors.as_slice(), + [ConsensusError::BasicError(BasicError::StateTransitionNotActiveError(error))] + if error.state_transition_type() == "TokenTradeModeTradeable" + && error.current_protocol_version() + == platform_version.protocol_version + && error.required_protocol_version() == 16 + ); + } } #[test] - fn should_allow_a_contract_with_a_tradeable_token_from_protocol_version_15() { - let platform_version = PlatformVersion::get(TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION) - .expect("the version that introduced the token marketplace"); + fn should_allow_a_contract_with_a_tradeable_token_from_protocol_version_16() { + let platform_version = protocol_version_admitting_tradeable(); let result = contract_create_with_trade_mode(TokenTradeMode::Tradeable, platform_version) .validate_is_allowed(platform_version) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/token/token_config_update_transition_action/structure_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/token/token_config_update_transition_action/structure_v0/mod.rs index 55f4006bebb..f92b970dbdd 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/token/token_config_update_transition_action/structure_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/token/token_config_update_transition_action/structure_v0/mod.rs @@ -29,7 +29,8 @@ impl TokenConfigUpdateTransitionActionStructureValidationV0 for TokenConfigUpdat /// which Drive refuses for a read-only one. An update that is not performed yet, a group /// member's vote, is refused too, as the group action it opens or joins could never close. /// - /// Then the marketplace rules of the trade mode the update proposes (protocol version 15): a + /// Then the marketplace rules of the trade mode the update proposes (reached with a tradeable + /// mode from protocol version 16, the first whose `is_allowed` gate lets one through): a /// `MarketplaceTradeMode` item can make a token tradeable only if the token is transferable /// (`NonTransferableTokenTradeableError`, 10281), the rule contract create and update apply to /// the configuration they carry. `transferable` is fixed at creation and no other item changes diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/bindings/list/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/bindings/list/mod.rs index 7a34659aa3e..f0d4ab9056d 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/bindings/list/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/bindings/list/mod.rs @@ -57,6 +57,7 @@ mod tests { use dpp::system_data_contracts::token_market_contract; use dpp::system_data_contracts::token_market_contract::v1::document_types::{ask, bid}; use dpp::tokens::gas_fees_paid_by::GasFeesPaidBy; + use dpp::version::mocks::v5_test::TEST_PROTOCOL_VERSION_5; use drive::drive::contract::DataContractFetchInfo; use drive::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::{DocumentBaseTransitionAction, DocumentBaseTransitionActionV0}; use drive::state_transition_action::batch::batched_transition::document_transition::document_delete_transition_action::v0::DocumentDeleteTransitionActionV0; @@ -117,12 +118,15 @@ mod tests { } } - /// Through the version dispatch: the latest protocol version binds exactly one trigger to - /// each replace and delete of an `ask` and a `bid`, and running it refuses the write with - /// `DataTriggerConditionError`. Protocol version 14 binds none of them. + /// Through the version dispatch: the latest bindings bind exactly one trigger to each + /// replace and delete of an `ask` and a `bid`, and running it refuses the write with + /// `DataTriggerConditionError`. Protocol version 14 binds none of them. The token market + /// contract exists from protocol version 16, which has no tables yet, so the platform is + /// born at the test version that selects the token marketplace. #[test] fn should_refuse_order_writes_through_the_latest_bindings_and_bind_none_before_15() { let platform = TestPlatformBuilder::new() + .with_initial_protocol_version(TEST_PROTOCOL_VERSION_5) .build_with_mock_rpc() .set_genesis_state(); let state = platform.state.load(); @@ -131,7 +135,8 @@ mod tests { state: &state, config: &platform.config, }; - let latest = PlatformVersion::latest(); + let latest = PlatformVersion::get(TEST_PROTOCOL_VERSION_5) + .expect("expected the token marketplace test version"); let contract = platform .drive .get_contract_with_fetch_info( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/bindings/list/v3/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/bindings/list/v3/mod.rs index 09b1d669382..7278bc3242c 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/bindings/list/v3/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/bindings/list/v3/mod.rs @@ -20,7 +20,8 @@ use drive::state_transition_action::batch::batched_transition::document_transiti /// sent as a document transition. Only the token marketplace transitions write orders: /// creating one as a document is refused by `creationRestrictionMode` 2, and the types stay /// mutable and deletable, so documents carry a revision and storage flags for the partial -/// fills and closes the platform writes. +/// fills and closes the platform writes. The contract exists from protocol version 16, so +/// nothing matches these bindings under protocol version 15. /// /// Every other binding is v2's. #[inline(always)] diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/commit_reveal_lookup.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/commit_reveal_lookup.rs index f3468e73554..9cc1deffe40 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/commit_reveal_lookup.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/commit_reveal_lookup.rs @@ -904,8 +904,8 @@ mod commit_reveal_lookup_tests { ), ( 15, - (1_766_860, 9_720_000, 15_181_239), - (3_528_980, 75_411_000, 15_181_239) + (1_720_940, 9_720_000, 15_181_239), + (3_483_060, 75_411_000, 15_181_239) ), ] ); @@ -1877,13 +1877,15 @@ mod commit_reveal_lookup_tests { actual_fees.processing_fee, )); } - // A chain born at 15 also holds the decision proposals and token market contracts, - // two more siblings registered at genesis in the contracts tree; with both, the - // written post reads its contract for as many bytes as at 14. The lookups cost the - // same. + // A chain born at 15 also holds the decision proposals contract, one more sibling + // registered at genesis in the contracts tree, which reshapes it so the written post + // reads its contract for fewer bytes (-45_920). The lookups cost the same. + let ((found_at_14, found_storage_at_14), missing_at_14) = fees[0]; assert_eq!( - fees[0], fees[1], - "keyed by owner {keyed_by_owner}: the fees at 14, then at 15" + ((found_at_14 - 45_920, found_storage_at_14), missing_at_14), + fees[1], + "keyed by owner {keyed_by_owner}: the fees at 14 less the genesis shift, then at \ + 15" ); } } @@ -3117,10 +3119,10 @@ mod commit_reveal_lookup_tests { /// it consumes from what its lookup read, without reading it again. #[tokio::test] async fn should_pin_the_fees_of_a_reveal_choosing_the_first_of_its_preorders() { - // At 15 the contracts tree also holds the decision proposals and token market contracts, - // two more siblings registered at genesis; with both, the fixture contract's node is - // billed as many bytes to reach as at 14 - for (protocol_version, accepted_processing_fee) in [(14, 3_574_720), (15, 3_562_700)] { + // At 15 the contracts tree also holds the decision proposals contract, one more sibling + // registered at genesis, which reshapes it so the fixture contract's node is billed + // fewer bytes to reach (-45_920) + for (protocol_version, accepted_processing_fee) in [(14, 3_574_720), (15, 3_516_780)] { let platform_version = PlatformVersion::get(protocol_version).expect("expected the platform version"); let mut fixture = CommitRevealFixture::new_at(platform_version, |contract| { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/deletion.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/deletion.rs index c76768a561b..65cd14bc534 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/deletion.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/deletion.rs @@ -20,8 +20,9 @@ mod deletion_tests { // increases byte-billed contract-tree reads. // The app-connect and moderation charters contracts each add one sibling to the // genesis contracts tree, increasing the bytes billed when reading that tree - // (protocol 14 only). The decision proposals and token market contracts add two more - // at protocol 15, which reshape the tree so the contract read is billed fewer bytes (-47_280). + // (protocol 14 only). The decision proposals contract adds another at protocol + // 15, which reshapes the tree so the contract's node is billed fewer bytes to + // reach (-47_280). // DashPay v3's privateContactRequest type makes its sibling node larger (+2_860). 1773020, ) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns.rs index 2df11542360..d88df79566d 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns.rs @@ -37,9 +37,9 @@ mod dpns_tests { // increasing the bytes billed when reading that tree (protocol 14 only). The // moderation charters contract adds another, which reshapes the tree so the // DPNS contract's node is billed fewer bytes to reach (-287_760). The decision - // proposals and token market contracts add two more at protocol 15, and the DPNS - // node is billed more bytes to reach again (+137_760). - 5_899_360, + // proposals contract adds a third at protocol 15, which reshapes it back to as + // many bytes as with the app-connect contract alone (+287_760, 95_920 a create). + 6_049_360, ) .await; } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns_v3.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns_v3.rs index 6c7e8a8c976..5d77e246fdf 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns_v3.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns_v3.rs @@ -1571,9 +1571,8 @@ mod dpns_v3_tests { } } // At 15 each create also reads the DPNS contract through a contracts tree holding the - // decision proposals and token market contracts, two more siblings registered at - // genesis, which reshape the tree so the DPNS contract's node is billed more bytes to - // reach (+95_920 a create). + // decision proposals contract, one more sibling registered at genesis, which reshapes + // the tree so the DPNS contract's node is billed more bytes to reach (+95_920 a create). assert_eq!( measured, vec![ diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/replacement.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/replacement.rs index ba9302c1f68..eff503ee8f7 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/replacement.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/replacement.rs @@ -525,8 +525,9 @@ mod replacement_tests { // increases byte-billed contract-tree reads. // The app-connect and moderation charters contracts each add one sibling to the // genesis contracts tree, increasing the bytes billed when reading that tree - // (protocol 14 only). The decision proposals and token market contracts add two more - // at protocol 15, which reshape the tree so the contract read is billed fewer bytes (-47_280). + // (protocol 14 only). The decision proposals contract adds another at protocol + // 15, which reshapes the tree so the contract's node is billed fewer bytes to + // reach (-47_280). // DashPay v3's privateContactRequest type makes its sibling node larger (+2_860). 1501720, ) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/token_market_orders.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/token_market_orders.rs index c6c243f48e7..1c82675045e 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/token_market_orders.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/token_market_orders.rs @@ -1,4 +1,4 @@ -//! The token market contract's orders (`ask` and `bid`, protocol version 15) through block +//! The token market contract's orders (`ask` and `bid`, protocol version 16) through block //! processing. Only the token marketplace transitions write an order, so a document //! transition replacing or deleting a stored order is refused by the reject data trigger, //! even when its owner signs it, and the order stays as stored. @@ -17,11 +17,19 @@ mod token_market_orders_tests { use dpp::state_transition::StateTransition; use dpp::system_data_contracts::token_market_contract; use dpp::system_data_contracts::token_market_contract::v1::document_types::{ask, bid}; + use dpp::version::mocks::v5_test::TEST_PROTOCOL_VERSION_5; use drive::util::object_size_info::{ DocumentAndContractInfo, DocumentInfo::DocumentRefInfo, OwnedDocumentInfo, }; use std::collections::BTreeMap; + /// The token market contract exists from protocol version 16, which has no tables yet: the + /// test version that selects the token marketplace stands in for it. + fn token_marketplace_version() -> &'static PlatformVersion { + PlatformVersion::get(TEST_PROTOCOL_VERSION_5) + .expect("expected the token marketplace test version") + } + /// An order of `document_type_name` owned by `owner_id`, for 10 units of `token_id` (a /// token of 6 decimals) at a price of 5, as the marketplace stores it. fn order( @@ -63,7 +71,7 @@ mod token_market_orders_tests { &format!("select * from {document_type_name}"), market, Some(&platform.config.drive), - PlatformVersion::latest(), + token_marketplace_version(), ) .expect("expected an order query"); platform @@ -89,7 +97,7 @@ mod token_market_orders_tests { &platform.state.load(), &BlockInfo::default(), &transaction, - PlatformVersion::latest(), + token_marketplace_version(), false, None, ) @@ -108,8 +116,9 @@ mod token_market_orders_tests { /// leaves both orders as stored. #[tokio::test] async fn should_refuse_a_signed_replace_or_delete_of_a_stored_order() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let mut platform = TestPlatformBuilder::new() + .with_initial_protocol_version(platform_version.protocol_version) .build_with_mock_rpc() .set_genesis_state(); let (owner, signer, key) = setup_identity(&mut platform, 961, dash_to_credits!(0.5)); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/burn/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/burn/mod.rs index 78242a65169..5c543bf6fca 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/burn/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/burn/mod.rs @@ -3963,10 +3963,10 @@ mod token_burn_tests { // +740 per document write from protocol version 14: the contract's version item is // one more node to rehash; -12_820: the documents expirations tree joins `Misc` // beside the token supplies tree the burn rewrites, reshaping the `Misc` Merk - // PROTOCOL_VERSION_15: +48_640: the decision proposals and token market contracts - // join the genesis contracts tree, which reshapes it so the token contract's node is - // billed more bytes to reach - 4_404_840, + // PROTOCOL_VERSION_15: -48_640: the decision proposals contract adds one + // sibling to the genesis contracts tree, which reshapes the tree so the token + // contract's node is billed fewer bytes to reach + 4_307_560, ) .await; } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/direct_selling/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/direct_selling/mod.rs index 90730a76378..911fe3476d8 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/direct_selling/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/direct_selling/mod.rs @@ -31,10 +31,10 @@ mod token_selling_tests { // reads the total supply even though the token sets no max supply. 12_820 credits // less in fees: the documents expirations tree joins `Misc` beside the token // supplies tree the purchase rewrites, reshaping the `Misc` Merk - // PROTOCOL_VERSION_15: 48_640 credits more in fees: the decision proposals and token - // market contracts join the genesis contracts tree, which reshapes it so the token - // contract's node is billed more bytes to reach - 699_868_001_200, + // PROTOCOL_VERSION_15: 48_640 credits less in fees: the decision proposals + // contract adds one sibling to the genesis contracts tree, which reshapes the tree + // so the token contract's node is billed fewer bytes to reach + 699_868_098_480, ) .await; } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/non_transferable/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/non_transferable/mod.rs index 8e1959a5d08..4851ca43680 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/non_transferable/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/non_transferable/mod.rs @@ -602,14 +602,14 @@ mod tradeable { } /// Sends the contract owner's update of the token's trade mode to `Tradeable` to the mempool - /// and then in one block, and returns what check_tx refused it with, the block's result and + /// and then in one block, at protocol version 15, and returns what check_tx refused it with, the block's result and /// the trade mode the token has afterwards. async fn make_tradeable( non_transferable: bool, ) -> (Vec, StateTransitionExecutionResult, bool) { - let platform_version = PlatformVersion::latest(); + let platform_version = PlatformVersion::get(15).expect("expected protocol version 15"); let mut platform = TestPlatformBuilder::new() - .with_latest_protocol_version() + .with_initial_protocol_version(15) .build_with_mock_rpc() .set_genesis_state(); @@ -718,37 +718,30 @@ mod tradeable { (check_tx_errors, result, is_tradeable) } - /// The rule reads only the contract the action carries, so it runs with the batch's advanced - /// structure and the mempool refuses the update too. + /// Before protocol version 16 nothing can trade a token, so an update that makes one tradeable + /// is refused unpaid as not active, in the mempool and in a block, whether or not the token + /// is transferable: the refusal comes before the transferable rule (10281), which the update + /// first reaches at protocol version 16. #[tokio::test] - async fn should_refuse_making_a_non_transferable_token_tradeable_with_a_paid_error_10281() { - let (check_tx_errors, result, is_tradeable) = make_tradeable(true).await; - assert_matches!( - check_tx_errors.as_slice(), - [ConsensusError::BasicError( - BasicError::NonTransferableTokenTradeableError(_) - )] - ); - assert_matches!( - result, - PaidConsensusError { - error: error @ ConsensusError::BasicError( - BasicError::NonTransferableTokenTradeableError(_) - ), - .. - } if error.code() == 10281 - ); - assert!(!is_tradeable); - } - - #[tokio::test] - async fn should_make_a_transferable_token_tradeable_from_protocol_version_15() { - let (check_tx_errors, result, is_tradeable) = make_tradeable(false).await; - assert!(check_tx_errors.is_empty(), "{check_tx_errors:?}"); - assert_matches!( - result, - StateTransitionExecutionResult::SuccessfulExecution { .. } - ); - assert!(is_tradeable); + async fn should_refuse_making_a_token_tradeable_unpaid_as_not_active_at_protocol_version_15() { + for non_transferable in [false, true] { + let (check_tx_errors, result, is_tradeable) = make_tradeable(non_transferable).await; + assert_matches!( + check_tx_errors.as_slice(), + [ConsensusError::BasicError(BasicError::StateTransitionNotActiveError(error))] + if error.state_transition_type() + == "TokenConfigUpdateMarketplaceTradeModeTradeable" + && error.required_protocol_version() == 16, + "non_transferable {non_transferable}: {check_tx_errors:?}" + ); + assert_matches!( + &result, + StateTransitionExecutionResult::UnpaidConsensusError( + error @ ConsensusError::BasicError(BasicError::StateTransitionNotActiveError(_)) + ) if error.code() == 10603, + "non_transferable {non_transferable}: {result:?}" + ); + assert!(!is_tradeable); + } } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/nullifier_batch_guard.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/nullifier_batch_guard.rs index 8773474ce62..9ea1e69a58a 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/nullifier_batch_guard.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/nullifier_batch_guard.rs @@ -731,7 +731,7 @@ async fn should_preserve_single_entry_full_processor_fees_and_result() { .value .unwrap() ), - "9401d37544da815c64abeff4aba2c939cddf246f6e56af99e220b78c98514e46" + "cf69ef6453230e20690be3b3bc3ce08a7db20409a297f1dcc24e14ba1f3dce52" ); assert_eq!( pool.platform @@ -1893,9 +1893,9 @@ async fn should_preserve_a_real_single_payment_sponsor_on_first_check_recheck_an // the batch's estimate (protocol v15 note 14). let (estimated_storage, estimated_processing, actual_storage, actual_processing) = if shielded { - (171_126_000, 213_389_040, 155_142_000, 92_739_560) + (171_126_000, 213_389_040, 155_142_000, 92_785_480) } else { - (138_024_000, 117_713_120, 126_468_000, 3_870_440) + (138_024_000, 117_713_120, 126_468_000, 3_916_360) }; assert_eq!( result.execution_results().as_slice(), @@ -2185,39 +2185,39 @@ async fn should_preserve_single_entry_actions_errors_operations_and_settled_stat let (expected_validation, expected_settled) = match case { "shield" => ( "6a823c2db94612652926e6b9c1ae7feec9c2547dfd4cfc4e474318da1c16d59c", - "6eec6da9023f5143a81f4ee42f3549b31ea8d7f035cf664b5ec429cc5da4d81a", + "7dc04b305978bbe10c536bdc48dd78d5de4e97df259557c6c144b64f7074a2d2", ), "valid-payment" => ( "9388d5cf63c4a571b9fb009679e2e34d0b681acc88f0f5195e7287c7efbd92f7", - "0c3d3f5692aa6b658389d5b6c477f081dba505f350f65f8c3ee1f28dde3a68f2", + "c02bb91ee2f7c6a3bbdbe5f4872e7e09b9ef26f300325d6e54d8ea81cec78f2f", ), "failed-payment" => ( "d9b5fe191841bea952494f2a45e3833f925f4d367a1937b2ef1235a1aa01f51e", - "53c5a1d1399e154096559ec2a9a3ba560db72f08c1f6b0cd316e87131af5d657", + "0371f7c9a204d21e095852f8252e3605c050a52f8f6c161873cfc0b141da1db1", ), "within-bundle-repeat" => ( "8023e03a697a20f6a78396a05503a4bc583ca8f69e19bd7ee07a6ae0ce7be478", - "5766cf0e494a1cae19e034a4336196c62184c699a646d71f0de5e382b6b61fc1", + "58ac5c36b2f2e2b026b35e5f9779bc6e7f455239d628930a342980bf0ff98b97", ), "stored-repeat" => ( "05652ac85c972902e8c09d20a7d8586e17e9434a478b335da136ad85f73def01", - "653f494271acdedb71dc0b9e7a224cc47c84e188a6c5aeb315ff7da2f66627ec", + "f4926cd89acca5f8e4e83faf2e9443c6596faba5d33cb6fd4ff2a623931a6f66", ), "open-mint-group" => ( "5c68381297c9bf68c5e85ebe6bb9e0f1289e2c07718eecfb5e6773d6009455bb", - "c4f5e4054bfa4e85548d713765c6da605f38559e871a2824c38bc8209f3b5a17", + "149ce9457c30a7ae11564b1d87d1891e2755067b899fc244a11eac605ee30a8f", ), "closing-mint-group" => ( "2cedc16732c76e0605b5f46085db3d69c12936a5af55a2a82f52ec9e9ca67e38", - "16e25a2c4139c7b5294599a63461d1ecbba5109fcbf16e61a3578fb152ea72b2", + "0eb8bb2257372efdc4c3f226edf4bc673909ace34dddf9d88b83da7089f9c59e", ), "open-burn-group" => ( "e664a045f020ff84de1ca98f364fbabccfc141ad46aa82c79491a340bb0db5f8", - "f49e470f2f1b5a9ca68245783952dac60d26d7b8b89c20766cc1a3ba43c5e0f5", + "e18f310b05100d9d760e9dba56a95739b011f58a9e584f2e39a2e67c6ef05089", ), "closing-burn-group" => ( "93e1732286f168c4a91d2765931e181c5721bfca1bfd5f93b8baacca03e00b2b", - "3d5beeb201a0a33daacce4469c0a4aec845a82e6b74d31678dfe6aec24481830", + "086f76c36de8a93f1a659ac36f3f2937690443a51a230cb154f0aad0462bc2c0", ), _ => unreachable!("enumerated characterization case"), }; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/contract_user_moderation/tests/restore_constraints.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/contract_user_moderation/tests/restore_constraints.rs index c43c29bcb37..676f95277f8 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/contract_user_moderation/tests/restore_constraints.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/contract_user_moderation/tests/restore_constraints.rs @@ -414,10 +414,9 @@ async fn should_preserve_the_rule_free_restore_fee_and_document() { FeeResult { storage_fee: 9_612_000, // from protocol version 15 the restore reads its contract stored compiled (format - // version 2), about 1.8 times its bytes; the decision proposals and token market - // contracts registered at genesis from 15 add siblings to the contracts tree the - // restore's path crosses - processing_fee: 1_492_880, + // version 2), about 1.8 times its bytes; the decision proposals contract registered at + // genesis from 15 adds a sibling to the contracts tree the restore's path crosses + processing_fee: 1_442_880, ..Default::default() } ); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/contract_structure_error_tests.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/contract_structure_error_tests.rs index 423f1120c43..8c55717ac03 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/contract_structure_error_tests.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/contract_structure_error_tests.rs @@ -559,6 +559,22 @@ async fn should_refuse_a_contract_with_a_tradeable_token_unpaid_at_protocol_vers assert_refused_unpaid_as_not_active(&outcome, "TokenTradeModeTradeable"); } +/// Protocol version 15 decodes the trade mode and creates the marketplace's state, and refuses a +/// tradeable token as protocol version 13 does: nothing can trade one before protocol version 16, +/// so no contract stores the mode before then. +#[tokio::test] +async fn should_refuse_a_contract_with_a_tradeable_token_unpaid_at_protocol_version_15() { + let outcome = register_contract_with( + |contract| add_token_with_trade_mode(contract, TokenTradeMode::Tradeable), + 15, + dash_to_credits!(1.0), + ) + .await + .outcome; + + assert_refused_unpaid_as_not_active(&outcome, "TokenTradeModeTradeable"); +} + /// The same contract with a token that is not tradeable registers. #[tokio::test] async fn should_register_a_contract_with_a_token_that_is_not_tradeable_at_protocol_version_13() { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/contract_structure_error_tests.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/contract_structure_error_tests.rs index eed2de4d24c..4e792c40461 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/contract_structure_error_tests.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/contract_structure_error_tests.rs @@ -371,6 +371,19 @@ async fn should_refuse_an_update_adding_a_tradeable_token_unpaid_at_protocol_ver assert_refused_unpaid_as_not_active(&outcome, "TokenTradeModeTradeable"); } +/// Protocol version 15 decodes the trade mode and refuses the update as protocol version 13 +/// does: nothing can trade a token before protocol version 16. +#[tokio::test] +async fn should_refuse_an_update_adding_a_tradeable_token_unpaid_at_protocol_version_15() { + let outcome = update_fixture_contract( + |contract| add_token_with_trade_mode(contract, TokenTradeMode::Tradeable), + 15, + ) + .await; + + assert_refused_unpaid_as_not_active(&outcome, "TokenTradeModeTradeable"); +} + /// The same update with a token that is not tradeable passes the gate: check_tx admits it. #[tokio::test] async fn should_admit_an_update_adding_a_token_that_is_not_tradeable_at_protocol_version_13() { diff --git a/packages/rs-drive/grovedb-structure.json b/packages/rs-drive/grovedb-structure.json index 3319a196895..3bfb3fc1b22 100644 --- a/packages/rs-drive/grovedb-structure.json +++ b/packages/rs-drive/grovedb-structure.json @@ -792,7 +792,7 @@ "kinds": [ "BigSumTree" ], - "since": 15, + "since": 16, "presence": "always", "source": "packages/rs-drive/src/drive/tokens/paths.rs", "book": "data-model/token-marketplace.md", @@ -813,7 +813,7 @@ "kinds": [ "SumTree" ], - "since": 15, + "since": 16, "presence": "lazy", "source": "packages/rs-drive/src/drive/tokens/paths.rs", "description": "The escrowed listings of one token; created with its first listing.", @@ -834,7 +834,7 @@ "SumItem" ], "value": "token amount", - "since": 15, + "since": 16, "presence": "lazy", "source": "packages/rs-drive/src/drive/tokens/paths.rs", "description": "What one open listing still holds.", @@ -2044,7 +2044,7 @@ "kinds": [ "SumTree" ], - "since": 15, + "since": 16, "presence": "always", "source": "packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs", "book": "data-model/token-marketplace.md", @@ -2066,7 +2066,7 @@ "SumItem" ], "value": "credits", - "since": 15, + "since": 16, "presence": "lazy", "source": "packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs", "description": "What one open offer still holds.", @@ -6551,10 +6551,7 @@ "tree": { "hex": "80", "left": { - "hex": "40", - "left": { - "hex": "20" - } + "hex": "40" }, "right": { "hex": "c0" @@ -6658,10 +6655,7 @@ "hex": "20" }, "right": { - "hex": "5c", - "right": { - "hex": "60" - } + "hex": "5c" } }, "right": { diff --git a/packages/rs-drive/src/cache/system_contracts.rs b/packages/rs-drive/src/cache/system_contracts.rs index 71d368d7711..93bdf0509c1 100644 --- a/packages/rs-drive/src/cache/system_contracts.rs +++ b/packages/rs-drive/src/cache/system_contracts.rs @@ -251,7 +251,7 @@ impl SystemDataContracts { SystemDataContract::DecisionProposals => { DECISION_PROPOSALS_CONTRACT_INITIAL_PROTOCOL_VERSION } - // Written to state by the transition to protocol version 15. + // Written to state by the transition to protocol version 16. SystemDataContract::TokenMarket => TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION, // Never served from this cache: `WalletUtils` is only ever read from grovedb, and // the reserved `FeatureFlags` slot has no implementation. @@ -326,6 +326,7 @@ mod tests { use super::*; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; + use platform_version::version::mocks::v5_test::TEST_PROTOCOL_VERSION_5; fn platform_version(protocol_version: ProtocolVersion) -> &'static PlatformVersion { PlatformVersion::get(protocol_version).expect("expected a supported platform version") @@ -513,19 +514,35 @@ mod tests { fn should_serve_token_market_only_from_its_activation_version() { let contracts = SystemDataContracts::new(); - assert!(contracts - .find_by_id(SystemDataContract::TokenMarket.id(), platform_version(14)) - .expect("expected the pre-activation lookup to succeed") - .is_none()); + // Protocol version 16, the token marketplace's first, has no tables yet: the test + // version that selects the marketplace stands in for it. + let token_marketplace_version = platform_version(TEST_PROTOCOL_VERSION_5); + assert!( + token_marketplace_version.protocol_version + >= TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION + ); + + for before in [14, TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION - 1] { + assert!(contracts + .find_by_id( + SystemDataContract::TokenMarket.id(), + platform_version(before) + ) + .expect("expected the pre-activation lookup to succeed") + .is_none()); + } assert!(contracts .find_by_id( SystemDataContract::TokenMarket.id(), - platform_version(TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION) + token_marketplace_version ) - .expect("expected the v15 lookup to succeed") + .expect("expected the lookup from the activation version to succeed") .is_some()); assert!(contracts - .find_by_id(SystemDataContract::TokenMarket.id(), platform_version(14)) + .find_by_id( + SystemDataContract::TokenMarket.id(), + platform_version(TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION - 1) + ) .expect("an old-version lookup after materialization must succeed") .is_none()); } diff --git a/packages/rs-drive/src/drive/contract/fee_pots/estimated_costs/v1/mod.rs b/packages/rs-drive/src/drive/contract/fee_pots/estimated_costs/v1/mod.rs index 96b629ff9f9..9ac2aba6a01 100644 --- a/packages/rs-drive/src/drive/contract/fee_pots/estimated_costs/v1/mod.rs +++ b/packages/rs-drive/src/drive/contract/fee_pots/estimated_costs/v1/mod.rs @@ -6,7 +6,7 @@ use dpp::data_contract::document_type::action_fees::ContractFeePot; use grovedb::batch::KeyInfoPath; impl Drive { - /// v0 (protocol version 15), keeping a deeper description of the prefunded balances layer + /// v0 (protocol version 16), keeping a deeper description of the prefunded balances layer /// that another write of the batch registered: the escrow of the token marketplace's offers /// sits a level below the fee pots' keys. #[inline(always)] diff --git a/packages/rs-drive/src/drive/identity/estimation_costs/for_balances/v1/mod.rs b/packages/rs-drive/src/drive/identity/estimation_costs/for_balances/v1/mod.rs index 017dd1c5141..86471eff905 100644 --- a/packages/rs-drive/src/drive/identity/estimation_costs/for_balances/v1/mod.rs +++ b/packages/rs-drive/src/drive/identity/estimation_costs/for_balances/v1/mod.rs @@ -4,7 +4,7 @@ use crate::util::estimated_layers::EstimatedLayers; use grovedb::batch::KeyInfoPath; impl Drive { - /// Adds estimation costs for identity balances (protocol version 15): v0, keeping a deeper + /// Adds estimation costs for identity balances (protocol version 16): v0, keeping a deeper /// description of the root layer that another write of the batch registered. An offer of the /// token marketplace debits the buyer's balance and credits its escrow under the prefunded /// specialized balances, which sit deeper in the root tree than the balances, whichever diff --git a/packages/rs-drive/src/drive/initialization/v5/mod.rs b/packages/rs-drive/src/drive/initialization/v5/mod.rs index 858f42f8894..f23b0542b81 100644 --- a/packages/rs-drive/src/drive/initialization/v5/mod.rs +++ b/packages/rs-drive/src/drive/initialization/v5/mod.rs @@ -1,6 +1,6 @@ //! Drive Initialization //! -//! Version 5: version 4 plus the token marketplace escrow trees (protocol version 15). +//! Version 5: version 4 plus the token marketplace escrow trees (protocol version 16). use crate::drive::Drive; use crate::error::Error; @@ -16,12 +16,12 @@ impl Drive { ) -> Result<(), Error> { self.create_initial_state_structure_v4(transaction, platform_version)?; - // Token marketplace escrow trees (protocol version 15): the BigSumTree under the Tokens + // Token marketplace escrow trees (protocol version 16): the BigSumTree under the Tokens // tree of the tokens open listings hold, and the SumTree under the prefunded specialized // balances of the credits open offers hold. Last, after everything version 4 builds, and - // through the same helper as the upgrade path (`Platform::transition_to_version_15`), so - // a chain born at version 15 and one upgraded to it build byte-identical `[Tokens]` and - // `[PreFundedSpecializedBalances]` subtrees. + // through the helper the upgrade to that version must use too, so a chain born at it and + // one upgraded to it build byte-identical `[Tokens]` and `[PreFundedSpecializedBalances]` + // subtrees. self.insert_token_order_escrow_trees(transaction, platform_version)?; Ok(()) diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs index 055d96c0f3f..ebe6f751303 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs @@ -28,7 +28,7 @@ use crate::util::batch::GroveDbOpBatch; pub const PREFUNDED_BALANCES_FOR_VOTING: u8 = 128; /// The key for the credits the token marketplace holds in escrow for open offers (protocol -/// version 15): a SumTree whose SumItems are keyed by order id. It sits under the prefunded +/// version 16): a SumTree whose SumItems are keyed by order id. It sits under the prefunded /// specialized balances root, a SumTree, so the credit conservation check counts it. pub const PREFUNDED_BALANCES_FOR_TOKEN_ORDERS: u8 = 32; diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/structure.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/structure.rs index d34de62cd7b..cfd25a18b30 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/structure.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/structure.rs @@ -63,7 +63,7 @@ pub(crate) fn structure() -> StructureNode { "PREFUNDED_BALANCES_FOR_TOKEN_ORDERS", ) .kind(ElementKind::SumTree) - .since(15) + .since(16) .source("packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs") .book("data-model/token-marketplace.md") .describe( diff --git a/packages/rs-drive/src/drive/tokens/calculate_total_tokens_balance/v0/mod.rs b/packages/rs-drive/src/drive/tokens/calculate_total_tokens_balance/v0/mod.rs index e7eecb2e56d..d3e73b33008 100644 --- a/packages/rs-drive/src/drive/tokens/calculate_total_tokens_balance/v0/mod.rs +++ b/packages/rs-drive/src/drive/tokens/calculate_total_tokens_balance/v0/mod.rs @@ -44,7 +44,7 @@ impl Drive { total_identity_token_balances, // Token shielded pools do not exist before protocol version 14. total_token_shielded_pool_balances: 0, - // v0 predates the token order escrow (protocol version 15): zero leaves the + // v0 predates the token order escrow (protocol version 16): zero leaves the // conservation check of every protocol version that selects v0 as it was. total_token_order_escrow_balances: 0, }) diff --git a/packages/rs-drive/src/drive/tokens/calculate_total_tokens_balance/v1/mod.rs b/packages/rs-drive/src/drive/tokens/calculate_total_tokens_balance/v1/mod.rs index 89cfb39c925..77ca3a35805 100644 --- a/packages/rs-drive/src/drive/tokens/calculate_total_tokens_balance/v1/mod.rs +++ b/packages/rs-drive/src/drive/tokens/calculate_total_tokens_balance/v1/mod.rs @@ -53,7 +53,7 @@ impl Drive { total_tokens_in_platform, total_identity_token_balances, total_token_shielded_pool_balances, - // v1 predates the token order escrow (protocol version 15): zero leaves the + // v1 predates the token order escrow (protocol version 16): zero leaves the // conservation check of protocol version 14, which selects v1, as it was. total_token_order_escrow_balances: 0, }) diff --git a/packages/rs-drive/src/drive/tokens/calculate_total_tokens_balance/v2/mod.rs b/packages/rs-drive/src/drive/tokens/calculate_total_tokens_balance/v2/mod.rs index c4e69d0f301..1b0ed80b1c2 100644 --- a/packages/rs-drive/src/drive/tokens/calculate_total_tokens_balance/v2/mod.rs +++ b/packages/rs-drive/src/drive/tokens/calculate_total_tokens_balance/v2/mod.rs @@ -11,7 +11,7 @@ use grovedb::TransactionArg; use platform_version::version::PlatformVersion; impl Drive { - /// Version 2 (protocol version 15): the token marketplace escrow BigSumTree joins the + /// Version 2 (protocol version 16): the token marketplace escrow BigSumTree joins the /// identity balances and the shielded pools on the balance side, so `identity balances + /// shielded pool balances + escrowed listings` must equal the total supplies. Listing a token /// moves it from its holder's balance into escrow without touching supply. diff --git a/packages/rs-drive/src/drive/tokens/mod.rs b/packages/rs-drive/src/drive/tokens/mod.rs index e5127d9461a..6597d0e40aa 100644 --- a/packages/rs-drive/src/drive/tokens/mod.rs +++ b/packages/rs-drive/src/drive/tokens/mod.rs @@ -55,7 +55,7 @@ pub mod unfreeze; #[cfg(feature = "server")] pub mod calculate_total_tokens_balance; -/// The escrow of the token marketplace (protocol version 15): the tokens open listings hold and +/// The escrow of the token marketplace (protocol version 16): the tokens open listings hold and /// the credits open offers hold. #[cfg(feature = "server")] pub mod order_escrow; diff --git a/packages/rs-drive/src/drive/tokens/order_escrow/estimated_costs/v0/mod.rs b/packages/rs-drive/src/drive/tokens/order_escrow/estimated_costs/v0/mod.rs index f749a910981..e825612783d 100644 --- a/packages/rs-drive/src/drive/tokens/order_escrow/estimated_costs/v0/mod.rs +++ b/packages/rs-drive/src/drive/tokens/order_escrow/estimated_costs/v0/mod.rs @@ -44,7 +44,7 @@ impl Drive { // The escrow key sits deeper in the Tokens Merk than the balances key the token balance // estimation describes at level 0, and a batch moving tokens into or out of escrow writes - // both. From protocol version 15 the token balance estimation keeps this deeper + // both. From protocol version 16 the token balance estimation keeps this deeper // description too (`for_token_balances` 1), whichever registers first. insert_estimated_layer_keeping_deeper( estimated_costs_only_with_layer_info, diff --git a/packages/rs-drive/src/drive/tokens/order_escrow/insert_trees.rs b/packages/rs-drive/src/drive/tokens/order_escrow/insert_trees.rs index c8d17cb7a45..4f954cdd7ea 100644 --- a/packages/rs-drive/src/drive/tokens/order_escrow/insert_trees.rs +++ b/packages/rs-drive/src/drive/tokens/order_escrow/insert_trees.rs @@ -9,7 +9,7 @@ use grovedb::{Element, TransactionArg}; use grovedb_path::SubtreePath; impl Drive { - /// Inserts the two escrow trees of the token marketplace (protocol version 15) if they do not + /// Inserts the two escrow trees of the token marketplace (protocol version 16) if they do not /// exist yet: /// /// - `[Tokens, TOKEN_ORDER_ESCROW_KEY]`, an empty BigSumTree that holds one SumTree per @@ -21,9 +21,9 @@ impl Drive { /// specialized balances root is a SumTree, so the credit conservation check counts it /// without a change. /// - /// CONSENSUS-CRITICAL: both the genesis path (`Drive::create_initial_state_structure_v5`) - /// and the upgrade path (`Platform::transition_to_version_15`) call this one helper, in the - /// same position, so a chain born at protocol version 15 and a chain upgraded to it build + /// CONSENSUS-CRITICAL: the genesis path (`Drive::create_initial_state_structure_v5`) calls + /// this helper last, and the upgrade to protocol version 16 must call it too, in the same + /// position, so a chain born at that version and a chain upgraded to it build /// byte-identical `[Tokens]` and `[PreFundedSpecializedBalances]` subtrees. pub fn insert_token_order_escrow_trees( &self, diff --git a/packages/rs-drive/src/drive/tokens/order_escrow/mod.rs b/packages/rs-drive/src/drive/tokens/order_escrow/mod.rs index d5ad05bc43b..d44df3ecc6a 100644 --- a/packages/rs-drive/src/drive/tokens/order_escrow/mod.rs +++ b/packages/rs-drive/src/drive/tokens/order_escrow/mod.rs @@ -1,4 +1,4 @@ -//! The escrow of the token marketplace (protocol version 15). +//! The escrow of the token marketplace (protocol version 16). //! //! An open listing holds the tokens it offers in `[Tokens, TOKEN_ORDER_ESCROW_KEY, token id, //! order id]`, a SumItem of the token's escrow SumTree, and an open offer holds the credits it @@ -43,8 +43,16 @@ mod tests { use grovedb::EstimatedLayerSizes::AllSubtrees; use grovedb::EstimatedSumTrees::AllBigSumTrees; use grovedb::{EstimatedLayerInformation, GroveDb, TreeType}; + use platform_version::version::mocks::v5_test::TEST_PROTOCOL_VERSION_5; use std::collections::BTreeMap; + /// The token marketplace starts with protocol version 16, which has no tables yet: its + /// escrow is tested under the test version that selects it on top of protocol version 15. + fn token_marketplace_version() -> &'static PlatformVersion { + PlatformVersion::get(TEST_PROTOCOL_VERSION_5) + .expect("expected the token marketplace test version") + } + fn apply(drive: &Drive, operations: Vec) { drive .apply_batch_low_level_drive_operations( @@ -52,14 +60,14 @@ mod tests { None, operations, &mut vec![], - &PlatformVersion::latest().drive, + &token_marketplace_version().drive, ) .expect("expected to apply the operations"); } #[test] fn should_hold_set_and_release_what_a_listing_escrows() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let drive = setup_drive_with_initial_state_structure(Some(platform_version)); let token_id = [5; 32]; let order_id = [9; 32]; @@ -119,7 +127,7 @@ mod tests { #[test] fn should_hold_set_and_release_what_an_offer_escrows() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let drive = setup_drive_with_initial_state_structure(Some(platform_version)); let order_id = [9; 32]; let fetch = |drive: &Drive| { @@ -158,11 +166,11 @@ mod tests { } /// Listing moves tokens from a balance into escrow: the supply is unchanged, and the token - /// conservation check of protocol version 15 counts the escrow. The calculator of protocol + /// conservation check of protocol version 16 counts the escrow. The calculator of protocol /// version 14, which reads no escrow, would see tokens missing. #[test] fn should_keep_the_token_supply_balanced_when_tokens_move_into_escrow() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let drive = setup_drive_with_initial_state_structure(Some(platform_version)); let token_id = [5; 32]; let identity_id = [6; 32]; @@ -244,14 +252,14 @@ mod tests { order_id, None, &mut vec![], - PlatformVersion::latest(), + token_marketplace_version(), ) .expect("expected to fetch the escrow") } fn fetch_offer(drive: &Drive, order_id: [u8; 32]) -> Option { drive - .fetch_credit_order_escrow(order_id, None, &mut vec![], PlatformVersion::latest()) + .fetch_credit_order_escrow(order_id, None, &mut vec![], token_marketplace_version()) .expect("expected to fetch the escrow") } @@ -259,7 +267,7 @@ mod tests { /// tree the first queues and does not insert it again. #[test] fn should_insert_a_tokens_escrow_tree_once_for_two_listings_in_one_batch() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let drive = setup_drive_with_initial_state_structure(Some(platform_version)); let token_id = [5; 32]; @@ -296,7 +304,7 @@ mod tests { /// the batch is refused: what the shared operations prevent. #[test] fn should_refuse_a_batch_inserting_a_tokens_escrow_tree_twice() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let drive = setup_drive_with_initial_state_structure(Some(platform_version)); let token_id = [5; 32]; let mut batch = vec![]; @@ -330,7 +338,7 @@ mod tests { /// cost something to apply and change nothing. #[test] fn should_estimate_every_escrow_write_without_writing_it() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let drive = setup_drive_with_initial_state_structure(Some(platform_version)); let token_id = [5; 32]; let order_id = [9; 32]; @@ -455,7 +463,7 @@ mod tests { /// deeper description already registered for the same batch. #[test] fn should_keep_the_deeper_tokens_layer_estimate() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let tokens_layer_level = |estimation: &EstimatedLayers| match estimation .get(&KeyInfoPath::from_known_path(tokens_root_path())) .map(|layer| &layer.estimated_layer_count) @@ -503,7 +511,7 @@ mod tests { /// Both escrows hold signed 8-byte values: `i64::MAX` is held, one more is refused. #[test] fn should_hold_up_to_i64_max_in_either_escrow() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let drive = setup_drive_with_initial_state_structure(Some(platform_version)); let token_id = [5; 32]; let largest = i64::MAX as u64; @@ -569,11 +577,12 @@ mod tests { .is_err()); } - /// The escrow methods are active from protocol version 15: at 14 every one of them refuses - /// with `VersionNotActive` instead of building operations for trees that do not exist there. + /// The escrow methods are active from protocol version 16: at 14 and 15 every one of them + /// refuses with `VersionNotActive` instead of building operations for trees that do not + /// exist there. #[test] - fn should_refuse_every_escrow_method_before_protocol_version_15() { - let latest = PlatformVersion::latest(); + fn should_refuse_every_escrow_method_before_protocol_version_16() { + let latest = token_marketplace_version(); let drive = setup_drive_with_initial_state_structure(Some(latest)); let token_id = [5; 32]; let order_id = [9; 32]; @@ -686,20 +695,23 @@ mod tests { ] }; - let before = PlatformVersion::get(14).expect("expected protocol version 14"); - for (name, result) in calls(before) { - assert!( - matches!( - result, - Err(Error::Drive(DriveError::VersionNotActive { .. })) - ), - "{name} at protocol version 14: expected VersionNotActive, got {result:?}" - ); + for before in [14, 15] { + let platform_version = + PlatformVersion::get(before).expect("expected the protocol version"); + for (name, result) in calls(platform_version) { + assert!( + matches!( + result, + Err(Error::Drive(DriveError::VersionNotActive { .. })) + ), + "{name} at protocol version {before}: expected VersionNotActive, got {result:?}" + ); + } } for (name, result) in calls(latest) { assert!( result.is_ok(), - "{name} at the latest protocol version: {result:?}" + "{name} at the token marketplace test version: {result:?}" ); } } @@ -710,7 +722,7 @@ mod tests { drive: &Drive, build: impl Fn(&mut Option) -> Vec, ) -> (FeeResult, FeeResult) { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let fee = |costs: Vec| { drive .calculate_fee( @@ -755,7 +767,7 @@ mod tests { /// specialized balances Merk and a listing's on the fourth of the Tokens Merk. #[test] fn should_estimate_at_least_what_an_escrow_write_costs() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let drive = setup_drive_with_initial_state_structure(Some(platform_version)); let token_id = [5; 32]; @@ -822,11 +834,11 @@ mod tests { } /// The offers' escrow is described at its key's depth in the prefunded specialized balances - /// layer, and from protocol version 15 the voting balance and fee pot estimations of the + /// layer, and from protocol version 16 the voting balance and fee pot estimations of the /// same batch keep that deeper description, whichever registers first. #[test] fn should_keep_the_deeper_prefunded_balances_layer_estimate() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let prefunded_layer_level = |estimation: &EstimatedLayers| match estimation .get(&KeyInfoPath::from_known_path( prefunded_specialized_balances_path(), @@ -889,7 +901,7 @@ mod tests { /// the balance estimation built last lowers it to the balances key, as it always did. #[test] fn should_keep_the_escrow_depth_whichever_of_balance_and_escrow_is_built_first() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let drive = setup_drive_with_initial_state_structure(Some(platform_version)); let token_id = [5; 32]; let tokens_layer_level = |estimation: &Option| match estimation @@ -954,7 +966,7 @@ mod tests { /// did. #[test] fn should_keep_the_credit_escrow_depths_whichever_of_debit_and_escrow_is_built_first() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let drive = setup_drive_with_initial_state_structure(Some(platform_version)); let level_at = |estimation: &Option, path: KeyInfoPath| match estimation .as_ref() @@ -1018,7 +1030,7 @@ mod tests { /// rebuilds and holds that scale's orders alone. #[test] fn should_sum_the_depth_of_each_price_scale_apart() { - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let drive = setup_drive_with_initial_state_structure(Some(platform_version)); let contract = load_system_data_contract(SystemDataContract::TokenMarket, platform_version) .expect("expected the token market contract"); diff --git a/packages/rs-drive/src/drive/tokens/paths.rs b/packages/rs-drive/src/drive/tokens/paths.rs index 63037812436..25e38decbd1 100644 --- a/packages/rs-drive/src/drive/tokens/paths.rs +++ b/packages/rs-drive/src/drive/tokens/paths.rs @@ -32,7 +32,7 @@ pub const TOKEN_DISTRIBUTIONS_KEY: u8 = 32; pub const TOKEN_SHIELDED_POOLS_KEY: u8 = 224; /// Key for the token order escrow tree (a BigSumTree of per-token SumTrees). /// -/// Introduced in protocol version 15 for the token marketplace. Each token that has had an open +/// Introduced in protocol version 16 for the token marketplace. Each token that has had an open /// listing owns one child SumTree keyed by its token id, created with its first listing, whose /// SumItems, keyed by order id, are the tokens each open listing holds in escrow. The BigSumTree /// total is every token held in escrow and joins the identity balances and the shielded pools on @@ -47,7 +47,7 @@ pub const TOKEN_ORDER_ESCROW_KEY: u8 = 96; // TOKEN_DISTRIBUTIONS_KEY TOKEN_DIRECT_SELL_PRICE_KEY TOKEN_CONTRACT_INFO_KEY // // TOKEN_SHIELDED_POOLS_KEY (protocol version 14) is the right child of TOKEN_IDENTITY_INFO_KEY, -// and TOKEN_ORDER_ESCROW_KEY (protocol version 15) the right child of TOKEN_DIRECT_SELL_PRICE_KEY. +// and TOKEN_ORDER_ESCROW_KEY (protocol version 16) the right child of TOKEN_DIRECT_SELL_PRICE_KEY. // The token distribution Tree level diff --git a/packages/rs-drive/src/drive/tokens/structure.rs b/packages/rs-drive/src/drive/tokens/structure.rs index 435e2b87491..39041c5ffe1 100644 --- a/packages/rs-drive/src/drive/tokens/structure.rs +++ b/packages/rs-drive/src/drive/tokens/structure.rs @@ -373,7 +373,7 @@ fn distributions() -> StructureNode { ]) } -/// The tokens the token marketplace holds in escrow for open listings, from protocol 15. +/// The tokens the token marketplace holds in escrow for open listings, from protocol 16. fn order_escrow() -> StructureNode { StructureNode::fixed( "order_escrow", @@ -382,7 +382,7 @@ fn order_escrow() -> StructureNode { "TOKEN_ORDER_ESCROW_KEY", ) .kind(ElementKind::BigSumTree) - .since(15) + .since(16) .source(SOURCE) .book("data-model/token-marketplace.md") .describe( diff --git a/packages/rs-drive/src/structure/tests.rs b/packages/rs-drive/src/structure/tests.rs index c84105bb2e2..b239de8c3be 100644 --- a/packages/rs-drive/src/structure/tests.rs +++ b/packages/rs-drive/src/structure/tests.rs @@ -9,6 +9,7 @@ use crate::util::test_helpers::setup::{setup_drive, setup_drive_with_initial_sta use dpp::block::block_info::BlockInfo; use dpp::identity::Identity; use dpp::version::PlatformVersion; +use platform_version::version::mocks::v5_test::TEST_PROTOCOL_VERSION_5; use std::collections::BTreeSet; use std::fs; use std::path::{Path, PathBuf}; @@ -1946,9 +1947,11 @@ mod fixtures { conformance_of(&drive, "token_shielded_pool", run); } /// The token marketplace escrow: two listings of one token holding tokens, and two offers - /// holding credits. + /// holding credits. The marketplace starts with protocol version 16, which has no tables + /// yet, so the fixture is built under the test version that selects it. fn token_order_escrow(run: &mut FixtureRun) { - let platform_version = PlatformVersion::latest(); + let platform_version = PlatformVersion::get(TEST_PROTOCOL_VERSION_5) + .expect("expected the token marketplace test version"); let drive = setup_drive_with_initial_state_structure(Some(platform_version)); let token_id = [7; 32]; for (order_id, amount) in [([1; 32], 500), ([2; 32], 30)] { @@ -1980,7 +1983,7 @@ mod fixtures { .expect("expected the offer escrow operations"), ); } - conformance_of(&drive, "token_order_escrow", run); + conformance_of_at_version(&drive, "token_order_escrow", run, platform_version); } /// Documents of a type declaring a `ttl`: stored without storage flags, each with an entry /// in the documents expirations tree under the time it expires, and a lifetime storage fee diff --git a/packages/rs-drive/src/verify/document/verify_document_history/tests.rs b/packages/rs-drive/src/verify/document/verify_document_history/tests.rs index 277f4517cd3..40414fcfd0e 100644 --- a/packages/rs-drive/src/verify/document/verify_document_history/tests.rs +++ b/packages/rs-drive/src/verify/document/verify_document_history/tests.rs @@ -393,8 +393,8 @@ fn should_preserve_non_history_roots_fees_and_proofs_after_grove_upgrade() { ) } else { ( - "651594de7d2cae89a6730ecdd0332a8b9702ca4ae0774765ffe4c5a8df75b7dc", - "19f71d377e3e4378cc613495e47b6854f41d1a626b37c6a35c8ea5f8e8a19126", + "345843c481567f2c52b2245f36ab9e8ff22dc6eb0972c779b7ac5f2bbd8e3a18", + "234aacc1287d406f115f9a69469bba948a052f9374b5375e1b5f0361006294e6", ) }; let mut reference = selected.clone(); @@ -611,7 +611,7 @@ fn should_preserve_non_history_roots_fees_and_proofs_after_grove_upgrade() { let expected_nested_proof = if selected.protocol_version == 14 { "9a1b6f2933735c9a54d7eadac8872d08ce5936e4bc798aa6d00abebd73248578" } else { - "3c84d97bc0393698e5e2a33cd55e52c4e2f526dd4e13c96065578d25af797846" + "d5a96f13bd5f69e3bba2d20b5573a6e060524b03285c5d9518a5770cd775a233" }; assert_eq!( sha256::Hash::hash(&nested_proof).to_string(), diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v11.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v11.rs index 6f990d7d0ad..cf2ae46dd13 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v11.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v11.rs @@ -28,7 +28,8 @@ use super::{ /// and the profile create and replace triggers, as the DashPay contract v3 /// (`SYSTEM_DATA_CONTRACT_VERSIONS_V4`) declares their checks as schema keywords; and with a /// refusal of a document transition's replace or delete of a token market contract order -/// (`ask` and `bid`), as only the token marketplace transitions write them. +/// (`ask` and `bid`), as only the token marketplace transitions write them. That contract +/// exists from protocol version 16, so nothing matches these bindings before it. /// - the batch `advanced_structure` 2: v1, then the structure checks of token actions protocol /// v15 introduces, which read only the contract the action carries and so run in check_tx too. /// A `TokenConfigUpdate` can make a token tradeable only if it is transferable. @@ -126,7 +127,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V11: DriveAbciValidationVersions = document_create_transition_structure_validation: 2, // a decision proposal states its fund, a rule within the limits and an end date one to four weeks away; the poll a contested create names is compared with the expected one by what names the index document_create_transition_state_validation: 3, // a non-contested create cannot take the values of a live contest its index values do not decide data_triggers: DriveAbciValidationDataTriggerAndBindingVersions { - bindings: 3, // no DashPay bindings (DashPay v3 declares their checks); the token market contract's orders are written by the marketplace transitions only + bindings: 3, // no DashPay bindings (DashPay v3 declares their checks); also lists the token market order rejects, unreachable before that contract exists (protocol version 16) triggers: DriveAbciValidationDataTriggerVersions { create_domain_data_trigger: 2, ..DRIVE_ABCI_VALIDATION_VERSIONS_V10 diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_token_method_versions/mod.rs b/packages/rs-platform-version/src/version/drive_versions/drive_token_method_versions/mod.rs index 650f5adbce7..471891f73f1 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_token_method_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_token_method_versions/mod.rs @@ -11,13 +11,13 @@ pub struct DriveTokenMethodVersions { pub update: DriveTokenUpdateMethodVersions, pub calculate_total_tokens_balance: FeatureVersion, pub distribution: DriveTokenDistributionMethodVersions, - /// The escrow of the token marketplace (protocol version 15): the tokens open listings hold + /// The escrow of the token marketplace (protocol version 16): the tokens open listings hold /// and the credits open offers hold. pub order_escrow: DriveTokenOrderEscrowMethodVersions, } /// The escrow methods of the token marketplace: `None` in every table before protocol version -/// 15, whose transitions are refused there, so a call before 15 is an error rather than a +/// 16, whose transitions are refused there, so a call before 16 is an error rather than a /// silent write. #[derive(Clone, Debug, Default)] pub struct DriveTokenOrderEscrowMethodVersions { diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_token_method_versions/v1.rs b/packages/rs-platform-version/src/version/drive_versions/drive_token_method_versions/v1.rs index 7f3280a7831..6766045d53f 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_token_method_versions/v1.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_token_method_versions/v1.rs @@ -70,7 +70,7 @@ pub const DRIVE_TOKEN_METHOD_VERSIONS_V1: DriveTokenMethodVersions = DriveTokenM mark_once_per_identity_release_as_distributed: 0, evonode_participation_rewards: 0, }, - // The token marketplace's escrow is active from protocol version 15 + // The token marketplace's escrow is active from protocol version 16 // (`DRIVE_TOKEN_METHOD_VERSIONS_V3`). order_escrow: DriveTokenOrderEscrowMethodVersions { add_tokens: None, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_token_method_versions/v3.rs b/packages/rs-platform-version/src/version/drive_versions/drive_token_method_versions/v3.rs index 84a628706b2..43c3aea7a6a 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_token_method_versions/v3.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_token_method_versions/v3.rs @@ -3,7 +3,9 @@ use crate::version::drive_versions::drive_token_method_versions::{ DriveTokenMethodVersions, DriveTokenOrderEscrowMethodVersions, }; -/// Drive token methods for protocol v15+. +/// Drive token methods with the token marketplace, which starts with protocol version 16. No +/// protocol version's tables select them yet: until protocol version 16 has tables, the test +/// version `TEST_PLATFORM_V5` does. /// /// Identical to [`super::v2::DRIVE_TOKEN_METHOD_VERSIONS_V2`] except /// `calculate_total_tokens_balance` is bumped to `2`: the tokens the token marketplace holds in diff --git a/packages/rs-platform-version/src/version/drive_versions/v10.rs b/packages/rs-platform-version/src/version/drive_versions/v10.rs index 9a274e09b99..f9f3078a922 100644 --- a/packages/rs-platform-version/src/version/drive_versions/v10.rs +++ b/packages/rs-platform-version/src/version/drive_versions/v10.rs @@ -1,24 +1,17 @@ use crate::version::drive_versions::drive_contract_method_versions::v5::DRIVE_CONTRACT_METHOD_VERSIONS_V5; -use crate::version::drive_versions::drive_contract_method_versions::{ - DriveContractFeePotMethodVersions, DriveContractMethodVersions, -}; use crate::version::drive_versions::drive_document_method_versions::v5::DRIVE_DOCUMENT_METHOD_VERSIONS_V5; use crate::version::drive_versions::drive_grove_method_versions::v2::DRIVE_GROVE_METHOD_VERSIONS_V2; use crate::version::drive_versions::drive_identity_method_versions::v2::DRIVE_IDENTITY_METHOD_VERSIONS_V2; use crate::version::drive_versions::drive_identity_method_versions::{ - DriveIdentityCostEstimationMethodVersions, DriveIdentityMethodVersions, - DriveIdentityUpdateMethodVersions, + DriveIdentityMethodVersions, DriveIdentityUpdateMethodVersions, }; use crate::version::drive_versions::drive_state_transition_method_versions::v5::DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V5; -use crate::version::drive_versions::drive_token_method_versions::v3::DRIVE_TOKEN_METHOD_VERSIONS_V3; use crate::version::drive_versions::drive_verify_method_versions::v4::DRIVE_VERIFY_METHOD_VERSIONS_V4; use crate::version::drive_versions::drive_vote_method_versions::v4::DRIVE_VOTE_METHOD_VERSIONS_V4; use crate::version::drive_versions::v9::DRIVE_VERSION_V9; use crate::version::drive_versions::{ - DriveBatchOperationsMethodVersion, DriveFeesMethodVersions, DriveInitializationMethodVersions, - DriveMethodVersions, DrivePlatformSystemMethodVersions, - DrivePrefundedSpecializedMethodVersions, DriveSystemEstimationCostsMethodVersions, - DriveVersion, + DriveBatchOperationsMethodVersion, DriveFeesMethodVersions, DriveMethodVersions, + DrivePlatformSystemMethodVersions, DriveSystemEstimationCostsMethodVersions, DriveVersion, }; use grovedb_version::version::v5::GROVE_V5; @@ -30,25 +23,6 @@ use grovedb_version::version::v5::GROVE_V5; /// nothing when its format version 1 bytes match the stored contract's, whatever format the /// stored one is in, as contracts are stored compiled from this version /// (`contract_storage_serialization_version` 2). -/// * **Escrow trees**: `create_initial_state_structure` 5 adds the two escrow trees of the -/// token marketplace: `[Tokens, TOKEN_ORDER_ESCROW_KEY]`, the BigSumTree of the tokens open -/// listings hold, and `[PreFundedSpecializedBalances, PREFUNDED_BALANCES_FOR_TOKEN_ORDERS]`, -/// the SumTree of the credits open offers hold. The upgrade path -/// (`Platform::transition_to_version_15`) inserts them through the same helper. -/// * **Token conservation**: `DRIVE_TOKEN_METHOD_VERSIONS_V3` bumps -/// `calculate_total_tokens_balance` to 2, which counts the escrowed listings on the balance -/// side; its escrow methods, `None` before, are active. -/// * **Escrow fee estimates**: the offers' escrow key sits a level below the other keys of the -/// prefunded specialized balances layer, so `estimated_cost_for_prefunded_specialized_balance_update` -/// 2 and `add_estimation_costs_for_contract_fee_pot_update` 1 keep a deeper description of that -/// layer another write of the batch registered, rather than lowering it to their keys' level; -/// likewise the listings' escrow key sits deeper in the Tokens layer than the balances key, and -/// `for_token_balances` 1 keeps a deeper description of the Tokens layer. The escrows also sit -/// deeper in the root tree than the identity balances and the token balances, so -/// `for_balances` 1, `for_token_balances` 1 and the voting balance estimation 2 keep a deeper -/// description of the root as well. Beyond the estimators, `apply_drive_operations` 2 merges -/// the descriptions of every write of a batch (below), so no other write of the batch (a -/// document, a nonce) lowers what the escrows describe, whichever is built first. /// * **Yes/no vote polls**: `DRIVE_VOTE_METHOD_VERSIONS_V4` bumps /// `insert.register_identity_vote` to 1, which registers a vote of either poll kind, and /// `cleanup.remove_all_votes_given_by_identities` to 1, which also removes the yes/no votes of @@ -128,23 +102,8 @@ use grovedb_version::version::v5::GROVE_V5; /// Everything else matches `DRIVE_VERSION_V9`. pub const DRIVE_VERSION_V10: DriveVersion = DriveVersion { methods: DriveMethodVersions { - initialization: DriveInitializationMethodVersions { - create_initial_state_structure: 5, // changed in v10: adds the token marketplace escrow trees - }, - token: DRIVE_TOKEN_METHOD_VERSIONS_V3, // changed in v10: calculate_total_tokens_balance 2 counts the token marketplace escrow; order_escrow active - contract: DriveContractMethodVersions { - fee_pots: DriveContractFeePotMethodVersions { - add_estimation_costs_for_contract_fee_pot_update: 1, // changed in v10: keeps a deeper prefunded balances layer description - ..DRIVE_CONTRACT_METHOD_VERSIONS_V5.fee_pots - }, - ..DRIVE_CONTRACT_METHOD_VERSIONS_V5 // changed in v10: apply_contract_with_serialization 1 (compiled contract storage) - }, + contract: DRIVE_CONTRACT_METHOD_VERSIONS_V5, // changed in v10: apply_contract_with_serialization 1 (compiled contract storage) identity: DriveIdentityMethodVersions { - cost_estimation: DriveIdentityCostEstimationMethodVersions { - for_balances: 1, // changed in v10: keeps a deeper root description - for_token_balances: 1, // changed in v10: keeps a deeper root and Tokens layer description - ..DRIVE_IDENTITY_METHOD_VERSIONS_V2.cost_estimation - }, update: DriveIdentityUpdateMethodVersions { add_new_keys_to_masternode_identity: 1, // changed in v10: a masternode key whose hash the identity already holds a reference for is added without a second one ..DRIVE_IDENTITY_METHOD_VERSIONS_V2.update @@ -156,10 +115,6 @@ pub const DRIVE_VERSION_V10: DriveVersion = DriveVersion { convert_drive_operations_to_grove_operations: 2, // changed: sibling history deletes share their pending lifecycle container (note 41) apply_drive_operations: 2, // changed in v10: a batch's estimate is resolved (note 14) }, - prefunded_specialized_balances: DrivePrefundedSpecializedMethodVersions { - estimated_cost_for_prefunded_specialized_balance_update: 2, // changed in v10: keeps a deeper prefunded balances layer description - ..DRIVE_VERSION_V9.methods.prefunded_specialized_balances - }, vote: DRIVE_VOTE_METHOD_VERSIONS_V4, // changed in v10: the yes/no poll kind verify: DRIVE_VERIFY_METHOD_VERSIONS_V4, // changed in v10: the yes/no and private document entries proof verifiers; a document that may be contested is verified state_transitions: DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V5, // changed in v10: a consume deletes what its lookup read diff --git a/packages/rs-platform-version/src/version/feature_initial_protocol_versions.rs b/packages/rs-platform-version/src/version/feature_initial_protocol_versions.rs index fd91614fd9a..ec1271420d6 100644 --- a/packages/rs-platform-version/src/version/feature_initial_protocol_versions.rs +++ b/packages/rs-platform-version/src/version/feature_initial_protocol_versions.rs @@ -30,11 +30,16 @@ pub const TOKEN_SHIELDED_POOL_INITIAL_PROTOCOL_VERSION: ProtocolVersion = 14; /// version 14 and registered at genesis from that version on; below it the contract does not /// exist and lookups must report it absent. pub const MODERATION_CHARTERS_CONTRACT_INITIAL_PROTOCOL_VERSION: ProtocolVersion = 14; -/// The token marketplace (a token whose `marketplaceRules.tradeMode` is `Tradeable`, whose holders -/// sell it to each other through escrowed listings and offers) activates with protocol version 15. -/// Below it a token configuration or a configuration update that makes a token tradeable is -/// refused without a fee, as software that predates the marketplace cannot decode one. -pub const TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION: ProtocolVersion = 15; +/// The token marketplace starts with protocol version 16, the version that brings the +/// transitions placing and filling its orders. From that version on its escrow trees and the +/// token market system contract are created at genesis; below it the contract does not exist and +/// lookups must report it absent. A tradeable token (`marketplaceRules.tradeMode` `Tradeable`, +/// whose holders sell it to each other through escrowed listings and offers) is admitted from +/// the same version: below it a token configuration or a configuration update that makes a token +/// tradeable is refused without a fee. That covers protocol version 15, whose software decodes +/// the mode: the stored form of the mode is not final until the order transitions ship, so no +/// contract may store it before then. +pub const TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION: ProtocolVersion = 16; /// Yes/no masternode vote polls activate with protocol version 15: a masternode vote naming one /// (a `YesNoVote`, or a resource vote on a `YesNoVotePoll`) is not active before it, every /// yes/no method slot is `None` in the tables before it, and the vote decisions trees are diff --git a/packages/rs-platform-version/src/version/mocks/mod.rs b/packages/rs-platform-version/src/version/mocks/mod.rs index c2d2c94a49f..afc341e5a68 100644 --- a/packages/rs-platform-version/src/version/mocks/mod.rs +++ b/packages/rs-platform-version/src/version/mocks/mod.rs @@ -1,5 +1,6 @@ pub mod v2_test; pub mod v3_test; pub mod v4_test; +pub mod v5_test; pub const TEST_PROTOCOL_VERSION_SHIFT_BYTES: u32 = 28; diff --git a/packages/rs-platform-version/src/version/mocks/v5_test.rs b/packages/rs-platform-version/src/version/mocks/v5_test.rs new file mode 100644 index 00000000000..8dc082b2208 --- /dev/null +++ b/packages/rs-platform-version/src/version/mocks/v5_test.rs @@ -0,0 +1,79 @@ +use crate::version::drive_versions::drive_contract_method_versions::{ + DriveContractFeePotMethodVersions, DriveContractMethodVersions, +}; +use crate::version::drive_versions::drive_identity_method_versions::{ + DriveIdentityCostEstimationMethodVersions, DriveIdentityMethodVersions, +}; +use crate::version::drive_versions::drive_token_method_versions::v3::DRIVE_TOKEN_METHOD_VERSIONS_V3; +use crate::version::drive_versions::v10::DRIVE_VERSION_V10; +use crate::version::drive_versions::{ + DriveInitializationMethodVersions, DriveMethodVersions, + DrivePrefundedSpecializedMethodVersions, DriveVersion, +}; +use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; +use crate::version::protocol_version::PlatformVersion; +use crate::version::system_data_contract_versions::v4::SYSTEM_DATA_CONTRACT_VERSIONS_V4; +use crate::version::system_data_contract_versions::SystemDataContractVersions; +use crate::version::v15::PLATFORM_V15; + +pub const TEST_PROTOCOL_VERSION_5: u32 = (1 << TEST_PROTOCOL_VERSION_SHIFT_BYTES) + 5; + +/// Protocol version 15 with the token marketplace, which starts with protocol version 16 +/// (`TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION`). That version has no tables yet, so the +/// marketplace's code is tested under this one. No network runs it. What it selects on top of +/// protocol version 15 is what protocol version 16's tables take over: +/// +/// - `create_initial_state_structure` 5 creates the two escrow trees at genesis: +/// `[Tokens, TOKEN_ORDER_ESCROW_KEY]`, a BigSumTree of one SumTree per token of the tokens its +/// open listings hold, and `[PreFundedSpecializedBalances, +/// PREFUNDED_BALANCES_FOR_TOKEN_ORDERS]`, a SumTree of the credits open offers hold. An +/// upgrade inserts them through the same helper (`Drive::insert_token_order_escrow_trees`). +/// - `DRIVE_TOKEN_METHOD_VERSIONS_V3`: `calculate_total_tokens_balance` 2 counts the escrowed +/// tokens on the balance side of the token conservation check, and the escrow methods +/// (`order_escrow`), `None` in every other table, are active. +/// - The offers' escrow key sits a level below the other keys of the prefunded specialized +/// balances layer, so `estimated_cost_for_prefunded_specialized_balance_update` 2 and +/// `add_estimation_costs_for_contract_fee_pot_update` 1 keep a deeper description of that +/// layer another write of the batch registered, rather than lowering it to their keys' level. +/// Likewise the listings' escrow key sits deeper in the Tokens layer than the balances key, +/// and both escrows sit deeper in the root tree than the identity and token balances, so +/// `for_balances` 1 and `for_token_balances` 1 keep a deeper description of those layers. +/// - The token market contract v1 (`token_market: 1`), whose `ask` and `bid` types hold the open +/// orders, registered at genesis and stored without storage flags by an upgrade. +pub const TEST_PLATFORM_V5: PlatformVersion = PlatformVersion { + protocol_version: TEST_PROTOCOL_VERSION_5, + drive: DriveVersion { + methods: DriveMethodVersions { + initialization: DriveInitializationMethodVersions { + create_initial_state_structure: 5, + }, + token: DRIVE_TOKEN_METHOD_VERSIONS_V3, + contract: DriveContractMethodVersions { + fee_pots: DriveContractFeePotMethodVersions { + add_estimation_costs_for_contract_fee_pot_update: 1, + ..DRIVE_VERSION_V10.methods.contract.fee_pots + }, + ..DRIVE_VERSION_V10.methods.contract + }, + identity: DriveIdentityMethodVersions { + cost_estimation: DriveIdentityCostEstimationMethodVersions { + for_balances: 1, + for_token_balances: 1, + ..DRIVE_VERSION_V10.methods.identity.cost_estimation + }, + ..DRIVE_VERSION_V10.methods.identity + }, + prefunded_specialized_balances: DrivePrefundedSpecializedMethodVersions { + estimated_cost_for_prefunded_specialized_balance_update: 2, + ..DRIVE_VERSION_V10.methods.prefunded_specialized_balances + }, + ..DRIVE_VERSION_V10.methods + }, + ..DRIVE_VERSION_V10 + }, + system_data_contracts: SystemDataContractVersions { + token_market: 1, + ..SYSTEM_DATA_CONTRACT_VERSIONS_V4 + }, + ..PLATFORM_V15 +}; diff --git a/packages/rs-platform-version/src/version/protocol_version.rs b/packages/rs-platform-version/src/version/protocol_version.rs index a2df2e6fc87..97353402b69 100644 --- a/packages/rs-platform-version/src/version/protocol_version.rs +++ b/packages/rs-platform-version/src/version/protocol_version.rs @@ -10,6 +10,8 @@ use crate::version::mocks::v3_test::TEST_PLATFORM_V3; #[cfg(feature = "mock-versions")] use crate::version::mocks::v4_test::TEST_PLATFORM_V4; #[cfg(feature = "mock-versions")] +use crate::version::mocks::v5_test::TEST_PLATFORM_V5; +#[cfg(feature = "mock-versions")] use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; use crate::version::system_data_contract_versions::SystemDataContractVersions; #[cfg(feature = "mock-versions")] @@ -71,8 +73,12 @@ pub const PLATFORM_VERSIONS: &[PlatformVersion] = &[ // We use OnceLock to be able to modify the version mocks pub static PLATFORM_TEST_VERSIONS: OnceLock> = OnceLock::new(); #[cfg(feature = "mock-versions")] -const DEFAULT_PLATFORM_TEST_VERSIONS: &[PlatformVersion] = - &[TEST_PLATFORM_V2, TEST_PLATFORM_V3, TEST_PLATFORM_V4]; +const DEFAULT_PLATFORM_TEST_VERSIONS: &[PlatformVersion] = &[ + TEST_PLATFORM_V2, + TEST_PLATFORM_V3, + TEST_PLATFORM_V4, + TEST_PLATFORM_V5, +]; pub const LATEST_PLATFORM_VERSION: &PlatformVersion = &PLATFORM_V15; @@ -88,7 +94,7 @@ impl PlatformVersion { // Init default set of test versions let versions = PLATFORM_TEST_VERSIONS - .get_or_init(|| vec![TEST_PLATFORM_V2, TEST_PLATFORM_V3, TEST_PLATFORM_V4]); + .get_or_init(|| Vec::from(DEFAULT_PLATFORM_TEST_VERSIONS)); return versions.get(test_version as usize - 2).ok_or( PlatformVersionError::UnknownVersionError(format!( @@ -116,7 +122,7 @@ impl PlatformVersion { // Init default set of test versions let versions = PLATFORM_TEST_VERSIONS - .get_or_init(|| vec![TEST_PLATFORM_V2, TEST_PLATFORM_V3, TEST_PLATFORM_V4]); + .get_or_init(|| Vec::from(DEFAULT_PLATFORM_TEST_VERSIONS)); return versions.get(test_version as usize - 2); } diff --git a/packages/rs-platform-version/src/version/system_data_contract_versions/mod.rs b/packages/rs-platform-version/src/version/system_data_contract_versions/mod.rs index 9423cdf4135..10717025443 100644 --- a/packages/rs-platform-version/src/version/system_data_contract_versions/mod.rs +++ b/packages/rs-platform-version/src/version/system_data_contract_versions/mod.rs @@ -18,7 +18,7 @@ pub struct SystemDataContractVersions { pub app_connect: FeatureVersion, pub moderation_charters: FeatureVersion, pub decision_proposals: FeatureVersion, - /// The token market contract (protocol version 15): the open listings and offers of the + /// The token market contract (protocol version 16): the open listings and offers of the /// token marketplace. 0 before it exists. pub token_market: FeatureVersion, } diff --git a/packages/rs-platform-version/src/version/system_data_contract_versions/v4.rs b/packages/rs-platform-version/src/version/system_data_contract_versions/v4.rs index d97bdccbae4..5eb9333890c 100644 --- a/packages/rs-platform-version/src/version/system_data_contract_versions/v4.rs +++ b/packages/rs-platform-version/src/version/system_data_contract_versions/v4.rs @@ -5,10 +5,9 @@ use crate::version::system_data_contract_versions::SystemDataContractVersions; // reveal and deletion of the writer's own preorder from an earlier block // (preorders unsalted, one per owner and name, the first valid one of a name // chosen), and the new domain's identity record held to its owner. Domains can -// no longer be deleted. The token market contract (token_market: 1), the open -// listings and offers of the token marketplace, is written to state by the -// upgrade to 15 and registered at genesis from 15 on. v3 (dpns: 2, no token -// market) remains for PROTOCOL_VERSION_14 chain replay. +// no longer be deleted. v3 (dpns: 2) remains for PROTOCOL_VERSION_14 chain +// replay. The token market contract does not exist yet (token_market: 0): the +// token marketplace starts with protocol version 16. // // The DashPay contract v3 states the checks of its two data triggers as schema // keywords: a contact request's `toUserId` refers to an identity other than the @@ -33,6 +32,6 @@ pub const SYSTEM_DATA_CONTRACT_VERSIONS_V4: SystemDataContractVersions = document_history: 1, app_connect: 1, moderation_charters: 1, - token_market: 1, + token_market: 0, decision_proposals: 1, }; diff --git a/packages/rs-platform-version/src/version/v15.rs b/packages/rs-platform-version/src/version/v15.rs index 6a0691f5044..4407188f234 100644 --- a/packages/rs-platform-version/src/version/v15.rs +++ b/packages/rs-platform-version/src/version/v15.rs @@ -115,8 +115,7 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// the parent's subdomain rule. DPNS needs no new data trigger bindings: /// its `domain` Replace and Delete rejects are never reached, as /// `documentsMutable` and `canBeDeleted` false refuse both first (10404). -/// (The bindings move to 3 for the token market contract, note 17, and -/// DashPay, note 24, not for DPNS.) +/// (The bindings move to 3 for DashPay, note 24, not for DPNS.) /// /// 4. **`countOf` and `sumOf` match byte array keys**: `CONTRACT_VERSIONS_V7` /// selects `parse_property_constraints` 1, whose grammar binds a filter key @@ -128,13 +127,17 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// consensus reads the total as it reads any other. `parse_property_constraints` /// 0 (protocol version 14) reads such a binding as an integer and refuses it. /// -/// 5. **Tradeable tokens**: `TokenTradeMode::Tradeable` -/// (`TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION`) lets a token's holders list it and make -/// offers for it. Before this version a contract whose token is tradeable, and a -/// `TokenConfigUpdate` that makes a token tradeable, are refused unpaid as not active -/// (`StateTransitionNotActiveError`, 10603), the refusal older software gives by failing to -/// decode the mode. A tradeable token must be transferable (`NonTransferableTokenTradeableError`, -/// 10281): contract create and update refuse it unpaid, and the batch `advanced_structure` 2 +/// 5. **Tradeable tokens, decoded and not yet admitted**: `TokenTradeMode::Tradeable` lets a +/// token's holders list it and make offers for it. This version decodes the mode and admits +/// no token that has it: a contract whose token is tradeable, and a `TokenConfigUpdate` that +/// makes a token tradeable, are refused unpaid as not active (`StateTransitionNotActiveError`, +/// 10603) below `TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION` (16), the refusal +/// software older than this version gives by failing to decode the mode. The transitions +/// that place and fill orders come with protocol version 16, and the stored form of the mode +/// is not final before them, so no contract stores it under this version. The rules a +/// tradeable token is held to are in place for the version that admits one: it must be +/// transferable (`NonTransferableTokenTradeableError`, 10281), which contract create and +/// update refuse unpaid, and the batch `advanced_structure` 2 /// (`DRIVE_ABCI_VALIDATION_VERSIONS_V11`) checks the trade mode an update proposes against the /// contract the action carries, charged, so check_tx refuses the update too. Protocol v14 and /// earlier keep the batch `advanced_structure` 1. @@ -430,26 +433,19 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// the complete evidence policy at activation, including a zero byte budget. /// Protocol v14 and earlier retain their existing evidence limits. /// -/// 17. **The token marketplace's state**: `DRIVE_VERSION_V10` creates the two escrow trees at -/// genesis (`create_initial_state_structure` 5) and `transition_to_version_15` inserts them -/// through the same helper: `[Tokens, TOKEN_ORDER_ESCROW_KEY]`, a BigSumTree of one SumTree -/// per token of the tokens its open listings hold, and `[PreFundedSpecializedBalances, -/// PREFUNDED_BALANCES_FOR_TOKEN_ORDERS]`, a SumTree of the credits open offers hold. Its -/// `calculate_total_tokens_balance` 2 counts the escrowed tokens on the balance side of the -/// token conservation check; the credit check already counts every prefunded specialized -/// balance. The escrow methods (`order_escrow`) are `None` in every earlier table. The offers' -/// escrow key sits two levels into the prefunded specialized balances layer, below the keys -/// the voting balance and contract fee pot estimations describe, so their v2 and v1 keep a -/// deeper description of that layer another write of the batch registered, and -/// `apply_drive_operations` 2 (note 14) keeps it whatever the order of the batch's writes. -/// `SYSTEM_DATA_CONTRACT_VERSIONS_V4` selects the token market contract v1, whose -/// `ask` and `bid` types hold the open orders, each with the token's decimals when it was -/// placed, which prices its fills and keys its `book` and `depth` index entries -/// (`tokenId`, `decimals`, `price`) so prices of different scales never mix: registered at -/// genesis from this version and -/// stored without storage flags by `transition_to_version_15`. Users cannot write them: -/// `creationRestrictionMode` 2 refuses a create, and the data trigger `bindings` 3 -/// (`DRIVE_ABCI_VALIDATION_VERSIONS_V11`) refuse a replace or a delete. +/// 17. **No token marketplace yet**: the token marketplace starts with protocol version 16 +/// (`TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION`), and nothing of it is part of this version. +/// Its escrow trees are not created (`create_initial_state_structure` stays at 4 and +/// `transition_to_version_15` inserts none), the token conservation check does not read an +/// escrow (`calculate_total_tokens_balance` stays at 1), the escrow methods (`order_escrow`) +/// are `None`, the token market contract does not exist (`token_market: 0`, registered +/// neither at genesis nor by the upgrade, and absent from the system contract cache), and +/// no tradeable token is admitted (note 5). The code of all of it is present and selected by +/// no protocol version's tables; the test version `TEST_PLATFORM_V5` selects it on top of +/// this version's tables so it stays tested. The data trigger `bindings` 3 +/// (`DRIVE_ABCI_VALIDATION_VERSIONS_V11`), which this version selects for DashPay (note +/// 24), also list the rejects of a replace or a delete of a token market order: they match +/// the token market contract's id only, so nothing reaches them before that contract exists. /// /// 18. **Core fork activations recorded in state**: `update_core_info` 1 /// (`DRIVE_ABCI_METHOD_VERSIONS_V11`) asks Core, in a block that moves the chain locked @@ -565,7 +561,7 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// trigger. Every property is stored as v2 stores it (DashPay keeps sized integer /// types off, so the key indexes stay i64), so documents written under v1 and v2 /// read back unchanged. The data trigger `bindings` 3 (`DRIVE_ABCI_VALIDATION_VERSIONS_V11`, -/// which also add note 17's order rejects) drop the DashPay contact request create and +/// which also list the token market order rejects, note 17) drop the DashPay contact request create and /// profile create and replace triggers, which made the identity, writer and type byte /// checks and refused with `DataTriggerConditionError` (40500). Protocol v14 keeps /// DashPay v2 and bindings 2, and earlier versions the contract and bindings they had. @@ -931,11 +927,11 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// results. pub const PLATFORM_V15: PlatformVersion = PlatformVersion { protocol_version: PROTOCOL_VERSION_15, - drive: DRIVE_VERSION_V10, // changed: calculate_fee 1 prices a refund at the storing epoch's rate (note 27); apply_contract_with_serialization 1 writes nothing for a contract whose format version 1 bytes match the stored one's (note 8); vote method versions v4: register_identity_vote 1 registers a yes/no vote, remove_all_votes_given_by_identities 1 also removes the yes/no votes of a masternode that left the list, every yes_no method and remove_vote_poll_end_date_query_operations Some(0) make yes/no polls active, add_vote_poll_end_date_query_operations 1 adds only the entry when the batch already queues the end date's tree with other storage flags, and verify methods v4 make the yes/no proof verifiers active (note 10) and verify_private_document_entries Some(0) a page of a private type's store (note 13); state transition method versions v5: document_create_transition 1 deletes a consumed document from what its lookup read (note 11); document method versions v5: insert_empty_private_document_store_operation Some(0) creates a private document type's store, and fetch_private_document_entries and prove_private_document_entries Some(0) read and prove a page of it (note 13); apply_drive_operations 2 resolves a batch's estimate, remove_reference_for_index_level_for_contract_operations 2, add_reference_for_index_level_for_contract_operations 1, stateless_delete_of_non_tree_for_costs 1 and for_total_system_credits_update 1 describe their layers as they are (note 14); create_initial_state_structure 5 adds the token marketplace escrow trees; calculate_total_tokens_balance 2 counts escrowed tokens; the escrow primitives; the identity balance, token balance, prefunded specialized balance and contract fee pot estimations (for_balances 1, for_token_balances 1, estimated_cost_for_prefunded_specialized_balance_update 2, add_estimation_costs_for_contract_fee_pot_update 1) keep a deeper layer description (note 17); fetch_core_fork_activation_height and store_core_fork_activation_height Some(0) keep the Core fork activations (note 18); document method versions v5: append_private_document_entries_operations Some(0) appends a private document create's entries (note 25); grove_version GROVE_V5 (note 26); verify methods v4: verify_proof_keep_serialized 1 verifies a document that may be contested (note 29); document method versions v5: single_document_path_query 1 selects the latest retained revision at or before a block time, and verify_proof_keep_serialized 1 verifies it (note 31); retained-history writers, readers, estimates and verifiers select the per-type revision layout (note 35); add_new_keys_to_masternode_identity 1 adds a masternode key whose hash the identity already holds a reference for (note 32); document method versions v5: insert.add_document_for_contract_operations 2, delete.delete_document_for_contract_operations 1, delete.remove_document_from_primary_storage 1 and its estimate 1, query.fetch_document_lifecycle Some(0), and the erase/lifecycle estimate and erase_refund_recipient_cost selectors Some(0); batch_operations.convert_drive_operations_to_grove_operations 2; state transition method versions v5: document_delete_transition 1 and document_erase_transition Some(0); verify methods v4: single_document.verify_proof 1 extend retained history (note 41); document method versions v5: add_indices_for_top_index_level_for_contract_operations 3 writes no entry in an expired time range bucket (note 36) + drive: DRIVE_VERSION_V10, // changed: calculate_fee 1 prices a refund at the storing epoch's rate (note 27); apply_contract_with_serialization 1 writes nothing for a contract whose format version 1 bytes match the stored one's (note 8); vote method versions v4: register_identity_vote 1 registers a yes/no vote, remove_all_votes_given_by_identities 1 also removes the yes/no votes of a masternode that left the list, every yes_no method and remove_vote_poll_end_date_query_operations Some(0) make yes/no polls active, add_vote_poll_end_date_query_operations 1 adds only the entry when the batch already queues the end date's tree with other storage flags, and verify methods v4 make the yes/no proof verifiers active (note 10) and verify_private_document_entries Some(0) a page of a private type's store (note 13); state transition method versions v5: document_create_transition 1 deletes a consumed document from what its lookup read (note 11); document method versions v5: insert_empty_private_document_store_operation Some(0) creates a private document type's store, and fetch_private_document_entries and prove_private_document_entries Some(0) read and prove a page of it (note 13); apply_drive_operations 2 resolves a batch's estimate, remove_reference_for_index_level_for_contract_operations 2, add_reference_for_index_level_for_contract_operations 1, stateless_delete_of_non_tree_for_costs 1 and for_total_system_credits_update 1 describe their layers as they are (note 14); fetch_core_fork_activation_height and store_core_fork_activation_height Some(0) keep the Core fork activations (note 18); document method versions v5: append_private_document_entries_operations Some(0) appends a private document create's entries (note 25); grove_version GROVE_V5 (note 26); verify methods v4: verify_proof_keep_serialized 1 verifies a document that may be contested (note 29); document method versions v5: single_document_path_query 1 selects the latest retained revision at or before a block time, and verify_proof_keep_serialized 1 verifies it (note 31); retained-history writers, readers, estimates and verifiers select the per-type revision layout (note 35); add_new_keys_to_masternode_identity 1 adds a masternode key whose hash the identity already holds a reference for (note 32); document method versions v5: insert.add_document_for_contract_operations 2, delete.delete_document_for_contract_operations 1, delete.remove_document_from_primary_storage 1 and its estimate 1, query.fetch_document_lifecycle Some(0), and the erase/lifecycle estimate and erase_refund_recipient_cost selectors Some(0); batch_operations.convert_drive_operations_to_grove_operations 2; state transition method versions v5: document_delete_transition 1 and document_erase_transition Some(0); verify methods v4: single_document.verify_proof 1 extend retained history (note 41); document method versions v5: add_indices_for_top_index_level_for_contract_operations 3 writes no entry in an expired time range bucket (note 36) drive_abci: DriveAbciVersion { structs: DRIVE_ABCI_STRUCTURE_VERSIONS_V2, methods: DRIVE_ABCI_METHOD_VERSIONS_V11, // changed: perform_events_on_first_block_of_protocol_change 3 migrates retained history after operator-payout reconciliation and other activation work (note 35); the yes/no poll's tally, record, clean-up and finish hook are Some(0) (note 10); verify_chain_lock_locally 1 rejects a chain lock locally only when Platform holds the quorums active at its signing height, and verify_chain_lock_through_core 1 has Core's verifychainlock check the others before submitchainlock; consensus_params_update 2 installs the full evidence policy (note 16); update_core_info 1 records the chain locked height at which Core's V24 is first seen active (note 18); build_untied_withdrawal_transactions_from_documents 1 emits asset unlock payload version 2 once V24 is recorded as active (note 20); update_voter_identity 1 re-enables the voter key of the address a masternode returns to (note 22); update_masternode_list 2 and update_operator_identity 1 make operator payouts and the operator identities' TRANSFER keys follow Core's diffs (note 32) - validation_and_processing: DRIVE_ABCI_VALIDATION_VERSIONS_V11, // changed: identity update advanced_structure 1 refuses unpaid an identity update whose added key's proof of possession does not verify (note 2); create_domain_data_trigger 2 (note 3); contract update transform_into_action 1 holds an update to the compiled size cap in check_tx (note 8); batch advanced_structure 2 refuses a token config update on a read-only contract (note 9); masternode vote transform_into_action 1 looks up a masternode's previous answer on a yes/no poll (note 10); document_reference_validation 1 keeps what a consumed commitment's lookup read (note 11); document create structure_validation 2 holds a decision proposal to its fund, rule and end date (note 12); data trigger bindings 3 refuse a replace or a delete of a token market order (note 17) and drop the DashPay bindings (note 24); document create state_validation 3 keeps a create outside a contest off the values of a live one its index values do not decide (note 19); identity create basic_structure 1 checks the identity id before the asset lock proof and advanced_structure 2 no longer does (note 23); contract user moderation transform_into_action 1 writes a moderator's field change in the name of whoever holds the document's storage (note 28); validate_state_transition_identity_signed 2 refuses a contract create or update signed by a key with a budget or an expiry (note 34); batch_state_transition.document_delete_transition_structure_validation 2 and document_erase_transition_structure_validation/document_erase_transition_state_validation Some(0) admit the lifecycle (note 41) + validation_and_processing: DRIVE_ABCI_VALIDATION_VERSIONS_V11, // changed: identity update advanced_structure 1 refuses unpaid an identity update whose added key's proof of possession does not verify (note 2); create_domain_data_trigger 2 (note 3); contract update transform_into_action 1 holds an update to the compiled size cap in check_tx (note 8); batch advanced_structure 2 refuses a token config update on a read-only contract (note 9); masternode vote transform_into_action 1 looks up a masternode's previous answer on a yes/no poll (note 10); document_reference_validation 1 keeps what a consumed commitment's lookup read (note 11); document create structure_validation 2 holds a decision proposal to its fund, rule and end date (note 12); data trigger bindings 3 drop the DashPay bindings (note 24); document create state_validation 3 keeps a create outside a contest off the values of a live one its index values do not decide (note 19); identity create basic_structure 1 checks the identity id before the asset lock proof and advanced_structure 2 no longer does (note 23); contract user moderation transform_into_action 1 writes a moderator's field change in the name of whoever holds the document's storage (note 28); validate_state_transition_identity_signed 2 refuses a contract create or update signed by a key with a budget or an expiry (note 34); batch_state_transition.document_delete_transition_structure_validation 2 and document_erase_transition_structure_validation/document_erase_transition_state_validation Some(0) admit the lifecycle (note 41) withdrawal_constants: DRIVE_ABCI_WITHDRAWAL_CONSTANTS_V3, query: DRIVE_ABCI_QUERY_VERSIONS_V3, // changed: getDocumentHistory accepts V1 only checkpoints: DRIVE_ABCI_CHECKPOINT_PARAMETERS_V1, @@ -956,7 +952,7 @@ pub const PLATFORM_V15: PlatformVersion = PlatformVersion { methods: DPP_METHOD_VERSIONS_V3, factory_versions: DPP_FACTORY_VERSIONS_V1, }, - system_data_contracts: SYSTEM_DATA_CONTRACT_VERSIONS_V4, // changed: DPNS v3 checks a name's create with keywords (note 3); the decision proposals contract (note 12); the token market contract is selected (note 17); DashPay v3 states what its data triggers checked (note 24) + system_data_contracts: SYSTEM_DATA_CONTRACT_VERSIONS_V4, // changed: DPNS v3 checks a name's create with keywords (note 3); the decision proposals contract (note 12); DashPay v3 states what its data triggers checked (note 24) fee_version: FEE_VERSION4, // changed: decision proposals prefund their poll with 0.5 Dash (note 12); a private document entry pays its storage and 10,000,000 credits (note 25); a multiple choice proposal pays a 0.2 Dash processing fee on create (note 40) system_limits: SYSTEM_LIMITS_V5, // changed: max_compiled_contract_size caps a contract stored compiled at 1 MiB (note 8); max_private_document_entry_size caps a private type's entries at 4096 bytes, and the private document store limits size its store (note 13); max_private_document_entries_per_transition caps a private document create at 16 entries (note 25); max_document_revisions_erased_per_transition caps an erase at 100 revisions (note 41) consensus: ConsensusVersions { diff --git a/packages/rs-sdk-trusted-context-provider/Cargo.toml b/packages/rs-sdk-trusted-context-provider/Cargo.toml index b8f08291cfb..28636d7ef8f 100644 --- a/packages/rs-sdk-trusted-context-provider/Cargo.toml +++ b/packages/rs-sdk-trusted-context-provider/Cargo.toml @@ -108,6 +108,13 @@ reqwest = { version = "0.12", features = ["json"] } [target.'cfg(target_os = "android")'.dependencies] reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls-webpki-roots"] } +[dev-dependencies] +# The test platform versions: the token marketplace is tested under one until protocol version +# 16 has tables. +platform-version = { path = "../rs-platform-version", features = [ + "mock-versions", +] } + [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] tokio = { version = "1.40", features = ["macros", "rt-multi-thread"] } # The `refresh_checkpoints` example reads Platform's Core height from proved diff --git a/packages/rs-sdk-trusted-context-provider/src/local.rs b/packages/rs-sdk-trusted-context-provider/src/local.rs index 53fdfab72d6..65ced3be8be 100644 --- a/packages/rs-sdk-trusted-context-provider/src/local.rs +++ b/packages/rs-sdk-trusted-context-provider/src/local.rs @@ -193,6 +193,12 @@ impl ContractSource for LocalContextResolver { #[cfg(all(test, any(feature = "dpns-contract", feature = "all-system-contracts")))] mod tests { + /// The token marketplace starts with protocol version 16, which has no tables yet: the test + /// version that selects it stands in for it. + fn token_marketplace_version() -> &'static dpp::version::PlatformVersion { + &dpp::version::mocks::v5_test::TEST_PLATFORM_V5 + } + use std::sync::Arc; use dash_context_provider::ContractSource; @@ -255,26 +261,26 @@ mod tests { assert_eq!(resolver.token_configuration(&token_id), Some(config)); } - /// The token market contract does not exist before protocol version 15. + /// The token market contract does not exist before protocol version 16. /// The SPV and adaptive providers read contracts only from the resolver, /// so it must refuse a contract preloaded under that id there itself. #[test] - fn should_refuse_a_preloaded_token_market_contract_before_protocol_15() { + fn should_refuse_a_preloaded_token_market_contract_before_protocol_16() { let resolver = LocalContextResolver::new(); let mut contract = app_contract(); let id = SystemDataContract::TokenMarket.id(); contract.set_id(id); resolver.add_known_data_contract(Arc::new(contract)); - let pv14 = PlatformVersion::get(14).expect("protocol version 14"); let pv15 = PlatformVersion::get(15).expect("protocol version 15"); + let marketplace_version = token_marketplace_version(); - assert!(resolver.data_contract(&id, pv14).unwrap().is_none()); - assert!(ContractSource::get_data_contract(&resolver, &id, pv14) + assert!(resolver.data_contract(&id, pv15).unwrap().is_none()); + assert!(ContractSource::get_data_contract(&resolver, &id, pv15) .unwrap() .is_none()); assert_eq!( resolver - .data_contract(&id, pv15) + .data_contract(&id, marketplace_version) .unwrap() .map(|contract| contract.id()), Some(id) diff --git a/packages/rs-sdk-trusted-context-provider/src/provider.rs b/packages/rs-sdk-trusted-context-provider/src/provider.rs index 4b4104f555d..1c87cc692e0 100644 --- a/packages/rs-sdk-trusted-context-provider/src/provider.rs +++ b/packages/rs-sdk-trusted-context-provider/src/provider.rs @@ -1047,6 +1047,12 @@ impl ContextProvider for TrustedHttpContextProvider { #[cfg(all(test, not(target_arch = "wasm32")))] pub(crate) mod tests { + /// The token marketplace starts with protocol version 16, which has no tables yet: the test + /// version that selects it stands in for it. + fn token_marketplace_version() -> &'static dpp::version::PlatformVersion { + &dpp::version::mocks::v5_test::TEST_PLATFORM_V5 + } + use super::*; use crate::quorum_refresh::MIN_GAP; use dash_context_provider::ContextProviderMode; @@ -2510,7 +2516,7 @@ pub(crate) mod tests { /// The token market system contract is served only from its activation version on. #[cfg(any(feature = "token-market-contract", feature = "all-system-contracts"))] #[test] - fn should_serve_token_market_only_from_protocol_15() { + fn should_serve_token_market_only_from_protocol_16() { use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::version::PlatformVersion; @@ -2524,38 +2530,38 @@ pub(crate) mod tests { let id = SystemDataContract::TokenMarket.id(); assert!(provider - .get_data_contract(&id, PlatformVersion::get(14).unwrap()) + .get_data_contract(&id, PlatformVersion::get(15).unwrap()) .expect("a pre-activation lookup must not error") .is_none()); let contract = provider - .get_data_contract(&id, PlatformVersion::get(15).unwrap()) - .expect("the lookup must succeed at protocol version 15") - .expect("the token market contract must be served at protocol version 15"); + .get_data_contract(&id, token_marketplace_version()) + .expect("the lookup must succeed at protocol version 16") + .expect("the token market contract must be served at protocol version 16"); assert_eq!(contract.id(), id); // A copy preloaded into the known contracts is not served before activation either. provider.add_known_contract((*contract).clone()); assert!(provider - .get_data_contract(&id, PlatformVersion::get(14).unwrap()) + .get_data_contract(&id, PlatformVersion::get(15).unwrap()) .expect("a pre-activation lookup must not error") .is_none()); assert!(provider - .get_data_contract(&id, PlatformVersion::get(15).unwrap()) - .expect("the lookup must succeed at protocol version 15") + .get_data_contract(&id, token_marketplace_version()) + .expect("the lookup must succeed at protocol version 16") .is_some()); } /// A build without the token market feature still refuses a contract preloaded under the - /// token market's id before protocol version 15, and serves it from 15. + /// token market's id before protocol version 16, and serves it from 16. #[test] - fn should_refuse_a_preloaded_token_market_id_before_protocol_15_in_any_build() { + fn should_refuse_a_preloaded_token_market_id_before_protocol_16_in_any_build() { use dpp::data_contract::config::DataContractConfig; use dpp::data_contract::v1::DataContractV1; use dpp::version::PlatformVersion; use std::collections::BTreeMap; - let platform_version = PlatformVersion::latest(); + let platform_version = token_marketplace_version(); let id = SystemDataContract::TokenMarket.id(); let contract = DataContract::V1(DataContractV1 { id, @@ -2586,12 +2592,12 @@ pub(crate) mod tests { .with_known_contracts(vec![contract]); assert!(provider - .get_data_contract(&id, PlatformVersion::get(14).unwrap()) + .get_data_contract(&id, PlatformVersion::get(15).unwrap()) .expect("a pre-activation lookup must not error") .is_none()); assert!(provider .get_data_contract(&id, platform_version) - .expect("the lookup must succeed from protocol version 15") + .expect("the lookup must succeed from protocol version 16") .is_some()); } @@ -2653,11 +2659,11 @@ pub(crate) mod tests { } } - /// The token market contract does not exist before protocol version 15, + /// The token market contract does not exist before protocol version 16, /// so no source may serve one under its id there: a fallback provider /// asked after the local contracts must not be able to supply it either. #[test] - fn should_refuse_a_token_market_contract_from_the_fallback_before_protocol_15() { + fn should_refuse_a_token_market_contract_from_the_fallback_before_protocol_16() { use dpp::version::PlatformVersion; // A numeric loopback URL avoids DNS; contract lookups make no HTTP requests. @@ -2668,12 +2674,12 @@ pub(crate) mod tests { ) .unwrap() .with_fallback_provider(ServesEveryContract); - let pv14 = PlatformVersion::get(14).unwrap(); + let pv15 = PlatformVersion::get(15).unwrap(); let app_contract = Identifier::new([0x5a; 32]); assert!( provider - .get_data_contract(&app_contract, pv14) + .get_data_contract(&app_contract, pv15) .expect("the fallback answers") .is_some(), "the fallback must be asked for a contract the provider does not hold" @@ -2681,12 +2687,12 @@ pub(crate) mod tests { let token_market = SystemDataContract::TokenMarket.id(); assert!(provider - .get_data_contract(&token_market, pv14) + .get_data_contract(&token_market, pv15) .expect("a pre-activation lookup must not error") .is_none()); assert!(provider - .get_data_contract(&token_market, PlatformVersion::get(15).unwrap()) - .expect("the lookup must succeed from protocol version 15") + .get_data_contract(&token_market, token_marketplace_version()) + .expect("the lookup must succeed from protocol version 16") .is_some()); } diff --git a/packages/rs-sdk-trusted-context-provider/src/system_contracts.rs b/packages/rs-sdk-trusted-context-provider/src/system_contracts.rs index b76e02d57f6..6714e2c73a0 100644 --- a/packages/rs-sdk-trusted-context-provider/src/system_contracts.rs +++ b/packages/rs-sdk-trusted-context-provider/src/system_contracts.rs @@ -36,7 +36,7 @@ use dpp::version::PlatformVersion; use std::sync::Arc; /// Whether `id` names a system data contract that does not exist yet at -/// `platform_version`: the token market contract before protocol version 15. A +/// `platform_version`: the token market contract before protocol version 16. A /// provider serves no contract under such an id, neither one preloaded into its /// known contracts nor one its build loads, whichever contract features it has, so /// each provider asks this before its known contracts. @@ -233,7 +233,7 @@ pub(crate) fn system_data_contract( } #[cfg(any(feature = "token-market-contract", feature = "all-system-contracts"))] - // Below protocol version 15 the token market contract is absent + // Below protocol version 16 the token market contract is absent // (`is_inactive_system_contract`). if *id == SystemDataContract::TokenMarket.id() && !is_inactive_system_contract(id, platform_version) @@ -254,36 +254,43 @@ pub(crate) fn system_data_contract( #[cfg(test)] mod tests { + /// The token marketplace starts with protocol version 16, which has no tables yet: the test + /// version that selects it stands in for it. + fn token_marketplace_version() -> &'static dpp::version::PlatformVersion { + &dpp::version::mocks::v5_test::TEST_PLATFORM_V5 + } + use super::*; - /// The shared loader serves the token market contract only from protocol version 15, + /// The shared loader serves the token market contract only from protocol version 16, /// whatever its caller checked: before, none, without an error. #[cfg(any(feature = "token-market-contract", feature = "all-system-contracts"))] #[test] - fn should_load_no_token_market_contract_before_protocol_15() { + fn should_load_no_token_market_contract_before_protocol_16() { let id = data_contracts::SystemDataContract::TokenMarket.id(); assert!( - system_data_contract(&id, PlatformVersion::get(14).expect("protocol version 14")) + system_data_contract(&id, PlatformVersion::get(15).expect("protocol version 15")) .expect("a pre-activation load does not error") .is_none() ); - assert!( - system_data_contract(&id, PlatformVersion::get(15).expect("protocol version 15")) - .expect("the load succeeds at protocol version 15") - .is_some() - ); + assert!(system_data_contract(&id, token_marketplace_version()) + .expect("the load succeeds at protocol version 16") + .is_some()); } #[test] - fn should_mark_only_the_token_market_inactive_before_protocol_15() { - let pv14 = PlatformVersion::get(14).expect("protocol version 14"); + fn should_mark_only_the_token_market_inactive_before_protocol_16() { let pv15 = PlatformVersion::get(15).expect("protocol version 15"); + let marketplace_version = token_marketplace_version(); let token_market = data_contracts::SystemDataContract::TokenMarket.id(); - assert!(is_inactive_system_contract(&token_market, pv14)); - assert!(!is_inactive_system_contract(&token_market, pv15)); + assert!(is_inactive_system_contract(&token_market, pv15)); + assert!(!is_inactive_system_contract( + &token_market, + marketplace_version + )); assert!(!is_inactive_system_contract( &data_contracts::SystemDataContract::DPNS.id(), - pv14 + pv15 )); } } diff --git a/packages/rs-sdk-trusted-context-provider/src/verified_provider.rs b/packages/rs-sdk-trusted-context-provider/src/verified_provider.rs index e1fe972f6ec..1605c2da65a 100644 --- a/packages/rs-sdk-trusted-context-provider/src/verified_provider.rs +++ b/packages/rs-sdk-trusted-context-provider/src/verified_provider.rs @@ -772,6 +772,12 @@ impl ContextProvider for VerifiedHttpContextProvider { #[cfg(all(test, not(target_arch = "wasm32")))] mod tests { + /// The token marketplace starts with protocol version 16, which has no tables yet: the test + /// version that selects it stands in for it. + fn token_marketplace_version() -> &'static dpp::version::PlatformVersion { + &dpp::version::mocks::v5_test::TEST_PLATFORM_V5 + } + use super::*; use crate::proof_fetches::{DKG_INTERVAL_BLOCKS, MAX_RECENT_STATES}; use dash_core_proof::bootstrap; @@ -3088,41 +3094,41 @@ mod tests { }) } - /// The token market contract does not exist before protocol version 15: no contract is + /// The token market contract does not exist before protocol version 16: no contract is /// served under its id then, not even one preloaded into the known contracts, whichever /// contract features the build has. From 15 the preloaded one is. #[test] - fn should_refuse_a_preloaded_token_market_id_before_protocol_15_in_any_build() { + fn should_refuse_a_preloaded_token_market_id_before_protocol_16_in_any_build() { let provider = with_sources(&["https://127.0.0.1"]).expect("a provider"); let id = data_contracts::SystemDataContract::TokenMarket.id(); provider.add_known_contract(empty_contract(id)); assert!(provider - .get_data_contract(&id, PlatformVersion::get(14).expect("protocol version 14")) + .get_data_contract(&id, PlatformVersion::get(15).expect("protocol version 15")) .expect("a pre-activation lookup does not error") .is_none()); assert!(provider - .get_data_contract(&id, PlatformVersion::get(15).expect("protocol version 15")) - .expect("the lookup succeeds at protocol version 15") + .get_data_contract(&id, token_marketplace_version()) + .expect("the lookup succeeds at protocol version 16") .is_some()); } /// A build loading the token market contract, with none preloaded, serves none before - /// protocol version 15, without an error, and the system contract from 15. + /// protocol version 16, without an error, and the system contract from 16. #[cfg(any(feature = "token-market-contract", feature = "all-system-contracts"))] #[test] - fn should_load_the_token_market_contract_only_from_protocol_15() { + fn should_load_the_token_market_contract_only_from_protocol_16() { let provider = with_sources(&["https://127.0.0.1"]).expect("a provider"); let id = data_contracts::SystemDataContract::TokenMarket.id(); assert!(provider - .get_data_contract(&id, PlatformVersion::get(14).expect("protocol version 14")) + .get_data_contract(&id, PlatformVersion::get(15).expect("protocol version 15")) .expect("a pre-activation lookup does not error") .is_none()); let contract = provider - .get_data_contract(&id, PlatformVersion::get(15).expect("protocol version 15")) - .expect("the lookup succeeds at protocol version 15") - .expect("the token market contract is served at protocol version 15"); + .get_data_contract(&id, token_marketplace_version()) + .expect("the lookup succeeds at protocol version 16") + .expect("the token market contract is served at protocol version 16"); assert_eq!(contract.id(), id); } } diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swift b/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swift index cd22aefcdfe..1961a253a44 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swift @@ -242,7 +242,7 @@ public enum TokenDistributionRecipient: String, CaseIterable, Codable, Sendable // MARK: - Token Trade Mode /// Trading modes for tokens. Raw values match rs-dpp's `TokenTradeMode` in -/// contract JSON. `tradeable` is valid from protocol version 15. +/// contract JSON. `tradeable` is valid from protocol version 16. /// /// Stored on `PersistentToken` as its raw string, so a new case leaves the /// entity hash unchanged. The frozen schema copies keep only `notTradeable`. diff --git a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DataContractParserTradeModeTests.swift b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DataContractParserTradeModeTests.swift index cfa9bc730e8..cec4a95c0a8 100644 --- a/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DataContractParserTradeModeTests.swift +++ b/packages/swift-sdk/SwiftTests/SwiftDashSDKTests/DataContractParserTradeModeTests.swift @@ -15,7 +15,7 @@ import SwiftData /// } /// ``` /// -/// "Tradeable" is valid from protocol version 15. The Swift enum used to +/// "Tradeable" is valid from protocol version 16. The Swift enum used to /// have only `notTradeable`, so the parser's `TokenTradeMode(rawValue:)` /// returned nil for it and the token kept the `notTradeable` default, which /// made `PersistentToken.isTradeable` report false for a tradeable token. diff --git a/packages/token-market-contract/Cargo.toml b/packages/token-market-contract/Cargo.toml index c338081d99c..13702d04936 100644 --- a/packages/token-market-contract/Cargo.toml +++ b/packages/token-market-contract/Cargo.toml @@ -13,3 +13,8 @@ serde_json = { version = "1.0" } platform-value = { path = "../rs-platform-value" } [dev-dependencies] base58 = "0.2.0" +# The test platform versions: the token marketplace is tested under one until protocol version +# 16 has tables. +platform-version = { path = "../rs-platform-version", features = [ + "mock-versions", +] } diff --git a/packages/token-market-contract/README.md b/packages/token-market-contract/README.md index 425fbc3fc50..b1a78e6f07e 100644 --- a/packages/token-market-contract/README.md +++ b/packages/token-market-contract/README.md @@ -2,10 +2,11 @@ The token market system contract holds the open orders of the token marketplace: the listings (`ask`) holders make to sell a tradeable token at a -price, and the offers (`bid`) anyone makes to buy one. It activates at protocol -version 15, registered at genesis by chains born at 15 and inserted by the -upgrade to 15, and has the same ID on every network: -`AE6yYq65VdfGCg2MSyV9vV7cWGiFWjbwBuy7THesDh4e`. +price, and the offers (`bid`) anyone makes to buy one. It activates with the +token marketplace at protocol version 16, registered at genesis by chains born +at 16 and inserted by the upgrade to 16, and has the same ID on every network: +`AE6yYq65VdfGCg2MSyV9vV7cWGiFWjbwBuy7THesDh4e`. It does not exist under +protocol version 15 or earlier. Only the token marketplace transitions write these documents. Users cannot create them (`creationRestrictionMode` 2), and a replace or delete sent as a diff --git a/packages/token-market-contract/src/lib.rs b/packages/token-market-contract/src/lib.rs index 436f487cd99..4bd96441636 100644 --- a/packages/token-market-contract/src/lib.rs +++ b/packages/token-market-contract/src/lib.rs @@ -17,7 +17,7 @@ pub const ID: Identifier = Identifier(IdentifierBytes32(ID_BYTES)); pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES)); /// The contract's definitions for `platform_version`. Version 0, the value the tables of -/// protocol versions below 15 carry, names no schema generation and is refused like any +/// protocol versions below 16 carry, names no schema generation and is refused like any /// unknown version: the contract does not exist before its activation. pub fn load_definitions(platform_version: &PlatformVersion) -> Result, Error> { match platform_version.system_data_contracts.token_market { @@ -56,10 +56,13 @@ mod tests { } #[test] - fn should_load_the_schema_at_the_latest_platform_version() { + fn should_load_the_schema_at_the_token_marketplace_test_version() { + use platform_version::version::mocks::v5_test::TEST_PLATFORM_V5; use v1::document_types::{ask, bid}; - let schema = load_documents_schemas(PlatformVersion::latest()).expect("schema loads"); + // The token marketplace starts with protocol version 16, which has no tables yet: the + // test version that selects it stands in for it. + let schema = load_documents_schemas(&TEST_PLATFORM_V5).expect("schema loads"); let declared = |name: &str, properties: &[&str], summed: &str| { let document_type = schema .get(name) @@ -126,14 +129,17 @@ mod tests { #[test] fn should_refuse_to_load_below_the_activation_version() { - let platform_version = PlatformVersion::get(14).expect("protocol version 14"); - assert!(matches!( - load_documents_schemas(platform_version), - Err(Error::UnknownVersionMismatch { received: 0, .. }) - )); - assert!(matches!( - load_definitions(platform_version), - Err(Error::UnknownVersionMismatch { received: 0, .. }) - )); + for protocol_version in [14, 15] { + let platform_version = + PlatformVersion::get(protocol_version).expect("expected the protocol version"); + assert!(matches!( + load_documents_schemas(platform_version), + Err(Error::UnknownVersionMismatch { received: 0, .. }) + )); + assert!(matches!( + load_definitions(platform_version), + Err(Error::UnknownVersionMismatch { received: 0, .. }) + )); + } } } diff --git a/packages/wasm-dpp2/src/tokens/configuration/trade_mode.rs b/packages/wasm-dpp2/src/tokens/configuration/trade_mode.rs index 43c6dba93bc..f541b43402b 100644 --- a/packages/wasm-dpp2/src/tokens/configuration/trade_mode.rs +++ b/packages/wasm-dpp2/src/tokens/configuration/trade_mode.rs @@ -25,7 +25,8 @@ impl TokenTradeModeWasm { TokenTradeModeWasm(TokenTradeMode::NotTradeable) } - /// Holders may list the token and make offers for it (protocol version 15). + /// Holders may list the token and make offers for it. Admitted from protocol version 16: + /// earlier versions refuse a contract or a configuration update that uses it. #[wasm_bindgen(js_name = "Tradeable")] pub fn tradeable() -> TokenTradeModeWasm { TokenTradeModeWasm(TokenTradeMode::Tradeable)