Skip to content
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

Supporting Spore #252

Closed
Keith-CY opened this issue Aug 1, 2023 · 12 comments · Fixed by nervosnetwork/neuron#2810
Closed

Supporting Spore #252

Keith-CY opened this issue Aug 1, 2023 · 12 comments · Fixed by nervosnetwork/neuron#2810
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@Keith-CY
Copy link
Member

Keith-CY commented Aug 1, 2023

This protocol is not open-sourced yet, so the document is shared by magickbase google workspace at https://drive.google.com/file/d/1uQ4TMRxiF8TsEhkP_6oQoQzzsC4Q5Tbs/view?usp=sharing

SDK:


It's intended to be public on mainnet on YYYY/mm/dd, and the team hopes Neuron to support displaying its name and description(optional) in the customized assets window, similar to what m-NFT did.

The mechanism is simple as follows:

  1. detect if an unknown asset is a spore cell, if yes;
  2. parse type id of spore cluster cell(if there is) and load it;
  3. parse name and description from the spore cluster cell and display it along with the spore cell
  4. if a spore cell is not bound to a cluster, display a fallback name.
@Keith-CY Keith-CY added the documentation Improvements or additions to documentation label Aug 1, 2023
@Keith-CY Keith-CY added this to Neuron Aug 1, 2023
@Danie0918 Danie0918 moved this to 🏗 In Progress in Neuron Aug 1, 2023
@Danie0918
Copy link
Contributor

PRD : https://10x1hg.axshare.com @Keith-CY Please review.

@yanguoyu
Copy link

yanguoyu commented Aug 2, 2023

if cluster was set, then the referenced Spore Cluster Cell should appear in CellDep ,
and should follow rules below:

  1. A Spore Cluster Cell with same Type Script args set in Spore Cell 's cluster field
    must exist in both Inputs and Outputs

If the Spore cell has a cluster field in the data, we can find the cluster in the transaction input or output, then we can load the cluster cell data and get name and description. Otherwise, we will show the fallback name.
Do I understand correctly?

@Keith-CY
Copy link
Member Author

Keith-CY commented Aug 2, 2023

if cluster was set, then the referenced Spore Cluster Cell should appear in CellDep ,
and should follow rules below:

  1. A Spore Cluster Cell with same Type Script args set in Spore Cell 's cluster field
    must exist in both Inputs and Outputs

If the Spore cell has a cluster field in the data, we can find the cluster in the transaction input or output, then we can load the cluster cell data and get name and description. Otherwise, we will show the fallback name. Do I understand correctly?

The reference to the cluster cell could be found in the cell deps field

if cluster was set, then the referenced Spore Cluster Cell should appear in CellDep , and should follow rules below

@homura
Copy link

homura commented Aug 2, 2023

According to the PRD and SDK, we may need a model to adapt light client and full node.

One difficulty here is that it's a bit hard to find the cluster of a spore in light client, we may need to use fetch_tranasction to continuously resolve the OutPoint until we find the minting/issuance transition

interface SporeNftManager {
  list(): Promise<Paginate<SporeNft>>;
  getClusterBySpore(outPoint: OutPoint): Promise<Cluster>;
  transfer(options: { recipient: Address; outPoint: OutPoint }): Promise<Hash>;
}

interface LightClientSporeManager extends SporeNftManager {
  // `fetch_transaction` to find previous transaction inputs 
  // until resolvedTx.inputs.find(input => equals(input.type.scriptHash(), targetClusterTypeHash))
  getClusterBySpore(outPoint: OutPoint): Promise<Cluster>;
}

interface FullNodeSporeManager extends SporeNftManager {}

@Keith-CY Keith-CY changed the title Supporting Spore NFT Protocol Supporting Spore Aug 3, 2023
@Danie0918 Danie0918 assigned homura and unassigned Sven-TBD and Danie0918 Aug 10, 2023
@homura
Copy link

homura commented Aug 29, 2023

@Keith-CY @yanguoyu

I've created a pull request for this issue, but it has some limitations when working with the light client. Perhaps we can discuss whether the limitations are acceptable.

Limitation with The Light Client

  • expected: [ID][Cluster Name] Spore
  • actual: [ID][Cluster ID] Spore

When working with the light client in this PR, the [Cluster Name] part is displayed as a Cluster ID. This is because it is difficult to resolve the cluster cell from a spore cell, which is not owned by the wallet. To search the cluster cell that derives the spore cell, we need to:

  1. Decode the cluster_id from a spore cell's data if the spore is born from a cluster
  2. Build the type script filter of code_hash: cluster_code_hash, data: data1, args: cluster_id and search in the CKB indexer
  3. Repeat step 2 with another version of cluster scripts if the cluster cell is not found.

This limitation appears because Neuron only subscribes to lock scripts owned by a wallet, while the cluster cell may not belong to it.

Although we can subscribe to the cluster cells not owned by the wallet, it will make the light client heavier. If we subscribe to more scripts to make the features the same as the full node, the light client will lose its lightness. Therefore, I believe that the trade-off here may be acceptable.

@Keith-CY
Copy link
Member Author

@Keith-CY @yanguoyu

I've created a pull request for this issue, but it has some limitations when working with the light client. Perhaps we can discuss whether the limitations are acceptable.

Limitation with The Light Client

  • expected: [ID][Cluster Name] Spore
  • actual: [ID][Cluster ID] Spore

When working with the light client in this PR, the [Cluster Name] part is displayed as a Cluster ID. This is because it is difficult to resolve the cluster cell from a spore cell, which is not owned by the wallet. To search the cluster cell that derives the spore cell, we need to:

  1. Decode the cluster_id from a spore cell's data if the spore is born from a cluster
  2. Build the type script filter of code_hash: cluster_code_hash, data: data1, args: cluster_id and search in the CKB indexer
  3. Repeat step 2 with another version of cluster scripts if the cluster cell is not found.

This limitation appears because Neuron only subscribes to lock scripts owned by a wallet, while the cluster cell may not belong to it.
Although we can subscribe to the cluster cells not owned by the wallet, it will make the light client heavier. If we subscribe to more scripts to make the features the same as the full node, the light client will lose its lightness. Therefore, I believe that the trade-off here may be acceptable.

I have a question, a trade-off solution and a suggestion 🙈

question: why is step 2 repeated when the cluster cell is not found

trade-off solution: a link to the spore cell can be appended next to an unknown spore nft

suggestion: we may connect to light client developers for some advices.

@homura
Copy link

homura commented Aug 29, 2023

question: why is step 2 repeated when the cluster cell is not found

Since there are multiple versions of cluster scripts available, we need to try them until we find a match.

suggestion: we may connect to light client developers for some advices.

good point

@yanguoyu
Copy link

We'd better set the start block number(maybe the spore contract block number) for the cluster script when adding a cluster script to the filter. The light client will wait for the minimum synced height when we add a new script into the script filter. After all filter scripts reach the same height, they will sync together again.

The sync speed will slow if the wallet owner has many different spore clusters. Or can we get the cluster transaction hash? If so we can get the cluster detail by fetch_transaction but not wait to sync the script.

@homura
Copy link

homura commented Aug 30, 2023

Or can we get the cluster transaction hash?

When fetching the transaction of a cluster cell, one must trace back from the spore cell to find the mint transaction. However, the fetch_transaction process is async and requires a placeholder during the search.

I'm not sure it's worth increasing the workload of the light client for this process, as fetching the spore data, typically an image, is not small.

@yanguoyu
Copy link

Or can we get the cluster transaction hash?

When fetching the transaction of a cluster cell, one must trace back from the spore cell to find the mint transaction. However, the fetch_transaction process is async and requires a placeholder during the search.

I'm not sure it's worth increasing the workload of the light client for this process, as fetching the spore data, typically an image, is not small.

I guess finding the cluster cell from transaction lists is quicker than adding the script to filter because it needs to scan the block from the start block number to the cluster cell, we don't know the cluster cell's block number. And it may block other scripts' sync process.

typically an image, is not small.
It's really a point that we should consider. How much is the spore cell max image size?

@Danie0918 Danie0918 moved this from 🏗 In Progress to 🔎 Code Review in Neuron Sep 4, 2023
@Danie0918 Danie0918 moved this from 🔎 Code Review to 👀 Testing in Neuron Sep 11, 2023
@Danie0918 Danie0918 assigned FrederLu and silySuper and unassigned homura and FrederLu Sep 11, 2023
@yanguoyu
Copy link

@Danie0918 Danie0918 moved this from 👀 Testing to 🚩Pre Release in Neuron Oct 9, 2023
@Danie0918 Danie0918 moved this from 🚩Pre Release to 👀 Testing in Neuron Oct 23, 2023
@homura
Copy link

homura commented Oct 23, 2023

It is better for Neuron to support the transferring feature because the Spore Demo is only supporting Omnilock for now, otherwise, the Spores in Neuron would lose its activity

@Sven-TBD Sven-TBD moved this from 👀 Testing to 🚩Pre Release in Neuron Nov 20, 2023
@Keith-CY Keith-CY moved this from 🚩Pre Release to ✅ Done in Neuron Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants