Skip to content

Semantic meaning of ScriptId is confusing #73

@jstolarek

Description

@jstolarek

In the off-chain code we have a SciptId data type (in the TrustlessSidechain.Versioning.ScriptId module):

data ScriptId
  = FUELMintingPolicy
  | MerkleRootTokenPolicy
  | MerkleRootTokenValidator
  | CommitteeCandidateValidator
  | CandidatePermissionPolicy
  | CommitteeHashValidator
  | DsKeyPolicy
  | DsConfPolicy
  | DsConfValidator
  | DsInsertValidator
  | CheckpointValidator
  | CheckpointPolicy
  | FUELBurningPolicy
  | VersionOraclePolicy -- not versioned
  | VersionOracleValidator -- not versioned
  | FUELProxyPolicy -- not versioned
  | CommitteeCertificateVerificationPolicy
  | CommitteeOraclePolicy
  | CommitteePlainEcdsaSecp256k1ATMSPolicy -- TODO: implement versioning for this policy (#686)
  | CommitteePlainSchnorrSecp256k1ATMSPolicy -- TODO: implement versioning for this policy (#686)
  | DParameterPolicy
  | DParameterValidator
  | PermissionedCandidatesPolicy
  | PermissionedCandidatesValidator
  | ScriptCache
  | InitTokenPolicy
  | ReserveValidator
  | ReserveAuthPolicy
  | IlliquidCirculationSupplyValidator
  | IlliquidCirculationSupplyWithdrawalPolicy
  | GovernancePolicy
  | MultiSigPolicy

This data type has custom instances of ToData and FromData that ensure its constructors are represented as integers, which is crucial for on-chain extensibility.

The problem is that the semantic meaning of ScriptId has become unclear. It was originally created to avoid using integers when retrieving scripts from the versioning system. However, we also use ScriptId when deserializing the scripts. Not all scripts are versioned, but all scripts are (de)serialized, which means there exist constructors for scripts that are not versioned.

More interestingly, there also exist abstract script identifiers. This leads to bizarre situations. Consider these two constructors:

  | GovernancePolicy
  | MultiSigPolicy

GovernancePolicy represents the currently active modular governance (cf. #48), so whenever we want to recover an active version of governance we will refer to it using the GovernancePolicy constructor. MultiSigPolicy on the other hand refers to a concrete implementation of a governance policy (possibly one of many implementations). And so when the MultiSigPolicy script gets inserted into the versioning system it will be stored under the GovernancePolicy ID, serving as an implementation of modular governance. Thus, GovernancePolicy is just an abstract identifier. The fact that we store script with one ID under a different ID in the versioning system is confusing and we should rethink how to approach this.


IOG Jira: https://input-output.atlassian.net/browse/ETCM-8062

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactoringCode cleanups and improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions