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
730d0fdc
Commit
730d0fdc
authored
Sep 04, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
平行链增加监督节点
parent
b375d231
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
178 additions
and
204 deletions
+178
-204
action.go
plugin/dapp/paracross/executor/action.go
+85
-37
exec.go
plugin/dapp/paracross/executor/exec.go
+6
-0
kv.go
plugin/dapp/paracross/executor/kv.go
+30
-0
paracross_test.go
plugin/dapp/paracross/executor/paracross_test.go
+18
-126
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+0
-10
superaccount_test.go
plugin/dapp/paracross/executor/superaccount_test.go
+3
-24
supervisionaccount.go
plugin/dapp/paracross/executor/supervisionaccount.go
+0
-0
supervisionaccount.md
plugin/dapp/paracross/executor/supervisionaccount.md
+10
-0
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+8
-7
errors.go
plugin/dapp/paracross/types/errors.go
+6
-0
paracross.go
plugin/dapp/paracross/types/paracross.go
+12
-0
paracross.pb.go
plugin/dapp/paracross/types/paracross.pb.go
+0
-0
No files found.
plugin/dapp/paracross/executor/action.go
View file @
730d0fdc
This diff is collapsed.
Click to expand it.
plugin/dapp/paracross/executor/exec.go
View file @
730d0fdc
...
...
@@ -125,3 +125,9 @@ func (e *Paracross) Exec_ParaBindMiner(payload *pt.ParaBindMinerCmd, tx *types.T
a
:=
newAction
(
e
,
tx
)
return
a
.
bindMiner
(
payload
)
}
//Exec_SupervisionNodeGroupConfig exec Supervision node config
func
(
e
*
Paracross
)
Exec_SupervisionNodeGroupConfig
(
payload
*
pt
.
ParaNodeAddrConfig
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
a
:=
newAction
(
e
,
tx
)
return
a
.
SupervisionNodeGroupConfig
(
payload
)
}
plugin/dapp/paracross/executor/kv.go
View file @
730d0fdc
...
...
@@ -38,6 +38,14 @@ var (
paraBindMinderAddr
string
paraBindMinderNode
string
//监督节点
paraSupervisionNodes
string
paraSupervisionNodeAddr
string
paraSupervisionNodeGroupStatusAddrs
string
paraSupervisionNodeGroupIDPrefix
string
paraSupervisionSelfConsensStages
string
paraSupervisionSelfConsensStageIDPrefix
string
)
func
setPrefix
()
{
...
...
@@ -67,6 +75,12 @@ func setPrefix() {
localNodeGroupStatusTitle
=
"LODB-paracross-nodegroupStatusTitle-"
paraSupervisionNodes
=
"mavl-paracross-supervision-nodes-title-"
paraSupervisionNodeAddr
=
"mavl-paracross-supervision-nodes-titleAddr-"
paraSupervisionNodeGroupStatusAddrs
=
"mavl-paracross-supervision-nodegroup-apply-title-"
paraSupervisionNodeGroupIDPrefix
=
"mavl-paracross-supervision-title-nodegroupid-"
paraSupervisionSelfConsensStages
=
"mavl-paracross-supervision-selfconsens-stages-"
paraSupervisionSelfConsensStageIDPrefix
=
"mavl-paracross-supervision-selfconsens-id-"
}
func
calcTitleKey
(
t
string
)
[]
byte
{
...
...
@@ -195,3 +209,19 @@ func calcParaBindMinerAddr(node, bind string) []byte {
func
calcParaBindMinerNode
(
node
string
)
[]
byte
{
return
[]
byte
(
paraBindMinderNode
+
node
)
}
func
calcParaSupervisionNodeGroupAddrsKey
(
title
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
paraSupervisionNodes
+
"%s"
,
title
))
}
func
calcParaSupervisionNodeGroupStatusKey
(
title
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
paraSupervisionNodeGroupStatusAddrs
+
"%s"
,
title
))
}
func
calcParaSupervisionNodeAddrKey
(
title
string
,
addr
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
paraSupervisionNodeAddr
+
"%s-%s"
,
title
,
addr
))
}
func
calcParaSupervisionNodeGroupIDKey
(
title
,
hash
string
)
string
{
return
fmt
.
Sprintf
(
paraSupervisionNodeGroupIDPrefix
+
"%s-%s"
,
title
,
hash
)
}
plugin/dapp/paracross/executor/paracross_test.go
View file @
730d0fdc
...
...
@@ -26,21 +26,14 @@ import (
"github.com/stretchr/testify/suite"
)
// 构造一个4个节点的平行链数据, 进行测试
const
(
SignedType
=
types
.
SECP256K1
)
var
(
MainBlockHash10
=
[]
byte
(
"main block hash 10"
)
MainBlockHeight
=
int64
(
10
)
CurHeight
=
int64
(
10
)
Title
=
string
(
"user.p.test."
)
Title
=
"user.p.test."
TitleHeight
=
int64
(
10
)
PerBlock
=
[]
byte
(
"block-hash-9"
)
CurBlock
=
[]
byte
(
"block-hash-10"
)
PerState
=
[]
byte
(
"state-hash-9"
)
CurState
=
[]
byte
(
"state-hash-10"
)
PrivKeyA
=
"0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
// 1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4
PrivKeyB
=
"0x19c069234f9d3e61135fefbeb7791b149cdf6af536f26bebb310d4cd22c3fee4"
// 1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR
...
...
@@ -53,10 +46,8 @@ var (
[]
byte
(
"1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
),
}
TokenSymbol
=
"X"
MainBlockHeightForTransfer
=
int64
(
9
)
chain33TestCfg
=
types
.
NewChain33Config
(
testnode
.
DefaultConfig
)
chain33TestMainCfg
=
types
.
NewChain33Config
(
strings
.
Replace
(
types
.
GetDefaultCfgstring
(),
"Title=
\"
local
\"
"
,
"Title=
\"
test
\"
"
,
1
))
chain33TestCfg
=
types
.
NewChain33Config
(
testnode
.
DefaultConfig
)
chain33TestMainCfg
=
types
.
NewChain33Config
(
strings
.
Replace
(
types
.
GetDefaultCfgstring
(),
"Title=
\"
local
\"
"
,
"Title=
\"
test
\"
"
,
1
))
)
type
CommitTestSuite
struct
{
...
...
@@ -92,7 +83,6 @@ func init() {
}
func
(
suite
*
CommitTestSuite
)
SetupSuite
()
{
suite
.
stateDB
,
_
=
dbm
.
NewGoMemDB
(
"state"
,
"state"
,
1024
)
// memdb 不支持KVDB接口, 等测试完Exec , 再扩展 memdb
//suite.localDB, _ = dbm.NewGoMemDB("local", "local", 1024)
...
...
@@ -118,7 +108,7 @@ func (suite *CommitTestSuite) SetupSuite() {
// setup title nodes : len = 4
nodeConfigKey
:=
calcManageConfigNodesKey
(
Title
)
nodeValue
:=
makeNodeInfo
(
Title
,
Title
,
4
)
suite
.
stateDB
.
Set
(
nodeConfigKey
,
types
.
Encode
(
nodeValue
))
_
=
suite
.
stateDB
.
Set
(
nodeConfigKey
,
types
.
Encode
(
nodeValue
))
value
,
err
:=
suite
.
stateDB
.
Get
(
nodeConfigKey
)
if
err
!=
nil
{
suite
.
T
()
.
Error
(
"get setup title failed"
,
err
)
...
...
@@ -129,7 +119,7 @@ func (suite *CommitTestSuite) SetupSuite() {
stageKey
:=
calcParaSelfConsStagesKey
()
stage
:=
&
pt
.
SelfConsensStage
{
StartHeight
:
0
,
Enable
:
pt
.
ParaConfigYes
}
stages
:=
&
pt
.
SelfConsensStages
{
Items
:
[]
*
pt
.
SelfConsensStage
{
stage
}}
suite
.
stateDB
.
Set
(
stageKey
,
types
.
Encode
(
stages
))
_
=
suite
.
stateDB
.
Set
(
stageKey
,
types
.
Encode
(
stages
))
value
,
err
=
suite
.
stateDB
.
Get
(
stageKey
)
if
err
!=
nil
{
suite
.
T
()
.
Error
(
"get setup stages failed"
,
err
)
...
...
@@ -142,7 +132,7 @@ func (suite *CommitTestSuite) SetupSuite() {
titleStatus
.
Title
=
Title
titleStatus
.
Height
=
CurHeight
-
1
titleStatus
.
BlockHash
=
PerBlock
saveTitle
(
suite
.
stateDB
,
calcTitleKey
(
Title
),
&
titleStatus
)
_
=
saveTitle
(
suite
.
stateDB
,
calcTitleKey
(
Title
),
&
titleStatus
)
// setup api
hashes
:=
&
types
.
ReqHashes
{
Hashes
:
[][]
byte
{
MainBlockHash10
}}
...
...
@@ -200,13 +190,13 @@ func signTx(s suite.Suite, tx *types.Transaction, hexPrivKey string) (*types.Tra
return
tx
,
err
}
bytes
,
err
:=
common
.
FromHex
(
hexPrivKey
[
:
])
bytes
Data
,
err
:=
common
.
FromHex
(
hexPrivKey
[
:
])
if
err
!=
nil
{
s
.
T
()
.
Error
(
"TestExec"
,
"Hex2Bytes privkey faiiled"
,
err
)
return
tx
,
err
}
privKey
,
err
:=
c
.
PrivKeyFromBytes
(
bytes
)
privKey
,
err
:=
c
.
PrivKeyFromBytes
(
bytes
Data
)
if
err
!=
nil
{
s
.
T
()
.
Error
(
"TestExec"
,
"PrivKeyFromBytes failed"
,
err
)
return
tx
,
err
...
...
@@ -224,13 +214,13 @@ func getPrivKey(s suite.Suite, hexPrivKey string) (crypto.PrivKey, error) {
return
nil
,
err
}
bytes
,
err
:=
common
.
FromHex
(
hexPrivKey
[
:
])
bytes
Data
,
err
:=
common
.
FromHex
(
hexPrivKey
[
:
])
if
err
!=
nil
{
s
.
T
()
.
Error
(
"TestExec"
,
"Hex2Bytes privkey faiiled"
,
err
)
return
nil
,
err
}
privKey
,
err
:=
c
.
PrivKeyFromBytes
(
bytes
)
privKey
,
err
:=
c
.
PrivKeyFromBytes
(
bytes
Data
)
if
err
!=
nil
{
s
.
T
()
.
Error
(
"TestExec"
,
"PrivKeyFromBytes failed"
,
err
)
return
nil
,
err
...
...
@@ -311,6 +301,7 @@ func checkDoneReceipt(suite suite.Suite, receipt *types.Receipt, commitCnt int)
}
func
checkRecordReceipt
(
suite
*
CommitTestSuite
,
receipt
*
types
.
Receipt
,
commitCnt
int
)
{
_
=
commitCnt
assert
.
Equal
(
suite
.
T
(),
receipt
.
Ty
,
int32
(
types
.
ExecOk
))
assert
.
Len
(
suite
.
T
(),
receipt
.
KV
,
0
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
1
)
...
...
@@ -363,105 +354,6 @@ func TestGetTitle(t *testing.T) {
assert
.
Equal
(
t
,
titleExpect
,
title
)
}
/*
func TestCrossLimits(t *testing.T) {
stateDB, _ := dbm.NewGoMemDB("state", "state", 1024)
localDB := new(dbmock.KVDB)
api := new(apimock.QueueProtocolAPI)
exec := newParacross().(*Paracross)
exec.SetLocalDB(localDB)
exec.SetStateDB(stateDB)
exec.SetEnv(0, 0, 0)
exec.SetAPI(api)
func (s *VoteTestSuite) TestFilterTxsForPara() {
tx1, err := createAssetTransferTx(s.Suite, PrivKeyA, nil)
s.Nil(err)
tx2, err := createParaNormalTx(s.Suite, PrivKeyB, nil)
s.Nil(err)
tx3, err := createParaNormalTx(s.Suite,PrivKeyA,[]byte("toA"))
s.Nil(err)
tx4, err := createCrossParaTx(s.Suite, []byte("toB"))
s.Nil(err)
tx5, err := createParaNormalTx(s.Suite,PrivKeyA,[]byte("toB"))
s.Nil(err)
tx345 := []*types.Transaction{tx3, tx4,tx5}
txGroup345, err := createTxsGroup(s.Suite, tx345)
s.Nil(err)
tx6, err := createCrossParaTx(s.Suite, nil)
s.Nil(err)
tx7, err := createCrossParaTx(s.Suite, nil)
s.Nil(err)
tx67 := []*types.Transaction{tx6, tx7}
txGroup67, err := createTxsGroup(s.Suite, tx67)
s.Nil(err)
tx71, err := createParaNormalTx(s.Suite,PrivKeyA,[]byte("toA"))
s.Nil(err)
tx72, err := createCrossParaTx(s.Suite, []byte("toB"))
s.Nil(err)
tx73, err := createParaNormalTx(s.Suite,PrivKeyA,[]byte("toB"))
s.Nil(err)
tx777 := []*types.Transaction{tx71, tx72,tx73}
txGroup777, err := createTxsGroup(s.Suite, tx777)
s.Nil(err)
tx8, err := createAssetTransferTx(s.Suite, PrivKeyA, nil)
s.Nil(err)
tx9, err := createAssetTransferTx(s.Suite, PrivKeyC, nil)
s.Nil(err)
txs := []*types.Transaction{tx1, tx2}
txs = append(txs, txGroup345...)
txs = append(txs, txGroup67...)
txs = append(txs, txGroup777...)
txs = append(txs, tx8)
txs = append(txs, tx9)
errlog := &types.ReceiptLog{Ty: types.TyLogErr, Log: []byte("")}
feelog := &types.Receipt{}
feelog.Logs = append(feelog.Logs, errlog)
recpt1 := &types.ReceiptData{Ty: types.ExecPack,Logs:feelog.Logs}
recpt2 := &types.ReceiptData{Ty: types.ExecPack}
recpt3 := &types.ReceiptData{Ty: types.ExecOk}
recpt4 := &types.ReceiptData{Ty: types.ExecOk}
recpt5 := &types.ReceiptData{Ty: types.ExecOk}
recpt6 := &types.ReceiptData{Ty: types.ExecPack,Logs:feelog.Logs}
recpt7 := &types.ReceiptData{Ty: types.ExecPack}
recpt71 := &types.ReceiptData{Ty: types.ExecPack}
recpt72 := &types.ReceiptData{Ty: types.ExecPack}
recpt73 := &types.ReceiptData{Ty: types.ExecPack}
recpt8 := &types.ReceiptData{Ty: types.ExecPack,Logs:feelog.Logs}
recpt9 := &types.ReceiptData{Ty: types.ExecOk}
receipts := []*types.ReceiptData{recpt1, recpt2, recpt3, recpt4, recpt5, recpt6, recpt7, recpt71,recpt72, recpt73, recpt8,recpt9}
block := &types.Block{Txs: txs}
detail := &types.BlockDetail{
Block: block,
Receipts: receipts,
}
rst := FilterTxsForPara(Title, detail)
filterTxs := []*types.Transaction{ tx2,tx3, tx4, tx5,tx71,tx72,tx73,tx9}
s.Equal( filterTxs, rst)
}
tx := &types.Transaction{Execer: []byte("p.user.test.paracross")}
res := exec.CrossLimits(tx, 1)
assert.True(t, res)
}
*/
type
VoteTestSuite
struct
{
suite
.
Suite
stateDB
dbm
.
KV
...
...
@@ -489,7 +381,7 @@ func (s *VoteTestSuite) SetupSuite() {
stageKey
:=
calcParaSelfConsStagesKey
()
stage
:=
&
pt
.
SelfConsensStage
{
StartHeight
:
0
,
Enable
:
pt
.
ParaConfigYes
}
stages
:=
&
pt
.
SelfConsensStages
{
Items
:
[]
*
pt
.
SelfConsensStage
{
stage
}}
s
.
stateDB
.
Set
(
stageKey
,
types
.
Encode
(
stages
))
_
=
s
.
stateDB
.
Set
(
stageKey
,
types
.
Encode
(
stages
))
value
,
err
:=
s
.
stateDB
.
Get
(
stageKey
)
if
err
!=
nil
{
s
.
T
()
.
Error
(
"get setup stages failed"
,
err
)
...
...
@@ -565,7 +457,7 @@ func (s *VoteTestSuite) TestVoteTx() {
//s.T().Log(string(kv.GetKey()))
if
bytes
.
Equal
(
key
,
kv
.
Key
)
{
var
rst
pt
.
ParacrossNodeStatus
types
.
Decode
(
kv
.
GetValue
(),
&
rst
)
_
=
types
.
Decode
(
kv
.
GetValue
(),
&
rst
)
s
.
Equal
([]
byte
{
0x4d
},
rst
.
TxResult
)
s
.
Equal
([]
byte
{
0x25
},
rst
.
CrossTxResult
)
s
.
Equal
(
7
,
len
(
rst
.
TxHashs
))
...
...
@@ -662,7 +554,7 @@ func (s *VoteTestSuite) TestVoteTxFork() {
//s.T().Log(string(kv.GetKey()))
if
bytes
.
Equal
(
key
,
kv
.
Key
)
{
var
rst
pt
.
ParacrossNodeStatus
types
.
Decode
(
kv
.
GetValue
(),
&
rst
)
_
=
types
.
Decode
(
kv
.
GetValue
(),
&
rst
)
s
.
Equal
([]
byte
(
"8e"
),
rst
.
TxResult
)
s
.
Equal
([]
byte
(
"22"
),
rst
.
CrossTxResult
)
s
.
Equal
(
1
,
len
(
rst
.
TxHashs
))
...
...
@@ -739,7 +631,7 @@ func createTxsGroup(s suite.Suite, txs []*types.Transaction) ([]*types.Transacti
}
privKey
,
_
:=
getPrivKey
(
s
,
PrivKeyA
)
for
i
:=
range
group
.
Txs
{
group
.
SignN
(
i
,
int32
(
types
.
SECP256K1
),
privKey
)
_
=
group
.
SignN
(
i
,
int32
(
types
.
SECP256K1
),
privKey
)
}
return
group
.
Txs
,
nil
}
...
...
@@ -794,11 +686,11 @@ func TestUpdateCommitBlockHashs(t *testing.T) {
}
updateCommitBlockHashs
(
stat
,
commit
)
assert
.
Equal
(
t
,
int
(
1
)
,
len
(
stat
.
BlockDetails
.
BlockHashs
))
assert
.
Equal
(
t
,
1
,
len
(
stat
.
BlockDetails
.
BlockHashs
))
assert
.
Equal
(
t
,
commit
.
BlockHash
,
stat
.
BlockDetails
.
BlockHashs
[
0
])
updateCommitBlockHashs
(
stat
,
commit
)
assert
.
Equal
(
t
,
int
(
1
)
,
len
(
stat
.
BlockDetails
.
BlockHashs
))
assert
.
Equal
(
t
,
1
,
len
(
stat
.
BlockDetails
.
BlockHashs
))
assert
.
Equal
(
t
,
commit
.
BlockHash
,
stat
.
BlockDetails
.
BlockHashs
[
0
])
commit2
:=
&
pt
.
ParacrossNodeStatus
{
...
...
@@ -812,7 +704,7 @@ func TestUpdateCommitBlockHashs(t *testing.T) {
CrossTxHashs
:
[][]
byte
{[]
byte
(
"hash2"
)},
}
updateCommitBlockHashs
(
stat
,
commit2
)
assert
.
Equal
(
t
,
int
(
2
)
,
len
(
stat
.
BlockDetails
.
BlockHashs
))
assert
.
Equal
(
t
,
2
,
len
(
stat
.
BlockDetails
.
BlockHashs
))
assert
.
Equal
(
t
,
commit2
.
BlockHash
,
stat
.
BlockDetails
.
BlockHashs
[
1
])
}
...
...
plugin/dapp/paracross/executor/superaccount.go
View file @
730d0fdc
...
...
@@ -280,7 +280,6 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
return
receipt
,
nil
}
func
(
a
*
action
)
nodeQuit
(
config
*
pt
.
ParaNodeAddrConfig
)
(
*
types
.
Receipt
,
error
)
{
...
...
@@ -309,7 +308,6 @@ func (a *action) nodeQuit(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
Height
:
a
.
height
}
return
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
nil
,
stat
),
nil
}
func
(
a
*
action
)
nodeCancel
(
config
*
pt
.
ParaNodeAddrConfig
)
(
*
types
.
Receipt
,
error
)
{
...
...
@@ -357,7 +355,6 @@ func (a *action) nodeCancel(config *pt.ParaNodeAddrConfig) (*types.Receipt, erro
}
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaUnSupportNodeOper
,
"nodeid %s was quit status:%d"
,
config
.
Id
,
stat
.
Status
)
}
func
(
a
*
action
)
nodeModify
(
config
*
pt
.
ParaNodeAddrConfig
)
(
*
types
.
Receipt
,
error
)
{
...
...
@@ -602,7 +599,6 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
stat
.
Status
=
pt
.
ParaApplyClosed
stat
.
Height
=
a
.
height
}
}
else
{
if
stat
.
Status
==
pt
.
ParaApplyJoining
{
r
,
err
:=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
stat
.
TargetAddr
,
true
)
...
...
@@ -651,7 +647,6 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
receiptDone
:=
makeVoteDoneReceipt
(
stat
,
len
(
nodes
),
len
(
stat
.
Votes
.
Addrs
),
most
,
pt
.
ParaNodeVoteStr
[
vote
],
stat
.
Status
)
receipt
=
mergeReceipt
(
receipt
,
receiptDone
)
return
receipt
,
nil
}
func
unpdateNodeGroup
(
db
dbm
.
KV
,
title
,
addr
string
,
add
bool
)
(
*
types
.
Receipt
,
error
)
{
...
...
@@ -929,7 +924,6 @@ func (a *action) nodeGroupApproveModify(config *pt.ParaNodeGroupConfig, modify *
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
return
receipt
,
nil
}
func
(
a
*
action
)
nodeGroupApproveApply
(
config
*
pt
.
ParaNodeGroupConfig
,
apply
*
pt
.
ParaNodeGroupStatus
)
(
*
types
.
Receipt
,
error
)
{
...
...
@@ -971,7 +965,6 @@ func (a *action) nodeGroupApproveApply(config *pt.ParaNodeGroupConfig, apply *pt
}
return
receipt
,
nil
}
// NodeGroupApprove super addr approve the node group apply
...
...
@@ -1068,13 +1061,11 @@ func (a *action) NodeGroupConfig(config *pt.ParaNodeGroupConfig) (*types.Receipt
return
nil
,
err
}
return
a
.
nodeGroupApply
(
config
)
}
else
if
config
.
Op
==
pt
.
ParacrossNodeGroupApprove
{
if
config
.
Id
==
""
{
return
nil
,
types
.
ErrInvalidParam
}
return
a
.
nodeGroupApprove
(
config
)
}
else
if
config
.
Op
==
pt
.
ParacrossNodeGroupQuit
{
if
config
.
Id
==
""
{
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -1122,5 +1113,4 @@ func (a *action) NodeConfig(config *pt.ParaNodeAddrConfig) (*types.Receipt, erro
default
:
return
nil
,
pt
.
ErrParaUnSupportNodeOper
}
}
plugin/dapp/paracross/executor/superaccount_test.go
View file @
730d0fdc
...
...
@@ -25,7 +25,7 @@ import (
var
(
PrivKey14K
=
"CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
// 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt
Account14K
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
Account1MC
=
"1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
//
Account1MC = "1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
applyAddrs
=
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4, 1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR, 1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k,1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
Account12Q
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
...
...
@@ -60,7 +60,6 @@ func createRawNodeGroupApplyTx(apply *pt.ParaNodeGroupConfig) (*types.Transactio
}
return
tx
,
nil
}
type
NodeManageTestSuite
struct
{
...
...
@@ -68,13 +67,10 @@ type NodeManageTestSuite struct {
stateDB
dbm
.
KV
localDB
*
dbmock
.
KVDB
api
*
apimock
.
QueueProtocolAPI
exec
*
Paracross
//title string
exec
*
Paracross
}
func
(
suite
*
NodeManageTestSuite
)
SetupSuite
()
{
suite
.
stateDB
,
_
=
dbm
.
NewGoMemDB
(
"state"
,
"state"
,
1024
)
// memdb 不支持KVDB接口, 等测试完Exec , 再扩展 memdb
//suite.localDB, _ = dbm.NewGoMemDB("local", "local", 1024)
...
...
@@ -90,12 +86,6 @@ func (suite *NodeManageTestSuite) SetupSuite() {
suite
.
exec
.
SetBlockInfo
([]
byte
(
""
),
[]
byte
(
""
),
3
)
enableParacrossTransfer
=
false
//forkHeight := types.GetDappFork(pt.ParaX, pt.ForkCommitTx)
//if forkHeight == types.MaxHeight {
// types.ReplaceDappFork(MainTitle, pt.ParaX, pt.ForkCommitTx, 0)
//
//}
chain33TestCfg
.
S
(
"config.consensus.sub.para.MainForkParacrossCommitTx"
,
int64
(
1
))
chain33TestCfg
.
S
(
"config.exec.sub.manage.superManager"
,
[]
interface
{}{
Account12Q
})
...
...
@@ -105,7 +95,6 @@ func (suite *NodeManageTestSuite) SetupSuite() {
Block
:
&
types
.
Block
{},
}
MainBlockHash10
=
blockDetail
.
Block
.
Hash
(
chain33TestCfg
)
}
func
(
suite
*
NodeManageTestSuite
)
TestSetup
()
{
...
...
@@ -145,7 +134,6 @@ func checkGroupApplyReceipt(suite *NodeManageTestSuite, receipt *types.Receipt)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
1
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeGroupConfig
),
receipt
.
Logs
[
0
]
.
Ty
)
}
func
checkGroupApproveReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
)
{
...
...
@@ -164,7 +152,6 @@ func checkJoinReceipt(suite *NodeManageTestSuite, receipt *types.Receipt) {
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeConfig
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParaApplyJoining
),
stat
.
Status
)
assert
.
NotNil
(
suite
.
T
(),
stat
.
Votes
)
}
func
checkQuitReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
)
{
...
...
@@ -179,7 +166,6 @@ func checkQuitReceipt(suite *NodeManageTestSuite, receipt *types.Receipt) {
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeConfig
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParaApplyQuiting
),
stat
.
Status
)
assert
.
NotNil
(
suite
.
T
(),
stat
.
Votes
)
}
func
checkVoteReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
,
count
int
)
{
...
...
@@ -189,15 +175,14 @@ func checkVoteReceipt(suite *NodeManageTestSuite, receipt *types.Receipt, count
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
assert
.
Len
(
suite
.
T
(),
stat
.
Votes
.
Votes
,
count
)
}
func
checkVoteDoneReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
,
count
int
,
join
bool
)
{
_
=
count
suite
.
NotNil
(
receipt
)
assert
.
Equal
(
suite
.
T
(),
receipt
.
Ty
,
int32
(
types
.
ExecOk
))
suite
.
T
()
.
Log
(
"checkVoteDoneReceipt"
,
"kvlen"
,
len
(
receipt
.
KV
))
_
,
arry
,
err
:=
getParacrossNodes
(
suite
.
stateDB
,
Title
)
suite
.
Suite
.
Nil
(
err
)
if
join
{
...
...
@@ -264,7 +249,6 @@ func (suite *NodeManageTestSuite) testNodeGroupConfigQuit() {
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
//checkGroupApproveReceipt(suite, receipt)
}
func
(
suite
*
NodeManageTestSuite
)
testNodeGroupConfig
()
{
...
...
@@ -296,7 +280,6 @@ func (suite *NodeManageTestSuite) testNodeGroupConfig() {
receipt
=
nodeCommit
(
suite
,
PrivKey12Q
,
tx
)
checkGroupApproveReceipt
(
suite
,
receipt
)
}
func
(
suite
*
NodeManageTestSuite
)
testNodeConfig
()
{
...
...
@@ -342,7 +325,6 @@ func (suite *NodeManageTestSuite) testNodeConfig() {
func
(
suite
*
NodeManageTestSuite
)
TestExec
()
{
suite
.
testNodeGroupConfig
()
suite
.
testNodeConfig
()
}
func
TestNodeManageSuite
(
t
*
testing
.
T
)
{
...
...
@@ -350,7 +332,6 @@ func TestNodeManageSuite(t *testing.T) {
}
func
(
suite
*
NodeManageTestSuite
)
TearDownSuite
()
{
}
func
TestGetAddrGroup
(
t
*
testing
.
T
)
{
...
...
@@ -374,7 +355,6 @@ func TestGetAddrGroup(t *testing.T) {
ret
=
getConfigAddrs
(
addrs
)
assert
.
Equal
(
t
,
[]
string
(
nil
),
ret
)
assert
.
Equal
(
t
,
0
,
len
(
ret
))
}
func
TestUpdateVotes
(
t
*
testing
.
T
)
{
...
...
@@ -402,5 +382,4 @@ func TestGetNodeIdSuffix(t *testing.T) {
id
=
"mavl-paracross-title-nodegroupid-user.p.para.-0xb6cd0274aa5f839fa2291ecfbfc626b494aacac7587a61e444e9f848a4c02d7b-1"
rtID
=
getParaNodeIDSuffix
(
id
)
assert
.
Equal
(
t
,
txID
,
rtID
)
}
plugin/dapp/paracross/executor/supervisionaccount.go
0 → 100644
View file @
730d0fdc
This diff is collapsed.
Click to expand it.
plugin/dapp/paracross/executor/supervisionaccount.md
0 → 100644
View file @
730d0fdc
平行链目前有超级节点和普通节点两个角色,对超级节点账户组没有制衡的角色
波卡有钓鱼节点的概念,可以监督验证节点。chain33 也可以增加一个监督节点
基本功能如下:
1.
监督节点可以是一个节点也可以是监督节点账户组。
1.
监督节点账户组和超级节点账户组共识逻辑一样,都是超过2/3节点的共识结果,否则认为没有达成共识
1.
如果监督节点或超级节点账户组任何一方没有达成共识,认为暂时没有达成共识
1.
如果监督节点和超级节点的共识结果不一致,则暂时搁置共识,等待修正共识。不做处罚处理
1.
所有参与共识的监督节点和超级节点 前2/3节点平分挖矿奖励。
\ No newline at end of file
plugin/dapp/paracross/proto/paracross.proto
View file @
730d0fdc
...
...
@@ -20,13 +20,14 @@ message ParacrossStatusBlockDetails {
message
ParacrossHeightStatus
{
// ing, done
int32
status
=
1
;
string
title
=
2
;
int64
height
=
3
;
ParacrossStatusDetails
details
=
4
;
int64
mainHeight
=
5
;
bytes
mainHash
=
6
;
ParacrossStatusBlockDetails
blockDetails
=
7
;
int32
status
=
1
;
string
title
=
2
;
int64
height
=
3
;
ParacrossStatusDetails
details
=
4
;
ParacrossStatusDetails
supervisionDetails
=
5
;
int64
mainHeight
=
6
;
bytes
mainHash
=
7
;
ParacrossStatusBlockDetails
blockDetails
=
8
;
}
message
ParacrossHeightStatusRsp
{
...
...
plugin/dapp/paracross/types/errors.go
View file @
730d0fdc
...
...
@@ -59,4 +59,10 @@ var (
ErrConsensClosed
=
errors
.
New
(
"ErrConsensClosed"
)
//ErrBlsSignVerify bls12-381 aggregate sign verify
ErrBlsSignVerify
=
errors
.
New
(
"ErrBlsSignVerify"
)
//ErrParaSupervisionNodeAddrExisted node addr exist in group
ErrParaSupervisionNodeAddrExisted
=
errors
.
New
(
"ErrParaSupervisionNodeAddrExisted"
)
//ErrParaSupervisionNodeGroupNotSet para config node group not set by take over
ErrParaSupervisionNodeGroupNotSet
=
errors
.
New
(
"ErrParaSupervisionNodeGroupNotSet"
)
//ErrParaSupervisionNodeGroupExisted para config group taked over alreay
ErrParaSupervisionNodeGroupExisted
=
errors
.
New
(
"ErrParaSupervisionNodesExisted"
)
)
plugin/dapp/paracross/types/paracross.go
View file @
730d0fdc
...
...
@@ -49,6 +49,12 @@ const (
TyLogParaCrossAssetTransfer
=
670
TyLogParaBindMinerAddr
=
671
TyLogParaBindMinerNode
=
672
TyLogParaSupervisionNodeGroupConfig
=
680
TyLogParaSupervisionNodeGroupAddrsUpdate
TyLogParaSupervisionNodeConfig
TyLogParaSupervisionNodeStatusUpdate
TyLogParaStageSupervisionGroupUpdate
)
// action type
...
...
@@ -164,6 +170,12 @@ const (
ParacrossNodeGroupModify
)
const
(
ParacrossSupervisionNodeApply
=
iota
+
1
ParacrossSupervisionNodeApprove
ParacrossSupervisionNodeQuit
)
var
(
// ParacrossActionCommitStr Commit string
ParacrossActionCommitStr
=
string
(
"Commit"
)
...
...
plugin/dapp/paracross/types/paracross.pb.go
View file @
730d0fdc
This diff is collapsed.
Click to expand it.
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