Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
d2526d02
Commit
d2526d02
authored
Nov 16, 2021
by
mdj33
Committed by
vipwzw
Nov 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autonomy add item proposal
parent
9c037e47
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
359 additions
and
52 deletions
+359
-52
docker-compose.sh
build/docker-compose.sh
+4
-0
chain33.para.toml
chain33.para.toml
+3
-2
chain33.para.toml.readme
chain33.para.toml.readme
+3
-2
chain33.toml
chain33.toml
+3
-0
para.go
plugin/consensus/para/para.go
+5
-5
paracreate.go
plugin/consensus/para/paracreate.go
+1
-1
proposal_board.go
plugin/dapp/autonomy/commands/proposal_board.go
+9
-0
proposal_item.go
plugin/dapp/autonomy/commands/proposal_item.go
+267
-0
exec.go
plugin/dapp/autonomy/executor/exec.go
+13
-0
item.go
plugin/dapp/autonomy/executor/item.go
+12
-23
itemaction.go
plugin/dapp/autonomy/executor/itemaction.go
+5
-9
query.go
plugin/dapp/autonomy/executor/query.go
+11
-1
item.proto
plugin/dapp/autonomy/proto/item.proto
+0
-1
const.go
plugin/dapp/autonomy/types/const.go
+5
-0
item.pb.go
plugin/dapp/autonomy/types/item.pb.go
+0
-0
types.go
plugin/dapp/autonomy/types/types.go
+13
-0
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+4
-7
type.go
plugin/dapp/paracross/types/type.go
+1
-1
No files found.
build/docker-compose.sh
View file @
d2526d02
...
...
@@ -132,6 +132,10 @@ function base_init() {
sed
-i
$sedfix
's/^enableReduceLocaldb=.*/enableReduceLocaldb=false/g'
chain33.toml
sed
-i
$sedfix
's/^enablePushSubscribe=.*/enablePushSubscribe=true/g'
chain33.toml
fi
#autonomy config
sed
-i
$sedfix
's/^autonomyExec =.*/autonomyExec=""/g'
chain33.toml
}
function
start
()
{
...
...
chain33.para.toml
View file @
d2526d02
...
...
@@ -113,8 +113,8 @@ ParaRemoteGrpcClient="localhost:8802"
startHeight
=
345850
#主链指定高度后等待块数,防止主链回滚,联盟链最小为1,小于1则采用缺省高度100
#waitMainBlockNum=100
#
打包时间间隔,单位
秒
writeBlock
Seconds
=
2
#
等待打包主链区块时间间隔,单位毫
秒
writeBlock
Msec
=
2000
#共识节点账户,共识节点需要配置自己的账户,并且钱包导入对应种子,非共识节点留空
authAccount
=
""
#创世地址额度
...
...
@@ -380,6 +380,7 @@ ForkUnfreezeIDX= 0
[fork.sub.autonomy]
Enable
=
0
ForkAutonomyDelRule
=
0
ForkAutonomyEnableItem
=
0
[fork.sub.jsvm]
Enable
=
0
...
...
chain33.para.toml.readme
View file @
d2526d02
...
...
@@ -118,8 +118,8 @@ ParaRemoteGrpcClient="localhost:8802"
startHeight=345850
#主链指定高度后等待块数,防止主链回滚,联盟链最小为1,小于1则采用缺省高度100
#waitMainBlockNum=100
#
检索主链最新区块时间间隔,单位
秒
writeBlock
Seconds=2
#
等待打包主链区块时间间隔,单位毫
秒
writeBlock
Msec=2000
#共识节点账户,共识节点需要配置自己的账户,并且钱包导入对应种子,非共识节点留空
authAccount=""
#创世地址额度
...
...
@@ -385,6 +385,7 @@ ForkUnfreezeIDX= 0
[fork.sub.autonomy]
Enable=0
ForkAutonomyDelRule=0
ForkAutonomyEnableItem=0
[fork.sub.jsvm]
Enable=0
...
...
chain33.toml
View file @
d2526d02
...
...
@@ -277,6 +277,9 @@ superManager=[
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
,
"1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK"
]
#autonomy执行器名字
autonomyExec
=
"autonomy"
[exec.sub.paracross]
nodeGroupFrozenCoins
=
0
#平行链共识停止后主链等待的高度
...
...
plugin/consensus/para/para.go
View file @
d2526d02
...
...
@@ -35,7 +35,7 @@ const (
//current miner tx take any privatekey for unify all nodes sign purpose, and para chain is free
minerPrivateKey
=
"6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
defaultGenesisAmount
int64
=
1e8
poolMainBlock
Sec
int64
=
5
poolMainBlock
Msec
int64
=
5000
defaultEmptyBlockInterval
int64
=
50
//write empty block every interval blocks in mainchain
defaultSearchMatchedBlockDepth
int32
=
10000
)
...
...
@@ -70,7 +70,7 @@ type client struct {
}
type
subConfig
struct
{
WriteBlock
Seconds
int64
`json:"writeBlockSeconds
,omitempty"`
WriteBlock
Msec
int64
`json:"writeBlockMsec
,omitempty"`
ParaRemoteGrpcClient
string
`json:"paraRemoteGrpcClient,omitempty"`
StartHeight
int64
`json:"startHeight,omitempty"`
WaitMainBlockNum
int64
`json:"waitMainBlockNum,omitempty"`
...
...
@@ -105,8 +105,8 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
subcfg
.
GenesisAmount
=
defaultGenesisAmount
}
if
subcfg
.
WriteBlock
Seconds
<=
0
{
subcfg
.
WriteBlock
Seconds
=
poolMainBlockS
ec
if
subcfg
.
WriteBlock
Msec
<=
0
{
subcfg
.
WriteBlock
Msec
=
poolMainBlockMs
ec
}
//WaitMainBlockNum 配置最小为1,因为genesis块是startHeight-1, wait=1和startHeight相等
...
...
@@ -291,7 +291,7 @@ func (client *client) GetStartMainHash(height int64) []byte {
}
if
height
>
0
{
hint
:=
time
.
NewTicker
(
time
.
Second
*
time
.
Duration
(
client
.
subCfg
.
WriteBlockSeconds
)
)
hint
:=
time
.
NewTicker
(
time
.
Second
)
for
lastHeight
<
height
+
client
.
subCfg
.
WaitMainBlockNum
{
select
{
case
<-
hint
.
C
:
...
...
plugin/consensus/para/paracreate.go
View file @
d2526d02
...
...
@@ -537,7 +537,7 @@ out:
if
err
==
nil
{
continue
}
time
.
Sleep
(
time
.
Second
*
time
.
Duration
(
client
.
subCfg
.
WriteBlockSeconds
))
time
.
Sleep
(
time
.
Millisecond
*
time
.
Duration
(
client
.
subCfg
.
WriteBlockMsec
))
continue
}
...
...
plugin/dapp/autonomy/commands/proposal_board.go
View file @
d2526d02
...
...
@@ -69,6 +69,15 @@ func AutonomyCmd() *cobra.Command {
ShowProposalChangeCmd
(),
)
// item
cmd
.
AddCommand
(
ProposalItemCmd
(),
RevokeProposalItemCmd
(),
VoteProposalItemCmd
(),
TerminateProposalItemCmd
(),
ShowProposalItemCmd
(),
)
return
cmd
}
...
...
plugin/dapp/autonomy/commands/proposal_item.go
0 → 100644
View file @
d2526d02
// 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
()
}
plugin/dapp/autonomy/executor/exec.go
View file @
d2526d02
...
...
@@ -7,6 +7,7 @@ package executor
import
(
"github.com/33cn/chain33/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
// Exec_PropChange 创建事项规则
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
))
return
action
.
propItem
(
payload
)
}
// Exec_RvkPropItem 撤销事项规则
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
))
return
action
.
rvkPropItem
(
payload
)
}
// Exec_VotePropItem 投票事项规则
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
))
return
action
.
votePropItem
(
payload
)
}
// Exec_TmintPropItem 终止事项规则
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
))
return
action
.
tmintPropItem
(
payload
)
}
plugin/dapp/autonomy/executor/item.go
View file @
d2526d02
...
...
@@ -5,7 +5,6 @@
package
executor
import
(
"fmt"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
...
...
@@ -108,7 +107,7 @@ func (a *Autonomy) listProposalItem(req *auty.ReqQueryProposalItem) (types.Messa
return
&
rep
,
nil
}
func
getProposalItem
Db
(
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
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"invalid parameter"
)
}
...
...
@@ -127,48 +126,38 @@ func getProposalItemDb(db dbm.KV, req *types.ReqString) (*auty.ReplyQueryProposa
}
// IsAutonomyApprovedItem get 2 parameters: autonomyItemID, applyTxHash
func
IsAutonomyApprovedItem
(
db
dbm
.
KV
,
req
*
types
.
ReqStrings
)
(
types
.
Message
,
error
)
{
rep
:=
&
types
.
Reply
{
IsOk
:
false
}
func
IsAutonomyApprovedItem
(
db
dbm
.
KV
,
req
*
types
.
ReqMultiStrings
)
(
types
.
Message
,
error
)
{
if
req
==
nil
{
rep
.
Msg
=
[]
byte
(
"req is nill"
)
return
rep
,
types
.
ErrInvalidParam
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"req is nil"
)
}
if
len
(
req
.
Datas
)
<
2
{
rep
.
Msg
=
[]
byte
(
"req datas less 2 parameters"
)
return
rep
,
types
.
ErrInvalidParam
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"req datas less 2 parameters"
)
}
autonomyItemID
:=
req
.
Datas
[
0
]
applyTxHash
:=
req
.
Datas
[
1
]
res
,
err
:=
getProposalItem
Db
(
db
,
&
types
.
ReqString
{
Data
:
autonomyItemID
})
res
,
err
:=
getProposalItem
(
db
,
&
types
.
ReqString
{
Data
:
autonomyItemID
})
if
err
!=
nil
{
rep
.
Msg
=
[]
byte
(
err
.
Error
())
return
rep
,
err
return
nil
,
err
}
if
len
(
res
.
GetPropItems
())
<=
0
{
rep
.
Msg
=
[]
byte
(
"not found item"
)
return
rep
,
types
.
ErrNotFound
return
nil
,
errors
.
Wrapf
(
types
.
ErrNotFound
,
"not get item"
)
}
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
rep
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"item id=%s,req=%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
)
}
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
rep
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"item txHash=%s,req=%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
)
}
if
res
.
PropItems
[
0
]
.
Status
==
auty
.
AutonomyStatusTmintPropItem
&&
res
.
PropItems
[
0
]
.
BoardVoteRes
.
Pass
{
rep
.
IsOk
=
true
return
rep
,
nil
return
&
types
.
Reply
{
IsOk
:
true
},
nil
}
if
res
.
PropItems
[
0
]
.
Status
!=
auty
.
AutonomyStatusTmintPropItem
{
rep
.
Msg
=
[]
byte
(
fmt
.
Sprintf
(
"item status =%d not terminate"
,
res
.
PropItems
[
0
]
.
Status
))
return
rep
,
errors
.
Wrapf
(
types
.
ErrNotAllow
,
"item status =%d not terminate"
,
res
.
PropItems
[
0
]
.
Status
)
return
nil
,
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
rep
,
errors
.
Wrap
(
types
.
ErrNotAllow
,
"item vote status not pass"
)
return
nil
,
errors
.
Wrapf
(
types
.
ErrNotAllow
,
"item vote status not pass = %v"
,
res
.
PropItems
[
0
]
.
BoardVoteRes
.
Pass
)
}
plugin/dapp/autonomy/executor/itemaction.go
View file @
d2526d02
...
...
@@ -16,11 +16,7 @@ const (
)
func
(
a
*
action
)
propItem
(
prob
*
auty
.
ProposalItem
)
(
*
types
.
Receipt
,
error
)
{
//itemTx 不能等待太久,太久需要重新申请
if
a
.
height
>
prob
.
ItemTxBlockHeight
+
itemWaitBlockNumber
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"itemTx wait too long, curHeight=%d,itemTx=%d"
,
a
.
height
,
prob
.
ItemTxBlockHeight
)
}
//start和end之间不能小于720高度,end不能超过当前高度+100w
if
prob
.
StartBlockHeight
<
a
.
height
||
prob
.
StartBlockHeight
>=
prob
.
EndBlockHeight
||
prob
.
StartBlockHeight
+
startEndBlockPeriod
>
prob
.
EndBlockHeight
||
prob
.
EndBlockHeight
>
a
.
height
+
propEndBlockPeriod
||
...
...
@@ -179,7 +175,7 @@ func (a *action) votePropItem(voteProb *auty.VoteProposalItem) (*types.Receipt,
if
err
!=
nil
{
alog
.
Error
(
"votePropItem "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"checkVotesRecord boardVotesRecord failed"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
return
nil
,
err
ors
.
Wrapf
(
err
,
"check votes record from addr=%s"
,
a
.
fromaddr
)
}
// 更新已经投票地址
...
...
@@ -242,7 +238,7 @@ func (a *action) tmintPropItem(tmintProb *auty.TerminateProposalItem) (*types.Re
if
err
!=
nil
{
alog
.
Error
(
"tmintPropItem "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"getProposalItem failed"
,
tmintProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
return
nil
,
err
ors
.
Wrapf
(
err
,
"get item id=%s"
,
tmintProb
.
ProposalID
)
}
pre
:=
copyAutonomyProposalItem
(
cur
)
...
...
@@ -252,7 +248,7 @@ func (a *action) tmintPropItem(tmintProb *auty.TerminateProposalItem) (*types.Re
err
:=
auty
.
ErrProposalStatus
alog
.
Error
(
"tmintPropItem "
,
"addr"
,
a
.
fromaddr
,
"status"
,
cur
.
Status
,
"status is not match"
,
tmintProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
return
nil
,
err
ors
.
Wrapf
(
err
,
"cur status=%d"
,
cur
.
Status
)
}
// 董事会投票期间不能终止
...
...
@@ -261,7 +257,7 @@ func (a *action) tmintPropItem(tmintProb *auty.TerminateProposalItem) (*types.Re
err
:=
auty
.
ErrTerminatePeriod
alog
.
Error
(
"tmintPropItem "
,
"addr"
,
a
.
fromaddr
,
"status"
,
cur
.
Status
,
"height"
,
a
.
height
,
"in board vote period can not terminate"
,
tmintProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
return
nil
,
err
ors
.
Wrapf
(
err
,
"vote period not should be terminated"
)
}
if
cur
.
BoardVoteRes
.
TotalVotes
!=
0
&&
cur
.
BoardVoteRes
.
TotalVotes
>
cur
.
BoardVoteRes
.
QuitVotes
&&
...
...
plugin/dapp/autonomy/executor/query.go
View file @
d2526d02
...
...
@@ -64,7 +64,17 @@ func (a *Autonomy) Query_ListProposalChange(in *auty.ReqQueryProposalChange) (ty
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 查询提案修改董事会成员
func
(
a
*
Autonomy
)
Query_IsAutonomyApprovedItem
(
in
*
types
.
ReqStrings
)
(
types
.
Message
,
error
)
{
func
(
a
*
Autonomy
)
Query_IsAutonomyApprovedItem
(
in
*
types
.
Req
Multi
Strings
)
(
types
.
Message
,
error
)
{
return
IsAutonomyApprovedItem
(
a
.
GetStateDB
(),
in
)
}
plugin/dapp/autonomy/proto/item.proto
View file @
d2526d02
...
...
@@ -35,7 +35,6 @@ message ProposalItem {
// 项目相关
string
itemTxHash
=
4
;
// item tx hash
string
exec
=
5
;
// 合约执行器
int64
itemTxBlockHeight
=
6
;
//需要设置区块高度,太久的item不处理
string
description
=
7
;
// 简述
// 投票相关
...
...
plugin/dapp/autonomy/types/const.go
View file @
d2526d02
...
...
@@ -129,6 +129,11 @@ const (
GetProposalChange
=
"GetProposalChange"
// ListProposalChange 查询多个
ListProposalChange
=
"ListProposalChange"
// GetProposalItem 用于在cmd里面的区分不同的查询
GetProposalItem
=
"GetProposalItem"
// ListProposalItem 查询多个
ListProposalItem
=
"ListProposalItem"
)
//包的名字可以通过配置文件来配置
...
...
plugin/dapp/autonomy/types/item.pb.go
0 → 100644
View file @
d2526d02
This diff is collapsed.
Click to expand it.
plugin/dapp/autonomy/types/types.go
View file @
d2526d02
...
...
@@ -15,6 +15,8 @@ var name string
var
(
//ForkAutonomyDelRule fork for delete boards member rules
ForkAutonomyDelRule
=
"ForkAutonomyDelRule"
//ForkAutonomyEnableItem fork for add autonomy item support
ForkAutonomyEnableItem
=
"ForkAutonomyEnableItem"
)
func
init
()
{
...
...
@@ -28,6 +30,7 @@ func init() {
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
cfg
.
RegisterDappFork
(
AutonomyX
,
"Enable"
,
0
)
cfg
.
RegisterDappFork
(
AutonomyX
,
ForkAutonomyDelRule
,
9500000
)
cfg
.
RegisterDappFork
(
AutonomyX
,
ForkAutonomyEnableItem
,
10000000
)
}
//InitExecutor ...
...
...
@@ -78,6 +81,11 @@ func (a *AutonomyType) GetLogMap() map[int64]*types.LogInfo {
TyLogRvkPropChange
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptProposalChange
{}),
Name
:
"LogRvkPropChange"
},
TyLogVotePropChange
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptProposalChange
{}),
Name
:
"LogVotePropChange"
},
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 {
"RvkPropChange"
:
AutonomyActionRvkPropChange
,
"VotePropChange"
:
AutonomyActionVotePropChange
,
"TmintPropChange"
:
AutonomyActionTmintPropChange
,
"PropItem"
:
AutonomyActionPropItem
,
"RvkPropItem"
:
AutonomyActionRvkPropItem
,
"VotePropItem"
:
AutonomyActionVotePropItem
,
"TmintPropItem"
:
AutonomyActionTmintPropItem
,
}
}
plugin/dapp/paracross/executor/superaccount.go
View file @
d2526d02
...
...
@@ -964,17 +964,14 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
//只在主链检查, 主链检查失败不会同步到平行链,主链成功,平行链默认成功
if
!
cfg
.
IsPara
()
{
//fork之后采用 autonomy 检查模式
if
cfg
.
IsDappFork
(
a
.
height
,
pt
.
ParaX
,
pt
.
ForkParaAutonomySuperGroup
)
{
confManager
:=
types
.
ConfSub
(
cfg
,
manager
.
ManageX
)
autonomyExec
:=
confManager
.
GStr
(
"autonomyExec"
)
if
len
(
autonomyExec
)
<=
0
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrNotFound
,
"manager autonomy key not config"
)
}
confManager
:=
types
.
ConfSub
(
cfg
,
manager
.
ManageX
)
autonomyExec
:=
confManager
.
GStr
(
types
.
AutonomyCfgKey
)
if
cfg
.
IsDappFork
(
a
.
height
,
pt
.
ParaX
,
pt
.
ForkParaAutonomySuperGroup
)
&&
len
(
autonomyExec
)
>
0
{
//去autonomy 合约检验是否id approved, 成功 err返回nil
_
,
err
:=
a
.
api
.
QueryChain
(
&
types
.
ChainExecutor
{
Driver
:
autonomyExec
,
FuncName
:
"IsAutonomyApprovedItem"
,
Param
:
types
.
Encode
(
&
types
.
ReqStrings
{
Datas
:
[]
string
{
config
.
AutonomyItemID
,
config
.
Id
}}),
Param
:
types
.
Encode
(
&
types
.
Req
Multi
Strings
{
Datas
:
[]
string
{
config
.
AutonomyItemID
,
config
.
Id
}}),
})
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"query autonomy,approveid=%s,hashId=%s"
,
config
.
AutonomyItemID
,
config
.
Id
)
...
...
plugin/dapp/paracross/types/type.go
View file @
d2526d02
...
...
@@ -70,7 +70,7 @@ func InitFork(cfg *types.Chain33Config) {
cfg
.
RegisterDappFork
(
ParaX
,
ForkLoopCheckCommitTxDone
,
3230000
)
cfg
.
RegisterDappFork
(
ParaX
,
ForkParaAssetTransferRbk
,
4500000
)
cfg
.
RegisterDappFork
(
ParaX
,
ForkParaSupervision
,
6000000
)
cfg
.
RegisterDappFork
(
ParaX
,
ForkParaAutonomySuperGroup
,
10
0
00000
)
cfg
.
RegisterDappFork
(
ParaX
,
ForkParaAutonomySuperGroup
,
10
2
00000
)
//只在平行链启用
cfg
.
RegisterDappFork
(
ParaX
,
ForkParaSelfConsStages
,
types
.
MaxHeight
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment