Skip to content

Commit

Permalink
Merge pull request #2019 from ergoplatform/v5.0.14
Browse files Browse the repository at this point in the history
5.0.14 release candidate
  • Loading branch information
kushti committed Aug 25, 2023
2 parents 3561825 + ee27cc6 commit a057767
Show file tree
Hide file tree
Showing 38 changed files with 1,979 additions and 279 deletions.
10 changes: 7 additions & 3 deletions FAQ.md
Expand Up @@ -44,12 +44,16 @@ The details of the Ergo emission schedule and monetary supply can be found in th

* Website: https://ergoplatform.org/

* Twitter: https://twitter.com/ergoplatformorg
* ErgoDocs: https://docs.ergoplatform.com

* Wiki: https://github.com/ergoplatform/ergo/wiki
* Twitter: https://twitter.com/Ergo_Platform

* Telegram: https://t.me/ergoplatform

* Ecosystem: https://sigmaverse.io
*
* Github: https://github.com/ergoplatform/ergo

* Documents: https://ergoplatform.org/en/documents/

* Telegram: https://t.me/ergoplatform
* Wiki: https://github.com/ergoplatform/ergo/wiki
118 changes: 73 additions & 45 deletions README.md
@@ -1,68 +1,96 @@
# Ergo

This repository contains the reference implementation of the
Ergo Platform protocol, which is an alternative to
the [Bitcoin protocol](https://bitcoin.org/bitcoin.pdf).
Welcome to the official repository for the [Ergo Platform](https://ergoplatform.org/). 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.

Ergo Platform website: [https://ergoplatform.org/](https://ergoplatform.org/)
The reference client is primarily written in Scala. While certain components of the protocol are implemented in other languages (for instance, [sigma-rust](https://github.com/ergoplatform/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.

## Differences from Bitcoin
## Key Features of Ergo

* Powerful contracts in the multi-stage extended UTXO model (see [ErgoScript whitepaper](https://ergoplatform.org/docs/ErgoScript.pdf))
* Memory-hard Proof-of-Work function [Autolykos2](https://docs.ergoplatform.com/ErgoPow.pdf)
* Support for stateless clients (asymmetric, based on [https://eprint.iacr.org/2016/994](https://eprint.iacr.org/2016/994)),
[NiPoPoWs](https://eprint.iacr.org/2017/963.pdf), hybrid modes
* [Alternative transactional language](https://github.com/ScorexFoundation/sigmastate-interpreter), which is more powerful than Bitcoin Script but also safe against
heavy validation attacks
* Alternative fee model with [mandatory storage-rent component](https://fc18.ifca.ai/bitcoin/papers/bitcoin18-final18.pdf )
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](https://ergoplatform.org/docs/ErgoScript.pdf).
* **Autolykos2**: A memory-hard Proof-of-Work function, providing enhanced security. Learn more about it [here](https://docs.ergoplatform.com/ErgoPow.pdf).
* Support for Stateless Clients: Ergo supports asymmetric stateless clients, based on [this paper](https://eprint.iacr.org/2016/994), and includes features like NiPoPoWs and hybrid modes.
* **Advanced Transactional Language**: Ergo introduces an [alternative transactional language](https://github.com/ScorexFoundation/sigmastate-interpreter) 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](https://fc18.ifca.ai/bitcoin/papers/bitcoin18-final18.pdf ) (also known as demurrage).

## Specifications

A [White Paper](https://ergoplatform.org/docs/whitepaper.pdf) with a brief description is available. A Yellow Paper with detailed specification is underway and will be available shortly. At the moment, there are [drafts of the Yellow Paper](https://github.com/ergoplatform/ergo/tree/master/papers/yellow) available,
and currently the reference implementation code should be considered as the specification.
* [white paper](https://ergoplatform.org/docs/whitepaper.pdf) - a brief description of the protocol
* [ErgoScript white paper](https://ergoplatform.org/docs/ErgoScript.pdf) - describes ErgoScript, a Cryptocurrency Scripting Language Supporting Noninteractive Zero-Knowledge Proofs used in Ergo

More papers can be found at [docs.ergoplatform.com/documents](https://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](https://docs.ergoplatform.com/node/install/).

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](https://eprint.iacr.org/2018/129.pdf). To enable this feature add the following to your configuration file:
```
ergo {
...
node.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](https://eprint.iacr.org/2017/963.pdf).
```
ergo{
...
node.nipopow.nipopowBootstrap = true
node.utxo.utxoBootstrap = true
...
}
```

* The stateless mode provides full-node security without the need to hold the entire UTXO set. This is achieved through the methods detailed in the ["Improving Authenticated Dynamic Dictionaries, with Applications to Cryptocurrencies" paper](https://eprint.iacr.org/2016/994.pdf). In this mode, it's possible to download and validate an arbitrary-sized suffix of the blockchain. Here's an example of how to configure this mode:

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

This client relies on some assumptions in regards with its environment:

* execution environment is trusted. While seed is stored in encrypted files, and the client's
wallet tries to remove secret key from memory as soon as possible when it is not needed, the
client has no protection from side-channel attacks, memory scans etc.
* clocks should be more or less synchronized. If timestamp of a block is more than 20 minutes
in future, the block will be temporarily rejected. The client does not use NTP or other time
syncing protocols.
For more detailed information on different modes of node operation, please visit [docs.ergoplatform.com/node/modes](https://docs.ergoplatform.com/node/modes).

## Building and Running Node and UI
## Testing Procedures

See [documentation](https://docs.ergoplatform.com/node/install/)
Ergo utilizes three types of tests:

## Testing
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 regimes. Docker is also required for these tests. Run them with the `sudo sbt it2:test` command.

There are three kinds of tests:
## Setting up the Project in an IDE

1) Unit and property tests, run them with `sbt test` command.
2) Integration tests, they require for Docker to be installed, then run `sudo sbt it:test`.
3) Bootstrapping tests, very slow as they are checking that the node is indeed catching up with the main network in
different regimes, they require for Docker too, run as `sudo sbt it2:test`.
You can use either [IntelliJ IDEA](https://www.jetbrains.com/idea/) (Community or Ultimate edition) or [VSCode](https://code.visualstudio.com/) with the [Metals](https://scalameta.org/metals/) extension.

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

Your can use [IntelliJ IDEA](https://www.jetbrains.com/idea/) (Community or Ultimate edition) or
[VSCode](https://code.visualstudio.com/) + [Metals](https://scalameta.org/metals/).
Before opening the project in IDE make sure it can be built with sbt.
You may need to fix dependency resolution 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.

After that you can open the project folder in Idea (File / Open)
which will run Project Import Wizard. The wizard will use SBT configuration
(build.sbt file) to generate Idea's project configuration files.
You can open `File / Project Structure...` dialog to see project configuration.
If everything is successful you can compile the project in IDE.
## Contributing to Ergo

## Contributions
Ergo is an open-source project and we welcome contributions from developers and testers! Join the discussion on [Ergo Discord](https://discord.gg/kj7s7nb) in the #development channel and check out our [Contributing documentation](https://docs.ergoplatform.com/contribute/).

Ergo is open-source and open movement, always in need for testers and developers! Please feel free
to discuss development in [Ergo Discord](https://discord.gg/kj7s7nb), #development channel.
## Frequently Asked Questions

## FAQ
[Frequently Asked Questions](FAQ.md)
For common queries, please refer to our [Frequently Asked Questions](FAQ.md) page.

Expand Up @@ -5,7 +5,7 @@ import scorex.crypto.authds.avltree.batch.Constants.{DigestType, HashFnType, has
import scorex.crypto.authds.avltree.batch.VersionedLDBAVLStorage.{topNodeHashKey, topNodeHeightKey}
import scorex.crypto.authds.avltree.batch.serialization.{BatchAVLProverManifest, BatchAVLProverSubtree, ProxyInternalNode}
import scorex.crypto.authds.{ADDigest, ADKey}
import scorex.util.encode.Base58
import scorex.util.encode.Base16
import scorex.crypto.hash
import scorex.crypto.hash.Digest32
import scorex.db.{LDBKVStore, LDBVersionedStore}
Expand Down Expand Up @@ -42,11 +42,12 @@ class VersionedLDBAVLStorage(store: LDBVersionedStore)

override def rollback(version: ADDigest): Try[(ProverNodes[DigestType], Int)] = Try {
if (!this.version.contains(version)) { // do not rollback to self
log.info(s"Doing rollback from ${this.version.map(Base16.encode)} to ${Base16.encode(version)}:")
store.rollbackTo(version)
}
}.flatMap(_ => restorePrunedRootNode())
.recoverWith { case e =>
log.warn(s"Failed to recover tree for digest ${Base58.encode(version)}:", e)
log.warn(s"Failed to recover tree for digest ${Base16.encode(version)}:", e)
Failure(e)
}

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Expand Up @@ -37,7 +37,7 @@ val circeVersion = "0.13.0"
val akkaVersion = "2.6.10"
val akkaHttpVersion = "10.2.4"

val sigmaStateVersion = "5.0.8"
val sigmaStateVersion = "5.0.10"

// for testing current sigmastate build (see sigmastate-ergo-it jenkins job)
val effectiveSigmaStateVersion = Option(System.getenv().get("SIGMASTATE_VERSION")).getOrElse(sigmaStateVersion)
Expand Down
Expand Up @@ -4,11 +4,11 @@ import org.ergoplatform.ErgoLikeContext.Height
import org.ergoplatform.sdk.wallet.protocol.context.ErgoLikeParameters
import org.ergoplatform.wallet.protocol.Constants
import org.ergoplatform.{ErgoBox, ErgoBoxCandidate, ErgoLikeContext, ErgoLikeInterpreter}
import scorex.crypto.authds.ADDigest
import scorex.util.ScorexLogging
import sigmastate.Values.ErgoTree
import sigmastate.interpreter.Interpreter.{ScriptEnv, VerificationResult}
import sigmastate.{AvlTreeData, AvlTreeFlags}
import special.collection.Coll

import scala.util.Try

Expand Down Expand Up @@ -100,7 +100,7 @@ object ErgoInterpreter {
new ErgoInterpreter(params)

/** Create [[AvlTreeData]] with the given digest and all operations enabled. */
def avlTreeFromDigest(digest: ADDigest): AvlTreeData = {
def avlTreeFromDigest(digest: Coll[Byte]): AvlTreeData = {
val flags = AvlTreeFlags(insertAllowed = true, updateAllowed = true, removeAllowed = true)
AvlTreeData(digest, flags, Constants.HashLength)
}
Expand Down
@@ -1,6 +1,6 @@
package org.ergoplatform.wallet.serialization

import org.ergoplatform.JsonCodecs
import org.ergoplatform.sdk.JsonCodecs

/**
* JSON Codecs provided as singleton package, not trait.
Expand Down
@@ -1,9 +1,9 @@
package org.ergoplatform.wallet.interpreter

import org.ergoplatform.sdk.wallet.protocol.context.{ErgoLikeParameters, ErgoLikeStateContext}
import scorex.crypto.authds.ADDigest
import scorex.util.encode.Base16
import sigmastate.basics.CryptoConstants
import sigmastate.eval.Extensions.ArrayOps
import sigmastate.eval.{CGroupElement, CPreHeader, Colls}
import special.collection.Coll
import special.sigma.{Header, PreHeader}
Expand Down Expand Up @@ -39,9 +39,10 @@ trait InterpreterSpecCommon {

override def sigmaLastHeaders: Coll[Header] = Colls.emptyColl

override def previousStateDigest: ADDigest =
ADDigest @@ Base16.decode("a5df145d41ab15a01e0cd3ffbab046f0d029e5412293072ad0f5827428589b9302")
override def previousStateDigest: Coll[Byte] =
Base16.decode("a5df145d41ab15a01e0cd3ffbab046f0d029e5412293072ad0f5827428589b9302")
.getOrElse(throw new Error(s"Failed to parse genesisStateDigest"))
.toColl

override def sigmaPreHeader: PreHeader = CPreHeader(
version = 0,
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/.well-known/ai-plugin.json
@@ -0,0 +1,18 @@
{
"schema_version": "v1",
"name_for_human": "Ergo Node Plugin (no auth)",
"name_for_model": "ergonode",
"description_for_human": "Plugin for interacting with Ergo node.",
"description_for_model": "Specification of Ergo Node API for ChatGPT plugin.\n The following endpoints supported \n - /blocks/chainSlice - Get headers in a specified range of heights\n - /info - Get the basic information about the status of Ergo Node. \n - /transactions/unconfirmed/byTransactionId - Get unconfirmed transaction from the mempool\n - /transactions/poolHistogram - Get histogram (waittime, (n_trans, sum(fee)) for transactions in mempool.\n - /peers/connected - Get a list of current connected peers\n - /peers/blacklisted - Get a list of blacklisted peers\n - /utils/address - Check address validity\n - /blockchain/indexedHeight - Get current indexed block height. (The indexer has processed all blocks up to this height.)\n - /blockchain/transaction/byId - Retrieve a transaction by its id\n - /blockchain/transaction/byAddress - Retrieve a list of transactions by their associated address\n - /blockchain/box/byId - Retrieve a box by its id\n - /blockchain/box/byAddress - Retrieve boxes by their associated \n - /blockchain/box/unspent/byAddress - Retrieve unspent boxes by their associated address\n - /blockchain/token/byId - Retrieve minting information about a token\n - /blockchain/balanceForAddress - Retrieve balance information of an Ergo address.",
"auth": {
"type": "none"
},
"api": {
"type": "openapi",
"url": "http://localhost:9053/openapi.yaml",
"is_user_authenticated": false
},
"logo_url": "https://cryptologos.cc/logos/ergo-erg-logo.png",
"contact_email": "team@ergoplatform.org",
"legal_info_url": "https://ergoplatform.org/en/legal/"
}

0 comments on commit a057767

Please sign in to comment.