Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ggq89 committed Jun 29, 2019
2 parents a8a0d1c + 1758221 commit bb7c828
Show file tree
Hide file tree
Showing 25 changed files with 118 additions and 103 deletions.
94 changes: 47 additions & 47 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,54 +151,54 @@ matrix:
- sudo -H apt-get install expect
- sudo -H apt-get install lftp
- chmod +x bdd/upload2Ftp.sh
- os: linux
dist: xenial
go: 1.12.5
env: multiple_nodes_bdd
script:
#- os: linux
# dist: xenial
# go: 1.12.5
# env: multiple_nodes_bdd
# script:
#- go build ./cmd/gptn
- make gptn
- cp bdd/light/testcases/!(preset.sh) bdd/node
- cp build/bin/gptn bdd/node
- cd bdd/node
- chmod -R +x *
- sudo -H chmod +w /etc/hosts
- sudo -H sed -i 's/127.0.0.1 localhost/127.0.0.1/g' /etc/hosts
- sudo -H sed -i '$a0.0.0.0 localhost' /etc/hosts
- ./launchMultipleNodes.sh
- netstat -ap | grep gptn
- cat /etc/hosts
- vi ptn-genesis.json
- cd ${BASE_DIR}/bdd
- mkdir -p ${BDD_LOG_PATH}
- if [ $IS_RUN_MULTIPLE == 'true' ]; then
python -m robot.run -d ${BDD_LOG_PATH}/${MULTIPLE_DIR} -i normal ./testcase/zMulti-node;
fi
after_script:
- killall gptn
- sleep 2
- cd ${BASE_DIR}
- zip -j ./bdd/logs/zMulti-node.zip ./bdd/logs/*
- |
if [ $IS_UPLOAD == 'true' ]; then
# uplaod all log
./bdd/upload2Ftp.sh ${FTP_PWD} ${TRAVIS_BRANCH};
# echo ftp address
echo "The path of all bdd log in vsftpd is 'ftp://47.74.209.46"
echo "If you want to open it in explorer, you should close VPN first."
echo "If you want to open in windows explorer, you should open Internet Explorer and open Settings->Adanced-Enable FTP Folder view"
fi
install:
- sudo -H pip install --upgrade pip
- sudo -H pip install robotframework==2.8.5
- sudo -H pip install requests
- sudo -H pip install robotframework-requests
- sudo -H pip install demjson
- sudo -H pip install pexpect
- sudo -H apt-get install jq
- sudo -H apt-get install tcl tk expect
- sudo -H apt-get install lftp
- chmod +x bdd/upload2Ftp.sh
# - make gptn
# - cp bdd/light/testcases/!(preset.sh) bdd/node
# - cp build/bin/gptn bdd/node
# - cd bdd/node
# - chmod -R +x *
# - sudo -H chmod +w /etc/hosts
# - sudo -H sed -i 's/127.0.0.1 localhost/127.0.0.1/g' /etc/hosts
# - sudo -H sed -i '$a0.0.0.0 localhost' /etc/hosts
# - ./launchMultipleNodes.sh
# - netstat -ap | grep gptn
# - cat /etc/hosts
#
# - cd ${BASE_DIR}/bdd
# - mkdir -p ${BDD_LOG_PATH}
# - if [ $IS_RUN_MULTIPLE == 'true' ]; then
# python -m robot.run -d ${BDD_LOG_PATH}/${MULTIPLE_DIR} -i normal ./testcase/zMulti-node;
# fi
# after_script:
# - killall gptn
# - sleep 2
# - cd ${BASE_DIR}
# - zip -j ./bdd/logs/zMulti-node.zip ./bdd/logs/*
# - |
# if [ $IS_UPLOAD == 'true' ]; then
# # uplaod all log
# ./bdd/upload2Ftp.sh ${FTP_PWD} ${TRAVIS_BRANCH};
# # echo ftp address
# echo "The path of all bdd log in vsftpd is 'ftp://47.74.209.46"
# echo "If you want to open it in explorer, you should close VPN first."
# echo "If you want to open in windows explorer, you should open Internet Explorer and open Settings->Adanced-Enable FTP Folder view"
# fi
# install:
# - sudo -H pip install --upgrade pip
# - sudo -H pip install robotframework==2.8.5
# - sudo -H pip install requests
# - sudo -H pip install robotframework-requests
# - sudo -H pip install demjson
# - sudo -H pip install pexpect
# - sudo -H apt-get install jq
# - sudo -H apt-get install tcl tk expect
# - sudo -H apt-get install lftp
# - chmod +x bdd/upload2Ftp.sh
- os: linux
dist: xenial
go: 1.12.5
Expand Down
4 changes: 2 additions & 2 deletions bdd/contract/testcases/createaccount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set timeout 30
spawn ../node/gptn account new
expect "Passphrase:"
send "1\r"
send "1\n"
expect "Repeat passphrase:"
send "1\r"
send "1\n"
interact

2 changes: 1 addition & 1 deletion bdd/contract/testcases/transfertoken.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ set tokenHolder [lindex $argv 0]
set another [lindex $argv 1]
spawn ../../node/gptn --exec "personal.transferPtn($tokenHolder,$another,5990)" attach ../../node/palletone/gptn.ipc
expect "Passphrase:"
send "1\r"
send "1\n"
interact
4 changes: 2 additions & 2 deletions bdd/dct/createaccount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set timeout 30
spawn ../node/gptn account new
expect "Passphrase:"
send "1\r"
send "1\n"
expect "Repeat passphrase:"
send "1\r"
send "1\n"
interact

8 changes: 4 additions & 4 deletions bdd/dct/deposit_test_cases/DepositContractTest.robot
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Business_02
Business_03
[Documentation] jury 交付 1000000 0000 0000 及以上才可以加入候选列表
${resul} juryPayToDepositContract ${juryAddr_01} 100000000000000
${resul} juryPayToDepositContract ${juryAddr_01} 1000000000
log ${resul}
${result} getCandidateBalanceWithAddr ${juryAddr_01} #获取该地址保证金账户详情
log ${result} #余额为100000000000000
Expand All @@ -135,7 +135,7 @@ Business_03
Business_04
[Documentation] 没收jury节点
${resul} juryPayToDepositContract ${juryAddr_02} 100000000000000
${resul} juryPayToDepositContract ${juryAddr_02} 1000000000
log ${resul}
${result} getCandidateBalanceWithAddr ${juryAddr_02} #获取该地址保证金账户详情
log ${result}
Expand All @@ -159,7 +159,7 @@ Business_04
Business_05
[Documentation] dev 交付 10000 0000 0000 及以上才可以加入候选列表
${resul} developerPayToDepositContract ${developerAddr_01} 1000000000000
${resul} developerPayToDepositContract ${developerAddr_01} 100000000
log ${resul}
${result} getCandidateBalanceWithAddr ${developerAddr_01} #获取该地址保证金账户详情
log ${result}
Expand All @@ -183,7 +183,7 @@ Business_05
Business_06
[Documentation] 没收dev节点
${resul} developerPayToDepositContract ${developerAddr_02} 1000000000000
${resul} developerPayToDepositContract ${developerAddr_02} 100000000
log ${resul}
${result} getCandidateBalanceWithAddr ${developerAddr_02} #获取该地址保证金账户详情
log ${result}
Expand Down
2 changes: 1 addition & 1 deletion bdd/dct/deposit_test_cases/publicParams.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ ${Url} http://127.0.0.1:8545
${depositContractAddress} PCGTta3M4t3yXu8uRgkKvaWd2d8DR32W9vM
${amount} 0
${fee} 10
${medDepositAmount} 500000000000000
${medDepositAmount} 5000000000
2 changes: 1 addition & 1 deletion bdd/dct/transfertoken.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ set tokenHolder [lindex $argv 0]
set another [lindex $argv 1]
spawn ../node/gptn --exec "personal.transferPtn($tokenHolder,$another,5990000)" attach ../node/palletone/gptn.ipc
expect "Passphrase:"
send "1\r"
send "1\n"
interact
4 changes: 2 additions & 2 deletions bdd/light/testcases/createaccount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set timeout 30
spawn ./gptn account new
expect "Passphrase:"
send "1\r"
send "1\n"
expect "Repeat passphrase:"
send "1\r"
send "1\n"
interact

2 changes: 1 addition & 1 deletion bdd/light/testcases/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set timeout 30
spawn ./gptn init
expect "Passphrase:"
send "1\r"
send "1\n"
interact


2 changes: 1 addition & 1 deletion bdd/node/launchMultipleNodes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set timeout 30
./preset.sh
#spawn ./start.sh
#expect "Please input the numbers of nodes you want:"
#send "3\r"
#send "3\n"
#interact
#expect eof
#EOF
Expand Down
6 changes: 3 additions & 3 deletions bdd/upload2Ftp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ set ftppwd [lindex $argv 0]
set folder [lindex $argv 1]
spawn lftp travis:$ftppwd@47.74.209.46
expect "lftp"
send "cd ${folder}\r"
send "cd ${folder}\n"
expect "cd"
send "mirror -R /home/travis/gopath/src/github.com/palletone/go-palletone/bdd/logs\r"
send "mirror -R /home/travis/gopath/src/github.com/palletone/go-palletone/bdd/logs\n"
expect "transferred"
send "exit\r"
send "exit\n"
interact
4 changes: 2 additions & 2 deletions cmd/deployment/createaccount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set timeout 30
spawn ./gptn account new
expect "Passphrase:"
send "1\r"
send "1\n"
expect "Repeat passphrase:"
send "1\r"
send "1\n"
interact

2 changes: 1 addition & 1 deletion cmd/deployment/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set timeout 30
spawn ./gptn init
expect "Passphrase:"
send "1\r"
send "1\n"
interact


6 changes: 4 additions & 2 deletions cmd/deployment/modifyjson.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ if [ $index -eq 0 ] ; then
createaccount=`./createaccount.sh`
account=`echo $createaccount | sed -n '$p'| awk '{print $NF}'`
account=${account:0:35}
account=`echo ${account///}`
account=`echo ${account//
/}`

add=`echo $add | jq ".tokenHolder = \"$account\""`

createaccount=`./createaccount.sh`
account=`echo $createaccount | sed -n '$p'| awk '{print $NF}'`
account=${account:0:35}
account=`echo ${account///}`
account=`echo ${account//
/}`

add=`echo $add | jq ".initialParameters.foundation_address = \"$account\""`

Expand Down
2 changes: 1 addition & 1 deletion cmd/gptn/genesis_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func modifyConfig(ctx *cli.Context, mediators []*mp.MediatorConf) error {
cfg.MediatorPlugin.EnableStaleProduction = true
cfg.MediatorPlugin.EnableConsecutiveProduction = false
cfg.MediatorPlugin.RequiredParticipation = 0
cfg.MediatorPlugin.EnableGroupSigning = true
cfg.MediatorPlugin.EnableGroupSigning = false
cfg.MediatorPlugin.Mediators = mediators

// change log
Expand Down
4 changes: 2 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
}
case ctx.GlobalBool(TestnetFlag.Name):
urls = configure.TestnetBootnodes
case cfg.BootstrapNodes != nil:
case len(cfg.BootstrapNodes) > 0:
return // already set, don't apply defaults.
}

Expand Down Expand Up @@ -751,7 +751,7 @@ func MakePasswordList(ctx *cli.Context) []string {
lines := strings.Split(string(text), "\n")
// Sanitise DOS line endings.
for i := range lines {
lines[i] = strings.TrimRight(lines[i], "\r")
lines[i] = strings.TrimRight(lines[i], "\n")
}
return lines
}
Expand Down
19 changes: 12 additions & 7 deletions configure/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ package configure

// MainnetBootnodes are the pnode URLs of the P2P bootstrap nodes running on
// the main PalletOne network.
var MainnetBootnodes = []string{}
var MainnetBootnodes = []string{
"pnode://98627f6b5fa0f549ff644e66fc2b9801ea039614784ea65d1e9e942fed573004a65d0b2e85d4a949c28844efe6f357d97c1198e1194eb436fb0a8bbfafb8e6d2@123.126.106.88:30303",
"pnode://eaef728cb3bb7d96f5efb377b2a21d134061eb4ae0276a9573055f998b7fde4fece4aac1d93c5d9bb57d8ddf054f922720dd6188f30c8f85cc68ee9e37465958@123.126.106.88:30305",
"pnode://d9d50a943c836e1576589e948c5f0b92429173e617906bcecbe16b528f3bd924f831d86b1abdb646c9ecfed466760f18423f35ef26a5ef73ac102418da6dc3c9@123.126.106.88:30306",
"pnode://beacea1636d1ee955247199d09cdc39db38db115616e22dd6c50939b44d40a876cbda4f7cedf86a2398ff67f8d67c63fbc88be1e86277377c75250ae023aa15b@123.126.106.89:30307",
"pnode://5e93e974f036fa917d66277dafb020c2c705321c82fefde81b186a934a42867324f966a83f51884a0b1e8694bd241405fbdac3131f644de3d1d4b8f88a52886a@123.126.106.89:30308",
}

// TestnetBootnodes are the pnode URLs of the P2P bootstrap nodes running on the
// Ropsten test network.
var TestnetBootnodes = []string{
"pnode://eb6523c0220620a63c1b2d1375d8c04a35e88d8ef05344331bad187c1fdc37a0c65eeff91963cd576b160753f58680109cc181514ebfb0831d42ca39cac2ee15@60.205.177.166:30303",
"pnode://aaa3a9f08a2ac9e566b5ab1c9e34655c5214b55a205c7ae0526ce59d5e841c6cafdbd23a98a8ee2181b113a0855ae007a02a559365fb0f21e0a72c9237940794@123.126.106.83:30305",
"pnode://d18ea6e8cb09984b19fbf9c47636aaa952f8aef3fabdef75756d946990091510fd3b4fbff5db5860e3b395e5bc6159454a3f5b9b87a27f6efa8a081a037a4d6c@123.126.106.84:30306",
"pnode://28f45690b29282b3ed19373f20099c6e00e275183c795d2082820cafd54d91e4009610effc7249feeaaf826ad21c3a5fa983567d190f9d3b4305338cc5a847b6@123.126.106.85:30307",
"pnode://ef2b94a2305bbbe7a9445647cf73b6aeae96e5b75f16eb78f2605f2b85f6099842cec6a01e7f995caf813b61072b99090d37141ec31fc338054bb6500925ace5@123.126.106.85:30308",
}
"pnode://d6250d040c3569e2f15f1dcd07f3dc0c56bc92736ecab2a57fe16a3d800fd8bbc2e52de8dacba59a0248c5982a4ebc2ed35bd63ad506d80705be681a51ee8d7d@123.126.106.82:30303",
"pnode://de7babb5d2b14bb780a1a5fc0f3c17e03d70ddfa847cd704f2347772997cd0ae7cf016e0d899748e0291d301805a263d2e96a15361ce3f26d47893ad167adbf0@123.126.106.83:30305",
"pnode://0096833853449ce46a1720638d044531a4f6de7cd3c22c90a96266384c9fa3cf550b14d552fbcb28e7635e0de4737ca5d985ff4954750eddbe1501ead5c461c5@123.126.106.84:30306",
"pnode://79054cfedfdbf2bedef3c9ee865a1a9843a65eaf0939be496f5b9560e42fbbfc09ea71197601834a2e68d61eb88792a2e9c143ad6c59c343b7eb1c36e461e62d@123.126.106.85:30307",
"pnode://3d7b3db523418565cc119bb4a4813753ad5a714441193e5c89ade195f4666691df66f4dbf43595efa9b343f8ad7946d057a47fb10ad5b05d7b00e30aa9068712@60.205.177.166:30308"}
5 changes: 2 additions & 3 deletions consensus/jury/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func runContractCmd(rwM rwset.TxManager, dag iDag, contract *contracts.Contract,
return nil, errors.New(fmt.Sprintf("[%s]runContractCmd APP_CONTRACT_INVOKE txid(%s) rans err:%s", shortId(reqId.String()), req.txid, err))
}
result := invokeResult.(*modules.ContractInvokeResult)
payload := modules.NewContractInvokePayload(result.ContractId, result.Args, 0 /*result.ExecutionTime*/, result.ReadSet, result.WriteSet, result.Payload, modules.ContractError{})
payload := modules.NewContractInvokePayload(result.ContractId, result.Args, 0 /*result.ExecutionTime*/ , result.ReadSet, result.WriteSet, result.Payload, modules.ContractError{})
if payload != nil {
msgs = append(msgs, modules.NewMessage(modules.APP_CONTRACT_INVOKE, payload))
}
Expand Down Expand Up @@ -498,7 +498,7 @@ func checkAndAddTxSigMsgData(local *modules.Transaction, recv *modules.Transacti
for _, sig := range sigs {
if true == bytes.Equal(sig.PubKey, recvSigMsg.Payload.(*modules.SignaturePayload).Signatures[0].PubKey) &&
true == bytes.Equal(sig.Signature, recvSigMsg.Payload.(*modules.SignaturePayload).Signatures[0].Signature) {
log.Infof("[%s]checkAndAddTxSigMsgData tx already recv, reqId[%s]", shortId(reqId.String()), reqId.String())
log.Infof("[%s]checkAndAddTxSigMsgData tx already receive, tx[%s]", shortId(reqId.String()), recv.Hash().String())
return false, nil
}
}
Expand Down Expand Up @@ -734,4 +734,3 @@ func getValidAddress(addrs []common.Address) ([]common.Address) {
}
return result
}

19 changes: 10 additions & 9 deletions consensus/jury/contractEvent.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,17 @@ func (p *Processor) contractExecEvent(tx *modules.Transaction, ele []modules.Ele
}

func (p *Processor) contractSigEvent(tx *modules.Transaction, ele []modules.ElectionInf) (broadcast bool, err error) {
p.locker.Lock()
defer p.locker.Unlock()
reqId := tx.RequestHash()
if _, ok := p.mtx[reqId];ok {
if checkTxReceived(p.mtx[reqId].rcvTx, tx) {
return false, nil
}
}
log.Debugf("[%s]contractSigEvent, receive sig tx[%s]", shortId(reqId.String()), tx.Hash().String())
if _, ok := p.mtx[reqId]; !ok {
//log.Debug("contractSigEvent", "local not find reqId,create it", reqId)
p.locker.Lock()
log.Debugf("[%s]contractSigEvent, local not find reqId,create it", shortId(reqId.String()))
p.mtx[reqId] = &contractTx{
reqTx: tx.GetRequestTx(),
eleInf: ele,
Expand All @@ -160,19 +167,13 @@ func (p *Processor) contractSigEvent(tx *modules.Transaction, ele []modules.Elec
adaInf: make(map[uint32]*AdapterInf),
}
p.mtx[reqId].rcvTx = append(p.mtx[reqId].rcvTx, tx)
p.locker.Unlock()

//go p.runContractReq(reqId, ele) //del
return true, nil
}
ctx := p.mtx[reqId]

if checkTxReceived(ctx.rcvTx, tx) {
return false, nil
}
ctx.rcvTx = append(ctx.rcvTx, tx)

//如果是jury,将接收到tx与本地执行后的tx进行对比,相同则添加签名到sigTx,如果满足三个签名且签名值最小则广播tx,否则函数返回
//如果是jury,将接收到tx与本地执行后的tx进行对比,相同则添加签名到sigTx,如果满足签名数量且签名值最小则广播tx,否则函数返回
if ok, err := checkAndAddTxSigMsgData(ctx.sigTx, tx); err == nil && ok {
if getTxSigNum(ctx.sigTx) >= p.contractSigNum {
if localIsMinSignature(ctx.sigTx) { //todo
Expand Down
4 changes: 4 additions & 0 deletions consensus/jury/election.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ func (p *Processor) processElectionSigResultEvent(evt *ElectionSigResultEvent) e
if mel == nil || mel.nType != 1 {
return nil
}
if len(mel.sigs) >= p.dag.ChainThreshold() {
log.Debugf("[%s]processElectionSigResultEvent, sig number is enough", shortId(reqId.String()))
return nil
}
//检查签名是否重复,收集签名,数量满足则广播请求交易
for _, sig := range mel.sigs {
if bytes.Equal(sig.PubKey, evt.Sig.PubKey) {
Expand Down
Loading

0 comments on commit bb7c828

Please sign in to comment.