CYFS:Next Generation Protocol Family to Build Web3

Overview

CYFS Logo cyfs-lib-ver rust liscence Downloads

CYFS:Next Generation Protocol Family to Build Web3

Introduce

CYFS is the next-generation technology to build real Web3 by upgrading the basic protocol of Web (TCP/IP+DNS+HTTP). It has a subversive architectural design that everyone brings their own OOD (Owner Online Device) to form a truly decentralized network.

We define Web3 as follows:

  • Web3 allows everyone to have rights to save data on the Internet, publish data, and get income from data.
  • Web3's Internet applications are completely decentralized, developers have the right to publish and update applications, and users have the right to use them permanently.
  • Web3's data has been determined ownership when generated, and use Trust Link to link together to form the 'data-ownership network', which is the future semantic web that allows data to show its true value.

After 6 years of research and development, we have achieved the above goals on the CYFS testnet. For the detailed design of the theory and practice of CYFS, please refer to the relevant documents. Open source of CYFS is an important milestone for CYFS, marking that its design has been basically stable and has entered an open community-driven R&D stage. We look forward to having more people join us. We need your passion and strength. Let’s build Web3 that belongs to ourselves together.

This is the repository of the CYFS protocol stack on Github. Although we have built a decentralized GitHub (CodeDAO) on the CYFS testnet to realize the decentralized bootstrapping of CYFS. But before the CYFS mainnet online, we still decided to stay a little longer in WEB2.0 and use this repository as the main community-driven R&D base. After the CYFS mainnet goes online, the entire Repo will move to CodeDAO.

This repository only contains the implementation of the CYFS core system. It does not include the important basic software of the CYFS ecosystem: CyberChat and CYFS Browser, nor does it include SDK implementations for developers of different languages. The following is a list of other important open source projects in the CYFS ecosystem (continuously updated)

  • cyfs-ts-sdk: cyfs-sdk based on typescript to help typescript developers build Web3 DEC apps.
  • CYFS Transmission Lab: A system for the network lab for testing the CYFS protocol (Coming soon)
  • CyberChat: CYFS wallet, manage DID, OOD, DECApp and data assets (Coming soon)
  • CYFS Browser: A browser based on the Chrome kernel that supports the cyfs:// protocol (https://github.com/buckyos/cyfs-browser)
  • CodeDAO: Decentralized Github with CYFS (Coming soon)

Background

CYFS Architecture

The above is the overall architecture diagram of CYFS, which can help to establish a macro understanding of the design of CYFS. The core design of CYFS can be decomposed into the following parts

  • Design of NamedObject and double-section construction of cyfs://o/$ownerid/$objid (Object Link).
  • The BDT protocol improves TCP/IP: the network protocol evolves from address-oriented to trusted identity-oriented.
  • MetaChain upgrades DNS, realizes decentralized addressing, and realizes Data is Account.
  • The Owner deploys its own server OOD (Owner Online Device) on the network, which supports the decentralized accessibility of cyfs://
  • Design proofs of storage and proofs of service based on the game-based consensus theory of dispute before going on the chain, and realize the decentralized high reliability and high availability of cyfs://
  • The off-chain delivery of computing resources is separated from on-chain matching, and an evolvable economic model is used to build decentralized shared cloud computing
  • Data property rights analysis based on the input and results of trusted computing, to realize the evolution from on-chain smart contracts to off-chain Data Exchage Contract (DEC).
  • The Service of Web3 DEC App is installed on everyone's OOD, realizing the decentralization of application services

What key problems are these designs designed to solve? (We believe that "finding the right problem is half done~") You can read "CYFS Architecture" and "CYFS Whitepaper" (coming soon), the amount of content comparison Great, you can understand it with practice~

Start your Web3 journey with “Hello CYFS”

We strongly recommend that you read the "Hello CYFS" series of articles in full to get a complete initial experience of CYFS (the whole process can be completed within 1 hour):

  1. "Compile and deploy DIY-OOD"
  2. "Create Your DID"
  3. "Publish File and Download"
  4. "Tips your friend"
  5. "Publish Website and View"

You can also use the following fast progress to have a first experience of "doing nothing without understand and save time"~

Advance CYFS DEC App develpe tutorial is online

"Decentralized message board development"

Quick Start

The following will build your own Web3 environment by compiling the CYFS source code, and complete the basic experience of Web3 in this environment:

  • Publish a folder to the Web3 world and get a permanent address of cyfs://o/$ownerid/$dirid/index.html which can be accessed by CYFS Browser.
  • Use the cyfs get command to download the files in the folder you just published.

Note that this environment is normally not isolated, but can be added to the CYFS network (we have planned 3 networks: nightly, beta, relase, currently only nightly is available), so the following tutorial does not include compiling MetaChain with source code +SN part. If you plan to build a complete system in an independent environment and need to compile and deploy MetaChain super nodes, please read the document "MetaChain Construction" (Coming soon).

Compile

Prepare an idle Linux host, preferably a VPS, with more than 2G of memory. Preparation:

  • Node.js 16 or above
  • rustc 1.63 or above

Run the following command to compile the OOD System.

cd ${cyfs_sources_dir}/src
npm i
node ../scripts/build-standalone.js

During the compilation process of the script, the ${cyfs_root} folder needs to be created. If the current system or current user does not have permission to create this folder, you need to manually create the ${cyfs_root} folder in advance, and assign read and write permissions to the current user. (In the official environment, all components and data of the OOD System will be installed to ${cyfs_root})

${cyfs_root} path:

  • Windows: c:\cyfs
  • MacOS: ~/Library/cyfs
  • Other systems: /cyfs

Compile successfully generates ood-installer

Install the newly compiled OOD System

Before installation, you need to prepare the depends:

  • Node.js 16 and above
  • MongoDB 4.4 version, configured to boot, use the default port, no authentication (using SQLite as the object storage engine can not rely on MongoDB, the subsequent installation script will support the selection of the storage engine)
  • The latest version of docker-ce, configured to start at boot

Find the newly compiled ood-installer in the src directory and execute

./ood-installer --target solo

After a minintes , the installation is complete.

Activate OOD

In order to experience the process, the cli tool is used here to complete the D.I.D creation process. **D.I.D created based on the cli tool can only be used for testing purposes! **

  1. Install cyfs-tool: use the command line npm i -g cyfs-tool-nightly to install the nightly version of the cyfs-tool tool
  2. Generating sets of identities

    Use the command cyfs desc -s to generate a matching identity file and save it in the save_path directory. If save_path is not specified, it defaults to ~/.cyfs_profile

  3. Bind OOD

    After the identity is generated, copy the two files /ood.desc and /ood.sec to ${cyfs_root}/etc/desc on the OOD machine and rename it to device. desc and device.sec

  4. Bind CYFS-Runtime

    After the identity is generated, copy the two files /runtime.desc and /runtime.sec to ${cyfs_runtime_root}/etc/desc on the CYFS browser machine and rename them to device.desc and device.sec

${cyfs_runtime_root} specific path:

  • Windows: %appdata%/cyfs
  • Mac OS: ~/Library/Application Support/cyfs

Publish your first Web3 website

First prepare the www directory of your website, let's first experience publishing static websites to Web3, and follow-up documents for the construction of dynamic websites will be introduced.

use command

cyfs upload  -e ood -t ood

Add the file pointed to by the local to the OOD. The command execution is complete, the local www directory has been uploaded to OOD and the unique URL to the Web3.0 website has been generated (the end of the command execution). The link is cyfs O-Link, which looks like this cyfs://o/$ownerid/$objid, where $objid is the ContentId of the directory.

Browse the website just released

Use the command on any machine with cyfs-tool installed

cyfs get cyfs://o/$ownerid/$objid/index.html

You can download the just-released official website.

Any machine with a cyfs browser installed can use the cyfs browser to open cyfs://o/$ownerid/$objid/index.html and browse the website just released. For the download of cyfs browser, see here

Code guide

Through the above process, you have a basic understanding of the design and use of CYFS. Although the design of CYFS is basically stable, we still have a lot of code to write. We are very eager for your help, but certainly not too much energy to write documentation (details are in the source code~). Here we do a minimalist code introduction, hoping to help you understand the implementation of CYFS faster.

According to the architecture, we know that the core of cyfs:// is the construction and acquisition of Object Linke, and the premise of acquisition is to upload data to OOD at least. The process is as follows:

  1. Start the local protocol stack (cyfs-rutnime)
  2. Calculate the hash of all files in the directory locally, and construct a FileObject with the current PeopleId as the Owner
  3. Generate a Map structure (directory structure) locally, and construct a MapObject with the current PeopleId as the Owner, At this time, cyfs:// has been constructed, but the cyfs:// cannot be accessed at this time
  4. Add the above named objects and named data to the local stack
  5. Initiate CYFS PUT operation to OOD: save the MapObject to OOD and set the access permission to public
  6. Let OOD start MapObject Prepare and save a named data on OOD
  7. MapObject Prepare is completed on OOD, cyfs:// can be accessed

Then the process of using cyfs get to obtain is as follows:

  1. Start the local protocol stack cyfs-runtime
  2. Use the HTTP protocol to initiate an HTTP GET request to cyfs-runtime
  3. cyfs-runtime checks whether the object exists in the local cache
  4. cyfs-runtime initiates a NamedObject query request (the following behaviors are not serial)
    • 4.1 Query NamedObject from OOD
    • 4.2 OOD query local, whether NamedObject exists
    • 4.3 OOD queries MetaChain, whether NamedObject exists
    • 4.4 OOD queries whether the NamedObject exists on the previous hop device according to the Reference information in get
    • 4.5 OOD queries the configuration of Object's Owner Zone through MetaChain
    • 4.6 OOD is configured through Zone, connected to NamedObject's OOD, or connected to NamedObject' Cache, and query NamedObject
  5. After getting the ChunkId, cyfs-runtime calls the Channel interface (NDN semantic interface) of the BDT to request the Chunk
    • 5.1 For the first, small Chunk, get it directly from the associated OOD
    • 5.2 For the second Chunk, it will try to get it from the previous hop (Reference OOD)
    • 5.3 BDT will try to perform multi-source search and multi-source download based on fountain code based on the context information of the application layer
    • 5.4 The router can identify the Chunk request packets sent by the BDT, intercept and forward them, and further optimize the overall load of the network
    • 5.5 Only OOD will upload Chunk
  6. When the first Chunk of the FileObject is ready (passed authentication), the HTTP GET request in step 1 starts to return data

(The above process is shown in the figure below) get-from-cyfs

For the overall design of the CYFS protocol, please refer to Introduction to CYFS Protocol.md

After understanding the logic of the above process, you can read the relevant code according to the following guidelines.

Upload

  1. Start the local protocol stack: util.ts: create_stack()
  2. Construct FileObject: file_recorder.rs: FileRecorder.add_file()
  3. Construct ObjectMap: publish_manager.rs: PublishLocalDirTask.publish()
  4. Add the above Named-Objects and Named-Data to the local protocol stack: file_recorder.rs: FileRecorder.record_file_chunk_list()
  5. Initiate a CYFS PUT operation to the OOD: save the MapObject to the OOD and set the access permission to public: upload.ts: upload_obj()
  6. Let OOD start MapObject Prepare and save Named-data(Chunks) on OOD: upload.ts: run()

Get

  1. Start the local protocol stack: util.ts: create_stack()
  2. Initiate an HTTP GET request using the HTTP protocol
  3. cyfs-runtime checks whether the object exists in the local cache
  4. cyfs-runtime initiates NamedObject query requirements (the following behaviors are usually not serial)
    • 4.1 Query NamedObject from OOD
    • 4.2 OOD query local, whether NamedObject exists
    • 4.3 OOD queries MetaChain, whether NamedObject exists
    • 4.4 OOD queries whether the NamedObject exists on the previous hop device according to the Reference information in GET
    • 4.5 OOD queries the configuration of Object's Owner Zone through MetaChain
    • 4.6 OOD is configured through Zone, connected to NamedObject's OOD, or connected to NamedObject' Cache, and query NamedObject
  5. After get the ChunkId, cyfs-runtime calls the Channel interface (NDN semantic interface) of the BDT to request the Chunk
    • 5.1 For the first and small Chunk, get it directly from the associated OOD
    • 5.2 For the second Chunk, it will try to get it from the previous-jump (Reference OOD)
    • 5.3 BDT will try to perform multi-source search and multi-source download based on fountain code based on the context information of the application layer
    • 5.4 The router can identify the Chunk request packets sent by the BDT, intercept and forward them, and further optimize the overall load of the network
    • 5.5 Only OOD will upload Chunk
  6. When the first chunk of the FileObject is ready and verified, the HTTP GET request in step 1 starts to return data

DecApp development practice

The following series of articles describes how to implement a message board DecApp based on CYFS. this is a long series of articles detailing the general process of developing a DecApp

  1. Introduction
  2. DEC App basic principle
  3. Implement your own message service
  4. Run and debug your own message service
  5. Extended reading: Further explanation of the principles and introduction of some tools
  6. Implement the front end
  7. Send it to your friends and understand the CYFS permission system
  8. Use the emulator to test the app across zones
  9. Extended reading: Decentralized, trusted data, semantic data, data property rights
  10. Add comments
  11. DEC App data security and high availability
  12. Extended reading: Learn more about data exchange contracts and DAOs
  13. Summary

Directory Structure

You have learned from the architecture diagram that the project implementation of CYFS is not small. To prevent you from getting lost, this chapter is a small map that will help you get a basic understanding of the CYFS code structure and understand where the key code will be.

  • src //source directory, many development commands require this directory to be the current directory for operations
    • service // contains the code of a series of important executable files, which is a good starting point for reading the code
      • gateway //nginx of CYFS system, the most important basic service on OOD
      • cyfs-runtime //CYFS user mode protocol stack implementation, the most common process in development and debugging
      • ood-daemon //The basic daemon of OOD, keep alive and automatically update other basic services
      • app-manager //Installation manager of DEC App
      • chunk-manager // The most primitive and simple thinking and implementation of the concept of CYFS NDN, currently used for the lowest basic services
      • file-manager // The most primitive and simple thinking and implementation of the concept of CYFS NON, currently used for the lowest-level basic services
      • cyfs-runtime // The backend of the CYFS protocol stack used by the CYFS browser, based on the standard CYFS protocol stack, provides some functions that are convenient for the browser to use
    • component
      • cyfs-base //The basic component shared by all projects, here you can see the implementation details of NamedObject
      • cyfs-base-meta // MetaChain's base object definition
      • cyfs-bdt //The implementation of the BDT protocol, be careful of the huge scale when expanding
      • cyfs-core // Definition of core objects in the CYFS system
      • cyfs-chunk // CYFS protocol stack supports NDN protocol
      • cyfs-stack //The implementation of the CYFS protocol should be the largest component in the system
      • cyfs-meta-lib //Related implementation of MetaChain Client
      • cyfs-mobile-stack //Encapsulation of CYFS mobile protocol stack
      • cyfs-noc //NamedObject storage engine implementation (SQLite+MongoDB), which is the component that has the greatest impact on system IO performance
    • test //Test project, only includes the parts that have been sorted out, the code for a large number of network tests of CYFS is in the CYFS Transmission Lab. -tools //cyfs tools. The design idea of ​​cyfs toolchain is a top-level script and a series of independent gadgets, taking into account the consistency of cli experience and the independence of project construction
  • scripts //Compile script directory, we use js script to replace makefile
  • doc //document directory

Roadmap

CYFS is currently in the state of dev_testnet (nightly), in this state, all components will be affected by the daily build results by default, and we do not consider how the data structure is backward compatible, and the protection of data security is not enough. whole. This version should only be used for development testing and should not be used in production production.

Our next goal is to complete the launch of the testnet (beta). Relatively nightly, beta will specify strict release standards, and will make the data structure as backward compatible as possible, and can confidently protect users' data security. The stability of beta will be able to support the release of beta products~ The main difference from the release version is assets is fake assets, and there are gaps in stability and performance.

We hope to launch the CYFS mainnet within 18 months. There is no definite launch time for the CYFS mainnet. As long as the asset security, stability and performance of the testnet reach the preset goals, we will enter the release channel of the mainnet.

Welcome to follow CYFS-Stack & Services to learn more about CYFS Roadmap~

Contributing

The dev_testnet of CYFS is designed and implemented by Shenzhen BuckyCloud. The core team of Shenzhen BuckyCloud is inherited from the original Xunlei(NASQ:XNET) infrastructure R&D team. We have rich experience in network protocol and infrastructure development, as well as super-large-scale P2P network design and tuning. experience. After CYFS is open source, BuckyCloud has completed its key historical mission. Now we prefer to call ourselves CYFS CoreDevTeam. In the future, it will be an open team organized based on DAO. The main responsibility is to promote the continuous research and development of CYFS. We welcome all engineers to join:

  • If you have rich experience in network protocol development, at this moment we need you to help us improve the core protocol together
  • If you are very familiar with open source culture and open source community, you can join decentralized github (CodeDAO) with us
  • If you have rich experience in blockchain development, MetaChain, which is waiting to be rewritten at the moment, urgently needs you~ We already have an ambitious design, but over the years we have focused on off-chain protocol development, block-chain development resource is very limited
  • If your main language does not include typescript and rust, you can help us build SDK for other languages
  • If you are very good at the product, you can help us improve the basic experience of CYFS, or create a real Web3 Startup on CodeDAO
  • Of course, everyone is welcome to submit bugs, suggestions for product improvement, and help us revise documents.... We guarantee that your contributions will be remembered

We are designing a DAO-NFT-based contribution record system. When this Repo is move to CodeDAO as a whole, CYFS DAO Tokens can be issued according to the share size of contributors (fairness is difficult)

License

BSD-2-Clause License
Copyright (c) 2023, CYFS Core Dev Team.

Comments
  • WIndows App-manager is interrupted and cannot be recovered during the installation of DEC APP npm i

    WIndows App-manager is interrupted and cannot be recovered during the installation of DEC APP npm i

    Describe the bug WIndows App-manager is interrupted and cannot be recovered during the installation of DEC APP npm i

    To Reproduce

    • Install cyfs://5r4MYfFJ7ktzBzSi1sWmU7BJLgpEEdp8ukbWemsFuQc1/9tGpLNndpfRjUF59SsZidVaPuPd8QNFJusQKH8genY3Q
    • When DEC APP executes npm i during installation, kill app-manager process
    • Then ood-daamon will restart app-manager.Reinstall dec app will clean up old files, there will be a problem of file occupation
    [2023-04-13 20:15:19.397449 +08:00] ERROR [ThreadId(32)] [service\app-manager\src\app_controller.rs:154] install app:9tGpLNndpfRjUF59SsZidVaPuPd8QNFJusQKH8genY3Q failed, errio_IOwn(Urk : This file is in use by another program and cannot be accessed by the process. (os error 32), Some(IoError(Os { code: 32, kind: Uncategorized, message: "This file is in use by another program and cannot be accessed by the process." } )))
    

    Expected behavior In the process of windows npm i, the file lock created by the system cannot be released, and the user needs to restart the computer to solve this problem. However, similar scenarios will appear during the ood service update process, which needs to be compatible with the update process, or optimized by app-manager. This problem does not exist when app-manager uses docker mode.

    System information OOD-Service : 1.1.0.0-nightly (23-04-13) build by code 314d358d

    log.zip

    bug App-Manager 
    opened by lizhihongTest 16
  • More refined App Manager status recovery

    More refined App Manager status recovery

    Currently, AppManager checks the current status of all DecApps when they are launched. If the status is operation in progress, such as Installing, Uninstalling, it will change to the corresponding failure status, i.e. InstallFailed, UninstallFailed

    Here it should be possible to do a finer state recovery, not simply restore to Failed state, but to a more "normal" state

    task App-Manager 
    opened by weiqiushi 14
  • AppManager's install command timeout may cause the child install process to not be killed

    AppManager's install command timeout may cause the child install process to not be killed

    AppManager has a timeout of 15 minutes for each installation command when executing DecApp's installation command. When the time is exceeded and the installation command has not exited, child.kill() will be called to kill it.

    Under windows system, if the install command starts a child process, such as npm i, child.kill() may not kill its child process, which may lead to problems such as the DecApp folder being occupied.

    bug App-Manager 
    opened by weiqiushi 14
  • v82 testing

    v82 testing

    Issue for v82 testing. Please help testing on a variety of supported platforms, as well as interaction with different software.

    Let us know which version you tested on which operating system.

    If you find an issue, please search Github for known issues first and then open a new Github issue.

    This issue should not be used to report bugs, as a single thread makes it impossible to track more than one topic.

    What to test

    For an idea what to test, see 82 release candidate testing guide

    Release Tests 
    opened by tracy101 10
  • App-manager local store mode update dec_app  failed

    App-manager local store mode update dec_app failed

    Describe the bug App-manager local store mode update dec_app failed

    To Reproduce

    • My OOD Service config App-manager local store mode
    • Installed dec_app version 1.0.3 by local store mode
    • I want to update my dec_app to version 1.0.4,excute command cyfs deploy and check dec_app is update in meta chain
    • Excute ood-installer --sync-app-repo ,sync the latest dec_app 1.0.4 to the local successfully
    • But the App-manager auto update dec_app to 1.0.4 failed

    Expected behavior I can run command ood-installer --sync-app-repo success , and the App-manager can update the dec_app success

    System information cyfs-sdk 0.6.2 OOD Service :linux 1.1.1.80

    bug App-Manager 
    opened by lizhihongTest 10
  • Static website first load performance issue

    Static website first load performance issue

    Describe the bug Static website first load performance issue To Reproduce Nodejs installs cyfs-sdk and cyfs-tool, publishes a web3 static web page, and it takes 80s to open the static page with a CYFS browser 1、Excute command: npm i cyfs-sdk -g and npm i cyfs-tool -g
    2、Use cyfs create -n my_web 3、Use cyfs deploy 200images static web page 4、Use CYFS browser open the cyfs link to load web page, it takes 80s load finisged Expected behavior CYFS Stack should optimize first load speed of web3 pages System information OOD : linux 1.1.1.80 CYFS browser: V 1.0.1.98 (beta) windows cyfs-sdk : 0.6.2

    bug CYFS Stack CYFS-Runtime Performance 
    opened by lizhihongTest 10
  • AppManager incorrectly enters the UninstallFailed state when uninstalling DecApp

    AppManager incorrectly enters the UninstallFailed state when uninstalling DecApp

    When AppManager uninstalls DecApp, if the DecApp service folder is occupied, AppManager will mark it as UninstallFailed status. Should it be marked as successfully uninstalled here? If the occupied folder may cause the installation to fail in the future. Should it go to InstallFailed at the time of installation, or should it remain UninstallFailed?

    bug App-Manager 
    opened by weiqiushi 10
  • Test schedule for 83 Release

    Test schedule for 83 Release

    Issue for v83 testing. Please help testing on a variety of supported platforms, as well as interaction with different software.

    Let us know which version you tested on which operating system.

    If you find an issue, please search Github for known issues first and then open a new Github issue.

    This issue should not be used to report bugs, as a single thread makes it impossible to track more than one topic.

    Add test task:

    • Feature:
    • Bug fixed:
    • [x] #203
    • [x] #216
    • [x] #222
    • [x] #224
    • [x] #238
    • [x] #207
    • [x] #239
    • [x] #247
    • [x] #214
    • Other panic fixed

    These code modifications have been released in Nighlty version 1.1.0.753-1.1.0.756, and the test version specified by the configuration can be referred to:How to config OOD service testing environment

    task Release Tests 
    opened by lizhihongTest 9
  • Install app:9tGpLNniojkX6rVCdDi7t6BK1sMqDjw32RFhxQUReiFH failed, err: (ZipError, invalid Zip archive: Invalid zip header, None)

    Install app:9tGpLNniojkX6rVCdDi7t6BK1sMqDjw32RFhxQUReiFH failed, err: (ZipError, invalid Zip archive: Invalid zip header, None)

    Describe the bug The default dec-app drops in the beta environment, the installation fails:

    [2023-04-15 09:10:50.622562 +00:00] ERROR [ThreadId(10)] [service/app-manager/src/app_controller.rs:154] install app:9tGpLNniojkX6rVCdDi7t6BK1sMqDjw32RFhxQUReiFH failed, err: (ZipError, invalid Zip archive: Invalid zip header, None)
    

    This seems to be an exception when downloading the file, unable to open the compressed package, reinstalling and reusing the wrong zip file, and not re-downloading

    app-manager_3874026_rCURRENT.log

    bug App-Manager 
    opened by lizhihongTest 9
  • Improve permission system that supports dynamic tokens for DEC

    Improve permission system that supports dynamic tokens for DEC

    The current permission system has two layers: rmeta and object access, with the following characteristics:

    • RMeta layer: It can set permissions based on the global-state path and assign permissions to (dec, zone) groups using access-string control. It can also set permissions for specific (dec, zone) pairs through (dec-id, device-id/owner-id).
    • Object-level access: This is at the noc layer, where permissions can be set for each object based on (dec, zone) groups using access-string control.

    These two levels of permissions can handle many static configurations but are insufficient for some dynamic permission scenarios, such as:

    A DEC needs to share a specific resource with others and sets a token (maybe a random password string). As long as others know this token, they can access the resource. The shared token has an expiration time, after which others will no longer have access.

    This is a typical token-based sharing mechanism, with tokens being custom-generated and validated by each DEC. Tokens can be a random password or a public key format, etc.

    The protocol stack needs to consider how to support this form of dynamic permission. It is reasonable to add it to the rmeta layer, as introduced from the beginning. Since DEC validation is required, the handler system also needs to be involved. The DEC can dynamically handle permission validation requests for each rmeta to determine whether to grant or deny access.

    feature CYFS Stack Permission 
    opened by lurenpluto 9
  • If ACL Handler response error,satck.root_state_accessor_stub.get_object_by_path() will not return

    If ACL Handler response error,satck.root_state_accessor_stub.get_object_by_path() will not return

    Describe the bug If I set ACL handler event return response : cyfs.Err(cyfs.BuckyError.new_dec_error(match_response_error,"request set response_error")), the function will satck.root_state_accessor_stub.get_object_by_path() will not return

    zone-simulator_133340_rCURRENT.log

    Details

    • hadler
    export class DynamicTokenHandler implements cyfs.RouterHandlerAclRoutine{
        private token : string
        constructor(token:string){
            this.token = token;
        }
        async call(param: cyfs.RouterHandlerAclRequest): Promise<cyfs.BuckyResult<cyfs.RouterHandlerAclResult>> {
            console.info(`will handle dynamic acl${param.request.req_path}: query${param.request.req_query_string}`)
            let action = cyfs.AclAction.Reject;
            let querys = param.request.req_query_string.split("&");
            let match_return_error = 0;
            let match_response_error = 0;
            for(let query of querys){
                let [key,value] = query.split("=");
                console.info(`Dynamic Token will check key=${key} value = ${value}`)
                if(key === "token" && value === this.token){
                    console.info(`DynamicTokenHandler check token success,will return access accept`)
                    action = cyfs.AclAction.Accept;
                }
                if(key === "return_error"){
                    match_return_error = Number(value);
                    console.info(`DynamicTokenHandler will return error ${match_return_error}`)
                    break;
                }
                if(key === "response_error"){
                    match_response_error = Number(value);
                    console.info(`DynamicTokenHandler will response error ${match_response_error}`)
                    break;
                }
            }
            let resp :cyfs.AclHandlerResponse = {
                action
            }
            if(match_response_error != 0){
                return cyfs.Err(cyfs.BuckyError.new_dec_error(match_response_error,"request set return_error"));
            }
            let result : cyfs.RouterHandlerAclResult =  {
                action: cyfs.RouterHandlerAction.Response,
                response : cyfs.Ok(resp),
            }
            if(match_response_error != 0){
                result = {
                    action: cyfs.RouterHandlerAction.Response,
                    response : cyfs.Err(cyfs.BuckyError.new_dec_error(match_response_error,"request set response_error")),
                }
            }
            return cyfs.Ok(result)
        }  
    }
    
    • client
                    let prepare_obj =await new ShareObjectWithTokenAction({
                        local: zone1_ood_app1_http,
                        input: {
                            timeout: 200 * 1000,
                        },
                        expect: { err: 0 },
                    }).start({
                        handler_id : "test-the-some-id-handler-789",
                        chain : cyfs.RouterHandlerChain.Acl,
                        root_req_path:"/qa_test_token",
                        index : 0,
                        filter: "*",
                        default_action : cyfs.RouterHandlerAction.Reject,
                        routine : new DynamicTokenHandler(TOKEN),
                        token : TOKEN,
                    });
                    assert.equal(prepare_obj.err,0,prepare_obj.log);
                    let zone1_ood = test_runner.stack_manager.get_cyfs_satck(zone1_ood_app1_http).stack!;
                    let zone2_ood = test_runner.stack_manager.get_cyfs_satck(zone2_ood_app1_http).stack!;
                    let  get_object_result = await zone2_ood.root_state_accessor_stub(zone1_ood.local_device_id().object_id).get_object_by_path(`${prepare_obj.resp.share_req_path}?token=${TOKEN}&response_error=404`);
                    assert.equal( get_object_result.err,true, get_object_result.val.toString());
                    if( get_object_result.err){
                        console.info(`get_object_by_path err = ${JSON.stringify(get_object_result.val)}`)
                    }
    

    associate issuse #175 bug Handler 
    opened by lizhihongTest 8
  • `ChunkId::new` panic with misaligned pointer dereference

    `ChunkId::new` panic with misaligned pointer dereference

    Describe the bug https://github.com/buckyos/CYFS/blob/9eaf33f280f060814d18e182c42aa6867f70e0a0/src/component/cyfs-base/src/objects/chunk.rs#L221-L233 No matter how I try to create ChunkId with ChunkId::new, it will panic and show the error: misaligned pointer dereference: address must be a multiple of 0x4 but is 0xaddress.

    To Reproduce

    fn main() {
        let (chunk_len, chunk_data) = random_mem(1024, 1024);
        let chunk_hash = hash_data(&chunk_data[..]);
        println!("{:?}", chunk_hash);
        let chunkid = ChunkId::new(&chunk_hash, chunk_len as u32);
    }
    

    There is no sample code in documentation; therefore, I follow the sample code and test I found in repository.

    Expected behavior I expected to get chunk_id at the last line. I am sure the bug comes from new function because I always could print chunk_hash.

    System information

    [dependencies]
    cyfs-base = "0.6.12"
    cyfs-bdt = "0.7.3"
    cyfs-lib = "0.8.3"
    

    Here are my dependencies. I used it on ubuntu 20.04 with x86-64.

    bug 
    opened by shinmao 2
  • Unsound `transmute` in safe method

    Unsound `transmute` in safe method

    https://github.com/buckyos/CYFS/blob/9eaf33f280f060814d18e182c42aa6867f70e0a0/src/component/cyfs-base/src/objects/chunk.rs#L157-L159 The safe method as_object_id used transmute to convert &ChunkId to &ObjectId. When we use transmute on reference, we need to ensure the layout (e.g., size and alignment) by ourselves. Even though ChunkId and ObjectId have the same type definition, rust compiler preserves the right to reorder and add padding bytes to the struct of repr(Rust) representation. Suggest to add repr(C) to both struct to make this guarantee.

    opened by shinmao 0
  • Query task group state failed in rust.

    Query task group state failed in rust.

    When I query task group state in rust, it returns err: (InvalidFormat, parse json string error: value=Download, err: (InvalidParam, unknown trans group type: Download, None), None)

    rust code: stack.trans().get_task_group_state(TransGetTaskGroupStateOutputRequest { common: NDNOutputRequestCommon { req_path: None, dec_id: None, level: NDNAPILevel::Router, target: Some(ood_id.clone()), referer_object: vec![], flags: 0, }, group: group_id.clone(), group_type: TransTaskGroupType::Download, speed_when: None, }).await

    bug 
    opened by glen0125 3
  • Problems with ood-daemon restore backup data

    Problems with ood-daemon restore backup data

    According to the feedback of some related products, OOD has been found to be missing data during gateway usage use after restoring data according to the following process:

    1. Initialize a new ood environment with ood-installer In this case, the ood is in an unbound state and only the ood-daemon process is available
    2. Call the remote-restore interface of ood-daemon to restore the data from other ood backups This process may take longer, depending on the size of the backup data, etc.
    3. The above process includes the binding process because the {cyfs}/etc/desc directory is backed up.
    4. After the recovery is completed, use gateway directly It's found that in some cases the data is missing, especially when accessing the root-state to get the dec app's state, the state is completely different from the state of the backed up source ood
    bug OOD-daemon Backup & Restore 
    opened by lurenpluto 3
  • Test schedule for 84 Release

    Test schedule for 84 Release

    Issue for v84 testing. Please help testing on a variety of supported platforms, as well as interaction with different software.

    Let us know which version you tested on which operating system.

    If you find an issue, please search Github for known issues first and then open a new Github issue.

    This issue should not be used to report bugs, as a single thread makes it impossible to track more than one topic.

    Add test task:

    • Feature:
    • [ ] #141
    • [ ] #256
    • [ ] #264
    • Bug fixed:

    These code modifications have been released in Nighlty version 1.1.0.757+, and the test version specified by the configuration can be referred to:How to config OOD service testing environment

    task 
    opened by lizhihongTest 0
Releases(1.1.1.83)
Owner
CYFS Core Dev Team
CYFS Core Dev Team
Validity is a next-generation, deduction-based language for formally verified, context-aware, autonomous & reactive smart contracts.

Validity Language Validity is a next-generation, deduction-based language for formally verified, context-aware, autonomous & reactive smart contracts.

Tempest Labs 4 Nov 11, 2022
TurboSHAKE: A Family of XOFs based on round reduced ( 12 rounds ) Keccak[1600] Permutation

turboshake TurboSHAKE: A Family of eXtendable Output Functions based on round reduced ( 12 rounds ) Keccak[1600] Permutation Overview TurboSHAKE is a

Anjan Roy 4 Mar 20, 2023
miners is a fast Rust library for the Maximal Information-based Nonparametric Exploration (MIC and MINE family)

miners miners is a fast Rust library for the Maximal Information-based Nonparametric Exploration (MIC and MINE family). miners using rayon and vectori

CuteSocks 7 Nov 2, 2023
Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana (WIP) ⛏👷🚧⚠️

Solana BPF Boilerplate Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana This boilerplate provides the following. Si

ono 6 Jan 30, 2022
Making Token Exchange program with Solana(Rust), Web3, and Vue

Escrow program for Solana blockchain Tech stack Program (Smart Contract) Rust crates: solana-program, spl-token Solana CLI for test validator UI Types

Hoon Wee 3 May 10, 2022
A Web3.0 forum implemented based on Substrate

Substrate Node Template A fresh FRAME-based Substrate node, ready for hacking ?? Getting Started Follow the steps below to get started with the Node T

Daogang Tang 5 Mar 24, 2022
A Web3.0 forum implemented based on Substrate

Substrate Node Template A fresh FRAME-based Substrate node, ready for hacking ?? Getting Started Follow the steps below to get started with the Node T

Mike Tang 5 Mar 24, 2022
Summer Boot (web2&web3, the decentralized web framework)

Summer Boot The next generation decentralized web framework allows users to manage and share their own data. It will be a wide area and cross regional

Summer 111 Dec 1, 2022
Ethereum JSON-RPC multi-transport client. Rust implementation of web3 library

Ethereum JSON-RPC multi-transport client. Rust implementation of web3 library. ENS address: rust-web3.eth

Tomasz Drwięga 1.2k Jan 8, 2023
Outp0st is an open-source UI tool to enable next-level team collaboration on dApp development over Terra blockchain

Outp0st is an open-source UI tool to enable next-level team collaboration on dApp development over Terra blockchain

Genolis 2 May 4, 2022
A template for your next Rust project.

Opinionated Rust Template A template for your next Rust project. To start coding run: cargo generate tomkarw/opinionated-rust-template Only requires j

Tom Karwowski 8 Dec 1, 2022
Cryptographic Primitive Code Generation by Fiat

Fiat-Crypto: Synthesizing Correct-by-Construction Code for Cryptographic Primitives Building This repository requires Coq 8.11 or later. Note that if

Programming Languages and Verification Group at MIT CSAIL 538 Jan 7, 2023
A pretty simple tool for password generation, written in Rust.

passwdgen A pretty simple tool for password generation, written in Rust. Usage: passwdgen - a pretty simple tool for password generation Usage: passw

Kirill Belolipetsky 9 Feb 19, 2023
Release complex cargo-workspaces automatically with changelog generation, used by `gitoxide`

cargo smart-release Fearlessly release workspace crates and with beautiful semi-handcrafted changelogs. Key Features zero-configuration cargo smart-re

Sebastian Thiel 24 Oct 11, 2023
Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.

Note to readers: On December 1, 2020, the Libra Association was renamed to Diem Association. The project repos are in the process of being migrated. A

Diem 16.7k Jan 8, 2023
Examples and helpers to build NFT contracts on CosmWasm

CosmWasm NFTS This repo is the official repository to work on all NFT standard and examples in the CosmWasm ecosystem. cw721 and cw721-base were moved

CosmWasm 147 Jan 4, 2023
A lightweight and flexible framework to build your tailored blockchain applications.

TRINCI Blockchain Core A lightweight and flexible framework to build your tailored blockchain applications. Requirements The required dependencies to

Affidaty S.p.A. 11 Sep 26, 2022
Dfinity's fungible token standard. Any PRs and comments are welcome,collaborate with us to build this standard

Dfinity's fungible token standard. Any PRs and comments are welcome,collaborate with us to build this standard

Deland Labs 46 Nov 7, 2022
Dione is an anonymize and encrypted messaging system build on top on a peer to peer layer.

Secure and Anonymous Messaging WARNING: Currently Dione is not ready to be used nor does it fulfill its goal of being an anonymous messenger. In order

Dione 41 Jan 5, 2023