安裝環(huán)境 ubuntu16.04 64位
一安裝依賴庫(mysql數(shù)據(jù)庫 )
注意丽声,記得安裝sql時的root用戶密碼
sudo apt-get install mysql-server libmysqlclient-dev libreadline-dev
二 安裝ruby環(huán)境
//回到home目錄
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
sudo rbenv install 2.2.3
sudo rbenv global 2.2.3
sudo gem install bundler
三下載水龍頭代碼
git clone https://github.com/bitshares/faucet
cd faucet
sudo bundle # ignore warnings
四 配置水龍頭文件
(1)水龍頭訪問配置faucet.yml
cp config/faucet-example.yml config/faucet.yml
vim config/faucet.yml
》》內(nèi)容如下
cli_wallet_connection: ws://127.0.0.1:8099 //錢包開放的websocketurl劲室,cli_wallet -r參數(shù)對應(yīng) ./cli_wallet --chain-id="a35368851451335a25ea894c9bf81831c4e7c39e56ce94700a7813700cadf701" -s ws://127.0.0.1:8090 -w wallet.json -r 127.0.0.1:8099 -H 127.0.0.1:8092
registrar_account: nathan //提供注冊的推薦人用戶名熬尺,本例子為在比特股環(huán)境搭建》已創(chuàng)建且升級為會員的用戶名nathan
referrer_percent: 50
refcode_prefix: F01
default_url: 127.0.0.1 //水龍頭對外訪問的IP
default_port: 3000 //水龍頭對外訪問的端口
exception_notification:
sender_address: faucet@example.com
exception_recipients: admin@example.com
smtp:
address: address
user_name: user
password: password
(2)密碼種子文件secrets.yml(ruby on rails用到的密碼種子配置文件)
cp config/secrets-example.yml config/secrets.yml
rake secret
vim config/secrets.yml
》》內(nèi)容如下 (按需要改各個清空的密碼種子)
development:
secret_key_base: abcdefg123456
test:
secret_key_base: abcdefg123456
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: abcdefg123456
(3)數(shù)據(jù)庫配置
vim config/database.yml
》》內(nèi)容如下
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root #數(shù)據(jù)庫登錄用戶名
password: #數(shù)據(jù)庫登錄密碼,根據(jù)安裝mysql時的填寫
host: localhost #數(shù)據(jù)庫url
development:
<<: *default
database: bitshares_faucet_dev
test:
<<: *default
database: bitshares_faucet_test
production:
<<: *default
database: bitshares_faucet
五 創(chuàng)建并初始化數(shù)據(jù)庫
rake db:create; rake db:migrate; rake db:seed
RAILS_ENV=production bundle exec rake db:create db:schema:load
六 運行水龍頭服務(wù) (-b 0.0.0.0 -b灌砖,bind之意衷掷。是讓本機以外的主機,能夠訪問水龍頭服務(wù))
rails s -b 0.0.0.0
七 聯(lián)合調(diào)試
1 創(chuàng)建創(chuàng)世狀態(tài)json
./witness_node --create-genesis-json "genesis.json"
2 啟動witness_node
./witness_node --rpc-endpoint "127.0.0.1:8090" --enable-stale-production -d test_net --seed-nodes "[]" --genesis-json "genesis.json"
3 啟動cli_wallet(如果報chain-id出錯誊酌,則替換提示的chain-id)
./cli_wallet --chain-id="a35368851451335a25ea894c9bf81831c4e7c39e56ce94700a7813700cadf701" -s ws://127.0.0.1:8090 -w wallet.json -r 127.0.0.1:8099 -H 127.0.0.1:8092
4 啟動網(wǎng)頁錢包服務(wù)
4.1 修改網(wǎng)頁錢包的配置文件露乏,配置默認水龍頭地址,默認p2p網(wǎng)絡(luò)的地址
/bitshares-ui/app/api/apiConfig.js
》》內(nèi)容如下
export const blockTradesAPIs = {
BASE: "https://api.blocktrades.us/v2",
// BASE_OL: "https://api.blocktrades.us/ol/v2",
BASE_OL: "https://ol-api1.openledger.info/api/v0/ol/support",
COINS_LIST: "/coins",
ACTIVE_WALLETS: "/active-wallets",
TRADING_PAIRS: "/trading-pairs",
DEPOSIT_LIMIT: "/deposit-limits",
ESTIMATE_OUTPUT: "/estimate-output-amount"
};
export const settingsAPIs = {
DEFAULT_WS_NODE: "ws://127.0.0.1:8090", //默認witness_node節(jié)點網(wǎng)絡(luò)地址
WS_NODE_LIST: [
{url: "ws://127.0.0.1:8090", location: "My hosted"}//本地witness_node節(jié)點網(wǎng)絡(luò)地址
],
DEFAULT_FAUCET: "http://127.0.0.1:3000", //默認水龍頭地址
RPC_URL: "http://127.0.0.1:8092" //推測是錢包api服務(wù)地址箱锐,測試中暫時未用到
};
4.2 啟動網(wǎng)頁錢包
npm start
4.3 瀏覽器打開127.0.0.1:8080
5 注冊(用賬戶模式測試)
注意:此時的cli_wallet命令行,
5.1 必須是unlock狀態(tài)(否則注冊報Failed to create account: tes32 - Assert Exception: !self.is_locked():)
5.2 nathan賬戶存在劳较,且已升級為會員。
5.3 nathan賬戶有很多余額
八 遇到的問題
1 配置水龍頭服務(wù)時幢哨,生成密碼種子命令rake secret報錯
$rake secret報錯
Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.,因為沒nodejs環(huán)境
=>安裝nodejs
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
nvm install v6
nvm use v6
2 執(zhí)行rake db:create; rake db:migrate; rake db:seed報錯,因root用戶在localhost被禁用
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
=>
$ sudo mysql -u root # I had to use "sudo" since is new installation
mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;
3 Failed to create account: tes32 - Assert Exception: !self.is_locked():
=》
進入cli_wallet命令模式(my_password 是set_password my_password設(shè)置的密碼)
locked >>> unlock my_password
4 運行witness_node 一天后嫂便,發(fā)現(xiàn)無法產(chǎn)生塊
2994239ms thread-0 producer_plugin.cpp:210 block_production_loo ] initk generated block #202 @ 2017-09-11T06:49:54 with 0 trxs 0 pending
2998489ms thread-0 producer_plugin.cpp:229 block_production_loo ] Not producing block because node didn't wake up within 500ms of the slot time.
3000615ms thread-0 producer_plugin.cpp:229 block_production_loo ] Not producing block because node didn't wake up within 500ms of the slot time.
3002818ms thread-0 chain_controller.cpp:235 _push_block ] inith #203 @2017-09-11t06:50:03 | 0 trx, 0 pending, exectime_ms=13
=>
BM說捞镰,生成一個大區(qū)塊是阻塞了岸售,沒說解決方法。以下是原文
This is an indication that the single CPU is getting backlogged by a large blocking task that is not properly timebound... eg, block generation with a large pending set. (https://github.com/EOSIO/eos/issues/397)
5 注意凸丸,witness_node, cli_wallet,faucet配置的IP為127.0.0.1,則服務(wù)只能本機訪問瞭稼。如需要本機外的機器能訪問腻惠,把127.0.0.1設(shè)置為本機的局域網(wǎng)IP或公網(wǎng)IP。
6 注冊時集灌,水龍頭后臺服務(wù)報異常Failed to create account: tes2 - Assert Exception: base58str.substr( 0, prefix_len ) == prefix
!!! register_account error: {"code"=>1, "message"=>"Assert Exception: base58str.substr( 0, prefix_len ) == prefix: ", "data"=>{"code"=>10, "name"=>"assert_exception", "message"=>"Assert Exception", "stack"=>[{"context"=>{"level"=>"error", "file"=>"types.cpp", "line"=>60, "method"=>"public_key_type", "hostname"=>"", "thread_name"=>"th_a", "timestamp"=>"2017-09-23T06:47:58"}, "format"=>"base58str.substr( 0, prefix_len ) == prefix: ", "data"=>{"base58str"=>"GPH5jNZn4sB7t3sBDcX3NFdx2BLEh3WA15SLmoG71dHCoLs1iTZwH"}}, {"context"=>{"level"=>"warn", "file"=>"websocket_api.cpp", "line"=>122, "method"=>"on_message", "hostname"=>"", "thread_name"=>"th_a", "timestamp"=>"2017-09-23T06:47:58"}, "format"=>"", "data"=>{"call.method"=>"call", "call.params"=>[0, "register_account", ["tes2", "GPH5jNZn4sB7t3sBDcX3NFdx2BLEh3WA15SLmoG71dHCoLs1iTZwH", "GPH5fMdwtVVKGvyawZwEBTBnftbovvNdJg1Q34BMpXPWggXtEKrbv", "nathan", "nathan", 0, true]]}}]}}
=》
因為網(wǎng)頁錢包生成的公鑰的地址前綴(GPH)和比特股源碼的前綴(BTS)不對應(yīng)欣喧。目前采用方法(2)唆阿,原因是試錯先試了這方法(2)酷鸦。方法(1)未驗證.
推測可行修改方式
(1)網(wǎng)頁錢包bitshares-core的公鑰前綴生成,是在bitsharesjs庫里提供的妄壶。這里說可以把公鑰前綴修改下。(https://blog.xiaofuxing.name/2017/04/18/ecc_in_nodejs_introduction.html)
const bitsharesjsws = require('bitsharesjs-ws');
bitsharesjsws.ChainConfig.setPrefix('BTS'); //可以手工設(shè)定前綴氨淌,這樣的話可以兼容Steem區(qū)塊鏈伊磺。
bitsharesjs庫公鑰前綴源碼見
node_modules>bitsharesjs>cjs>src>ChainConfig.js
"use strict";
exports.__esModule = true;
var _this = void 0;
var ecc_config = {
address_prefix: process.env.npm_config__graphene_ecc_default_address_prefix || "GPH"
};
_this = {
core_asset: "CORE",
address_prefix: "GPH",
expire_in_secs: 15,
expire_in_secs_proposal: 24 * 60 * 60,
review_in_secs_committee: 24 * 60 * 60,
networks: {
BitShares: {
core_asset: "BTS",
address_prefix: "BTS",
chain_id: "4018d7844c78f6a6c41c6a552b898022310fc5dec06da467ee7905a8dad512c8"
},
Muse: {
core_asset: "MUSE",
address_prefix: "MUSE",
chain_id: "45ad2d3f9ef92a49b55c2227eb06123f613bb35dd08bd876f2aea21925a67a67"
},
Test: {
core_asset: "TEST",
address_prefix: "TEST",
chain_id: "39f5e2ede1f8bc1a3a54a7914414e3779e33193f1f5693510e73cb7a87617447"
},
Obelisk: {
core_asset: "GOV",
address_prefix: "FEW",
chain_id: "1cfde7c388b9e8ac06462d68aadbd966b58f88797637d9af805b4560b0e9661e"
}
},
(2)改bitshares-core源碼的公鑰前綴為GPH重新編譯豪筝,且修改所有公鑰前綴為GPH。
修改如下
(2.1)修改源碼
(2.1.1) 源碼/bitshares-core/libraries/chain/include/graphene/chain/config.hpp
#define GRAPHENE_SYMBOL "BTS"
#define GRAPHENE_ADDRESS_PREFIX "BTS"
=>
#define GRAPHENE_SYMBOL "GPH"
#define GRAPHENE_ADDRESS_PREFIX "GPH"
(2.1.2)源碼/bitshares-core/libraries/chain/protocol/types.cpp 搜索多處"BTS"
std::string( "BTS" );
=>
std::string( "GPH" );
(2.1.3)源碼bitshares-core/libraries/chain/db_init.cpp
if( symbol == "BTS" )
=>
if( symbol == "GPH" )
(2.1.4) 修改 bitshares-core/genesis.json 敲街,替換多處
"BTS
=》
"GPH
然后重新編譯bitshares-core
(2.2)修改witness_node啟動創(chuàng)世塊狀態(tài)文件genesis.json严望,替換多處
"BTS
=》
"GPH
(2.3)修改witness_node啟動參數(shù)文件像吻,比特股參數(shù)文件 config.ini奸披,替換多處
"BTS
=》
"GPH
九 引用
http://docs.bitshares.org/testnet/7-faucet.html 《Setting up the Faucet》