fix(dpp): correct misleading non-mainnet minimum-interval error message#3668
Conversation
The literal said "Minimum allowed is 100" but the enforced floor is network-dependent (the validator is the single source of truth). Display-only string reword; non-breaking, no consensus-format change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughError message for token distribution block interval validation is updated to replace the hardcoded minimum threshold text with a message indicating the interval is below the network-required minimum, making the error more descriptive and contextual. ChangesToken Distribution Error Message Update
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
🕓 Ready for review — next in queue (commit 51b73ec) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3668 +/- ##
============================================
- Coverage 88.05% 87.88% -0.18%
============================================
Files 2521 2537 +16
Lines 308781 311090 +2309
============================================
+ Hits 271908 273403 +1495
- Misses 36873 37687 +814
🚀 New features to boost your workflow:
|
Issue
InvalidTokenDistributionBlockIntervalTooShortError'sDisplayliteral assertedMinimum allowed is 100.That number is correct only on mainnet. The actual enforced floor is network-dependent (mainnet 100 / testnet 5 / devnet 2 / regtest 1), computed by the validator atpackages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/reward_distribution_type/validation/v0/mod.rs. On testnet/devnet/regtest the message lied — and it is surfaced verbatim to JS/wasm consumers viageneric_consensus_error!.Fix (Option A — string-only
Displayreword)Single line, single file: the
#[error(...)]literal now readsBlockBasedDistribution interval is too short: {interval}. It is below the network-required minimum.No hardcoded number, no per-network table baked into the message — the validator stays the single source of truth.
Why Option A, not Option B (carry the real minimum)
Option B requires adding a
minimumfield to the error struct. That struct isbincode::Encode/Decode+PlatformSerialize/PlatformDeserialize,#[platform_serialize(unversioned)], wire-encoded insideConsensusError(state-transition results / proofs). bincode encodes structs as ordered fieldless concatenation, so a field addition changes the byte layout andDecodeshape with no version discriminant to gate it — a hard, ungated breaking consensus-serialization change, plus mandatory regen of every bincode/proof vector carrying this variant. Disproportionate for a cosmetic diagnostic-string bug.The
#[error(...)]literal is pure runtimeDisplay— never serialized. Reword = zero wire impact: no struct/field/derive/serde change, error code 10272 unchanged, validator unchanged, wasm signature unchanged (JS message auto-fixed via passthrough), no vector regen. Non-breaking → plainfix, no!, noBREAKING CHANGE:footer.Scope / out of scope
100substring, so no test changed.InvalidTokenDistributionTimeIntervalTooShortError(Minimum allowed is 3,600,000 ms (1 hour)) is the same network-dependent class but is intentionally out of scope for this minimal fix — flagged here, not expanding scope.Validation
cargo check -p dppclean (only pre-existing unrelated baseline warnings).cargo clippy -p dpp -- -D warnings: no new findings — the failures are pre-existing baseline inserialization_traits.rs, proven identical on untouchedorigin/v3.1-dev.cargo test -p dpp token_perpetual_distribution: 405 passed, 0 failed.cargo check -p wasm-dpp: clean — message passthrough builds unchanged.🤖 Generated with Claude Code
Summary by CodeRabbit