fix(dao): clamp proposal-create validity range to per-DAO max_width

VALIDITY_RANGE_SLOTS const was hardcoded to 1799 (Sulkta's 30min budget
minus 1 slot). For tiny test DAOs (preprod_test: 30s) this overshoots
the governor's create_proposal_time_range_max_width and the validator
rejects with CekError on submit. Now: derive max width from
GovernorDatum.create_proposal_time_range_max_width / 1000 - 1, capped
at VALIDITY_RANGE_SLOTS for safety.
This commit is contained in:
Kayos 2026-05-07 17:12:10 -07:00
parent 044ebd2379
commit 66eacf5749

View file

@ -574,8 +574,16 @@ pub fn build_unsigned_proposal_create(
// pauthorizedBy on the stake checks proposer's pkh appears in
// txInfoSignatories — we disclose it explicitly so pallas-txbuilder
// knows to require + emit the corresponding witness.
// Range width must be ≤ governor.create_proposal_time_range_max_width
// (in ms; slot length on every Shelley+ network is 1 second). For
// Sulkta-shape governors with 30min windows, the legacy 1799-slot
// const fits. For tiny test DAOs (preprod_test: 30s) it must shrink
// to the per-DAO budget. Subtract 1 slot for safety against round-up.
let max_width_slots = ((args.governor.datum.create_proposal_time_range_max_width / 1_000) as u64)
.saturating_sub(1)
.min(VALIDITY_RANGE_SLOTS);
staging = staging.valid_from_slot(args.tip_slot);
staging = staging.invalid_from_slot(args.tip_slot + VALIDITY_RANGE_SLOTS);
staging = staging.invalid_from_slot(args.tip_slot + max_width_slots);
let proposer_pkh_arr: [u8; 28] = args
.proposer_pkh