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
9c037e47
Commit
9c037e47
authored
Nov 15, 2021
by
mdj33
Committed by
vipwzw
Nov 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autonomy add item proposal
parent
4763c2ca
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
802 additions
and
12 deletions
+802
-12
chain33.toml
chain33.toml
+1
-1
go.mod
go.mod
+1
-1
exec.go
plugin/dapp/autonomy/executor/exec.go
+24
-0
exec_local.go
plugin/dapp/autonomy/executor/exec_local.go
+20
-0
item.go
plugin/dapp/autonomy/executor/item.go
+174
-0
itemaction.go
plugin/dapp/autonomy/executor/itemaction.go
+346
-0
itemtable.go
plugin/dapp/autonomy/executor/itemtable.go
+73
-0
kv.go
plugin/dapp/autonomy/executor/kv.go
+9
-0
projectaction.go
plugin/dapp/autonomy/executor/projectaction.go
+2
-2
query.go
plugin/dapp/autonomy/executor/query.go
+5
-0
autonomy.proto
plugin/dapp/autonomy/proto/autonomy.proto
+8
-0
item.proto
plugin/dapp/autonomy/proto/item.proto
+87
-0
const.go
plugin/dapp/autonomy/types/const.go
+18
-0
config.go
plugin/dapp/mix/executor/config.go
+2
-3
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+23
-3
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+1
-0
type.go
plugin/dapp/paracross/types/type.go
+8
-2
No files found.
chain33.toml
View file @
9c037e47
...
@@ -307,7 +307,7 @@ pointHX="19172955941344617222923168298456110557655645809646772800021167670156933
...
@@ -307,7 +307,7 @@ pointHX="19172955941344617222923168298456110557655645809646772800021167670156933
pointHY
=
"21116962883761739586121793871108889864627195706475546685847911817475098399811"
pointHY
=
"21116962883761739586121793871108889864627195706475546685847911817475098399811"
#电路最大支持1024个叶子hash,10 level, 配置可以小于1024,但不能大于
#电路最大支持1024个叶子hash,10 level, 配置可以小于1024,但不能大于
maxTreeLeaves
=
1024
maxTreeLeaves
=
1024
mixApprs
=[]
[metrics]
[metrics]
#是否使能发送metrics数据的发送
#是否使能发送metrics数据的发送
...
...
go.mod
View file @
9c037e47
module github.com/33cn/plugin
module github.com/33cn/plugin
go 1.15
go 1.15
replace github.com/33cn/chain33 => /home/pony/go/src/github.com/33cn/chain33
require (
require (
github.com/33cn/chain33 v1.65.6-0.20211025083411-82c4406c6701
github.com/33cn/chain33 v1.65.6-0.20211025083411-82c4406c6701
github.com/BurntSushi/toml v0.3.1
github.com/BurntSushi/toml v0.3.1
...
...
plugin/dapp/autonomy/executor/exec.go
View file @
9c037e47
...
@@ -130,3 +130,27 @@ func (a *Autonomy) Exec_TmintPropChange(payload *auty.TerminateProposalChange, t
...
@@ -130,3 +130,27 @@ func (a *Autonomy) Exec_TmintPropChange(payload *auty.TerminateProposalChange, t
action
:=
newAction
(
a
,
tx
,
int32
(
index
))
action
:=
newAction
(
a
,
tx
,
int32
(
index
))
return
action
.
tmintPropChange
(
payload
)
return
action
.
tmintPropChange
(
payload
)
}
}
// Exec_PropChange 创建事项规则
func
(
a
*
Autonomy
)
Exec_PropItem
(
payload
*
auty
.
ProposalItem
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
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
)
{
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
)
{
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
)
{
action
:=
newAction
(
a
,
tx
,
int32
(
index
))
return
action
.
tmintPropItem
(
payload
)
}
plugin/dapp/autonomy/executor/exec_local.go
View file @
9c037e47
...
@@ -106,3 +106,23 @@ func (a *Autonomy) ExecLocal_VotePropChange(payload *auty.VoteProposalChange, tx
...
@@ -106,3 +106,23 @@ func (a *Autonomy) ExecLocal_VotePropChange(payload *auty.VoteProposalChange, tx
func
(
a
*
Autonomy
)
ExecLocal_TmintPropChange
(
payload
*
auty
.
TerminateProposalChange
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_TmintPropChange
(
payload
*
auty
.
TerminateProposalChange
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execAutoLocalChange
(
tx
,
receiptData
)
return
a
.
execAutoLocalChange
(
tx
,
receiptData
)
}
}
// ExecLocal_PropItem 创建事项规则
func
(
a
*
Autonomy
)
ExecLocal_PropItem
(
payload
*
auty
.
ProposalItem
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execAutoLocalItem
(
tx
,
receiptData
)
}
// ExecLocal_RvkPropItem 撤销事项规则
func
(
a
*
Autonomy
)
ExecLocal_RvkPropItem
(
payload
*
auty
.
RevokeProposalItem
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execAutoLocalItem
(
tx
,
receiptData
)
}
// ExecLocal_VotePropItem 投票事项规则
func
(
a
*
Autonomy
)
ExecLocal_VotePropItem
(
payload
*
auty
.
VoteProposalItem
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execAutoLocalItem
(
tx
,
receiptData
)
}
// ExecLocal_TmintPropItem 终止事项规则
func
(
a
*
Autonomy
)
ExecLocal_TmintPropItem
(
payload
*
auty
.
TerminateProposalItem
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execAutoLocalItem
(
tx
,
receiptData
)
}
plugin/dapp/autonomy/executor/item.go
0 → 100644
View file @
9c037e47
// 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
executor
import
(
"fmt"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/pkg/errors"
)
func
(
a
*
Autonomy
)
execAutoLocalItem
(
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
set
,
err
:=
a
.
execLocalItem
(
receiptData
)
if
err
!=
nil
{
return
set
,
err
}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
a
.
AddRollbackKV
(
tx
,
tx
.
Execer
,
set
.
KV
)
return
dbSet
,
nil
}
func
(
a
*
Autonomy
)
execLocalItem
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
table
:=
NewItemTable
(
a
.
GetLocalDB
())
for
_
,
log
:=
range
receiptData
.
Logs
{
switch
log
.
Ty
{
case
auty
.
TyLogPropItem
,
auty
.
TyLogRvkPropItem
,
auty
.
TyLogVotePropItem
,
auty
.
TyLogTmintPropItem
:
{
var
receipt
auty
.
ReceiptProposalItem
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
return
nil
,
err
}
err
=
table
.
Replace
(
receipt
.
Current
)
if
err
!=
nil
{
return
nil
,
err
}
}
default
:
break
}
}
kvs
,
err
:=
table
.
Save
()
if
err
!=
nil
{
return
nil
,
err
}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
dbSet
,
nil
}
func
(
a
*
Autonomy
)
listProposalItem
(
req
*
auty
.
ReqQueryProposalItem
)
(
types
.
Message
,
error
)
{
if
req
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
localDb
:=
a
.
GetLocalDB
()
query
:=
NewItemTable
(
localDb
)
.
GetQuery
(
localDb
)
var
primary
[]
byte
if
req
.
Height
>
0
{
primary
=
[]
byte
(
dapp
.
HeightIndexStr
(
req
.
Height
,
int64
(
req
.
Index
)))
}
indexName
:=
""
if
req
.
Status
>
0
&&
req
.
Addr
!=
""
{
indexName
=
"addr_status"
}
else
if
req
.
Status
>
0
{
indexName
=
"status"
}
else
if
req
.
Addr
!=
""
{
indexName
=
"addr"
}
cur
:=
&
ItemRow
{
AutonomyProposalItem
:
&
auty
.
AutonomyProposalItem
{},
}
cur
.
Address
=
req
.
Addr
cur
.
Status
=
req
.
Status
cur
.
Height
=
req
.
Height
cur
.
Index
=
req
.
Index
prefix
,
err
:=
cur
.
Get
(
indexName
)
if
err
!=
nil
{
alog
.
Error
(
"Get"
,
"indexName"
,
indexName
,
"err"
,
err
)
return
nil
,
err
}
rows
,
err
:=
query
.
ListIndex
(
indexName
,
prefix
,
primary
,
req
.
Count
,
req
.
Direction
)
if
err
!=
nil
{
alog
.
Error
(
"query List failed"
,
"indexName"
,
indexName
,
"prefix"
,
"prefix"
,
"key"
,
string
(
primary
),
"err"
,
err
)
return
nil
,
err
}
if
len
(
rows
)
==
0
{
return
nil
,
types
.
ErrNotFound
}
var
rep
auty
.
ReplyQueryProposalItem
for
_
,
row
:=
range
rows
{
r
,
ok
:=
row
.
Data
.
(
*
auty
.
AutonomyProposalItem
)
if
!
ok
{
alog
.
Error
(
"listProposalItem"
,
"err"
,
"bad row type"
)
return
nil
,
types
.
ErrDecode
}
rep
.
PropItems
=
append
(
rep
.
PropItems
,
r
)
}
return
&
rep
,
nil
}
func
getProposalItemDb
(
db
dbm
.
KV
,
req
*
types
.
ReqString
)
(
*
auty
.
ReplyQueryProposalItem
,
error
)
{
if
req
==
nil
||
len
(
req
.
Data
)
<=
0
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"invalid parameter"
)
}
value
,
err
:=
db
.
Get
(
propItemID
(
req
.
Data
))
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"fail,db.get item id=%s"
,
req
.
Data
)
}
prop
:=
&
auty
.
AutonomyProposalItem
{}
err
=
types
.
Decode
(
value
,
prop
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"decode item fail"
)
}
rep
:=
&
auty
.
ReplyQueryProposalItem
{}
rep
.
PropItems
=
append
(
rep
.
PropItems
,
prop
)
return
rep
,
nil
}
// IsAutonomyApprovedItem get 2 parameters: autonomyItemID, applyTxHash
func
IsAutonomyApprovedItem
(
db
dbm
.
KV
,
req
*
types
.
ReqStrings
)
(
types
.
Message
,
error
)
{
rep
:=
&
types
.
Reply
{
IsOk
:
false
}
if
req
==
nil
{
rep
.
Msg
=
[]
byte
(
"req is nill"
)
return
rep
,
types
.
ErrInvalidParam
}
if
len
(
req
.
Datas
)
<
2
{
rep
.
Msg
=
[]
byte
(
"req datas less 2 parameters"
)
return
rep
,
types
.
ErrInvalidParam
}
autonomyItemID
:=
req
.
Datas
[
0
]
applyTxHash
:=
req
.
Datas
[
1
]
res
,
err
:=
getProposalItemDb
(
db
,
&
types
.
ReqString
{
Data
:
autonomyItemID
})
if
err
!=
nil
{
rep
.
Msg
=
[]
byte
(
err
.
Error
())
return
rep
,
err
}
if
len
(
res
.
GetPropItems
())
<=
0
{
rep
.
Msg
=
[]
byte
(
"not found item"
)
return
rep
,
types
.
ErrNotFound
}
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
)
}
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
)
}
if
res
.
PropItems
[
0
]
.
Status
==
auty
.
AutonomyStatusTmintPropItem
&&
res
.
PropItems
[
0
]
.
BoardVoteRes
.
Pass
{
rep
.
IsOk
=
true
return
rep
,
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
)
}
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"
)
}
plugin/dapp/autonomy/executor/itemaction.go
0 → 100644
View file @
9c037e47
// 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
executor
import
(
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/pkg/errors"
)
const
(
itemWaitBlockNumber
=
40
*
1000
//4w高度,大概2天
)
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
)
}
if
prob
.
StartBlockHeight
<
a
.
height
||
prob
.
StartBlockHeight
>=
prob
.
EndBlockHeight
||
prob
.
StartBlockHeight
+
startEndBlockPeriod
>
prob
.
EndBlockHeight
||
prob
.
EndBlockHeight
>
a
.
height
+
propEndBlockPeriod
||
prob
.
RealEndBlockHeight
!=
0
{
return
nil
,
errors
.
Wrapf
(
auty
.
ErrSetBlockHeight
,
"propItem exe height=%d,start=%d,end=%d,realEnd=%d"
,
a
.
height
,
prob
.
StartBlockHeight
,
prob
.
EndBlockHeight
,
prob
.
RealEndBlockHeight
)
}
if
len
(
prob
.
ItemTxHash
)
<=
0
{
return
nil
,
errors
.
Wrap
(
types
.
ErrInvalidParam
,
"propItem tx hash nil"
)
}
// 获取董事会成员
pboard
,
err
:=
a
.
getActiveBoard
()
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"propItem.getActiveBoard"
)
}
// 获取当前生效提案规则
rule
,
err
:=
a
.
getActiveRule
()
if
err
!=
nil
{
alog
.
Error
(
"propItem "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"getActiveRule failed"
,
err
)
return
nil
,
err
}
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
// 冻结提案金
receipt
,
err
:=
a
.
coinsAccount
.
ExecFrozen
(
a
.
fromaddr
,
a
.
execaddr
,
rule
.
ProposalAmount
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"propItem.accountFrozen,proposalAmount=%d,addr=%s"
,
rule
.
ProposalAmount
,
a
.
fromaddr
)
}
logs
=
append
(
logs
,
receipt
.
Logs
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
cur
:=
&
auty
.
AutonomyProposalItem
{
PropItem
:
prob
,
CurRule
:
rule
,
Boards
:
pboard
.
Boards
,
BoardVoteRes
:
&
auty
.
VoteResult
{
TotalVotes
:
int32
(
len
(
pboard
.
Boards
))},
Status
:
auty
.
AutonomyStatusProposalItem
,
Address
:
a
.
fromaddr
,
Height
:
a
.
height
,
Index
:
a
.
index
,
ProposalID
:
common
.
ToHex
(
a
.
txhash
),
}
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
propItemID
(
common
.
ToHex
(
a
.
txhash
)),
Value
:
types
.
Encode
(
cur
)})
receiptLog
:=
getItemReceiptLog
(
nil
,
cur
,
auty
.
TyLogPropItem
)
logs
=
append
(
logs
,
receiptLog
)
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
func
(
a
*
action
)
rvkPropItem
(
rvkProb
*
auty
.
RevokeProposalItem
)
(
*
types
.
Receipt
,
error
)
{
cur
,
err
:=
a
.
getProposalItem
(
rvkProb
.
ProposalID
)
if
err
!=
nil
{
alog
.
Error
(
"rvkPropItem "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"getProposalItem failed"
,
rvkProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
errors
.
Wrapf
(
err
,
"rvkPropItem.getItem,id=%s"
,
rvkProb
.
ProposalID
)
}
pre
:=
copyAutonomyProposalItem
(
cur
)
// 检查当前状态
if
cur
.
Status
!=
auty
.
AutonomyStatusProposalItem
{
err
:=
auty
.
ErrProposalStatus
alog
.
Error
(
"rvkPropItem "
,
"addr"
,
a
.
fromaddr
,
"status"
,
cur
.
Status
,
"status is not match"
,
rvkProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
errors
.
Wrapf
(
err
,
"rvkPropItem wrong status =%d"
,
cur
.
Status
)
}
start
:=
cur
.
GetPropItem
()
.
StartBlockHeight
if
a
.
height
>=
start
{
err
:=
auty
.
ErrRevokeProposalPeriod
alog
.
Error
(
"rvkPropItem "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"ProposalID"
,
rvkProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
errors
.
Wrapf
(
err
,
"rvkPropItem item started, startheight=%d,cur=%d"
,
start
,
a
.
height
)
}
if
a
.
fromaddr
!=
cur
.
Address
{
err
:=
auty
.
ErrRevokeProposalPower
alog
.
Error
(
"rvkPropItem "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"ProposalID"
,
rvkProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
errors
.
Wrapf
(
err
,
"rvkPropItem wrong from addr, from=%s,,cur=%s"
,
a
.
fromaddr
,
cur
.
Address
)
}
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
// 解冻提案金
receipt
,
err
:=
a
.
coinsAccount
.
ExecActive
(
a
.
fromaddr
,
a
.
execaddr
,
cur
.
CurRule
.
ProposalAmount
)
if
err
!=
nil
{
alog
.
Error
(
"rvkPropItem "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"ExecActive amount"
,
cur
.
CurRule
.
ProposalAmount
,
"err"
,
err
)
return
nil
,
err
}
logs
=
append
(
logs
,
receipt
.
Logs
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
cur
.
Status
=
auty
.
AutonomyStatusRvkPropItem
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
propItemID
(
rvkProb
.
ProposalID
),
Value
:
types
.
Encode
(
cur
)})
receiptLog
:=
getItemReceiptLog
(
pre
,
cur
,
auty
.
TyLogRvkPropItem
)
logs
=
append
(
logs
,
receiptLog
)
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
func
(
a
*
action
)
votePropItem
(
voteProb
*
auty
.
VoteProposalItem
)
(
*
types
.
Receipt
,
error
)
{
cur
,
err
:=
a
.
getProposalItem
(
voteProb
.
ProposalID
)
if
err
!=
nil
{
alog
.
Error
(
"votePropItem "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"getProposalItem failed"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
errors
.
Wrapf
(
err
,
"votePropItem.getItem id=%s"
,
voteProb
.
ProposalID
)
}
pre
:=
copyAutonomyProposalItem
(
cur
)
// 检查当前状态
if
cur
.
Status
==
auty
.
AutonomyStatusRvkPropItem
||
cur
.
Status
==
auty
.
AutonomyStatusTmintPropItem
{
err
:=
auty
.
ErrProposalStatus
alog
.
Error
(
"votePropItem "
,
"addr"
,
a
.
fromaddr
,
"status"
,
cur
.
Status
,
"ProposalID"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
errors
.
Wrapf
(
err
,
"votePropItem cur status=%d"
,
cur
.
Status
)
}
start
:=
cur
.
GetPropItem
()
.
StartBlockHeight
end
:=
cur
.
GetPropItem
()
.
EndBlockHeight
realHeight
:=
cur
.
GetPropItem
()
.
RealEndBlockHeight
if
a
.
height
<
start
||
a
.
height
>
end
||
realHeight
!=
0
{
err
:=
auty
.
ErrVotePeriod
alog
.
Error
(
"votePropItem "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"ProposalID"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
errors
.
Wrapf
(
err
,
"votePropItem current height=%d,start=%d,end=%d,real=%d"
,
a
.
height
,
start
,
end
,
realHeight
)
}
// 董事会成员验证
var
isBoard
bool
for
_
,
addr
:=
range
cur
.
Boards
{
if
addr
==
a
.
fromaddr
{
isBoard
=
true
break
}
}
if
!
isBoard
{
err
=
auty
.
ErrNoActiveBoard
alog
.
Error
(
"votePropItem "
,
"addr"
,
a
.
fromaddr
,
"this addr is not active board member"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
errors
.
Wrapf
(
err
,
"fromAddr notActiveBoardMember proposalid=%s"
,
voteProb
.
ProposalID
)
}
// 检查是否已经参与投票
votes
,
err
:=
a
.
checkVotesRecord
([]
string
{
a
.
fromaddr
},
boardVotesRecord
(
voteProb
.
ProposalID
))
if
err
!=
nil
{
alog
.
Error
(
"votePropItem "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"checkVotesRecord boardVotesRecord failed"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
// 更新已经投票地址
votes
.
Address
=
append
(
votes
.
Address
,
a
.
fromaddr
)
// 更新投票结果
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
)
}
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
// 首次进入投票期,即将提案金转入自治系统地址
if
cur
.
Status
==
auty
.
AutonomyStatusProposalItem
{
receipt
,
err
:=
a
.
coinsAccount
.
ExecTransferFrozen
(
cur
.
Address
,
a
.
execaddr
,
a
.
execaddr
,
cur
.
CurRule
.
ProposalAmount
)
if
err
!=
nil
{
alog
.
Error
(
"votePropItem "
,
"addr"
,
cur
.
Address
,
"execaddr"
,
a
.
execaddr
,
"ExecTransferFrozen amount fail"
,
err
)
return
nil
,
err
}
logs
=
append
(
logs
,
receipt
.
Logs
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
}
if
cur
.
BoardVoteRes
.
TotalVotes
!=
0
&&
cur
.
BoardVoteRes
.
TotalVotes
>
cur
.
BoardVoteRes
.
QuitVotes
&&
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
)
/
float32
(
cur
.
BoardVoteRes
.
TotalVotes
-
cur
.
BoardVoteRes
.
QuitVotes
)
>=
float32
(
cur
.
CurRule
.
BoardApproveRatio
)
/
100.0
{
cur
.
BoardVoteRes
.
Pass
=
true
cur
.
PropItem
.
RealEndBlockHeight
=
a
.
height
}
key
:=
propItemID
(
voteProb
.
ProposalID
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropItem
if
cur
.
BoardVoteRes
.
Pass
{
cur
.
Status
=
auty
.
AutonomyStatusTmintPropItem
}
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
cur
)})
// 更新VotesRecord
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
boardVotesRecord
(
voteProb
.
ProposalID
),
Value
:
types
.
Encode
(
votes
)})
ty
:=
auty
.
TyLogVotePropItem
if
cur
.
BoardVoteRes
.
Pass
{
ty
=
auty
.
TyLogTmintPropItem
}
receiptLog
:=
getItemReceiptLog
(
pre
,
cur
,
int32
(
ty
))
logs
=
append
(
logs
,
receiptLog
)
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
func
(
a
*
action
)
tmintPropItem
(
tmintProb
*
auty
.
TerminateProposalItem
)
(
*
types
.
Receipt
,
error
)
{
cur
,
err
:=
a
.
getProposalItem
(
tmintProb
.
ProposalID
)
if
err
!=
nil
{
alog
.
Error
(
"tmintPropItem "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"getProposalItem failed"
,
tmintProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
pre
:=
copyAutonomyProposalItem
(
cur
)
// 检查当前状态
if
cur
.
Status
==
auty
.
AutonomyStatusTmintPropItem
||
cur
.
Status
==
auty
.
AutonomyStatusRvkPropItem
{
err
:=
auty
.
ErrProposalStatus
alog
.
Error
(
"tmintPropItem "
,
"addr"
,
a
.
fromaddr
,
"status"
,
cur
.
Status
,
"status is not match"
,
tmintProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
// 董事会投票期间不能终止
end
:=
cur
.
GetPropItem
()
.
EndBlockHeight
if
!
cur
.
BoardVoteRes
.
Pass
&&
a
.
height
<=
end
{
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
}
if
cur
.
BoardVoteRes
.
TotalVotes
!=
0
&&
cur
.
BoardVoteRes
.
TotalVotes
>
cur
.
BoardVoteRes
.
QuitVotes
&&
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
)
/
float32
(
cur
.
BoardVoteRes
.
TotalVotes
-
cur
.
BoardVoteRes
.
QuitVotes
)
>=
float32
(
cur
.
CurRule
.
BoardApproveRatio
)
/
100.0
{
cur
.
BoardVoteRes
.
Pass
=
true
}
else
{
cur
.
BoardVoteRes
.
Pass
=
false
}
cur
.
PropItem
.
RealEndBlockHeight
=
a
.
height
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
// 如果为提案状态,则判断是否需要扣除提案费
if
cur
.
Status
==
auty
.
AutonomyStatusProposalItem
&&
a
.
height
>
end
{
receipt
,
err
:=
a
.
coinsAccount
.
ExecTransferFrozen
(
cur
.
Address
,
a
.
execaddr
,
a
.
execaddr
,
cur
.
CurRule
.
ProposalAmount
)
if
err
!=
nil
{
alog
.
Error
(
"tmintPropItem "
,
"addr"
,
cur
.
Address
,
"execaddr"
,
a
.
execaddr
,
"ExecTransferFrozen amount fail"
,
err
)
return
nil
,
err
}
logs
=
append
(
logs
,
receipt
.
Logs
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
}
cur
.
Status
=
auty
.
AutonomyStatusTmintPropItem
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
propItemID
(
tmintProb
.
ProposalID
),
Value
:
types
.
Encode
(
cur
)})
receiptLog
:=
getItemReceiptLog
(
pre
,
cur
,
auty
.
TyLogTmintPropItem
)
logs
=
append
(
logs
,
receiptLog
)
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
func
(
a
*
action
)
getProposalItem
(
ID
string
)
(
*
auty
.
AutonomyProposalItem
,
error
)
{
value
,
err
:=
a
.
db
.
Get
(
propItemID
(
ID
))
if
err
!=
nil
{
return
nil
,
err
}
cur
:=
&
auty
.
AutonomyProposalItem
{}
err
=
types
.
Decode
(
value
,
cur
)
if
err
!=
nil
{
return
nil
,
err
}
return
cur
,
nil
}
// getItemReceiptLog 根据提案信息获取log
// 状态变化:
func
getItemReceiptLog
(
pre
,
cur
*
auty
.
AutonomyProposalItem
,
ty
int32
)
*
types
.
ReceiptLog
{
log
:=
&
types
.
ReceiptLog
{}
log
.
Ty
=
ty
r
:=
&
auty
.
ReceiptProposalItem
{
Prev
:
pre
,
Current
:
cur
}
log
.
Log
=
types
.
Encode
(
r
)
return
log
}
func
copyAutonomyProposalItem
(
cur
*
auty
.
AutonomyProposalItem
)
*
auty
.
AutonomyProposalItem
{
if
cur
==
nil
{
return
nil
}
newAut
:=
*
cur
if
cur
.
PropItem
!=
nil
{
newItem
:=
*
cur
.
GetPropItem
()
newAut
.
PropItem
=
&
newItem
}
if
cur
.
CurRule
!=
nil
{
newRule
:=
*
cur
.
GetCurRule
()
newAut
.
CurRule
=
&
newRule
}
if
len
(
cur
.
Boards
)
>
0
{
newAut
.
Boards
=
make
([]
string
,
len
(
cur
.
Boards
))
copy
(
newAut
.
Boards
,
cur
.
Boards
)
}
if
cur
.
BoardVoteRes
!=
nil
{
newRes
:=
*
cur
.
GetBoardVoteRes
()
newAut
.
BoardVoteRes
=
&
newRes
}
return
&
newAut
}
plugin/dapp/autonomy/executor/itemtable.go
0 → 100644
View file @
9c037e47
package
executor
import
(
"fmt"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
)
/*
table struct
data: autonomy item
index: status, addr
*/
var
itemOpt
=
&
table
.
Option
{
Prefix
:
"LODB-autonomy"
,
Name
:
"item"
,
Primary
:
"heightindex"
,
Index
:
[]
string
{
"addr"
,
"status"
,
"addr_status"
},
}
//NewItemTable 新建表
func
NewItemTable
(
kvdb
db
.
KV
)
*
table
.
Table
{
rowmeta
:=
NewItemRow
()
newTable
,
err
:=
table
.
NewTable
(
rowmeta
,
kvdb
,
itemOpt
)
if
err
!=
nil
{
panic
(
err
)
}
return
newTable
}
//ItemRow table meta 结构
type
ItemRow
struct
{
*
auty
.
AutonomyProposalItem
}
//NewItemRow 新建一个meta 结构
func
NewItemRow
()
*
ItemRow
{
return
&
ItemRow
{
AutonomyProposalItem
:
&
auty
.
AutonomyProposalItem
{}}
}
//CreateRow 新建数据行(注意index 数据一定也要保存到数据中,不能就保存heightindex)
func
(
r
*
ItemRow
)
CreateRow
()
*
table
.
Row
{
return
&
table
.
Row
{
Data
:
&
auty
.
AutonomyProposalItem
{}}
}
//SetPayload 设置数据
func
(
r
*
ItemRow
)
SetPayload
(
data
types
.
Message
)
error
{
if
d
,
ok
:=
data
.
(
*
auty
.
AutonomyProposalItem
);
ok
{
r
.
AutonomyProposalItem
=
d
return
nil
}
return
types
.
ErrTypeAsset
}
//Get 按照indexName 查询 indexValue
func
(
r
*
ItemRow
)
Get
(
key
string
)
([]
byte
,
error
)
{
if
key
==
"heightindex"
{
return
[]
byte
(
dapp
.
HeightIndexStr
(
r
.
Height
,
int64
(
r
.
Index
))),
nil
}
else
if
key
==
"status"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%2d"
,
r
.
Status
)),
nil
}
else
if
key
==
"addr"
{
return
[]
byte
(
r
.
Address
),
nil
}
else
if
key
==
"addr_status"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s:%2d"
,
r
.
Address
,
r
.
Status
)),
nil
}
return
nil
,
types
.
ErrNotFound
}
plugin/dapp/autonomy/executor/kv.go
View file @
9c037e47
...
@@ -79,3 +79,12 @@ var (
...
@@ -79,3 +79,12 @@ var (
func
propChangeID
(
txHash
string
)
[]
byte
{
func
propChangeID
(
txHash
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s%s"
,
changePrefix
,
txHash
))
return
[]
byte
(
fmt
.
Sprintf
(
"%s%s"
,
changePrefix
,
txHash
))
}
}
var
(
//item
itemPrefix
=
idPrefix
+
"item-"
)
func
propItemID
(
txHash
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s%s"
,
itemPrefix
,
txHash
))
}
plugin/dapp/autonomy/executor/projectaction.go
View file @
9c037e47
...
@@ -261,7 +261,7 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
...
@@ -261,7 +261,7 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
}
}
if
a
.
api
.
GetConfig
()
.
IsDappFork
(
a
.
height
,
auty
.
AutonomyX
,
auty
.
ForkAutonomyDelRule
)
{
if
a
.
api
.
GetConfig
()
.
IsDappFork
(
a
.
height
,
auty
.
AutonomyX
,
auty
.
ForkAutonomyDelRule
)
{
if
cur
.
BoardVoteRes
.
TotalVotes
!=
0
&&
if
cur
.
BoardVoteRes
.
TotalVotes
!=
0
&&
cur
.
BoardVoteRes
.
TotalVotes
>
cur
.
BoardVoteRes
.
QuitVotes
&&
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
)
/
float32
(
cur
.
BoardVoteRes
.
TotalVotes
-
cur
.
BoardVoteRes
.
QuitVotes
)
>=
float32
(
cur
.
CurRule
.
BoardApproveRatio
)
/
100.0
{
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
)
/
float32
(
cur
.
BoardVoteRes
.
TotalVotes
-
cur
.
BoardVoteRes
.
QuitVotes
)
>=
float32
(
cur
.
CurRule
.
BoardApproveRatio
)
/
100.0
{
cur
.
BoardVoteRes
.
Pass
=
true
cur
.
BoardVoteRes
.
Pass
=
true
cur
.
PropProject
.
RealEndBlockHeight
=
a
.
height
cur
.
PropProject
.
RealEndBlockHeight
=
a
.
height
...
@@ -463,7 +463,7 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
...
@@ -463,7 +463,7 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
return
nil
,
err
return
nil
,
err
}
}
if
a
.
api
.
GetConfig
()
.
IsDappFork
(
a
.
height
,
auty
.
AutonomyX
,
auty
.
ForkAutonomyDelRule
)
{
if
a
.
api
.
GetConfig
()
.
IsDappFork
(
a
.
height
,
auty
.
AutonomyX
,
auty
.
ForkAutonomyDelRule
)
{
if
cur
.
BoardVoteRes
.
TotalVotes
!=
0
&&
if
cur
.
BoardVoteRes
.
TotalVotes
!=
0
&&
cur
.
BoardVoteRes
.
TotalVotes
>
cur
.
BoardVoteRes
.
QuitVotes
&&
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
)
/
float32
(
cur
.
BoardVoteRes
.
TotalVotes
-
cur
.
BoardVoteRes
.
QuitVotes
)
>=
float32
(
cur
.
CurRule
.
BoardApproveRatio
)
/
100.0
{
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
)
/
float32
(
cur
.
BoardVoteRes
.
TotalVotes
-
cur
.
BoardVoteRes
.
QuitVotes
)
>=
float32
(
cur
.
CurRule
.
BoardApproveRatio
)
/
100.0
{
cur
.
BoardVoteRes
.
Pass
=
true
cur
.
BoardVoteRes
.
Pass
=
true
}
else
{
}
else
{
...
...
plugin/dapp/autonomy/executor/query.go
View file @
9c037e47
...
@@ -63,3 +63,8 @@ func (a *Autonomy) Query_GetProposalChange(in *types.ReqString) (types.Message,
...
@@ -63,3 +63,8 @@ func (a *Autonomy) Query_GetProposalChange(in *types.ReqString) (types.Message,
func
(
a
*
Autonomy
)
Query_ListProposalChange
(
in
*
auty
.
ReqQueryProposalChange
)
(
types
.
Message
,
error
)
{
func
(
a
*
Autonomy
)
Query_ListProposalChange
(
in
*
auty
.
ReqQueryProposalChange
)
(
types
.
Message
,
error
)
{
return
a
.
listProposalChange
(
in
)
return
a
.
listProposalChange
(
in
)
}
}
// Query_GetProposalChange 查询提案修改董事会成员
func
(
a
*
Autonomy
)
Query_IsAutonomyApprovedItem
(
in
*
types
.
ReqStrings
)
(
types
.
Message
,
error
)
{
return
IsAutonomyApprovedItem
(
a
.
GetStateDB
(),
in
)
}
plugin/dapp/autonomy/proto/autonomy.proto
View file @
9c037e47
...
@@ -9,6 +9,7 @@ import "board.proto";
...
@@ -9,6 +9,7 @@ import "board.proto";
import
"project.proto"
;
import
"project.proto"
;
import
"rule.proto"
;
import
"rule.proto"
;
import
"change.proto"
;
import
"change.proto"
;
import
"item.proto"
;
package
types
;
package
types
;
option
go_package
=
"../types"
;
option
go_package
=
"../types"
;
...
@@ -40,6 +41,13 @@ message AutonomyAction {
...
@@ -40,6 +41,13 @@ message AutonomyAction {
RevokeProposalChange
rvkPropChange
=
17
;
RevokeProposalChange
rvkPropChange
=
17
;
VoteProposalChange
votePropChange
=
18
;
VoteProposalChange
votePropChange
=
18
;
TerminateProposalChange
tmintPropChange
=
19
;
TerminateProposalChange
tmintPropChange
=
19
;
//提案事项审核相关
ProposalItem
propItem
=
21
;
RevokeProposalItem
rvkPropItem
=
22
;
VoteProposalItem
votePropItem
=
23
;
TerminateProposalItem
tmintPropItem
=
24
;
}
}
int32
ty
=
20
;
int32
ty
=
20
;
}
}
plugin/dapp/autonomy/proto/item.proto
0 → 100644
View file @
9c037e47
// 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.
syntax
=
"proto3"
;
import
"lcommon.proto"
;
package
types
;
option
go_package
=
"../types"
;
message
AutonomyProposalItem
{
ProposalItem
propItem
=
1
;
// 投票该提案的规则
RuleConfig
curRule
=
2
;
// 投票该提案的董事会成员
repeated
string
boards
=
3
;
// 董事会投票结果
VoteResult
boardVoteRes
=
4
;
// 状态
int32
status
=
6
;
string
address
=
7
;
int64
height
=
8
;
int32
index
=
9
;
string
proposalID
=
10
;
}
message
ProposalItem
{
// 提案时间
int32
year
=
1
;
int32
month
=
2
;
int32
day
=
3
;
// 项目相关
string
itemTxHash
=
4
;
// item tx hash
string
exec
=
5
;
// 合约执行器
int64
itemTxBlockHeight
=
6
;
//需要设置区块高度,太久的item不处理
string
description
=
7
;
// 简述
// 投票相关
int64
startBlockHeight
=
12
;
// 提案开始投票高度
int64
endBlockHeight
=
13
;
// 提案结束投票高度
int64
realEndBlockHeight
=
14
;
// 实际提案结束投票高度
int32
projectNeedBlockNum
=
15
;
// 以提案结束投票高度为准,需要项目需要消耗的区块数目所对应的时间
}
message
RevokeProposalItem
{
string
proposalID
=
1
;
}
message
VoteProposalItem
{
string
proposalID
=
1
;
bool
approve
=
2
;
AutonomyVoteOption
vote
=
3
;
}
message
TerminateProposalItem
{
string
proposalID
=
1
;
}
// receipt
message
ReceiptProposalItem
{
AutonomyProposalItem
prev
=
1
;
AutonomyProposalItem
current
=
2
;
}
message
LocalProposalItem
{
AutonomyProposalItem
propItem
=
1
;
repeated
string
comments
=
2
;
}
// query
message
ReqQueryProposalItem
{
int32
status
=
1
;
string
addr
=
2
;
int32
count
=
3
;
int32
direction
=
4
;
int64
height
=
5
;
int32
index
=
6
;
}
message
ReplyQueryProposalItem
{
repeated
AutonomyProposalItem
propItems
=
1
;
}
plugin/dapp/autonomy/types/const.go
View file @
9c037e47
...
@@ -30,6 +30,11 @@ const (
...
@@ -30,6 +30,11 @@ const (
AutonomyActionVotePropChange
AutonomyActionVotePropChange
AutonomyActionTmintPropChange
AutonomyActionTmintPropChange
AutonomyActionPropItem
AutonomyActionRvkPropItem
AutonomyActionVotePropItem
AutonomyActionTmintPropItem
//log for autonomy
//log for autonomy
TyLogPropBoard
=
2101
TyLogPropBoard
=
2101
TyLogRvkPropBoard
=
2102
TyLogRvkPropBoard
=
2102
...
@@ -53,6 +58,11 @@ const (
...
@@ -53,6 +58,11 @@ const (
TyLogRvkPropChange
=
2142
TyLogRvkPropChange
=
2142
TyLogVotePropChange
=
2143
TyLogVotePropChange
=
2143
TyLogTmintPropChange
=
2144
TyLogTmintPropChange
=
2144
TyLogPropItem
=
2161
TyLogRvkPropItem
=
2162
TyLogVotePropItem
=
2163
TyLogTmintPropItem
=
2164
)
)
// Board status
// Board status
...
@@ -88,6 +98,14 @@ const (
...
@@ -88,6 +98,14 @@ const (
AutonomyStatusTmintPropChange
AutonomyStatusTmintPropChange
)
)
// Item status
const
(
AutonomyStatusProposalItem
=
iota
+
1
AutonomyStatusRvkPropItem
AutonomyStatusVotePropItem
AutonomyStatusTmintPropItem
)
const
(
const
(
// GetProposalBoard 用于在cmd里面的区分不同的查询
// GetProposalBoard 用于在cmd里面的区分不同的查询
GetProposalBoard
=
"GetProposalBoard"
GetProposalBoard
=
"GetProposalBoard"
...
...
plugin/dapp/mix/executor/config.go
View file @
9c037e47
...
@@ -6,7 +6,6 @@ package executor
...
@@ -6,7 +6,6 @@ package executor
import
(
import
(
dbm
"github.com/33cn/chain33/common/db"
dbm
"github.com/33cn/chain33/common/db"
manager
"github.com/33cn/chain33/system/dapp/manage/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
mixTy
"github.com/33cn/plugin/plugin/dapp/mix/types"
mixTy
"github.com/33cn/plugin/plugin/dapp/mix/types"
"github.com/pkg/errors"
"github.com/pkg/errors"
...
@@ -14,8 +13,8 @@ import (
...
@@ -14,8 +13,8 @@ import (
// IsSuperManager is supper manager or not
// IsSuperManager is supper manager or not
func
isSuperManager
(
cfg
*
types
.
Chain33Config
,
addr
string
)
bool
{
func
isSuperManager
(
cfg
*
types
.
Chain33Config
,
addr
string
)
bool
{
confM
anager
:=
types
.
ConfSub
(
cfg
,
manager
.
Manage
X
)
confM
ix
:=
types
.
ConfSub
(
cfg
,
mixTy
.
Mix
X
)
for
_
,
m
:=
range
confM
anager
.
GStrList
(
"superManager
"
)
{
for
_
,
m
:=
range
confM
ix
.
GStrList
(
"mixApprs
"
)
{
if
addr
==
m
{
if
addr
==
m
{
return
true
return
true
}
}
...
...
plugin/dapp/paracross/executor/superaccount.go
View file @
9c037e47
...
@@ -960,9 +960,29 @@ func (a *action) nodeGroupApproveApply(config *pt.ParaNodeGroupConfig, apply *pt
...
@@ -960,9 +960,29 @@ func (a *action) nodeGroupApproveApply(config *pt.ParaNodeGroupConfig, apply *pt
// NodeGroupApprove super addr approve the node group apply
// NodeGroupApprove super addr approve the node group apply
func
(
a
*
action
)
nodeGroupApprove
(
config
*
pt
.
ParaNodeGroupConfig
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
nodeGroupApprove
(
config
*
pt
.
ParaNodeGroupConfig
)
(
*
types
.
Receipt
,
error
)
{
cfg
:=
a
.
api
.
GetConfig
()
cfg
:=
a
.
api
.
GetConfig
()
//只在主链检查
if
!
cfg
.
IsPara
()
&&
!
isSuperManager
(
cfg
,
a
.
fromaddr
)
{
//只在主链检查, 主链检查失败不会同步到平行链,主链成功,平行链默认成功
return
nil
,
errors
.
Wrapf
(
types
.
ErrNotAllow
,
"node group approve not super manager:%s"
,
a
.
fromaddr
)
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"
)
}
//去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
}}),
})
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"query autonomy,approveid=%s,hashId=%s"
,
config
.
AutonomyItemID
,
config
.
Id
)
}
}
else
if
!
isSuperManager
(
cfg
,
a
.
fromaddr
)
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrNotAllow
,
"node group approve not super manager:%s"
,
a
.
fromaddr
)
}
}
}
id
,
err
:=
getNodeGroupID
(
cfg
,
a
.
db
,
config
.
Title
,
a
.
exec
.
GetMainHeight
(),
config
.
Id
)
id
,
err
:=
getNodeGroupID
(
cfg
,
a
.
db
,
config
.
Title
,
a
.
exec
.
GetMainHeight
(),
config
.
Id
)
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
9c037e47
...
@@ -125,6 +125,7 @@ message ParaNodeGroupConfig {
...
@@ -125,6 +125,7 @@ message ParaNodeGroupConfig {
string
addrs
=
4
;
string
addrs
=
4
;
int64
coinsFrozen
=
5
;
int64
coinsFrozen
=
5
;
string
blsPubKeys
=
6
;
string
blsPubKeys
=
6
;
string
autonomyItemID
=
7
;
}
}
message
ParaNodeGroupStatus
{
message
ParaNodeGroupStatus
{
...
...
plugin/dapp/paracross/types/type.go
View file @
9c037e47
...
@@ -26,12 +26,17 @@ var (
...
@@ -26,12 +26,17 @@ var (
MainLoopCheckCommitTxDoneForkHeight
=
"mainLoopCheckCommitTxDoneForkHeight"
MainLoopCheckCommitTxDoneForkHeight
=
"mainLoopCheckCommitTxDoneForkHeight"
//MainForkParaSupervision = "mainForkParaSupervision"
//MainForkParaSupervision = "mainForkParaSupervision"
// ForkParaSelfConsStages 平行链自共识分阶段共识
ForkParaSelfConsStages
=
"ForkParaSelfConsStages"
// ForkParaAssetTransferRbk 平行链资产转移平行链失败主链回滚
// ForkParaAssetTransferRbk 平行链资产转移平行链失败主链回滚
ForkParaAssetTransferRbk
=
"ForkParaAssetTransferRbk"
ForkParaAssetTransferRbk
=
"ForkParaAssetTransferRbk"
// ForkParaSupervision 平行链新增监督节点
// ForkParaSupervision 平行链新增监督节点
ForkParaSupervision
=
"ForkParaSupervision"
ForkParaSupervision
=
"ForkParaSupervision"
//ForkParaAutonomySuperGroup 分叉之后autonomy授权共识账户组,之前是配置超级管理员授权
ForkParaAutonomySuperGroup
=
"ForkParaAutonomySuperGroup"
//只在平行链开启的分叉
// ForkParaSelfConsStages 平行链自共识分阶段共识
ForkParaSelfConsStages
=
"ForkParaSelfConsStages"
// ForkParaFullMinerHeight 平行链全挖矿开启高度
// ForkParaFullMinerHeight 平行链全挖矿开启高度
ForkParaFullMinerHeight
=
"ForkParaFullMinerHeight"
ForkParaFullMinerHeight
=
"ForkParaFullMinerHeight"
// ForkParaRootHash 平行链按照ForkRootHash计算rootHash高度,在之前版本中平行链侧计算txRootHash没有提供正确的主链高度计算,需要分叉
// ForkParaRootHash 平行链按照ForkRootHash计算rootHash高度,在之前版本中平行链侧计算txRootHash没有提供正确的主链高度计算,需要分叉
...
@@ -65,6 +70,7 @@ func InitFork(cfg *types.Chain33Config) {
...
@@ -65,6 +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
,
ForkParaSelfConsStages
,
types
.
MaxHeight
)
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