Commit d2526d02 authored by mdj33's avatar mdj33 Committed by vipwzw

autonomy add item proposal

parent 9c037e47
...@@ -132,6 +132,10 @@ function base_init() { ...@@ -132,6 +132,10 @@ function base_init() {
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
fi fi
#autonomy config
sed -i $sedfix 's/^autonomyExec =.*/autonomyExec=""/g' chain33.toml
} }
function start() { function start() {
......
...@@ -113,8 +113,8 @@ ParaRemoteGrpcClient="localhost:8802" ...@@ -113,8 +113,8 @@ ParaRemoteGrpcClient="localhost:8802"
startHeight=345850 startHeight=345850
#主链指定高度后等待块数,防止主链回滚,联盟链最小为1,小于1则采用缺省高度100 #主链指定高度后等待块数,防止主链回滚,联盟链最小为1,小于1则采用缺省高度100
#waitMainBlockNum=100 #waitMainBlockNum=100
#打包时间间隔,单位 #等待打包主链区块时间间隔,单位毫
writeBlockSeconds=2 writeBlockMsec=2000
#共识节点账户,共识节点需要配置自己的账户,并且钱包导入对应种子,非共识节点留空 #共识节点账户,共识节点需要配置自己的账户,并且钱包导入对应种子,非共识节点留空
authAccount="" authAccount=""
#创世地址额度 #创世地址额度
...@@ -380,6 +380,7 @@ ForkUnfreezeIDX= 0 ...@@ -380,6 +380,7 @@ ForkUnfreezeIDX= 0
[fork.sub.autonomy] [fork.sub.autonomy]
Enable=0 Enable=0
ForkAutonomyDelRule=0 ForkAutonomyDelRule=0
ForkAutonomyEnableItem=0
[fork.sub.jsvm] [fork.sub.jsvm]
Enable=0 Enable=0
......
...@@ -118,8 +118,8 @@ ParaRemoteGrpcClient="localhost:8802" ...@@ -118,8 +118,8 @@ ParaRemoteGrpcClient="localhost:8802"
startHeight=345850 startHeight=345850
#主链指定高度后等待块数,防止主链回滚,联盟链最小为1,小于1则采用缺省高度100 #主链指定高度后等待块数,防止主链回滚,联盟链最小为1,小于1则采用缺省高度100
#waitMainBlockNum=100 #waitMainBlockNum=100
#检索主链最新区块时间间隔,单位 #等待打包主链区块时间间隔,单位毫
writeBlockSeconds=2 writeBlockMsec=2000
#共识节点账户,共识节点需要配置自己的账户,并且钱包导入对应种子,非共识节点留空 #共识节点账户,共识节点需要配置自己的账户,并且钱包导入对应种子,非共识节点留空
authAccount="" authAccount=""
#创世地址额度 #创世地址额度
...@@ -385,6 +385,7 @@ ForkUnfreezeIDX= 0 ...@@ -385,6 +385,7 @@ ForkUnfreezeIDX= 0
[fork.sub.autonomy] [fork.sub.autonomy]
Enable=0 Enable=0
ForkAutonomyDelRule=0 ForkAutonomyDelRule=0
ForkAutonomyEnableItem=0
[fork.sub.jsvm] [fork.sub.jsvm]
Enable=0 Enable=0
......
...@@ -277,6 +277,9 @@ superManager=[ ...@@ -277,6 +277,9 @@ superManager=[
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv",
"1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK" "1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK"
] ]
#autonomy执行器名字
autonomyExec="autonomy"
[exec.sub.paracross] [exec.sub.paracross]
nodeGroupFrozenCoins=0 nodeGroupFrozenCoins=0
#平行链共识停止后主链等待的高度 #平行链共识停止后主链等待的高度
......
...@@ -35,7 +35,7 @@ const ( ...@@ -35,7 +35,7 @@ const (
//current miner tx take any privatekey for unify all nodes sign purpose, and para chain is free //current miner tx take any privatekey for unify all nodes sign purpose, and para chain is free
minerPrivateKey = "6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b" minerPrivateKey = "6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
defaultGenesisAmount int64 = 1e8 defaultGenesisAmount int64 = 1e8
poolMainBlockSec int64 = 5 poolMainBlockMsec int64 = 5000
defaultEmptyBlockInterval int64 = 50 //write empty block every interval blocks in mainchain defaultEmptyBlockInterval int64 = 50 //write empty block every interval blocks in mainchain
defaultSearchMatchedBlockDepth int32 = 10000 defaultSearchMatchedBlockDepth int32 = 10000
) )
...@@ -70,7 +70,7 @@ type client struct { ...@@ -70,7 +70,7 @@ type client struct {
} }
type subConfig struct { type subConfig struct {
WriteBlockSeconds int64 `json:"writeBlockSeconds,omitempty"` WriteBlockMsec int64 `json:"writeBlockMsec,omitempty"`
ParaRemoteGrpcClient string `json:"paraRemoteGrpcClient,omitempty"` ParaRemoteGrpcClient string `json:"paraRemoteGrpcClient,omitempty"`
StartHeight int64 `json:"startHeight,omitempty"` StartHeight int64 `json:"startHeight,omitempty"`
WaitMainBlockNum int64 `json:"waitMainBlockNum,omitempty"` WaitMainBlockNum int64 `json:"waitMainBlockNum,omitempty"`
...@@ -105,8 +105,8 @@ func New(cfg *types.Consensus, sub []byte) queue.Module { ...@@ -105,8 +105,8 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
subcfg.GenesisAmount = defaultGenesisAmount subcfg.GenesisAmount = defaultGenesisAmount
} }
if subcfg.WriteBlockSeconds <= 0 { if subcfg.WriteBlockMsec <= 0 {
subcfg.WriteBlockSeconds = poolMainBlockSec subcfg.WriteBlockMsec = poolMainBlockMsec
} }
//WaitMainBlockNum 配置最小为1,因为genesis块是startHeight-1, wait=1和startHeight相等 //WaitMainBlockNum 配置最小为1,因为genesis块是startHeight-1, wait=1和startHeight相等
...@@ -291,7 +291,7 @@ func (client *client) GetStartMainHash(height int64) []byte { ...@@ -291,7 +291,7 @@ func (client *client) GetStartMainHash(height int64) []byte {
} }
if height > 0 { if height > 0 {
hint := time.NewTicker(time.Second * time.Duration(client.subCfg.WriteBlockSeconds)) hint := time.NewTicker(time.Second)
for lastHeight < height+client.subCfg.WaitMainBlockNum { for lastHeight < height+client.subCfg.WaitMainBlockNum {
select { select {
case <-hint.C: case <-hint.C:
......
...@@ -537,7 +537,7 @@ out: ...@@ -537,7 +537,7 @@ out:
if err == nil { if err == nil {
continue continue
} }
time.Sleep(time.Second * time.Duration(client.subCfg.WriteBlockSeconds)) time.Sleep(time.Millisecond * time.Duration(client.subCfg.WriteBlockMsec))
continue continue
} }
......
...@@ -69,6 +69,15 @@ func AutonomyCmd() *cobra.Command { ...@@ -69,6 +69,15 @@ func AutonomyCmd() *cobra.Command {
ShowProposalChangeCmd(), ShowProposalChangeCmd(),
) )
// item
cmd.AddCommand(
ProposalItemCmd(),
RevokeProposalItemCmd(),
VoteProposalItemCmd(),
TerminateProposalItemCmd(),
ShowProposalItemCmd(),
)
return cmd return cmd
} }
......
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package commands
import (
"encoding/json"
jsonrpc "github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
auty "github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/spf13/cobra"
)
// ProposalItemCmd 创建提案命令
func ProposalItemCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "proposalItem",
Short: "create proposal Item",
Run: proposalItem,
}
addProposalItemFlags(cmd)
return cmd
}
func addProposalItemFlags(cmd *cobra.Command) {
cmd.Flags().Int32P("year", "y", 0, "year")
cmd.Flags().Int32P("month", "m", 0, "month")
cmd.Flags().Int32P("day", "d", 0, "day")
cmd.Flags().StringP("itemTxHash", "i", "", "the tx to apply check")
cmd.MarkFlagRequired("itemTxHash")
cmd.Flags().StringP("exec", "x", "", "last stage proposal ID")
cmd.Flags().StringP("description", "p", "", "description item")
cmd.Flags().Int64P("startBlock", "s", 0, "start block height")
cmd.MarkFlagRequired("startBlock")
cmd.Flags().Int64P("endBlock", "e", 0, "end block height")
cmd.MarkFlagRequired("endBlock")
}
func proposalItem(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
paraName, _ := cmd.Flags().GetString("paraName")
year, _ := cmd.Flags().GetInt32("year")
month, _ := cmd.Flags().GetInt32("month")
day, _ := cmd.Flags().GetInt32("day")
txHash, _ := cmd.Flags().GetString("itemTxHash")
exec, _ := cmd.Flags().GetString("exec")
description, _ := cmd.Flags().GetString("description")
startBlock, _ := cmd.Flags().GetInt64("startBlock")
endBlock, _ := cmd.Flags().GetInt64("endBlock")
params := &auty.ProposalItem{
Year: year,
Month: month,
Day: day,
ItemTxHash: txHash,
Exec: exec,
Description: description,
StartBlockHeight: startBlock,
EndBlockHeight: endBlock,
}
payLoad, err := json.Marshal(params)
if err != nil {
return
}
pm := &rpctypes.CreateTxIn{
Execer: types.GetExecName(auty.AutonomyX, paraName),
ActionName: "PropItem",
Payload: payLoad,
}
var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.CreateTransaction", pm, &res)
ctx.RunWithoutMarshal()
}
// RevokeProposalItemCmd 撤销提案
func RevokeProposalItemCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "revokeItem",
Short: "revoke proposal Item",
Run: revokeProposalItem,
}
addRevokeProposalItemFlags(cmd)
return cmd
}
func addRevokeProposalItemFlags(cmd *cobra.Command) {
cmd.Flags().StringP("proposalID", "p", "", "proposal ID")
cmd.MarkFlagRequired("proposalID")
}
func revokeProposalItem(cmd *cobra.Command, args []string) {
paraName, _ := cmd.Flags().GetString("paraName")
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
ID, _ := cmd.Flags().GetString("proposalID")
params := &auty.RevokeProposalItem{
ProposalID: ID,
}
payLoad, err := json.Marshal(params)
if err != nil {
return
}
pm := &rpctypes.CreateTxIn{
Execer: types.GetExecName(auty.AutonomyX, paraName),
ActionName: "RvkPropItem",
Payload: payLoad,
}
var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.CreateTransaction", pm, &res)
ctx.RunWithoutMarshal()
}
// VoteProposalItemCmd 投票提案
func VoteProposalItemCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "voteItem",
Short: "vote proposal Item",
Run: voteProposalItem,
}
addVoteProposalItemFlags(cmd)
return cmd
}
func addVoteProposalItemFlags(cmd *cobra.Command) {
cmd.Flags().StringP("proposalID", "p", "", "proposal ID")
cmd.MarkFlagRequired("proposalID")
cmd.Flags().Int32P("approve", "r", 1, "1:approve, 2:oppose, 3:quit, default 1")
}
func voteProposalItem(cmd *cobra.Command, args []string) {
paraName, _ := cmd.Flags().GetString("paraName")
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
ID, _ := cmd.Flags().GetString("proposalID")
approve, _ := cmd.Flags().GetInt32("approve")
params := &auty.VoteProposalItem{
ProposalID: ID,
Vote: auty.AutonomyVoteOption(approve),
}
payLoad, err := json.Marshal(params)
if err != nil {
return
}
pm := &rpctypes.CreateTxIn{
Execer: types.GetExecName(auty.AutonomyX, paraName),
ActionName: "VotePropItem",
Payload: payLoad,
}
var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.CreateTransaction", pm, &res)
ctx.RunWithoutMarshal()
}
// TerminateProposalItemCmd 终止提案
func TerminateProposalItemCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "terminateItem",
Short: "terminate proposal Item",
Run: terminateProposalItem,
}
addTerminateProposalItemFlags(cmd)
return cmd
}
func addTerminateProposalItemFlags(cmd *cobra.Command) {
cmd.Flags().StringP("proposalID", "p", "", "proposal ID")
cmd.MarkFlagRequired("proposalID")
}
func terminateProposalItem(cmd *cobra.Command, args []string) {
paraName, _ := cmd.Flags().GetString("paraName")
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
ID, _ := cmd.Flags().GetString("proposalID")
params := &auty.RevokeProposalItem{
ProposalID: ID,
}
payLoad, err := json.Marshal(params)
if err != nil {
return
}
pm := &rpctypes.CreateTxIn{
Execer: types.GetExecName(auty.AutonomyX, paraName),
ActionName: "TmintPropItem",
Payload: payLoad,
}
var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.CreateTransaction", pm, &res)
ctx.RunWithoutMarshal()
}
// ShowProposalItemCmd 显示提案查询信息
func ShowProposalItemCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "showItem",
Short: "show proposal Item info",
Run: showProposalItem,
}
addShowProposalItemflags(cmd)
return cmd
}
func addShowProposalItemflags(cmd *cobra.Command) {
cmd.Flags().Uint32P("type", "y", 0, "type(0:query by hash; 1:list)")
cmd.MarkFlagRequired("type")
cmd.Flags().StringP("proposalID", "p", "", "proposal ID")
cmd.Flags().Uint32P("status", "s", 0, "status")
cmd.Flags().StringP("addr", "a", "", "address")
cmd.Flags().Int32P("count", "c", 1, "count, default is 1")
cmd.Flags().Int32P("direction", "d", 0, "direction, default is reserve")
cmd.Flags().Int64P("height", "t", -1, "height, default is -1")
cmd.Flags().Int32P("index", "i", -1, "index, default is -1")
}
func showProposalItem(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
typ, _ := cmd.Flags().GetUint32("type")
propID, _ := cmd.Flags().GetString("proposalID")
status, _ := cmd.Flags().GetUint32("status")
addr, _ := cmd.Flags().GetString("addr")
count, _ := cmd.Flags().GetInt32("count")
direction, _ := cmd.Flags().GetInt32("direction")
height, _ := cmd.Flags().GetInt64("height")
index, _ := cmd.Flags().GetInt32("index")
var params rpctypes.Query4Jrpc
var rep interface{}
params.Execer = auty.AutonomyX
if 0 == typ {
req := types.ReqString{
Data: propID,
}
params.FuncName = auty.GetProposalItem
params.Payload = types.MustPBToJSON(&req)
rep = &auty.ReplyQueryProposalItem{}
} else if 1 == typ {
req := auty.ReqQueryProposalItem{
Status: int32(status),
Addr: addr,
Count: count,
Direction: direction,
Height: height,
Index: index,
}
params.FuncName = auty.ListProposalItem
params.Payload = types.MustPBToJSON(&req)
rep = &auty.ReplyQueryProposalItem{}
}
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, rep)
ctx.Run()
}
...@@ -7,6 +7,7 @@ package executor ...@@ -7,6 +7,7 @@ package executor
import ( import (
"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"
) )
// 提案董事会相关 // 提案董事会相关
...@@ -133,24 +134,36 @@ func (a *Autonomy) Exec_TmintPropChange(payload *auty.TerminateProposalChange, t ...@@ -133,24 +134,36 @@ func (a *Autonomy) Exec_TmintPropChange(payload *auty.TerminateProposalChange, t
// Exec_PropChange 创建事项规则 // Exec_PropChange 创建事项规则
func (a *Autonomy) Exec_PropItem(payload *auty.ProposalItem, tx *types.Transaction, index int) (*types.Receipt, error) { func (a *Autonomy) Exec_PropItem(payload *auty.ProposalItem, tx *types.Transaction, index int) (*types.Receipt, error) {
if !a.GetAPI().GetConfig().IsDappFork(a.GetHeight(), auty.AutonomyX, auty.ForkAutonomyEnableItem) {
return nil, errors.Wrapf(types.ErrActionNotSupport, "not after fork")
}
action := newAction(a, tx, int32(index)) action := newAction(a, tx, int32(index))
return action.propItem(payload) return action.propItem(payload)
} }
// Exec_RvkPropItem 撤销事项规则 // Exec_RvkPropItem 撤销事项规则
func (a *Autonomy) Exec_RvkPropItem(payload *auty.RevokeProposalItem, tx *types.Transaction, index int) (*types.Receipt, error) { func (a *Autonomy) Exec_RvkPropItem(payload *auty.RevokeProposalItem, tx *types.Transaction, index int) (*types.Receipt, error) {
if !a.GetAPI().GetConfig().IsDappFork(a.GetHeight(), auty.AutonomyX, auty.ForkAutonomyEnableItem) {
return nil, errors.Wrapf(types.ErrActionNotSupport, "not after fork")
}
action := newAction(a, tx, int32(index)) action := newAction(a, tx, int32(index))
return action.rvkPropItem(payload) return action.rvkPropItem(payload)
} }
// Exec_VotePropItem 投票事项规则 // Exec_VotePropItem 投票事项规则
func (a *Autonomy) Exec_VotePropItem(payload *auty.VoteProposalItem, tx *types.Transaction, index int) (*types.Receipt, error) { func (a *Autonomy) Exec_VotePropItem(payload *auty.VoteProposalItem, tx *types.Transaction, index int) (*types.Receipt, error) {
if !a.GetAPI().GetConfig().IsDappFork(a.GetHeight(), auty.AutonomyX, auty.ForkAutonomyEnableItem) {
return nil, errors.Wrapf(types.ErrActionNotSupport, "not after fork")
}
action := newAction(a, tx, int32(index)) action := newAction(a, tx, int32(index))
return action.votePropItem(payload) return action.votePropItem(payload)
} }
// Exec_TmintPropItem 终止事项规则 // Exec_TmintPropItem 终止事项规则
func (a *Autonomy) Exec_TmintPropItem(payload *auty.TerminateProposalItem, tx *types.Transaction, index int) (*types.Receipt, error) { func (a *Autonomy) Exec_TmintPropItem(payload *auty.TerminateProposalItem, tx *types.Transaction, index int) (*types.Receipt, error) {
if !a.GetAPI().GetConfig().IsDappFork(a.GetHeight(), auty.AutonomyX, auty.ForkAutonomyEnableItem) {
return nil, errors.Wrapf(types.ErrActionNotSupport, "not after fork")
}
action := newAction(a, tx, int32(index)) action := newAction(a, tx, int32(index))
return action.tmintPropItem(payload) return action.tmintPropItem(payload)
} }
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
package executor package executor
import ( import (
"fmt"
dbm "github.com/33cn/chain33/common/db" dbm "github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/system/dapp" "github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
...@@ -108,7 +107,7 @@ func (a *Autonomy) listProposalItem(req *auty.ReqQueryProposalItem) (types.Messa ...@@ -108,7 +107,7 @@ func (a *Autonomy) listProposalItem(req *auty.ReqQueryProposalItem) (types.Messa
return &rep, nil return &rep, nil
} }
func getProposalItemDb(db dbm.KV, req *types.ReqString) (*auty.ReplyQueryProposalItem, error) { func getProposalItem(db dbm.KV, req *types.ReqString) (*auty.ReplyQueryProposalItem, error) {
if req == nil || len(req.Data) <= 0 { if req == nil || len(req.Data) <= 0 {
return nil, errors.Wrapf(types.ErrInvalidParam, "invalid parameter") return nil, errors.Wrapf(types.ErrInvalidParam, "invalid parameter")
} }
...@@ -127,48 +126,38 @@ func getProposalItemDb(db dbm.KV, req *types.ReqString) (*auty.ReplyQueryProposa ...@@ -127,48 +126,38 @@ func getProposalItemDb(db dbm.KV, req *types.ReqString) (*auty.ReplyQueryProposa
} }
// IsAutonomyApprovedItem get 2 parameters: autonomyItemID, applyTxHash // IsAutonomyApprovedItem get 2 parameters: autonomyItemID, applyTxHash
func IsAutonomyApprovedItem(db dbm.KV, req *types.ReqStrings) (types.Message, error) { func IsAutonomyApprovedItem(db dbm.KV, req *types.ReqMultiStrings) (types.Message, error) {
rep := &types.Reply{IsOk: false}
if req == nil { if req == nil {
rep.Msg = []byte("req is nill") return nil, errors.Wrapf(types.ErrInvalidParam, "req is nil")
return rep, types.ErrInvalidParam
} }
if len(req.Datas) < 2 { if len(req.Datas) < 2 {
rep.Msg = []byte("req datas less 2 parameters") return nil, errors.Wrapf(types.ErrInvalidParam, "req datas less 2 parameters")
return rep, types.ErrInvalidParam
} }
autonomyItemID := req.Datas[0] autonomyItemID := req.Datas[0]
applyTxHash := req.Datas[1] applyTxHash := req.Datas[1]
res, err := getProposalItemDb(db, &types.ReqString{Data: autonomyItemID}) res, err := getProposalItem(db, &types.ReqString{Data: autonomyItemID})
if err != nil { if err != nil {
rep.Msg = []byte(err.Error()) return nil, err
return rep, err
} }
if len(res.GetPropItems()) <= 0 { if len(res.GetPropItems()) <= 0 {
rep.Msg = []byte("not found item") return nil, errors.Wrapf(types.ErrNotFound, "not get item")
return rep, types.ErrNotFound
} }
if res.PropItems[0].ProposalID != autonomyItemID { if res.PropItems[0].ProposalID != autonomyItemID {
rep.Msg = []byte(fmt.Sprintf("res prop id=%s not equal query=%s", res.PropItems[0].ProposalID, autonomyItemID)) return nil, errors.Wrapf(types.ErrInvalidParam, "get prop id=%s not equal req=%s", res.PropItems[0].ProposalID, autonomyItemID)
return rep, errors.Wrapf(types.ErrInvalidParam, "item id=%s,req=%s", res.PropItems[0].ProposalID, autonomyItemID)
} }
if res.PropItems[0].PropItem.ItemTxHash != applyTxHash { if res.PropItems[0].PropItem.ItemTxHash != applyTxHash {
rep.Msg = []byte(fmt.Sprintf("res item tx id=%s not equal query=%s", res.PropItems[0].PropItem.ItemTxHash, applyTxHash)) return nil, errors.Wrapf(types.ErrInvalidParam, "get item id=%s != req=%s", res.PropItems[0].PropItem.ItemTxHash, applyTxHash)
return rep, errors.Wrapf(types.ErrInvalidParam, "item txHash=%s,req=%s", res.PropItems[0].PropItem.ItemTxHash, applyTxHash)
} }
if res.PropItems[0].Status == auty.AutonomyStatusTmintPropItem && res.PropItems[0].BoardVoteRes.Pass { if res.PropItems[0].Status == auty.AutonomyStatusTmintPropItem && res.PropItems[0].BoardVoteRes.Pass {
rep.IsOk = true return &types.Reply{IsOk: true}, nil
return rep, nil
} }
if res.PropItems[0].Status != auty.AutonomyStatusTmintPropItem { if res.PropItems[0].Status != auty.AutonomyStatusTmintPropItem {
rep.Msg = []byte(fmt.Sprintf("item status =%d not terminate", res.PropItems[0].Status)) return nil, errors.Wrapf(types.ErrNotAllow, "item status =%d not terminate", res.PropItems[0].Status)
return rep, errors.Wrapf(types.ErrNotAllow, "item status =%d not terminate", res.PropItems[0].Status)
} }
rep.Msg = []byte(fmt.Sprintf("item vote status not pass = %v", res.PropItems[0].BoardVoteRes.Pass)) return nil, errors.Wrapf(types.ErrNotAllow, "item vote status not pass = %v", res.PropItems[0].BoardVoteRes.Pass)
return rep, errors.Wrap(types.ErrNotAllow, "item vote status not pass")
} }
...@@ -16,11 +16,7 @@ const ( ...@@ -16,11 +16,7 @@ const (
) )
func (a *action) propItem(prob *auty.ProposalItem) (*types.Receipt, error) { func (a *action) propItem(prob *auty.ProposalItem) (*types.Receipt, error) {
//itemTx 不能等待太久,太久需要重新申请 //start和end之间不能小于720高度,end不能超过当前高度+100w
if a.height > prob.ItemTxBlockHeight+itemWaitBlockNumber {
return nil, errors.Wrapf(types.ErrInvalidParam, "itemTx wait too long, curHeight=%d,itemTx=%d", a.height, prob.ItemTxBlockHeight)
}
if prob.StartBlockHeight < a.height || prob.StartBlockHeight >= prob.EndBlockHeight || if prob.StartBlockHeight < a.height || prob.StartBlockHeight >= prob.EndBlockHeight ||
prob.StartBlockHeight+startEndBlockPeriod > prob.EndBlockHeight || prob.StartBlockHeight+startEndBlockPeriod > prob.EndBlockHeight ||
prob.EndBlockHeight > a.height+propEndBlockPeriod || prob.EndBlockHeight > a.height+propEndBlockPeriod ||
...@@ -179,7 +175,7 @@ func (a *action) votePropItem(voteProb *auty.VoteProposalItem) (*types.Receipt, ...@@ -179,7 +175,7 @@ func (a *action) votePropItem(voteProb *auty.VoteProposalItem) (*types.Receipt,
if err != nil { if err != nil {
alog.Error("votePropItem ", "addr", a.fromaddr, "execaddr", a.execaddr, "checkVotesRecord boardVotesRecord failed", alog.Error("votePropItem ", "addr", a.fromaddr, "execaddr", a.execaddr, "checkVotesRecord boardVotesRecord failed",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
return nil, err return nil, errors.Wrapf(err, "check votes record from addr=%s", a.fromaddr)
} }
// 更新已经投票地址 // 更新已经投票地址
...@@ -242,7 +238,7 @@ func (a *action) tmintPropItem(tmintProb *auty.TerminateProposalItem) (*types.Re ...@@ -242,7 +238,7 @@ func (a *action) tmintPropItem(tmintProb *auty.TerminateProposalItem) (*types.Re
if err != nil { if err != nil {
alog.Error("tmintPropItem ", "addr", a.fromaddr, "execaddr", a.execaddr, "getProposalItem failed", alog.Error("tmintPropItem ", "addr", a.fromaddr, "execaddr", a.execaddr, "getProposalItem failed",
tmintProb.ProposalID, "err", err) tmintProb.ProposalID, "err", err)
return nil, err return nil, errors.Wrapf(err, "get item id=%s", tmintProb.ProposalID)
} }
pre := copyAutonomyProposalItem(cur) pre := copyAutonomyProposalItem(cur)
...@@ -252,7 +248,7 @@ func (a *action) tmintPropItem(tmintProb *auty.TerminateProposalItem) (*types.Re ...@@ -252,7 +248,7 @@ func (a *action) tmintPropItem(tmintProb *auty.TerminateProposalItem) (*types.Re
err := auty.ErrProposalStatus err := auty.ErrProposalStatus
alog.Error("tmintPropItem ", "addr", a.fromaddr, "status", cur.Status, "status is not match", alog.Error("tmintPropItem ", "addr", a.fromaddr, "status", cur.Status, "status is not match",
tmintProb.ProposalID, "err", err) tmintProb.ProposalID, "err", err)
return nil, err return nil, errors.Wrapf(err, "cur status=%d", cur.Status)
} }
// 董事会投票期间不能终止 // 董事会投票期间不能终止
...@@ -261,7 +257,7 @@ func (a *action) tmintPropItem(tmintProb *auty.TerminateProposalItem) (*types.Re ...@@ -261,7 +257,7 @@ func (a *action) tmintPropItem(tmintProb *auty.TerminateProposalItem) (*types.Re
err := auty.ErrTerminatePeriod err := auty.ErrTerminatePeriod
alog.Error("tmintPropItem ", "addr", a.fromaddr, "status", cur.Status, "height", a.height, alog.Error("tmintPropItem ", "addr", a.fromaddr, "status", cur.Status, "height", a.height,
"in board vote period can not terminate", tmintProb.ProposalID, "err", err) "in board vote period can not terminate", tmintProb.ProposalID, "err", err)
return nil, err return nil, errors.Wrapf(err, "vote period not should be terminated")
} }
if cur.BoardVoteRes.TotalVotes != 0 && cur.BoardVoteRes.TotalVotes > cur.BoardVoteRes.QuitVotes && if cur.BoardVoteRes.TotalVotes != 0 && cur.BoardVoteRes.TotalVotes > cur.BoardVoteRes.QuitVotes &&
......
...@@ -64,7 +64,17 @@ func (a *Autonomy) Query_ListProposalChange(in *auty.ReqQueryProposalChange) (ty ...@@ -64,7 +64,17 @@ func (a *Autonomy) Query_ListProposalChange(in *auty.ReqQueryProposalChange) (ty
return a.listProposalChange(in) return a.listProposalChange(in)
} }
// Query_GetProposalItem 查询提案
func (a *Autonomy) Query_GetProposalItem(in *types.ReqString) (types.Message, error) {
return getProposalItem(a.GetStateDB(), in)
}
// Query_ListProposalItem 批量查询
func (a *Autonomy) Query_ListProposalItem(in *auty.ReqQueryProposalItem) (types.Message, error) {
return a.listProposalItem(in)
}
// Query_GetProposalChange 查询提案修改董事会成员 // Query_GetProposalChange 查询提案修改董事会成员
func (a *Autonomy) Query_IsAutonomyApprovedItem(in *types.ReqStrings) (types.Message, error) { func (a *Autonomy) Query_IsAutonomyApprovedItem(in *types.ReqMultiStrings) (types.Message, error) {
return IsAutonomyApprovedItem(a.GetStateDB(), in) return IsAutonomyApprovedItem(a.GetStateDB(), in)
} }
...@@ -35,7 +35,6 @@ message ProposalItem { ...@@ -35,7 +35,6 @@ message ProposalItem {
// 项目相关 // 项目相关
string itemTxHash = 4; // item tx hash string itemTxHash = 4; // item tx hash
string exec = 5; // 合约执行器 string exec = 5; // 合约执行器
int64 itemTxBlockHeight = 6; //需要设置区块高度,太久的item不处理
string description = 7; // 简述 string description = 7; // 简述
// 投票相关 // 投票相关
......
...@@ -129,6 +129,11 @@ const ( ...@@ -129,6 +129,11 @@ const (
GetProposalChange = "GetProposalChange" GetProposalChange = "GetProposalChange"
// ListProposalChange 查询多个 // ListProposalChange 查询多个
ListProposalChange = "ListProposalChange" ListProposalChange = "ListProposalChange"
// GetProposalItem 用于在cmd里面的区分不同的查询
GetProposalItem = "GetProposalItem"
// ListProposalItem 查询多个
ListProposalItem = "ListProposalItem"
) )
//包的名字可以通过配置文件来配置 //包的名字可以通过配置文件来配置
......
This diff is collapsed.
...@@ -15,6 +15,8 @@ var name string ...@@ -15,6 +15,8 @@ var name string
var ( var (
//ForkAutonomyDelRule fork for delete boards member rules //ForkAutonomyDelRule fork for delete boards member rules
ForkAutonomyDelRule = "ForkAutonomyDelRule" ForkAutonomyDelRule = "ForkAutonomyDelRule"
//ForkAutonomyEnableItem fork for add autonomy item support
ForkAutonomyEnableItem = "ForkAutonomyEnableItem"
) )
func init() { func init() {
...@@ -28,6 +30,7 @@ func init() { ...@@ -28,6 +30,7 @@ func init() {
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) cfg.RegisterDappFork(AutonomyX, ForkAutonomyDelRule, 9500000)
cfg.RegisterDappFork(AutonomyX, ForkAutonomyEnableItem, 10000000)
} }
//InitExecutor ... //InitExecutor ...
...@@ -78,6 +81,11 @@ func (a *AutonomyType) GetLogMap() map[int64]*types.LogInfo { ...@@ -78,6 +81,11 @@ func (a *AutonomyType) GetLogMap() map[int64]*types.LogInfo {
TyLogRvkPropChange: {Ty: reflect.TypeOf(ReceiptProposalChange{}), Name: "LogRvkPropChange"}, TyLogRvkPropChange: {Ty: reflect.TypeOf(ReceiptProposalChange{}), Name: "LogRvkPropChange"},
TyLogVotePropChange: {Ty: reflect.TypeOf(ReceiptProposalChange{}), Name: "LogVotePropChange"}, TyLogVotePropChange: {Ty: reflect.TypeOf(ReceiptProposalChange{}), Name: "LogVotePropChange"},
TyLogTmintPropChange: {Ty: reflect.TypeOf(ReceiptProposalChange{}), Name: "LogTmintPropChange"}, TyLogTmintPropChange: {Ty: reflect.TypeOf(ReceiptProposalChange{}), Name: "LogTmintPropChange"},
TyLogPropItem: {Ty: reflect.TypeOf(ReceiptProposalItem{}), Name: "LogPropItem"},
TyLogRvkPropItem: {Ty: reflect.TypeOf(ReceiptProposalItem{}), Name: "LogRvkPropItem"},
TyLogVotePropItem: {Ty: reflect.TypeOf(ReceiptProposalItem{}), Name: "LogVotePropItem"},
TyLogTmintPropItem: {Ty: reflect.TypeOf(ReceiptProposalItem{}), Name: "LogTmintPropItem"},
} }
} }
...@@ -112,5 +120,10 @@ func (a *AutonomyType) GetTypeMap() map[string]int32 { ...@@ -112,5 +120,10 @@ func (a *AutonomyType) GetTypeMap() map[string]int32 {
"RvkPropChange": AutonomyActionRvkPropChange, "RvkPropChange": AutonomyActionRvkPropChange,
"VotePropChange": AutonomyActionVotePropChange, "VotePropChange": AutonomyActionVotePropChange,
"TmintPropChange": AutonomyActionTmintPropChange, "TmintPropChange": AutonomyActionTmintPropChange,
"PropItem": AutonomyActionPropItem,
"RvkPropItem": AutonomyActionRvkPropItem,
"VotePropItem": AutonomyActionVotePropItem,
"TmintPropItem": AutonomyActionTmintPropItem,
} }
} }
...@@ -964,17 +964,14 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip ...@@ -964,17 +964,14 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
//只在主链检查, 主链检查失败不会同步到平行链,主链成功,平行链默认成功 //只在主链检查, 主链检查失败不会同步到平行链,主链成功,平行链默认成功
if !cfg.IsPara() { if !cfg.IsPara() {
//fork之后采用 autonomy 检查模式 //fork之后采用 autonomy 检查模式
if cfg.IsDappFork(a.height, pt.ParaX, pt.ForkParaAutonomySuperGroup) {
confManager := types.ConfSub(cfg, manager.ManageX) confManager := types.ConfSub(cfg, manager.ManageX)
autonomyExec := confManager.GStr("autonomyExec") autonomyExec := confManager.GStr(types.AutonomyCfgKey)
if len(autonomyExec) <= 0 { if cfg.IsDappFork(a.height, pt.ParaX, pt.ForkParaAutonomySuperGroup) && len(autonomyExec) > 0 {
return nil, errors.Wrapf(types.ErrNotFound, "manager autonomy key not config")
}
//去autonomy 合约检验是否id approved, 成功 err返回nil //去autonomy 合约检验是否id approved, 成功 err返回nil
_, err := a.api.QueryChain(&types.ChainExecutor{ _, err := a.api.QueryChain(&types.ChainExecutor{
Driver: autonomyExec, Driver: autonomyExec,
FuncName: "IsAutonomyApprovedItem", FuncName: "IsAutonomyApprovedItem",
Param: types.Encode(&types.ReqStrings{Datas: []string{config.AutonomyItemID, config.Id}}), Param: types.Encode(&types.ReqMultiStrings{Datas: []string{config.AutonomyItemID, config.Id}}),
}) })
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "query autonomy,approveid=%s,hashId=%s", config.AutonomyItemID, config.Id) return nil, errors.Wrapf(err, "query autonomy,approveid=%s,hashId=%s", config.AutonomyItemID, config.Id)
......
...@@ -70,7 +70,7 @@ func InitFork(cfg *types.Chain33Config) { ...@@ -70,7 +70,7 @@ func InitFork(cfg *types.Chain33Config) {
cfg.RegisterDappFork(ParaX, ForkLoopCheckCommitTxDone, 3230000) cfg.RegisterDappFork(ParaX, ForkLoopCheckCommitTxDone, 3230000)
cfg.RegisterDappFork(ParaX, ForkParaAssetTransferRbk, 4500000) cfg.RegisterDappFork(ParaX, ForkParaAssetTransferRbk, 4500000)
cfg.RegisterDappFork(ParaX, ForkParaSupervision, 6000000) cfg.RegisterDappFork(ParaX, ForkParaSupervision, 6000000)
cfg.RegisterDappFork(ParaX, ForkParaAutonomySuperGroup, 10000000) cfg.RegisterDappFork(ParaX, ForkParaAutonomySuperGroup, 10200000)
//只在平行链启用 //只在平行链启用
cfg.RegisterDappFork(ParaX, ForkParaSelfConsStages, types.MaxHeight) cfg.RegisterDappFork(ParaX, ForkParaSelfConsStages, types.MaxHeight)
......
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