Skip to content

fix: remove extra clone from tipset serialization#7169

Closed
akaladarshi wants to merge 1 commit into
mainfrom
akaladarshi/fix-tipset-serialization
Closed

fix: remove extra clone from tipset serialization#7169
akaladarshi wants to merge 1 commit into
mainfrom
akaladarshi/fix-tipset-serialization

Conversation

@akaladarshi

@akaladarshi akaladarshi commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary of changes

Changes introduced in this pull request:

  • While serializing the tipset we were cloning the enitre blockheader just to create a struct and then clone again for serialization.
  • Changed the field to directly use the HashLotusJson field to avoid cloning.

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

  • Refactor
    • Improved internal JSON serialization handling for Tipset data structures to use consistent type conversion patterns.

@akaladarshi akaladarshi requested a review from a team as a code owner June 11, 2026 14:00
@akaladarshi akaladarshi requested review from LesnyRumcajs and hanabi1224 and removed request for a team June 11, 2026 14:00
@akaladarshi akaladarshi added the RPC requires calibnet RPC checks to run on CI label Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8cf27881-fd36-4f83-a25d-7af9611213e8

📥 Commits

Reviewing files that changed from the base of the PR and between 45c8974 and f39f31a.

📒 Files selected for processing (1)
  • src/blocks/tipset.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)

Walkthrough

Updated Tipset Lotus JSON serialization to use HasLotusJson trait associated types for cids and blocks fields, removing field-level adapter annotations. Deserialization and serialization now employ from_lotus_json() and into_lotus_json() conversions respectively.

Changes

Tipset Lotus JSON Serialization Refactoring

Layer / File(s) Summary
Tipset Lotus JSON trait-based serialization
src/blocks/tipset.rs
TipsetLotusJsonInner field types for cids and blocks change to HasLotusJson associated types, removing explicit serde(with=...)/schemars(with=...) annotations. Deserialization converts blocks via from_lotus_json() before constructing Tipset. Serialization converts tipset.key() and tipset.block_headers() via into_lotus_json() when building TipsetLotusJsonInner.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • ChainSafe/forest#6227: Adds HasLotusJson trait support for Arc<T> and refactors RPC to use Arc<Tipset>, which directly depends on this PR's trait-based serialization plumbing for Tipset.

Suggested reviewers

  • LesnyRumcajs
  • hanabi1224
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: removing an extra clone from tipset serialization. It accurately summarizes the primary optimization in the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch akaladarshi/fix-tipset-serialization
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch akaladarshi/fix-tipset-serialization

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

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 64.37%. Comparing base (2c1f7e6) to head (f39f31a).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/blocks/tipset.rs 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/blocks/tipset.rs 84.77% <75.00%> (+0.02%) ⬆️

... and 12 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c1f7e6...f39f31a. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

RPC requires calibnet RPC checks to run on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant