Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
317 changes: 169 additions & 148 deletions Cargo.lock

Large diffs are not rendered by default.

32 changes: 19 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ eframe = { version = "0.35.0", features = ["persistence", "wgpu"] }
base64 = "0.22.1"
# TODO: GHSA-7gcf-g7xr-8hxj (serde_with <3.21.0) is unfixable from here — the 2.x pin lives in
# dashcore-rpc-json (dashpay/rust-dashcore, rpc-json/Cargo.toml). Re-check when these pins move.
dash-sdk = { git = "https://github.com/dashpay/platform", rev = "63cf57f40d0000bf3b2b26026c8fa1c71162852d", features = [
dash-sdk = { git = "https://github.com/dashpay/platform", rev = "01d944795e3dc9776fd4d01959df9abc1ea98c87", features = [
"core_key_wallet",
"core_key_wallet_manager",
"core_bincode",
Expand All @@ -30,15 +30,15 @@ dash-sdk = { git = "https://github.com/dashpay/platform", rev = "63cf57f40d0000b
"core_spv",
"shielded",
] }
rs-sdk-trusted-context-provider = { git = "https://github.com/dashpay/platform", rev = "63cf57f40d0000bf3b2b26026c8fa1c71162852d" }
platform-wallet = { git = "https://github.com/dashpay/platform", rev = "63cf57f40d0000bf3b2b26026c8fa1c71162852d", features = [
rs-sdk-trusted-context-provider = { git = "https://github.com/dashpay/platform", rev = "01d944795e3dc9776fd4d01959df9abc1ea98c87" }
platform-wallet = { git = "https://github.com/dashpay/platform", rev = "01d944795e3dc9776fd4d01959df9abc1ea98c87", features = [
"serde",
"shielded",
] }
# `serde` backs `model::secret::Secret`'s `Deserialize`: the upstream
# visitor copies a borrowed `&str` straight into guarded memory instead of
# routing through a transient `String`. Secret schemas are included by `secrets`.
platform-wallet-storage = { git = "https://github.com/dashpay/platform", rev = "63cf57f40d0000bf3b2b26026c8fa1c71162852d", features = [
platform-wallet-storage = { git = "https://github.com/dashpay/platform", rev = "01d944795e3dc9776fd4d01959df9abc1ea98c87", features = [
"shielded",
"serde",
] }
Expand All @@ -50,15 +50,21 @@ serde = "1.0.219"
serde_json = "1.0.140"
serde_yaml_ng = { version = "0.10.0" }
tokio = { version = "1.46.1", features = ["full"] }
# INTENTIONAL(bincode-unmaintained-pin): the pin is deliberate; do not "fix" the audit
# warning by bumping. bincode is flagged unmaintained (RUSTSEC-2025-0141, INFO-level —
# no known vulnerability). The advisory
# covers *all* versions, so no bump can clear it: 2.0.1 is the last functional release
# and 3.0.0 is a tombstone whose lib.rs is a bare `compile_error!`. This crate encodes
# the on-disk wallet-secret envelopes and QualifiedIdentity blobs, so switching encoders
# changes the wire format of data users already have on disk — that needs a designed
# read-old/write-new migration, not a dependency bump.
bincode = { version = "=2.0.1", features = ["serde"] }
# INTENTIONAL(bincode-unmaintained-pin): the exact pin is deliberate; do not "fix" the audit
# warning by bumping. bincode is flagged unmaintained (RUSTSEC-2025-0141, INFO-level — no
# known vulnerability). The advisory covers *all* versions, so no bump can clear it: 2.0.1
# is the last functional release and 3.0.0 is a tombstone whose lib.rs is a bare
# `compile_error!`.
# The dependency is aliased to `grovedb-bincode`, the bincode 2.0.1 fork that dpp,
# platform-value and rust-dashcore implement `Encode`/`Decode` against; the trait
# identities must match or DET's codecs over those types stop compiling. On the ordinary
# (non-`*_untrusted`) paths DET uses — native, `bincode::serde` and the derive macros —
# its wire format is identical to bincode 2.0.1, per source-level analysis of hash-identical
# function bodies and derive-codegen substitution (docs/ai-design/2026-09-14-platform-4.2-dev-bump/);
# no executable fixture pins it. This switch therefore needs no read-old/write-new
# migration. Any other encoder change still does:
# this crate encodes the on-disk wallet-secret envelopes and QualifiedIdentity blobs.
bincode = { package = "grovedb-bincode", version = "=2.1.0", features = ["serde"] }
hex = { version = "0.4.3" }
async-trait = "0.1.89"
itertools = "0.14.0"
Expand Down
122 changes: 122 additions & 0 deletions docs/ai-design/2026-09-14-platform-4.2-dev-bump/upgrade-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Platform `v4.2-dev` pin upgrade

Reviewed on 2026-09-14. The four Platform dependencies (`dash-sdk`,
`rs-sdk-trusted-context-provider`, `platform-wallet`, `platform-wallet-storage`)
move together from `63cf57f40d0000bf3b2b26026c8fa1c71162852d` (`4.2.0-dev.8`)
to `01d944795e3dc9776fd4d01959df9abc1ea98c87` (`4.2.0-dev.10`, `v4.2-dev` HEAD).
The old pin is an ancestor of the new one: 29 new commits, none dropped.

Transitive moves:

- rust-dashcore: `93260bf39bac5d9d09e89bfb45e9ea3ff7fdcbcd` becomes
`e4208c90786a6854bd498315bcb571ef24182c15` (0.45.0; five commits, including
transaction detection and filter-sync fixes).
- GroveDB: 5.0.1 becomes 6.0.0 (`6816457d`). The grovestark dependency keeps
its own 4.0.0 copy.
- `grovedb-bincode` / `grovedb-bincode-derive` 2.1.0 are added. crates.io
`bincode` 2.0.1 and 1.3.3 stay in the lock for grovestark and GroveDB 4.0.0
only.

The full analysis (findings F1–F17, wire-compatibility proof and compile
probe) lives outside the repository in
`/data/artifacts/dash-evo-tool/2026-09-14/`:
`platform-4.2-dev-impact.md`, `platform-4.2-dev-compile-probe.md` and
`platform-3968-dropped-content.md`.

## Compatibility work

| Upstream change | DET change |
| --- | --- |
| [#4635](https://github.com/dashpay/platform/pull/4635): dpp, platform-value and rust-dashcore implement `Encode`/`Decode` from `grovedb-bincode`, which has its own trait identities | `bincode` is aliased to `grovedb-bincode =2.1.0` (`Cargo.toml`). DET's derives and manual codecs over dpp types compile again; import paths are unchanged. |
| [#4625](https://github.com/dashpay/platform/pull/4625): dpp deserialization traits split into trusted and untrusted pairs | The state transition and contract visualizers use the untrusted decoders for pasted bytes. The saved-contract reader (`contract_token_db.rs`) uses the untrusted decoder as well: under the same no-limit config it accepts every valid stored contract, and it does not pre-allocate from length prefixes. |
| [#4645](https://github.com/dashpay/platform/pull/4645): `rewards_in_interval_with_explanation` takes a `&PlatformVersion` | The estimated token-reward query passes the app's active platform version, which selects the version-gated distribution math. |
| [#4708](https://github.com/dashpay/platform/pull/4708) / [#4711](https://github.com/dashpay/platform/pull/4711): new `PlatformWalletError` variants `ShieldedIdentityDebitPending`, `ShieldedRecoveryCorrupted`, `ShieldedRecoveryKeysRequired` | New `TaskError` variants with fixed, actionable messages. The upstream `reason` text stays in the source chain only. Both exhaustive matches name the variants explicitly; identity funding buckets them as `Other` because no identity flow runs a shielded operation. |

## Existing data

**bincode blobs: no migration.** `grovedb-bincode` 2.1.0 is a fork of bincode
2.0.1. On every ordinary (non-`*_untrusted`) entry point DET uses (native
`encode_to_vec`/`decode_from_slice`, `bincode::serde`, and the derive macros),
it produces the same bytes and accepts the same inputs. That covers stored
`QualifiedIdentity`/`KeyStorage`, token configurations, the secret envelopes
and every serde sidecar.

This verdict rests on source-level analysis only (see
`## grovedb-bincode wire compatibility` in `platform-4.2-dev-impact.md`):

- **Runtime.** Every file outside the untrusted additions is byte-identical
between bincode 2.0.1 and grovedb-bincode 2.1.0. In the files that differ,
the bodies on the ordinary path hash-identical (`Decoder for DecoderImpl`,
`decode_from_slice`, `borrow_decode_from_slice`, the serde decode chain,
limit accounting). The serde deserializer's edited methods reduce to the old
behaviour under the fixed `Ordinary` policy.
- **Derive macros.** `Encode` generation is hash-identical. `Decode` and
`BorrowDecode` generation reduce to bincode_derive 2.0.1's output by literal
substitution when the fork's `untrusted` attribute is unset, which holds for
every plain `#[derive(Decode)]`/`#[derive(BorrowDecode)]`.

This repository has no executable regression fixture for bincode wire
compatibility. The fork's own compatibility tests against bincode 2.0.1 were
read, not run. Existing blobs round-trip through the persistence unit tests,
but those tests encode and decode with the same crate, so they cannot detect
an encoder drift.

**`platform-wallet-storage`: no change.** No migration, schema or secret-envelope
change between the pins.

**Shielded store: additive.** `shielded_pending_spends` gains two
`INTEGER NOT NULL DEFAULT 0` columns via an idempotent `ALTER TABLE`. Older
builds still read the table. Opening the store is stricter: an already-malformed pending-spend row that
cannot be classified now fails the open (`ShieldedRecoveryCorrupted`) instead
of being skipped.

## Deferred

- **Contested DPNS fee label.** At protocol version 14 the contested
registration fee is 0.1 DASH and consensus requires the exact amount. The
transition amount already comes from the SDK's platform version, but
`register_dpns_name_screen.rs` still shows "Cost ≈ 0.2006 Dash". Marked
`TODO(platform-4.2-dev-bump)` (impact report F4).
- **Devnet protocol seed.** Upstream seeds devnets at protocol version 14
because lower versions cannot deserialize devnet contracts. DET still seeds
every network at version 12 (`default_platform_version`). Marked
`TODO(platform-4.2-dev-bump)` (F5). Visibility is not the blocker:
`dash_sdk::sdk` is a public module and `min_protocol_version` is a
`pub const fn` at the new pin (`rs-sdk/src/sdk.rs:70`). What remains is the
seeding decision itself. The older `TODO(platform#4231)` beside it is a
separate cleanup; that PR is already merged.
- Other runtime deltas are covered only by network-dependent tests, which were
not run:
- rust-dashcore transaction detection and filter sync;
- the protocol-14 GroveDB proof-envelope floor;
- grovestark's GroveDB 4.0.0 parsing proofs from GroveDB 6.0 nodes.

## Corrections to the previous notes

`docs/ai-design/2026-09-10-platform-pin/upgrade-notes.md` is kept as a
historical record. Two of its claims are stale:

- [#4585](https://github.com/dashpay/platform/pull/4585) is described as open.
It merged on 2026-09-11 and is included in this pin (FFI-only; DET does not
use it).
- [#4587](https://github.com/dashpay/platform/pull/4587) is described as
carrying the contact-account filter-scan generation fix. That fix was
removed from #4587 on 2026-09-14 and now lives, unmerged, in
[#4740](https://github.com/dashpay/platform/pull/4740). Neither pin contains
it. DET still invalidates scan coverage only for contact accounts it
creates at bootstrap or unlock. This bump does not change that.

## Validation and limits

- bincode wire compatibility: source-level analysis only (see
"Existing data"); no executable fixture.
- `cargo check --all-features --all-targets`,
`cargo fmt --all`, and
`cargo clippy --all-features --all-targets -- -D warnings` on the new pin.
- `cargo test --all-features --lib`, scoped to the bincode-persistence modules
(identity blobs including the golden v0.9.3 blob, key storage, seed and
single-key envelopes, DET k/v, wallet meta, settings, contested names, token
registry), and the new shielded error-mapping and
message tests.
- Not run: the full workspace suite (CI covers it), backend E2E, GUI tests, and
opening a real user's shielded store. Checks used Linux and synthetic data.
119 changes: 119 additions & 0 deletions src/backend_task/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2456,6 +2456,54 @@ pub enum TaskError {
source: platform_wallet::wallet::shielded::FileShieldedStoreError,
},

/// An earlier identity-funded shielded payment is still unresolved, so the
/// upstream coordinator refused to start this one. Nothing was built or
/// broadcast; retrying immediately hits the same refusal.
///
/// Populated by `map_shielded_op_error` from
/// `PlatformWalletError::ShieldedIdentityDebitPending`.
#[error(
"An earlier shielded payment from identity {identity_id} has not finished yet, so this payment was not started. Wait for the earlier payment to complete, then try again."
)]
ShieldedIdentityDebitPending {
identity_id: Identifier,
#[source]
source: Box<platform_wallet::error::PlatformWalletError>,
},

/// Durable shielded recovery data is damaged, so a pending payment cannot
/// be identified or reconstructed safely. The upstream `reason` stays in
/// the source chain (details/logs) and never reaches the message.
///
/// The advised recourse is real: removing the wallet runs upstream
/// `remove_wallet` → `unregister_wallet` → `purge_wallet`, which deletes
/// the wallet's `shielded_pending_spends` rows (damaged guards included);
/// re-importing then re-binds and re-syncs from chain.
///
/// Populated by `map_shielded_op_error` from
/// `PlatformWalletError::ShieldedRecoveryCorrupted`.
#[error("{message}", message = shielded_recovery_corrupted_message(*.account_index))]
ShieldedRecoveryCorrupted {
account_index: Option<u32>,
#[source]
source: Box<platform_wallet::error::PlatformWalletError>,
},

/// An unresolved shielded payment needs viewing keys for an account that
/// is not currently available. The upstream `reason` stays in the source
/// chain (details/logs) and never reaches the message.
///
/// Populated by `map_shielded_op_error` from
/// `PlatformWalletError::ShieldedRecoveryKeysRequired`.
#[error(
"A pending shielded payment needs shielded account #{account_index}, which is not available right now. Unlock or restore the wallet that holds this account, then try again."
)]
ShieldedRecoveryKeysRequired {
account_index: u32,
#[source]
source: Box<platform_wallet::error::PlatformWalletError>,
},

// ──────────────────────────────────────────────────────────────────────────
// Network context errors
// ──────────────────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -2859,6 +2907,18 @@ pub(crate) fn vault_error(
class(Box::new(source))
}

/// User-facing text for [`TaskError::ShieldedRecoveryCorrupted`]. Upstream
/// reports the account only when the damaged record identifies one, so each
/// case gets its own complete sentence rather than a spliced fragment.
fn shielded_recovery_corrupted_message(account_index: Option<u32>) -> String {
match account_index {
Some(account_index) => format!(
"Saved recovery data for shielded account #{account_index} is damaged, so a pending payment cannot be checked safely. Make sure you have this wallet's recovery phrase, remove the wallet, then import it again with that phrase."
),
None => "Saved recovery data for your shielded funds is damaged, so a pending payment cannot be checked safely. Make sure you have this wallet's recovery phrase, remove the wallet, then import it again with that phrase.".to_string(),
}
}

/// Escapes control characters in a token name for safe display in error messages.
fn escape_token_name(name: &str) -> String {
name.chars().filter(|c| !c.is_control()).collect()
Expand Down Expand Up @@ -4644,6 +4704,65 @@ mod tests {
);
}

/// The shielded recovery messages interpolate only DET-owned fields and
/// never echo the upstream `reason` (which targets developers).
#[test]
fn shielded_recovery_displays_are_actionable_and_hide_upstream_reason() {
use platform_wallet::error::PlatformWalletError as P;
const REASON: &str = "pending spend row 7 has an ill-formed nullifier";

let corrupted = |account_index| TaskError::ShieldedRecoveryCorrupted {
account_index,
source: Box::new(P::ShieldedRecoveryCorrupted {
account_index,
reason: REASON.to_string(),
}),
};
let with_account = corrupted(Some(3)).to_string();
assert!(with_account.contains("#3"), "got: {with_account}");
let without_account = corrupted(None).to_string();
assert!(!without_account.contains('#'), "got: {without_account}");

let keys = TaskError::ShieldedRecoveryKeysRequired {
account_index: 2,
source: Box::new(P::ShieldedRecoveryKeysRequired {
account_index: 2,
reason: REASON.to_string(),
}),
}
.to_string();
assert!(keys.contains("#2"), "got: {keys}");

let identity_id = Identifier::from([0x5D; 32]);
let pending = TaskError::ShieldedIdentityDebitPending {
identity_id,
source: Box::new(P::ShieldedIdentityDebitPending {
identity_id: [0x5D; 32],
}),
}
.to_string();
assert!(
pending.contains(&identity_id.to_string(Encoding::Base58)),
"got: {pending}"
);

for msg in [&with_account, &without_account, &keys, &pending] {
assert!(!msg.contains(REASON), "upstream reason leaked: {msg}");
}
// Each action names a flow DET actually has (Remove + import with the
// recovery phrase; unlock/restore; wait) — never an absent backup flow.
for msg in [&with_account, &without_account] {
assert!(
msg.contains("recovery phrase") && msg.contains("import it again"),
"no remove-and-import action in: {msg}"
);
assert!(!msg.contains("backup"), "no backup flow exists: {msg}");
}
for msg in [&keys, &pending] {
assert!(msg.contains("then try again"), "no action in: {msg}");
}
}

#[test]
fn shielded_fee_exceeds_balance_display_shows_dash() {
let err = TaskError::ShieldedFeeExceedsBalance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ impl AppContext {
max_cycle_moment,
Some(get_epoch_reward_ratio),
last_claim.is_none(),
self.platform_version(),
)
.map_err(|e| TaskError::TokenQueryError {
detail: format!("Failed to calculate estimated rewards: {}", e),
Expand All @@ -258,6 +259,7 @@ impl AppContext {
max_cycle_moment,
None,
last_claim.is_none(),
self.platform_version(),
)
.map_err(|e| TaskError::TokenQueryError {
detail: format!("Failed to calculate estimated rewards: {}", e),
Expand Down
8 changes: 6 additions & 2 deletions src/context/contract_token_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use dash_sdk::dpp::data_contract::associated_token::token_configuration::accesso
use dash_sdk::dpp::data_contract::associated_token::token_configuration_convention::accessors::v0::TokenConfigurationConventionV0Getters;
use dash_sdk::dpp::platform_value::string_encoding::Encoding;
use dash_sdk::dpp::serialization::{
PlatformDeserializableWithPotentialValidationFromVersionedStructure,
PlatformDeserializableWithPotentialValidationFromVersionedStructureUntrusted,
PlatformSerializableWithPlatformVersion,
};
use dash_sdk::platform::{DataContract, Identifier};
Expand Down Expand Up @@ -184,7 +184,11 @@ impl AppContext {
&self,
stored: StoredContract,
) -> std::result::Result<QualifiedContract, TaskError> {
let contract = DataContract::versioned_deserialize(
// DET wrote these bytes, but the untrusted decoder accepts every valid
// stored contract under the same no-limit config and does not
// pre-allocate from length prefixes, so a corrupt local entry fails
// the decode instead of aborting on a huge allocation.
let contract = DataContract::versioned_deserialize_untrusted(
&stored.contract_bytes,
false,
self.platform_version(),
Expand Down
Loading
Loading