Repository navigation
feat(sdk): seed devnets at protocol version 14 and persist the learned version - #4735
Conversation
…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]>
|
Warning Review limit reachedNext included review available in 56 seconds. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
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. Comment |
|
🕓 Queued for automated review — 11th in line, estimated start in ~1.4 h (commit 7d8bcb1)
|
`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]>
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
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 withvalue wrong type error: unexpected property nameand banned the address instead of ratcheting. Yappr works around this with a warm-up query against DPNS on every page load, which costs onegetDataContractround trip per load on every network.What was done?
min_protocol_versionseeds mainnet, testnet and regtest at 13, the lowest version any of them runs, and devnets at 14, the current version. The function is nowpubso the wasm layer can consult it.SdkBuilder::with_protocol_version_observeris 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.protocol_version_store: on mainnet and testnet the learned version is written tolocalStorageunderdash-sdk.protocol-version.<network>, andWasmSdkBuilder.build()seeds the next SDK from it through the existing unpinnedwith_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).withVersionpins and disables both the read and the write. The store is reached throughjs_sys::Reflect, so a missinglocalStorage(workers, Node) or a throwing accessor (blocked site data) is a silent no-op, not a link error.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_floorsandtest_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 checkandcargo 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).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, theProtocolVersionObserveralias, andmin_protocol_versionbecoming public. Default seeding behaviour changes for unpinned SDKs, upward only.Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code