IntersectMBO / cardano-cli

This repository contains sources for the command-line interface (CLI) tool for interacting with the Cardano blockchain.
Apache License 2.0
39 stars 15 forks source link

Remove check of drep metadata size. #818

Closed CarlosLopezDeLara closed 2 months ago

CarlosLopezDeLara commented 3 months ago

Changelog

- description: |
    Remove check of Drep metadata size, always return the hash of the file passed by the user. This to be compatible with CIP119.
    Upgrade cardano-api-9.1.0.0
# uncomment types applicable to the change:
  type:
   - feature        # introduces a new feature
   - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - refactoring    # QoL changes
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

Resolves: https://github.com/IntersectMBO/cardano-cli/issues/792 Depends on: https://github.com/IntersectMBO/cardano-api/pull/569 which is not on the tagged cardano-api-9.0.0.0 . Therefore this requires a new release of cardano-api.

How to trust this PR

Before this PR we had:

cardano-cli conway governance drep metadata-hash --drep-metadata-file drep.jsonld
Command failed: governance drep metadata-hash  Error: DRep metadata validation error: DRep metadata must consist of at most 512 bytes, but it consists of 178103 bytes.

With this PR we always return the hash and the resulting hash matches the one on the test vector of CIP-119 AND matches the hash obtained with governance hash anchor-data AND matches the result of using blake2b directly:

$ ./dist-newstyle/build/x86_64-linux/ghc-8.10.7/cardano-cli-8.25.0.0/x/cardano-cli/build/cardano-cli/cardano-cli conway governance drep metadata-hash
 --drep-metadata-file tmp/drep.jsonld 
a14a5ad4f36bddc00f92ddb39fd9ac633c0fd43f8bfa57758f9163d10ef916de

$ ./dist-newstyle/build/x86_64-linux/ghc-8.10.7/cardano-cli-8.25.0.0/x/cardano-cli/build/cardano-cli/cardano-cli conway governance hash anchor-data --file-text tmp/drep.jsonld 
a14a5ad4f36bddc00f92ddb39fd9ac633c0fd43f8bfa57758f9163d10ef916de

$ b2sum -l 256 tmp/drep.jsonld 
a14a5ad4f36bddc00f92ddb39fd9ac633c0fd43f8bfa57758f9163d10ef916de  tmp/drep.jsonld

Checklist

palas commented 2 months ago

Backup: https://github.com/IntersectMBO/cardano-cli/tree/backup/clr/drepmetadata

palas commented 2 months ago

FYI: I have rebased your branch because we have done changes to the formatting. I have made a copy of the unrebased branch that you can find in my previous comment in this PR.