Skip to content

Change VersionVector actorID encoding from hex to base64 #1030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 28, 2025

Conversation

mnnseong
Copy link
Contributor

@mnnseong mnnseong commented Jul 18, 2025

What this PR does / why we need it?

To reduce the size of serialized VersionVectors, the actorID encoding format has been changed from hex string to base64. Since actorIDs are used as keys in VersionVector objects and frequently transferred in network messages, reducing their length helps decrease payload size and improve performance. This change does not affect the semantics of the actorID, only its encoded representation.

Any background context you want to provide?

What are the relevant tickets?

Related to yorkie-team/yorkie#1388

Checklist

  • Added relevant tests or not required
  • Addressed and resolved all CodeRabbit review comments
  • Didn't break anything

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when handling version vector data by updating the encoding and decoding of actor IDs to use base64 format, ensuring consistent behavior across different environments.

To reduce the size of serialized VersionVectors, the actorID encoding
format has been changed from hex string to base64. Since actorIDs are
used as keys in VersionVector objects and frequently transferred in
network messages, reducing their length helps decrease payload size and
improve performance. This change does not affect the semantics of the
actorID, only its encoded representation.
Copy link

coderabbitai bot commented Jul 18, 2025

Walkthrough

The conversion logic for VersionVector objects to and from Protobuf format was updated to encode actor IDs as base64 strings rather than raw strings. Two new utility functions for base64 encoding and decoding of Uint8Array were introduced to ensure compatibility across different environments.

Changes

Cohort / File(s) Change Summary
VersionVector Conversion & Utilities
- packages/sdk/src/api/converter.ts
Updated VersionVector conversion logic to use base64 encoding for actor IDs; added environment-agnostic base64 utility functions (base64ToUint8Array, uint8ArrayToBase64).

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Converter
    participant Protobuf

    Client->>Converter: toVersionVector(versionVector)
    Converter->>Converter: Convert actor IDs from hex to Uint8Array
    Converter->>Converter: Encode Uint8Array to base64
    Converter->>Protobuf: Store base64 as keys in vector map

    Protobuf->>Converter: fromVersionVector(protoVector)
    Converter->>Converter: Decode base64 keys to Uint8Array
    Converter->>Converter: Convert Uint8Array to hex strings
    Converter->>Client: Return reconstructed VersionVector
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

Suggested reviewers

  • JOOHOJANG
  • hackerwins

Poem

In code we hop, from hex to base64,
Actor IDs now wear a brand new mold.
With bytes that flip and strings that twirl,
Our VersionVectors dance and swirl.
🐇✨ Base64 dreams in every key,
Encoding change for all to see!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19f238a and 3ebae76.

📒 Files selected for processing (1)
  • packages/sdk/src/api/converter.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/sdk/src/api/converter.ts
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch actorid-base64-conversion

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@CLAassistant
Copy link

CLAassistant commented Jul 18, 2025

CLA assistant check
All committers have signed the CLA.

@mnnseong mnnseong marked this pull request as ready for review July 24, 2025 07:00
@hackerwins hackerwins force-pushed the main branch 4 times, most recently from 3f1f084 to 0d6a2da Compare July 28, 2025 01:47
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 37.50000% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.91%. Comparing base (3c25f22) to head (3ebae76).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
packages/sdk/src/api/converter.ts 37.50% 11 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1030      +/-   ##
==========================================
- Coverage   78.10%   77.91%   -0.19%     
==========================================
  Files          66       66              
  Lines        5764     5788      +24     
  Branches     1043     1049       +6     
==========================================
+ Hits         4502     4510       +8     
- Misses        951      963      +12     
- Partials      311      315       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hackerwins hackerwins self-requested a review July 28, 2025 04:10
Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

@hackerwins hackerwins merged commit 1f1c176 into main Jul 28, 2025
2 checks passed
@hackerwins hackerwins deleted the actorid-base64-conversion branch July 28, 2025 04:11
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.

3 participants