Commit 4f2480d4 authored by QM's avatar QM

Merge remote-tracking branch 'upstream/master' into issues898_para_add_supervision_0923

parents 30115e85 84435b3c
...@@ -134,10 +134,6 @@ function base_init() { ...@@ -134,10 +134,6 @@ function base_init() {
#relay genesis #relay genesis
sed -i $sedfix 's/^genesis="12qyocayNF7.*/genesis="1G5Cjy8LuQex2fuYv3gzb7B8MxAnxLEqt3"/g' chain33.toml sed -i $sedfix 's/^genesis="12qyocayNF7.*/genesis="1G5Cjy8LuQex2fuYv3gzb7B8MxAnxLEqt3"/g' chain33.toml
#autonomy
sed -i $sedfix 's/^useBalance=.*/useBalance=true/g' chain33.toml
sed -i $sedfix 's/^total="16htvcBNS.*/total="1Q9sQwothzM1gKSzkVZ8Dt1tqKX1uzSagx"/g' chain33.toml
if [ "$DAPP" == "x2ethereum" ]; then if [ "$DAPP" == "x2ethereum" ]; then
sed -i $sedfix 's/^enableReduceLocaldb=.*/enableReduceLocaldb=false/g' chain33.toml sed -i $sedfix 's/^enableReduceLocaldb=.*/enableReduceLocaldb=false/g' chain33.toml
sed -i $sedfix 's/^enablePushSubscribe=.*/enablePushSubscribe=true/g' chain33.toml sed -i $sedfix 's/^enablePushSubscribe=.*/enablePushSubscribe=true/g' chain33.toml
......
...@@ -372,6 +372,7 @@ ForkUnfreezeIDX= 0 ...@@ -372,6 +372,7 @@ ForkUnfreezeIDX= 0
[fork.sub.autonomy] [fork.sub.autonomy]
Enable=0 Enable=0
ForkAutonomyDelRule=0
[fork.sub.jsvm] [fork.sub.jsvm]
Enable=0 Enable=0
......
...@@ -4,6 +4,10 @@ strpwd=$(pwd) ...@@ -4,6 +4,10 @@ strpwd=$(pwd)
strcmd=${strpwd##*dapp/} strcmd=${strpwd##*dapp/}
strapp=${strcmd%/cmd*} strapp=${strcmd%/cmd*}
OUT_DIR="${1}/$strapp"
mkdir -p "${OUT_DIR}"
cp ./build/* "${OUT_DIR}"
OUT_TESTDIR="${1}/dapptest/$strapp" OUT_TESTDIR="${1}/dapptest/$strapp"
mkdir -p "${OUT_TESTDIR}" mkdir -p "${OUT_TESTDIR}"
cp ./test/* "${OUT_TESTDIR}" cp ./test/* "${OUT_TESTDIR}"
This diff is collapsed.
#!/usr/bin/env bash
# shellcheck disable=SC2128
# shellcheck source=/dev/null
# shellcheck disable=SC2155
set -x
set -e
#color
RED='\033[1;31m'
GRE='\033[1;32m'
NOC='\033[0m'
function exit_test() {
exit 1
}
# $1 dockerName
function get_docker_addr() {
local dockerAddr=$(docker inspect "${1}" | jq ".[].NetworkSettings.Networks" | grep "IPAddress" | awk '{ print $2}' | sed 's/\"//g' | sed 's/,//g')
echo "${dockerAddr}"
}
# chain33 区块等待 $1:cli 路径 $2:等待高度
function block_wait() {
set +x
local CLI=${1}
if [[ $# -lt 1 ]]; then
echo -e "${RED}wrong block_wait parameter${NOC}"
exit_test
fi
local cur_height=$(${CLI} block last_header | jq ".height")
local expect=$((cur_height + ${2}))
local count=0
while true; do
new_height=$(${CLI} block last_header | jq ".height")
if [[ ${new_height} -ge ${expect} ]]; then
break
fi
count=$((count + 1))
sleep 1
done
count=$((count + 1))
set -x
echo -e "${GRE}chain33 wait new block $count s, cur height=$expect,old=$cur_height${NOC}"
}
# 检查交易是否执行成功 $1:cli 路径 $2:交易hash
function check_tx() {
set +x
local CLI=${1}
if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong check_tx parameters${NOC}"
exit_test
fi
if [[ ${2} == "" ]]; then
echo -e "${RED}wrong check_tx txHash is empty${NOC}"
exit_test
fi
local count=0
while true; do
ty=$(${CLI} tx query -s "${2}" | jq .receipt.ty)
if [[ ${ty} != "" ]]; then
break
fi
count=$((count + 1))
sleep 1
if [[ ${count} -ge 100 ]]; then
echo "chain33 query tx for too long"
break
fi
done
set -x
ty=$(${CLI} tx query -s "${2}" | jq .receipt.ty)
if [[ ${ty} != 2 ]]; then
echo -e "${RED}check tx error, hash is ${2}${NOC}"
exit_test
fi
}
# 检查地址是否匹配 $1返回结果 $2匹配地址
function check_addr() {
if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong check number parameters${NOC}"
exit_test
fi
addr=$(echo "${1}" | jq -r ".acc.addr")
if [[ ${addr} != "${2}" ]]; then
echo -e "${RED}error addr, expect ${1}, get ${2}${NOC}"
exit_test
fi
}
# 判断结果 $1 和 $2 是否相等
function is_equal() {
set +x
if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong parameter${NOC}"
exit_test
fi
if [[ $1 != "$2" ]]; then
echo -e "${RED}$1 != ${2}${NOC}"
exit_test
fi
set -x
}
# 判断结果 $1 和 $2 是否不相等
function is_not_equal() {
set +x
if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong parameter${NOC}"
exit_test
fi
if [[ $1 == "$2" ]]; then
echo -e "${RED}$1 == ${2}${NOC}"
exit_test
fi
set -x
}
# import_key and transfer $1 key, $2 label, $3 addr, $4 transfer amount
function import_addr() {
local key="$1"
local label="$2"
local addr="$3"
# shellcheck disable=SC2154
result=$(${Chain33Cli} account import_key -k "${key}" -l "${label}")
check_addr "${result}" "${addr}"
if [ "$#" -eq 4 ]; then
# shellcheck disable=SC2154
hash=$(${Chain33Cli} send coins transfer -a "$4" -n test -t "${addr}" -k "${minerAddr}")
check_tx "${Chain33Cli}" "${hash}"
fi
}
function InitChain33Account() {
# shellcheck disable=SC2154
{
import_addr "${propKey}" "prop" "${propAddr}" 1000
import_addr "${votePrKey2}" "vote2" "${voteAddr2}" 100
import_addr "${votePrKey3}" "vote3" "${voteAddr3}" 100
import_addr "${changeKey}" "changeTest" "${changeAddr}" 10
}
autonomyAddr=$(${Chain33Cli} exec addr -e autonomy)
hash=$(${Chain33Cli} send coins transfer -a 900 -n test -t "${autonomyAddr}" -k "${propKey}")
check_tx "${Chain33Cli}" "${hash}"
local count=0
# shellcheck disable=SC2154
# shellcheck disable=SC2068
for key in ${arrayKey[@]}; do
import_addr "${key}" "board${count}" "${arrayAddr[count]}" 100
count=$((count + 1))
done
}
#!/usr/bin/env bash
# shellcheck disable=SC2128
# shellcheck source=/dev/null
source "./autonomyTest.sh"
function autonomy() {
if [ "${2}" == "test" ]; then
echo "========================== autonomy test =========================="
set +e
set -x
mainTest
echo "========================== autonomy test end =========================="
fi
}
This diff is collapsed.
...@@ -88,7 +88,7 @@ func addProposalBoardFlags(cmd *cobra.Command) { ...@@ -88,7 +88,7 @@ func addProposalBoardFlags(cmd *cobra.Command) {
cmd.Flags().Int32P("month", "m", 0, "month") cmd.Flags().Int32P("month", "m", 0, "month")
cmd.Flags().Int32P("day", "d", 0, "day") cmd.Flags().Int32P("day", "d", 0, "day")
cmd.Flags().BoolP("update", "u", false, "replace or update boards, default is replace(false); update(true)") cmd.Flags().Int32P("update", "u", 1, "addr delete or replace boards, 1:add, 2:delete, 3:replace all, default is 1")
cmd.Flags().Int64P("startBlock", "s", 0, "start block height") cmd.Flags().Int64P("startBlock", "s", 0, "start block height")
cmd.MarkFlagRequired("startBlock") cmd.MarkFlagRequired("startBlock")
cmd.Flags().Int64P("endBlock", "e", 0, "end block height") cmd.Flags().Int64P("endBlock", "e", 0, "end block height")
...@@ -106,7 +106,7 @@ func proposalBoard(cmd *cobra.Command, args []string) { ...@@ -106,7 +106,7 @@ func proposalBoard(cmd *cobra.Command, args []string) {
month, _ := cmd.Flags().GetInt32("month") month, _ := cmd.Flags().GetInt32("month")
day, _ := cmd.Flags().GetInt32("day") day, _ := cmd.Flags().GetInt32("day")
update, _ := cmd.Flags().GetBool("update") update, _ := cmd.Flags().GetInt32("update")
startBlock, _ := cmd.Flags().GetInt64("startBlock") startBlock, _ := cmd.Flags().GetInt64("startBlock")
endBlock, _ := cmd.Flags().GetInt64("endBlock") endBlock, _ := cmd.Flags().GetInt64("endBlock")
boardstr, _ := cmd.Flags().GetString("boards") boardstr, _ := cmd.Flags().GetString("boards")
...@@ -117,7 +117,7 @@ func proposalBoard(cmd *cobra.Command, args []string) { ...@@ -117,7 +117,7 @@ func proposalBoard(cmd *cobra.Command, args []string) {
Year: year, Year: year,
Month: month, Month: month,
Day: day, Day: day,
Update: update, BoardUpdate: auty.BoardUpdate(update),
Boards: boards, Boards: boards,
StartBlockHeight: startBlock, StartBlockHeight: startBlock,
EndBlockHeight: endBlock, EndBlockHeight: endBlock,
...@@ -191,7 +191,8 @@ func VoteProposalBoardCmd() *cobra.Command { ...@@ -191,7 +191,8 @@ func VoteProposalBoardCmd() *cobra.Command {
func addVoteProposalBoardFlags(cmd *cobra.Command) { func addVoteProposalBoardFlags(cmd *cobra.Command) {
cmd.Flags().StringP("proposalID", "p", "", "proposal ID") cmd.Flags().StringP("proposalID", "p", "", "proposal ID")
cmd.MarkFlagRequired("proposalID") cmd.MarkFlagRequired("proposalID")
cmd.Flags().Int32P("approve", "r", 1, "is approve, default true")
cmd.Flags().Int32P("approve", "r", 1, "1:approve, 2:oppose, 3:quit, default 1")
cmd.Flags().StringP("originAddr", "o", "", "origin address: addr1-addr2......addrN") cmd.Flags().StringP("originAddr", "o", "", "origin address: addr1-addr2......addrN")
} }
...@@ -203,12 +204,6 @@ func voteProposalBoard(cmd *cobra.Command, args []string) { ...@@ -203,12 +204,6 @@ func voteProposalBoard(cmd *cobra.Command, args []string) {
approve, _ := cmd.Flags().GetInt32("approve") approve, _ := cmd.Flags().GetInt32("approve")
originAddr, _ := cmd.Flags().GetString("originAddr") originAddr, _ := cmd.Flags().GetString("originAddr")
var isapp bool
if approve == 0 {
isapp = false
} else {
isapp = true
}
var originAddrs []string var originAddrs []string
if len(originAddr) > 0 { if len(originAddr) > 0 {
originAddrs = strings.Split(originAddr, "-") originAddrs = strings.Split(originAddr, "-")
...@@ -216,8 +211,8 @@ func voteProposalBoard(cmd *cobra.Command, args []string) { ...@@ -216,8 +211,8 @@ func voteProposalBoard(cmd *cobra.Command, args []string) {
params := &auty.VoteProposalBoard{ params := &auty.VoteProposalBoard{
ProposalID: ID, ProposalID: ID,
Approve: isapp,
OriginAddr: originAddrs, OriginAddr: originAddrs,
VoteOption: auty.AutonomyVoteOption(approve),
} }
payLoad, err := json.Marshal(params) payLoad, err := json.Marshal(params)
if err != nil { if err != nil {
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
package commands package commands
import ( import (
"strings"
"encoding/json" "encoding/json"
jsonrpc "github.com/33cn/chain33/rpc/jsonclient" jsonrpc "github.com/33cn/chain33/rpc/jsonclient"
...@@ -36,8 +34,8 @@ func addProposalChangeFlags(cmd *cobra.Command) { ...@@ -36,8 +34,8 @@ func addProposalChangeFlags(cmd *cobra.Command) {
cmd.Flags().Int64P("endBlock", "e", 0, "end block height") cmd.Flags().Int64P("endBlock", "e", 0, "end block height")
cmd.MarkFlagRequired("endBlock") cmd.MarkFlagRequired("endBlock")
cmd.Flags().StringP("changes", "c", "", "addr1-true*addr2-false*addr3-true*......*addrN-false (1<=N<20)") cmd.Flags().StringP("change", "c", "", "addr")
cmd.MarkFlagRequired("changes") cmd.MarkFlagRequired("change")
} }
func proposalChange(cmd *cobra.Command, args []string) { func proposalChange(cmd *cobra.Command, args []string) {
...@@ -49,29 +47,12 @@ func proposalChange(cmd *cobra.Command, args []string) { ...@@ -49,29 +47,12 @@ func proposalChange(cmd *cobra.Command, args []string) {
startBlock, _ := cmd.Flags().GetInt64("startBlock") startBlock, _ := cmd.Flags().GetInt64("startBlock")
endBlock, _ := cmd.Flags().GetInt64("endBlock") endBlock, _ := cmd.Flags().GetInt64("endBlock")
changestr, _ := cmd.Flags().GetString("changes") changeAddrstr, _ := cmd.Flags().GetString("change")
changeStr := strings.Split(changestr, "*")
var changes []*auty.Change var changes []*auty.Change
for _, chStr := range changeStr { change := &auty.Change{Cancel: true, Addr: changeAddrstr}
per := strings.Split(chStr, "-") changes = append(changes, change)
if len(per) == 2 {
if per[1] == "true" {
change := &auty.Change{
Cancel: true,
Addr: per[0],
}
changes = append(changes, change)
} else if per[1] == "false" {
change := &auty.Change{
Cancel: false,
Addr: per[0],
}
changes = append(changes, change)
}
}
}
params := &auty.ProposalChange{ params := &auty.ProposalChange{
Year: year, Year: year,
Month: month, Month: month,
...@@ -148,7 +129,7 @@ func VoteProposalChangeCmd() *cobra.Command { ...@@ -148,7 +129,7 @@ func VoteProposalChangeCmd() *cobra.Command {
func addVoteProposalChangeFlags(cmd *cobra.Command) { func addVoteProposalChangeFlags(cmd *cobra.Command) {
cmd.Flags().StringP("proposalID", "p", "", "proposal ID") cmd.Flags().StringP("proposalID", "p", "", "proposal ID")
cmd.MarkFlagRequired("proposalID") cmd.MarkFlagRequired("proposalID")
cmd.Flags().Int32P("approve", "r", 1, "is approve, default true") cmd.Flags().Int32P("approve", "r", 1, "1:approve, 2:oppose, 3:quit, default 1")
} }
func voteProposalChange(cmd *cobra.Command, args []string) { func voteProposalChange(cmd *cobra.Command, args []string) {
...@@ -157,16 +138,9 @@ func voteProposalChange(cmd *cobra.Command, args []string) { ...@@ -157,16 +138,9 @@ func voteProposalChange(cmd *cobra.Command, args []string) {
ID, _ := cmd.Flags().GetString("proposalID") ID, _ := cmd.Flags().GetString("proposalID")
approve, _ := cmd.Flags().GetInt32("approve") approve, _ := cmd.Flags().GetInt32("approve")
var isapp bool
if approve == 0 {
isapp = false
} else {
isapp = true
}
params := &auty.VoteProposalChange{ params := &auty.VoteProposalChange{
ProposalID: ID, ProposalID: ID,
Approve: isapp, Vote: auty.AutonomyVoteOption(approve),
} }
payLoad, err := json.Marshal(params) payLoad, err := json.Marshal(params)
if err != nil { if err != nil {
......
...@@ -54,7 +54,6 @@ func addProposalProjectFlags(cmd *cobra.Command) { ...@@ -54,7 +54,6 @@ func addProposalProjectFlags(cmd *cobra.Command) {
cmd.Flags().Int64P("endBlock", "e", 0, "end block height") cmd.Flags().Int64P("endBlock", "e", 0, "end block height")
cmd.MarkFlagRequired("endBlock") cmd.MarkFlagRequired("endBlock")
cmd.Flags().Int32P("projectNeedBlockNum", "n", 0, "project complete need time(unit is block number)") cmd.Flags().Int32P("projectNeedBlockNum", "n", 0, "project complete need time(unit is block number)")
cmd.MarkFlagRequired("projectNeedBlockNum")
} }
func proposalProject(cmd *cobra.Command, args []string) { func proposalProject(cmd *cobra.Command, args []string) {
...@@ -171,7 +170,7 @@ func VoteProposalProjectCmd() *cobra.Command { ...@@ -171,7 +170,7 @@ func VoteProposalProjectCmd() *cobra.Command {
func addVoteProposalProjectFlags(cmd *cobra.Command) { func addVoteProposalProjectFlags(cmd *cobra.Command) {
cmd.Flags().StringP("proposalID", "p", "", "proposal ID") cmd.Flags().StringP("proposalID", "p", "", "proposal ID")
cmd.MarkFlagRequired("proposalID") cmd.MarkFlagRequired("proposalID")
cmd.Flags().Int32P("approve", "r", 1, "is approve, default true") cmd.Flags().Int32P("approve", "r", 1, "1:approve, 2:oppose, 3:quit, default 1")
} }
func voteProposalProject(cmd *cobra.Command, args []string) { func voteProposalProject(cmd *cobra.Command, args []string) {
...@@ -180,16 +179,10 @@ func voteProposalProject(cmd *cobra.Command, args []string) { ...@@ -180,16 +179,10 @@ func voteProposalProject(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
ID, _ := cmd.Flags().GetString("proposalID") ID, _ := cmd.Flags().GetString("proposalID")
approve, _ := cmd.Flags().GetInt32("approve") approve, _ := cmd.Flags().GetInt32("approve")
var isapp bool
if approve == 0 {
isapp = false
} else {
isapp = true
}
params := &auty.VoteProposalProject{ params := &auty.VoteProposalProject{
ProposalID: ID, ProposalID: ID,
Approve: isapp, Vote: auty.AutonomyVoteOption(approve),
} }
payLoad, err := json.Marshal(params) payLoad, err := json.Marshal(params)
if err != nil { if err != nil {
......
...@@ -47,6 +47,8 @@ func addProposalRuleFlags(cmd *cobra.Command) { ...@@ -47,6 +47,8 @@ func addProposalRuleFlags(cmd *cobra.Command) {
cmd.Flags().Int64P("proposalAmount", "p", 0, "proposal cost amount") cmd.Flags().Int64P("proposalAmount", "p", 0, "proposal cost amount")
cmd.Flags().Int64P("largeProjectAmount", "l", 0, "large project amount threshold") cmd.Flags().Int64P("largeProjectAmount", "l", 0, "large project amount threshold")
cmd.Flags().Int32P("publicPeriod", "u", 0, "public time") cmd.Flags().Int32P("publicPeriod", "u", 0, "public time")
cmd.Flags().Int32P("pubAttendRatio", "a", 0, "public attend ratio(unit is %)")
cmd.Flags().Int32P("pubApproveRatio", "v", 0, "public approve ratio(unit is %)")
} }
func proposalRule(cmd *cobra.Command, args []string) { func proposalRule(cmd *cobra.Command, args []string) {
...@@ -65,6 +67,8 @@ func proposalRule(cmd *cobra.Command, args []string) { ...@@ -65,6 +67,8 @@ func proposalRule(cmd *cobra.Command, args []string) {
proposalAmount, _ := cmd.Flags().GetInt64("proposalAmount") proposalAmount, _ := cmd.Flags().GetInt64("proposalAmount")
largeProjectAmount, _ := cmd.Flags().GetInt64("largeProjectAmount") largeProjectAmount, _ := cmd.Flags().GetInt64("largeProjectAmount")
publicPeriod, _ := cmd.Flags().GetInt32("publicPeriod") publicPeriod, _ := cmd.Flags().GetInt32("publicPeriod")
pubAttendRatio, _ := cmd.Flags().GetInt32("pubAttendRatio")
pubApproveRatio, _ := cmd.Flags().GetInt32("pubApproveRatio")
cfg, err := commandtypes.GetChainConfig(rpcLaddr) cfg, err := commandtypes.GetChainConfig(rpcLaddr)
if err != nil { if err != nil {
...@@ -82,6 +86,8 @@ func proposalRule(cmd *cobra.Command, args []string) { ...@@ -82,6 +86,8 @@ func proposalRule(cmd *cobra.Command, args []string) {
ProposalAmount: proposalAmount * cfg.CoinPrecision, ProposalAmount: proposalAmount * cfg.CoinPrecision,
LargeProjectAmount: largeProjectAmount * cfg.CoinPrecision, LargeProjectAmount: largeProjectAmount * cfg.CoinPrecision,
PublicPeriod: publicPeriod, PublicPeriod: publicPeriod,
PubAttendRatio: pubAttendRatio,
PubApproveRatio: pubApproveRatio,
}, },
StartBlockHeight: startBlock, StartBlockHeight: startBlock,
EndBlockHeight: endBlock, EndBlockHeight: endBlock,
...@@ -154,7 +160,7 @@ func VoteProposalRuleCmd() *cobra.Command { ...@@ -154,7 +160,7 @@ func VoteProposalRuleCmd() *cobra.Command {
func addVoteProposalRuleFlags(cmd *cobra.Command) { func addVoteProposalRuleFlags(cmd *cobra.Command) {
cmd.Flags().StringP("proposalID", "p", "", "proposal ID") cmd.Flags().StringP("proposalID", "p", "", "proposal ID")
cmd.MarkFlagRequired("proposalID") cmd.MarkFlagRequired("proposalID")
cmd.Flags().Int32P("approve", "r", 1, "is approve, default true") cmd.Flags().Int32P("approve", "r", 1, "1:approve, 2:oppose, 3:quit, default 1")
cmd.Flags().StringP("originAddr", "o", "", "origin address: addr1-addr2......addrN") cmd.Flags().StringP("originAddr", "o", "", "origin address: addr1-addr2......addrN")
} }
...@@ -165,12 +171,6 @@ func voteProposalRule(cmd *cobra.Command, args []string) { ...@@ -165,12 +171,6 @@ func voteProposalRule(cmd *cobra.Command, args []string) {
ID, _ := cmd.Flags().GetString("proposalID") ID, _ := cmd.Flags().GetString("proposalID")
approve, _ := cmd.Flags().GetInt32("approve") approve, _ := cmd.Flags().GetInt32("approve")
originAddr, _ := cmd.Flags().GetString("originAddr") originAddr, _ := cmd.Flags().GetString("originAddr")
var isapp bool
if approve == 0 {
isapp = false
} else {
isapp = true
}
var originAddrs []string var originAddrs []string
if len(originAddr) > 0 { if len(originAddr) > 0 {
...@@ -179,8 +179,8 @@ func voteProposalRule(cmd *cobra.Command, args []string) { ...@@ -179,8 +179,8 @@ func voteProposalRule(cmd *cobra.Command, args []string) {
params := &auty.VoteProposalRule{ params := &auty.VoteProposalRule{
ProposalID: ID, ProposalID: ID,
Approve: isapp,
OriginAddr: originAddrs, OriginAddr: originAddrs,
Vote: auty.AutonomyVoteOption(approve),
} }
payLoad, err := json.Marshal(params) payLoad, err := json.Marshal(params)
if err != nil { if err != nil {
......
...@@ -15,6 +15,7 @@ import ( ...@@ -15,6 +15,7 @@ import (
type subConfig struct { type subConfig struct {
Total string `json:"total"` Total string `json:"total"`
UseBalance bool `json:"useBalance"` UseBalance bool `json:"useBalance"`
Execer string `json:"execer"`
} }
var ( var (
......
...@@ -407,7 +407,6 @@ func checkExecLocalBoard(t *testing.T, kvdb db.KVDB, cur *auty.AutonomyProposalB ...@@ -407,7 +407,6 @@ func checkExecLocalBoard(t *testing.T, kvdb db.KVDB, cur *auty.AutonomyProposalB
assert.Equal(t, prop.Address, cur.Address) assert.Equal(t, prop.Address, cur.Address)
assert.Equal(t, prop.Height, cur.Height) assert.Equal(t, prop.Height, cur.Height)
assert.Equal(t, prop.Index, cur.Index) assert.Equal(t, prop.Index, cur.Index)
} }
func saveKvs(sdb db.DB, kvs []*types.KeyValue) { func saveKvs(sdb db.DB, kvs []*types.KeyValue) {
......
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
auty "github.com/33cn/plugin/plugin/dapp/autonomy/types" auty "github.com/33cn/plugin/plugin/dapp/autonomy/types"
ticket "github.com/33cn/plugin/plugin/dapp/ticket/executor" ticket "github.com/33cn/plugin/plugin/dapp/ticket/executor"
ticketTy "github.com/33cn/plugin/plugin/dapp/ticket/types" ticketTy "github.com/33cn/plugin/plugin/dapp/ticket/types"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
) )
...@@ -195,57 +196,96 @@ func TestPropBoard(t *testing.T) { ...@@ -195,57 +196,96 @@ func TestPropBoard(t *testing.T) {
opts := []*auty.ProposalBoard{ opts := []*auty.ProposalBoard{
{ // ErrRepeatAddr { // ErrRepeatAddr
Update: true, BoardUpdate: auty.BoardUpdate_ADDBoard,
Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", "18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"}, Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", "18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"},
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // ErrRepeatAddr { // ErrRepeatAddr
Update: true, BoardUpdate: auty.BoardUpdate_ADDBoard,
Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", AddrA}, Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", AddrA},
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // ErrBoardNumber { // ErrBoardNumber
Update: true, BoardUpdate: auty.BoardUpdate_ADDBoard,
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // 正常 { // 正常
Update: true, BoardUpdate: auty.BoardUpdate_ADDBoard,
Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"}, Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"},
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // ErrRepeatAddr { // ErrRepeatAddr
Update: false, BoardUpdate: auty.BoardUpdate_REPLACEALL,
Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", "18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"}, Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", "18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"},
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // ErrBoardNumber { // ErrBoardNumber
Update: false, BoardUpdate: auty.BoardUpdate_REPLACEALL,
Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", AddrA}, Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", AddrA},
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // 正常 { // 正常
Update: false, BoardUpdate: auty.BoardUpdate_REPLACEALL,
Boards: boards, Boards: boards,
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // ErrNotFound
BoardUpdate: auty.BoardUpdate_DELBoard,
Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"},
StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
},
{ // ErrNotFound
BoardUpdate: auty.BoardUpdate_DELBoard,
Boards: []string{Addr17, "18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"},
StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
},
{ // ErrBoardNumber
BoardUpdate: auty.BoardUpdate_DELBoard,
Boards: []string{Addr16, Addr17},
StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
},
{ // ErrRepeatAddr
BoardUpdate: auty.BoardUpdate_DELBoard,
Boards: []string{Addr17, Addr17},
StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
},
{ // 正常
BoardUpdate: auty.BoardUpdate_DELBoard,
Boards: []string{Addr17},
StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
},
} }
result := []error{ result := []error{
auty.ErrRepeatAddr, auty.ErrRepeatAddr,
auty.ErrRepeatAddr, auty.ErrRepeatAddr,
auty.ErrBoardNumber, auty.ErrBoardNumber,
nil, nil,
auty.ErrRepeatAddr, auty.ErrRepeatAddr,
auty.ErrBoardNumber, auty.ErrBoardNumber,
nil, nil,
types.ErrNotFound,
types.ErrNotFound,
auty.ErrBoardNumber,
auty.ErrRepeatAddr,
nil,
} }
lenBoards := []int{0, 0, 0, 22, 0, 0, 21, 0, 0, 0, 0, 20}
InitBoard(stateDB) InitBoard(stateDB)
exec.SetStateDB(stateDB) exec.SetStateDB(stateDB)
...@@ -255,8 +295,14 @@ func TestPropBoard(t *testing.T) { ...@@ -255,8 +295,14 @@ func TestPropBoard(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
pbtx, err = signTx(pbtx, PrivKeyA) pbtx, err = signTx(pbtx, PrivKeyA)
assert.NoError(t, err) assert.NoError(t, err)
_, err = exec.Exec(pbtx, i) receipt, err := exec.Exec(pbtx, i)
assert.Equal(t, err, result[i]) assert.Equal(t, errors.Cause(err), result[i])
if receipt != nil {
var stat auty.AutonomyProposalBoard
err := types.Decode(receipt.KV[1].Value, &stat)
assert.NoError(t, err)
assert.Equal(t, len(stat.Board.Boards), lenBoards[i])
}
} }
} }
...@@ -290,6 +336,7 @@ func testPropBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm. ...@@ -290,6 +336,7 @@ func testPropBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.
Month: 7, Month: 7,
Day: 10, Day: 10,
Boards: boards, Boards: boards,
BoardUpdate: auty.BoardUpdate_REPLACEALL,
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
} }
...@@ -423,19 +470,19 @@ func voteProposalBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB ...@@ -423,19 +470,19 @@ func voteProposalBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB
// 4人参与投票,3人赞成票,1人反对票 // 4人参与投票,3人赞成票,1人反对票
type record struct { type record struct {
priv string priv string
appr bool vote auty.AutonomyVoteOption
origin []string origin []string
} }
records := []record{ records := []record{
{priv: PrivKeyA, appr: false}, {priv: PrivKeyA, vote: auty.AutonomyVoteOption_OPPOSE},
{priv: PrivKey1, appr: true, origin: []string{AddrB, AddrC, AddrD}}, {priv: PrivKey1, vote: auty.AutonomyVoteOption_APPROVE, origin: []string{AddrB, AddrC, AddrD}},
} }
InitMinerAddr(stateDB, []string{AddrB, AddrC, AddrD}, Addr1) InitMinerAddr(stateDB, []string{AddrB, AddrC, AddrD}, Addr1)
for i, record := range records { for i, record := range records {
opt := &auty.VoteProposalBoard{ opt := &auty.VoteProposalBoard{
ProposalID: proposalID, ProposalID: proposalID,
Approve: record.appr, VoteOption: record.vote,
OriginAddr: record.origin, OriginAddr: record.origin,
} }
tx, err := voteProposalBoardTx(opt) tx, err := voteProposalBoardTx(opt)
......
...@@ -27,11 +27,11 @@ var boardOpt = &table.Option{ ...@@ -27,11 +27,11 @@ var boardOpt = &table.Option{
//NewBoardTable 新建表 //NewBoardTable 新建表
func NewBoardTable(kvdb db.KV) *table.Table { func NewBoardTable(kvdb db.KV) *table.Table {
rowmeta := NewBoardRow() rowmeta := NewBoardRow()
table, err := table.NewTable(rowmeta, kvdb, boardOpt) newTable, err := table.NewTable(rowmeta, kvdb, boardOpt)
if err != nil { if err != nil {
panic(err) panic(err)
} }
return table return newTable
} }
//BoardRow table meta 结构 //BoardRow table meta 结构
......
...@@ -8,8 +8,10 @@ import ( ...@@ -8,8 +8,10 @@ import (
"sort" "sort"
"github.com/33cn/chain33/common" "github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
auty "github.com/33cn/plugin/plugin/dapp/autonomy/types" auty "github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/pkg/errors"
) )
func (a *action) propChange(prob *auty.ProposalChange) (*types.Receipt, error) { func (a *action) propChange(prob *auty.ProposalChange) (*types.Receipt, error) {
...@@ -30,11 +32,21 @@ func (a *action) propChange(prob *auty.ProposalChange) (*types.Receipt, error) { ...@@ -30,11 +32,21 @@ func (a *action) propChange(prob *auty.ProposalChange) (*types.Receipt, error) {
alog.Error("propChange ", "addr", a.fromaddr, "execaddr", a.execaddr, "getActiveBoard failed", err) alog.Error("propChange ", "addr", a.fromaddr, "execaddr", a.execaddr, "getActiveBoard failed", err)
return nil, err return nil, err
} }
// 检查是否符合提案修改 // 检查是否符合提案修改
new, err := a.checkChangeable(act, prob.Changes) var newBoard *auty.ActiveBoard
if err != nil { if a.api.GetConfig().IsDappFork(a.height, auty.AutonomyX, auty.ForkAutonomyDelRule) {
alog.Error("propChange ", "addr", a.fromaddr, "execaddr", a.execaddr, "checkChangeable failed", err) //替换成员方案
return nil, err newBoard, err = a.replaceBoard(act, prob.Changes)
if err != nil {
return nil, err
}
} else {
newBoard, err = a.checkChangeable(act, prob.Changes)
if err != nil {
alog.Error("propChange ", "addr", a.fromaddr, "execaddr", a.execaddr, "checkChangeable failed", err)
return nil, err
}
} }
// 获取当前生效提案规则,并且将不修改的规则补齐 // 获取当前生效提案规则,并且将不修改的规则补齐
...@@ -59,7 +71,7 @@ func (a *action) propChange(prob *auty.ProposalChange) (*types.Receipt, error) { ...@@ -59,7 +71,7 @@ func (a *action) propChange(prob *auty.ProposalChange) (*types.Receipt, error) {
cur := &auty.AutonomyProposalChange{ cur := &auty.AutonomyProposalChange{
PropChange: prob, PropChange: prob,
CurRule: rule, CurRule: rule,
Board: new, Board: newBoard,
VoteResult: &auty.VoteResult{TotalVotes: int32(len(act.Boards))}, VoteResult: &auty.VoteResult{TotalVotes: int32(len(act.Boards))},
Status: auty.AutonomyStatusProposalChange, Status: auty.AutonomyStatusProposalChange,
Address: a.fromaddr, Address: a.fromaddr,
...@@ -151,8 +163,8 @@ func (a *action) votePropChange(voteProb *auty.VoteProposalChange) (*types.Recei ...@@ -151,8 +163,8 @@ func (a *action) votePropChange(voteProb *auty.VoteProposalChange) (*types.Recei
start := cur.GetPropChange().StartBlockHeight start := cur.GetPropChange().StartBlockHeight
end := cur.GetPropChange().EndBlockHeight end := cur.GetPropChange().EndBlockHeight
real := cur.GetPropChange().RealEndBlockHeight realHeight := cur.GetPropChange().RealEndBlockHeight
if a.height < start || a.height > end || real != 0 { if a.height < start || a.height > end || realHeight != 0 {
err := auty.ErrVotePeriod err := auty.ErrVotePeriod
alog.Error("votePropChange ", "addr", a.fromaddr, "execaddr", a.execaddr, "ProposalID", alog.Error("votePropChange ", "addr", a.fromaddr, "execaddr", a.execaddr, "ProposalID",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
...@@ -167,20 +179,32 @@ func (a *action) votePropChange(voteProb *auty.VoteProposalChange) (*types.Recei ...@@ -167,20 +179,32 @@ func (a *action) votePropChange(voteProb *auty.VoteProposalChange) (*types.Recei
return nil, err return nil, err
} }
// 董事会成员验证 cfg := a.api.GetConfig()
// 董事会成员验证,把剔除的原成员放回来
mpBd := make(map[string]struct{}) mpBd := make(map[string]struct{})
for _, b := range cur.Board.Boards { if cfg.IsDappFork(a.height, auty.AutonomyX, auty.ForkAutonomyDelRule) {
mpBd[b] = struct{}{} for _, b := range cur.Board.Boards {
} if b == cur.PropChange.Changes[0].Addr {
for _, ch := range cur.PropChange.Changes { mpBd[cur.Address] = struct{}{}
if ch.Cancel { continue
mpBd[ch.Addr] = struct{}{} }
} else { mpBd[b] = struct{}{}
if _, ok := mpBd[ch.Addr]; ok { }
delete(mpBd, ch.Addr) } else {
for _, b := range cur.Board.Boards {
mpBd[b] = struct{}{}
}
for _, ch := range cur.PropChange.Changes {
if ch.Cancel {
mpBd[ch.Addr] = struct{}{}
} else {
if _, ok := mpBd[ch.Addr]; ok {
delete(mpBd, ch.Addr)
}
} }
} }
} }
if _, ok := mpBd[a.fromaddr]; !ok { if _, ok := mpBd[a.fromaddr]; !ok {
err = auty.ErrNoActiveBoard err = auty.ErrNoActiveBoard
alog.Error("votePropChange ", "addr", a.fromaddr, "this addr is not active board member", alog.Error("votePropChange ", "addr", a.fromaddr, "this addr is not active board member",
...@@ -191,10 +215,23 @@ func (a *action) votePropChange(voteProb *auty.VoteProposalChange) (*types.Recei ...@@ -191,10 +215,23 @@ func (a *action) votePropChange(voteProb *auty.VoteProposalChange) (*types.Recei
// 更新投票记录 // 更新投票记录
votes.Address = append(votes.Address, a.fromaddr) votes.Address = append(votes.Address, a.fromaddr)
if voteProb.Approve { if cfg.IsDappFork(a.height, auty.AutonomyX, auty.ForkAutonomyDelRule) {
cur.VoteResult.ApproveVotes++ switch voteProb.Vote {
case auty.AutonomyVoteOption_APPROVE:
cur.VoteResult.ApproveVotes++
case auty.AutonomyVoteOption_OPPOSE:
cur.VoteResult.OpposeVotes++
case auty.AutonomyVoteOption_QUIT:
cur.VoteResult.QuitVotes++
default:
return nil, errors.Wrapf(types.ErrInvalidParam, "vote option=%d", voteProb.Vote)
}
} else { } else {
cur.VoteResult.OpposeVotes++ if voteProb.Approve {
cur.VoteResult.ApproveVotes++
} else {
cur.VoteResult.OpposeVotes++
}
} }
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
...@@ -319,6 +356,56 @@ func (a *action) getProposalChange(ID string) (*auty.AutonomyProposalChange, err ...@@ -319,6 +356,56 @@ func (a *action) getProposalChange(ID string) (*auty.AutonomyProposalChange, err
return cur, nil return cur, nil
} }
//新的方案只允许替换board里面的成员,而且是本用户申请,不允许从revBoard恢复
func (a *action) replaceBoard(act *auty.ActiveBoard, change []*auty.Change) (*auty.ActiveBoard, error) {
//一个成员只允许替换一个新的
if len(change) > 1 {
return nil, errors.Wrapf(types.ErrInvalidParam, "only allow one addr to be replaced,change=%d", len(change))
}
//只允许替换,不允许恢复操作
if !change[0].Cancel || len(change[0].Addr) <= 0 {
return nil, errors.Wrapf(types.ErrInvalidParam, "cancel=false not allow to addr=%s", change[0].Addr)
}
if err := address.CheckAddress(change[0].Addr); err != nil {
return nil, err
}
mpBd := make(map[string]struct{})
mpRbd := make(map[string]struct{})
for _, b := range act.Boards {
mpBd[b] = struct{}{}
}
for _, b := range act.Revboards {
mpRbd[b] = struct{}{}
}
//发起者必须是董事会成员
if _, ok := mpBd[a.fromaddr]; !ok {
return nil, errors.Wrap(types.ErrNotAllow, "from addr should be in boards")
}
//待替换地址不能在board和revBoard里面
if _, ok := mpBd[change[0].Addr]; ok {
return nil, errors.Wrapf(types.ErrNotAllow, "new addr=%s in boards", change[0].Addr)
}
if _, ok := mpRbd[change[0].Addr]; ok {
return nil, errors.Wrapf(types.ErrNotAllow, "new addr=%s in rev boards", change[0].Addr)
}
//替换board
for i, k := range act.Boards {
if k == a.fromaddr {
act.Boards[i] = change[0].Addr
break
}
}
//当前地址追加到revBoards
act.Revboards = append(act.Revboards, a.fromaddr)
return act, nil
}
func (a *action) checkChangeable(act *auty.ActiveBoard, change []*auty.Change) (*auty.ActiveBoard, error) { func (a *action) checkChangeable(act *auty.ActiveBoard, change []*auty.Change) (*auty.ActiveBoard, error) {
mpBd := make(map[string]struct{}) mpBd := make(map[string]struct{})
mpRbd := make(map[string]struct{}) mpRbd := make(map[string]struct{})
...@@ -348,19 +435,19 @@ func (a *action) checkChangeable(act *auty.ActiveBoard, change []*auty.Change) ( ...@@ -348,19 +435,19 @@ func (a *action) checkChangeable(act *auty.ActiveBoard, change []*auty.Change) (
if len(mpBd) > maxBoards || len(mpBd) < minBoards { if len(mpBd) > maxBoards || len(mpBd) < minBoards {
return nil, auty.ErrBoardNumber return nil, auty.ErrBoardNumber
} }
new := &auty.ActiveBoard{ newBoard := &auty.ActiveBoard{
Amount: act.Amount, Amount: act.Amount,
StartHeight: act.StartHeight, StartHeight: act.StartHeight,
} }
for k := range mpBd { for k := range mpBd {
new.Boards = append(new.Boards, k) newBoard.Boards = append(newBoard.Boards, k)
} }
sort.Strings(new.Boards) sort.Strings(newBoard.Boards)
for k := range mpRbd { for k := range mpRbd {
new.Revboards = append(new.Revboards, k) newBoard.Revboards = append(newBoard.Revboards, k)
} }
sort.Strings(new.Revboards) sort.Strings(newBoard.Revboards)
return new, nil return newBoard, nil
} }
// getReceiptLog 根据提案信息获取log // getReceiptLog 根据提案信息获取log
......
...@@ -27,11 +27,11 @@ var changeOpt = &table.Option{ ...@@ -27,11 +27,11 @@ var changeOpt = &table.Option{
//NewChangeTable 新建表 //NewChangeTable 新建表
func NewChangeTable(kvdb db.KV) *table.Table { func NewChangeTable(kvdb db.KV) *table.Table {
rowmeta := NewChangeRow() rowmeta := NewChangeRow()
table, err := table.NewTable(rowmeta, kvdb, changeOpt) newTable, err := table.NewTable(rowmeta, kvdb, changeOpt)
if err != nil { if err != nil {
panic(err) panic(err)
} }
return table return newTable
} }
//ChangeRow table meta 结构 //ChangeRow table meta 结构
......
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"github.com/33cn/chain33/common" "github.com/33cn/chain33/common"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
auty "github.com/33cn/plugin/plugin/dapp/autonomy/types" auty "github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/pkg/errors"
"github.com/33cn/chain33/common/address" "github.com/33cn/chain33/common/address"
) )
...@@ -184,8 +185,8 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec ...@@ -184,8 +185,8 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
start := cur.GetPropProject().StartBlockHeight start := cur.GetPropProject().StartBlockHeight
end := cur.GetPropProject().EndBlockHeight end := cur.GetPropProject().EndBlockHeight
real := cur.GetPropProject().RealEndBlockHeight realHeight := cur.GetPropProject().RealEndBlockHeight
if a.height < start || a.height > end || real != 0 { if a.height < start || a.height > end || realHeight != 0 {
err := auty.ErrVotePeriod err := auty.ErrVotePeriod
alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "ProposalID", alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "ProposalID",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
...@@ -217,11 +218,25 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec ...@@ -217,11 +218,25 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
// 更新已经投票地址 // 更新已经投票地址
votes.Address = append(votes.Address, a.fromaddr) votes.Address = append(votes.Address, a.fromaddr)
// 更新投票结果 // 更新投票结果
if voteProb.Approve { if a.api.GetConfig().IsDappFork(a.height, auty.AutonomyX, auty.ForkAutonomyDelRule) {
cur.BoardVoteRes.ApproveVotes++ switch voteProb.Vote {
case auty.AutonomyVoteOption_APPROVE:
cur.BoardVoteRes.ApproveVotes++
case auty.AutonomyVoteOption_OPPOSE:
cur.BoardVoteRes.OpposeVotes++
case auty.AutonomyVoteOption_QUIT:
cur.BoardVoteRes.QuitVotes++
default:
return nil, errors.Wrapf(types.ErrInvalidParam, "vote option=%d", voteProb.Vote)
}
} else { } else {
cur.BoardVoteRes.OpposeVotes++ if voteProb.Approve {
cur.BoardVoteRes.ApproveVotes++
} else {
cur.BoardVoteRes.OpposeVotes++
}
} }
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
......
...@@ -27,11 +27,11 @@ var projectOpt = &table.Option{ ...@@ -27,11 +27,11 @@ var projectOpt = &table.Option{
//NewProjectTable 新建表 //NewProjectTable 新建表
func NewProjectTable(kvdb db.KV) *table.Table { func NewProjectTable(kvdb db.KV) *table.Table {
rowmeta := NewProjectRow() rowmeta := NewProjectRow()
table, err := table.NewTable(rowmeta, kvdb, projectOpt) newTable, err := table.NewTable(rowmeta, kvdb, projectOpt)
if err != nil { if err != nil {
panic(err) panic(err)
} }
return table return newTable
} }
//ProjectRow table meta 结构 //ProjectRow table meta 结构
......
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"github.com/33cn/chain33/common" "github.com/33cn/chain33/common"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
auty "github.com/33cn/plugin/plugin/dapp/autonomy/types" auty "github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/pkg/errors"
"github.com/33cn/chain33/common/address" "github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/system/dapp" "github.com/33cn/chain33/system/dapp"
...@@ -18,10 +19,24 @@ const ( ...@@ -18,10 +19,24 @@ const (
minBoardApproveRatio = 50 minBoardApproveRatio = 50
// 最大董事会赞成率 // 最大董事会赞成率
maxBoardApproveRatio = 66 maxBoardApproveRatio = 66
// 最小全体持票人否决率 // 最小全体持票人否决率
minPubOpposeRatio = 33 minPubOpposeRatio = 33
// 最大全体持票人否决率 // 最大全体持票人否决率
maxPubOpposeRatio = 50 maxPubOpposeRatio = 50
// 可以调整,但是可能需要进行范围的限制:参与率最低设置为 50%, 最高设置为 80%,赞成率,最低 50.1%,最高80% ??? 最低 50.1% ????
//不能设置太低和太高,太低就容易作弊,太高则有可能很难达到
// 最小全体持票人参与率
minPubAttendRatio = 50
// 最大全体持票人参与率
maxPubAttendRatio = 80
// 最小全体持票人赞成率
minPubApproveRatio = 50
// 最大全体持票人赞成率
maxPubApproveRatio = 80
// 最小公示周期 // 最小公示周期
minPublicPeriod int32 = 17280 * 7 minPublicPeriod int32 = 17280 * 7
// 最大公示周期 // 最大公示周期
...@@ -36,19 +51,27 @@ const ( ...@@ -36,19 +51,27 @@ const (
maxProposalAmount = 2000 maxProposalAmount = 2000
) )
func checkParaInvalid(param, min, max int64) bool {
if param > max || param < min {
return true
}
return false
}
func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) { func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) {
cfg := a.api.GetConfig() cfg := a.api.GetConfig()
//如果全小于等于0,则说明该提案规则参数不正确 //如果全小于等于0,则说明该提案规则参数不正确
if prob.RuleCfg == nil || prob.RuleCfg.BoardApproveRatio <= 0 && prob.RuleCfg.PubOpposeRatio <= 0 && if prob.RuleCfg == nil {
prob.RuleCfg.ProposalAmount <= 0 && prob.RuleCfg.LargeProjectAmount <= 0 && prob.RuleCfg.PublicPeriod <= 0 {
alog.Error("propRule ", "ProposalRule RuleCfg invaild or have no modify param", prob.RuleCfg) alog.Error("propRule ", "ProposalRule RuleCfg invaild or have no modify param", prob.RuleCfg)
return nil, types.ErrInvalidParam return nil, types.ErrInvalidParam
} }
if (prob.RuleCfg.BoardApproveRatio > 0 && (prob.RuleCfg.BoardApproveRatio > maxBoardApproveRatio || prob.RuleCfg.BoardApproveRatio < minBoardApproveRatio)) || if checkParaInvalid(int64(prob.RuleCfg.BoardApproveRatio), minBoardApproveRatio, maxBoardApproveRatio) ||
(prob.RuleCfg.PubOpposeRatio > 0 && (prob.RuleCfg.PubOpposeRatio > maxPubOpposeRatio || prob.RuleCfg.PubOpposeRatio < minPubOpposeRatio)) || checkParaInvalid(int64(prob.RuleCfg.PubOpposeRatio), minPubOpposeRatio, maxPubOpposeRatio) ||
(prob.RuleCfg.PublicPeriod > 0 && (prob.RuleCfg.PublicPeriod > maxPublicPeriod || prob.RuleCfg.PublicPeriod < minPublicPeriod)) || checkParaInvalid(int64(prob.RuleCfg.PublicPeriod), int64(minPublicPeriod), int64(maxPublicPeriod)) ||
(prob.RuleCfg.LargeProjectAmount > 0 && (prob.RuleCfg.LargeProjectAmount > maxLargeProjectAmount*cfg.GetCoinPrecision() || prob.RuleCfg.LargeProjectAmount < minLargeProjectAmount*cfg.GetCoinPrecision())) || checkParaInvalid(prob.RuleCfg.LargeProjectAmount, minLargeProjectAmount*cfg.GetCoinPrecision(), maxLargeProjectAmount*cfg.GetCoinPrecision()) ||
(prob.RuleCfg.ProposalAmount > 0 && (prob.RuleCfg.ProposalAmount > maxProposalAmount*cfg.GetCoinPrecision() || prob.RuleCfg.ProposalAmount < minProposalAmount*cfg.GetCoinPrecision())) { checkParaInvalid(prob.RuleCfg.ProposalAmount, minProposalAmount*cfg.GetCoinPrecision(), maxProposalAmount*cfg.GetCoinPrecision()) ||
checkParaInvalid(int64(prob.RuleCfg.PubAttendRatio), minPubAttendRatio, maxPubAttendRatio) ||
checkParaInvalid(int64(prob.RuleCfg.PubApproveRatio), minPubApproveRatio, maxPubApproveRatio) {
alog.Error("propRule RuleCfg invaild", "ruleCfg", prob.RuleCfg) alog.Error("propRule RuleCfg invaild", "ruleCfg", prob.RuleCfg)
return nil, types.ErrInvalidParam return nil, types.ErrInvalidParam
} }
...@@ -173,8 +196,8 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt, ...@@ -173,8 +196,8 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
start := cur.GetPropRule().StartBlockHeight start := cur.GetPropRule().StartBlockHeight
end := cur.GetPropRule().EndBlockHeight end := cur.GetPropRule().EndBlockHeight
real := cur.GetPropRule().RealEndBlockHeight realHeight := cur.GetPropRule().RealEndBlockHeight
if a.height < start || a.height > end || real != 0 { if a.height < start || a.height > end || realHeight != 0 {
err := auty.ErrVotePeriod err := auty.ErrVotePeriod
alog.Error("votePropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "ProposalID", alog.Error("votePropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "ProposalID",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
...@@ -230,10 +253,24 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt, ...@@ -230,10 +253,24 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
return nil, err return nil, err
} }
if voteProb.Approve { cfg := a.api.GetConfig()
cur.VoteResult.ApproveVotes += vtCouts if cfg.IsDappFork(a.height, auty.AutonomyX, auty.ForkAutonomyDelRule) {
switch voteProb.Vote {
case auty.AutonomyVoteOption_APPROVE:
cur.VoteResult.ApproveVotes += vtCouts
case auty.AutonomyVoteOption_OPPOSE:
cur.VoteResult.OpposeVotes += vtCouts
case auty.AutonomyVoteOption_QUIT:
cur.VoteResult.QuitVotes += vtCouts
default:
return nil, errors.Wrapf(types.ErrInvalidParam, "wrong vote value=%d", voteProb.Vote)
}
} else { } else {
cur.VoteResult.OpposeVotes += vtCouts if voteProb.Approve {
cur.VoteResult.ApproveVotes += vtCouts
} else {
cur.VoteResult.OpposeVotes += vtCouts
}
} }
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
...@@ -250,12 +287,20 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt, ...@@ -250,12 +287,20 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
kv = append(kv, receipt.KV...) kv = append(kv, receipt.KV...)
} }
if cur.VoteResult.TotalVotes != 0 && if cfg.IsDappFork(a.height, auty.AutonomyX, auty.ForkAutonomyDelRule) {
cur.VoteResult.ApproveVotes+cur.VoteResult.OpposeVotes != 0 && if isApproved(cur.VoteResult.TotalVotes, cur.VoteResult.ApproveVotes, cur.VoteResult.OpposeVotes, cur.VoteResult.QuitVotes,
float32(cur.VoteResult.ApproveVotes+cur.VoteResult.OpposeVotes)/float32(cur.VoteResult.TotalVotes) > float32(pubAttendRatio)/100.0 && cur.CurRule.PubAttendRatio, cur.CurRule.PubApproveRatio) {
float32(cur.VoteResult.ApproveVotes)/float32(cur.VoteResult.ApproveVotes+cur.VoteResult.OpposeVotes) > float32(pubApproveRatio)/100.0 { cur.VoteResult.Pass = true
cur.VoteResult.Pass = true cur.PropRule.RealEndBlockHeight = a.height
cur.PropRule.RealEndBlockHeight = a.height }
} else {
if cur.VoteResult.TotalVotes != 0 &&
cur.VoteResult.ApproveVotes+cur.VoteResult.OpposeVotes != 0 &&
float32(cur.VoteResult.ApproveVotes+cur.VoteResult.OpposeVotes)/float32(cur.VoteResult.TotalVotes) > float32(pubAttendRatio)/100.0 &&
float32(cur.VoteResult.ApproveVotes)/float32(cur.VoteResult.ApproveVotes+cur.VoteResult.OpposeVotes) > float32(pubApproveRatio)/100.0 {
cur.VoteResult.Pass = true
cur.PropRule.RealEndBlockHeight = a.height
}
} }
key := propRuleID(voteProb.ProposalID) key := propRuleID(voteProb.ProposalID)
...@@ -320,11 +365,16 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re ...@@ -320,11 +365,16 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re
cur.VoteResult.TotalVotes = vtCouts cur.VoteResult.TotalVotes = vtCouts
} }
if float32(cur.VoteResult.ApproveVotes+cur.VoteResult.OpposeVotes)/float32(cur.VoteResult.TotalVotes) > float32(pubAttendRatio)/100.0 && if a.api.GetConfig().IsDappFork(a.height, auty.AutonomyX, auty.ForkAutonomyDelRule) {
float32(cur.VoteResult.ApproveVotes)/float32(cur.VoteResult.ApproveVotes+cur.VoteResult.OpposeVotes) > float32(pubApproveRatio)/100.0 { cur.VoteResult.Pass = isApproved(cur.VoteResult.TotalVotes, cur.VoteResult.ApproveVotes, cur.VoteResult.OpposeVotes, cur.VoteResult.QuitVotes,
cur.VoteResult.Pass = true cur.CurRule.PubAttendRatio, cur.CurRule.PubApproveRatio)
} else { } else {
cur.VoteResult.Pass = false if float32(cur.VoteResult.ApproveVotes+cur.VoteResult.OpposeVotes)/float32(cur.VoteResult.TotalVotes) > float32(pubAttendRatio)/100.0 &&
float32(cur.VoteResult.ApproveVotes)/float32(cur.VoteResult.ApproveVotes+cur.VoteResult.OpposeVotes) > float32(pubApproveRatio)/100.0 {
cur.VoteResult.Pass = true
} else {
cur.VoteResult.Pass = false
}
} }
cur.PropRule.RealEndBlockHeight = a.height cur.PropRule.RealEndBlockHeight = a.height
...@@ -450,21 +500,28 @@ func upgradeRule(cur, modify *auty.RuleConfig) *auty.RuleConfig { ...@@ -450,21 +500,28 @@ func upgradeRule(cur, modify *auty.RuleConfig) *auty.RuleConfig {
if cur == nil || modify == nil { if cur == nil || modify == nil {
return nil return nil
} }
new := *cur newConfig := *cur
if modify.BoardApproveRatio > 0 { if modify.BoardApproveRatio > 0 {
new.BoardApproveRatio = modify.BoardApproveRatio newConfig.BoardApproveRatio = modify.BoardApproveRatio
} }
if modify.PubOpposeRatio > 0 { if modify.PubOpposeRatio > 0 {
new.PubOpposeRatio = modify.PubOpposeRatio newConfig.PubOpposeRatio = modify.PubOpposeRatio
} }
if modify.ProposalAmount > 0 { if modify.ProposalAmount > 0 {
new.ProposalAmount = modify.ProposalAmount newConfig.ProposalAmount = modify.ProposalAmount
} }
if modify.LargeProjectAmount > 0 { if modify.LargeProjectAmount > 0 {
new.LargeProjectAmount = modify.LargeProjectAmount newConfig.LargeProjectAmount = modify.LargeProjectAmount
} }
if modify.PublicPeriod > 0 { if modify.PublicPeriod > 0 {
new.PublicPeriod = modify.PublicPeriod newConfig.PublicPeriod = modify.PublicPeriod
}
if modify.PubAttendRatio > 0 {
newConfig.PubAttendRatio = modify.PubAttendRatio
} }
return &new if modify.PubApproveRatio > 0 {
newConfig.PubApproveRatio = modify.PubApproveRatio
}
return &newConfig
} }
...@@ -27,11 +27,11 @@ var ruleOpt = &table.Option{ ...@@ -27,11 +27,11 @@ var ruleOpt = &table.Option{
//NewRuleTable 新建表 //NewRuleTable 新建表
func NewRuleTable(kvdb db.KV) *table.Table { func NewRuleTable(kvdb db.KV) *table.Table {
rowmeta := NewRuleRow() rowmeta := NewRuleRow()
table, err := table.NewTable(rowmeta, kvdb, ruleOpt) newTable, err := table.NewTable(rowmeta, kvdb, ruleOpt)
if err != nil { if err != nil {
panic(err) panic(err)
} }
return table return newTable
} }
//RuleRow table meta 结构 //RuleRow table meta 结构
......
...@@ -25,6 +25,16 @@ message AutonomyProposalBoard { ...@@ -25,6 +25,16 @@ message AutonomyProposalBoard {
string proposalID = 9; string proposalID = 9;
} }
enum BoardUpdate {
INV = 0;
//新增
ADDBoard = 1;
//剔除
DELBoard = 2;
//整体替换
REPLACEALL = 3;
}
// action // action
message ProposalBoard { message ProposalBoard {
// 提案时间 // 提案时间
...@@ -41,6 +51,10 @@ message ProposalBoard { ...@@ -41,6 +51,10 @@ message ProposalBoard {
int64 startBlockHeight = 6; // 提案开始投票高度 int64 startBlockHeight = 6; // 提案开始投票高度
int64 endBlockHeight = 7; // 提案结束投票高度 int64 endBlockHeight = 7; // 提案结束投票高度
int64 realEndBlockHeight = 8; // 实际提案结束投票高度 int64 realEndBlockHeight = 8; // 实际提案结束投票高度
//代替update,并扩展
BoardUpdate boardUpdate = 9;
} }
message RevokeProposalBoard { message RevokeProposalBoard {
...@@ -50,7 +64,10 @@ message RevokeProposalBoard { ...@@ -50,7 +64,10 @@ message RevokeProposalBoard {
message VoteProposalBoard { message VoteProposalBoard {
string proposalID = 1; string proposalID = 1;
bool approve = 2; bool approve = 2;
//真正投票地址
repeated string originAddr = 3; repeated string originAddr = 3;
//代替approve,并增加了弃权选项
AutonomyVoteOption voteOption = 4;
} }
message TerminateProposalBoard { message TerminateProposalBoard {
......
...@@ -54,6 +54,7 @@ message RevokeProposalChange { ...@@ -54,6 +54,7 @@ message RevokeProposalChange {
message VoteProposalChange { message VoteProposalChange {
string proposalID = 1; string proposalID = 1;
bool approve = 2; bool approve = 2;
AutonomyVoteOption vote = 3;
} }
message TerminateProposalChange { message TerminateProposalChange {
......
...@@ -16,6 +16,8 @@ message VoteResult { ...@@ -16,6 +16,8 @@ message VoteResult {
int32 opposeVotes = 3; int32 opposeVotes = 3;
// 是否通过 // 是否通过
bool pass = 4; bool pass = 4;
//弃权票
int32 quitVotes = 5;
} }
message PublicVote { message PublicVote {
...@@ -44,6 +46,22 @@ message RuleConfig { ...@@ -44,6 +46,22 @@ message RuleConfig {
int64 largeProjectAmount = 4; int64 largeProjectAmount = 4;
// 重大项目公示时间(以区块数为单位) // 重大项目公示时间(以区块数为单位)
int32 publicPeriod = 5; int32 publicPeriod = 5;
// 全体持票人参与率
int32 pubAttendRatio = 6;
// 全体持票人赞成率
int32 pubApproveRatio = 7;
}
//三种投票选项
enum AutonomyVoteOption {
NOJOIN = 0;
//支持
APPROVE = 1;
//反对
OPPOSE = 2;
//弃权
QUIT = 3;
} }
message ActiveBoard { message ActiveBoard {
......
...@@ -59,6 +59,7 @@ message RevokeProposalProject { ...@@ -59,6 +59,7 @@ message RevokeProposalProject {
message VoteProposalProject { message VoteProposalProject {
string proposalID = 1; string proposalID = 1;
bool approve = 2; bool approve = 2;
AutonomyVoteOption vote = 3;
} }
message PubVoteProposalProject { message PubVoteProposalProject {
......
...@@ -44,6 +44,7 @@ message VoteProposalRule { ...@@ -44,6 +44,7 @@ message VoteProposalRule {
string proposalID = 1; string proposalID = 1;
bool approve = 2; bool approve = 2;
repeated string originAddr = 3; repeated string originAddr = 3;
AutonomyVoteOption vote = 4;
} }
message TerminateProposalRule { message TerminateProposalRule {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -280,9 +280,10 @@ type VoteProposalRule struct { ...@@ -280,9 +280,10 @@ type VoteProposalRule struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
ProposalID string `protobuf:"bytes,1,opt,name=proposalID,proto3" json:"proposalID,omitempty"` ProposalID string `protobuf:"bytes,1,opt,name=proposalID,proto3" json:"proposalID,omitempty"`
Approve bool `protobuf:"varint,2,opt,name=approve,proto3" json:"approve,omitempty"` Approve bool `protobuf:"varint,2,opt,name=approve,proto3" json:"approve,omitempty"`
OriginAddr []string `protobuf:"bytes,3,rep,name=originAddr,proto3" json:"originAddr,omitempty"` OriginAddr []string `protobuf:"bytes,3,rep,name=originAddr,proto3" json:"originAddr,omitempty"`
Vote AutonomyVoteOption `protobuf:"varint,4,opt,name=vote,proto3,enum=types.AutonomyVoteOption" json:"vote,omitempty"`
} }
func (x *VoteProposalRule) Reset() { func (x *VoteProposalRule) Reset() {
...@@ -338,6 +339,13 @@ func (x *VoteProposalRule) GetOriginAddr() []string { ...@@ -338,6 +339,13 @@ func (x *VoteProposalRule) GetOriginAddr() []string {
return nil return nil
} }
func (x *VoteProposalRule) GetVote() AutonomyVoteOption {
if x != nil {
return x.Vote
}
return AutonomyVoteOption_NOJOIN
}
type TerminateProposalRule struct { type TerminateProposalRule struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -1071,13 +1079,16 @@ var file_rule_proto_rawDesc = []byte{ ...@@ -1071,13 +1079,16 @@ var file_rule_proto_rawDesc = []byte{
0x76, 0x6f, 0x6b, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65,
0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x44, 0x18, 0x01, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x44, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x44, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x44,
0x22, 0x6c, 0x0a, 0x10, 0x56, 0x6f, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x22, 0x9b, 0x01, 0x0a, 0x10, 0x56, 0x6f, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61,
0x52, 0x75, 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61,
0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x6c, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f,
0x61, 0x6c, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x18, 0x73, 0x61, 0x6c, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65,
0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x12, 0x1e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x12,
0x0a, 0x0a, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, 0x03, 0x1e, 0x0a, 0x0a, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20,
0x28, 0x09, 0x52, 0x0a, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x22, 0x37, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x12,
0x2d, 0x0a, 0x04, 0x76, 0x6f, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, 0x2e,
0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x6e, 0x6f, 0x6d, 0x79, 0x56, 0x6f,
0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x04, 0x76, 0x6f, 0x74, 0x65, 0x22, 0x37,
0x0a, 0x15, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x0a, 0x15, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x6f,
0x73, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f,
0x73, 0x61, 0x6c, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f,
...@@ -1187,23 +1198,25 @@ var file_rule_proto_goTypes = []interface{}{ ...@@ -1187,23 +1198,25 @@ var file_rule_proto_goTypes = []interface{}{
(*ReplyQueryProposalComment)(nil), // 14: types.ReplyQueryProposalComment (*ReplyQueryProposalComment)(nil), // 14: types.ReplyQueryProposalComment
(*RuleConfig)(nil), // 15: types.RuleConfig (*RuleConfig)(nil), // 15: types.RuleConfig
(*VoteResult)(nil), // 16: types.VoteResult (*VoteResult)(nil), // 16: types.VoteResult
(AutonomyVoteOption)(0), // 17: types.AutonomyVoteOption
} }
var file_rule_proto_depIdxs = []int32{ var file_rule_proto_depIdxs = []int32{
1, // 0: types.AutonomyProposalRule.propRule:type_name -> types.ProposalRule 1, // 0: types.AutonomyProposalRule.propRule:type_name -> types.ProposalRule
15, // 1: types.AutonomyProposalRule.curRule:type_name -> types.RuleConfig 15, // 1: types.AutonomyProposalRule.curRule:type_name -> types.RuleConfig
16, // 2: types.AutonomyProposalRule.voteResult:type_name -> types.VoteResult 16, // 2: types.AutonomyProposalRule.voteResult:type_name -> types.VoteResult
15, // 3: types.ProposalRule.ruleCfg:type_name -> types.RuleConfig 15, // 3: types.ProposalRule.ruleCfg:type_name -> types.RuleConfig
0, // 4: types.ReceiptProposalRule.prev:type_name -> types.AutonomyProposalRule 17, // 4: types.VoteProposalRule.vote:type_name -> types.AutonomyVoteOption
0, // 5: types.ReceiptProposalRule.current:type_name -> types.AutonomyProposalRule 0, // 5: types.ReceiptProposalRule.prev:type_name -> types.AutonomyProposalRule
0, // 6: types.LocalProposalRule.propRule:type_name -> types.AutonomyProposalRule 0, // 6: types.ReceiptProposalRule.current:type_name -> types.AutonomyProposalRule
0, // 7: types.ReplyQueryProposalRule.propRules:type_name -> types.AutonomyProposalRule 0, // 7: types.LocalProposalRule.propRule:type_name -> types.AutonomyProposalRule
10, // 8: types.ReceiptProposalComment.cmt:type_name -> types.Comment 0, // 8: types.ReplyQueryProposalRule.propRules:type_name -> types.AutonomyProposalRule
13, // 9: types.ReplyQueryProposalComment.rltCmt:type_name -> types.RelationCmt 10, // 9: types.ReceiptProposalComment.cmt:type_name -> types.Comment
10, // [10:10] is the sub-list for method output_type 13, // 10: types.ReplyQueryProposalComment.rltCmt:type_name -> types.RelationCmt
10, // [10:10] is the sub-list for method input_type 11, // [11:11] is the sub-list for method output_type
10, // [10:10] is the sub-list for extension type_name 11, // [11:11] is the sub-list for method input_type
10, // [10:10] is the sub-list for extension extendee 11, // [11:11] is the sub-list for extension type_name
0, // [0:10] is the sub-list for field type_name 11, // [11:11] is the sub-list for extension extendee
0, // [0:11] is the sub-list for field type_name
} }
func init() { file_rule_proto_init() } func init() { file_rule_proto_init() }
......
...@@ -12,6 +12,11 @@ import ( ...@@ -12,6 +12,11 @@ import (
var name string var name string
var (
//ForkAutonomyDelRule fork for delete boards member rules
ForkAutonomyDelRule = "ForkAutonomyDelRule"
)
func init() { func init() {
name = AutonomyX name = AutonomyX
types.AllowUserExec = append(types.AllowUserExec, []byte(name)) types.AllowUserExec = append(types.AllowUserExec, []byte(name))
...@@ -22,6 +27,7 @@ func init() { ...@@ -22,6 +27,7 @@ func init() {
//InitFork ... //InitFork ...
func InitFork(cfg *types.Chain33Config) { func InitFork(cfg *types.Chain33Config) {
cfg.RegisterDappFork(AutonomyX, "Enable", 0) cfg.RegisterDappFork(AutonomyX, "Enable", 0)
cfg.RegisterDappFork(AutonomyX, ForkAutonomyDelRule, 9500000)
} }
//InitExecutor ... //InitExecutor ...
......
...@@ -399,6 +399,7 @@ ForkUnfreezeIDX= 0 ...@@ -399,6 +399,7 @@ ForkUnfreezeIDX= 0
[fork.sub.autonomy] [fork.sub.autonomy]
Enable=0 Enable=0
ForkAutonomyDelRule=0
[fork.sub.jsvm] [fork.sub.jsvm]
Enable=0 Enable=0
......
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