From bd7ed805b49e30c64cc59d96fa37fa90c2f8a878 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Mon, 7 Oct 2024 18:23:44 +0300 Subject: [PATCH 1/3] chore(drive): log invalid state on deserialisation (#2220) --- .../storage/fetch_platform_state/v0/mod.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/storage/fetch_platform_state/v0/mod.rs b/packages/rs-drive-abci/src/execution/storage/fetch_platform_state/v0/mod.rs index 25960bf5b3..a815e0266a 100644 --- a/packages/rs-drive-abci/src/execution/storage/fetch_platform_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/storage/fetch_platform_state/v0/mod.rs @@ -16,8 +16,18 @@ impl Platform { .fetch_platform_state_bytes(transaction, platform_version) .map_err(Error::Drive)? .map(|bytes| { - PlatformState::versioned_deserialize(&bytes, platform_version) - .map_err(Error::Protocol) + let result = PlatformState::versioned_deserialize(&bytes, platform_version) + .map_err(Error::Protocol); + + if result.is_err() { + tracing::error!( + bytes = hex::encode(&bytes), + "Unable deserialize platform state for version {}", + platform_version.protocol_version + ); + } + + result }) .transpose() } From 5e996edd879222d51b9843a4625a04db4c1b2daf Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Mon, 7 Oct 2024 18:25:41 +0300 Subject: [PATCH 2/3] chore(release): update changelog and bump version to 1.4.0-dev.7 (#2221) --- CHANGELOG.md | 7 +++ Cargo.lock | 50 +++++++++---------- package.json | 2 +- packages/bench-suite/package.json | 2 +- packages/check-features/Cargo.toml | 2 +- packages/dapi-grpc/Cargo.toml | 2 +- packages/dapi-grpc/package.json | 2 +- packages/dapi/package.json | 2 +- packages/dash-spv/package.json | 2 +- packages/dashmate/package.json | 2 +- packages/dashpay-contract/Cargo.toml | 2 +- packages/dashpay-contract/package.json | 2 +- packages/data-contracts/Cargo.toml | 2 +- packages/dpns-contract/Cargo.toml | 2 +- packages/dpns-contract/package.json | 2 +- packages/feature-flags-contract/Cargo.toml | 2 +- packages/feature-flags-contract/package.json | 2 +- packages/js-dapi-client/package.json | 2 +- packages/js-dash-sdk/package.json | 2 +- packages/js-grpc-common/package.json | 2 +- .../Cargo.toml | 2 +- .../package.json | 2 +- packages/platform-test-suite/package.json | 2 +- packages/rs-dapi-client/Cargo.toml | 2 +- packages/rs-dapi-grpc-macros/Cargo.toml | 2 +- packages/rs-dpp/Cargo.toml | 2 +- packages/rs-drive-abci/Cargo.toml | 2 +- packages/rs-drive-proof-verifier/Cargo.toml | 2 +- packages/rs-drive/Cargo.toml | 2 +- .../Cargo.toml | 2 +- .../Cargo.toml | 2 +- packages/rs-platform-serialization/Cargo.toml | 2 +- .../rs-platform-value-convertible/Cargo.toml | 2 +- packages/rs-platform-value/Cargo.toml | 2 +- packages/rs-platform-version/Cargo.toml | 2 +- packages/rs-platform-versioning/Cargo.toml | 2 +- packages/rs-sdk/Cargo.toml | 2 +- packages/simple-signer/Cargo.toml | 2 +- packages/strategy-tests/Cargo.toml | 2 +- packages/wallet-lib/package.json | 2 +- packages/wasm-dpp/Cargo.toml | 2 +- packages/wasm-dpp/package.json | 2 +- packages/withdrawals-contract/Cargo.toml | 2 +- packages/withdrawals-contract/package.json | 2 +- 44 files changed, 74 insertions(+), 67 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77bd24bbd2..6929775650 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.4.0-dev.7](https://github.com/dashpay/platform/compare/v1.4.0-dev.6...v1.4.0-dev.7) (2024-10-07) + + +### Miscellaneous Chores + +* **drive:** log invalid state on deserialisation ([#2220](https://github.com/dashpay/platform/issues/2220)) + ## [1.4.0-dev.6](https://github.com/dashpay/platform/compare/v1.4.0-dev.5...v1.4.0-dev.6) (2024-10-07) diff --git a/Cargo.lock b/Cargo.lock index 3fc716539f..4af5a74799 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -673,7 +673,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "check-features" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "toml", ] @@ -1042,7 +1042,7 @@ dependencies = [ [[package]] name = "dapi-grpc" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "dapi-grpc-macros", "futures-core", @@ -1058,7 +1058,7 @@ dependencies = [ [[package]] name = "dapi-grpc-macros" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "dapi-grpc", "heck 0.5.0", @@ -1103,7 +1103,7 @@ dependencies = [ [[package]] name = "dash-sdk" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "arc-swap", "async-trait", @@ -1203,7 +1203,7 @@ dependencies = [ [[package]] name = "dashpay-contract" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "platform-value", "platform-version", @@ -1213,7 +1213,7 @@ dependencies = [ [[package]] name = "data-contracts" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "dashpay-contract", "dpns-contract", @@ -1344,7 +1344,7 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "dpns-contract" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "platform-value", "platform-version", @@ -1354,7 +1354,7 @@ dependencies = [ [[package]] name = "dpp" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "anyhow", "assert_matches", @@ -1406,7 +1406,7 @@ dependencies = [ [[package]] name = "drive" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "arc-swap", "assert_matches", @@ -1447,7 +1447,7 @@ dependencies = [ [[package]] name = "drive-abci" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "arc-swap", "assert_matches", @@ -1502,7 +1502,7 @@ dependencies = [ [[package]] name = "drive-proof-verifier" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "bincode", "dapi-grpc", @@ -1723,7 +1723,7 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "feature-flags-contract" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "platform-value", "platform-version", @@ -2561,7 +2561,7 @@ dependencies = [ [[package]] name = "json-schema-compatibility-validator" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "assert_matches", "json-patch", @@ -2719,7 +2719,7 @@ dependencies = [ [[package]] name = "masternode-reward-shares-contract" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "platform-value", "platform-version", @@ -3299,7 +3299,7 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "platform-serialization" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "bincode", "platform-version", @@ -3307,7 +3307,7 @@ dependencies = [ [[package]] name = "platform-serialization-derive" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "proc-macro2", "quote", @@ -3317,7 +3317,7 @@ dependencies = [ [[package]] name = "platform-value" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "base64 0.22.1", "bincode", @@ -3338,7 +3338,7 @@ dependencies = [ [[package]] name = "platform-value-convertible" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "quote", "syn 2.0.75", @@ -3346,7 +3346,7 @@ dependencies = [ [[package]] name = "platform-version" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "bincode", "grovedb-version", @@ -3357,7 +3357,7 @@ dependencies = [ [[package]] name = "platform-versioning" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "proc-macro2", "quote", @@ -3849,7 +3849,7 @@ dependencies = [ [[package]] name = "rs-dapi-client" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "backon", "chrono", @@ -4316,7 +4316,7 @@ checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" [[package]] name = "simple-signer" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "base64 0.22.1", "bincode", @@ -4382,7 +4382,7 @@ dependencies = [ [[package]] name = "strategy-tests" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "bincode", "dpp", @@ -5301,7 +5301,7 @@ checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "wasm-dpp" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "anyhow", "async-trait", @@ -5603,7 +5603,7 @@ dependencies = [ [[package]] name = "withdrawals-contract" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" dependencies = [ "num_enum 0.5.11", "platform-value", diff --git a/package.json b/package.json index 8bd83932cc..135b7d3084 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/platform", - "version": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "private": true, "scripts": { "setup": "yarn install && yarn run build && yarn run configure", diff --git a/packages/bench-suite/package.json b/packages/bench-suite/package.json index aab27b9a75..b3e2fac245 100644 --- a/packages/bench-suite/package.json +++ b/packages/bench-suite/package.json @@ -1,7 +1,7 @@ { "name": "@dashevo/bench-suite", "private": true, - "version": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "description": "Dash Platform benchmark tool", "scripts": { "bench": "node ./bin/bench.js", diff --git a/packages/check-features/Cargo.toml b/packages/check-features/Cargo.toml index 7140cdc9f6..7d11a7421f 100644 --- a/packages/check-features/Cargo.toml +++ b/packages/check-features/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "check-features" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/packages/dapi-grpc/Cargo.toml b/packages/dapi-grpc/Cargo.toml index c487569ab2..be9ba8e05b 100644 --- a/packages/dapi-grpc/Cargo.toml +++ b/packages/dapi-grpc/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dapi-grpc" description = "GRPC client for Dash Platform" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" authors = [ "Samuel Westrich ", "Igor Markin ", diff --git a/packages/dapi-grpc/package.json b/packages/dapi-grpc/package.json index 5e0458d6f0..558ad26654 100644 --- a/packages/dapi-grpc/package.json +++ b/packages/dapi-grpc/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/dapi-grpc", - "version": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "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 fc39f2b7a2..eff603e912 100644 --- a/packages/dapi/package.json +++ b/packages/dapi/package.json @@ -1,7 +1,7 @@ { "name": "@dashevo/dapi", "private": true, - "version": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "description": "A decentralized API for the Dash network", "scripts": { "api": "node scripts/api.js", diff --git a/packages/dash-spv/package.json b/packages/dash-spv/package.json index 7c864ad320..e8f982f0ea 100644 --- a/packages/dash-spv/package.json +++ b/packages/dash-spv/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/dash-spv", - "version": "2.4.0-dev.6", + "version": "2.4.0-dev.7", "description": "Repository containing SPV functions used by @dashevo", "main": "index.js", "scripts": { diff --git a/packages/dashmate/package.json b/packages/dashmate/package.json index 78ceccc610..397c430574 100644 --- a/packages/dashmate/package.json +++ b/packages/dashmate/package.json @@ -1,6 +1,6 @@ { "name": "dashmate", - "version": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "description": "Distribution package for Dash node installation", "scripts": { "lint": "eslint .", diff --git a/packages/dashpay-contract/Cargo.toml b/packages/dashpay-contract/Cargo.toml index c9cce559b0..dd94bf77f0 100644 --- a/packages/dashpay-contract/Cargo.toml +++ b/packages/dashpay-contract/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dashpay-contract" description = "DashPay data contract schema and tools" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true license = "MIT" diff --git a/packages/dashpay-contract/package.json b/packages/dashpay-contract/package.json index 48472808ff..9d8bc10a8c 100644 --- a/packages/dashpay-contract/package.json +++ b/packages/dashpay-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/dashpay-contract", - "version": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "description": "Reference contract of the DashPay DPA on Dash Evolution", "scripts": { "lint": "eslint .", diff --git a/packages/data-contracts/Cargo.toml b/packages/data-contracts/Cargo.toml index 7fe6683b5e..5c7c908471 100644 --- a/packages/data-contracts/Cargo.toml +++ b/packages/data-contracts/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "data-contracts" description = "Dash Platform system data contracts" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true license = "MIT" diff --git a/packages/dpns-contract/Cargo.toml b/packages/dpns-contract/Cargo.toml index 30bff16530..e26c6b3f92 100644 --- a/packages/dpns-contract/Cargo.toml +++ b/packages/dpns-contract/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dpns-contract" description = "DPNS data contract schema and tools" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true license = "MIT" diff --git a/packages/dpns-contract/package.json b/packages/dpns-contract/package.json index d52e8cb905..c653837569 100644 --- a/packages/dpns-contract/package.json +++ b/packages/dpns-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/dpns-contract", - "version": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "description": "A contract and helper scripts for DPNS DApp", "scripts": { "lint": "eslint .", diff --git a/packages/feature-flags-contract/Cargo.toml b/packages/feature-flags-contract/Cargo.toml index 99fbe6bd07..c96643b8cd 100644 --- a/packages/feature-flags-contract/Cargo.toml +++ b/packages/feature-flags-contract/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "feature-flags-contract" description = "Feature flags data contract schema and tools" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true license = "MIT" diff --git a/packages/feature-flags-contract/package.json b/packages/feature-flags-contract/package.json index 8bdf9bef48..70f1e9a538 100644 --- a/packages/feature-flags-contract/package.json +++ b/packages/feature-flags-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/feature-flags-contract", - "version": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "description": "Data Contract to store Dash Platform feature flags", "scripts": { "build": "", diff --git a/packages/js-dapi-client/package.json b/packages/js-dapi-client/package.json index a46be3f4e0..4339db52be 100644 --- a/packages/js-dapi-client/package.json +++ b/packages/js-dapi-client/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/dapi-client", - "version": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "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 c994dbf84e..6355ee3c35 100644 --- a/packages/js-dash-sdk/package.json +++ b/packages/js-dash-sdk/package.json @@ -1,6 +1,6 @@ { "name": "dash", - "version": "4.4.0-dev.6", + "version": "4.4.0-dev.7", "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-grpc-common/package.json b/packages/js-grpc-common/package.json index e6b740d9d8..c57a55fbe7 100644 --- a/packages/js-grpc-common/package.json +++ b/packages/js-grpc-common/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/grpc-common", - "version": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "description": "Common GRPC library", "main": "index.js", "scripts": { diff --git a/packages/masternode-reward-shares-contract/Cargo.toml b/packages/masternode-reward-shares-contract/Cargo.toml index 8a63885d54..0ba5f04dfe 100644 --- a/packages/masternode-reward-shares-contract/Cargo.toml +++ b/packages/masternode-reward-shares-contract/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "masternode-reward-shares-contract" description = "Masternode reward shares data contract schema and tools" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true license = "MIT" diff --git a/packages/masternode-reward-shares-contract/package.json b/packages/masternode-reward-shares-contract/package.json index 334c1342bd..20a60d9fa3 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": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "description": "A contract and helper scripts for reward sharing", "scripts": { "lint": "eslint .", diff --git a/packages/platform-test-suite/package.json b/packages/platform-test-suite/package.json index a03c1c8559..3ed5cf8d91 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": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "description": "Dash Network end-to-end tests", "scripts": { "test": "yarn exec bin/test.sh", diff --git a/packages/rs-dapi-client/Cargo.toml b/packages/rs-dapi-client/Cargo.toml index 817ef6889b..e5dc961574 100644 --- a/packages/rs-dapi-client/Cargo.toml +++ b/packages/rs-dapi-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rs-dapi-client" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" [features] diff --git a/packages/rs-dapi-grpc-macros/Cargo.toml b/packages/rs-dapi-grpc-macros/Cargo.toml index e35f8024b1..5b4b883c56 100644 --- a/packages/rs-dapi-grpc-macros/Cargo.toml +++ b/packages/rs-dapi-grpc-macros/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dapi-grpc-macros" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" description = "Macros used by dapi-grpc. Internal use only." diff --git a/packages/rs-dpp/Cargo.toml b/packages/rs-dpp/Cargo.toml index 4070f9a7e2..f096f1f747 100644 --- a/packages/rs-dpp/Cargo.toml +++ b/packages/rs-dpp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dpp" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true authors = [ diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index 075aed3f39..2c88cf0e16 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "drive-abci" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" authors = [ "Samuel Westrich ", "Ivan Shumkov ", diff --git a/packages/rs-drive-proof-verifier/Cargo.toml b/packages/rs-drive-proof-verifier/Cargo.toml index 2a5fce6242..f6ebac3824 100644 --- a/packages/rs-drive-proof-verifier/Cargo.toml +++ b/packages/rs-drive-proof-verifier/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "drive-proof-verifier" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true diff --git a/packages/rs-drive/Cargo.toml b/packages/rs-drive/Cargo.toml index 873ae06b0d..394bd20eb1 100644 --- a/packages/rs-drive/Cargo.toml +++ b/packages/rs-drive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "drive" description = "Dash drive built on top of GroveDB" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" authors = [ "Samuel Westrich ", "Ivan Shumkov ", diff --git a/packages/rs-json-schema-compatibility-validator/Cargo.toml b/packages/rs-json-schema-compatibility-validator/Cargo.toml index 1b1f5624d1..e7598b319c 100644 --- a/packages/rs-json-schema-compatibility-validator/Cargo.toml +++ b/packages/rs-json-schema-compatibility-validator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "json-schema-compatibility-validator" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true authors = ["Ivan Shumkov "] diff --git a/packages/rs-platform-serialization-derive/Cargo.toml b/packages/rs-platform-serialization-derive/Cargo.toml index 98b6fa10fa..790f2b2c1b 100644 --- a/packages/rs-platform-serialization-derive/Cargo.toml +++ b/packages/rs-platform-serialization-derive/Cargo.toml @@ -2,7 +2,7 @@ name = "platform-serialization-derive" authors = ["Samuel Westrich "] description = "Bincode serialization and deserialization derivations" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true license = "MIT" diff --git a/packages/rs-platform-serialization/Cargo.toml b/packages/rs-platform-serialization/Cargo.toml index e5f6f2ad03..ddb9000e9b 100644 --- a/packages/rs-platform-serialization/Cargo.toml +++ b/packages/rs-platform-serialization/Cargo.toml @@ -2,7 +2,7 @@ name = "platform-serialization" authors = ["Samuel Westrich "] description = "Bincode based serialization and deserialization" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true license = "MIT" diff --git a/packages/rs-platform-value-convertible/Cargo.toml b/packages/rs-platform-value-convertible/Cargo.toml index 2bbfb16f80..1b570a4325 100644 --- a/packages/rs-platform-value-convertible/Cargo.toml +++ b/packages/rs-platform-value-convertible/Cargo.toml @@ -2,7 +2,7 @@ name = "platform-value-convertible" authors = ["Samuel Westrich "] description = "Convertion to and from platform values" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true license = "MIT" diff --git a/packages/rs-platform-value/Cargo.toml b/packages/rs-platform-value/Cargo.toml index 1fb6a023f1..1f5ac10e8f 100644 --- a/packages/rs-platform-value/Cargo.toml +++ b/packages/rs-platform-value/Cargo.toml @@ -2,7 +2,7 @@ name = "platform-value" authors = ["Samuel Westrich "] description = "A simple value module" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true license = "MIT" diff --git a/packages/rs-platform-version/Cargo.toml b/packages/rs-platform-version/Cargo.toml index 3a66c92026..7497dd8786 100644 --- a/packages/rs-platform-version/Cargo.toml +++ b/packages/rs-platform-version/Cargo.toml @@ -2,7 +2,7 @@ name = "platform-version" authors = ["Samuel Westrich "] description = "Versioning library for Platform" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true license = "MIT" diff --git a/packages/rs-platform-versioning/Cargo.toml b/packages/rs-platform-versioning/Cargo.toml index cccfebf94a..0941cffbe5 100644 --- a/packages/rs-platform-versioning/Cargo.toml +++ b/packages/rs-platform-versioning/Cargo.toml @@ -2,7 +2,7 @@ name = "platform-versioning" authors = ["Samuel Westrich "] description = "Version derivation" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true license = "MIT" diff --git a/packages/rs-sdk/Cargo.toml b/packages/rs-sdk/Cargo.toml index d039e15e8d..aa41ed04ae 100644 --- a/packages/rs-sdk/Cargo.toml +++ b/packages/rs-sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dash-sdk" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" [dependencies] diff --git a/packages/simple-signer/Cargo.toml b/packages/simple-signer/Cargo.toml index 32910fdf36..aa28658d71 100644 --- a/packages/simple-signer/Cargo.toml +++ b/packages/simple-signer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "simple-signer" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true diff --git a/packages/strategy-tests/Cargo.toml b/packages/strategy-tests/Cargo.toml index 22e93611f4..20f191c0a5 100644 --- a/packages/strategy-tests/Cargo.toml +++ b/packages/strategy-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strategy-tests" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" authors = [ "Samuel Westrich ", "Ivan Shumkov ", diff --git a/packages/wallet-lib/package.json b/packages/wallet-lib/package.json index 01d482878b..8c23365ab4 100644 --- a/packages/wallet-lib/package.json +++ b/packages/wallet-lib/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/wallet-lib", - "version": "8.4.0-dev.6", + "version": "8.4.0-dev.7", "description": "Light wallet library for Dash", "main": "src/index.js", "unpkg": "dist/wallet-lib.min.js", diff --git a/packages/wasm-dpp/Cargo.toml b/packages/wasm-dpp/Cargo.toml index dd8309b128..ec72884429 100644 --- a/packages/wasm-dpp/Cargo.toml +++ b/packages/wasm-dpp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-dpp" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true authors = ["Anton Suprunchuk "] diff --git a/packages/wasm-dpp/package.json b/packages/wasm-dpp/package.json index e46c3999d6..3e7d34045d 100644 --- a/packages/wasm-dpp/package.json +++ b/packages/wasm-dpp/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/wasm-dpp", - "version": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "description": "The JavaScript implementation of the Dash Platform Protocol", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/withdrawals-contract/Cargo.toml b/packages/withdrawals-contract/Cargo.toml index dccf38033c..bab39adb8c 100644 --- a/packages/withdrawals-contract/Cargo.toml +++ b/packages/withdrawals-contract/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "withdrawals-contract" description = "Witdrawals data contract schema and tools" -version = "1.4.0-dev.6" +version = "1.4.0-dev.7" edition = "2021" rust-version.workspace = true license = "MIT" diff --git a/packages/withdrawals-contract/package.json b/packages/withdrawals-contract/package.json index 1c3acee5b5..f4270b3bc7 100644 --- a/packages/withdrawals-contract/package.json +++ b/packages/withdrawals-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/withdrawals-contract", - "version": "1.4.0-dev.6", + "version": "1.4.0-dev.7", "description": "Data Contract to manipulate and track withdrawals", "scripts": { "build": "", From 5aed75a4cdd788574e6abc949a2af9379939f3d7 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Tue, 8 Oct 2024 16:17:00 +0700 Subject: [PATCH 3/3] feat(sdk): fix client tls connections (#2223) Co-authored-by: Lukasz Klimek <842586+lklimek@users.noreply.github.com> --- Cargo.lock | 17 ++-- packages/rs-dapi-client/Cargo.toml | 10 ++- .../rs-dapi-client/src/connection_pool.rs | 12 +-- packages/rs-dapi-client/src/dapi_client.rs | 10 ++- packages/rs-dapi-client/src/transport.rs | 4 +- packages/rs-dapi-client/src/transport/grpc.rs | 90 ++++++++++++++----- packages/rs-sdk/src/platform/types/evonode.rs | 13 ++- 7 files changed, 111 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4af5a74799..92ff215c4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -309,11 +309,12 @@ dependencies = [ [[package]] name = "backon" -version = "0.5.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33e5b65cc81d81fbb8488f36458ab4771be35a722967bbc959df28b47397e3ff" +checksum = "e4fa97bb310c33c811334143cf64c5bb2b7b3c06e453db6b095d7061eff8f113" dependencies = [ "fastrand", + "tokio", ] [[package]] @@ -3955,9 +3956,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04182dffc9091a404e0fc069ea5cd60e5b866c3adf881eff99a32d048242dffa" +checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -4791,9 +4792,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -4884,9 +4885,9 @@ dependencies = [ [[package]] name = "tonic" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38659f4a91aba8598d27821589f5db7dddd94601e7a01b1e485a50e5484c7401" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", diff --git a/packages/rs-dapi-client/Cargo.toml b/packages/rs-dapi-client/Cargo.toml index e5dc961574..fb06b6abdc 100644 --- a/packages/rs-dapi-client/Cargo.toml +++ b/packages/rs-dapi-client/Cargo.toml @@ -19,8 +19,14 @@ dump = ["mocks"] offline-testing = [] [dependencies] -backon = "0.5" -dapi-grpc = { path = "../dapi-grpc" } +backon = { version = "1.2", default-features = false, features = [ + "tokio-sleep", +] } +dapi-grpc = { path = "../dapi-grpc", features = [ + "core", + "platform", + "client", +], default-features = false } futures = "0.3.28" http-serde = { version = "2.1", optional = true } rand = { version = "0.8.5", features = ["small_rng"] } diff --git a/packages/rs-dapi-client/src/connection_pool.rs b/packages/rs-dapi-client/src/connection_pool.rs index 16d8cf030d..97dd991d50 100644 --- a/packages/rs-dapi-client/src/connection_pool.rs +++ b/packages/rs-dapi-client/src/connection_pool.rs @@ -67,19 +67,21 @@ impl ConnectionPool { /// * `prefix` - Prefix for the item in the pool. Used to distinguish between Core and Platform clients. /// * `uri` - URI of the node. /// * `settings` - Applied request settings. - pub fn get_or_create( + pub fn get_or_create( &self, prefix: PoolPrefix, uri: &Uri, settings: Option<&AppliedRequestSettings>, - create: impl FnOnce() -> PoolItem, - ) -> PoolItem { + create: impl FnOnce() -> Result, + ) -> Result { if let Some(cli) = self.get(prefix, uri, settings) { - return cli; + return Ok(cli); } let cli = create(); - self.put(uri, settings, cli.clone()); + if let Ok(cli) = &cli { + self.put(uri, settings, cli.clone()); + } cli } diff --git a/packages/rs-dapi-client/src/dapi_client.rs b/packages/rs-dapi-client/src/dapi_client.rs index 17748ab2b0..372b28bc3f 100644 --- a/packages/rs-dapi-client/src/dapi_client.rs +++ b/packages/rs-dapi-client/src/dapi_client.rs @@ -199,7 +199,13 @@ impl DapiRequestExecutor for DapiClient { address.uri().clone(), &applied_settings, &pool, - ); + ) + .map_err(|e| { + DapiClientError::<::Error>::Transport( + e, + address.clone(), + ) + })?; let response = transport_request .execute_transport(&mut transport_client, &applied_settings) @@ -250,7 +256,7 @@ impl DapiRequestExecutor for DapiClient { // Start the routine with retry policy applied: // We allow let_and_return because `result` is used later if dump feature is enabled let result = routine - .retry(&retry_settings) + .retry(retry_settings) .notify(|error, duration| { tracing::warn!( ?error, diff --git a/packages/rs-dapi-client/src/transport.rs b/packages/rs-dapi-client/src/transport.rs index a5459834e1..600189fc2f 100644 --- a/packages/rs-dapi-client/src/transport.rs +++ b/packages/rs-dapi-client/src/transport.rs @@ -51,12 +51,12 @@ pub trait TransportClient: Send + Sized { type Error: CanRetry + Send + Debug + Mockable; /// Build client using node's url. - fn with_uri(uri: Uri, pool: &ConnectionPool) -> Self; + fn with_uri(uri: Uri, pool: &ConnectionPool) -> Result; /// Build client using node's url and [AppliedRequestSettings]. fn with_uri_and_settings( uri: Uri, settings: &AppliedRequestSettings, pool: &ConnectionPool, - ) -> Self; + ) -> Result; } diff --git a/packages/rs-dapi-client/src/transport/grpc.rs b/packages/rs-dapi-client/src/transport/grpc.rs index 98976ed08e..d5180099d0 100644 --- a/packages/rs-dapi-client/src/transport/grpc.rs +++ b/packages/rs-dapi-client/src/transport/grpc.rs @@ -8,7 +8,7 @@ use crate::{request_settings::AppliedRequestSettings, RequestSettings}; use dapi_grpc::core::v0::core_client::CoreClient; use dapi_grpc::core::v0::{self as core_proto}; use dapi_grpc::platform::v0::{self as platform_proto, platform_client::PlatformClient}; -use dapi_grpc::tonic::transport::Uri; +use dapi_grpc::tonic::transport::{ClientTlsConfig, Uri}; use dapi_grpc::tonic::Streaming; use dapi_grpc::tonic::{transport::Channel, IntoRequest}; use futures::{future::BoxFuture, FutureExt, TryFutureExt}; @@ -18,8 +18,16 @@ pub type PlatformGrpcClient = PlatformClient; /// Core Client using gRPC transport. pub type CoreGrpcClient = CoreClient; -fn create_channel(uri: Uri, settings: Option<&AppliedRequestSettings>) -> Channel { - let mut builder = Channel::builder(uri); +fn create_channel( + uri: Uri, + settings: Option<&AppliedRequestSettings>, +) -> Result { + let mut builder = Channel::builder(uri).tls_config( + ClientTlsConfig::new() + .with_native_roots() + .with_webpki_roots() + .assume_http2(true), + )?; if let Some(settings) = settings { if let Some(timeout) = settings.connect_timeout { @@ -27,50 +35,84 @@ fn create_channel(uri: Uri, settings: Option<&AppliedRequestSettings>) -> Channe } } - builder.connect_lazy() + Ok(builder.connect_lazy()) } impl TransportClient for PlatformGrpcClient { type Error = dapi_grpc::tonic::Status; - fn with_uri(uri: Uri, pool: &ConnectionPool) -> Self { - pool.get_or_create(PoolPrefix::Platform, &uri, None, || { - Self::new(create_channel(uri.clone(), None)).into() - }) - .into() + fn with_uri(uri: Uri, pool: &ConnectionPool) -> Result { + Ok(pool + .get_or_create(PoolPrefix::Platform, &uri, None, || { + match create_channel(uri.clone(), None) { + Ok(channel) => Ok(Self::new(channel).into()), + Err(e) => Err(dapi_grpc::tonic::Status::failed_precondition(format!( + "Channel creation failed: {}", + e + ))), + } + })? + .into()) } fn with_uri_and_settings( uri: Uri, settings: &AppliedRequestSettings, pool: &ConnectionPool, - ) -> Self { - pool.get_or_create(PoolPrefix::Platform, &uri, Some(settings), || { - Self::new(create_channel(uri.clone(), Some(settings))).into() - }) - .into() + ) -> Result { + Ok(pool + .get_or_create( + PoolPrefix::Platform, + &uri, + Some(settings), + || match create_channel(uri.clone(), Some(settings)) { + Ok(channel) => Ok(Self::new(channel).into()), + Err(e) => Err(dapi_grpc::tonic::Status::failed_precondition(format!( + "Channel creation failed: {}", + e + ))), + }, + )? + .into()) } } impl TransportClient for CoreGrpcClient { type Error = dapi_grpc::tonic::Status; - fn with_uri(uri: Uri, pool: &ConnectionPool) -> Self { - pool.get_or_create(PoolPrefix::Core, &uri, None, || { - Self::new(create_channel(uri.clone(), None)).into() - }) - .into() + fn with_uri(uri: Uri, pool: &ConnectionPool) -> Result { + Ok(pool + .get_or_create(PoolPrefix::Core, &uri, None, || { + match create_channel(uri.clone(), None) { + Ok(channel) => Ok(Self::new(channel).into()), + Err(e) => Err(dapi_grpc::tonic::Status::failed_precondition(format!( + "Channel creation failed: {}", + e + ))), + } + })? + .into()) } fn with_uri_and_settings( uri: Uri, settings: &AppliedRequestSettings, pool: &ConnectionPool, - ) -> Self { - pool.get_or_create(PoolPrefix::Core, &uri, Some(settings), || { - Self::new(create_channel(uri.clone(), Some(settings))).into() - }) - .into() + ) -> Result { + Ok(pool + .get_or_create( + PoolPrefix::Core, + &uri, + Some(settings), + || match create_channel(uri.clone(), Some(settings)) { + Ok(channel) => Ok(Self::new(channel).into()), + Err(e) => Err(dapi_grpc::tonic::Status::failed_precondition(format!( + "Channel creation failed: {}", + e + ))), + }, + )? + .into()) } } diff --git a/packages/rs-sdk/src/platform/types/evonode.rs b/packages/rs-sdk/src/platform/types/evonode.rs index 01c0630b49..77e893dfd5 100644 --- a/packages/rs-sdk/src/platform/types/evonode.rs +++ b/packages/rs-sdk/src/platform/types/evonode.rs @@ -10,7 +10,7 @@ use futures::{FutureExt, TryFutureExt}; use rs_dapi_client::transport::{ AppliedRequestSettings, PlatformGrpcClient, TransportClient, TransportRequest, }; -use rs_dapi_client::{Address, ConnectionPool, RequestSettings}; +use rs_dapi_client::{Address, ConnectionPool, DapiClientError, RequestSettings}; #[cfg(feature = "mocks")] use serde::{Deserialize, Serialize}; use std::fmt::Debug; @@ -74,7 +74,16 @@ impl TransportRequest for EvoNode { // We also create a new client to use with this request, so that the user does not need to // reconfigure SDK to use a single node. let pool = ConnectionPool::new(1); - let mut client = Self::Client::with_uri_and_settings(uri.clone(), settings, &pool); + // We create a new client with the given URI and settings + let client_result = Self::Client::with_uri_and_settings(uri.clone(), settings, &pool); + + // Handle the result manually to create a proper error response + let mut client = match client_result { + Ok(client) => client, + Err(e) => { + return async { Err(e) }.boxed(); + } + }; let mut grpc_request = GetStatusRequest { version: Some(get_status_request::Version::V0(GetStatusRequestV0 {})), }