intelchain

module
v1.10.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2024 License: LGPL-3.0

README

Intelchain

General Documentation

https://docs.intelchain.org

API Guide

http://api.intelchain.org/

Requirements

Go 1.22.5
GMP and OpenSSL

On macOS:

brew install gmp
brew install openssl
sudo ln -sf /usr/local/opt/openssl@1.1 /usr/local/opt/openssl

On Linux (Ubuntu)

sudo apt install libgmp-dev  libssl-dev  make gcc g++

On Linux (Cent OS / Amazon Linux 2)

sudo yum install glibc-static gmp-devel gmp-static openssl-libs openssl-static gcc-c++
First Install

Clone and set up all of the repos with the following set of commands:

  1. Create the appropriate directories:
mkdir -p $(go env GOPATH)/src/github.com/zennittians
cd $(go env GOPATH)/src/github.com/zennittians

If you get 'unknown command' or something along those lines, make sure to install golang first.

  1. Clone this repo & dependent repos.
git clone https://github.com/zennittians/mcl.git
git clone https://github.com/zennittians/bls.git
git clone https://github.com/zennittians/intelchain.git
cd intelchain
  1. Build the intelchain binary & dependent libs
go mod tidy
make

Run bash scripts/install_build_tools.sh to ensure build tools are of correct versions. If you get 'missing go.sum entry for module providing package <package_name>', run go mod tidy.

Build

The make command should automatically build the intelchain binary & all dependent libs.

However, if you wish to bypass the Makefile, first export the build flags:

export CGO_CFLAGS="-I$GOPATH/src/github.com/zennittians/bls/include -I$GOPATH/src/github.com/zennittians/mcl/include -I/opt/homebrew/opt/openssl@1.1/include"
export CGO_LDFLAGS="-L$GOPATH/src/github.com/zennittians/bls/lib -L/opt/homebrew/opt/openssl@1.1/lib"
export LD_LIBRARY_PATH=$GOPATH/src/github.com/zennittians/bls/lib:$GOPATH/src/github.com/zennittians/mcl/lib:/opt/homebrew/opt/openssl@1.1/lib
export LIBRARY_PATH=$LD_LIBRARY_PATH
export DYLD_FALLBACK_LIBRARY_PATH=$LD_LIBRARY_PATH
export GO111MODULE=on

Then you can build all executables with the following command:

bash ./scripts/go_executable_build.sh -S

Reference bash ./scripts/go_executable_build.sh -h for more build options

Debugging

One can start a local network (a.k.a localnet) with your current code using the following command:

make debug

This localnet has 2 shards, with 11 nodes on shard 0 (+1 explorer node) and 10 nodes on shard 0 (+1 explorer node).

The shard 0 endpoint will be on the explorer at http://localhost:9599. The shard 1 endpoint will be on the explorer at http://localhost:9598.

You can view the localnet configuration at /test/configs/local-resharding.txt. The fields for the config are (space-delimited & in order) ip, port, mode, bls_pub_key, and shard (optional).

One can force kill the local network with the following command:

make debug-kill

You can view all make commands with make help

Testing

To keep things consistent, we have a docker image to run all tests. These are the same tests ran on the pull request checks.

Note that all test Docker containers bind several ports to the host machine for your convenience. The ports are:

  • 9500 - Shard 0 RPC for a validator
  • 9501 - Shard 1 RPC for a validator
  • 9599 - Shard 0 RPC for an explorer
  • 9598 - Shard 1 RPC for an explorer
  • 9799 - Shard 0 Rosetta (for an explorer)
  • 9798 - Shard 1 Rosetta (for an explorer)
  • 9899 - Shard 0 WS for an explorer
  • 9898 - Shard 1 WS for an explorer

This allows you to use curl, itc CLI, postman, rosetta-cli, etc... on your host machine to play with or probe the localnet that was used for the test.

Go tests

To run this test, do:

make test-go

This test runs the go tests along with go lint, go fmt, go imports, go mod, and go generate checks.

RPC tests

To run this test, do:

make test-rpc

If you wish to debug further with the localnet after the tests are done, open a new shell and run:

make test-rpc-attach
Rosetta tests

To run this test, do:

make test-rosetta

Similar to the RPC tests, if you wish to debug further with the localnet after the tests are done, open a new shell and run:

make test-rosetta-attach

Directories

Path Synopsis
Package accounts implements high level Ethereum account management.
Package accounts implements high level Ethereum account management.
abi
Package abi implements the Ethereum ABI (Application Binary Interface).
Package abi implements the Ethereum ABI (Application Binary Interface).
abi/bind
Package bind generates Ethereum contract Go bindings.
Package bind generates Ethereum contract Go bindings.
keystore
Package keystore implements encrypted storage of secp256k1 private keys.
Package keystore implements encrypted storage of secp256k1 private keys.
api
service/explorer
TODO: refactor this whole module to v0 and v1
TODO: refactor this whole module to v0 and v1
service/prometheus
Package prometheus defines a service which is used for metrics collection and health of a node in intelchain.
Package prometheus defines a service which is used for metrics collection and health of a node in intelchain.
v0
v1
v2
v3
cmd
bootnode command
intelchain command
common
math
Package math provides integer math utilities.
Package math provides integer math utilities.
ntp
Package core implements the Ethereum consensus protocol.
Package core implements the Ethereum consensus protocol.
rawdb
Package rawdb contains a collection of low level database accessors.
Package rawdb contains a collection of low level database accessors.
state
Package state provides a caching layer atop the Ethereum state trie.
Package state provides a caching layer atop the Ethereum state trie.
state/snapshot
Package snapshot implements a journalled, dynamic state dump.
Package snapshot implements a journalled, dynamic state dump.
types
Package types contains data types related to Ethereum consensus.
Package types contains data types related to Ethereum consensus.
vm
Package vm implements the Ethereum Virtual Machine.
Package vm implements the Ethereum Virtual Machine.
vm/runtime
Package runtime provides a basic execution model for executing EVM code.
Package runtime provides a basic execution model for executing EVM code.
crypto
bls
vdf
Package vdf is a proof-of-concept implementation of a delay function and the security properties are not guaranteed.
Package vdf is a proof-of-concept implementation of a delay function and the security properties are not guaranteed.
vrf
Package vrf defines the interface to a verifiable random function.
Package vrf defines the interface to a verifiable random function.
vrf/p256
Package p256 implements a verifiable random function using curve p256.
Package p256 implements a verifiable random function using curve p256.
eth
rpc
Package rpc implements bi-directional JSON-RPC 2.0 on multiple transports.
Package rpc implements bi-directional JSON-RPC 2.0 on multiple transports.
internal
cli
configs/bootnode
Package nodeconfig includes all the configuration variables for a node.
Package nodeconfig includes all the configuration variables for a node.
configs/node
Package nodeconfig includes all the configuration variables for a node.
Package nodeconfig includes all the configuration variables for a node.
configs/sharding
Package shardingconfig defines types and utilities that deal with Intelchain sharding configuration schedule.
Package shardingconfig defines types and utilities that deal with Intelchain sharding configuration schedule.
tikv/byte_alloc
from https://github.com/xtaci/smux/blob/master/alloc.go
from https://github.com/xtaci/smux/blob/master/alloc.go
itc
tracers
Package tracers is a collection of JavaScript transaction tracers.
Package tracers is a collection of JavaScript transaction tracers.
tracers/internal/tracers
Package tracers contains the actual JavaScript tracer assets.
Package tracers contains the actual JavaScript tracer assets.
node
p2p
package p2p
package p2p
rpc
intelchain/filters
Package filters implements an ethereum filtering system for block, transactions and log events.
Package filters implements an ethereum filtering system for block, transactions and log events.
apr
test
chain command
chain/reward command
chain/vrf command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL