Skip to content

Commit

Permalink
merging w. 5.0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Sep 12, 2023
2 parents 136e8fc + a4072cc commit 373005b
Show file tree
Hide file tree
Showing 453 changed files with 21,100 additions and 8,907 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.10, 2.11.12]
scala: [2.13.8, 2.12.10, 2.11.12]
java: [[email protected]]
runs-on: ${{ matrix.os }}
steps:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: qemu
uses: docker/setup-qemu-action@v1

- uses: docker/setup-buildx-action@v1

- name: Docker Login
uses: docker/[email protected]
Expand All @@ -29,5 +34,6 @@ jobs:
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ devnet

# IDE/Editor files
.idea
.bsp
.ensime
.ensime_cache/
scorex.yaml
Expand Down Expand Up @@ -61,6 +62,7 @@ local.conf
.metals/
.vscode/
project/metals.sbt
null/

# scala worksheets
*.worksheet.sc
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mozilla/sbt:11.0.8_1.3.13 as builder
FROM sbtscala/scala-sbt:eclipse-temurin-11.0.15_1.7.1_2.13.8 as builder
WORKDIR /mnt
COPY build.sbt findbugs-exclude.xml ./
COPY project/ project/
Expand All @@ -12,14 +12,15 @@ COPY . ./
RUN sbt assembly
RUN mv `find target/scala-*/stripped/ -name ergo-*.jar` ergo.jar

FROM openjdk:11-jre-slim
FROM eclipse-temurin:11-jre-jammy
RUN apt-get update && apt-get install -y curl jq && rm -rf /var/lib/apt/lists/*
RUN adduser --disabled-password --home /home/ergo --uid 9052 --gecos "ErgoPlatform" ergo && \
install -m 0750 -o ergo -g ergo -d /home/ergo/.ergo
USER ergo
EXPOSE 9020 9052 9030 9053
EXPOSE 9020 9021 9022 9052 9030 9053
WORKDIR /home/ergo
VOLUME ["/home/ergo/.ergo"]
ENV MAX_HEAP 3G
ENV _JAVA_OPTIONS "-Xmx${MAX_HEAP}"
ENV _JAVA_OPTIONS "-Xms${MAX_HEAP} -Xmx${MAX_HEAP}"
COPY --from=builder /mnt/ergo.jar /home/ergo/ergo.jar
ENTRYPOINT ["java", "-jar", "/home/ergo/ergo.jar"]
54 changes: 53 additions & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
# Frequently Asked Questions

TODO, currently you can find a FAQ at [https://ergoplatform.org/en/faq/](https://ergoplatform.org/en/faq/)
## What is Ergo?

Ergo is a Resilient Platform for Contractual Money. It is designed to be a platform for applications with the main focus to provide an efficient, secure and easy way to implement financial contracts.

To achieve this goal, Ergo includes various technical and economic improvements to existing blockchain solutions. Every coin in Ergo is protected by a program in ErgoScript, which is a powerful and protocol friendly scripting language based on Σ-protocols. It specifies conditions under which a coin can be used: who can spend them, when, under what external conditions, to whom, and so on.

Extended support of light nodes makes Ergo friendly for end users and allows it to run contracts on common devices such as mobile phones trustlessly. To be useful in the long-term, Ergo is strictly following a long‐term survivability approach — it uses widely-researched solutions that are not going to result in security issues in the future, while also preventing performance degradation over time with a new economic model.

Finally, Ergo is a self‐amendable protocol, that allows it to absorb new ideas and improve itself in the future. The focuses on long‐term survivability and self‐amendability are what give Ergo its resiliency.

## What does Contractual Money Mean?

In our opinion, the overwhelming majority of successful public blockchain use‐cases are related to financial applications. Ergo is extending Bitcoin’s way of writing contracts by attaching a protecting script (together with additional custom data) to every coin. Thus Ergo applications are defined in terms of guarding scripts built into boxes also containing data involved in execution. We coin the term Contractual Money for Ergs and secondary tokens which usage is bounded by a contract. For example, in addition to regular protection by some m‐of‐n signature, Ergo allows specifying, who are the possible recipients of these coins, which may also be a contract with such complex conditions. This "chaining" approach allows implementing secure and efficient contracts of arbitrary complexity.

## What was the ICO price?

Ergo is following the most decentralized way of emission and will start with zero coins in supply with the “minting” of the entire coin supply happening during the first eight years of Ergo mainnet, using the tried and tested PoW mining method. There was no ICO of Ergo. No VC Funding. No Pre mine.

## How to mine Ergo?

You need [a configured (Ergo node)](https://github.com/ergoplatform/ergo/wiki/Set-up-a-full-node) and GPU with at least 4 Gb of memory (while 8 Gb is recommended for maximum efficiency). Use this [guide](https://github.com/ergoplatform/ergo/wiki/Mining) to configure miner together with the node. Note, that you may employ many GPUs together on one Ergo node.

## How to find Ergo mining pools?

See the mining pools listed [here](https://miningpoolstats.stream/ergo). Please select one of the smaller pools.

## Does Ergo have a block size limit?

No, Ergo does not have a hard block size limit. Instead, the block size can increase or decrease over time based on demand. It is capped at a certain growth rate to prevent excessive growth in a short period of time.

## Why does Ergo have its own smart contract language?

The design space of programming languages is very broad ranging from general-purpose languages like C, Java, Python up to specialized languages like SQL, HTML, CSS, however, none of them was designed for the Contractual Money application.

ErgoScript was designed to achieve several properties. It only contains deterministic operations to maintain consensus in the network. To prevent possible spam attacks ErgoScript supports ahead-of-time cost estimation, excluding a wide range of operations like possibly infinite loops. But even keeping all these limitations in mind, ErgoScript is expressive enough to implement complex smart contracts, including Turing-complete smart contracts but in a secure manner.

## What is the Ergo token emission schedule and total monetary base?

The details of the Ergo emission schedule and monetary supply can be found in the blog post [here](https://ergoplatform.org/en/blog/2019_05_20-curve/).

## Where can I learn more about Ergo?

* Website: https://ergoplatform.org/

* Twitter: https://twitter.com/ergoplatformorg

* Wiki: https://github.com/ergoplatform/ergo/wiki

* Github: https://github.com/ergoplatform/ergo

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

* Telegram: https://t.me/ergoplatform
78 changes: 11 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Ergo Platform website: [https://ergoplatform.org/](https://ergoplatform.org/)
* 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 that Bitcoin Script but also safe against
* [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 )

Expand All @@ -21,76 +21,20 @@ heavy validation attacks
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.

## Installation
## Security assumptions

You can check our [Setup A Full Node](https://github.com/ergoplatform/ergo/wiki/Set-up-a-full-node) wiki page to learn how to manually setup and configure a node.
This client relies on some assumptions in regards with its environment:

Alternatively you can run the prepared [ergo-installer.sh](ergo-installer.sh) script. With this script you'll have the latest Ergo node installed without any hassle (only availalbe for Linux distributions):
* 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.

curl -s https://raw.githubusercontent.com/ergoplatform/ergo/master/ergo-installer.sh | sh -s -- --api-key=<YOUR_API_KEY>
## Building and Running Node and UI

## Build from source

In order to build the Ergo node from sources you need JDK (>= 1.8) and SBT to be
[installed](https://docs.scala-lang.org/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.html) on your machine.

In order to simply get a single jar run: `sbt assembly` - assembly would appear in `target/scala-2.12/` directory.

If you want to create a package for a specific platform with launching scripts the one of the following
packager commands could be chosen (depending on desired system type you want to build for):
- `universal:packageBin` - Generates a universal zip file
- `universal:packageZipTarball` - Generates a universal tgz file
- `debian:packageBin` - Generates a deb
- `docker:publishLocal` - Builds a Docker image using the local Docker server
- `rpm:packageBin` - Generates an rpm
- `universal:packageOsxDmg` - Generates a DMG file with the same contents as the universal zip/tgz.
- `windows:packageBin` - Generates an MSI

The final build command should look like: `sbt <packager_command>`, example: `sbt universal:packageBin`.
A resulted package could be found in the `target/scala-2.12/<platform_type>` directory.

## Running the node

The node can be started in a couple different ways:

- In case you only have a jar: `java -jar /path/to/ergo-<version>.jar --<networkId> -c /path/to/local.conf`
- Using start script from sbt-native-packager: `sh /path/to/bin/ergo --<networkId> -c /path/to/local.conf`

Available `networkId` options: `mainnet`, `testnet`, `devnet`.

## UI

Node UI (graphical interface) could be accessed at `<node_ip>:<api_port>/panel` in your browser.

<img src="https://github.com/ergoplatform/static-data/raw/master/img/node_ui.png" align="right" />

## Docker Quick Start

Ergo has officially supported Docker package. To run last Ergo version in mainnet as a console application with logs printed to console:

sudo docker run --rm -p 9030:9030 -p 127.0.0.1:9053:9053 -v /path/on/host/to/ergo/data:/home/ergo/.ergo ergoplatform/ergo --mainnet

This will connect to Ergo mainnet with default config and open port `9030` globally and `9053` locally on the host system. All data will be stored in your host directory `/path/on/host/to/ergo/data`.

To run specific Ergo version `<VERSION>` as a service with custom config `/path/on/host/system/to/myergo.conf`:

sudo docker run -d \
-p 9030:9030 \
-p 127.0.0.1:9053:9053 \
-v /path/on/host/to/ergo/data:/home/ergo/.ergo \
-v /path/on/host/system/to/myergo.conf:/etc/myergo.conf \
-e MAX_HEAP=3G \
ergoplatform/ergo:<VERSION> --<networkId> -c /etc/myergo.conf

Available versions can be found on [Ergo Docker image page](https://hub.docker.com/r/ergoplatform/ergo/tags), for example, `v4.0.20`.

This will connect to the Ergo mainnet or testnet following your configuration passed in `myergo.conf` and network flag `--<networkId>`. Every default config value would be overwritten with corresponding value in `myergo.conf`. `MAX_HEAP` variable can be used to control how much memory can the node consume.

This command also would store your data in `/path/on/host/to/ergo/data` on host system, and open ports `9030` (node communication) globally and `9053` (REST API) locally on host system. The `/path/on/host/to/ergo/data` directory must has `777` permissions or has owner/group numeric id equal to `9052` to be writable by container, as `ergo` user inside Docker image (please refer to [Dockerfile](Dockerfile)).

Ergo node works normally behind NAT, so you can keep closed your `9030` port, hence other nodes could not discover and connect to yours one, only your node could initiate connections.

It is also a good practice to keep closed REST API port `9053`, and connect to your node from inside another container in the same Docker network (this case not covered by this short quick start manual).
See [documentation](https://docs.ergoplatform.com/node/install/)

## Testing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object AVLTreeBatchPerformance extends {
val logger = LoggerFactory.getLogger("TEST")
var prover: Prover = _
var store: LDBVersionedStore = _
var storage: VersionedLDBAVLStorage[Digest32] = _
var storage: VersionedLDBAVLStorage = _
var operations: Array[Operation] = _

@Setup(Level.Iteration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object Helper {
type HF = Blake2b256.type
type Prover = PersistentBatchAVLProver[Digest32, HF]

implicit val hf = Blake2b256
implicit val hf: HF = Blake2b256

val kl = 32
val vl = 8
Expand All @@ -33,12 +33,12 @@ object Helper {
inserts ++ updates
}

def persistentProverWithVersionedStore(keepVersions: Int,
baseOperationsCount: Int = 0): (Prover, LDBVersionedStore, VersionedLDBAVLStorage[Digest32]) = {
def persistentProverWithVersionedStore(initialKeepVersions: Int,
baseOperationsCount: Int = 0): (Prover, LDBVersionedStore, VersionedLDBAVLStorage) = {
val dir = java.nio.file.Files.createTempDirectory("bench_testing_" + scala.util.Random.alphanumeric.take(15)).toFile
dir.deleteOnExit()
val store = new LDBVersionedStore(dir, keepVersions = keepVersions)
val storage = new VersionedLDBAVLStorage(store, NodeParameters(kl, Some(vl), ll))
val store = new LDBVersionedStore(dir, initialKeepVersions = initialKeepVersions)
val storage = new VersionedLDBAVLStorage(store)
require(storage.isEmpty)
val prover = new BatchAVLProver[Digest32, HF](kl, Some(vl))

Expand Down
10 changes: 5 additions & 5 deletions avldb/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ name := "avldb"
libraryDependencies ++= Seq(
"javax.xml.bind" % "jaxb-api" % "2.4.0-b180830.0359",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"org.scorexfoundation" %% "scrypto" % "2.1.10"
"com.google.guava" % "guava" % "23.0",
"org.scorexfoundation" %% "scrypto" % "2.3.0"
)

libraryDependencies ++= Seq(
Expand All @@ -16,13 +17,12 @@ libraryDependencies ++= Seq(
)

libraryDependencies ++= Seq(
"org.ethereum" % "leveldbjni-all" % "1.18.3"
"org.ethereum" % "leveldbjni-all" % "1.18.3",
"org.typelevel" %% "spire" % "0.14.1"
)

testOptions in Test := Seq(Tests.Filter(t => !t.matches(".*Benchmark$")))
javaOptions in run += "-Xmx12G"

//scalacOptions ++= Seq("-Xdisable-assertions")
javaOptions in run += "-Xmx6G"

publishMavenStyle := true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
package scorex.core.serialization

import java.nio.ByteBuffer

import akka.util.ByteString
import scorex.util.ByteArrayBuilder
import scorex.util.serialization._

import scala.util.Try

trait ScorexSerializer[T] extends Serializer[T, T, Reader, Writer] {

def toByteString(obj: T): ByteString = {
val writer = new VLQByteStringWriter()
serialize(obj, writer)
writer.result()
}

def parseByteString(byteString: ByteString): T = {
val reader = new VLQByteStringReader(byteString)
parse(reader)
}

def parseByteStringTry(byteString: ByteString): Try[T] = {
Try(parseByteString(byteString))
}
/**
* Basic interface for serializer with additional methods to work with bytes, not only Reader/Writer instances
*/
trait ErgoSerializer[T] extends Serializer[T, T, Reader, Writer] {

/**
* Serialize object `obj` to byte array
*/
def toBytes(obj: T): Array[Byte] = {
val writer = new VLQByteBufferWriter(new ByteArrayBuilder())
serialize(obj, writer)
writer.result().toBytes
}


/**
* Deserialize byte array into object of type `T` (or throw exception)
*/
def parseBytes(bytes: Array[Byte]): T = {
val reader = new VLQByteBufferReader(ByteBuffer.wrap(bytes))
parse(reader)
}

/**
* Deserialize byte array into object of type `T` (or return Failure)
*/
def parseBytesTry(bytes: Array[Byte]): Try[T] = {
Try(parseBytes(bytes))
}
Expand Down
Loading

0 comments on commit 373005b

Please sign in to comment.