Code Monkey home page Code Monkey logo

filestorage's People

Contributors

cstrangedk avatar dmytronazarenko avatar dmytrotkk avatar kladkogex avatar yavrsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

filestorage's Issues

[SIP-1] FileStorage Reserve Improvement - Fix Security Vulnerability in Owner Key

SKALE Improvement Proposal 1 | Fix Usage of Ownership Key to Reserve Storage

The Problem

  • SKALE Chain Owner must be involved in signing a transaction to reserve space
  • This is a MAJOR vulnerability when deployed and cannot be used in production code
  • This is a vulnerability because the SKALE chain owner private key must be embedded into the client

A Solution

Allow SKALE Chain Config to let contracts call the reserve space function internally. So essentially whitelist contracts (and addresses) if that is your preference.

The actual solution would involve a whitelist mapping with potentially different access levels, amounts that can be reserved, and other config SKALE sees internally.

Example

  • A Storage Contract Inherits Storage Contract.
  • A Storage Contract is Whitelisted.
  • The Storage contract can now determine when storage can actually be reserved.

Example

  • User can receive 100 KB for free, and pay per each additional 100 KB. The storage contract can handle unlocking and go from there.
  • The same could be done for an NFT contract.

┆Issue is synchronized with this Jira Task

As USER I want to download files through URL

We need to allow users to download files from FileStorage through URL. Solidity contracts will have access to FileStorage through FileStorage contract and readChunk functionality.

Proposed solution:

  • Add NGINX Webserver docker container to each SKALE node.
  • Run on standard ports: HTTP_PORT = 80 and HTTPS_PORT = 443.
  • The HTTPS port will use the SSL certificate already available on each SKALE node.
  • Provide through NGINX read-only access to each file in filestorage.
  • Use the following URL convention : http(s)/NODE_DOMAIN_NAME/SCHAIN_ID Example: http://skalenode1.com/1234/cat.
  • The config file of the NGINX webserver will translate incoming URLs into locations in filestorage.

┆Issue is synchronized with this Jira Story

Emitting events in Filestorage

For File storage UI, we need to display file timestamps. Now there are difficulties with displaying time stamps in UI due to in the file storage contract we don’t save the time stamp field and don’t emit this event.

Solution:
Emit event in all functions which modify the state:
createFile
createDirectory
deleteFile
...

File Storage Web3 Server Connectivity issues

Followed the process in the https://docs.skale.network/filestorage/web3-server documentation for FileStorage
Currently, it doesn't work because of the following issues.

There were 3 problems that caused this issue:

  1. I have to pass the address in lower case like a5b91ef3496e3a616ff08b05580ea36490063f80
  2. On dappNet nodes 80 port was closed (this one is fixed but can we make sure all good on mainnet)
  3. Schain proxy does not support filestorage nginx, to download files, we have to ping specific schain node directly

┆Issue is synchronized with this Jira Task

[SIP-3] SKALE File Storage -> Default Ownership Transfer on Action

SKALE Improvement Proposal 3

The Problem

When a file is uploaded to a SKALE chain, the owner is the individual who uploads the file. If that file is then used to support metadata or NFT data, what happens if the NFT is listed and sold or if the NFT is send or gifted to someone else? The answer is that the File still technically belongs to the original owner.

A Solution (Theoretically Simple)

The simplest solution theoretically, is to have a transfer ownership function within the storage contract that moves the chunks and locations to the new owner address. This would result in the highest level of mutable, yet irreversible file storage in existence. However, by looking at the existing smart contract that may not be a "simple" solution.

An alternative solution is to change how the data is pointed to initially. Currently, chunks are stored within directories that are by default linked to an address. It could make more sense to create files outside of directories by default and have them floating in a "bucket" or just the general mapping. From there they could be linked to an address or a unique identifier that could in turn be switched by the contract on transfer.

Examples

Additionally, regardless of the solution; a contract once again would need to have access to control this contract functionality so an NFT contract could make this call on a send or a marketplace could on a sale.

┆Issue is synchronized with this Jira Task

Add role based access control to Filestorage predeployed

Currentl schain owner has 2 administrative functionality:

  1. Allocate space for new users
  2. Upgrade filestorage functionality

With multisig we need to give permission for (2) to separate account and Marionette contract and for (1) only for Marionette contract. For this purpose need to implement accessControl for Filestorage.sol

tx.origin needs to be changed with msg.sender to support control by smart contract

┆Issue is synchronized with this Jira Task

Update filestorage for NFT

Also user should be able to check file validity before they download it from node. Solution:

  • Calculate file checksum while uploading and store it on FS contract
  • Get file checksum by calling appropriate precompiled

┆Issue is synchronized with this Jira Task

Refactor filestorage contract

  • Need to remove assembly calls
  • Using implemented structures for files and dirs
  • Split file data structure and dir data structure

┆Issue is synchronized with this Jira Task

[SIP-2] Update Need to Reserve Space on Every Upload to File Storage

SKALE Improvement Proposal 2 | Remove Need for Reserve Space on Every File Upload

The Problem

  • When uploading a file to SKALE FileStorage, space must be reserved every time. This results in extra smart contract calls every time and I higher possibility for error.

A Solution

Allow the SKALE File Storage configuration to have a simple tracker that holds total space reserved. The total space reserved of all individuals can never exceed the total space available for the SKALE chain. Additionally, a user can reserve X amount of space and only utilize Y% of the space at any given time. This in itself I see as a problem, however, I believe it can be solved by allowing the FileStorage contract to be configured by the sChain owner to customize the abilities of the solution to the generated problem. This can be done by only allowing an individual to owner up to W amount at any given time, only allow a user to own Z percentage of the total file storage. Another example is having a starting block at at a value of B and then the FileStorage can only expand in increments of C.

Example:

The client application calls upload file to file storage contract. The file storage contract checks the user uploading the file and if the user has allocated, yet unused space; the file will upload successfully. If not, the user will be prompted to unlock additional storage according to the platform structure.

┆Issue is synchronized with this Jira Task

Consider using UnsafeRegion in filestorage operation

Investigate possibilities when skaled's crash in the middle of filestorage operation could lead to unrecoverable error. Use UnsafeRegion in these places:

{
UnsafeRegion::lock ur_lock;
...
}

With this, if crash happens inside ur_lock's scope, skaled will exit with code 200 (causing restart fro snapshot).

┆Issue is synchronized with this Jira Task

Add API for reserveSpace

We need to add reserveSpace API in filestorage.js to allow sChain owners reserve filestorage space for certain addresses.

┆Issue is synchronized with this Jira Task

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.