Commit 6e693abc authored by 王志文's avatar 王志文

Merge branch 'add_plugin_2' into 'master'

Add plugin 2 See merge request chain33/plugin!11
parents 4be3c2e0 5bd284a8
...@@ -49,7 +49,8 @@ update: ...@@ -49,7 +49,8 @@ update:
rm -rf ${CHAIN33_PATH} rm -rf ${CHAIN33_PATH}
git clone --depth 1 -b master https://${CHAIN33}.git ${CHAIN33_PATH} git clone --depth 1 -b master https://${CHAIN33}.git ${CHAIN33_PATH}
rm -rf vendor/${CHAIN33}/.git rm -rf vendor/${CHAIN33}/.git
cp -R vendor/${CHAIN33}/vendor/* vendor/ rm -rf vendor/${CHAIN33}/vendor/github.com/apache/thrift/tutorial/erl/
cp -Rf vendor/${CHAIN33}/vendor/* vendor/
rm -rf vendor/${CHAIN33}/vendor rm -rf vendor/${CHAIN33}/vendor
govendor init govendor init
go build -i -o tool gitlab.33.cn/chain33/plugin/vendor/gitlab.33.cn/chain33/chain33/cmd/tools go build -i -o tool gitlab.33.cn/chain33/plugin/vendor/gitlab.33.cn/chain33/chain33/cmd/tools
...@@ -204,9 +205,8 @@ auto_ci_after: clean fmt protobuf ...@@ -204,9 +205,8 @@ auto_ci_after: clean fmt protobuf
@git add *.go *.sh *.proto @git add *.go *.sh *.proto
@git status @git status
@files=$$(git status -suno);if [ -n "$$files" ]; then \ @files=$$(git status -suno);if [ -n "$$files" ]; then \
git add *.go *.sh *.proto; \
git status; \ git status; \
git commit -m "auto ci [ci-skip]"; \ git commit -a -m "auto ci [ci-skip]"; \
git push origin HEAD:$(branch); \ git push origin HEAD:$(branch); \
fi; fi;
...@@ -219,13 +219,12 @@ auto_ci: clean fmt_proto fmt_shell protobuf ...@@ -219,13 +219,12 @@ auto_ci: clean fmt_proto fmt_shell protobuf
-${auto_fmt} -${auto_fmt}
-find . -name '*.go' -not -path './vendor/*' | xargs gofmt -l -w -s -find . -name '*.go' -not -path './vendor/*' | xargs gofmt -l -w -s
${auto_fmt} ${auto_fmt}
git add *.go *.sh *.proto
git status git status
echo $(branch) echo $(branch)
files=$$(git status -suno); if [ -n "$$files" ]; then \ files=$$(git status -suno); if [ -n "$$files" ]; then \
git add *.go *.sh *.proto; \ git add *.go *.sh *.proto; \
git status; \ git status; \
git commit -m "auto ci"; \ git commit -a -m "auto ci"; \
git push origin HEAD:$(branch); \ git push origin HEAD:$(branch); \
exit 1; \ exit 1; \
fi; fi;
......
...@@ -4,9 +4,10 @@ package main ...@@ -4,9 +4,10 @@ package main
import ( import (
_ "gitlab.33.cn/chain33/chain33/system" _ "gitlab.33.cn/chain33/chain33/system"
"gitlab.33.cn/chain33/chain33/util/cli"
"gitlab.33.cn/chain33/plugin/cli/buildflags" "gitlab.33.cn/chain33/plugin/cli/buildflags"
_ "gitlab.33.cn/chain33/plugin/plugin" _ "gitlab.33.cn/chain33/plugin/plugin"
"gitlab.33.cn/chain33/chain33/util/cli"
) )
func main() { func main() {
......
[![pipeline status](https://gitlab.33.cn/chain33/chain33/badges/develop/pipeline.svg)](https://gitlab.33.cn/chain33/chain33/commits/master) [![pipeline status](https://gitlab.33.cn/chain33/chain33/badges/master/pipeline.svg)](https://gitlab.33.cn/chain33/chain33/commits/master)
[![coverage report](https://gitlab.33.cn/chain33/chain33/badges/develop/coverage.svg)](https://gitlab.33.cn/chain33/chain33/commits/master) [![coverage report](https://gitlab.33.cn/chain33/chain33/badges/master/coverage.svg)](https://gitlab.33.cn/chain33/chain33/commits/master)
[![Go Report Card](https://goreportcard.com/badge/gitlab.33.cn/chain33/chain33)](https://goreportcard.com/report/gitlab.33.cn/chain33/chain33) [![Go Report Card](https://goreportcard.com/badge/gitlab.33.cn/chain33/chain33)](https://goreportcard.com/report/gitlab.33.cn/chain33/chain33)
# Chain33 Core Developer Edition # Chain33 Core Developer Edition
......
...@@ -64,30 +64,43 @@ echo "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" ...@@ -64,30 +64,43 @@ echo "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME"
echo "CLI=$CLI" echo "CLI=$CLI"
#################### ####################
testtoml=chain33.toml
function base_init() { function base_init() {
# update test environment # update test environment
sed -i $sedfix 's/^Title.*/Title="local"/g' chain33.toml sed -i $sedfix 's/^Title.*/Title="local"/g' ${testtoml}
sed -i $sedfix 's/^TestNet=.*/TestNet=true/g' chain33.toml sed -i $sedfix 's/^TestNet=.*/TestNet=true/g' ${testtoml}
# p2p # p2p
sed -i $sedfix 's/^seeds=.*/seeds=["chain33:13802","chain32:13802","chain31:13802"]/g' chain33.toml sed -i $sedfix 's/^seeds=.*/seeds=["chain33:13802","chain32:13802","chain31:13802"]/g' ${testtoml}
#sed -i $sedfix 's/^enable=.*/enable=true/g' chain33.toml #sed -i $sedfix 's/^enable=.*/enable=true/g' chain33.toml
sed -i $sedfix '0,/^enable=.*/s//enable=true/' chain33.toml sed -i $sedfix '0,/^enable=.*/s//enable=true/' ${testtoml}
sed -i $sedfix 's/^isSeed=.*/isSeed=true/g' chain33.toml sed -i $sedfix 's/^isSeed=.*/isSeed=true/g' ${testtoml}
sed -i $sedfix 's/^innerSeedEnable=.*/innerSeedEnable=false/g' chain33.toml sed -i $sedfix 's/^innerSeedEnable=.*/innerSeedEnable=false/g' ${testtoml}
sed -i $sedfix 's/^useGithub=.*/useGithub=false/g' chain33.toml sed -i $sedfix 's/^useGithub=.*/useGithub=false/g' ${testtoml}
# rpc # rpc
sed -i $sedfix 's/^jrpcBindAddr=.*/jrpcBindAddr="0.0.0.0:8801"/g' chain33.toml sed -i $sedfix 's/^jrpcBindAddr=.*/jrpcBindAddr="0.0.0.0:8801"/g' ${testtoml}
sed -i $sedfix 's/^grpcBindAddr=.*/grpcBindAddr="0.0.0.0:8802"/g' chain33.toml sed -i $sedfix 's/^grpcBindAddr=.*/grpcBindAddr="0.0.0.0:8802"/g' ${testtoml}
sed -i $sedfix 's/^whitelist=.*/whitelist=["localhost","127.0.0.1","0.0.0.0"]/g' chain33.toml sed -i $sedfix 's/^whitelist=.*/whitelist=["localhost","127.0.0.1","0.0.0.0"]/g' ${testtoml}
# wallet # wallet
sed -i $sedfix 's/^minerdisable=.*/minerdisable=false/g' chain33.toml sed -i $sedfix 's/^minerdisable=.*/minerdisable=false/g' ${testtoml}
#consens
consens_init "solo"
} }
function consens_init() {
if [ "$1" == "solo" ]; then
sed -i $sedfix 's/^name="ticket"/name="solo"/g' ${testtoml}
sed -i $sedfix 's/^singleMode=false/singleMode=true/g' ${testtoml}
fi
}
function start() { function start() {
echo "=========== # docker-compose ps =============" echo "=========== # docker-compose ps ============="
docker-compose ps docker-compose ps
...@@ -99,35 +112,20 @@ function start() { ...@@ -99,35 +112,20 @@ function start() {
#docker-compose -f docker-compose.yml -f docker-compose-paracross.yml -f docker-compose-relay.yml up --build -d #docker-compose -f docker-compose.yml -f docker-compose-paracross.yml -f docker-compose-relay.yml up --build -d
docker-compose up --build -d docker-compose up --build -d
local SLEEP=30 local SLEEP=5
echo "=========== sleep ${SLEEP}s =============" echo "=========== sleep ${SLEEP}s ============="
sleep ${SLEEP} sleep ${SLEEP}
docker-compose ps docker-compose ps
# query node run status # query node run status
check_docker_status
${CLI} block last_header ${CLI} block last_header
${CLI} net info ${CLI} net info
${CLI} net peer_info ${CLI} net peer_info
peersCount=$(${CLI} net peer_info | jq '.[] | length') peersCount=$(${CLI} net peer_info | jq '.[] | length')
echo "${peersCount}" echo "peersCount=${peersCount}"
if [ "${peersCount}" -lt 2 ]; then
sleep 20
peersCount=$(${CLI} net peer_info | jq '.[] | length')
echo "${peersCount}"
if [ "${peersCount}" -lt 2 ]; then
echo "peers error"
exit 1
fi
fi
#echo "=========== # create seed for wallet ============="
#seed=$(${CLI} seed generate -l 0 | jq ".seed")
#if [ -z "${seed}" ]; then
# echo "create seed error"
# exit 1
#fi
echo "=========== # save seed to wallet =============" echo "=========== # save seed to wallet ============="
result=$(${CLI} seed save -p 1314 -s "tortoise main civil member grace happy century convince father cage beach hip maid merry rib" | jq ".isok") result=$(${CLI} seed save -p 1314 -s "tortoise main civil member grace happy century convince father cage beach hip maid merry rib" | jq ".isok")
...@@ -162,19 +160,12 @@ function start() { ...@@ -162,19 +160,12 @@ function start() {
exit 1 exit 1
fi fi
sleep 1 block_wait 1
echo "=========== # close auto mining ============="
result=$(${CLI} wallet auto_mine -f 0 | jq ".isok")
if [ "${result}" = "false" ]; then
exit 1
fi
block_wait "${CLI}" 1
echo "=========== check genesis hash ========== " echo "=========== check genesis hash ========== "
${CLI} block hash -t 0 ${CLI} block hash -t 0
res=$(${CLI} block hash -t 0 | jq ".hash") res=$(${CLI} block hash -t 0 | jq ".hash")
count=$(echo "$res" | grep -c "0x67c58d6ba9175313f0468ae4e0ddec946549af7748037c2fdd5d54298afd20b6") count=$(echo "$res" | grep -c "0xfd39dbdbd2cdeb9f34bcec3612735671b35e2e2dbf9a4e6e3ed0c34804a757bb")
if [ "${count}" != 1 ]; then if [ "${count}" != 1 ]; then
echo "genesis hash error!" echo "genesis hash error!"
exit 1 exit 1
...@@ -184,33 +175,54 @@ function start() { ...@@ -184,33 +175,54 @@ function start() {
${CLI} block last_header ${CLI} block last_header
result=$(${CLI} block last_header | jq ".height") result=$(${CLI} block last_header | jq ".height")
if [ "${result}" -lt 1 ]; then if [ "${result}" -lt 1 ]; then
block_wait "${CLI}" 2 block_wait 2
fi fi
sync_status "${CLI}" # sync_status "${CLI}"
${CLI} wallet status ${CLI} wallet status
${CLI} account list ${CLI} account list
${CLI} mempool list ${CLI} mempool list
} }
function check_docker_status() {
status=$(docker-compose ps | grep chain33_1 | awk '{print $6}')
if [ "${status}" == "Exit" ]; then
echo "=========== chain33 service Exit logs ========== "
docker-compose logs chain33
echo "=========== chain33 service Exit logs End========== "
fi
}
function block_wait() { function block_wait() {
sleep "$1"
}
function block_wait_by_height() {
if [ "$#" -lt 2 ]; then if [ "$#" -lt 2 ]; then
echo "wrong block_wait params" echo "wrong block_wait params"
exit 1 exit 1
fi fi
cur_height=$(${1} block last_header | jq ".height")
expect=$((cur_height + ${2})) cur_height=$1
count=0 # shellcheck disable=SC2004
expect=$(($1 + $2))
count=100
while true; do while true; do
new_height=$(${1} block last_header | jq ".height") new_height=$(${CLI} block last_header | jq ".height")
if [ "${new_height}" -ge "${expect}" ]; then if [ "${new_height}" -ge "${expect}" ]; then
break break
fi fi
count=$((count + 1)) count=$((count - 1))
if [ $count -le 0 ]; then
exit 1
fi
echo "wait new block, cur height=$new_height,expect=$expect"
sleep 1 sleep 1
done done
echo "wait new block $count s, cur height=$expect,old=$cur_height" echo "wait new block remain $count s, cur height=$new_height,old=$cur_height"
} }
function check_docker_container() { function check_docker_container() {
...@@ -262,18 +274,23 @@ function sync() { ...@@ -262,18 +274,23 @@ function sync() {
function transfer() { function transfer() {
echo "=========== # transfer =============" echo "=========== # transfer ============="
${CLI} block last_header
curHeight=$(${CLI} block last_header | jq ".height")
echo "curheight=$curHeight"
hashes=() hashes=()
for ((i = 0; i < 10; i++)); do for ((i = 0; i < 10; i++)); do
hash=$(${CLI} send coins transfer -a 1 -n test -t 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt -k 4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01) hash=$(${CLI} send coins transfer -a 1 -n test -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944)
echo "$hash"
hashes=("${hashes[@]}" "$hash") hashes=("${hashes[@]}" "$hash")
done done
block_wait "${CLI}" 1
block_wait_by_height "$curHeight", 1
echo "len: ${#hashes[@]}" echo "len: ${#hashes[@]}"
if [ "${#hashes[@]}" != 10 ]; then if [ "${#hashes[@]}" != 10 ]; then
echo "tx number wrong" echo "tx number wrong"
exit 1 exit 1
fi fi
for ((i = 0; i < ${#hashes[*]}; i++)); do for ((i = 0; i < ${#hashes[*]}; i++)); do
txs=$(${CLI} tx query_hash -s "${hashes[$i]}" | jq ".txs") txs=$(${CLI} tx query_hash -s "${hashes[$i]}" | jq ".txs")
if [ -z "${txs}" ]; then if [ -z "${txs}" ]; then
...@@ -282,28 +299,17 @@ function transfer() { ...@@ -282,28 +299,17 @@ function transfer() {
fi fi
done done
echo "=========== # withdraw =============" ${CLI} account balance -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -e coins
hash=$(${CLI} send coins transfer -a 2 -n deposit -t 1wvmD6RNHzwhY4eN75WnM6JcaAvNQ4nHx -k CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944) balance=$(${CLI} account balance -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -e coins | jq -r ".balance")
echo "${hash}" if [ "${balance}" != "10.0000" ]; then
block_wait "${CLI}" 1 echo "wrong balance=$balance, should not be 10.0000"
before=$(${CLI} account balance -a 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt -e retrieve | jq -r ".balance")
if [ "${before}" == "0.0000" ]; then
echo "wrong ticket balance, should not be zero"
exit 1 exit 1
fi fi
hash=$(${CLI} send coins withdraw -a 1 -n withdraw -e retrieve -k CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944)
echo "${hash}"
block_wait "${CLI}" 1
txs=$(${CLI} tx query_hash -s "${hash}" | jq ".txs")
if [ "${txs}" == "null" ]; then
echo "withdraw cannot find tx"
exit 1
fi
} }
function base_config() { function base_config() {
sync # sync
transfer transfer
} }
......
...@@ -98,6 +98,13 @@ targetTimePerBlock = 15 ...@@ -98,6 +98,13 @@ targetTimePerBlock = 15
[mver.consensus.ForkChainParamV2] [mver.consensus.ForkChainParamV2]
powLimitBits = "0x1f2fffff" powLimitBits = "0x1f2fffff"
[consensus.sub.solo]
genesis="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
genesisBlockTime=1514533394
hotkeyAddr="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
waitTxMs=10
[consensus.sub.ticket] [consensus.sub.ticket]
genesisBlockTime=1514533394 genesisBlockTime=1514533394
[[consensus.sub.ticket.genesis]] [[consensus.sub.ticket.genesis]]
......
...@@ -240,13 +240,6 @@ func (this *importPackageStrategy) fetchPlugin(gitrepo, version string) error { ...@@ -240,13 +240,6 @@ func (this *importPackageStrategy) fetchPlugin(gitrepo, version string) error {
return cmd.Run() return cmd.Run()
} }
func runcmd(action string, param string) error {
cmd := exec.Command("govendor", action, param)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
// fetchPluginPackage 使用govendor来下载依赖包 // fetchPluginPackage 使用govendor来下载依赖包
func (this *importPackageStrategy) fetchPluginPackage() error { func (this *importPackageStrategy) fetchPluginPackage() error {
mlog.Info("下载插件源码包") mlog.Info("下载插件源码包")
......
...@@ -54,10 +54,10 @@ func init() { ...@@ -54,10 +54,10 @@ func init() {
sendCmd, sendCmd,
closeCmd, closeCmd,
) )
pluginmgr.AddCmd(rootCmd)
} }
func Run(RPCAddr, ParaName string) { func Run(RPCAddr, ParaName string) {
pluginmgr.AddCmd(rootCmd)
log.SetLogLevel("error") log.SetLogLevel("error")
types.S("RPCAddr", RPCAddr) types.S("RPCAddr", RPCAddr)
types.S("ParaName", ParaName) types.S("ParaName", ParaName)
......
...@@ -197,7 +197,7 @@ func (wallet *Wallet) IsRescanUtxosFlagScaning() (bool, error) { ...@@ -197,7 +197,7 @@ func (wallet *Wallet) IsRescanUtxosFlagScaning() (bool, error) {
return flag, err return flag, err
} }
return flag, types.ErrNotSupport return flag, nil
} }
func (wallet *Wallet) Close() { func (wallet *Wallet) Close() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment