Skip to content

feat(sdk): seed devnets at protocol version 14 and persist the learned version - #4735

Merged
QuantumExplorer merged 2 commits into
v4.2-devfrom
feat/sdk-protocol-version-floor-persistence
Sep 14, 2026
Merged

QuantumExplorer merged 2 commits into
v4.2-devfrom
feat/sdk-protocol-version-floor-persistence

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

An unpinned SDK seeds its protocol version at a per-network floor and only ratchets upward from response metadata after a proof verifies (the ratchet must not consume unverified metadata). The floors were mainnet 11 and everything else 12.

Devnets are cut from the current development line, and their contracts use index grammar (rankedCountable, timeRange, ttl, skipIfAbsent) that protocol version 12 cannot deserialize. The first proved request that touched such a contract failed at the floor with value wrong type error: unexpected property name and banned the address instead of ratcheting. Yappr works around this with a warm-up query against DPNS on every page load, which costs one getDataContract round trip per load on every network.

What was done?

  • Floors. min_protocol_version seeds mainnet, testnet and regtest at 13, the lowest version any of them runs, and devnets at 14, the current version. The function is now pub so the wasm layer can consult it.
  • Observer. SdkBuilder::with_protocol_version_observer is called once per upward ratchet with the new version; never for equal, lower, zero or unknown inputs, and never on a pinned SDK. Clones share it.
  • Persistence (wasm-sdk). New protocol_version_store: on mainnet and testnet the learned version is written to localStorage under dash-sdk.protocol-version.<network>, and WasmSdkBuilder.build() seeds the next SDK from it through the existing unpinned with_initial_version. A stored value at or below the floor, or one this build does not know, is ignored. Devnets and regtest are not persisted (devnets are re-cut and already seed at the current version; regtest is local). withVersion pins and disables both the read and the write. The store is reached through js_sys::Reflect, so a missing localStorage (workers, Node) or a throwing accessor (blocked site data) is a silent no-op, not a link error.
  • Docs. The evo-sdk README documents the floors, the persistence key, and what pinning disables.

Net effect for a browser app: the first proved request of a later page load already runs at the network's version. When the stored version equals the bundled latest there is nothing left to learn, so an app-side warm-up can be skipped by checking sdk.version(). On devnets the warm-up becomes unnecessary outright.

How Has This Been Tested?

  • cargo test -p dash-sdk --lib --features mocks: 189 passed. New tests: test_per_network_floors and test_protocol_version_observer_fires_only_on_upward_ratchet (one notification per upward step; silent for equal, lower, zero, unknown; clones share the observer; a pinned SDK never notifies). Four existing ratchet tests moved their target from 12 to 14, since 12 is now below the floor.
  • cargo check and cargo clippy -p wasm-sdk --target wasm32-unknown-unknown: clean. cargo clippy -p dash-sdk --features mocks --lib --tests: clean (the only warning in either run is a pre-existing unused import in rs-drive on v4.2-dev).
  • Context: the failing bootstrap was reproduced against the moutai devnet (dev.10 nodes) with both the published evo-sdk 4.2.0-dev.10 and a native rs-sdk fetch of the Yappr social contract; forcing version 14 made both succeed.

Assumption to confirm: a 13 floor is safe only if mainnet and testnet are both at protocol version 13 or above.

Breaking Changes

None. Public API grows by SdkBuilder::with_protocol_version_observer, the ProtocolVersionObserver alias, and min_protocol_version becoming public. Default seeding behaviour changes for unpinned SDKs, upward only.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

…d version

An unpinned SDK seeds its protocol version at a per-network floor and only
ratchets upward from response metadata after a proof verifies. The floors
were mainnet 11 and everything else 12. Devnets are cut from the current
development line, and their contracts use index grammar (rankedCountable,
timeRange, ttl, skipIfAbsent) that older versions cannot deserialize, so the
first proved request that touched such a contract failed at the floor and
banned the address instead of ratcheting. Yappr works around this with a
warm-up query against DPNS on every page load.

Raise the floors: mainnet, testnet and regtest seed at 13, the lowest
version any of them runs; devnets seed at 14, the current version.

Let a host keep what auto-detect learned. `SdkBuilder::with_protocol_version_observer`
is called once per upward ratchet with the new version, never for equal,
lower, zero or unknown inputs, and never on a pinned SDK. wasm-sdk uses it
to persist the learned version in `localStorage` under
`dash-sdk.protocol-version.<network>` for mainnet and testnet, and seeds the
next builder from it through the unpinned `with_initial_version`, so the
first proved request of a later page load already runs at the network's
version. When the stored version equals the bundled latest there is nothing
left to learn and no warm-up is needed. Devnets and regtest are not
persisted; `withVersion` pins and disables both the read and the write.

`min_protocol_version` becomes public so the wasm layer can ignore a stored
value at or below the floor.

Tests: per-network floors; the observer fires exactly once per upward step,
clones share it, a pinned SDK never notifies. Existing ratchet tests move
their target from 12 to 14, since 12 is now below the floor.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 56 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 15351256-0a47-40c0-8dc2-9bffc32828d6

📥 Commits

Reviewing files that changed from the base of the PR and between 66efe32 and 7d8bcb1.

📒 Files selected for processing (6)
  • packages/js-evo-sdk/README.md
  • packages/rs-sdk/src/sdk.rs
  • packages/rs-sdk/tests/fetch/document_query_v0_v1.rs
  • packages/wasm-sdk/src/lib.rs
  • packages/wasm-sdk/src/protocol_version_store.rs
  • packages/wasm-sdk/src/sdk.rs

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

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added this to the v4.2.0 milestone Sep 14, 2026
@thepastaclaw

thepastaclaw commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 Queued for automated review — 11th in line, estimated start in ~1.4 h (commit 7d8bcb1)
Estimated review time once started: ~15 min (two-phase automated review; median of recent runs).

  • Request priority review — tick this box and the review moves to the front of the queue.

@QuantumExplorer QuantumExplorer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed

`sdk_builder_default_seeds_atomic_to_floor` repeated the mainnet floor as a
literal (`PROTOCOL_VERSION_11`), so raising the floor broke it. Take the
value from the now-public `min_protocol_version` instead, so the test follows
the SDK when the networks move on.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@QuantumExplorer
QuantumExplorer merged commit 01d9447 into v4.2-dev Sep 14, 2026
5 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/sdk-protocol-version-floor-persistence branch September 14, 2026 12:17
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.25%. Comparing base (1a16988) to head (7d8bcb1).
⚠️ Report is 4 commits behind head on v4.2-dev.

Additional details and impacted files
@@             Coverage Diff              @@
##           v4.2-dev    #4735      +/-   ##
============================================
+ Coverage     78.88%   83.25%   +4.36%     
============================================
  Files          2828     2836       +8     
  Lines        401036   389066   -11970     
============================================
+ Hits         316377   323925    +7548     
+ Misses        84659    65141   -19518     
Components Coverage Δ
dpp 83.68% <ø> (+6.63%) ⬆️
drive 84.28% <ø> (+3.20%) ⬆️
drive-abci 86.24% <ø> (+3.98%) ⬆️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 70.53% <ø> (+4.98%) ⬆️
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 36.88% <ø> (+5.37%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants