本文为Burrow私链搭建预研分析。
Go语言版本:1.11以上
Goland安装mod
https://goproxy.cn
执行命令
go mod vendor
安装命令
go get github.com/hyperledger/burrow
cd $GOPATH/src/github.com/hyperledger/burrow
export GO111MODULE=on
make build
#burrow 可执行文件默认在$HOME/go/bin下
# Read spec on stdin
burrow spec -p1 -f1 | burrow configure -s- > burrow.toml
# This is a place we can store config files and burrow's working directory '.burrow'
mkdir chain_dir && cd chain_dir
burrow spec --participant-accounts=1 --full-accounts=1 > genesis-spec.json
burrow configure --genesis-spec=genesis-spec.json > burrow.toml
# To select our validator address by index in the GenesisDoc
# Or to select based on address directly (substituting the example address below with your validator's):
burrow start --address=9F50D730BD69A7258F5EA9DDD8A92B58FE763C7C
#地址需要在.key/data/下有账号才行
rm -rf .burrow
jobs:
- name: sendTxTest1
send:
destination: PUT_HERE_ONE_ACCOUNT_OF_YOUR_GENESIS
amount: 42
SIGNING_ADDRESS=HERE_ONE_VALIDATOR_ADDRESS_OF_THE_GENESIS
burrow deploy --address BE584820DC904A55449D7EB0C97607B40224B96E test.yaml
*****Executing Job*****
Job Name => defaultAddr
*****Executing Job*****
Job Name => sendTxTest1
Transaction Hash => 41E0C13D1515F83E6FFDC5032C60682BE1F5B19A
Writing [test.output.json] to current directory
jobs:
- name: deployStorageK
deploy:
contract: storage.sol
- name: setStorageBaseBool
set:
val: "true"
- name: setStorageBool
call:
destination: $deployStorageK
function: setBool
data:
- $setStorageBaseBool
- name: queryStorageBool
query-contract:
destination: $deployStorageK
function: getBool
- name: assertStorageBool
assert:
key: $queryStorageBool
relation: eq
val: $setStorageBaseBool
# tests string bools: #71
- name: setStorageBool2
call:
destination: $deployStorageK
function: setBool2
data:
- true
- name: queryStorageBool2
query-contract:
destination: $deployStorageK
function: getBool2
- name: assertStorageBool2
assert:
key: $queryStorageBool2
relation: eq
val: "true"
- name: setStorageBaseInt
set:
val: 50000
- name: setStorageInt
call:
destination: $deployStorageK
function: setInt
data:
- $setStorageBaseInt
- name: queryStorageInt
query-contract:
destination: $deployStorageK
function: getInt
- name: assertStorageInt
assert:
key: $queryStorageInt
relation: eq
val: $setStorageBaseInt
- name: setStorageBaseUint
set:
val: 9999999
- name: setStorageUint
call:
destination: $deployStorageK
function: setUint
data:
- $setStorageBaseUint
- name: queryStorageUint
query-contract:
destination: $deployStorageK
function: getUint
- name: assertStorageUint
assert:
key: $queryStorageUint
relation: eq
val: $setStorageBaseUint
- name: setStorageBaseAddress
set:
val: "1040E6521541DAB4E7EE57F21226DD17CE9F0FB7"
- name: setStorageAddress
call:
destination: $deployStorageK
function: setAddress
data:
- $setStorageBaseAddress
- name: queryStorageAddress
query-contract:
destination: $deployStorageK
function: getAddress
- name: assertStorageAddress
assert:
key: $queryStorageAddress
relation: eq
val: $setStorageBaseAddress
- name: setStorageBaseBytes
set:
val: marmatoshi
- name: setStorageBytes
call:
destination: $deployStorageK
function: setBytes
data:
- $setStorageBaseBytes
- name: queryStorageBytes
query-contract:
destination: $deployStorageK
function: getBytes
- name: assertStorageBytes
assert:
key: $queryStorageBytes
relation: eq
val: $setStorageBaseBytes
- name: setStorageBaseString
set:
val: nakaburrow
- name: setStorageString
call:
destination: $deployStorageK
function: setString
data:
- $setStorageBaseString
- name: queryStorageString
query-contract:
destination: $deployStorageK
function: getString
- name: assertStorageString
assert:
key: $queryStorageString
relation: eq
val: $setStorageBaseString
pragma solidity >=0.0.0;
contract SimpleStorage {
bool storedBool;
bool storedBool2;
int storedInt;
uint storedUint;
address storedAddress;
bytes32 storedBytes;
string storedString;
function setBool(bool x) public {
storedBool = x;
}
function getBool() view public returns (bool retBool) {
return storedBool;
}
function setBool2(bool x) public {
storedBool2 = x;
}
function getBool2() view public returns (bool retBool) {
return storedBool2;
}
function setInt(int x) public {
storedInt = x;
}
function getInt() view public returns (int retInt) {
return storedInt;
}
function setUint(uint x) public {
storedUint = x;
}
function getUint() view public returns (uint retUint) {
return storedUint;
}
function setAddress(address x) public {
storedAddress = x;
}
function getAddress() view public returns (address retAddress) {
return storedAddress;
}
function setBytes(bytes32 x) public {
storedBytes = x;
}
function getBytes() view public returns (bytes32 retBytes) {
return storedBytes;
}
function setString(string memory x) public {
storedString = x;
}
function getString() view public returns (string memory retString) {
return storedString;
}
}
4、因为需要编译合约,我们采取solc binary编译方式,以下是安装过程:
首先安装npm和node
一、第一种安装方法(推荐)
#安装nvm
[sudo] curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
#激活nvm
[sudo] source ~/.nvm/nvm.sh
#安装node
[sudo] nvm install node
#切换到该版本
[sudo] nvm use node
二、第二种安装方法
#安装nodejs
[sudo] yum install nodejs
#建立软连接
[sudo] ln -s /usr/bin/nodejs /usr/bin/node
#安装npm
[sudo] yum install npm
#安装remix
[sudo] npm install remix-ide -g
[sudo] remix-ide
4、将合约部署至单节点
burrow deploy --address F71831847564B7008AD30DD56336D9C42787CF63 deploy.yaml
rm -rf .burrow* .keys*
burrow spec -f2 | burrow configure -s- --pool
burrow start --config=burrow000.toml
burrow start --config=burrow001.toml
rm -rf .burrow00*
curl -s 127.0.0.1:26758/consensus
burrow spec -v1 -r1 | burrow configure -s- --pool
burrow start --config burrow000.toml &
burrow start --config burrow001.toml &
curl -s " localhost:26758 / validators ”
burrow tx --config burrow001.toml formulate bond --amount 10000 | burrow tx commit
burrow tx --config burrow001.toml formulate bond --source 8A468CC3A28A6E84ED52E433DA21D6E9ED7C1577 --amount 10000
curl -s "localhost:26759/validators"
burrow tx formulate unbond | burrow tx commit