Skip to content

Changes for new ndn-python updates - #129

Draft
suraviregmi wants to merge 5 commits into
UCLA-IRL:masterfrom
suraviregmi:new-ndn-python
Draft

suraviregmi wants to merge 5 commits into
UCLA-IRL:masterfrom
suraviregmi:new-ndn-python

Conversation

@suraviregmi

@suraviregmi suraviregmi commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Command models: the 11 TLV classes (9 in command/repo_commands.py, 2 in utils/pubsub.py) are now dataclasses.
Handlers: every handler uses the new (name, app_param, reply, context) form and replies with reply(...)
Registration: register(prefix, func) and set_interest_filter became attach_handler plus register.
Unregistering: unlisten / stop now also detach the handler, because the new unregister only removes the NFD route.
Validators: I used sha256_digest_checker everywhere the old app relied on its defaults. That was the old default for both Interests and Data, so the repo accepts and rejects the same packets as before.
Signing: the new NDNApp has no keychain, so PubSub, the four clients and DirectIngestHandle take an optional keychain=. If you leave it out, they load the default keychain, which is what the old app signed with. main.py creates one keychain and passes it in.
Examples: putfile.py and leavesync.py used to pass KeychainDigest() to NDNApp; they now pass it to the client.

Todo:
update once python-ndn PR is merged : pyproject.toml still pins python-ndn = "^0.4.2"

Reference PR: named-data/python-ndn#111

@suraviregmi

suraviregmi commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Hey @zjkmxy, I tested your updates to the python-ndn PR #111 and made the necessary changes in this PR. I was able to run the repo and verify that everything works as expected.

Once [python-ndn PR #111] is merged, could you please review this PR so we can get it merged as well?

@zjkmxy

zjkmxy commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Hey @zjkmxy, I tested your updates to the python-ndn PR #111 and made the necessary changes in this PR. I was able to run the repo and verify that everything works as expected.

Once [python-ndn PR #111] is merged, could you please review this PR so we can get it merged as well?

Sure. Let me get my diff merged first.
Based on CI signals you may also need to fix the unit tests.
Also, Python 3.10 is not supported any more in latest python-ndn.

data_name_dedupe: bool = enc.tlv_field(RepoTypeNumber.SYNC_DATA_NAME_DEDUPE, default=False)
reset: bool = enc.tlv_field(RepoTypeNumber.SYNC_RESET, default=False)
# forwarding_hint: enc.Links | None = enc.tlv_field(RepoTypeNumber.FORWARDING_HINT, default=None)
# sync_prefix: EmbName | None = enc.tlv_field(RepoTypeNumber.REGISTER_PREFIX, default=None)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This line is very confusing and should be removed.

Comment thread ndn_python_repo/handle/ingest_handle.py Outdated
async def _validate_command(self, name, sig_ptrs, context) -> ValidResult:
"""
Validate ingest command Interests with ``interest_validator``.
Unsigned commands bypass it, so that ``_on_insert_interest`` answers them with a NACK

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't seem necessary.
The protocol requires every ingest command to be signed.
If a client sends an unsigned command, it is a protocol violation, and the repo does not need to reply.
It is just like the repo does not reply if the command name "ingest" is misspelled.

@suraviregmi
suraviregmi requested a review from zjkmxy November 4, 2026 16:46
Comment thread pyproject.toml Outdated
[tool.poetry.dependencies]
python = "^3.10"
python = "^3.11"
python-ndn = "^0.5.1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Link to the specific git commit so that this can be tested on CI.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Active issues include a caller-supplied validator causing a TypeError and fetcher hang, plus an unmigrated sync example that fails with the updated dependency.

2 open issues
What changed in this PR

Migrates the repository service and clients to the updated python-ndn API and revises the direct-ingest command format.

Changes:

  • Requires Python 3.11+, pins a python-ndn revision, and converts TLV models to dataclasses.
  • Updates handlers, registration, validation, and explicit keychain handling.
  • Encapsulates ingest commands in signed Data carried by unsigned Interests, with corresponding schema, documentation, and test updates.
File Description
tests/​integration/​integration_test.py Migrates network tests and direct-ingest scenarios.
tests/​ingest_security_test.py Tests signed command Data and protocol rejection paths.
tests/​concurrent_fetcher_test.py Uses the updated application constructor.
pyproject.toml Raises the Python minimum and pins python-ndn.
ndn_python_repo/​utils/​pubsub.py Migrates message encoding, handlers, and signing.
ndn_python_repo/​utils/​passive_svs.py Updates sync parsing, transmission, and handler cleanup.
ndn_python_repo/​utils/​concurrent_fetcher.py Adopts explicit validation and response context.
ndn_python_repo/​ndn-python-repo.conf.sample Clarifies signed-command validation in a comment.
ndn_python_repo/​ingest.lvs.sample Matches timestamp and nonce components in command names.
ndn_python_repo/​handle/​write_command_handle.py Attaches insert-check handlers with explicit validation.
ndn_python_repo/​handle/​utils.py Updates single-packet fetching and raw-packet access.
ndn_python_repo/​handle/​sync_command_handle.py Parses sync commands with the dataclass decoder.
ndn_python_repo/​handle/​read_handle.py Uses reply callbacks and detaches stopped handlers.
ndn_python_repo/​handle/​ingest_handle.py Validates command Data and uses deadline-aware replies.
ndn_python_repo/​handle/​delete_command_handle.py Attaches delete-check handlers with explicit validation.
ndn_python_repo/​handle/​command_handle_base.py Updates command serialization and signed replies.
ndn_python_repo/​command/​repo_commands.py Converts command and status models to dataclasses.
ndn_python_repo/​cmd/​main.py Shares a default keychain across repository components.
ndn_python_repo/​clients/​sync.py Adds keychain injection and updated command encoding.
ndn_python_repo/​clients/​putfile.py Migrates packet creation, handlers, and command signing.
ndn_python_repo/​clients/​ingest.py Sends signed command Data inside unsigned Interests.
ndn_python_repo/​clients/​delete.py Updates command encoding and keychain handling.
ndn_python_repo/​clients/​command_checker.py Updates status queries, validation, and response decoding.
examples/​putfile.py Passes the digest keychain to the client.
examples/​leavesync.py Passes the digest keychain to the sync client.
docs/​src/​specification/​ingest.rst Documents the revised ingest format and validation rules.
docs/​src/​specification/​encoding.rst Describes ingest command Data encapsulation.
.github/​workflows/​test.yml Removes Python 3.10 from the test matrix.

Review effort: Balanced

Comment on lines +78 to +79
data_name, content, context = await app.express(
int_name, sha256_digest_checker, can_be_prefix=False, lifetime=1000, **kwargs)
Comment thread pyproject.toml
python = "^3.10"
python-ndn = "^0.5.1"
python = "^3.11"
python-ndn = { git = "https://github.com/named-data/python-ndn.git", rev = "150eb16681e324f0e17110eb6fb276d034a5916f" }
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.

4 participants