Skip to content

rs-sdk: an unpinned SDK builds testnet transitions at protocol 13 after testnet activated 14 #5495

Open

Description

@romchornyi

Expected Behavior

An unpinned SDK (platform_version = 0 over the FFI) builds its first state transitions at the protocol version the network has activated. Clients should not need a hard per-network pin to avoid transitions the network refuses.

Current Behavior

min_protocol_version seeds Testnet at 13, while testnet has activated protocol 14 (Drive 5.0.0-rc.4: getStatus reports latest / current / next = 14 / 14 / 14):

pub const fn min_protocol_version(network: Network) -> u32 {
match network {
Network::Mainnet => dpp::version::v13::PROTOCOL_VERSION_13,
Network::Testnet => dpp::version::v13::PROTOCOL_VERSION_13,
Network::Devnet => dpp::version::v14::PROTOCOL_VERSION_14,
Network::Regtest => dpp::version::v13::PROTOCOL_VERSION_13,
}
}

v5.0-dev has the same floor.

An unpinned SDK moves above the floor in only two ways:

  • when a proved response carries a newer version (maybe_update_protocol_version);
  • when the client calls refresh_protocol_version, which is opt-in.

Until then it builds state transitions with v13 tables. Some of them are refused at v14. ShieldFromAssetLock is version 1 only from v14:

shield_from_asset_lock_state_transition: FeatureVersionBounds {
min_version: 1, // changed: version 0, whose bundle binds nothing, is refused from here
max_version: 1, // changed: version 1's bundle binds its kind and its asset lock
default_current_version: 1,

A v13 build of it therefore fails at decode with StateTransitionNotActiveError (10603). The failure is uncharged, and the asset lock stays unspent until the client retries at the right version.

The FFI exposes only two choices:

fn apply_version(builder: SdkBuilder, platform_version: u32) -> Result<SdkBuilder, DashSDKError> {
if platform_version == 0 {
return Ok(builder);
}
match dash_sdk::dpp::version::PlatformVersion::get(platform_version) {
Ok(v) => Ok(builder.with_version(v)),
Err(e) => Err(DashSDKError::new(
DashSDKErrorCode::InvalidParameter,
format!("Invalid platform_version {}: {}", platform_version, e),
)),
}
}

  • 0: auto-detect from the floor;
  • any other value: with_version, which pins the SDK and turns the ratchet off.

There is no unpinned seed like the wasm-sdk's with_initial_version plus its persisted learned version (#4735).

As a result, dashwallet-ios pins testnet to 14 (dashpay/dashwallet-ios#1222), just as it pinned 13 before (dashpay/dashwallet-ios#886 and dashpay/dashwallet-ios#915). A pin never learns a newer version. It breaks again at the next activation, and v5.1-dev's latest is already 15.

Possible Solution

  1. Raise the Testnet floor in min_protocol_version to 14 on the lines testnet runs (v5.0-dev, v5.1-dev). Devnet was already raised to 14 in feat(sdk): seed devnets at protocol version 14 and persist the learned version #4735.
  2. Longer term, an unpinned SDK should not build a version-sensitive transition at a version it has not confirmed. Any of these would do:
    • ratchet through refresh_protocol_version before the first transition build;
    • or expose with_initial_version and a version observer over the FFI, so mobile clients can persist the learned version the way the wasm-sdk does.

Either change lets clients drop their per-network pins.

Steps to Reproduce (for bugs)

  1. Build an SDK from v5.1-dev with platform_version = 0 on testnet.
  2. Before any proved query, build and broadcast a ShieldFromAssetLock. In Dash Wallet iOS this is Core → Shielded right after launch, with the testnet pin removed.
  3. The node refuses it with 10603. sdk.version() still reports 13.

These steps follow from the code path above. On the app side, the failure was seen while the app was pinned to 13; an unpinned run has not been reproduced.

Context

On testnet, every Core → Shielded transfer from Dash Wallet iOS failed with 10603 after protocol 14 activated. The cause was the app's pin at 13. dashpay/dashwallet-ios#1222 moves the pin to 14. This issue covers the SDK side, so that clients need no pin.

Related: #4735 (devnet floor 14, wasm-sdk persistence), #3900 (per-network floors), #3886 / #3893 (refresh on startup).

Your Environment

  • Version used: platform v5.1-dev 1a8cc36011 (same floor on v5.0-dev 907a1b98af); testnet Drive 5.0.0-rc.4, protocol 14
  • Environment name and version: SwiftDashSDK / rs-sdk-ffi, Dash Wallet iOS develop
  • Operating System and version: iOS simulator
  • Link to your project: https://github.com/dashpay/dashwallet-ios

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions