Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantic meaning of ScriptId is confusing #73

Open
jstolarek opened this issue Jul 31, 2024 · 0 comments
Open

Semantic meaning of ScriptId is confusing #73

jstolarek opened this issue Jul 31, 2024 · 0 comments
Labels
refactoring Code cleanups and improvements

Comments

@jstolarek
Copy link
Contributor

jstolarek commented Jul 31, 2024

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

@jstolarek jstolarek added bug Incorrect program behaviour refactoring Code cleanups and improvements and removed bug Incorrect program behaviour labels Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code cleanups and improvements
Projects
None yet
Development

No branches or pull requests

1 participant