Giter Site home page Giter Site logo

arkecosystem / core Goto Github PK

View Code? Open in Web Editor NEW
334.0 33.0 287.0 44.35 MB

The ARK Core Blockchain Framework. Check https://learn.ark.dev for more information.

Home Page: https://ark.io

License: MIT License

JavaScript 4.82% Shell 0.62% Dockerfile 0.02% TypeScript 94.53%
blockchain ark nodejs crypto dpos smartbridge typescript modular-architecture

core's Introduction

ARK Core

License: MIT

Note Please checkout MainSail for the next generation of the ARK-Core blockchain protocol featuring a new DPoS consensus engine that is more reliable and efficient. Currently in development.

Introduction

This repository contains all plugins that make up the ARK Core.

Check our dedicated documentation site for information about all available plugins and How to write a Core Plugin if you want to get started with developing your own plugins.

Documentation

API Documentation

Security

If you discover a security vulnerability within this package, please send an e-mail to [email protected]. All security vulnerabilities will be promptly addressed.

Credits

This project exists thanks to all the people who contribute.

License

MIT © ARK Ecosystem

core's People

Contributors

adrian69 avatar air1one avatar alessiodf avatar alexbarnsley avatar bertiespell avatar boldninja avatar ciband avatar dated avatar deanpress avatar dependabot[bot] avatar faustbrian avatar fix avatar itsanametoo avatar j-a-m-l avatar kovaczan avatar kristjank avatar lemii avatar luciorubeens avatar mariowhowrites avatar nigui avatar paroxysm avatar rainydio avatar renovate[bot] avatar sebastijankuzner avatar snyk-bot avatar spkjp avatar tpscrpt avatar vasild avatar whitehat avatar zillionn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

core's Issues

Make transaction vendor fields searchable

We basically have 2 options currently, one would require a change to the database and use more storage but grant much greater searching abilities.

  1. Keep the database how it is with a hex vendor field and require people to enter vendor fields in hex format for searches. Advantage is less storage, Disadvantage is no proper search for the most important part of a transaction to the end-user.

  2. Store the vendor field in plain text in the database, allows partial matching, regex pattern, full text search. Advantages are the mentioned ones, Disadvantages are more storage.

Implement bin executable

If we want people to allow to type things like ark-core start:mainnet we need to add a global bin executable that can handle all those commands we currently have inside the package.json as scripts.

    "bin": {
        "ark-core": "bin/index.js"
    },

Update core-commander to accommodate plugin configuration

The issue with the new plugin system is that the configuration file is a plain javascript object that gets exported and not a JSON object like previously which makes it hard (maybe impossible without a hacky solution) to read the configuration and write it back into the file as things like path.resolve or anyFunction() are resolved when you require a file that contains module.exports.

There are basically 2 solutions to this:

  1. Implement hacky solutions using reflection to provide configuration through the CLI
  2. Only copy the config into ~/.ark/config with the commander and require configuration to be done manually but offer "test" functionality in the commander to make sure the configuration is valid and working
    2.1 "test" functions are things like checking if a database or redis connection can be established, if the log file path exists, etc.

Implement jeffijoe/awilix as container

Currently we already have a bunch of singletons and include files over and over again in all kind of places which can be solved by implementing a container like https://github.com/jeffijoe/awilix.

We would register all classes and globally used variables (like configs) on application start in the container and they would be auto injected and accessible from everywhere.

Also we could get rid of the hacky singletons as the container can maintain the singleton state for us by only instantiating a class once if specified and retrieving the initial instance on consecutive calls.

remove empty wallets from memory

In order to optimise in memory wallets, empty wallets can be removed from wallet manager and be considered as cold wallet.
Needed rules :

  • If a new incoming tx, a check against the database for public key will rebuild complete state of wallet
  • for API, by default if no wallet is found in memory, it means balance is 0

add save dirty wallets on ctrl+c events

  • catch ctrl+c event
  • save dirty wallets
  • indicates somehow the wallets has been saved on shutdown
  • shutdown

when restart:

  • check if the wallets has been saved on shutdown recently (like a few rounds back)
  • if yes skip SPV build, load wallets from db and start normal sync
  • if no rebuild/SPV/sync (normal behaviour)

Implement config & argument validation

We could use https://github.com/sindresorhus/ow for 2 things.

I. Config Validation

We should make sure on application start that all important configuration like the network configuration is valid.

II. Argument Validation

We should make sure that arguments passed onto methods have the right type, length and format to avoid any unexpected behaviour that could cause harm or create corrupted data.

Performance Hit of Block Endpoints

We currently have API endpoints both in v1 and v2 that have a major impact on performance because the database has to be hit for a count of millions of records and then retrieve 50-100 records based on an offset.

This performance hit in a normal environment would be easy to fix by sharding, getting more hardware or optimizing the implementation of the database layer by using postgres specific functions like https://wiki.postgresql.org/wiki/Count_estimate which is not an option as we use Sequelize.

https://github.com/fix/ark-core/blob/master/app/api/public/versions/1/index.js#L11
https://github.com/fix/ark-core/blob/master/app/api/public/versions/2/index.js#L15
https://github.com/fix/ark-core/blob/master/app/api/public/versions/2/index.js#L39
https://github.com/fix/ark-core/blob/master/app/api/public/versions/2/index.js#L40

The only real solution without major changes or spec changes for people that want to run a node I can think of is that we load all blocks and transactions into memory on application start and push new blocks into memory after they are stored in the database.

This way we avoid hitting the database for millions of records as we could simply use filter, sortBy or length to count records instead of having to do heavy database queries after the application is booted.

Currently the requests on the block endpoints can take anywhere from 10 to 20 seconds (up to 3 minutes on stat endpoints) and this request time will only increase over time as we are not optimizing around postgres or something like cassandra which is designed for larger datasets.

The reality is people run their nodes on the cheapest possible option so we sadly have to work around that.

API v1 issues

http://localhost:4003/api/transactions?orderBy=timestamp:desc&offset=0&limit=50&recipientId=DTRdbaUW3RQQSL5By4G43JVaeHiqfVp9oh&senderId=DTRdbaUW3RQQSL5By4G43JVaeHiqfVp9oh

{
  "statusCode": 500,
  "error": "Internal Server Error",
  "message": "An internal server error occurred"
}

need to remove the senderId:

http://localhost:4003/api/transactions?orderBy=timestamp:desc&offset=0&limit=50&recipientId=DTRdbaUW3RQQSL5By4G43JVaeHiqfVp9oh

{
  "transactions": []
}

This was pulled directly from the Desktop Wallet, where I added my devnet v2 node to.

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.