Skip to content

Commit

Permalink
Merge pull request #20 from edenia/feat/hyperion
Browse files Browse the repository at this point in the history
Feat/hyperion
  • Loading branch information
xavier506 authored Aug 26, 2023
2 parents 4b6c7d7 + 9cd01b8 commit b55d52d
Show file tree
Hide file tree
Showing 12 changed files with 452 additions and 35 deletions.
60 changes: 26 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,71 @@
# Libre Testnet Local Network

<!-- README IS OUTDATED -->

## Description

Libre Local provides a quick way to setup a Local Testnet network for development.
The primary benefits of containers are consistency across different environments and deployment ease.

This project works along with a [full-stack-boilerplate](https://github.com/eoscostarica/full-stack-boilerplate) to help you build your AntelopeIO dApp.

## Why to use a local environment?

A local environment provides a series of benefits that you cannot in a public network, for example, with Libre locally, transaction costs are avoided since they are carried out in a development environment and not in production, also, they are accessed to system contracts to modify them as appropriate.
A local environment provides a series of benefits that you cannot in a public network, for example, with Libre Local, transaction costs are avoided since they are carried out in a development environment and not in production, also, they are access to system contracts to modify them as appropriate.

In a Blockchain network every transaction creates an immutable record and everything that is modified can affect both positively and negatively the users within it, it is for this reason that it is essential to have an environment premises where functionality tests, performance tests, stress tests, among others, can be carried out without the risk of producing a failure that affects users.
In a Blockchain network every transaction creates an immutable record and everything that is modified can affect both positively and negatively the users within it, for this reason it is essential to have an environment premises where functionality tests, performance tests, stress tests, among others, can be carried out without the risk of producing a failures that can affects users.

Finally, a factor to consider is the time that is reduced in the initial configuration of any network, this image allows directly, with only two commands to have the network installed and ready to perform functionality tests as necessary.
Finally, a factor to consider is the initial reduced time in configuration of any network, this image allows directly, with only two commands to have the network installed and ready to perform functionality tests as necessary.

## Contracts

The AntelopeIO image is based on the `eosio.system`, `eosio.token` and `eosio.msig` contracts for its configuration. Your code can be found at [this link](https://github.com/AntelopeIO/reference-contracts/tree/main/contracts).
The AntelopeIO image is based on the `eosio.system`, `eosio.token` and `eosio.msig` contracts for its configuration. The code can be found at [this link](https://github.com/AntelopeIO/reference-contracts/tree/main/contracts).

1. **eosio.system**: Defines the structures and actions needed for blockchain's core functionality.
2. **eosio.token**: Defines the structures and actions that allow users to create, issue, and manage tokens for AntelopeIO-based blockchains.
3. **eosio.msig**: Allows the creation of proposed transactions that require authorization from a list of accounts.

### Deployable projects

1. Eden: Take a look at the smart contract code [here](https://github.com/gofractally/Eden/tree/main/contracts).
2. simpleassets: A simple standard for digital assets on AntelopeIO blockchains: Non-Fungible Tokens (NFTs), Fungible Tokens (FTs), and Non-Transferable Tokens (NTTs). Take a look at the smart contract code [here](https://github.com/CryptoLions/SimpleAssets).
3. atomicassets: AtomicAssets is a Non Fungible Token (NFT) standard for eosio blockchains developed by pink.network. Take a look at the smart contract code [here](https://github.com/pinknetworkx/atomicassets-contract).
4. dgoods: dGoods is an open source and free standard for handling the virtual representation of items, both digital and physical, on the EOS blockchain led by Mythical Games. Take a look at the smart contract code [here](https://github.com/MythicalGames/dgoods).

### Prerequisites

- [Git](https://git-scm.com/)
- [Node.js](https://nodejs.org/en/)
- [Docker](https://www.docker.com/)
- [Eosio](https://developers.eos.io/welcome/latest/getting-started-guide/local-development-environment/index)
- [Leap](https://github.com/AntelopeIO/leap/releases/tag/v4.0.4)
- [Make](https://www.gnu.org/software/make/)

## Get started

- Create you `.env` by running `cp .env.example .env`
- Start the network with `make fast-run`. This will download the images if you don't have them and start the network
- Start the network with `make pull-docker-images && source run.sh create_wallet && source run.sh genesis && source run.sh start_network bp 3`. This will download the images if you don't have them and start the network
- Run the command `cleos get info` or check the link in the browser `http://127.0.0.1:8888/v1/chain/get_info`

If you run the command `cleos get info` or go to `http://127.0.0.1:8888/v1/chain/get_info` and get information like the following it is because you already have the environment ready to work.
If you run the command `cleos get info` or go to `http://127.0.0.1:8888/v1/chain/get_info` and if the information you received is like the following then you are ready to go.

```
{"server_version":"e57a1eab","chain_id":"981453d176ddca32aa278ff7b8af9bf4632de00ab49db273db03115705d90c5a","head_block_num":66,"last_irreversible_block_num":65,"last_irreversible_block_id":"00000041fcc36403c71cebfc95810f610412b474f60735639fcaa2d241fe5ffa","head_block_id":"00000042a08478812c642d311f5ff22b9212559eeb9ee1042925742d8b46dd7f","head_block_time":"2021-07-08T05:48:45.500","head_block_producer":"eosio","virtual_block_cpu_limit":213407,"virtual_block_net_limit":1118998,"block_cpu_limit":199900,"block_net_limit":1048576,"server_version_string":"v2.0.12","fork_db_head_block_num":66,"fork_db_head_block_id":"00000042a08478812c642d311f5ff22b9212559eeb9ee1042925742d8b46dd7f","server_full_version_string":"v2.0.12-e57a1eab619edffc25afa7eceb05a01ab575c34a"}
```sh
{
"server_version":"e57a1eab","chain_id":"981453d176ddca32aa278ff7b8af9bf4632de00ab49db273db03115705d90c5a","head_block_num":66,"last_irreversible_block_num":65,"last_irreversible_block_id":"00000041fcc36403c71cebfc95810f610412b474f60735639fcaa2d241fe5ffa","head_block_id":"00000042a08478812c642d311f5ff22b9212559eeb9ee1042925742d8b46dd7f","head_block_time":"2021-07-08T05:48:45.500","head_block_producer":"eosio","virtual_block_cpu_limit":213407,"virtual_block_net_limit":1118998,"block_cpu_limit":199900,"block_net_limit":1048576,"server_version_string":"v2.0.12","fork_db_head_block_num":66,"fork_db_head_block_id":"00000042a08478812c642d311f5ff22b9212559eeb9ee1042925742d8b46dd7f","server_full_version_string":"v2.0.12-e57a1eab619edffc25afa7eceb05a01ab575c34a"
}
```

**Note:** As it is a quick start, you can use the `.env.example` file with the key there provided.

> Don't use these keys in production environments, since they are public and it's just to start easily. Also consider that you will need to import your `own keys` to your wallet or the one provided in the `.env.example` file.
## Instructions for creating Libre Local Network image locally
## Instructions for compiling Libre Local Network image locally

To create the Docker image locally, you must run the following commands:

- Clone the local Eos repository `https://github.com/edenia/libre-local`
- Enter to the cloned repository folder `cd <path/libre-local>`
- Create your `.env` file `cp .env.example .env`
- Run the Dockerfile image `make run`, this will use the Dockerfiles to build the images and start the network according to the information in the nodes directory.
- Run the Dockerfile image `make build-docker-images && source run.sh create_wallet && source run.sh genesis && source run.sh start_network bp 3`, this will use the Dockerfiles to build the images and start the network according to the information in the nodes directory.
- Run the command `cleos get info` or check the link in the browser `http://127.0.0.1:8888/v1/chain/get_info`

By this point, you already have the Libre Local Network image running locally.
In this point, you already have the Libre Local Network image running locally.

If you wish to use the Smart Contracts currently running on Libre Mainnet or Libre Testnet, you can use the following command in the root folder of the repository to set them up:

```sh
./scripts/contracts.sh
```

> **Note:** To run a modified version of the contracts, you can update them, get the wasm and put them in the `./wasm` folder with their respective contract names, reset the network and run the previous command.
> **Note:** To run a modified version of the contracts, you can update them, get the wasm and put them in the `./wasm` folder with their respective contract name, reset the network and run the previous command.
## Setup Network

Expand Down Expand Up @@ -118,34 +109,35 @@ source run.sh start_network bp 5
./scripts/contracts.sh
```

5. Start Hyperion

```sh
source run.sh start_api_history
```

## File structure

```text title="./libre-local"
/
.
├── .env.example
├── .github
│ ├── ISSUE_TEMPLATE
│ └── workflows
├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── docker-compose.yaml
├── approve.json
├── makefile
├── nodes
│ ├── bp2
│ ├── bp3
│ ├── bp4
│ ├── bp5
│ ├── bp
│ └── genesis
├── run.sh
├── scripts
│ ├── contracts.sh
│ └── optional.sh
└── wasm
├── dao-contract
├── inscription-contract
├── libre-referrals
├── ordinals-contract
├── staking-contract
├── swap-contract
└── system-contracts
Expand Down
3 changes: 3 additions & 0 deletions api-history/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
ship/
ca.crt
6 changes: 6 additions & 0 deletions api-history/hyperion/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:20
RUN npm install pm2 -g
RUN git clone https://github.com/eosrio/hyperion-history-api.git
WORKDIR /hyperion-history-api
RUN git checkout main
RUN npm install
136 changes: 136 additions & 0 deletions api-history/hyperion/config/chains/local.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"api": {
"enabled": true,
"pm2_scaling": 1,
"node_max_old_space_size": 1024,
"chain_name": "Local Chain",
"server_addr": "0.0.0.0",
"server_port": 7000,
"stream_port": 1234,
"server_name": "localhost: 7000",
"provider_name": "Example Provider",
"provider_url": "https://example.com",
"chain_api": "",
"push_api": "",
"chain_logo_url": "",
"enable_caching": true,
"cache_life": 1,
"limits": {
"get_actions": 1000,
"get_voters": 100,
"get_links": 1000,
"get_deltas": 1000,
"get_trx_actions": 200
},
"access_log": false,
"chain_api_error_log": false,
"custom_core_token": "",
"enable_export_action": false,
"disable_rate_limit": false,
"rate_limit_rpm": 1000,
"rate_limit_allow": [],
"disable_tx_cache": false,
"tx_cache_expiration_sec": 3600,
"v1_chain_cache": [
{
"path": "get_block",
"ttl": 3000
},
{
"path": "get_info",
"ttl": 500
}
]
},
"indexer": {
"enabled": true,
"node_max_old_space_size": 4096,
"start_on": 0,
"stop_on": 0,
"rewrite": false,
"purge_queues": false,
"live_reader": true,
"live_only_mode": false,
"abi_scan_mode": false,
"fetch_block": true,
"fetch_traces": true,
"disable_reading": false,
"disable_indexing": false,
"process_deltas": true,
"disable_delta_rm": true
},
"settings": {
"preview": false,
"chain": "local",
"eosio_alias": "eosio",
"parser": "3.2",
"auto_stop": 0,
"index_version": "v1",
"debug": false,
"bp_logs": false,
"bp_monitoring": false,
"ipc_debug_rate": 60000,
"allow_custom_abi": false,
"rate_monitoring": true,
"max_ws_payload_mb": 256,
"ds_profiling": false,
"auto_mode_switch": false,
"hot_warm_policy": false,
"custom_policy": "",
"use_global_agent": false,
"index_partition_size": 10000000,
"es_replicas": 0
},
"blacklists": {
"actions": [],
"deltas": []
},
"whitelists": {
"actions": [],
"deltas": [],
"max_depth": 10,
"root_only": false
},
"scaling": {
"readers": 1,
"ds_queues": 1,
"ds_threads": 1,
"ds_pool_size": 1,
"indexing_queues": 1,
"ad_idx_queues": 1,
"dyn_idx_queues": 1,
"max_autoscale": 4,
"batch_size": 5000,
"resume_trigger": 5000,
"auto_scale_trigger": 20000,
"block_queue_limit": 10000,
"max_queue_limit": 100000,
"routing_mode": "round_robin",
"polling_interval": 10000
},
"features": {
"streaming": {
"enable": true,
"traces": true,
"deltas": true
},
"tables": {
"proposals": true,
"accounts": true,
"voters": true
},
"index_deltas": true,
"index_transfer_memo": true,
"index_all_deltas": true,
"deferred_trx": false,
"failed_trx": false,
"resource_limits": false,
"resource_usage": false
},
"prefetch": {
"read": 50,
"block": 100,
"index": 500
},
"plugins": {}
}
34 changes: 34 additions & 0 deletions api-history/hyperion/config/connections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"amqp": {
"host": "rabbitmq:5672",
"api": "rabbitmq:15672",
"protocol": "http",
"user": "rabbitmq",
"pass": "rabbitmq",
"vhost": "hyperion",
"frameMax": "0x10000"
},
"elasticsearch": {
"protocol": "https",
"host": "es01:9200",
"ingest_nodes": [
"es01:9200"
],
"user": "elastic",
"pass": "changeme123"
},
"redis": {
"host": "redis",
"port": "6379"
},
"chains": {
"local": {
"name": "Libre Local",
"chain_id": "f7a3fe6bf7dc0b011e25cee41ed9526b70a9702ca74599692852304cb36fdb2b",
"http": "http://genesis:8888",
"ship": "ws://genesis:8080",
"WS_ROUTER_PORT": 7001,
"WS_ROUTER_HOST": "127.0.0.1"
}
}
}
28 changes: 28 additions & 0 deletions api-history/hyperion/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: "3.8"
services:
indexer:
build: .
# restart: on-failure
volumes:
- ./config/connections.json:/hyperion-history-api/connections.json
- ./config/chains/:/hyperion-history-api/chains/
networks:
- libre-network
command: ./run.sh local-indexer

api:
build: .
ports:
- "7000:7000"
depends_on:
- indexer
volumes:
- ./config/connections.json:/hyperion-history-api/connections.json
- ./config/chains/:/hyperion-history-api/chains/
networks:
- libre-network
command: ./run.sh local-api

networks:
libre-network:
external: true
Loading

0 comments on commit b55d52d

Please sign in to comment.