Nodejs implementation of REI-Network protocols
This project is under continuous development, all protocols and modules may be changed in the future, use it at your own risk
- node >=
16.0.0
- npm >=
7.0.0
- supported system:
- MacOS 12+
- Any Linux with glibc >=
2.28
and glibcxx >=3.4.25
npm install @rei-network/cli --global
Usage: rei [options] [command]
Options:
-V, --version output the version number
--rpc open rpc server
--rpc-port <port> rpc server port
--rpc-host <port> rpc server host
--rpc-api <apis> rpc server apis: debug, eth, net, txpool, web3, rei
--p2p-tcp-port <port> p2p server tcp port
--p2p-udp-port <port> p2p server udp port
--p2p-nat <ip> p2p server nat ip
--max-peers <peers> max p2p peers count
--max-dials <dials> max p2p dials count
--bootnodes <bootnodes...> comma separated list of bootnodes
--sync <sync> sync mode: full, snap (default: "full")
--snap-trusted-height <trustedHeight> snap sync trusted height.
this value and trustedHash are specified at the same time to take effect.
snap sync will start from the specified block to verify the legitimacy.
e.g. 100
--snap-trusted-hash <trustedHash> snap sync trusted hash.
this value and trustedHeight are specified at the same time to take effect.
snap sync will start from the specified block to verify the legitimacy.
e.g. 0x123...
--snap-min-td <minTD> minimum total difficulty difference for snap sync
--skip-verify-snap whether skip verifing snapshot
--datadir <path> chain data dir path (default: "~/.rei")
--keystore <keystore> the datadir for keystore (default: "keystore")
--unlock <unlock> comma separated list of accounts to unlock
--password <password> password file to use for non-interactive password input
--chain <chain> chain name: rei-mainnet, rei-testnet, rei-devnet
--mine mine block
--coinbase <address> miner address
--verbosity <verbosity> logging verbosity: silent, error, warn, info, debug, detail (default: "info")
--receipts-cache-size <receiptsCacheSize> receipts cache size
--evm <evm> evm implementation type, "js" or "binding"
--bls <bls> the datadir for bls (default: "bls")
--bls-password <blsPassword> bls password file to use for non-interactive password input
--bls-file <blsFile> bls file name
-h, --help display help for command
Commands:
account Manage accounts
attach [ipcpath] Start an interactive JavaScript environment (connect to node)
console Start an interactive JavaScript environment
bls Manage bls signature key
Block producer startup
rei --mine --coinbase 0x...abc --unlock 0x...abc --password ./password
Normal node startup
rei --rpc --rpc-host 0.0.0.0
Bootnode startup
rei --p2p-nat 1.2.3.4
Testnet node startup
rei --chain rei-testnet
This monorepo uses npm workspaces. It links the local packages together, making development a lot easier.
Install:
npm install
Build:
npm run build -ws
npm run build:docker -- -t tag .
Windows users might run into the following error when trying to install the repo: '.' is not recognized as an internal or external command
. To remediate for this, you can force Windows to use Git bash to run scripts (you'll need to install Git for Windows for this) with the following command:
npm config set script-shell "C:\\Program Files (x86)\\git\\bin\\bash.exe"
If you ever need to reset this change, you can do so with this command:
npm config delete script-shell
Adds dependencies listed in the root package.
Builds all monorepo packages.
To build a specific package, use npm run build -w @rei-network/contracts
Only build single monorepo package.
Removes root and packages node_modules
, dist
directories, and other generated files.
Only remove dist
directories for each monorepo packages.
These scripts execute lint and lint:fix respectively, to all monorepo packages.
-
Q: Why do I get
ModuleNotFoundError: No module named 'distutils'
when I install@rei-network/cli
?like this
npm error gyp info spawn /usr/bin/python3 npm error gyp info spawn args [ npm error gyp info spawn args '/app/node_modules/node-gyp/gyp/gyp_main.py', npm error gyp info spawn args 'binding.gyp', npm error gyp info spawn args '-f', npm error gyp info spawn args 'make', npm error gyp info spawn args '-I', npm error gyp info spawn args '/app/node_modules/@chainsafe/blst/blst/bindings/node.js/build/config.gypi', npm error gyp info spawn args '-I', npm error gyp info spawn args '/app/node_modules/node-gyp/addon.gypi', npm error gyp info spawn args '-I', npm error gyp info spawn args '/root/.cache/node-gyp/22.16.0/include/node/common.gypi', npm error gyp info spawn args '-Dlibrary=shared_library', npm error gyp info spawn args '-Dvisibility=default', npm error gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/22.16.0', npm error gyp info spawn args '-Dnode_gyp_dir=/app/node_modules/node-gyp', npm error gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/22.16.0/<(target_arch)/node.lib', npm error gyp info spawn args '-Dmodule_root_dir=/app/node_modules/@chainsafe/blst/blst/bindings/node.js', npm error gyp info spawn args '-Dnode_engine=v8', npm error gyp info spawn args '--depth=.', npm error gyp info spawn args '--no-parallel', npm error gyp info spawn args '--generator-output', npm error gyp info spawn args 'build', npm error gyp info spawn args '-Goutput_dir=.' npm error gyp info spawn args ] npm error Traceback (most recent call last): npm error File "/app/node_modules/node-gyp/gyp/gyp_main.py", line 42, in <module> npm error import gyp # noqa: E402 npm error ^^^^^^^^^^ npm error File "/app/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 9, in <module> npm error import gyp.input npm error File "/app/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in <module> npm error from distutils.version import StrictVersion npm error ModuleNotFoundError: No module named 'distutils'
A: Please install python@3.11, then specify the python for
node-gyp
export PYTHON="/path/to/python3.11"
-
Q: Why do I get
SyntaxError: Unexpected token '?'
when I runrei
?like this
/xxx/v12.20.0/lib/node_modules/@rei-network/cli/node_modules/@gxchain2/discv5/lib/service/addrVotes.js:44 let best = [tiebreakerStr, this.tallies[tiebreakerStr] ?? 0]; ^ SyntaxError: Unexpected token '?' at wrapSafe (internal/modules/cjs/loader.js:915:16) at Module._compile (internal/modules/cjs/loader.js:963:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object.<anonymous> (/xxx/v12.20.0/lib/node_modules/@rei-network/cli/node_modules/@gxchain2/discv5/lib/service/service.js:18:21) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
A: Please update the node version to 14.16.1 or higher. nvm may be able to help you