w3f / polkadot-wiki

The source of truth for Polkadot.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenGov: Description of failure condition seems wrong

maltekliemann opened this issue · comments

The condition for failure of a referendum is described here:

- During the decision period, if a referendum fails to meet the approval and support thresholds for
the duration of the track-specific confirmation period, it fails and does not go to the enactment
period (it may have to be resubmitted, see below).

Seems to me like this is wrong. In fact, this is what the in-code docs say:

https://github.com/paritytech/polkadot-sdk/blob/9bf1a5e23884921498b381728bfddaae93f83744/substrate/frame/referenda/src/lib.rs#L41-L50

The difference is this: According to the wiki, if a proposal reaches the end of its decision period and has not yet been confirmed, it is rejected, even if it is confirming. According to the in-code docs (which, admittedly, aren't exactly unambiguous), however, the proposal is only rejected when it has reached the end of its decision period not confirming (passing and confirming appear to be used synonymously).

In other words, according to the in-code docs, if a proposal starts confirming one block before the end of the decision period and stays in confirming state for the duration of the confirmation period, it is approved. If the proposal ever leaves confirming state after the close of the decision period, it fails (I'm kinda guessing here).

By my cursory reading of the code and some quick experiments, I'm fairly convinced the in-code docs are correct and the wiki is wrong.

Thanks for reporting. I skimmed through the source code and observed that the time elapsed could be greater than the deciding period, provided the referendum is confirming. So, your claim "if a proposal starts confirming one block before the end of the decision period and stays in confirming state for the duration of the confirmation period, it is approved. " makes sense to me.

Time elapsed is calculated here https://github.com/paritytech/polkadot-sdk/blob/9bf1a5e23884921498b381728bfddaae93f83744/substrate/frame/referenda/src/lib.rs#L1153

If the referendum is confirming, then it lets elapsed time be greater than the deciding period here https://github.com/paritytech/polkadot-sdk/blob/9bf1a5e23884921498b381728bfddaae93f83744/substrate/frame/referenda/src/lib.rs#L1300 and if the voting tally reverses, the referendum is no longer confirming and gets rejected as the decision period has elapsed.

We will update the Wiki. Just curious how you experimented with this!

Thanks, that settles it then!

The question came up in a discussion with the Polkassembly team about why their app shows a proposal passing outside of the decision period. Played around with the tests of pallet-referendum and then verified using the Polkadot dev node.