IntersectMBO / plutus

The Plutus language implementation and tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Previous Governance Action Id needs to be a Maybe in ScriptContext for PlutusV3

lehins opened this issue · comments

Describe the feature you'd like

5 out of 7 available governance actions require that the previous governance action id for the latest enacted proposal of the same purpose is provided. See GovernanceActionId uses below:

https://github.com/input-output-hk/plutus/blob/78b710d275ec88ec237aba848836883fc5e94ce4/plutus-ledger-api/src/PlutusLedgerApi/V3/Contexts.hs#L300-L312

Problem with requiring previous governance action id is that initially there will be no previous governance actions enacted, thus no legal value can be provided for the initial proposal procedures.

GovernanceActionId is of the form 32 byte hash with a 4 byte index.

A couple of hacky solutions has been proposed for the very first proposals:

  • Require all zeros for the hash and an index
  • Use last babbage block hash (or some other hash form ledger state) and a zero index
  • Ignore the supplied value completely for the hash and index

The proper Haskell solution is to use a Maybe, thus not require any value for the initial governance actions. This works out just fine in ledger, but it does affect PlutusV3 ScriptContext, so we need to make this decision together.

If we use a Maybe, that means throughout history of PlutusV3 scripts there will only be a handful transactions that will have a Nothing value, but I still think it is safer than all of the proposed hacky solution.

The plan would be for PlutusV4 and next era after Conway to change GovActions to have those fields required (remove the Maybe wrapping), since by then we'll have all of types of proposals enacted and the previous value will always be available.

Depending on the resolution of this ticket there might need to be a change in the implementation, or no action on Plutus side, except closing this ticket.

See the relevant PR on the ledger side that implements this change: #3615

Describe alternatives you've considered

No response

I'm happy with a Maybe. I suspect it will not often be relevant for people to look at this field, so I don't think the Nothing possibility is that problematic.

@michaelpj Beautiful, thank you.

This means, that current implementation need to be changed to:

data GovernanceAction
  = -- TODO: this is currently empty.
    ParameterChange (Maybe GovernanceActionId)
  | -- | proposal to update protocol version
    HardForkInitiation (Maybe GovernanceActionId) ProtocolVersion
  | TreasuryWithdrawals (Map V2.Credential V2.Value)
  | NoConfidence (Maybe GovernanceActionId)
  | NewCommittee
      (Maybe GovernanceActionId)
      [ColdCommitteeCredential] -- ^ Old committee
      Committee -- ^ New Committee
  | NewConstitution (Maybe GovernanceActionId) Constitution
  | InfoAction

CC @WhatisRT

Fixed by #5481.