pallet-referenda extracted from governance umbrella PR#2714
Conversation
🛡️ AI Review — Skeptic (security review)VERDICT: VULNERABLE Baseline scrutiny: l0r1s has write permission, an established 2018 account, substantial prior subtensor history, and author/committer match; branch is governance-referenda -> devnet-ready. The PR does not modify Findings
Prior-comment reconciliation
ConclusionThis looks like a legitimate governance-pallet extraction, but 📜 Previous run (superseded)
# 🔍 AI Review — Auditor (domain review) has not yet run on this PR. |
|
🔄 AI review updated — Skeptic: VULNERABLE |
|
🔄 AI review updated — Skeptic: VULNERABLE |
| /// do not need to track whether one is currently pending. | ||
| fn set_alarm(index: ReferendumIndex, when: BlockNumberFor<T>) -> Result<(), DispatchError> { | ||
| let call = T::Preimages::bound(CallOf::<T>::from(Call::advance_referendum { index }))?; | ||
| let _ = T::Scheduler::cancel_named(alarm_name(index)); |
There was a problem hiding this comment.
[MEDIUM] Replacing an alarm can delete the only wake-up if scheduling fails
set_alarm cancels the existing alarm before attempting schedule_named. Callers such as on_tally_updated and expire_or_rearm_deadline rely on this alarm for automatic referendum progress; if schedule_named fails after the cancel, the referendum can be left Ongoing with no future wake-up except manual root intervention. Preserve the existing alarm until the replacement is known to be installed, or use a reschedule path that does not drop the old alarm on failure.
|
🔄 AI review updated — Skeptic: VULNERABLE |
|
🔄 AI review updated — Skeptic: VULNERABLE |
Summary
Part of #2198
pallet-referendaowns the referendum state machine and coordinates with avoting backend such as
pallet-signed-votingthrough the shared poll traits.What Changed
pallet-referendawithsubmit,kill,advance_referendum, andenactextrinsics.TracksInfo, includingproposer sets, voter sets, voting schemes, proposal authorization, and
per-track decision strategies.
PassOrFailreferenda for approve/reject-by-deadline decisions, withapproval either executing the call or delegating it into a child review
referendum.
Adjustablereferenda for scheduled-call timing decisions, where votescan fast-track, cancel, or shift the scheduled dispatch time.
Enactedstatus transition happen atomically.
affect new referenda.
empty/zero decision parameters, and overlapping approve/reject or
fast-track/cancel thresholds.
documentation, and unit tests covering submission, lifecycle transitions,
delegation, scheduler/preimage cleanup, voting-backend hooks, track integrity,
and try-state checks.
pad_namehelper used by fixed-width track names.Behavioral Impact
This PR adds the referenda pallet crate and supporting common helper, but does
not wire the pallet into the runtime by itself.
Once connected by a follow-up runtime integration PR, referenda will act as the
poll producer for voting backends. Submitting a referendum will create a poll,
schedule the appropriate alarm or enactment task, and notify the voting backend.
Tally updates from the backend will re-arm the referendum for deferred state
machine evaluation, keeping voting updates separate from governance execution.
The pallet supports two governance flows:
PassOrFail: a proposal is approved, rejected, or expired before a deadline.Adjustable: a proposal is scheduled up front, then votes can accelerate,cancel, or delay dispatch.
Migration / Spec Version
The new pallet defines storage, but this PR does not add it to the runtime.
Because the pallet is not wired into the runtime in this PR, there is no live
storage migration or spec-version bump required here.
A later runtime integration PR should handle runtime configuration, track
definitions, spec-version changes, and any migration implications when this
pallet is wired in.
Testing
The PR includes pallet unit tests and benchmark code for the new referenda
surface. Suggested local verification:
cargo test -p pallet-referenda