Skip to content

Conversation

Hanssen0
Copy link
Member

It's definitely a mistake to name CellOnChain Cell, but there is nothing we can do with that right now. To avoid more duplicate code, CellAny was added to represent a cell that's on-chain or off-chain.

Copy link

changeset-bot bot commented Aug 16, 2025

🦋 Changeset detected

Latest commit: 71659a2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 20 packages
Name Type
@ckb-ccc/core Minor
@ckb-ccc/ssri Patch
@ckb-ccc/eip6963 Patch
@ckb-ccc/joy-id Patch
@ckb-ccc/lumos-patches Patch
@ckb-ccc/nip07 Patch
@ckb-ccc/okx Patch
@ckb-ccc/rei Patch
@ckb-ccc/shell Patch
@ckb-ccc/spore Patch
@ckb-ccc/udt Patch
@ckb-ccc/uni-sat Patch
@ckb-ccc/utxo-global Patch
@ckb-ccc/xverse Patch
@ckb-ccc/ccc Patch
ckb-ccc Patch
@ckb-ccc/connector Patch
@ckb-ccc/examples Patch
@ckb-ccc/ccc-playground Patch
@ckb-ccc/connector-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Aug 16, 2025

Deploy Preview for appccc ready!

Name Link
🔨 Latest commit 71659a2
🔍 Latest deploy log https://app.netlify.com/projects/appccc/deploys/68a123baaa495d0008247dfc
😎 Deploy Preview https://deploy-preview-262--appccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 65 (🔴 down 19 from production)
Accessibility: 88 (no change from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Aug 16, 2025

Deploy Preview for apiccc ready!

Name Link
🔨 Latest commit 71659a2
🔍 Latest deploy log https://app.netlify.com/projects/apiccc/deploys/68a123bae6cf240009a0b164
😎 Deploy Preview https://deploy-preview-262--apiccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 81 (🔴 down 2 from production)
Accessibility: 90 (no change from production)
Best Practices: 92 (no change from production)
SEO: 83 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Aug 16, 2025

Deploy Preview for liveccc ready!

Name Link
🔨 Latest commit 71659a2
🔍 Latest deploy log https://app.netlify.com/projects/liveccc/deploys/68a123ba207540000877c0b2
😎 Deploy Preview https://deploy-preview-262--liveccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 8 (🔴 down 6 from production)
Accessibility: 88 (no change from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @Hanssen0, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new CellAny class within the core module, designed to serve as a unified representation for both on-chain and off-chain cells. This change aims to reduce code duplication by allowing the existing Cell class to extend CellAny, thereby centralizing common cell-related functionalities.

Highlights

  • New Base Class: A new CellAny class has been introduced to abstract common properties and methods for both on-chain and off-chain cells.
  • Inheritance: The existing Cell class now extends CellAny, inheriting its properties and methods, which streamlines the codebase.
  • Code Refactoring: Shared methods such as capacityFree, occupiedSize, and isNervosDao have been moved from the Cell class to the new CellAny base class, promoting reusability and reducing duplication.
  • Constructor and Type Updates: The Cell class constructor has been updated to properly call the CellAny super constructor, and the CellLike type definition has been adjusted to align with the new CellAnyLike structure.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new CellAny class to represent both on-chain and off-chain cells, which is a great refactoring to reduce code duplication. The existing Cell class now extends CellAny, inheriting common functionality. The changes are well-structured and improve the overall design. I've added a couple of suggestions to further improve code conciseness and maintainability by reusing existing utilities and getters.

Copy link

netlify bot commented Aug 16, 2025

Deploy Preview for docsccc ready!

Name Link
🔨 Latest commit 71659a2
🔍 Latest deploy log https://app.netlify.com/projects/docsccc/deploys/68a123badcdb12000898132d
😎 Deploy Preview https://deploy-preview-262--docsccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 69 (🟢 up 8 from production)
Accessibility: 88 (no change from production)
Best Practices: 92 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@Hanssen0
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new CellAny class to represent both on-chain and off-chain cells, which is a great step towards reducing code duplication. The existing Cell class for on-chain cells now correctly extends CellAny, and methods like occupiedSize, capacityFree, and isNervosDao have been moved to the base class.

My main feedback is regarding property shadowing in the Cell constructor, which could be improved for better maintainability. Overall, the changes are well-structured and improve the codebase.

@Hanssen0 Hanssen0 force-pushed the feat/cell-any branch 3 times, most recently from 8bd6c41 to abc44f1 Compare August 16, 2025 23:17
@Hanssen0
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces CellAny to represent both on-chain and off-chain cells, which is a great architectural improvement. The existing Cell class now extends CellAny, effectively reducing code duplication and clarifying the distinction between on-chain and potentially off-chain cells. The changes are well-implemented. My feedback includes a couple of minor suggestions to improve code maintainability by avoiding repeated expressions.

@Hanssen0 Hanssen0 force-pushed the feat/cell-any branch 3 times, most recently from 8cbbe72 to 3cb1dad Compare August 16, 2025 23:51
@Hanssen0
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new CellAny class to represent both on-chain and off-chain cells, which is a significant improvement for code clarity and reducing duplication. The refactoring of the existing Cell class to extend CellAny and specifically represent on-chain cells is well-executed. The related changes to the Transaction class to adopt CellAny are consistent and enhance the overall API. My review includes a couple of suggestions to further improve the readability and maintainability of the new code.

@Hanssen0
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new CellAny class to represent both on-chain and off-chain cells, which is a great step towards reducing code duplication and clarifying the distinction that was previously blurred by the Cell class. The refactoring of Cell to extend CellAny is well-executed, and the related API simplifications in CellOutput and Transaction make the code cleaner and more intuitive to use. The changes are solid and improve the overall design. I have one suggestion to improve the robustness of a function call.

It's definitely a mistake to name `CellOnChain` `Cell`, but there is nothing we can do with that right now. To avoid more duplicate code, `CellAny` was added to represent a cell that's on-chain or off-chain.
@Hanssen0
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new CellAny class to represent both on-chain and off-chain cells, which is a great refactoring. The existing Cell class, which represents on-chain cells, now correctly inherits from CellAny. This change effectively reduces code duplication by moving common properties and methods like occupiedSize, capacityFree, and isNervosDao to the new base class. The related types and APIs, such as Transaction.getOutput and Transaction.addOutput, have been updated to use this new abstraction, making them cleaner and more consistent. The changes are well-implemented across the core and ssri packages. Overall, this is a high-quality contribution that improves the structure and maintainability of the codebase.

@Hanssen0
Copy link
Member Author

Finally, we make our overlord satisfied.
@phroi You know what, we should just assume the not-provided outputData is empty. Fighting with type-checking things is killing me 😭.

@phroi
Copy link
Contributor

phroi commented Aug 17, 2025

I wonder if there is a better name for CellAny

@phroi
Copy link
Contributor

phroi commented Aug 17, 2025

Also it would be nice a method for promotion to ccc.Cell by checking Client

@Hanssen0
Copy link
Member Author

I wonder if there is a better name for CellAny

This is the best I can get. Any suggestions are welcome.

Also it would be nice a method for promotion to ccc.Cell by checking Client

I think we can't get the outPoint from cellOutput and outputData?

@phroi
Copy link
Contributor

phroi commented Aug 17, 2025

I think we can't get the outPoint from cellOutput and outputData?

That's correct, I realized one minute too late 🤣

@phroi
Copy link
Contributor

phroi commented Aug 17, 2025

By the way, humor me here, a Cell(Any) has always an outpoint

@phroi
Copy link
Contributor

phroi commented Aug 17, 2025

Just the hash may change as the original transaction is modified

@phroi
Copy link
Contributor

phroi commented Aug 17, 2025

Not if we use this CellAny as template to add output cells, ok

@phroi
Copy link
Contributor

phroi commented Aug 17, 2025

I stand by my comment: all cells (input and output) in the context of a Transaction are ccc.Cell

Just the hash of outputs may change as the Transaction is updated

@Hanssen0
Copy link
Member Author

By the way, humor me here, a Cell(Any) has always an outpoint

You noticed me, it does. This point might be helpful when determining an outPoint before sending a transaction.
I might still not put it into the CellAny to avoid confusion (because of wrong outPoint, let's say Cell/CellAny's outPoint is always determined).

@phroi
Copy link
Contributor

phroi commented Aug 17, 2025

So we may actually not need ccc.CellAny

@Hanssen0
Copy link
Member Author

So we may actually not need ccc.CellAny

I would say it's still needed. Putting off chain outpoints into Cell does make sense, but will bring lots of trouble. Every place using Cell.outPoint will have to check if it's valid or not, making things more painful.

@phroi
Copy link
Contributor

phroi commented Aug 17, 2025

You probably are right, as usual. Just let's remember that even chained transactions output should be considered invalid until they are confirmed on-chain and enough time has passed, so no re-org can happen.

Otherwise even those can be invalid, say for example that an input is consumed by a competing transaction, then the outpoints become invalid

Every place using Cell.outPoint will have to check if it's valid or not, making things more painful.

This seems realistic, just could you make a realistic example?

@phroi
Copy link
Contributor

phroi commented Aug 17, 2025

[CellAny] is the best I can get. Any suggestions are welcome.

Do you fancy any of these? I asked help to GPT-o4 mini 😁

  • CellTransitional
  • CellMixed
  • CellSpectrum
  • CellSuperposition
  • CellBlend

@Hanssen0
Copy link
Member Author

You probably are right, as usual. Just let's remember that even chained transactions output should be considered invalid until they are confirmed on-chain and enough time has passed, so no re-org can happen.

Otherwise even those can be invalid, say for example that an input is consumed by a competing transaction, then the outpoints become invalid

Every place using Cell.outPoint will have to check if it's valid or not, making things more painful.

This seems realistic, just could you make a realistic example?

Client.getCell might be an example. It should handle both cached and consumed cells, but not non-existent cells. On the other hand, as you mentioned before, CellAny is also used as a parameter type, e.g. Transaction.addOutput, Udt.infoFrom, Udt.isUdt, relaxing the type requirement will make manually invoking easier.

@Hanssen0
Copy link
Member Author

[CellAny] is the best I can get. Any suggestions are welcome.

Do you fancy any of these? I asked help to GPT-o4 mini 😁

  • CellTransitional
  • CellMixed
  • CellSpectrum
  • CellSuperposition
  • CellBlend

Yea I also ask Gemini... didn't get a better name. Other names like CellEntity CellRecord CellObject... they are longer but do not provide more information than CellAny (even less).

@phroi
Copy link
Contributor

phroi commented Aug 17, 2025

Ok, the concept is sound, the code looks in order and well thought.

Just one additional question: would it make sense to add an additional parameter?

Something along the lines of type : "input"|"output" and tie to it the value of outpoint?

{ type : "input", outpoint : ccc.Outpoint} | {type:"output", outpoint : ccc.Outpoint | undefined}

@Hanssen0
Copy link
Member Author

Ok, the concept is sound, the code looks in order and well thought.

Just one additional question: would it make sense to add an additional parameter?

Something along the lines of type : "input"|"output" and tie to it the value of outpoint?

{ type : "input", outpoint : ccc.Outpoint} | {type:"output", outpoint: ccc.Outpoint | undefined}

Considering that CellAny is still mainly used as a parameter type, I would like to keep it as simple as possible.
Besides, all inputs are outputs before (except cellbases), all outputs may become inputs someday, aren't they?

@phroi
Copy link
Contributor

phroi commented Aug 17, 2025

Yeah, this may be more of a concept related to the code consuming these cells like UDT.balanceFrom/infoFrom

Looks good to me, feel free to merge!!
Phroi %41

@Hanssen0 Hanssen0 merged commit e496560 into ckb-devrel:master Aug 17, 2025
17 checks passed
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.

2 participants