Skip to content

fix(drive-abci): mimic block time truncated to whole seconds - #4477

Merged
QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/zen-yalow-a7395d
Aug 25, 2026
Merged

fix(drive-abci): mimic block time truncated to whole seconds#4477
QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/zen-yalow-a7395d

Conversation

@QuantumExplorer

@QuantumExplorerQuantumExplorer commented Aug 25, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

mimic_execute_block converts a block's time_ms into a protobuf Timestamp with the wrong scale: nanos: ((time_ms % 1000) * 1000) produces microseconds, not nanoseconds. BlockProposal::try_from converts back via to_millis() (seconds * 1000 + nanos / 1_000_000), so the sub-second part of every mimic-executed test block time was silently truncated to whole seconds — e.g. strategy tests with 300ms block spacing executed several consecutive blocks with an identical timestamp.

Same bug as the one fixed in process_proposal_collision_tests.rs on #4462 (review by @thepastaclaw), but in the shared mimic harness.

What was done?

Fixed both occurrences in packages/rs-drive-abci/src/mimic/mod.rs (prepare-proposal and process-proposal requests) to nanos: ((time_ms % 1000) * 1_000_000). Repo-wide grep confirms no other occurrence of the bad pattern remains.

How Has This Been Tested?

  • Full cargo test -p drive-abci --test strategy_tests: 95 passed, 0 failed, 4 ignored (the ignored ones are the long-running upgrade-fork tests, permanently #[ignore]d).
  • Audited every block_spacing_ms in the suite: genesis time and all spacings except 300ms are whole-second multiples, so for those tests the produced timestamps are bit-identical before/after. The only behavior-affected tests are the four run_chain_core_height_randomly_increasing_with_quorum_updates* tests (300ms spacing); all four pass — no test relied on the truncation.

Breaking Changes

None. mimic is test-only tooling (behind the mocks feature); its sole consumer is the drive-abci strategy-test harness.

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

Summary by CodeRabbit

  • Bug Fixes
    • Corrected timestamp precision in proposal processing.
    • Ensured millisecond values are accurately converted to nanoseconds for improved timing consistency.

The mimic execution converted milliseconds to protobuf Timestamp.nanos
with a microsecond scale ((time_ms % 1000) * 1000). BlockProposal
converts back via to_millis() (nanos / 1_000_000), so the sub-second
part of every mimic-executed block time was silently dropped.
Same fix as applied to process_proposal_collision_tests.rs in #4462.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actionsgithub-actionsBot added this to the v4.2.0 milestone Aug 25, 2026
@coderabbitai

coderabbitaiBot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 47e5638f-3cfe-47a8-ad13-f21ce0ba7a59

📥 Commits

Reviewing files that changed from the base of the PR and between 482da71 and 1e32dd9.

📒 Files selected for processing (1)
  • packages/rs-drive-abci/src/mimic/mod.rs

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


📝 Walkthrough

Walkthrough

The change corrects millisecond-to-nanosecond conversion in RequestPrepareProposal and RequestProcessProposal timestamps.

Changes

Proposal timestamp fix

Layer / File(s)Summary
Correct proposal timestamp conversion
packages/rs-drive-abci/src/mimic/mod.rs
The nanos calculation now multiplies the millisecond remainder by 1_000_000 for both proposal request timestamps.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk:⚪ Minimal · up to 1e32d

This localized test-harness fix corrects sub-second block timestamps, with the affected strategy tests passing; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title identifies the main change: fixing whole-second truncation of block time in the drive-abci mimic harness. It is concise and related to the changeset.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/zen-yalow-a7395d

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.

@thepastaclaw

thepastaclaw commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

ℹ️ Review superseded (commit 1e32dd9)
Last checked: 2026-08-25 09:20 UTC

@codecov

codecovBot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.78%. Comparing base (20b5b0a) to head (1e32dd9).
⚠️ Report is 3 commits behind head on v4.2-dev.

Additional details and impacted files
@@ Coverage Diff @@## v4.2-dev #4477 +/- ##
============================================
+ Coverage 86.69% 86.78% +0.08% 
============================================
Files 2735 2735 Lines 350211 350211 ============================================
+ Hits 303610 303921 +311 + Misses 46601 46290 -311 
ComponentsCoverage Δ
dpp88.84% <ø> (+<0.01%)⬆️
drive85.37% <ø> (+0.14%)⬆️
drive-abci89.18% <ø> (+0.07%)⬆️
sdk∅ <ø> (∅)
dapi-client∅ <ø> (∅)
platform-version∅ <ø> (∅)
platform-value92.92% <ø> (ø)
platform-wallet∅ <ø> (∅)
drive-proof-verifier47.03% <ø> (ø)
🚀 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.

@QuantumExplorer
QuantumExplorer merged commit d3b53db into v4.2-devAug 25, 2026
21 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/zen-yalow-a7395d branch August 25, 2026 09:18
bfoss765 added a commit that referenced this pull request Aug 25, 2026
Brings the branch up to date with upstream after #4457, #4465, #4399,
#4467, #4257, #4382, #4423, #4463, #4377, #4440, #4472, #4477, #4470,
and #4469 landed on v4.2-dev (base tip 1e26927).
One conflict, in
packages/kotlin-sdk/.../dashsdk/wallet/ManagedCoreWallet.kt: upstream
#4377 inserts a new setGapLimit() immediately above
broadcastTransaction(), while this branch rewrites that same
broadcastTransaction() — expanding its KDoc to document the age-guard
refusal and wrapping the body in mapNativeErrors { } so the native
stale-broadcast error (code 34) surfaces typed. The two edits are
additive and independent, so resolved as the union: setGapLimit() kept
verbatim from upstream, broadcastTransaction() kept verbatim from this
branch.
Three more files overlapped but auto-merged, and were verified rather
than assumed:
- changeset/core_bridge.rs: this branch factors the input walk into
spent_outpoint()/spent_outpoints() so the in-broadcast fence and the
persister's spent-set cannot disagree about which inputs count;
upstream #4257 replaces the synthetic ScriptBuf::default() with the
input's real locking script. Orthogonal — #4257 changes the Utxo
payload, the fence's filter predicate is unchanged. Both sides'
tests pass, including #4257's two new script-reconstruction tests
running through this branch's refactored walk.
- manager/mod.rs: upstream adds the tracked_masternodes field and its
initializer; this branch's SpendObservationHandler registration and
its cfg(any(test, feature = "shielded")) widening are untouched.
- rs-platform-wallet-ffi/src/error.rs: upstream adds
ErrorMasternodeListUnavailable = 46; this branch maps
PlatformWalletError::StaleReservation onto the existing shared code
34. No discriminant or name collides.
Upstream's three new PlatformWalletPersistence methods all carry default
bodies, so this branch's NoopTestPersister needs no change.
Verified: the merged tree is identical to origin/v4.2-dev except in
exactly the 18 files this branch owns, and this branch's net delta
against the new base is unchanged at +3457/-103.
cargo test -p platform-wallet --lib: 784 passed, 0 failed.
cargo test -p platform-wallet-ffi --lib: 278 passed, 0 failed.
cargo fmt --check and cargo clippy --all-targets -D warnings: clean on
both crates.
bfoss765 added a commit that referenced this pull request Aug 25, 2026
Brings the shielded-invite branch up to date with upstream v4.2-dev
(#4470 active-protocol-version shielded fees, #4472 shield credits to
an external Orchard recipient, #4477, #4469 swift async shutdown).
One conflict, in rs-platform-wallet/src/wallet/shielded/operations.rs:
both sides appended a #[cfg(test)] module at the same insertion point —
this branch's foreign_claim_guard_tests (single-flight claim lifecycle
guard, #4313 review finding 979bbc2fcb3c) and upstream #4472's
shield_recipient_tests (resolve_shield_recipient classification).
Resolved by keeping BOTH modules in full, this branch's first, each
under its own #[cfg(test)]. No code from either side dropped or
altered. The FFI error-code seam needed no hand-merge: upstream #4469's
ErrorMasternodeListUnavailable = 46 was allocated explicitly around
this branch's 43/44/45 shielded-invite trio.
Verified: cargo check -p platform-wallet --features shielded and
platform-wallet-ffi --all-features clean; cargo test platform-wallet
--features shielded --lib = 984 passed / 1 failed —
shield_input_selection_tests::regression_reports_max_from_usable_suffix
_not_total_account_balance, proven PRE-EXISTING on unmerged
origin/v4.2-dev (1e26927): upstream's versioned-fee change dropped
shield_fee_reserve_credits(LATEST) below the test's seeded 297_264_780
leading balance; the unmerged PR head passes it. platform-wallet-ffi =
330 passed / 0 failed; rs-unified-sdk-jni = 37 passed / 0 failed;
kotlin-sdk :sdk:test = 353 tests x debug+release, 0 failures.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
bfoss765 added a commit that referenced this pull request Aug 25, 2026
…4470 active-version fees + #4472 shield-to-recipient)
Reconciles the branch with the active-protocol-version fee estimation
(#4470), the shield-to-external-Orchard-recipient operation (#4472),
the block-time truncation fix (#4477) and the async wallet-manager
shutdown (#4469).
One textual conflict, packages/rs-platform-wallet-ffi/src/shielded_send.rs,
plus one silent auto-merge hazard in the same file:
- Duplicate guard helpers (auto-merged, NOT flagged by git). #4472
adopted this branch's panic-guard split verbatim, so the merge kept
BOTH copies of panic_payload_message / catch_panic_to_code /
SPEND_PANIC_GUIDANCE / catch_spend_panic. The bodies are byte
identical; this branch's copy is a strict superset (it also carries
IDENTITY_CREATE_PANIC_GUIDANCE, ASSET_LOCK_FUNDING_PANIC_GUIDANCE and
SEED_POOL_PANIC_GUIDANCE for its non-spend guard call sites). Kept
this branch's block, deleted upstream's duplicate, and widened the
SPEND_PANIC_GUIDANCE doc to name shield-to-recipient among the
operations it covers.
- The shared guard tests. Upstream re-labelled the operation string in
catch_spend_panic_maps_a_panic_to_the_unconfirmed_contract from
"shielded multi-output transfer" to "shielded shield to recipient"
and dropped the #4312 review-finding citation. Kept this branch's
labels and citation (one test name, one definition); the guard the
new export uses is exercised either way, and this branch's
catch_panic_to_code_carries_the_per_operation_contract and
max_recipients_matches_the_effective_action_ceiling tests survive.
Everything else interleaved cleanly and was verified rather than
assumed: this branch's four catch_pre_broadcast_panic sites (unshield /
transfer / transfer_multi / withdraw) and catch_pre_broadcast_panic_async
sit outside shield(), which is the only function #4472 rewrote in
operations.rs (into shield + shield_to + resolve_shield_recipient), so
both survive whole. No FFI export and no test was lost from either
side: the merged shielded_send.rs gains exactly
platform_wallet_manager_shielded_shield_to_recipient, and the only
retired test is upstream's own rename of
estimate_fee_matches_observed_onchain_values_for_2_actions into its
protocol-13 / protocol-14 / manager-handle triple.
No fee numbers needed recalibrating, and the output-aware predictor
needed no change to adopt #4470's active-version sourcing: it is
already version-parameterized end to end and every production call site
feeds it sdk.version() -- the same network-tracked accessor #4470
switched the FFI estimator to. ShieldedFeeKind::compute takes
&PlatformVersion (note_selection.rs:56); select_notes_with_fee and
select_notes_for_denomination thread it through (:197-207, :288-311);
reserve_unspent_notes and its denomination sibling pass sdk.version()
(operations.rs:2329, :2362), as do shield's fee carve (:593) and every
builder call (:647, :887, :1081, :1285, :1495, :1708, :1907).
PlatformVersion::latest() survives only in #[cfg(test)] fixtures and in
MAX_SHIELDED_TRANSFER_RECIPIENTS's ceiling assertion -- a structural
action bound, not a fee, and version-invariant in any case
(max_shielded_transition_actions = 16 and max_state_transition_size =
20480 in every system_limits version, so protocol 13 and 14 yield the
same ceiling of 6).
The shield_input_selection fixture survives because it derives:
reserve() calls shield_fee_reserve_credits(LATEST_PLATFORM_VERSION)
(platform_wallet.rs:2203) rather than pinning a literal, so it tracks
any fee-constant movement automatically. #4470 did not touch reserves
at all.
Verified: cargo fmt --check and cargo clippy clean on platform-wallet,
platform-wallet-ffi, dpp and rs-unified-sdk-jni. Tests: 942 passed
platform-wallet (--features shielded --lib), including all four
*_prover_panic_releases_the_note_reservation tests, all twelve
shield_input_selection_tests and #4472's four shield_recipient_tests;
294 passed platform-wallet-ffi (--features shielded --lib), including
#4470's estimate_fee protocol-13 / protocol-14 / manager-handle /
unknown-handle tests; 241 passed dpp shielded (--all-features --lib
shielded), including all three wire_cost_measured_tests. 0 failures.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for freeto 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

@QuantumExplorer@thepastaclaw