IMPL1.md (2164B)
1 # IMPL1: ppad-bolt3 implementation plan 2 3 ## Milestone 0: groundwork 4 5 - Verify project layout and create module stubs under `lib/`. 6 - Define core newtypes and ADTs in `Lightning.Protocol.BOLT3.Types`. 7 - Add smart constructors and total helpers. 8 9 ## Milestone 1: scripts and keys 10 11 - Implement per-commitment key helpers in 12 `Lightning.Protocol.BOLT3.Keys`. 13 - Implement script templates in `Lightning.Protocol.BOLT3.Scripts`: 14 - to_local, to_remote, HTLC offered/received, anchor outputs. 15 - Witness construction helpers. 16 17 ## Milestone 2: transaction assembly 18 19 - Implement tx assembly in `Lightning.Protocol.BOLT3.Tx`: 20 - Funding transaction (if needed for completeness). 21 - Commitment tx (local/remote). 22 - HTLC-timeout and HTLC-success. 23 - Closing tx. 24 - Implement weight and fee accounting helpers. 25 26 ## Milestone 3: encode/decode 27 28 - Implement serialization in `Lightning.Protocol.BOLT3.Encode`. 29 - Implement parsing + validation in `Lightning.Protocol.BOLT3.Decode`. 30 - Implement `Lightning.Protocol.BOLT3.Validate` for stateless rules. 31 32 ## Milestone 4: public API 33 34 - Wire re-exports in `Lightning.Protocol.BOLT3`. 35 - Document exported functions with Haddock examples. 36 37 ## Milestone 5: tests and benchmarks 38 39 - Add BOLT #3 vector tests in `test/Main.hs` (tasty-hunit). 40 - Add property tests (roundtrip, fee bounds) using tasty-quickcheck. 41 - Add benchmarks for serialization + assembly in `bench/Main.hs`. 42 - Add allocation tracking in `bench/Weight.hs`. 43 44 ## Independent work items 45 46 - Keys module can proceed in parallel with Scripts. 47 - Encode/Decode modules can be developed in parallel after Types. 48 - Benchmarks can start after Encode/Tx signatures are stable. 49 50 ## Risks and mitigations 51 52 - Spec ambiguities: annotate with links to BOLT #3 sections. 53 - Performance regressions: keep strictness + benchmark early. 54 - Validation gaps: cross-check with spec vectors. 55 56 ## Deliverables 57 58 - Full BOLT #3 tx modeling and serialization. 59 - Validation helpers with total APIs. 60 - Test suite + benchmarks per project conventions. 61 62 ## Local references 63 64 - If other BOLT implementations are needed, prefer local copies in 65 sibling repos (e.g. `../bolt1`) over fetching externally.