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

Anchor, On-chain Linked List pallet and Name Service #1528

Merged
merged 7 commits into from
Feb 14, 2023
Merged

Anchor, On-chain Linked List pallet and Name Service #1528

merged 7 commits into from
Feb 14, 2023

Conversation

ff13dfly
Copy link
Contributor

@ff13dfly ff13dfly commented Feb 10, 2023

Project Abstract

Anchor is a on-chain linked list system base on substrate 3.0.0. It is used to support cApp ( Chain Application ) development. On another hand, Anchor can alse be treated as Name Service or on-chain key-value storage system.

Grant level

  • Level 1: Up to $10,000, 2 approvals
  • Level 2: Up to $30,000, 3 approvals
  • Level 3: Unlimited, 5 approvals (for >$100k: Web3 Foundation Council approval)

Application Checklist

  • The application template has been copied and aptly renamed (project_name.md).
  • I have read the application guidelines.
  • A BTC, Ethereum (USDC/DAI) or Polkadot/Kusama (aUSD/USDT) address for the payment of the milestones is provided in the application.
  • The software delivered for this grant will be released under an open-source license specified in the application.
  • The initial PR contains only one commit (squash and force-push if needed).
  • The grant will only be announced once the first milestone has been accepted (see the announcement guidelines).
  • I prefer the discussion of this application to take place in a private Element/Matrix channel. My username is: @_______:matrix.org (change the homeserver if you use a different one)

@CLAassistant
Copy link

CLAassistant commented Feb 10, 2023

CLA assistant check
All committers have signed the CLA.

@Noc2 Noc2 self-assigned this Feb 10, 2023
Copy link
Collaborator

@Noc2 Noc2 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 the application. I have one initial comment/question: The milestone tables currently don't contain the pallet itself or anchor.js as a delivery. Why is this? I would recommend integrating these into the milestone.

@Noc2 Noc2 added the changes requested The team needs to clarify a few things first. label Feb 10, 2023
@ff13dfly
Copy link
Contributor Author

Thanks for the application. I have one initial comment/question: The milestone tables currently don't contain the pallet itself or anchor.js as a delivery. Why is this? I would recommend integrating these into the milestone.

Hello @Noc2 ,
Sorry for the missing part. Have updated.
About the Anchor pallet, the methods can work properly now. In this apply, testing and documents mainly.
About the anchor.js, will develop a demo to show all functions base on React.

You can access the [freeSaying ( Only applicable to mobile )](https://freesaying.net) demo to know well. Anchor network is the very important basic storage system. Anchor.js is a isolate JS library to access Anchor network, can read and write data easily.
Anchor pallet is a part of EasyPolka, the relationship as follow :

![easypolka.png](http://android.im/anchor/easypolka.png)
Copy link
Member

Choose a reason for hiding this comment

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

What are cSaying and cHome here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What are cSaying and cHome here?

Hello @semuelle , sorry for the slow response. "cSaying" and "cHome" is cApp ( Chain Application ) which are the pure JS code stored on-chain by Anchor.
For example, such JS code can be launched by "saying" that the plinth for cApp.

/* cApp basic structure.
*   @param RPC          object      //RPC object from plinth
*   @param container    string      //html DOM id for the cApp as container
*   @param error        object      //Error object from plinth
*/
;(function(RPC,container,error){
    // normal console log.
    console.log("Hello world, this is from cApp.");
    console.log(`Dom container id : ${container}`);
    console.log(`Error from pedestal : ${JSON.stringify(error)}`);

   // call RPC from plinth to access Anchor network
    var ss58="5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
    RPC.common.balance(ss58,function(res){
        console.log(res);
    });

})(RPC,domID,error);

So the data sent to setAnchor will be like this :

{
  "key":"any_name",
  "raw":"JS string above",
  "protocol": JSON.stringify({"type":"app","format":"JS","ver":"0.0.1"}),
  "pre":0
}

QR to access to freesaying.net.
![easypolka.png](http://android.im/anchor/qr.png)

- With Anchor, you can use run a substate network just need a bit upgrade. Through the highly customizable data structure and the ability of cApp, the threshold of application development on the chain is greatly reduced. It means that new developers who even does not know blockchain well can build cApp just by Javascript and publish it nearly free.
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain what development with Anchor instead of, say, Substrate or ink looks like and how it is easier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you explain what development with Anchor instead of, say, Substrate or ink looks like and how it is easier?

The reason is that developer who just has the skill of pure Javascript can join the blockchain development.
The follow is the structure of EasyPolka, after the green part developed well, only the two red parts left to care about.

EasyPolka_bluemap.png

  1. cApp part, it is pure JS coding. I think after some basic work, current JS applications can be converted to it.
  2. vService part, it is based on Node.js right now. Some of the services such as the cache for the on-chain data can be shared. Only some new function need to develop.

About ink or smart contract, I am not working on them actually, so just my view.
They are used for Financial Application very well. But for the normal applications, coins is not always the main thing to think about. That's Anchor pallet benefit, care about trusted data instead of coins.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, missing some details.
I have tried to work on smart contract , but failed. I can read the code , but can not make it work.
Will try again, I think I know substrate much better than the point I tried it, :-)

origin: OriginFor<T>, //default
key: Vec<u8>, //Anchor name
raw: Vec<u8>, //raw data to storage
protocol: Vec<u8>, //data protocol, used to decide how to decode raw data
Copy link
Member

Choose a reason for hiding this comment

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

What is protocol here and what does it do? Can you give an example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is protocol here and what does it do? Can you give an example?

There are two samples that I used for the cApp freeSaying.net.

  1. cApp protocol.
{
  "key":"any_name",
  "raw":"JS string above",
  "protocol": JSON.stringify({"type":"app","format":"JS","ver":"0.0.1"}),
  "pre":0
}
  1. data protocol
{
  "key":"any_name",
  "raw":JSON.stringify({"any":"object"}),
  "protocol": JSON.stringify({"type":"data","format":"JSON"}),
  "pre":0
}

cApp can subscribe the latest block and decode the data , if the protocol is supported by the cApp, it can be used by the cApp.
In short, the protocol is highly customized for the developer.


- **Total Estimated Duration:** 1 month
- **Full-Time Equivalent (FTE):** 1
- **Total Costs:** 6,000USD
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- **Total Costs:** 6,000USD
- **Total Costs:** 6,000 USD

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello, @keeganquigley , sorry for the slow response.
I will modify it and update.

@keeganquigley
Copy link
Contributor

Thanks for the application @ff13dfly, in addition to the comments above, our payment options have also changed recently. Can you either switch to USDC/DAI or provide a Polkadot address if you prefer using Statemint?

Also are you able to expand upon your future plans a bit? How do you plan to maintain it? Do you plan to apply for a follow-up grant, or other means of funding? Thanks!

@ff13dfly
Copy link
Contributor Author

Thanks for the application @ff13dfly, in addition to the comments above, our payment options have also changed recently. Can you either switch to USDC/DAI or provide a Polkadot address if you prefer using Statemint?

Thank you for reminding, will modify and update.

Also are you able to expand upon your future plans a bit? How do you plan to maintain it? Do you plan to apply for a follow-up grant, or other means of funding? Thanks!

Yes, I want to apply for a follow-up grant if it is helpful for Polkadot ecosystem. About funding, that's great if there is a chance, :-)

@semuelle
Copy link
Member

Thanks for the updates, @ff13dfly, but I'm still not quite sure I understand where/how this is going to be used.

  • What is plinth?
  • Are you planning to bid on a parachain slot on Polkadot/Kusama yourself, or where do you see the Anchor pallet being used?
  • What is the point of selling anchors? It sounds like a security issue if I could buy someone else's anchor and replace its content with my own code when others might be relying on it.
  • If I store some JS code on (an) Anchor, where do you suggest the data being generated by those apps to be stored? Would be it be somewhere centralised, or on Anchor? With the latter, it would have to be stored by adding new anchors or by appending to a single anchor each time. I'm not sure the upside of simplified development is worth the extra work of handling the data. Can you comment on this?

@ff13dfly
Copy link
Contributor Author

ff13dfly commented Feb 14, 2023

Thanks for the updates, @ff13dfly, but I'm still not quite sure I understand where/how this is going to be used.

Hello @semuelle , will try to explain in details.

  • What is plinth?

Right now, for the demo cApp , it is a React application which groups the RPC calls and manage the account ( create or load from encry JSON file ).
Then the cApp do not need to care about which node or server to link.

  • Are you planning to bid on a parachain slot on Polkadot/Kusama yourself, or where do you see the Anchor pallet being used?

For me, Yes, hope to run a parachain. For others, they can use Anchor pallet as Name Services such as ENS.

  • What is the point of selling anchors? It sounds like a security issue if I could buy someone else's anchor and replace its content with my own code when others might be relying on it.

This is the interesting part of On-chain Linked List, Anchor data are all stored on chain. As your sample, you can call the historical data.
For example, Anchor hello set data on block "234", "998" , "1756", sell it on block "3456", then the new owner set the new content on "4502". What need to do is that the application read the target block "1756" data.

For business, it is more interesting. It means that your Ancho is valuable not only rely on the characters but also the data or application you store on it. That is much like the real world.

  • If I store some JS code on (an) Anchor, where do you suggest the data being generated by those apps to be stored? Would be it be somewhere centralised, or on Anchor? With the latter, it would have to be stored by adding new anchors or by appending to a single anchor each time. I'm not sure the upside of simplified development is worth the extra work of handling the data. Can you comment on this?

Yes, you are right. I recommend to create new Anchor, just as the demo do, all data of the demo's data are Anchors, even the fav/tread history. At this use case, you can treat Anchor as Key-value Storage.
And, it is free for developer to store the data somewhere, but the cApp will be a bit hard to run properly so easy.

About Simplifying development, it is about the block chain access. Anchor is a way to store data on chain, and this way can be used to develop complex application without continually update the API.

For example, when substrate up to v4.0.0 or higher, Anchor pallet may need some update. But to the applications rely on Anchor, there is no update. So the developer can focus on the business itself.
This happened once when I develop the demo, one day, I can not read data for the local test node. After checking, I found that the substrate changed the Extrinsic details. After fix this, the demo cApp have nothing changed, this is good experience for me.

Copy link
Member

@semuelle semuelle left a comment

Choose a reason for hiding this comment

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

I have trouble imagining it working out the way you describe it, as JS libraries usually need regular updates as well. I am also skeptical that there is a market for anchors. However, you have shown that you are capable of implementing it and that you are committed to this project, so I'm approving it. I would need to see serious interest in the project before signing a follow-up grant, though.

@ff13dfly
Copy link
Contributor Author

I have trouble imagining it working out the way you describe it, as JS libraries usually need regular updates as well. I am also skeptical that there is a market for anchors. However, you have shown that you are capable of implementing it and that you are committed to this project, so I'm approving it. I would need to see serious interest in the project before signing a follow-up grant, though.

Thank you, will try to do it.

Copy link
Collaborator

@Noc2 Noc2 left a comment

Choose a reason for hiding this comment

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

I'm also happy to support it.

@Noc2 Noc2 merged commit a9a83b0 into w3f:master Feb 14, 2023
@github-actions
Copy link
Contributor

Congratulations and welcome to the Web3 Foundation Grants Program! Please refer to our Milestone Delivery repository for instructions on how to submit milestones and invoices, our FAQ for frequently asked questions and the support section of our README for more ways to find answers to your questions.

Before you start, take a moment to read through our announcement guidelines for all communications related to the grant or make them known to the right person in your organisation. In particular, please don't announce the grant publicly before at least the first milestone of your project has been approved. At that point or shortly before, you can get in touch with us at grantsPR@web3.foundation and we'll be happy to collaborate on an announcement about the work you’re doing.

Lastly, please remember to let us know in case you run into any delays or deviate from the deliverables in your application. You can either leave a comment here or directly request to amend your application via PR. We wish you luck with your project! 🚀

@ff13dfly
Copy link
Contributor Author

I'm also happy to support it.

Thank you, will try to finish it in time, :-)

@dsm-w3f dsm-w3f mentioned this pull request Sep 22, 2023
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested The team needs to clarify a few things first.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants