Skip to content

feat: full dlcspecs #163 compliance#223

Merged
matthewjablack merged 33 commits into
masterfrom
feat/dlcspecs-pr163-full-compliance
Jun 30, 2025
Merged

feat: full dlcspecs #163 compliance#223
matthewjablack merged 33 commits into
masterfrom
feat/dlcspecs-pr163-full-compliance

Conversation

@matthewjablack
Copy link
Copy Markdown
Contributor

@matthewjablack matthewjablack commented Jun 20, 2025

feat: Implement Full dlcspecs PR #163 Compliance

BREAKING CHANGES

This is a major breaking change that completely overhauls the DLC message serialization format.

  • Message serialization format is incompatible with previous versions
  • All DLC message classes renamed (removed V0 suffixes)

Overview

This PR implements complete dlcspecs PR #163 compliance in node-dlc, transforming it from the legacy TLV format to the modern DLC specification. This massive update ensures full compatibility with rust-dlc and other modern DLC implementations.

What's Included

Core Infra Updates

  • Protocol version support - Added PROTOCOL_VERSION = 1 constant
  • New type enums - ContractInfoType, ContractDescriptorType, OracleInfoType
  • Enhanced BufferWriter/Reader - Added sibling type and optional field methods
  • Collection prefixes - Changed from u16 to bigsize throughout
  • Future-proof TLV handling - Unknown TLVs preserved for forward compatibility

Complete @node-dlc/messaging package update

  • Removed V0 suffixes - Clean class names (DlcOffer vs DlcOfferV0)
  • Updated core DLC messages:
    • DlcOffer - Added protocolVersion, temporaryContractId, bigsize collections
    • DlcAccept - Updated with new format compatibility
    • DlcSign - Updated with new format compatibility
  • Modernized type hierarchy:
    • ContractInfoSingleContractInfo/DisjointContractInfo with sibling types
    • ContractDescriptorEnumeratedContractDescriptor/NumericOutcomeContractDescriptor
    • OracleInfoSingleOracleInfo/MultiOracleInfo

Testing

  • 171 passing internal tests (100% compatibility)
  • 24 test vector files from dlcspecs + rust-dlc (5.9MB total)
  • Cross-language compatibility tests with rust-dlc
  • rust-dlc CLI tool for cross-implementation validation
  • Automated test vector processing (52 total vectors)

Finance Lib Logic Updates

  • Financial instruments - Updated options, covered calls, puts
  • Payout curves - Enhanced Hyperbola and Polynomial implementations
  • Transaction building - Updated for new serialization format
  • Storage libraries - Maintained compatibility across format changes

Key Achievements

100% Rust-DLC Compatibility

  • Perfect serialization compatibility with rust-dlc
  • Property name standardization: cetSignaturescetAdaptorSignatures
  • Structural compatibility with rust-dlc JSON formats
  • 10/10 rust-dlc test files pass validation

Modern DLC Specification

Technical Details

Breaking Changes

  • Serialization format incompatible with legacy versions
  • Class names changed (removed V0 suffixes)
  • Message structure updates require client updates

Testing

  • All existing tests pass (171/171)
  • Cross-language compatibility validated
  • rust-dlc serialization compatibility confirmed
  • Comprehensive test vector validation
  • Edge case and error condition testing

- Add protocol version support (PROTOCOL_VERSION = 1)
- Update serialization format from legacy TLV to modern DLC spec
- Add temporary_contract_id field support
- Implement sibling sub-type format with bigsize identifiers
- Change collection prefixes from u16 to bigsize
- Add TLV stream support with unknown TLV handling
- Add robust type validation and error handling
- Fix cross-package import compatibility (DlcOfferV0 → DlcOffer)

This transforms node-dlc from legacy format to modern DLC
specification standards.
• Update payout curve implementations (Hyperbola, Polynomial)
• Update transaction building logic for new format
• Update financial instruments (options, covered calls, puts)
• Update finance builder test for dlcspecs compliance
• Enhance DLC contract construction utilities
• Update DLC store for new message serialization
• Update oracle store for new oracle message format
• Update order store for dlcspecs compliance
• Update corresponding test files for new format
• Maintain storage compatibility across format changes
• Update ContractInfo tests for new sibling types
• Update negotiation field tests for dlcspecs format
• Update oracle info tests for new oracle structure
• Update order-related test suites
• Update payout function tests for new serialization
• Update messaging package README documentation
@matthewjablack matthewjablack changed the title feat: Implement Full dlcspecs PR #163 Compliance feat: full dlcspecs #163 compliance Jun 20, 2025
@matthewjablack matthewjablack force-pushed the feat/dlcspecs-pr163-full-compliance branch 6 times, most recently from 31036fc to 880a1be Compare June 24, 2025 16:17
• Add comprehensive dlcspecs compatibility test suite
• Add rust-dlc cross-language compatibility tests
• Add 24 test vector files (dlcspecs + rust-dlc formats)
• Add rust-dlc CLI tool for cross-implementation testing
• Add test vector update and validation utilities
• Enable automated cross-ecosystem compatibility validation
• Update DLC message type expectations (DlcOfferV0 → DlcOffer)
• Fix compatibility test assertions for new format
• Update order message test references (OrderAcceptV0 → OrderAccept)
• Ensure all test assertions use modern new types
• Add Rust toolchain setup for compatibility tests
• Cache cargo registry and git dependencies
• Build rust-dlc-cli before running tests
• Add conditional build for backward compatibility
• Set 10-minute timeout to prevent hanging builds
• Increase timeout from 30s to 5 minutes (300000ms)
• Handle Rust compilation and dependency downloads
• Prevent ETIMEDOUT errors in CI/CD environments
• Fix timeout issues in both compatibility test files
• Set all required properties in OrderOffer test instances
• Add missing properties: contractFlags, temporaryContractId, fundingPubkey
• Add missing properties: payoutSpk, changeSpk, serial IDs
• Fix OrderNegotiationFields tests that create OrderOffer instances
• Ensure all Buffer properties are initialized before serialization
• Align test setup with DlcOffer.spec.ts pattern
• Set all required properties in buildCsoDlcOfferFixture function
• Add missing properties: contractFlags, temporaryContractId, fundingPubkey
• Add missing properties: payoutSpk, changeSpk, serial IDs, timelock values
• Fix PayoutFunction property access: pieces → payoutFunctionPieces
• Align test setup with DlcOffer.spec.ts pattern for consistency
• Add F64 class in @node-dlc/bufio for IEEE 754 precision handling
• Update HyperbolaPayoutCurvePiece to use F64 for all f64 parameters
• Smart JSON serialization: numbers for safe values, strings for large
• Rename EnumEventDescriptorV0 to EnumEventDescriptor with compat
• Update OptionInfo imports to simplified class names
• Simplify OrderOffer by removing complex funding fields
• Add comprehensive F64 and PayoutCurvePiece precision tests
• Fix fromJSON() zero value parsing with explicit undefined checks
• Add decimal.js dependency and export F64 from bufio
- Implement F64 class for precise floating-point handling
- Fix critical contractSize calculation bug in OptionInfo extraction
- Remove V0 suffixes from class names (PayoutFunction, etc.)
- Update tests to use F64 types and new PayoutFunction structure
- Fix OrderOffer validation with missing contractFlags field
- Prevent splitIntoRanges errors with identical from/to values
- Replace number comparisons with F64.isZero() for precision
- Maintain rust-dlc JSON compatibility with exact binary precision
- Replace hardcoded test data with programmatic object creation
- Update imports to remove V0 suffixes (OrderOffer, OrderAccept)
- Create proper ContractInfo with oracle and event descriptors
- Fix test assertions to compare key fields vs full serialization
- Add missing OracleEvent properties (eventId, oracleNonces)
- Use correct property names for all message objects
- Replace hardcoded hex test data with helper functions
- Add backward compatibility for DlcAccept message parsing
- Fix test assertions using round-trip serialization
- Improve test data structure and consistency in all stores
- Add error handling for malformed/old format message parsing
- Update funding input amounts to cover collateral requirements
- Sort test arrays for consistent comparison results
- remvoes transport package entirely
- irc unreliable, should be replaced with nostr
• Move toBigInt and bigIntToNumber helpers to shared util.ts
• Remove unused imports from test and message files
• Fix F64 import in PayoutCurvePiece test
• Remove unused variables and commented test data
- replace versioned classes with Single/Disjoint enum variants
- add proper JSON serialization/deserialization support
- update all tests to use new variant-based structure
- remove unused PayoutCurvePiece MessageType entries
- implement discriminator-based wire format serialization
- add backward compatibility exports for legacy code
- Add missing lint:fix script to wire package
- Fix TypeScript Buffer compatibility issues in tests
- Update ESLint config to allow while(true) in tests
- Sync yarn format:fix with VSCode formatting behavior
- Add formatting and linting checks to CI workflow
- Configure proper import sorting with spacing
- Add .editorconfig and .prettierignore files"
@matthewjablack matthewjablack force-pushed the feat/dlcspecs-pr163-full-compliance branch from 880a1be to 535e1b0 Compare June 24, 2025 16:21
- replace FundingInputV0 with FundingInput across codebase
- update DlcCloseV0 to DlcClose with protocol_version field
- fix imports and type casting in core, leveldb packages
- update test files to use new class names
- remove V0 suffixes from DlcTransactions, DlcCancel, DlcIds, DlcInfo
- update OracleInfo to use SingleOracleInfo/MultiOracleInfo concrete types
- replace OracleIdentifierV0 with OracleIdentifier concrete class
- update MessageType enum with concrete names and backward compatibility
- migrate leveldb store prefixes to use concrete naming scheme
- update all imports and references across packages and tests
- add backward compatibility aliases for V0 classes and types
- update chain manager and store interfaces to use concrete types
- remove deprecated V0 test files and update remaining test suites
@matthewjablack matthewjablack force-pushed the feat/dlcspecs-pr163-full-compliance branch from 8514aae to ce4a439 Compare June 25, 2025 07:01
- mv F64.ts from bufio to messaging/lib/serialize/
- export F64 from messaging package index
- rm F64 export from bufio package index
- update core pkg to import F64 from messaging
- mv messaging from devDeps to deps in core
- add decimal.js dep to messaging pkg
- rm v0 suffix from EventDescriptor classes
- add backward compatibility aliases
- update Messagetype enum with aliases
- update all references to use simplified names
- improve OracleAttestation format detection
- add comprehensive test vectors for oracle messages
- support both rust-dlc and DlcSpecs formats
- add better error handling for edge cases
- add loop counter to prevent infinite loops in CETCalculator
- fix hyperbola curve inverse function edge cases
- improve polynomial curve outcome calculations
- handle constant payout curves properly
- add proper endpoint handling for hyperbola curves
- fix PayoutFunction constructor initialization
- improve CoveredCall payout function building
- add defensive fixes for array initialization
- add create-oracle-announcement cmd
- add create-oracle-attestation cmd
- improve TLV format support
- add valid sig generation for testing purposes
- add input validation in TxFinalizer
- imrove err messages and debugging
- update package-lock with decimal.js dep
- handle edge cases more gracefully
- remove `as any` casts throughout codebase for type safety
- replace duck typing with switch statements using discriminators
- update OrderNegotiationFields to use variant-based approach
- make negotiationFields optional in OrderAccept message
- use proper type discrimination for ContractInfo/OracleInfo
- fix imports and add proper TypeScript type annotations
- rm any types and add explicit return type annotations
- fix bigIntToNumber to handle large integers safely
- add eslint-disable comments for unavoidable any usage
- update varIntBytes to properly handle number|BigInt union
@matthewjablack matthewjablack merged commit cf74d3e into master Jun 30, 2025
2 checks passed
@matthewjablack matthewjablack deleted the feat/dlcspecs-pr163-full-compliance branch June 30, 2025 06:17
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.

1 participant