fix(cardano): inject Plutus POSIXTime in milliseconds for mempool validation#1028
fix(cardano): inject Plutus POSIXTime in milliseconds for mempool validation#1028scarmuega wants to merge 1 commit into
Conversation
…idation The phase-2 script-context evaluation in the mempool built pallas' `SlotConfig` directly from `ChainSummary`, which keeps `slot_length` and `timestamp` in seconds (the Ouroboros era-summary convention). Pallas' `SlotConfig` expects milliseconds and performs no scaling of its own (`zero_time + (slot - zero_slot) * slot_length`), so the resulting `POSIXTime` in `txInfoValidRange` was 1000x too small. Scripts that inspect the validity range (deadlines, time-locks) would mis-validate. Centralize the seconds->milliseconds conversion in a new `ChainSummary::to_pallas_slot_config()` helper and use it from `evaluate_tx`. This mirrors the existing gRPC era-summary boundary, which already multiplies `timestamp` by 1000 on output. Co-Authored-By: Claude Opus 4.8 (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 (2)
📝 WalkthroughWalkthroughA ChangesSlotConfig Unit Conversion Helper
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 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 |
Summary
Phase-2 script-context evaluation in the mempool (
evaluate_txincrates/cardano/src/validate.rs) built pallas'SlotConfigdirectly fromChainSummaryvalues, which are stored in seconds (the Ouroboros era-summary convention). Pallas'SlotConfigexpects milliseconds and does no scaling of its own:As a result the
POSIXTimeexposed intxInfoValidRangewas 1000× too small. Any Plutus script that inspects the validity range (deadlines, time-locks) would mis-validate transactions in the mempool.Root cause
ChainSummary/EraSummarykeepslot_lengthandtimestampin seconds (forks.rsdivides slot duration by 1000;start.timestampcomes fromchrono::DateTime::timestamp(), Unix seconds). Every other consumer already converts at the boundary — e.g. the gRPC era-summary path doesboundary.timestamp.saturating_mul(1000)(src/serve/grpc/*/query.rs:702). The mempool validation path was the one site that fed seconds straight into pallas' ms-basedSlotConfig.Fix
The mismatch is an impedance boundary between two libraries with different unit conventions (dolos = seconds, pallas Plutus = milliseconds). Pallas is correct as-is — its contract matches upstream
cardano-ledger'sSlotConfig— so the conversion belongs on the dolos side, at the seam.ChainSummary::to_pallas_slot_config(), which converts bothslot_lengthandzero_timefrom seconds to milliseconds in one named place, so no future call site has to remember the unit mismatch.evaluate_tx.Testing
slot_config_is_in_millisecondsusing mainnet Shelley values — the expected output (slot_length: 1000,zero_slot: 4492800,zero_time: 1596059091000) exactly matches pallas' documented mainnetSlotConfig::default().cargo clippy -p dolos-cardanoclean;cargo build --bin dolosclean.🤖 Generated with Claude Code
Summary by CodeRabbit