All Projects → planetarium → NineChronicles.Headless

planetarium / NineChronicles.Headless

Licence: AGPL-3.0 license
A headless node of NineChronicles game network, powered by Libplanet.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to NineChronicles.Headless

Tensei
🚀 Content management and distribution with a touch of elegance.
Stars: ✭ 217 (+600%)
Mutual labels:  headless
Sourcebit
Sourcebit helps developers build data-driven JAMstack sites by pulling data from any third-party resource
Stars: ✭ 252 (+712.9%)
Mutual labels:  headless
puppeteer-lambda
Module for using Headless-Chrome by Puppeteer on AWS Lambda.
Stars: ✭ 117 (+277.42%)
Mutual labels:  headless
Ppspider
web spider built by puppeteer, support task-queue and task-scheduling by decorators,support nedb / mongodb, support data visualization; 基于puppeteer的web爬虫框架,提供灵活的任务队列管理调度方案,提供便捷的数据保存方案(nedb/mongodb),提供数据可视化和用户交互的实现方案
Stars: ✭ 237 (+664.52%)
Mutual labels:  headless
Serverless Puppeteer Layers
Serverless Framework + AWS Lambda Layers + Puppeteer = ❤️
Stars: ✭ 247 (+696.77%)
Mutual labels:  headless
macaca-puppeteer
Macaca puppeteer driver
Stars: ✭ 39 (+25.81%)
Mutual labels:  headless
Xvfbwrapper
Manage headless displays with Xvfb (X virtual framebuffer)
Stars: ✭ 209 (+574.19%)
Mutual labels:  headless
headless-docs
WP Engine Headless Documentation for Developers
Stars: ✭ 34 (+9.68%)
Mutual labels:  headless
Taiko
A node.js library for testing modern web applications
Stars: ✭ 2,964 (+9461.29%)
Mutual labels:  headless
CrawlerSamples
This is a Puppeteer+AngleSharp crawler console app samples, used C# 7.1 coding and dotnet core build.
Stars: ✭ 36 (+16.13%)
Mutual labels:  headless
Unite Cms
Really flexible headless CMS, built on top of Symfony and GraphQL.
Stars: ✭ 242 (+680.65%)
Mutual labels:  headless
Hiper
🚀 A statistical analysis tool for performance testing
Stars: ✭ 2,667 (+8503.23%)
Mutual labels:  headless
capybara-chrome
Chrome driver for Capybara using Chrome's remote debugging protocol
Stars: ✭ 27 (-12.9%)
Mutual labels:  headless
Pdf Bot
🤖 A Node queue API for generating PDFs using headless Chrome. Comes with a CLI, S3 storage and webhooks for notifying subscribers about generated PDFs
Stars: ✭ 2,551 (+8129.03%)
Mutual labels:  headless
wagtail-headless-preview
Previews for headless Wagtail setups
Stars: ✭ 99 (+219.35%)
Mutual labels:  headless
Sanity
The Sanity Studio – Collaborate in real-time on structured content
Stars: ✭ 3,007 (+9600%)
Mutual labels:  headless
chrome-headless-launcher
Run the latest Chrome browser on CLI without head
Stars: ✭ 39 (+25.81%)
Mutual labels:  headless
react-demos
Demonstrates how to content manage React apps with Magnolia CMS
Stars: ✭ 20 (-35.48%)
Mutual labels:  headless
CockpitCMS-React-Static
Example implementation using a combination of Cockpit Headless CMS and React Static
Stars: ✭ 24 (-22.58%)
Mutual labels:  headless
FlexDotnetCMS
A powerful, flexible, decoupled and easy to use and Fully Featured ASP .NET CMS, it can also be used as a Headless CMS
Stars: ✭ 45 (+45.16%)
Mutual labels:  headless

NineChronicles Headless

Planetarium Discord invite Planetarium-Dev Discord Invite

Table of Contents

Run

$ dotnet run --project ./NineChronicles.Headless.Executable/ -- --help

Usage: NineChronicles.Headless.Executable [command]
Usage: NineChronicles.Headless.Executable [--app-protocol-version <String>] [--genesis-block-path <String>] [--host <String>] [--port <UInt16>] [--swarm-private-key <String>] [--no-miner] [--miner-count <Int32>]
[--miner-private-key <String>] [--miner.block-interval <Int32>] [--store-type <String>] [--store-path <String>] [--no-reduce-store] [--ice-server <String>...] [--peer <String>...] [--trusted-app-protocol-version-signer <String>...]
[--rpc-server] [--rpc-listen-host <String>] [--rpc-listen-port <Int32>] [--rpc-remote-server] [--rpc-http-server] [--graphql-server] [--graphql-host <String>] [--graphql-port <Int32>] [--graphql-secret-token-path <String>] [--no-cor
s] [--confirmations <Int32>] [--nonblock-renderer] [--nonblock-renderer-queue <Int32>] [--strict-rendering] [--log-action-renders] [--network-type <NetworkType>] [--tx-life-time <Int32>] [--message-timeout <Int32>] [--tip-timeout <I
nt32>] [--demand-buffer <Int32>] [--static-peer <String>...] [--skip-preload] [--minimum-broadcast-target <Int32>] [--bucket-size <Int32>] [--chain-tip-stale-behavior-type <String>] [--tx-quota-per-signer <Int32>] [--maximum-poll-pe
ers <Int32>] [--config <String>] [--sentry-dsn <String>] [--sentry-trace-sample-rate <Double>] [--help] [--version]

NineChronicles.Headless.Executable

Commands:
  account
  validation
  chain
  key
  apv
  action
  state
  tx
  market
  genesis
  replay

Options:
  -V, --app-protocol-version <String>                      App protocol version token.
  -G, --genesis-block-path <String>                        Genesis block path of blockchain. Blockchain is recognized by its genesis block.
  -H, --host <String>                                      Hostname of this node for another nodes to access. This is not listening host like 0.0.0.0
  -P, --port <UInt16>                                      Port of this node for another nodes to access.
  --swarm-private-key <String>                             The private key used for signing messages and to specify your node. If you leave this null, a randomly generated value will be used.
  --no-miner                                               Disable block mining.
  --miner-count <Int32>                                    The number of miner task(thread).
  --miner-private-key <String>                             The private key used for mining blocks. Must not be null if you want to turn on mining with libplanet-node.
  --miner.block-interval <Int32>                           The miner's break time after mining a block. The unit is millisecond.
  --store-type <String>                                    The type of storage to store blockchain data. If not provided, "LiteDB" will be used as default. Available type: ["rocksdb", "memory"]
  --store-path <String>                                    Path of storage. This value is required if you use persistent storage e.g. "rocksdb"
  --no-reduce-store                                        Do not reduce storage. Enabling this option will use enormous disk spaces.
  -I, --ice-server <String>...                             ICE server to NAT traverse.
  --peer <String>...                                       Seed peer list to communicate to another nodes.
  -T, --trusted-app-protocol-version-signer <String>...    Trustworthy signers who claim new app protocol versions
  --rpc-server                                             Use this option if you want to make unity clients to communicate with this server with RPC
  --rpc-listen-host <String>                               RPC listen host
  --rpc-listen-port <Int32>                                RPC listen port
  --rpc-remote-server                                      Do a role as RPC remote server? If you enable this option, multiple Unity clients can connect to your RPC server.
  --rpc-http-server                                        If you enable this option with "rpcRemoteServer" option at the same time, RPC server will use HTTP/1, not gRPC.
  --graphql-server                                         Use this option if you want to enable GraphQL server to enable querying data.
  --graphql-host <String>                                  GraphQL listen host
  --graphql-port <Int32>                                   GraphQL listen port
  --graphql-secret-token-path <String>                     The path to write GraphQL secret token. If you want to protect this headless application, you should use this option and take it into headers.
  --no-cors                                                Run without CORS policy.
  --confirmations <Int32>                                  The number of required confirmations to recognize a block.
  --nonblock-renderer                                      Uses non-blocking renderer, which prevents the blockchain & swarm from waiting slow rendering. Turned off by default.
  --nonblock-renderer-queue <Int32>                        The size of the queue used by the non-blocking renderer. Ignored if --nonblock-renderer is turned off.
  --strict-rendering                                       Flag to turn on validating action renderer.
  --log-action-renders                                     Log action renders besides block renders. --rpc-server implies this.
  --network-type <NetworkType>                             Network type. (Allowed values: Main, Internal, Permanent, Test, Default)
  --tx-life-time <Int32>                                   The lifetime of each transaction, which uses minute as its unit.
  --message-timeout <Int32>                                The grace period for new messages, which uses second as its unit.
  --tip-timeout <Int32>                                    The grace period for tip update, which uses second as its unit.
  --demand-buffer <Int32>                                  A number of block size that determines how far behind the demand the tip of the chain will publish `NodeException` to GraphQL subscriptions.
  --static-peer <String>...                                A list of peers that the node will continue to maintain.
  --skip-preload                                           Run node without preloading.
  --minimum-broadcast-target <Int32>                       Minimum number of peers to broadcast message.
  --bucket-size <Int32>                                    Number of the peers can be stored in each bucket.
  --chain-tip-stale-behavior-type <String>                 Determines behavior when the chain's tip is stale. "reboot" and "preload" is available and "reboot" option is selected by default.
  --tx-quota-per-signer <Int32>                            The number of maximum transactions can be included in stage per signer.
  --maximum-poll-peers <Int32>                             The maximum number of peers to poll blocks. int.MaxValue by default.
  -C, --config <String>                                    Absolute path of "appsettings.json" file to provide headless configurations. (Default: appsettings.json)
  --sentry-dsn <String>                                    Sentry DSN
  --sentry-trace-sample-rate <Double>                      Trace sample rate for sentry
  -h, --help                                               Show help message
  --version                                                Show version

Use appsettings.{network}.json to provide CLI options

You can provide headless CLI options using file, appsettings.json. You'll find the default file at here. The path of appsettings.json can be either local file storage or URL. Refer full configuration fields from this file, set your options into appsettings.json under Headless section. You can also run headless server with previous way; You don't need to change anything if you don't want to. In case that the same option is provided from both appsetting.json and CLI option, the CLI option value is used instead from appsettings.json.

The default appsettings.json is an example for your own appsettings file. appsettings.{network}.json are runnable appsettings file and you can run local node for each network using following command:

dotnet run --project NineChronicles.Headless.Executable -C appsettings.{network}.json --store-type={YOUR_OWN_STORE_PATH}
  • appsettings.mainnet.json
    • This makes your node to connect to the Nine Chronicles mainnet (production).
  • appsettings.internal.json
    • This makes your node to connect to the Nine Chronicles internal network, which is test before release new version.
    • Internal network is kind of hard-fork of mainnet at some point to test new version.
    • You CANNOT use mainnet storage for internal headless node.
  • appsettings.previewnet.json
    • This makes your node to connect to the Nine Chronicles preview network to show feature preview.
    • This network is totally different network from genesis block.
    • Previewnet can be restarted from genesis block without any announcement to prepare next feature.

Please make sure the store in the path you provided must save right data for the network to connect. You cannot share data from any of those networks.

If you want to run your own isolated local network, please copy appsettings.json to appsettings.local.json and edit the contents.

cp appsettings.json appsettings.local.json
# Edit contents of appsettings.local.json
dotnet run --project NineChronicles.Headless.Executable -C appsettings.local.json --store-type={YOUR_OWN_STORE_PATH}

Caveat

APVs can be changed as Nine Chronicles deploys new version. You have to fit your APV sting to current on-chain version string. You can get APV strings at the following places:

Docker Build

A headless image can be created by running the command below in the directory where the solution is located.

$ docker build . -t <IMAGE_TAG> --build-arg COMMIT=<VERSION_SUFFIX>
  • Nine Chronicles Team uses <VERSION_SUFFIX> to build an image with the latest git commit and push to the official Docker Hub repository. However, if you want to build and push to your own Docker Hub account, the <VERSION_SUFFIX> can be any value.

Format

Formatting for PrivateKey or Peer follows the format in [Nekoyume Project README][../README.md].

How to run NineChronicles Headless on AWS EC2 instance using Docker

On Your AWS EC2 Instance

Pre-requisites

1. Pull planetariumhq/ninechronicles-headless Docker image to your AWS EC2 instance from the official Docker Hub repository.

  • If you would like to build your own Docker image from your local machine, refer to this section.
$ docker pull planetariumhq/ninechronicles-headless:[<TAGNAME>] (ex: v100300)

2. Create a Docker volume for blockchain data persistence

$ docker volume create [<VOLUME_NAME>] (ex: 9c-volume)

3. Run your Docker image with your Docker volume mounted (use -d for detached mode)

$ docker run \
--detach \
--volume 9c-volume:/app/data \
planetariumhq/ninechronicles-headless:[] \
[NineChronicles Headless Options]

Note)

  • If you want to use the same headless options as your Nine Chronicles game client, please refer to the headlessArgs values in value in https://release.nine-chronicles.com/apv.json.

  • If you are using an Elastic IP on your AWS instance, you can add the IP address in the --host option and not use the --ice-server option.

  • For mining, make sure to include the --miner-private-key option with your private key.

  • Docker Volumes Usage

Building Your Own Docker Image from Your Local Machine

Pre-requisites

1. Build Docker image with the tag name in [<DOCKER_HUB_ACCOUNT>/<IMAGE_NAME>] format.

$ docker build . --tag [<DOCKER_HUB_ACCOUNT>/<IMAGE_NAME>]:[<TAGNAME>] --build-arg COMMIT=[<VERSION_SUFFIX>]

2. Push your Docker image to your Docker Hub account.

$ docker push [<DOCKER_HUB_ACCOUNT>/<IMAGE_NAME>]:[<TAGNAME>]

Nine Chronicles GraphQL API Documentation

Check out Nine Chronicles GraphQL API Tutorial to get you started with using GraphQL API with NineChronicles Headless.

For more information on the GraphQL API, refer to the NineChronicles Headless GraphQL Documentation.


Create a new genesis block

1. (Optional) Create activation keys and PendingActivationState

Activation key is the code for 9c account to register/activate into NineChronicles. You can create activation key whenever you want later, so you can just skip this step.

dotnet run --project NineChronicles.Headless.Executable/NineChronicles.Headless.Executable.csproj -- tx create-activation-keys 10 > ActivationKeys.csv  # Change [10] to your number of new activation keys
dotnet run --project NineChronicles.Headless.Executable/NineChronicles.Headless.Executable.csproj -- tx create-pending-activations ActivationKeys.csv > PendingActivation

2. Create config file for genesis block

  1. Copy config.json.example to config.json
  2. Change values inside config.json
    • data.tablePath is required.
    • If you have PendingActivation file, set file path to extra.pendingActivationStatePath

Structure of genesis block

Key Type Required Description
data Required Related to the game data. This field is required.
data.tablePath string Path of game data table. Lib9c/Lib9c/TableCSV for NineChronicles.
currency Optional Related to currency data. Set initial mint / deposits.
currency.initialMinter PrivateKey (string) PrivateKey of initial minter.
Initial minting Tx. will be signed using this key and included in genesis block.
currency.initialCurrencyDeposit List Initial deposit data. These data will be created to Tx. and goes inside of genesis block.
If you leave this to null, the initialMinter will get 10000 currency as default.
currency.initialCurrencyDeposit[i].address Address (string) Address of depositor. Use address string except leading 0x.
currency.initialCurrencyDeposit[i].amount BigInteger Amount of currency give to depositor.
This amount will be given every block from start to end. ex) 100 from 0 to 9: total 1000 currency will be given.
currency.initialCurrencyDeposit[i].start long First block to give currency to depositor. genesis block is #0
currency.initialCurrencyDeposit[i].end long Last block to give currency to depositor.
If you want to give only once, set this value as same as start.
admin Optional Related to admin setting.
admin.activate bool If true, give admin privilege to admin address.
admin.address Address (string) Address to be admin. If not provided, the initialMinter will be set as admin.
admin.validUntil long Block number of admin lifetime. Admin address loses its privilege after this block.
extra Optional Extra setting.
extra.pendingActivationStatePath string If you want to set activation key inside genesis block to use, create PendingActivationData and save to file and provide here.

3. Create genesis block

dotnet run --project ./NineChronicles.Headless.Executable/ genesis ./config.json

After this step, you will get genesis-block file as output and another info in addition.

4. Run Headless node with genesis block

dotnet run --project ./NineChronicles.Headless.Executable/ \
    -V=[APP PROTOCOL VERSION] \
    -G=[PATH/TO/GENESIS/BLOCK] \
    --store-type=memory \
    --store-path= [PATH/TO/BLOCK/STORAGE] \
    --host=localhost \
    --port=43210 \
    --miner-private-key=[PRIVATE_KEY_OF_BLOCK_MINER]

If you see log like this, all process is successfully done:

Start mining.
[BlockChain] 424037645/18484: Starting to mine block #1 with difficulty 5000000 and previous hash 29f53d22...
[BlockChain] Gathering transactions to mine for block #1 from 0 staged transactions...
[BlockChain] Gathered total of 0 transactions to mine for block #1 from 0 staged transactions.
Evaluating actions in the block #1 pre-evaluation hash: 10d93de7...
Evaluating policy block action for block #1 System.Collections.Immutable.ImmutableArray`1[System.Byte]
Actions in 0 transactions for block #1 pre-evaluation hash: 10d93de7... evaluated in 20ms.
[BlockChain] 424037645/18484: Mined block #1 0838b084... with difficulty 5000000 and previous hash 29f53d22...
[BlockChain] Trying to append block #1 0838b084...
[BlockChain] Unstaging 0 transactions from block #1 0838b084...
[BlockChain] Unstaged 0 transactions from block #1 0838b084...
[Swarm] Trying to broadcast blocks...
[NetMQTransport] Broadcasting message Libplanet.Net.Messages.BlockHeaderMessage as 0x7862DD9b....Unspecified/localhost:43210. to 0 peers
[Swarm] Block broadcasting complete.
[BlockChain] Appended the block #1 0838b084...
[BlockChain] Invoking renderers for #1 0838b084... (1 renderer(s), 0 action renderer(s))
[LoggedRenderer] Invoking RenderBlock() for #1 0838b084... (was #0 29f53d22...)...
[LoggedRenderer] Invoked RenderBlock() for #1 0838b084... (was #0 29f53d22...).
[BlockChain] Invoked renderers for #1 0838b084... (1 renderer(s), 0 action renderer(s))
[Swarm] Trying to broadcast blocks...
[NetMQTransport] Broadcasting message Libplanet.Net.Messages.BlockHeaderMessage as 0x7862DD9b....Unspecified/localhost:43210. to 0 peers
[Swarm] Block broadcasting complete.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].