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

Implement of Store model #41

Open
5 tasks done
yanguoyu opened this issue Nov 24, 2022 · 17 comments
Open
5 tasks done

Implement of Store model #41

yanguoyu opened this issue Nov 24, 2022 · 17 comments
Assignees
Labels
enhancement New feature or request

Comments

@yanguoyu
Copy link
Contributor

yanguoyu commented Nov 24, 2022

We can reference the design of #2

@yanguoyu yanguoyu changed the title Implement of Store Modal Implement of Store model Nov 24, 2022
@yanguoyu yanguoyu self-assigned this Nov 24, 2022
@Keith-CY
Copy link
Member

Any updates on the subtasks?

@yanguoyu yanguoyu moved this to 🏗 In progress in CKB JS Backlog Nov 30, 2022
@yanguoyu
Copy link
Contributor Author

yanguoyu commented Nov 30, 2022

Any updates on the subtasks?

#51
There are some things that need to optimize.

@Keith-CY
Copy link
Member

I found that the schema defined in #51 missed storage of type script and lock script, correct me if I'm wrong

@Keith-CY Keith-CY moved this from 🏗 In progress to 👀 In review in CKB JS Backlog Dec 21, 2022
@yanguoyu
Copy link
Contributor Author

I found that the schema defined in #51 missed storage of type script and lock script, correct me if I'm wrong

This is my considerations:
For a DApp application, they may only use one of type and lock, If they use more lock or type(it should include some contracts), they should define more than one schema.
So they should define some schema to handle type or lock, but not define type or lock in a schema.
But I think I lost data location property definition.

@Keith-CY
Copy link
Member

I found that the schema defined in #51 missed storage of type script and lock script, correct me if I'm wrong

This is my considerations: For a DApp application, they may only use one of type and lock, If they use more lock or type(it should include some contracts), they should define more than one schema. So they should define some schema to handle type or lock, but not define type or lock in a schema. But I think I lost data location property definition.

Sure, developers should define a schema for type or lock so Store could locate corresponding cells by pattern. But in current implementation, I didn't find the interface to define the schema of type or lock. Then how can we map a Store to a specific type script

@yanguoyu
Copy link
Contributor Author

I found that the schema defined in #51 missed storage of type script and lock script, correct me if I'm wrong

This is my considerations: For a DApp application, they may only use one of type and lock, If they use more lock or type(it should include some contracts), they should define more than one schema. So they should define some schema to handle type or lock, but not define type or lock in a schema. But I think I lost data location property definition.

Sure, developers should define a schema for type or lock so Store could locate corresponding cells by pattern. But in current implementation, I didn't find the interface to define the schema of type or lock. Then how can we map a Store to a specific type script

Of course, I forget the data location property definition.

@yanguoyu
Copy link
Contributor Author

A draft pr about molecule serialize and deserialize, I need to add union and option molecule type and add test case.
And it also depend on #51

@yanguoyu
Copy link
Contributor Author

I found that the schema defined in #51 missed storage of type script and lock script, correct me if I'm wrong

This is my considerations: For a DApp application, they may only use one of type and lock, If they use more lock or type(it should include some contracts), they should define more than one schema. So they should define some schema to handle type or lock, but not define type or lock in a schema. But I think I lost data location property definition.

Sure, developers should define a schema for type or lock so Store could locate corresponding cells by pattern. But in current implementation, I didn't find the interface to define the schema of type or lock. Then how can we map a Store to a specific type script

Of course, I forget the data location property definition.

I found that Storage should not care about data and witness, they only need to serialize and deserialize from the defined struct.
So I move data and witness to store class, and also add type and lock for store class.
Because I have refactor store and storage, please have a review for #51
@Keith-CY @Daryl-L @PainterPuppets @zhengjianhui

@Daryl-L
Copy link
Contributor

Daryl-L commented Dec 27, 2022

I found that the schema defined in #51 missed storage of type script and lock script, correct me if I'm wrong

This is my considerations: For a DApp application, they may only use one of type and lock, If they use more lock or type(it should include some contracts), they should define more than one schema. So they should define some schema to handle type or lock, but not define type or lock in a schema. But I think I lost data location property definition.

Sure, developers should define a schema for type or lock so Store could locate corresponding cells by pattern. But in current implementation, I didn't find the interface to define the schema of type or lock. Then how can we map a Store to a specific type script

Of course, I forget the data location property definition.

I found that Storage should not care about data and witness, they only need to serialize and deserialize from the defined struct. So I move data and witness to store class, and also add type and lock for store class. Because I have refactor store and storage, please have a review for #51 @Keith-CY @Daryl-L @PainterPuppets @zhengjianhui

I have a simple question for Storage, what do the typeData and lockData stand for?

From my perspective, when the type script is null, the Storage use lockData to stand for data in cell, and when the type script is not null, use typeData instead. Correct me if I was wrong.

@yanguoyu
Copy link
Contributor Author

I found that the schema defined in #51 missed storage of type script and lock script, correct me if I'm wrong

This is my considerations: For a DApp application, they may only use one of type and lock, If they use more lock or type(it should include some contracts), they should define more than one schema. So they should define some schema to handle type or lock, but not define type or lock in a schema. But I think I lost data location property definition.

Sure, developers should define a schema for type or lock so Store could locate corresponding cells by pattern. But in current implementation, I didn't find the interface to define the schema of type or lock. Then how can we map a Store to a specific type script

Of course, I forget the data location property definition.

I found that Storage should not care about data and witness, they only need to serialize and deserialize from the defined struct. So I move data and witness to store class, and also add type and lock for store class. Because I have refactor store and storage, please have a review for #51 @Keith-CY @Daryl-L @PainterPuppets @zhengjianhui

I have a simple question for Storage, what do the typeData and lockData stand for?

From my perspective, when the type script is null, the Storage use lockData to stand for data in cell, and when the type script is not null, use typeData instead. Correct me if I was wrong.

I mistakenly read #41 (comment), I thought it means that I should distinguish where the data was from. And I was confused thought data is in lock and type, but now I'm waking up that data is in the cell. And I will merge lockData and typeData into data.

@Keith-CY #41 (comment) this comment you want to know how to define a schema to save data in lock script or type script, I haven't designed save data in lock or type, what should we design? Save in lock args or type args, or in type and lock?

@zhengjianhui
Copy link
Contributor

I found that the schema defined in #51 missed storage of type script and lock script, correct me if I'm wrong

This is my considerations: For a DApp application, they may only use one of type and lock, If they use more lock or type(it should include some contracts), they should define more than one schema. So they should define some schema to handle type or lock, but not define type or lock in a schema. But I think I lost data location property definition.

Sure, developers should define a schema for type or lock so Store could locate corresponding cells by pattern. But in current implementation, I didn't find the interface to define the schema of type or lock. Then how can we map a Store to a specific type script

Of course, I forget the data location property definition.

I found that Storage should not care about data and witness, they only need to serialize and deserialize from the defined struct. So I move data and witness to store class, and also add type and lock for store class. Because I have refactor store and storage, please have a review for #51 @Keith-CY @Daryl-L @PainterPuppets @zhengjianhui

I have a simple question for Storage, what do the typeData and lockData stand for?
From my perspective, when the type script is null, the Storage use lockData to stand for data in cell, and when the type script is not null, use typeData instead. Correct me if I was wrong.

I mistakenly read #41 (comment), I thought it means that I should distinguish where the data was from. And I was confused thought data is in lock and type, but now I'm waking up that data is in the cell. And I will merge lockData and typeData into data.

@Keith-CY #41 (comment) this comment you want to know how to define a schema to save data in lock script or type script, I haven't designed save data in lock or type, what should we design? Save in lock args or type args, or in type and lock?

Another problem here is that the args of the cell may also hold data, but I don't see this part in the implementation

@yanguoyu
Copy link
Contributor Author

Another problem here is that the args of the cell may also hold data, but I don't see this part in the implementation

Yes, your problem is duplicate to #41 (comment)
I will add it later maybe not currently.

@Keith-CY
Copy link
Member

I found that the schema defined in #51 missed storage of type script and lock script, correct me if I'm wrong

This is my considerations: For a DApp application, they may only use one of type and lock, If they use more lock or type(it should include some contracts), they should define more than one schema. So they should define some schema to handle type or lock, but not define type or lock in a schema. But I think I lost data location property definition.

Sure, developers should define a schema for type or lock so Store could locate corresponding cells by pattern. But in current implementation, I didn't find the interface to define the schema of type or lock. Then how can we map a Store to a specific type script

Of course, I forget the data location property definition.

I found that Storage should not care about data and witness, they only need to serialize and deserialize from the defined struct. So I move data and witness to store class, and also add type and lock for store class. Because I have refactor store and storage, please have a review for #51 @Keith-CY @Daryl-L @PainterPuppets @zhengjianhui

I have a simple question for Storage, what do the typeData and lockData stand for?
From my perspective, when the type script is null, the Storage use lockData to stand for data in cell, and when the type script is not null, use typeData instead. Correct me if I was wrong.

I mistakenly read #41 (comment), I thought it means that I should distinguish where the data was from. And I was confused thought data is in lock and type, but now I'm waking up that data is in the cell. And I will merge lockData and typeData into data.

@Keith-CY #41 (comment) this comment you want to know how to define a schema to save data in lock script or type script, I haven't designed save data in lock or type, what should we design? Save in lock args or type args, or in type and lock?

Yes, Store should be able to access type script or lock script by a schema so args could be readable.

Take omnilock as an example, its args could be parsed into 6 fields

  • 21 bytes auth
  • 1 byte omnilock flag
  • 32 bytes RC cell type ID
  • 2 bytes minimum ckb/udt in ACP
  • 8 bytes since for time lock
  • 32 bytes type script hash for supply

Ref: https://blog.cryptape.com/omnilock-a-universal-lock-that-powers-interoperability-1

@Keith-CY Keith-CY added the enhancement New feature or request label Dec 27, 2022
@yanguoyu
Copy link
Contributor Author

@Daryl-L I have removed lockData and typeData by 53139ee

@Keith-CY @zhengjianhui I will add the lock args and type args schema later.

@Daryl-L
Copy link
Contributor

Daryl-L commented Jan 5, 2023

I have another simple question, about Actor and Store. When I saw the test code in pr #29, these codes came to me.

const PARENT_REF = {
  name: `parent`,
  path: `/`,
  protocol: `local`,
  uri: `local://parent`,
}

const CHILD_REF = {
  name: `child`,
  path: `/parent/`,
  protocol: `local`,
  uri: `local://parent/child`,
}
class ParentActor extends ActorBase {}
class ChildActor extends ActorBase {}

Reflect.defineMetadata(ProviderKey.Actor, { ref: PARENT_REF }, ParentActor)
Reflect.defineMetadata(ProviderKey.Actor, { ref: CHILD_REF }, ChildActor)

Let's replace the ParentActor and the ChildActor to two different Stores. And each will have multiple instances, because the lock script and type script can have different args. So what if there are more than one instances are initiated at the same time, like the parentActorA and the parentActorB? They have the same uri, how to send the message to the instance parentActorA, not the second one? Or I have the wrong understanding about the Store?

@Keith-CY
Copy link
Member

Keith-CY commented Jan 5, 2023

I have another simple question, about Actor and Store. When I saw the test code in pr #29, these codes came to me.

const PARENT_REF = {
  name: `parent`,
  path: `/`,
  protocol: `local`,
  uri: `local://parent`,
}

const CHILD_REF = {
  name: `child`,
  path: `/parent/`,
  protocol: `local`,
  uri: `local://parent/child`,
}
class ParentActor extends ActorBase {}
class ChildActor extends ActorBase {}

Reflect.defineMetadata(ProviderKey.Actor, { ref: PARENT_REF }, ParentActor)
Reflect.defineMetadata(ProviderKey.Actor, { ref: CHILD_REF }, ChildActor)

Let's replace the ParentActor and the ChildActor to two different Stores. And each will have multiple instances, because the lock script and type script can have different args. So what if there are more than one instances are initiated at the same time, like the parentActorA and the parentActorB? They have the same uri, how to send the message to the instance parentActorA, not the second one? Or I have the wrong understanding about the Store?

parentActorA and parentActorB would have different uri because they have different pattern or args, quite similar to restful API. A store could be treated as a resource (that is why it has resource binding) and restful is suitable for it.

We can define the parent uri /parent/:args, and its child should be /parent/:args/:child_id

@Keith-CY Keith-CY moved this from 👀 In review to ✅ Done in CKB JS Backlog Jan 11, 2023
@yanguoyu
Copy link
Contributor Author

#162 for molecule serialize and deserialize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

4 participants