cypherbft

module
v0.0.0-...-9fbb145 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: MIT

README

cypherBFT Tutorial

Environment

To build the source,you need to install go1.11 language.

wget https://dl.google.com/go/go1.11.linux-amd64.tar.gz
tar -C /usr/local -zxvf go1.11.linux-amd64.tar.gz

Public iP for VPS is needed

Your ip of your machine or VPS which used to deploy cypher node must be public IP.such AWS ec2 which has public IP to deploy your cypher node! Please open 8000,6000,9090,7100 ports for UDP and TCP rule for VPS.

Install the openssl

for linux

sudo apt-get install openssl
sudo apt-get install libssl-dev

for mac:

git clone https://github.com/openssl/openssl
cd openssl
sudo ./config --prefix=/usr/local/openssl
make
make install
openssl version

Download repository

We suggest you switch your computer account to root account

1. Install Git:

for linux,run follow command: sudo apt-get install git

for mac,visit follow URL to install: http://sourceforge.net/projects/git-osx-installer/

2. Open the terminal and clone repository:
 git clone https://github.com/cypherium/cypherBFT.git
 cd cypherBFT
 ls
 make cypher

Tips:according to you system,please copy ./crypto/bls/lib/yoursystem/* to ./crypto/bls/lib/ for bls library.

Run the cypher

init database
./build/bin/cypher --datadir chandbname init ./genesis.json
run node
./build/bin/cypher --nat "none" --ws   -wsaddr="0.0.0.0" --wsorigins "*" --rpc --rpccorsdomain "*" --rpcaddr 0.0.0.0 --rpcapi cph,web3c,personal,miner --port 6000 --rpcport 8000 --verbosity 4 --datadir chandbname --networkid 16001 --gcmode archive --bootnodes cnode://098c1149a1476cf44ad9d480baa67d956715b8671a4915bed17d06a1cafd7b154bc1841d451d80d391427ebc48aaa3216d4e8a2b46544dffdc61b76be6475418@13.72.80.40:9090 console

start up parameters help

The IPC interface is enabled by default and exposes all the APIs supported by cypher, whereas the HTTP and WS interfaces need to manually be enabled and only expose a subset of APIs due to security reasons. These can be turned on/off and configured as you'd expect.

HTTP based JSON-RPC API options:

  • --addr HTTP-RPC server listening interface (default: localhost)
  • --rpcport HTTP-RPC server listening port (default: 8000)
  • --port P2P listening port (default: 6000)
  • --api API's offered over the HTTP-RPC interface (default: cph,net,web3)
  • --corsdomain Comma separated list of domains from which to accept cross origin requests (browser enforced)
  • --ws Enable the WS-RPC server
  • --wsaddr WS-RPC server listening interface (default: localhost)
  • --wsport WS-RPC server listening port (default: 8000)
  • --wsorigins Origins from which to accept websockets requests
  • --rpcapi API's offered over the IPC-RPC interface (default: admin,debug,cph,miner,net,personal,shh,txpool,web3)
  • --ipcpath Filename for IPC socket/pipe within the datadir (explicit paths escape it)
  • --nat value NAT port mapping mechanism (any|none|upnp|pmp|extip:) (default: "any")
  • --rnetport Committee consensus port(default: 7100)
  • --verbosity Output log level,max value is 6(default: 4)
  • --datadir Data directory for the databases and keystore
  • --networkid Network identifier (16162=mainNet)
  • --datadir Blockchain garbage collection mode ("full", "archive") (default: "full")
  • --bootnodes The first time a node connects to the network it uses one of the predefined bootnodes. Through these bootnodes a node can join the network and find other nodes.
  • --mine Enable mining
  • --console Start an interactive JavaScript environment

You'll need to use your own programming environments' capabilities (libraries, tools, etc) to connect via HTTP, WS or IPC to a cypher node configured with the above flags. You can reuse the same connection for multiple requests!

**Note: Please understand the security implications of opening up an S based transport before doing so! Hackers on the internet are actively trying to subvert Cypherium nodes with exposed APIs! Further, all browser tabs can access locally running web servers, so malicious web pages could try to subvert locally available API

Congratulations! You have started cypherium node successfully!

With the database up and running, try out these commands

1. cph.txBlockNumber

Check the transaction block height.

2. personal.newAccount("cypher2019xxddlllaaxxx")

New one account,Among " " your should assign one password.

3. net

List the peer nodes's detail from P2P network.

4. admin.peers

List the number of peer nodes from P2P network.

5. cph.accounts

List all the accounts

6. cph.getBalance(...)

Get the balance by specify one account. cph.getBalance("0x2dbde7263aaaf1286b9c41b1138191e178cb2fd4") The string of “ 0x2dbde7263aaaf1286b9c41b1138191e178cb2fd4” is your wallet account. This wallet account string you shoud copy and store it when you executiong comand “ personal.newAccount(...) “; also your can using command “ cph.accounts ” to find if from serveal acccounts.

Txpool

1. txpool.status

List count of pending and queued transactions.

2. txpool.content

List all transactions int txpool.

Manual send transaction demonstration

1. Guarantee you have two account

Check this through “cph.accounts”.If you do not have,please new two accouts by using comand “ personal.newAccount() “

2. check your account balance
 cph.getBalance("0x461f9d24b10edca41c1d9296f971c5c028e6c64c")
 cph.getBalance("0x01482d12a73186e9e0ac1421eb96381bbdcd4557")
3. unlock your account
personal.unlockAccount("0x461f9d24b10edca41c1d9296f971c5c028e6c64c")
4. sendTransaction
cph.sendTransaction({from:'461f9d24b10edca41c1d9296f971c5c028e6c64c',to: '01482d12a73186e9e0ac1421eb96381bbdcd4557', value: 1000000000000000000})
5. wait several seconds to checkout balance
 cph.getBalance("0x461f9d24b10edca41c1d9296f971c5c028e6c64c")
 cph.getBalance("0x01482d12a73186e9e0ac1421eb96381bbdcd4557")

RUN:Operator miner functions

1. miner.start(1, "0x2dbde7263aaaf1286b9c41b1138191e178cb2fd4")

First param 1 is for threads accord to you computer power;Second param is "0x2dbde7263aaaf1286b9c41b1138191e178cb2fd4" is your account.You must be enter your password.

2. miner.status()

After miner.start(),your can check your current status or your current node role by using function for miner.status():

You will wait minimum 1 hour to check with command function for miner.status() to confirm whether your node have been promoted successfully. If you are node accounts status is "I'm committee member, Doing consensus." or "I'm leader, Doing consensus."your account have been chosen into committee successfully:

Finally,after waiting about 1 hour you can check you account’s balance through function for cph.getBalance()

3. miner.content()

You can check miner’s candidate from yourself and other nodes.

4. miner.stop()

Stop the to find candidate to take part in consensus.

Check:Committee functions

1. cph.committeeMembers(230)

List the committee members for specify keyBlockNumber(such as 230).Based on node's role,address's section display:

  • common node,the address section is blank;
  • committee member node,the address section is ip address.
2. cph.committeeExceptions(13698)

List the accounts which does not signature the specify txBlockNumber(such as 13698)

3. cph.takePartInNumbers("0xca6df652714911b4c6d14881c143cc09e9ad61c0",492)

List the specify account(such as 0xca6df652714911b4c6d14881c143cc09e9ad61c0) take part in signature txBlock numbers at param 2 keyBlockNumber(value is 492) height. if is null,it don't take part in any consensus at the keyBlockNumber height.

More APIs

cypherium apis

Example scripts to run cypher quickly

You can copy the ./build/bin/cypher to the cypherBFTBin repo's corresponding directory such as linux or mac

Directories

Path Synopsis
Package accounts implements high level Cypherium account management.
Package accounts implements high level Cypherium account management.
abi
Package abi implements the Cypherium ABI (Application Binary Interface).
Package abi implements the Cypherium ABI (Application Binary Interface).
abi/bind
Package bind generates Cypherium contract Go bindings.
Package bind generates Cypherium contract Go bindings.
keystore
Package keystore implements encrypted storage of secp256k1 private keys.
Package keystore implements encrypted storage of secp256k1 private keys.
usbwallet
Package usbwallet implements support for USB hardware wallets.
Package usbwallet implements support for USB hardware wallets.
usbwallet/internal/trezor
Package trezor contains the wire protocol wrapper in Go.
Package trezor contains the wire protocol wrapper in Go.
cmd
bootnode
bootnode runs a bootstrap node for the Cypherium Discovery Protocol.
bootnode runs a bootstrap node for the Cypherium Discovery Protocol.
clef
signer is a utility that can be used so sign transactions and arbitrary data.
signer is a utility that can be used so sign transactions and arbitrary data.
cypher
cypher is the official command-line client for Cypherium.
cypher is the official command-line client for Cypherium.
evm
evm executes EVM code snippets.
evm executes EVM code snippets.
faucet
faucet is a Cpher faucet backed by a light client.
faucet is a Cpher faucet backed by a light client.
internal/browser
Package browser provides utilities for interacting with users' browsers.
Package browser provides utilities for interacting with users' browsers.
p2psim
p2psim provides a command-line client for a simulation HTTP API.
p2psim provides a command-line client for a simulation HTTP API.
rlpdump
rlpdump is a pretty-printer for RLP data.
rlpdump is a pretty-printer for RLP data.
utils
Package utils contains internal helper functions for cypherBFT commands.
Package utils contains internal helper functions for cypherBFT commands.
Package common contains various helper functions.
Package common contains various helper functions.
bitutil
Package bitutil implements fast bitwise operations.
Package bitutil implements fast bitwise operations.
compiler
Package compiler wraps the Solidity compiler executable (solc).
Package compiler wraps the Solidity compiler executable (solc).
hexutil
Package hexutil implements hex encoding with 0x prefix.
Package hexutil implements hex encoding with 0x prefix.
math
Package math provides integer math utilities.
Package math provides integer math utilities.
mclock
Package mclock is a wrapper for a monotonic clock source
Package mclock is a wrapper for a monotonic clock source
contracts
chequebook
Package chequebook package wraps the 'chequebook' Cypherium smart contract.
Package chequebook package wraps the 'chequebook' Cypherium smart contract.
ens
Package core implements the Cypherium consensus protocol.
Package core implements the Cypherium consensus protocol.
asm
Provides support for dealing with EVM assembly instructions (e.g., disassembling them).
Provides support for dealing with EVM assembly instructions (e.g., disassembling them).
bloombits
Package bloombits implements bloom filtering on batches of data.
Package bloombits implements bloom filtering on batches of data.
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 Cypherium state trie.
Package state provides a caching layer atop the Cypherium state trie.
vm
Package vm implements the Cypherium Virtual Machine.
Package vm implements the Cypherium 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.
cph
Package cph implements the Cypherium protocol.
Package cph implements the Cypherium protocol.
downloader
Package downloader contains the manual full chain synchronisation.
Package downloader contains the manual full chain synchronisation.
fetcher
Package fetcher contains the block announcement based synchronisation.
Package fetcher contains the block announcement based synchronisation.
filters
Package filters implements an cypherium filtering system for block, transactions and log events.
Package filters implements an cypherium filtering system for block, transactions and log events.
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.
Package cphclient provides a client for the Cypherium RPC API.
Package cphclient provides a client for the Cypherium RPC API.
Package cphstats implements the network stats reporting service.
Package cphstats implements the network stats reporting service.
bech32
Package bech32 reference implementation for Bech32 and segwit addresses.
Package bech32 reference implementation for Bech32 and segwit addresses.
bls
bn256
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
bn256/cloudflare
Package bn256 implements a particular bilinear group at the 128-bit security level.
Package bn256 implements a particular bilinear group at the 128-bit security level.
bn256/google
Package bn256 implements a particular bilinear group.
Package bn256 implements a particular bilinear group.
secp256k1
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package secp256k1 wraps the bitcoin secp256k1 C library.
sha3
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package cypherium defines interfaces for interacting with Cypherium.
Package cypherium defines interfaces for interacting with Cypherium.
Package event deals with subscriptions to real-time events.
Package event deals with subscriptions to real-time events.
filter
Package filter implements event filters.
Package filter implements event filters.
internal
cphapi
Package cphapi implements the general Cypherium API functions.
Package cphapi implements the general Cypherium API functions.
debug
Package debug interfaces Go runtime debugging facilities.
Package debug interfaces Go runtime debugging facilities.
guide
Package guide is a small test suite to ensure snippets in the dev guide work.
Package guide is a small test suite to ensure snippets in the dev guide work.
jsre
Package jsre provides execution environment for JavaScript.
Package jsre provides execution environment for JavaScript.
jsre/deps
Package deps contains the console JavaScript dependencies Go embedded.
Package deps contains the console JavaScript dependencies Go embedded.
web3ext
package web3ext contains cypher specific web3c.js extensions.
package web3ext contains cypher specific web3c.js extensions.
les
Package les implements the Light Cypherium Subprotocol.
Package les implements the Light Cypherium Subprotocol.
flowcontrol
Package flowcontrol implements a client side flow control mechanism Package flowcontrol implements a client side flow control mechanism
Package flowcontrol implements a client side flow control mechanism Package flowcontrol implements a client side flow control mechanism
Package light implements on-demand retrieval capable state and chain objects for the Cypherium Light Client.
Package light implements on-demand retrieval capable state and chain objects for the Cypherium Light Client.
log
Package log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable.
Package log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable.
Go port of Coda Hale's Metrics library <https://github.com/rcrowley/go-metrics> Coda Hale's original work: <https://github.com/codahale/metrics>
Go port of Coda Hale's Metrics library <https://github.com/rcrowley/go-metrics> Coda Hale's original work: <https://github.com/codahale/metrics>
exp
Hook go-metrics into expvar on any /debug/metrics request, load all vars from the registry into expvar, and execute regular expvar handler
Hook go-metrics into expvar on any /debug/metrics request, load all vars from the registry into expvar, and execute regular expvar handler
Package cypher contains the simplified mobile APIs to cypherBFT.
Package cypher contains the simplified mobile APIs to cypherBFT.
Package node sets up multi-protocol Cypherium nodes.
Package node sets up multi-protocol Cypherium nodes.
p2p
Package p2p implements the Cypherium p2p network protocols.
Package p2p implements the Cypherium p2p network protocols.
discover
Package discover implements the Node Discovery Protocol.
Package discover implements the Node Discovery Protocol.
discv5
Package discv5 implements the RLPx v5 Topic Discovery Protocol.
Package discv5 implements the RLPx v5 Topic Discovery Protocol.
enr
Package enr implements Cypherium Node Records as defined in EIP-778.
Package enr implements Cypherium Node Records as defined in EIP-778.
nat
Package nat provides access to common network port mapping protocols.
Package nat provides access to common network port mapping protocols.
netutil
Package netutil contains extensions to the net package.
Package netutil contains extensions to the net package.
protocols
Package protocols is an extension to p2p.
Package protocols is an extension to p2p.
simulations
Package simulations simulates p2p networks.
Package simulations simulates p2p networks.
pow
Package consensus implements different Cypherium consensus engines.
Package consensus implements different Cypherium consensus engines.
Package reconfig implements Cypherium reconfiguration.
Package reconfig implements Cypherium reconfiguration.
bftview
Package bftview implements Cypherium committee common operation functions.
Package bftview implements Cypherium committee common operation functions.
Package rlp implements the RLP serialization format.
Package rlp implements the RLP serialization format.
Package rpc provides access to the exported methods of an object across a network or other I/O connection.
Package rpc provides access to the exported methods of an object across a network or other I/O connection.
signer
rules/deps
Package deps contains the console JavaScript dependencies Go embedded.
Package deps contains the console JavaScript dependencies Go embedded.
Package tests implements execution of Cypherium JSON tests.
Package tests implements execution of Cypherium JSON tests.
Package trie implements Merkle Patricia Tries.
Package trie implements Merkle Patricia Tries.

Jump to

Keyboard shortcuts

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