Code Monkey home page Code Monkey logo

ergo's Introduction

Ergo

Welcome to the official repository for the Ergo Platform. This repository contains the reference client, also known as the node, for Ergo. Ergo is a cryptocurrency protocol that has been designed to offer a secure environment for peer-to-peer transactions. It supports programmable scarce money (Ergo) and a wide range of financial tools.

The reference client is primarily written in Scala. While certain components of the protocol are implemented in other languages (for instance, sigma-rust is a Rust-based implementation of the ErgoScript cryptocurrency scripting language), the reference client provides the most complete and comprehensive implementation of the Ergo protocol.

Key Features of Ergo

Ergo, while sharing some commonalities with Bitcoin as a UTXO Proof-of-Work cryptocurrency, stands out due to its unique design and features. It has been built from the ground up, introducing several innovative elements:

  • ErgoScript: A powerful contract language in the multi-stage extended UTXO model. More details can be found in the ErgoScript whitepaper.
  • Autolykos2: A memory-hard Proof-of-Work function, providing enhanced security. Learn more about it here.
  • Support for Stateless Clients: Ergo supports asymmetric stateless clients, based on this paper, and includes features like NiPoPoWs and hybrid modes.
  • Advanced Transactional Language: Ergo introduces an alternative transactional language that is more powerful than Bitcoin Script and is designed to be safe against heavy validation attacks.
  • Innovative Fee Model: Ergo implements an alternative fee model with a mandatory storage-rent component (also known as demurrage).

Specifications

  • white paper - a brief description of the protocol
  • ErgoScript white paper - describes ErgoScript, a Cryptocurrency Scripting Language Supporting Noninteractive Zero-Knowledge Proofs used in Ergo

More papers can be found at docs.ergoplatform.com/documents.

Security Assumptions

The Ergo client operates under certain assumptions about its environment:

  • The execution environment is trusted. Although the seed is stored in an encrypted file, and the client's wallet attempts to purge the secret key from memory as soon as it is no longer needed, the client does not have defenses against side-channel attacks, memory scans, etc.
  • Clocks are expected to be synchronized to a reasonable degree. If a block's timestamp is more than 20 minutes into the future, the block will be temporarily rejected. The client does not utilize NTP or other time synchronization protocols.

Building and Running the Node and UI

For instructions on how to build and run the node and UI, refer to the official documentation.

By default, the node processes all blocks from the genesis block. However, there are other options available that may be more suitable for hardware with limited resources.

  • Bootstrapping with a UTXO set snapshot: This works similarly to Ethereum's snap-sync. The node first downloads a UTXO set snapshot from a secure point in the past, then downloads blocks following the UTXO set snapshot and applies them to the set. For more details and security proofs, refer to the "Multi-mode cryptocurrency systems" paper. To enable this feature add the following to your configuration file:

ergo {
  ...
  node.utxo.utxoBootstrap = true
  ...
}
  • The UTXO set snapshot bootstrapping can be further optimized by combining it with NiPoPoW (Non-Interactive Proofs of Proof-of-Work). This method allows for syncing the headers-chain in logarithmic time, as opposed to the linear time required by the standard SPV sync for headers. For more details, refer to the NiPoPoW paper.

ergo{
  ...
  node.nipopow.nipopowBootstrap = true
  node.utxo.utxoBootstrap = true
  ...
}
ergo {
   ...
   node.stateType = "digest"
   node.blocksToKeep = 2160 # store and process last three days only
   node.nipopow.nipopowBootstrap = true   # compatible with NiPoPoWs 
   ...
}

For more detailed information on different modes of node operation, please visit docs.ergoplatform.com/node/modes.

Testing Procedures

Ergo utilizes three types of tests:

  1. Unit and property tests: These can be run using the sbt test command.
  2. Integration tests: These tests require Docker to be installed. Run them with the sudo sbt it:test command.
  3. Bootstrapping tests: These tests are time-consuming as they verify that the node is syncing with the main network in various modes. Docker is also required for these tests. Run them with the sudo sbt it2:test command.

Setting up the Project in an IDE

You can use either IntelliJ IDEA (Community or Ultimate edition) or VSCode with the Metals extension.

Ensure that the project can be built with sbt before opening it in an IDE. You may need to resolve any dependency errors first.

To open the project in IntelliJ IDEA, select File / Open and navigate to the project folder. This will initiate the Project Import Wizard, which uses the SBT configuration (build.sbt file) to generate the project configuration files for IDEA. You can view the project configuration in the File / Project Structure... dialog. If the import is successful, you should be able to compile the project in the IDE.

Modules

This repository has modular structure, so only parts which are needed for an application could be used:

  • avldb - implementation of authenticated AVL+ tree used in Ergo, with persistence
  • ergo-core - functionality needed for an SPV client (P2P messages, block section stuctures, PoW, NiPoPoW)
  • ergo-wallet - Java and Scala functionalities to sign and verify transactions

Using IntelliJ IDEA be sure to set Build Tools / sbt -> sbt shell / use for / builds, to avoid compilation errors

Contributing to Ergo

Ergo is an open-source project and we welcome contributions from developers and testers! Join the discussion over Ergo Discord in #development channel, or Telegram: https://t.me/ErgoDevelopers. Please also check out our Contributing documentation.

Frequently Asked Questions

For common queries, please refer to our Frequently Asked Questions page.

ergo's People

Contributors

andyceo avatar anon-yum avatar anon-yum2 avatar apextheory avatar aslesarenko avatar builat avatar catena2w avatar ccellado avatar deadit avatar ergomorphic avatar glasgowm148 avatar greenhat avatar gtklocker avatar jellymlg avatar kaichaosun avatar kettlebell avatar knizhnik avatar kushti avatar mike-aksarin avatar notelos avatar oskin1 avatar pragmaxim avatar ra3dnr avatar reqlez avatar ross-weir avatar scalahub avatar semyonoskin avatar terjokhin avatar tolsi avatar victormikheev 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ergo's Issues

Write tests for API

Write tests that check, that API requests and responses correspondes to src/main/resources/api/openapi.yaml

Fix findbugs issues

Findbugs (connected via sbt-findbugs plugin) finds 7 high-priority and 356 medium-priority issues. It would be good to reduce these numbers significantly, at least.

Fix API

And provide some rules how to write new API methods

Missing modifiers cache rework

Currently, toDownload structure in DeliveryTracker is used to store modifiers to download, and the structure is initially populated with missedModifiersForFullChain(). There are many problems with this approach, in particular, we need to store modifiers in (potentially, big) cache for limited time, and no chance to restore a modifier after removal from the cache.

As a solution, it is reasonable to have persistent cache of modifiers to download in History, and a method to get limited number of records in the cache.

Alternative approaches to forks comparison

Currently, two peers are exchanging lists of block ids of certain size and try to find a common block. Then a peer which decides that it is younger tries to upload blocks from another peer.

Maybe it is better to exchange with some number of headers, not ids. for example, we can adopt interactive KLS16 protocol, or non-interactive KMZ17 (with reasonable m&k parameters).

Spam script

Make a script which bombs network with a lot of transactions

AD Proofs

Build the persisted AVL+ tree from boxes (UTXO)
Implement ADProofVerify interface

Optimized hardware CPU/GPU miners support

Adopt some EquiHash (probably ZCash) GPU miner to be able to mine ERGO.
Should get block candidate from API of ergo node and publish block via API when corresponding nonce is found.

Application shutdown

Check that node shutdown correctly. For now it throws an Exception, not sure that it closes in consistent state

Add readme.md

Add project description, build status, code coverage, ...

Node not get connected to all known nodes

/peers/all response show:

[
  {
    "address": "159.203.94.149/159.203.94.149:9001",
    "lastSeen": 1518090270055,
    "connectionType": "outgoing"
  },
  {
    "address": "139.59.254.126/139.59.254.126:9001",
    "lastSeen": 1518090270055,
    "connectionType": "outgoing"
  },
  {
    "address": "static.88-198-13-202.clients.your-server.de/88.198.13.202:9001",
    "lastSeen": 1518090270055,
    "connectionType": "outgoing"
  }
]

but peers/connected show only this:

[
  {
    "address": "None",
    "name": "DO-139.59.254.126",
    "lastSeen": 1518090086364
  },
  {
    "address": "None",
    "name": "ergo-seed",
    "lastSeen": 1518090086364
  }
]

anwer from info shows that "peersCount" : 2,

Seems like something going wrong behaviour...

Make "testnet" section in settings

Currently, we have "node" and "chain" sections. For testnet-specific settings (whether to how generate testing transactions, how many transactions to put in a block etc), we need to create a new "testnet" section.

Incorrect loading of existed state

After start the node with existed state always throws the exception:

...
Caused by: java.lang.AssertionError: assertion failed
	at scala.Predef$.assert(Predef.scala:204)
	at scala.Predef$Ensuring$.ensuring$extension2(Predef.scala:316)
	at org.ergoplatform.nodeView.state.ErgoState$.generateGenesisUtxoState(ErgoState.scala:71)
	at org.ergoplatform.nodeView.UtxoErgoNodeViewHolder.genesisState(UtxoErgoNodeViewHolder.scala:21)
	at scorex.core.NodeViewHolder.$anonfun$nodeView$1(NodeViewHolder.scala:55)
	at scala.Option.getOrElse(Option.scala:121)
	at scorex.core.NodeViewHolder.$init$(NodeViewHolder.scala:55)
	at org.ergoplatform.nodeView.ErgoNodeViewHolder.<init>(ErgoNodeViewHolder.scala:20)
	at org.ergoplatform.nodeView.UtxoErgoNodeViewHolder.<init>(UtxoErgoNodeViewHolder.scala:12)
	... 18 more


StateSnapshot download

Synchronize node by downloading headers chain (or PoPoW proof), state snapshot and full blocks after snapshot

Unexpected messages in NodeViewSynchronizer

[scorex-akka.actor.default-dispatcher-11] >> [ERROR] s.core.network.NodeViewSynchronizer >> 13:52:07.429 Strange input: SemanticallySuccessfulModifier(Header({"votes":"11111","timestamp":1509101514574,"nonce":-9223372036854775808,"ADProofsRoot":"8tvBaVQaZc3FDpuAcokbghEFCFhwXD3P31FwQPeVcfSQ","stateRoot":"dgVXun3QExP45dP8sGYwc2goLTrAjgx2gTqJBq7FWHgqd","height":5,"nBits":16842752,"id":"41eg8nohapmkRCw8e8kyUZJtjWhZvwDfda37vrKuijZF","interlinks":["3zKbmGkDDYtGa9Mcx36hTcQGLAHxAfwBMc5M3deQWr9n","2xS1PX1J96d4EoSXumvWkMhL8TeMCCUssAvhPrBPZBVH","2xS1PX1J96d4EoSXumvWkMhL8TeMCCUssAvhPrBPZBVH","2xS1PX1J96d4EoSXumvWkMhL8TeMCCUssAvhPrBPZBVH"],"transactionsRoot":"9XLt3EjKbUrNeGSiMaFFJkYAWSA9duyg2zAkjv11v1fL","equihashSolutions":"1153cRfEHDqbjywexVDvpqPX9Mo2VeCo7b1p3zoDUwvtwPb6vhbAgGzovhJXVJpHxzFXoweCrang9gqNvqhFpF16d8fGdXQXEYGNbQvhZMvQLUqu9ctGVbc28CVSMBzGQZTs2jDR4bpqg837vGpFQxf9XCSie9EKiAFa4b78Hq9ofk","parentId":"CoNpwAqoJPcKNE8sZLt7mzeEZ2rqRbCdcPafhSa61FYT"}) Binary: 12PcxYu7ZC2rbYuAWkeXKibPUzRN5q52DXoNoRmW5uyG3szxhiqKN2jYyii16NpZ6QJjhmkHhERZN1jXH6Qi3j6VcFMGiDZMLNgeGmDz9uuCAzbAcnGwnBP9wqEow2iS7n8tgj2SoCs9Hvq7KmBrdw15k1EudcQL5TV5WgcMCjHxYKJt2P6wksBgV48VnrLWBzYwmaCb4KYRD1tuMQoTXhP7JF8qrFfpvEs28d8eUpP55FA7FU3VFFek1MP8bpH9hz5PJYaD1Vj1JD6h3w2G7hKSWKet9nTcumM7qGmt4DsXPBGyPwZp4vAXh47E6u9fAwF9MwFdrXBJKBh2MuSqqXehcTwXRNWAdbEtFAVrQJs2LyyTg2AYA42rJFTu6aaSwYim8J6CFWg7xmZSZ5fbVjN8TfkMq4XhQM3K4oWeP9TgCjAzY4RiiCGyPiruQSafaVVPrvpnpTMxJbSTWgzFozBXhFLxKiR3vq55ToLi)

Header of invalid block remains in the best chain

Test DigestErgoNodeViewHolderSpecification.("apply invalid full block") (now ignored) highlights the problem of invalid full-block application - a header of invalid block remains in the best chain.

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.