Giter VIP home page Giter VIP logo

bitmarkd's Introduction

bitmarkd - Main program

Made by GoDoc Go Report Card CircleCI

Prerequisites

  • Install the go language package for the system
  • Configure environment variables for go system
  • Install the ZMQ4 and Argon2 libraries

Operating system specific setup commands

FreeBSD

pkg install libzmq4 libargon2 git

MacOSX

(be sure that homebrew is installed correctly)

brew install argon2
brew install zeromq
brew install git

Ubuntu

(tested on version 18.04)

Install following packages

sudo apt install libargon2-0-dev uuid-dev libzmq3-dev git

Debian

(tested on version 9)

First we need to add access to testing package's repository as well as to our current version, in this case stable.

root@debian-bitmarkd:/# cat /etc/apt/sources.list.d/stable.list
deb     http://ftp.de.debian.org/debian/    stable main contrib non-free
deb-src http://ftp.de.debian.org/debian/    stable main contrib non-free
deb     http://security.debian.org/         stable/updates  main contrib non-free

root@debian-bitmarkd:/# cat /etc/apt/sources.list.d/testing.list
deb     http://ftp.de.debian.org/debian/    testing main contrib non-free
deb-src http://ftp.de.debian.org/debian/    testing main contrib non-free
deb     http://security.debian.org/         testing/updates  main contrib non-free

Now install libargon2 using:

apt-get -t testing install libargon2-dev libargon2-1

For the other packages, install from stable or testing, both versions work:

apt install uuid-dev libzmq3-dev
apt install git

Compilation commands for all operating systems

To compile use use the git command to clone the repository and the go command to compile all commands. The process requires that the Go installation be 1.12 or later as the build process uses Go Modules.

git clone https://github.com/bitmark-inc/bitmarkd
cd bitmarkd
go install -v ./...

Set up for running a node

Note: ensure that the ${HOME}/go/bin directory is on the path before continuing. The commands below assume that a checked out and compiled version of the system exists in the ${HOME}/bitmarkd directory.

Setup and run bitmarkd

Create the configuration directory, copy sample configuration, edit it to set up IP addresses, ports and local bitcoin testnet connection. The sample configuration has some embedded instructions for quick setup and only a few items near the beginning of the file need to be set for basic use.

mkdir -p ~/.config/bitmarkd
cp ~/bitmarkd/command/bitmarkd/bitmarkd.conf.sample  ~/.config/bitmarkd/bitmarkd.conf
${EDITOR} ~/.config/bitmarkd/bitmarkd.conf

To see the bitmarkd sub-commands:

bitmarkd --config-file="${HOME}/.config/bitmarkd/bitmarkd.conf" help

Generate key files and certificates.

bitmarkd --config-file="${HOME}/.config/bitmarkd/bitmarkd.conf" gen-peer-identity "${HOME}/.config/bitmarkd/"
bitmarkd --config-file="${HOME}/.config/bitmarkd/bitmarkd.conf" gen-rpc-cert "${HOME}/.config/bitmarkd/"
bitmarkd --config-file="${HOME}/.config/bitmarkd/bitmarkd.conf" gen-proof-identity "${HOME}/.config/bitmarkd/"

Start the program.

bitmarkd --config-file="${HOME}/.config/bitmarkd/bitmarkd.conf" start

Setup and run recorderd (the mining program)

This is similar to the bitmarkd steps above. For mining on the local bitmarkd the sample configuration should work without changes.

mkdir -p ~/.config/recorderd
cp ~/bitmarkd/command/recorderd/recorderd.conf.sample  ~/.config/recorderd/recorderd.conf
${EDITOR} ~/.config/recorderd/recorderd.conf

To see the recorderd sub-commands:

recorderd --config-file="${HOME}/.config/recorderd/recorderd.conf" help

Generate key files and certificates.

recorderd --config-file="${HOME}/.config/recorderd/recorderd.conf" generate-identity "${HOME}/.config/recorderd/

Start the program.

recorderd --config-file="${HOME}/.config/recorderd/recorderd.conf" start

Setup and run bitmark-cli (command line program to send transactions)

Initialise the bitmark-cli for live and test networks creating a new account on each network. This setup is presuming that live or test bitmarkd will be running on the same machine so thatthe loopback address can be used.

mkdir -p ~/.config/bitmark-cli
bitmark-cli -n bitmark -i mylive setup -c 127.0.0.1:2130  -d 'my first live account' -n
bitmark-cli -n testing -i mytest setup -c 127.0.0.1:12130  -d 'my first testing account' -n

To see the cli sub-commands: or details on a specific command e.g., "setup"

bitmark-cli help
bitmark-cli help setup

Note: If you wish to add more connections or change the default connection created above then it is necessary to edit the JSON configuration files to modify the connections list.

Prebuilt Binary

  • FreeBSD

Install bitmarkd bitmark-cli and recorderd

pkg install bitmark

Alternatively select one or more individual packages

pkg install bitmark-daemon
pkg install bitmark-recorder
pkg install bitmark-cli

Coding

  • setup git hooks

    Link git hooks directory, run command ./scripts/setup-hook.sh at root of bitmarkd directory. Currently it provides checks for two stages:

    1. Before commit (pre-commit)

    Runs go lint for every modified file. It shows suggestions but not necessary to follow.

    1. Before push to remote (pre-push)

    Runs go test for whole directory. It is mandatory to pass this check because generally, new modifications must not break existing logic/behaviour.

    Other optional actions are sonaqube and go tool vet. These two are optional to follow since static code analysis just provide some advice.

  • all variables are camel case with no underscores

  • labels are all lowercase with '_' between words

  • imports and one single block

  • all break/continue must have label

  • avoid break in switch and select

bitmarkd's People

Contributors

anhnguyenbitmark avatar araujobsd avatar awesome-doge avatar balduran avatar dependabot[bot] avatar hxw avatar jamieabc avatar jollyjoker992 avatar lemonlatte avatar moskovich avatar nodestory avatar pieceofr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bitmarkd's Issues

Activation mechanism

There is no activation mechanism for transitioning to new consensus rules in the Bitmark blockchain. The changes could be activated without buffer time. The deployments of new versions to full nodes can't be executed until primary node runners successfully upgrade the version of bitmarkd.

Regression test mode

There are 3 supported chains in bitmarkd configuration: bitmark, testing, and local. The local chain is designed for running regression tests.

The current local chain doesn't support generating blocks on demand for testing purposes. Almost every test case is coupled with recorderd, which makes the regression tests time-consuming. Most of the time is spent in checking if recorderd is working. The local chain should enable developers to have full control over the environment and test the bitmarkd functions without extra dependencies.

Besides, the local chain should be working with bitcoin/litecoin regression test mode. There are 3 modes of running payment modules: p2p, discovery, rest. Currently, the p2p mode can't be tested in the local chain because it automatically tries to connect to DNS seeds of bitcoin and litecoin for peer discovery on either mainnet or testnet.

Missing shared library from executing the Bitmark executable

While running Bitmark Linux version I come across this issue:

root@moby:~/bitmark-0.0.7-linux# ./Bitmark
./Bitmark: error while loading shared libraries: libgmodule-2.0.so.0:

It looks like it cannot find the shared objects, which are not in any of the dependencies

Memory leak

Starting from 0.12, it seems that there is a memory leak in bitmarkd.

Change log level on the fly

Current logger level is determined when program started, as using bm-tester, often with situation that some problem happens, but log level is set to critical thus cannot see actual system log message.

If log level can be changed while program is running, then we can change log level to get more detailed information when some unexpected problem happens.

Some dependencies require compiling shared libraries and headers to be present

bitmarkd relies on go-libucl, and go-argon2.

libucl is installed by running the Makefile in github.com/bitmark-inc/go-libucl and moving the headers and shared libs in the appropriate spaces.

libargon2 is installed by updating the submodules of go-argon2 and running the Makefile.

Installing these 2 libraries required some debugging and could ideally be automated to lower the bar for new users.

No package 'libzmq' found when go install

Following the instruction at the bottom of https://bitmark.com/ on Mac OSX 10.11.2

~$ go install github.com/bitmark-inc/bitmarkd
# pkg-config --cflags libzmq
Package libzmq was not found in the pkg-config search path.
Perhaps you should add the directory containing `libzmq.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libzmq' found
pkg-config: exit status 1

Unable to install bitmarkd through the CLI

I'm interested in running bitmarkd without having to have a GUI. After running the commands in the README and the website installation guide, I am presented with the following message:

root@moby:~# go get github.com/bitmark-inc/bitmarkd
package github.com/bitmark-inc/bitmarkd: no buildable Go source files in /root/go/src/github.com/bitmark-inc/bitmarkd

Reproduced on both Linux and Mac.

I see references to a package main in github.com/bitmark-inc/bitmarkd/command/bitmarkd. Is this the package that should be installed?

[NETWORK-OKR] Distributing System Testing Frameworks/Tools

Using the existing frameworks for testing P2P distributing system to make Network more stable.

  • Investing distribute system testing frameworks
  • Research on Jepsen
  • Research on Muxy
  • Demo on Jepsen
  • Demo on Muxy
  • Propose a framework for bitmark distributed system

Define `did:bmk` method operations

Acceptance criteria:

  • Sequence diagrams for the following operations
    • class operations: create, transfer, and update
    • token operations: create and transfer
  • Block diagram (wallet, bitmark blockchain, resolver, and resource server)

References:

--

Overall goal

  1. High-dimensional thinking about all needs

    Role, NFT, endpoint
    Decide on NFT Controller
    Determine the USER controller
    Is the item owning the "person" or the person owning the item.

  2. Convert all requirements into modules

    Convert into specific objects and modules
    Decide whether the verification module after CRUD is organized by node or an external company.

  3. Convert the type to UTXO

    Even if the verification mechanism of an external company organization is adopted. The most basic UTXO transaction verification mechanism is also required
    The mining mechanism of UTXO transactions is the same as BTC?LTC? or new tokens are to be issued. If there are new tokens in the future, support should be retained.

  4. Deploy the new UTXO to Bitmarkd's system
    • lib builds a new type of UTXO
    • lib reads UTXO in new state
    • lib Verifies the new state of UTXO
    • lib get rpc UTXO
    • RPC receiving type UTXO
    • RPC builds a new type of UTXO
    • RPC read UTXO in new state
    • RPC verifies the new state of UTXO
    • p2p synchronization implementation

High CPU if failed btc peer

If the btc peers.json contains unreachable IPv6 bitmarkd will use approximately 50% CPU.

Workaround:

  • stop bitmarkd
  • remove peers.json
  • restartd bitmarkd

This shows up in local test mode when IPv6 address was lost after switch to WIFI (IPv4 only)

Regression testing for consensus

Build a local cluster to test the correctness of the consensus protocol.

We're only able to test this case: the block with more backing nodes wins.

Reduce `logger.Initialise` when writing unite test

Current logger package needs to be initialised before using. This increase some complexity when writing unit test.

Not only every test case need to initialize logger, but also when background task is running while main test problem is terminating and finalize logger, it might cause unexpected problem of logger not initialised.

If logger can be default send to stdout, then it provides two benefits:

  • no need to setup logger for ever test
  • when ever unit test error, with go test -v shows details message of process, facilitate easier debugging

IPV4, IPV6 Mapping Issue on Different OS

Original Problem Description

In Bitmarkd configuration, if we want to listen on all address of IPV4 and IPV6, we may do this
listen = {
"0.0.0.0:2136",
"[::]:2136"
}
Then we get a bind error that said the port has already Bind.
We have 2 modules have the issue Peer and RPC

Propose base on """Linux"""

Use [::] to represent all interface
In configuration,
In RPC module
In Peer module

"BUT" ---> This is a os related and a library issue ... please see follow

Investigation on the Issue

according to this reference: https://lwn.net/Articles/688462/
In kernel Level,
OS do IPV4 IPV6 Mapping. In Linux it is a default, therefore, "[::]" means listen All
However, according to the article, BSD may not be the default. (OS dependent)

In Go Library Level, (Test on Ubuntu Linux Only )
In RPC, ipType can be specified "tcp" -- > listen all
l, err := tls.Listen(ipType[i], listen, tlsConfiguration)

If we want to specify this
listen = {
"0.0.0.0:2136",
"[::]:2136"
}
It is also ok, we should use
tcp4 -- > "0.0.0.0:2136",
tcp6 --> "[::]:2136"

However, In Peer ZMQ Library , If we can not bind both in NewBind. To listen to all, we shall use [::]:2136 (Notice: Maybe a deep investigation on ZMQ library may can )

// allocate IPv4 and IPv6 sockets
lstn.socket4, lstn.socket6, err = zmqutil.NewBind(log, zmq.REP, listenerZapDomain, privateKey, publicKey, c)

What should we do ??

Check on differences in in BSD, MAC and Linux and find the rules

  • Will IPV4 map IPV6?
  • What the parameters to reflect this on RPC and ZMQ setting

Missing dependency management system for maintaining Go packages

Bitmarkd depends on a series of other packages. Suggest to vendor these package and provide an easy way for installing, updating and maintaining them.
A good solution (also used in btcd) is Glide

Here is a sample glide.yaml file.

package: github.com/bitmark-inc/bitmarkd/command/bitmarkd
import:
- package: github.com/bitmark-inc/bitmarkd
  version: v2.10
  subpackages:
  - announce
  - asset
  - block
  - chain
  - configuration
  - fault
  - mode
  - payment
  - payment/bitcoin
  - peer
  - proof
  - reservoir
  - rpc
  - storage
  - util
  - version
  - zmqutil
- package: github.com/bitmark-inc/certgen
- package: github.com/bitmark-inc/exitwithstatus
- package: github.com/bitmark-inc/getoptions
- package: github.com/bitmark-inc/listener
- package: github.com/bitmark-inc/logger
- package: golang.org/x/crypto
  subpackages:
  - sha3

Let me know if you would like my help with this.

[DOC-OKR]Launch of Full-Node Documentation

Full-Node documentation has complete 40% in Q2. It needs to combine into the whole bitmark-documentation. The goal is working on launching full-node documentation.

  • Review the bitmark documentation to see how full-node documentation can merge into the documentation.
  • Work on the way to coordinating document structure with QA
  • Close this OKR to let the QA leading the document making process

Exapand proof submission request for independent or pooled mining

Add additional request fucntion to proof/submission.go. This currently only supports returning a nonce. Add the txZero field to the request and add a hash field to the response.
The submission must verify that txZero is a valid foundation record before accepting the submission and only return the hasg if this record is valid.

This allows for two possibilities

  1. recorderd can sign its own txZero and thus provide its own payment addresses

  2. a mining pool program can be created to use the returned hashes to apportion rewards to individual miners

Linux source zip contains `__MACOSX` files

bitmark-0.0.7-linux.zip contains artifacts from Mac's Finder utility. They usually contain useless information and sometimes also personal information on your desktop environment. Suggest to remove them

Hash rate calculation

Currently, hash rate calculation only considers leading zeros from difficulty, but actually remaining digits still have impact on hash rate calculation.

Better way is to calculate all those digits to have more accurate number.

Take difficulty 4.8 as an example, leading zeros are 8 + log2(4.8), hash rate is pow(2, 8+log2(4.8))/120

[NETWORK-OKR]Propose a new routing and discovery algorithm

Current discovery is using DNSLookup for TXT record and routing is using binary tree with X algorithm. There are more existing choices of discovery and routing. Explore the widely used algorithm come with a stable p2p library can be an improvement of P2P module.

  • Research on P2P algorithms
  • Research on gossip protocol on fault detection for routing
  • research and testing on specific algorithms (decided later
  • Propose a new algorithm

Disable payment verification for non-mining nodes

Non-mining nodes don't need to verify if fees for bitmark transactions are already paid or not. The status of a transaction can go to confirmed directly from pending. Disabling the payment module can remove additional dependencies on bitcoin and litecoin nodes and also reduce network bandwidth usage.

deprecate the 2135 publish port

Remove all the publish code as this was only ever used to forward data to a database collector. It is not necessary to have this in every bitmarkd as this program could just use the normal p2p connection and receive identical data. (this ports was simply publishing the exact same binary data as the normal p2p so is only adding extra processing and network overhead)

[NETWORK-OKR] Bidirectional connection and nat transveral

Current bitmark node requires public IP to connect with other nodes. This limits the utilization rate of bitmark nodes. The bi-directional connection enables that two nodes require only one public IP to connect with each other. Further more, nat transversal can enhance the requirement of using public ip. The task is to research on existing golang libraries for bidirectional and nat transversal.

  • Research on bidirectional tcp
  • Research on Nat transversal issue (20%)
  • Research on golang library
  • Testing on the libraries in bidirectional tcp
  • Testing on nat transversal feature
  • Create a simple P2P module to illustrate the bidirectional connection works

2130 only listens on IPv6 when set to "*"

The new config that uses "*" for TPC46 dual stack does not work for RPC (2130) on 0.12.4-beta.3.
Caused by change from old listener to plain Go library listen and separation to "tcp4" and "tcp6" options.

Detect the "::" and "0.0.0.0" case ad use the dual "tcp" config instead.

Testing fix in 0.12.4-beta.4

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.