Skip to content

feat: upgrade Platform SDK to 5.0.1 and expose network protocol version - #41

Merged
HashEngineering merged 21 commits into
mainfrom
codex/upgrade-platform-4.2
Nov 9, 2026
Merged

HashEngineering merged 21 commits into
mainfrom
codex/upgrade-platform-4.2

Conversation

@HashEngineering

@HashEngineering HashEngineering commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Pin the SDK to the ferment-5.0.1 Platform fork, which contains the finalized upstream v5.0.1 release and the Ferment/JNI patches.
  • Publish 5.0.1-SNAPSHOT, refresh the Rust lockfiles and generated Ferment bindings, and keep the proven network protocol version API introduced earlier in this PR.
  • Check both Android 64-bit ABIs in the AAR and allow unsigned local Maven publication for the wallet's CI build.

Why

Platform v5.0.1 is the stable patch release. The SDK must track its verified network protocol version, and the wallet must consume native libraries built from the pinned Platform revision. The existing token purchase replay protection remains in place.

Validation

  • cargo check --locked --offline -p dash-sdk and cargo check --locked --offline --manifest-path platform-mobile/Cargo.toml pass against the 5.0.1 fork.
  • cargo build --locked --offline --manifest-path dash-sdk-bindings/Cargo.toml, generateSWIG, and desktop cmakeBuild pass.
  • All six token_purchase::tests and the focused Java/Kotlin tests pass.
  • Android AAR publication passes for 5.0.1-SNAPSHOT. The packaged arm64-v8a and x86_64 libraries contain the required JNI exports and have 16 KB aligned load segments.
  • Focused wallet Connect tests pass against the locally published Maven artifacts. PR CI is running.

HashEngineering and others added 3 commits September 25, 2026 11:41
Add get_protocol_version_with_sdk and refresh_protocol_version_with_sdk
exports (fermented bindings regenerated) and DapiClient.getProtocolVersion()
/ refreshProtocolVersion() wrappers. refresh issues a proven getEpochsInfo
query and ratchets dash-sdk up to the version the network runs, so wallets
can pick fees that depend on the activated protocol version (e.g. the
contested username prefunded voting balance, 0.2 -> 0.1 DASH in v14).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f6d7496f-a0b0-448c-a840-7d97ae73b277

No actionable comments were generated in the recent review.

Walkthrough

The pull request updates mobile SDK configuration and cache handling, adds protocol-version access and refresh methods, changes IdentityUpdate deserialization, and extends Rust and Java FFI bindings. It also updates build versions, Rust toolchains, and SWIG generation tasks.

Changes: Platform SDK and bindings

Layer / File(s) Summary
Mobile SDK setup and cache
platform-mobile/src/config.rs, platform-mobile/src/provider.rs, platform-mobile/src/sdk.rs, platform-mobile/src/core.rs, platform-mobile/src/fetch_document.rs, platform-mobile/src/put.rs, platform-mobile/src/put_test.rs, platform-mobile/src/data_contracts.rs
SDK setup selects Mainnet or Testnet from the configuration and no longer accepts an explicit platform version. The generic cache is replaced by DataContractCache, and SDK setup and document operations use the revised cache and setup APIs.
Protocol-version access and refresh
dpp/src/main/java/org/dashj/platform/dapiclient/DapiClient.kt, platform-mobile/src/sdk.rs
DapiClient and the mobile SDK expose methods to return the learned protocol version and to refresh it through the SDK.
IdentityUpdate deserialization
platform-mobile/src/state_transition.rs
Both exported deserialization functions use the exact untagged, untrusted decoder with IdentityUpdate as the expected type.
Rust and Java FFI bindings
dash-sdk-bindings/cbindgen.toml, dash-sdk-bindings/src/lib.rs, platform-mobile/src/clone.rs, dash-sdk-java/src/main/cpp/clone.h, dash-sdk-java/src/main/swig/*, dash-sdk-java/build.gradle, build.gradle, dash-sdk-bindings/rust-toolchain.toml, platform-mobile/rust-toolchain.toml
Rust bindings add identity-type declarations and clone helpers. SWIG adds IdentityPublicKeyV1 wrappers and updates clone and ignore directives. The Java build adds SWIG metadata generation and makes CMake builds depend on SWIG generation. The project versions and Rust toolchains are updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant DapiClient
  participant SDK
  participant PlatformNetwork
  DapiClient->>SDK: refresh protocol version
  SDK->>PlatformNetwork: query protocol version
  PlatformNetwork-->>SDK: return query result
  SDK-->>DapiClient: return version or refresh error
Loading
Merge Risk: Minimal · previous review 94907

No confirmed issue currently blocks merging. The documented refresh fallback and support for other state-transition types remain unverified.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Title check Warning The title correctly identifies exposing the network protocol version, but it incorrectly states an upgrade to Platform SDK 5.0.1. The changes and objectives target Platform 4.2-dev and SDK 4.2.0-SNAPS… Update the title to reference Platform 4.2-dev or SDK 4.2.0-SNAPSHOT, for example: "feat: upgrade Platform SDK to 4.2-dev and expose network protocol version".
Passed Passed checks: 3 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title correctly identifies exposing the network protocol version, but it incorrectly states an upgrade to Platform SDK 5.0.1. The changes and objectives target Platform 4.2-dev and SDK 4.2.0-SNAPSHOT.

Resolution

Update the title to reference Platform 4.2-dev or SDK 4.2.0-SNAPSHOT, for example: "feat: upgrade Platform SDK to 4.2-dev and expose network protocol version".

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Fix failing CI checks
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share
ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b0331e6b-51ee-4b9f-a045-8539aefe4ac8
📥 Commits

Reviewing files that changed from the base of the PR and between e6cf0fc and 949074e.

⛔ Files ignored due to path filters (3)
  • dash-sdk-android/src/main/rust/Cargo.lock is excluded by !**/*.lock
  • dash-sdk-bindings/Cargo.lock is excluded by !**/*.lock
  • platform-mobile/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (24)
  • build.gradle
  • dash-sdk-android/src/main/rust/src/fermented.rs
  • dash-sdk-bindings/cbindgen.toml
  • dash-sdk-bindings/rust-toolchain.toml
  • dash-sdk-bindings/src/fermented.rs
  • dash-sdk-bindings/src/lib.rs
  • dash-sdk-java/build.gradle
  • dash-sdk-java/src/main/cpp/clone.h
  • dash-sdk-java/src/main/swig/document.i
  • dash-sdk-java/src/main/swig/identity_public_key.i
  • dash-sdk-java/src/main/swig/ignore.i
  • dash-sdk-java/src/main/swig/root.i
  • dpp/src/main/java/org/dashj/platform/dapiclient/DapiClient.kt
  • platform-mobile/rust-toolchain.toml
  • platform-mobile/src/clone.rs
  • platform-mobile/src/config.rs
  • platform-mobile/src/core.rs
  • platform-mobile/src/data_contracts.rs
  • platform-mobile/src/fetch_document.rs
  • platform-mobile/src/provider.rs
  • platform-mobile/src/put.rs
  • platform-mobile/src/put_test.rs
  • platform-mobile/src/sdk.rs
  • platform-mobile/src/state_transition.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Expose bounded V1 identity keys, DIP-13 application key derivation, remaining budgets, and explicit devnet configuration across Rust, JNI, and Kotlin.

Fix V1 native enum widths and index-only response confirmation using the submitted PV14 nonce-derived document ID. Add regression coverage and build against HashEngineering/platform ferment-5.0.
Decode one exact unsigned direct-purchase batch, verify token identity and denomination, and rebuild approved values with a fresh nonce and an unbound CRITICAL wallet key. Reject unsupported operations and hidden fee or group changes.

Add native decoder and JNI boundary regression tests. Treat purchase proof results as affected-state snapshots rather than execution confirmation.
Replace the owner-only bridge limitation that forced the wallet to block Yappr's group-bound CRITICAL grants. Verify all member pages at one block, expose admins and each member kind, and retain explicit errors instead of partial scope. Order Android native builds after SWIG generation to prevent stale JNI wrappers. Document the rationale and verified test coverage.
@HashEngineering

Copy link
Copy Markdown
Collaborator Author

Verified Contract Group Scope

Why This Changed

The Android bridge previously returned only a contract group's owner. Owner
equality alone does not describe the authority granted by a group-bound key:
groups can contain whole contracts, document types and token positions, and
authorized administrators can add future members.

The wallet consequently rejected all group grants as a temporary safety measure.
That restriction broke Yappr's legitimate v2 login flow, whose primary CRITICAL
authentication key is group-bound. Single-contract substitution is not an
equivalent fix: the supported CRITICAL grant profile requires group bounds.

Platform already supplies proof-verifying group information and member queries.
The missing piece was the Android bridge, not a new consensus rule. This change
exposes the full verified scope so the wallet can restore group approvals with
accurate consent instead of removing verification or requiring a different QR.

Guarantees

  • fetch_contract_group_snapshot_with_sdk uses the SDK's proof-verifying Fetch
    path for owner/admin information and all three member kinds.
  • Every member page must match the information query's block height, chain ID
    and block ID. A block mismatch retries the complete snapshot up to three times;
    no mixed-block or partial result is returned.
  • Pages contain at most 100 entries. Full pages require continuation, including
    the final empty page when necessary. More than 1,000 aggregate members produces
    an explicit review-size error rather than truncating the scope.
  • Proved absence is JSON null. Transport, proof, missing-page and cursor errors
    remain errors. The Kotlin decoder rejects incomplete or duplicate scope data.
  • Kotlin member/admin sets ignore transport order. Block identity is internal
    to snapshot construction, so a newer block alone does not change consent.
  • The existing owner-only API remains available for revocation audits; revoking
    recorded keys does not depend on fetching a complete membership snapshot.

The Android CMake tasks now depend on SWIG generation. Verification caught an
ARM64 library built before the new Java/JNI name was generated. Explicit ordering
prevents packaging an old C++ wrapper with a new Java SDK. Both packaged ABIs were
checked for the new JNI symbol, and the wallet APK libraries matched those bytes.

Verification

Three offline Rust tests cover block consistency, pagination/caps and all member
kinds. Three Kotlin model tests cover decoding, semantic equality and malformed
scope. The targeted SDK regression set passed 17 tests in total.

On 2026-10-25 the Pixel 9 API 36 AOSP emulator completed the Yappr testnet login
with wallet 11.9.2-connect. Its log records a successful identity-update response
at 21:38:07 followed by system-contract response submission and lookup. This is
evidence for that tested happy path, not exhaustive live coverage of every group
size, configuration-change race or interrupted approval.

Use 24.0.0-20261024.220449-1 instead of the moving SNAPSHOT alias. Record the publicly resolved JAR checksum and snapshot retention caveat; native SDK code is unchanged.
@HashEngineering

Copy link
Copy Markdown
Collaborator Author

Pushed d475d12: pin dashj-core to the existing timestamped publication 24.0.0-20261024.220449-1 rather than the moving 24.0.0-SNAPSHOT alias. Public Gradle resolution succeeded without Maven Local; JAR SHA-256 1f2afb88ca62ab910554e3aa9bf40c240111fc3d3379da152bf59bc19e7828bd is recorded in docs/dashj-build-pin.md, along with the snapshot-retention caveat. All 17 targeted SDK regression tests passed, and the Kotlin publication metadata was regenerated locally. No native SDK source/binary change is required. Wallet PR 1604 pins this revision and forces the same timestamped DashJ build across transitives; its 568 focused wallet tests, both APK builds, lint, and full-PR Sol review passed. This commit was pushed before the dependent wallet pin.

@HashEngineering

Copy link
Copy Markdown
Collaborator Author

Purchase replay security fix pushed in e9d3709 for dashpay/dash-wallet#1604.

The bridge now returns a versioned canonical request ID from the decoded purchase fields and original identity-contract nonce, excluding ignored envelope signing-key IDs. Submission uses the existing DPP constructor to preserve that nonce, rather than allocating a fresh nonce and turning a replay into another debit. Identical terms with a new valid operation nonce remain supported. The SDK nonce cache is invalidated after successful or failed broadcast results. Affected-state proofs are still not treated as execution evidence.

Validation: six native purchase tests and 19 focused JNI/Kotlin SDK tests passed. Both Android ABIs were rebuilt; their libraries were verified byte-for-byte in the wallet devnet and testnet APKs. The full wallet pre-review also inspected this exact SDK diff and found no blockers. Its sole CI-coverage suggestion has been addressed in the wallet shared SDK build script.

Rationale and integration requirements are in docs/token-purchase-replay.md. This is a focused fix on the existing Platform revision, not the planned Platform 5.0.1 upgrade. No live or funded purchase testing is claimed.

@HashEngineering HashEngineering changed the title feat: upgrade to Platform 4.2-dev and expose the network protocol version feat: upgrade Platform SDK to 5.0.1 and expose network protocol version Oct 29, 2026
HashEngineering and others added 7 commits October 29, 2026 09:55
The application encryption path ends with a hardened 31-bit rotation level
(dashpay/dips#191, used by the App Connect DIP, dashpay/dips#181):

  m/9'/coin'/5'/7'/0'/identityId'/contractId'/purpose'/rotation'

with rotation 0' first. Without it the path becomes permanent with the first
mainnet key and a compromised or retired key could never be replaced.

platform-mobile: application_encryption_private_key_from_seed takes a
rotation (below 2^31, an error otherwise) and appends it as a hardened level.
The 8-level path without rotation stays available as
application_encryption_legacy_private_key_from_seed, only to recognise keys
that wallets registered on testnet/devnet before the rotation level existed.
Tests pin the DIP vectors for both paths (abandon x11 about, mainnet).

Bindings: Ferment output for dash-sdk-bindings and dash-sdk-android now has
the new signature and the legacy function (regenerated with cargo build of
dash-sdk-bindings; the Android copy carries the same two functions), plus a
SWIG rename for applicationEncryptionLegacyPrivateKeyFromSeed.

Kotlin: ApplicationKeyDerivation.encryption gains a required rotation
parameter, so callers must choose it; new keys use 0. The pre-rotation path
is the explicitly named legacyEncryptionWithoutRotation.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: HashEngineering <hashengineeringsolutions@gmail.com>
Declare platform_value_value_map_ValueMap before including Ferment's generated header. This fixes the CI compile failure when Value is emitted before ValueMap without changing ABI or Platform versions.

Add a native header-order regression. Verified the original and reordered generated headers, a clean C++ rebuild, and seven JNI ValueTest tests.
@HashEngineering
HashEngineering merged commit f840f46 into main Nov 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants