Skip to content

multiformats: rewrite CID (cid_v0 + cid_v1) module#14

Merged
uink45 merged 2 commits intomainfrom
codex/rewrite-cid-v0-v1
Feb 15, 2026
Merged

multiformats: rewrite CID (cid_v0 + cid_v1) module#14
uink45 merged 2 commits intomainfrom
codex/rewrite-cid-v0-v1

Conversation

@uink45
Copy link
Collaborator

@uink45 uink45 commented Feb 15, 2026

Summary

  • rewrote cid_v0 and cid_v1 implementations with bounded parsing/encoding flow and deterministic failure-state resets
  • redesigned cid_v1 ownership to internal bounded storage (CIDV1_MAX_MULTIHASH_SIZE) and removed heap allocation from CID rewrite scope
  • tightened CIDv1 multihash validation (version/codec varints + exact payload framing) for both bytes and string decode paths
  • expanded base-prefix handling in CIDv1 decode to include upper-case multibase prefixes where applicable
  • replaced CID test suites with broader vector-driven positive/negative/boundary coverage and known-vector regressions

Files Changed

  • include/multiformats/cid/cid_v0.h
  • include/multiformats/cid/cid_v1.h
  • src/multiformats/cid/cid_v0.c
  • src/multiformats/cid/cid_v1.c
  • tests/multiformats/cid/test_cid_v0.c
  • tests/multiformats/cid/test_cid_v1.c

Rewrite Process Artifacts

  • standards mapping + remediation record (Step 3/7/8):
    • /Users/multi/Documents/GitHub/libp2p/standards/rewrite-pilot-4-cid-v0-v1.md

Validation

  • cmake --build --preset macos-full --target cid_v0 cid_v1 test_cid_v0 test_cid_v1
  • ctest --preset macos-full -R '^(Testcid_v0|Testcid_v1)$' --output-on-failure
  • cmake --build --preset macos-full --target multibase cid_v0 cid_v1 test_multibase test_cid_v0 test_cid_v1 multiaddr test_multiaddr peer_id test_peer_id
  • ctest --preset macos-full -R '^(Testmultibase|Testcid_v0|Testcid_v1|Testmultiaddr|Testpeer_id)$' --output-on-failure
  • cmake --preset linux-asan-ubsan
  • cmake --build --preset linux-asan-ubsan --target test_cid_v0 test_cid_v1
  • ctest --preset linux-asan-ubsan -R '^(Testcid_v0|Testcid_v1)$' --output-on-failure
  • clang-format --style=file --dry-run --Werror include/multiformats/cid/cid_v0.h include/multiformats/cid/cid_v1.h src/multiformats/cid/cid_v0.c src/multiformats/cid/cid_v1.c tests/multiformats/cid/test_cid_v0.c tests/multiformats/cid/test_cid_v1.c
  • cppcheck --error-exitcode=1 --std=c99 --enable=warning,portability --quiet --suppress=missingIncludeSystem src/multiformats include/multiformats tests/multiformats src/peer_id include/peer_id tests/peer_id
  • cppcheck --std=c99 --enable=all --check-level=exhaustive --quiet --suppress=missingIncludeSystem --suppress='*:tests/*' --addon=<misra.py> -I include src/multiformats/cid include/multiformats/cid tests/multiformats/cid
  • scripts/dev/run-fast-lane-local.sh --platform macos

@uink45 uink45 merged commit 4de8db7 into main Feb 15, 2026
3 checks passed
@uink45 uink45 deleted the codex/rewrite-cid-v0-v1 branch February 15, 2026 02:29
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