Coder Social home page Coder Social logo

criptomauro / casper-node Goto Github PK

View Code? Open in Web Editor NEW

This project forked from casper-network/casper-node

1.0 0.0 0.0 21.24 MB

Casper node

License: Apache License 2.0

Rust 90.57% Makefile 0.09% Shell 5.33% TypeScript 3.18% JavaScript 0.21% CMake 0.04% C 0.06% Python 0.44% Nix 0.07%

casper-node's Introduction

LOGO

Casper is the blockchain platform purpose-built to scale opportunity for everyone. Building toward blockchain’s next frontier, Casper is designed for real-world applications without sacrificing usability, cost, decentralization, or security. It removes the barriers that prevent mainstream blockchain adoption by making blockchain friendly to use, open to the world, and future-proof to support innovations today and tomorrow. Guided by open-source principles and built from the ground up to empower individuals, the team seeks to provide an equitable foundation made for long-lasting impact. Read more about our mission at: https://casper.network/network/casper-association

Current Development Status

The status on development is reported during the Community calls and is found here

The Casper MainNet is live.

Specification

Get Started with Smart Contracts

Community

casper-node

This is the core application for the Casper blockchain.

Running a validator node from Source

Pre-Requisites for Building

  • CMake 3.1.4 or greater
  • Rust
  • libssl-dev
  • pkg-config
  • gcc
  • g++
  • recommended wasm-strip (used to reduce the size of compiled Wasm)

Setup

Before building a node, prepare your Rust build environment:

make setup-rs

The node software can be compiled afterwards:

cargo build -p casper-node --release

The result will be a casper-node binary found in target/release. Copy this somewhere into your PATH, or substitute target/release/casper-node for casper-node in all examples below.

Running one node

To run a validator node you will need to specify a config file and launch the validator subcommand, for example

casper-node validator /etc/casper-node/config.toml

The node ships with an example configuration file that should be setup first. There is also a template for a local chainspec in the same folder.

For launching, the following configuration values must be properly set:

Setting Description
network.known_addresses Must refer to public listening addresses of one or more currently-running nodes. If the node cannot connect to any of these addresses, it will panic. The node can be run with this referring to its own address, but it will be equivalent to specifying an empty list for known_addresses - i.e. the node will run and listen, but will be reliant on other nodes connecting to it in order to join the network. This would be normal for the very first node of a network, but all subsequent nodes should normally specify that first node's public listening address as their known_addresses.

The node will not run properly without another node to connect to. It is recommended that multiple nodes are run.

Running multiple nodes on one machine

There is a tool which automates the process of running multiple nodes on a single machine.

Note that running multiple nodes on a single machine is normally only recommended for test purposes.

Configuration

In general nodes are configured through a configuration file, typically named config.toml. This file may reference other files or locations through relative paths. When it does, note that all paths that are not absolute will be resolved relative to config.toml directory.

Environment overrides

Some environments may call for overriding options through the environment. In this scenario, the NODE_CONFIG environment variable can be used. For example: alternatively expressed as

export NODE_CONFIG=consensus.secret_key_path=secret_keys/node-1.pem;network.known_addresses=[1.2.3.4:34553, 200.201.203.204:34553]
casper-node validator /etc/casper-node/config.toml

Note how the semicolon is used to separate configuration overrides here.

Development environment variables

To set the threshold at which a warn-level log message is generated for a long-running reactor event, use the env var CL_EVENT_MAX_MICROSECS. For example, to set the threshold to 1 millisecond:

CL_EVENT_MAX_MICROSECS=1000

To set the threshold at which a queue dump will occur, use the env var CL_MEM_DUMP_THRESHOLD_MB. When the process reaches this level of memory allocation a dump will occur, but this will only occur once. Queue dumps can be found in /tmp once they are complete. For example, to set the threshold to 16000 megabytes:

CL_MEM_DUMP_THRESHOLD_MB=16000

Logging

Logging can be enabled by setting the environment variable RUST_LOG. This can be set to one of the following levels, from lowest priority to highest: trace, debug, info, warn, error:

RUST_LOG=info cargo run --release -- validator resources/local/config.toml

If the environment variable is unset, it is equivalent to setting RUST_LOG=error.

Log message format

A typical log message will look like:

Jun 09 01:40:17.315 INFO  [casper_node::components::rpc_server rpc_server.rs:127] starting HTTP server; server_addr=127.0.0.1:7777

This is comprised of the following parts:

  • timestamp
  • log level
  • full module path (not to be confused with filesystem path) of the source of the message
  • filename and line number of the source of the message
  • message

Filtering log messages

RUST_LOG can be set to enable varying levels for different modules. Simply set it to a comma-separated list of module-path=level, where the module path is as shown above in the typical log message, with the end truncated to suit.

For example, to enable trace level logging for the small_network module in components, info level for all other modules in components, and warn level for the remaining codebase:

RUST_LOG=casper_node::components::small=trace,casper_node::comp=info,warn

Debugging

Some additional debug functionality is available, mainly allowed for inspections of the internal event queue.

Event queue dump

The event queue can be dumped by sending a SIGUSR1 to the running node process, e.g. if the node's process ID was $NODE_PID:

kill -USR1 $NODE_PID

This will create a queue_dump.json in the working directory of the node. A tool like jq can then be used to format and display it:

$ jq < queue_dump.json
{
  "NetworkIncoming": [],
  "Network": [],
  "Regular": [
    "AddressGossiper"
  ],
  "Api": []
}

jq Examples

Dump the type of events:

jq 'map_values( map(keys[0] | {"type": ., weight: 1})| group_by(.type) | map ([.[0].type,(.|length)]) | map({(.[0]): .[1]}) )' queue_dump.json

Count number of events in each queue:

jq 'map_values(map(keys[0]))' queue_dump.json

Running a client

See the client README.

Running a local network

See the nctl utility README.

Running on a existing network

To support upgrades with a network, the casper-node is installed using scripts distributed with the casper-node-launcher.

casper-node's People

Contributors

marc-casperlabs avatar goral09 avatar bors[bot] avatar afck avatar fraser999 avatar darthsiroftardis avatar fizyk20 avatar sacherjj avatar tomvasile avatar henrytill avatar casperlabs-bors-ng[bot] avatar edhastingscasperassociation avatar mpapierski avatar nilz3ro avatar xcthulhu avatar linclelinkpart5 avatar mparlikar avatar robj avatar piotr-putit avatar asladeofgreen avatar dwerner avatar dependabot[bot] avatar hysmagus avatar zie1ony avatar hoffmannjan avatar mcdee avatar stephenmoloney avatar khjcph avatar

Stargazers

 avatar

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.