Skip to content

feat(tck): implement updateTopic JSON-RPC method#2462

Draft
achintya2k5 wants to merge 4 commits into
hiero-ledger:mainfrom
achintya2k5:feat/tck-update-topic-2426
Draft

feat(tck): implement updateTopic JSON-RPC method#2462
achintya2k5 wants to merge 4 commits into
hiero-ledger:mainfrom
achintya2k5:feat/tck-update-topic-2426

Conversation

@achintya2k5

Copy link
Copy Markdown

Description:

Add the updateTopic JSON-RPC method to the TCK server, following the existing createTopic/updateAccount handler conventions.

  • Add UpdateTopicParams dataclass in tck/param/topic.py with topicId, memo, adminKey, submitKey, autoRenewPeriod, autoRenewAccountId, expirationTime, feeScheduleKey, feeExemptKeys, and customFees fields, plus JSON-RPC param parsing and validation
  • Add UpdateTopicResponse dataclass in tck/response/topic.py
  • Add _build_update_topic_transaction() helper and update_topic() handler in tck/handlers/topic.py, registered via @rpc_method("updateTopic")
  • Add unit test coverage in tests/tck/topic_test.py for param parsing, transaction building (including set-only-present-fields behavior for topicId and expirationTime), and registry wiring

Related issue(s):

Fixes #2426

Notes for reviewer:

All 11 new tests pass (pytest tests/tck/topic_test.py -v). Implementation mirrors the existing createTopic and updateAccount handlers for consistency.

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: achintya2k5 <achintyasin@gmail.com>
Copilot AI review requested due to automatic review settings July 21, 2026 11:38
@achintya2k5
achintya2k5 requested review from a team as code owners July 21, 2026 11:38
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@achintya2k5, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ad8ba7cf-42d3-4578-9b83-323cd0e3428a

📥 Commits

Reviewing files that changed from the base of the PR and between 417a9fc and f83d07f.

📒 Files selected for processing (3)
  • tck/handlers/topic.py
  • tck/param/topic.py
  • tck/response/topic.py

Walkthrough

Adds the updateTopic JSON-RPC method, including validated update parameters, transaction construction with optional fields, execution, receipt validation, and a typed status response.

Changes

Topic update operation

Layer / File(s) Summary
Topic update contracts
tck/param/topic.py, tck/response/topic.py
Defines UpdateTopicParams, validates required and fee-related fields, parses custom fees, and adds UpdateTopicResponse.
Topic update execution
tck/handlers/topic.py
Builds and executes TopicUpdateTransaction, applies provided update and common transaction fields, validates the receipt, and returns the response status.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant JSONRPC
  participant update_topic
  participant TopicUpdateTransaction
  participant HederaNetwork
  JSONRPC->>update_topic: UpdateTopicParams
  update_topic->>TopicUpdateTransaction: Build and set provided fields
  update_topic->>HederaNetwork: Execute transaction
  HederaNetwork-->>update_topic: Receipt status
  update_topic-->>JSONRPC: UpdateTopicResponse
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: implementing the updateTopic JSON-RPC method.
Description check ✅ Passed The description matches the change set and explains the new params, handler, response, and tests.
Linked Issues check ✅ Passed The changes implement the requested updateTopic method, including topicId, update fields, and present-field handling.
Out of Scope Changes check ✅ Passed No unrelated changes are apparent; the edits stay focused on updateTopic support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #2426

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

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.

Pull request overview

Adds the missing updateTopic JSON-RPC method to the TCK server so TopicUpdateTransaction test suites can run, aligning the implementation with existing topic/account handler patterns.

Changes:

  • Introduces UpdateTopicParams request model (JSON-RPC parsing/validation) and UpdateTopicResponse payload.
  • Implements _build_update_topic_transaction() plus update_topic() handler registered as updateTopic.
  • Adds unit tests covering param parsing, transaction building, and handler registry wiring.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
tests/tck/topic_test.py Adds new unit tests for updateTopic param parsing, transaction building, and registry registration.
tck/response/topic.py Adds UpdateTopicResponse dataclass for updateTopic responses.
tck/param/topic.py Adds UpdateTopicParams dataclass and JSON-RPC parsing for updateTopic.
tck/handlers/topic.py Adds TopicUpdateTransaction builder and updateTopic JSON-RPC handler.

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

Comment thread tck/handlers/topic.py
Comment thread tck/param/topic.py Outdated
Comment thread tests/tck/topic_test.py Outdated
Comment on lines +176 to +182
assert transaction.topic_id == TopicId.from_string("0.0.100")
assert transaction.memo == ""
assert transaction.admin_key is None
assert transaction.submit_key is None
assert transaction.auto_renew_period == Duration(7890000)
assert transaction.auto_renew_account is None
assert transaction.expiration_time is None
Comment thread tests/tck/topic_test.py Outdated
Comment thread tck/response/topic.py
Comment on lines +16 to +21
@dataclass
class UpdateTopicResponse:
"""Response payload for updateTopic"""

status: str | None = None

Comment thread tests/tck/topic_test.py Outdated
Comment thread tck/response/topic.py Outdated
Comment thread tck/param/topic.py Outdated
Comment thread tck/param/topic.py Outdated
Comment thread tck/param/topic.py Outdated
@github-actions github-actions Bot added open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review labels Jul 21, 2026
Comment thread tck/param/topic.py Outdated
Comment thread tests/tck/topic_test.py Outdated
@aceppaluni aceppaluni added status: update branch developer needs to click update branch status: Needs Developer Revision Author needs to apply suggested changes/improvements skill: beginner Achievable by a fairly new comer that has already completed a couple of good first issues and removed queue:junior-committer PR awaiting initial quality review open to community review PR is open for community review and feedback labels Jul 21, 2026
@hiero-ledger hiero-ledger deleted a comment from github-actions Bot Jul 21, 2026
@github-actions github-actions Bot added open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review labels Jul 21, 2026
@achintya2k5

Copy link
Copy Markdown
Author

Thank you for the review! I'll make the suggested changes and update this PR soon

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 94aea267-1092-492d-8192-ffdea6a0306e

📥 Commits

Reviewing files that changed from the base of the PR and between be42552 and 417a9fc.

📒 Files selected for processing (3)
  • tck/handlers/topic.py
  • tck/param/topic.py
  • tck/response/topic.py

Comment thread tck/handlers/topic.py
Signed-off-by: achintya2k5 <achintyasin@gmail.com>
@achintya2k5
achintya2k5 force-pushed the feat/tck-update-topic-2426 branch from 8a34b87 to 8c8d0ae Compare July 22, 2026 10:57

@exploreriii exploreriii left a comment

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.

@manishdait I think we have an issue here with the SDK
if set_auto_renew_period is str, we have Duration | int in the SDK

So we could either
temporarily override the str to int, so the tests pass, and give us time to correct the SDK in a different PR
e.g

        transaction.set_auto_renew_period(to_int(params.autoRenewPeriod))
        transaction.set_expiration_time(Timestamp(seconds=to_int(params.expirationTime), nanos=0))

or we correct the SDK as the tck tests will fail if set correct

auto_renew_period=Duration(7890000) default --> an update transaction must mean "no change" for any field the caller didn't set ---> JS SDK defaults to unset

a TopicUpdateTransaction that never touches memo still sends StringValue("") — which clears the topic's memo on-chain

_build_proto_body raising ValueError("Missing required fields: topic_id") — defer business validation to the network

Since the issue is more complicated than anticipated, i'm also happy to make the additional changes to the PR and do it as a joint effort

@exploreriii exploreriii left a comment

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.

We need to change class TopicUpdateTransaction(Transaction) regarding auto_renew_period, memo, set_expiration_time, _build_proto_body to ensure consistency with what the tck standards expect

@exploreriii

Copy link
Copy Markdown
Contributor

@achintya2k5 and @manishdait what is your preference?

@exploreriii exploreriii removed status: update branch developer needs to click update branch queue:junior-committer PR awaiting initial quality review open to community review PR is open for community review and feedback labels Jul 22, 2026
@exploreriii
exploreriii marked this pull request as draft July 22, 2026 11:26
@manishdait

Copy link
Copy Markdown
Contributor

I think using

transaction.set_auto_renew_period(to_int(params.autoRenewPeriod))
transaction.set_expiration_time(Timestamp(seconds=to_int(params.expirationTime), nanos=0))

is fine for the tck handlers. The handler is responsible for converting the rpc request parameters into the sdk types, so converting the values there makes sense.

Also we should still fix TopicUpdateTransaction and add support for set_expiration_time to have both int (seconds) and a Timestamp as param. also the current type hint is misleading since it refers to the protobuf.Timestamp object there.

So I am +1 on handling the conversion in the tck for now, while fixing the sdk behavior in a separate PR.

@achintya2k5

Copy link
Copy Markdown
Author

I agree with @manishdait , handling the conversion in the TCK handler for this PR. The handler is responsible for adapting the JSON-RPC request into the SDK types, so converting autoRenewPeriod and expirationTime there makes sense while keeping UpdateTopicParams aligned with the TCK specification.

I also feel that the TopicUpdateTransaction changes are a separate concern. The default auto_renew_period, memo behavior, set_expiration_time API, and _build_proto_body validation all affect the SDK itself and make this a broader change than the original scope of this issue. Splitting those into a dedicated issue/PR keeps this one focused on implementing the updateTopic TCK handler.

If you'd like, I'd also be happy to contribute to the SDK changes in that separate issue.

If everyone agrees with this approach, I'll update this PR with the handler-side conversions that @manishdait suggested so we can get this one ready to merge.

@exploreriii

Copy link
Copy Markdown
Contributor

Yes please, when this issue is completed, please do help by opening the other one :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skill: beginner Achievable by a fairly new comer that has already completed a couple of good first issues status: Needs Developer Revision Author needs to apply suggested changes/improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(tck): implement updateTopic JSON-RPC method

7 participants