Skip to content

fix: optimize Hash implementations and update tests for ExUnits class#57

Merged
solidsnakedev merged 4 commits into
mainfrom
feat/upgrade-modules-11
Nov 14, 2025
Merged

fix: optimize Hash implementations and update tests for ExUnits class#57
solidsnakedev merged 4 commits into
mainfrom
feat/upgrade-modules-11

Conversation

@solidsnakedev
Copy link
Copy Markdown
Collaborator

Summary

This PR fixes Transaction CBOR roundtrip equality issues and optimizes Hash implementations throughout the codebase.

Changes

Hash Optimization

  • Optimized Hash.symbol implementations to use minimal hashing strategy:
    • BootstrapWitness: only hash publicKey (identifying field)
    • ExUnitPrices: only hash memPrice
    • ExUnits: only hash mem
    • PoolVotingThresholds: only hash t1
    • DRepVotingThresholds: only hash t1
    • Redeemer: only hash tag + index
  • All Hash implementations now use Hash.cached() for performance

ExUnits Class Migration

  • Fixed computeTotalExUnits to use ExUnits class properties instead of tuple
  • Fixed Redeemer creation in TxBuilderImpl to use ExUnits class constructor
  • Updated all test files to use ExUnits class properties (.mem, .steps) instead of tuple indexing

MultiAsset Fixes

  • Fixed assetsToValue to build MultiAsset map correctly without using empty()
  • Updated all test files to access MultiAsset via .map property

Documentation

  • Removed problematic @example blocks from core modules (ProtocolVersion, TSchema, PoolParams)
  • Documentation generation now works correctly

Test Results

✅ All 652 tests passing
✅ No linting errors
✅ Documentation generation successful

- Optimize Hash.symbol implementations to use minimal hashing strategy:
  - BootstrapWitness: only hash publicKey (identifying field)
  - ExUnitPrices: only hash memPrice
  - ExUnits: only hash mem
  - PoolVotingThresholds: only hash t1
  - DRepVotingThresholds: only hash t1
  - Redeemer: only hash tag + index
- All Hash implementations use Hash.cached() for performance
- Fix computeTotalExUnits to use ExUnits class properties instead of tuple
- Fix Redeemer creation in TxBuilderImpl to use ExUnits class constructor
- Fix assetsToValue to build MultiAsset map correctly without using empty()
- Update all test files to use ExUnits class properties (.mem, .steps) instead of tuple indexing
- Update all test files to access MultiAsset via .map property
- Remove @example blocks from core modules (ProtocolVersion, TSchema, PoolParams)
- All 652 tests passing
Copilot AI review requested due to automatic review settings November 14, 2025 03:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements documentation generation improvements by updating generated API documentation to reflect new class-based schemas with enhanced equality and hash implementations. The changes primarily involve:

  • Addition of [Equal.symbol] and [Hash.symbol] method documentation for all class-based schemas
  • Addition of toJSON, toString, and [Inspectable.NodeInspectSymbol] method documentation
  • Removal of deprecated error classes, constructors, and utility functions from documentation
  • Standardization of function signatures (e.g., inputdata, a, etc.)
  • Migration from tuple-based to class-based representations for types like ExUnits, UnitInterval, and NonnegativeInterval

Reviewed Changes

Copilot reviewed 122 out of 288 changed files in this pull request and generated no comments.

Show a summary per file
File Description
VrfVkey.ts.md Added symbol method documentation, removed error classes
VrfKeyHash.ts.md Added symbol method documentation, removed error classes
VrfCert.ts.md Added symbol method documentation for VRFOutput and VRFProof
VotingProcedures.ts.md Added symbol methods, removed constructor utilities
Value.ts.md Added symbol methods for OnlyCoin and WithAssets classes
TransactionWitnessSet.ts.md Added symbol methods for TransactionWitnessSet and VKeyWitness
TransactionOutput.ts.md Added symbol methods, updated method names
TransactionInput.ts.md Added symbol methods, removed error classes
Transaction.ts.md Added symbol methods, removed error classes
Redeemer.ts.md Migrated ExUnits from tuple to class, added symbol methods
ProtocolParamUpdate.ts.md Migrated ExUnits/ExUnitPrices to classes, added symbol methods
ProposalProcedures.ts.md Added symbol methods, removed constructors
ProposalProcedure.ts.md Added symbol methods, removed error classes
MultiAsset.ts.md Migrated to class-based schema with symbol methods
NonnegativeInterval.ts.md Migrated from tuple to class-based schema
UnitInterval.ts.md Migrated from tuple to class-based schema

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@solidsnakedev solidsnakedev merged commit 123ae05 into main Nov 14, 2025
5 checks passed
@solidsnakedev solidsnakedev deleted the feat/upgrade-modules-11 branch November 14, 2025 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants