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

ci pass

parent d796f253
This diff is collapsed.
......@@ -269,11 +269,6 @@ func createNodeTx(cmd *cobra.Command, args []string) {
val, _ := cmd.Flags().GetUint32("value")
coins, _ := cmd.Flags().GetFloat64("coins_frozen")
if opAddr == "" {
fmt.Println("addr parameter should not be null")
return
}
payload := &pt.ParaNodeAddrConfig{Op: op, Id: id, Value: val, Addr: opAddr, CoinsFrozen: int64(math.Trunc((coins+0.0000001)*1e4)) * 1e4}
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pt.ParaX),
......@@ -316,15 +311,6 @@ func nodeGroupApply(cmd *cobra.Command, args []string) {
id, _ := cmd.Flags().GetString("id")
coins, _ := cmd.Flags().GetFloat64("coins_frozen")
if op == 0 || op > 3 {
fmt.Println("operation should be one of 1:apply,2:approve,3:quit")
return
}
if addrs == "" {
fmt.Println("addrs should not be nil")
return
}
payload := &pt.ParaNodeGroupConfig{Op: op, Id: id, Addrs: addrs, CoinsFrozen: int64(math.Trunc((coins+0.0000001)*1e4)) * 1e4}
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pt.ParaX),
......
......@@ -419,7 +419,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
}
haveCrossTxs := len(commit.Status.CrossTxHashs) > 0
if types.IsDappFork(a.height, pt.ParaX, pt.ForkCommitTx) && commit.Status.CrossTxHashs[0] == nil {
if commit.Status.Height > 0 && types.IsDappFork(commit.Status.MainBlockHeight, pt.ParaX, pt.ForkCommitTx) && commit.Status.CrossTxHashs[0] == nil {
haveCrossTxs = false
}
......
......@@ -17,8 +17,8 @@ var (
paraConfigNodes string //平行链自组织配置的nodes,最初是从manager同步过来
paraConfigNodeAddr string //平行链配置节点账户
paraNodeGroupStatusAddrs string //正在申请的addrs
paraNodeId string
paraNodeGroupId string
paraNodeID string
paraNodeGroupID string
localTx string
localTitle string
localTitleHeight string
......@@ -35,8 +35,8 @@ func setPrefix() {
paraConfigNodes = "mavl-paracross-nodes-title-"
paraConfigNodeAddr = "mavl-paracross-nodes-titleAddr-"
paraNodeGroupStatusAddrs = "mavl-paracross-nodegroup-apply-title-"
paraNodeId = "mavl-paracross-title-nodeid-"
paraNodeGroupId = "mavl-paracross-title-nodegroupid-"
paraNodeID = "mavl-paracross-title-nodeid-"
paraNodeGroupID = "mavl-paracross-title-nodegroupid-"
localTx = "LODB-paracross-titleHeightAddr-"
localTitle = "LODB-paracross-title-"
localTitleHeight = "LODB-paracross-titleHeight-"
......@@ -78,12 +78,12 @@ func calcParaNodeGroupStatusKey(title string) []byte {
return []byte(fmt.Sprintf(paraNodeGroupStatusAddrs+"%s", title))
}
func calcParaNodeIdKey(title, hash string) string {
return fmt.Sprintf(paraNodeId+"%s-%s", title, hash)
func calcParaNodeIDKey(title, hash string) string {
return fmt.Sprintf(paraNodeID+"%s-%s", title, hash)
}
func calcParaNodeGroupIdKey(title, hash string) string {
return fmt.Sprintf(paraNodeGroupId+"%s-%s", title, hash)
func calcParaNodeGroupIDKey(title, hash string) string {
return fmt.Sprintf(paraNodeGroupID+"%s-%s", title, hash)
}
func calcLocalTxKey(title string, height int64, addr string) []byte {
......@@ -110,9 +110,9 @@ func calcLocalNodeStatusPrefix(title string, status int32) []byte {
return []byte(fmt.Sprintf(localNodeTitleStatus+"%s-%02d-", title, status))
}
func calcLocalNodeTitlePrefix(title string) []byte {
return []byte(fmt.Sprintf(localNodeTitleStatus+"%s-", title))
}
//func calcLocalNodeTitlePrefix(title string) []byte {
// return []byte(fmt.Sprintf(localNodeTitleStatus+"%s-", title))
//}
func calcLocalNodeTitleDone(title, addr string) []byte {
return []byte(fmt.Sprintf(localNodeTitleDone+"%s-%s", title, addr))
......@@ -126,6 +126,6 @@ func calcLocalNodeGroupStatusPrefix(status int32) []byte {
return []byte(fmt.Sprintf(localNodeGroupStatusTitle+"%02d-", status))
}
func calcLocalNodeGroupAllPrefix() []byte {
return []byte(fmt.Sprintf(localNodeGroupStatusTitle))
}
//func calcLocalNodeGroupAllPrefix() []byte {
// return []byte(fmt.Sprintf(localNodeGroupStatusTitle))
//}
......@@ -89,7 +89,7 @@ func (p *Paracross) Query_GetNodeAddrInfo(in *pt.ReqParacrossNodeInfo) (types.Me
if err != nil {
return nil, err
}
stat, err := getNodeId(p.GetStateDB(), addrStat.ProposalId)
stat, err := getNodeID(p.GetStateDB(), addrStat.ProposalId)
if err != nil {
return nil, err
}
......
......@@ -46,7 +46,7 @@ func getNodeAddr(db dbm.KV, title, addr string) (*pt.ParaNodeAddrIdStatus, error
return &status, err
}
func getNodeId(db dbm.KV, id string) (*pt.ParaNodeIdStatus, error) {
func getNodeID(db dbm.KV, id string) (*pt.ParaNodeIdStatus, error) {
val, err := getDb(db, []byte(id))
if err != nil {
return nil, err
......@@ -77,7 +77,7 @@ func getDb(db dbm.KV, key []byte) ([]byte, error) {
return val, nil
}
func getNodeGroupId(db dbm.KV, id string) (*pt.ParaNodeGroupStatus, error) {
func getNodeGroupID(db dbm.KV, id string) (*pt.ParaNodeGroupStatus, error) {
val, err := getDb(db, []byte(id))
if err != nil {
return nil, err
......@@ -135,7 +135,7 @@ func makeNodeConfigReceipt(fromAddr string, config *pt.ParaNodeAddrConfig, prev,
}
}
func makeNodeGroupIdReceipt(addr string, prev, current *pt.ParaNodeGroupStatus) *types.Receipt {
func makeNodeGroupIDReceipt(addr string, prev, current *pt.ParaNodeGroupStatus) *types.Receipt {
log := &pt.ReceiptParaNodeGroupConfig{
Addr: addr,
Prev: prev,
......@@ -230,7 +230,7 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
clog.Info("first time add node addr", "title", config.Title, "addr", config.Addr)
stat := &pt.ParaNodeIdStatus{
Id: calcParaNodeIdKey(config.Title, common.ToHex(a.txhash)),
Id: calcParaNodeIDKey(config.Title, common.ToHex(a.txhash)),
Status: pt.ParacrossNodeJoining,
Title: config.Title,
TargetAddr: config.Addr,
......@@ -243,7 +243,11 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return receipt, nil
}
stat, err := getNodeId(a.db, addrStat.ProposalId)
stat, err := getNodeID(a.db, addrStat.ProposalId)
if err != nil {
clog.Error("nodeaccount.getNodeID fail", "err", err.Error())
return nil, err
}
var copyStat pt.ParaNodeIdStatus
err = deepCopy(&copyStat, stat)
if err != nil {
......@@ -252,7 +256,7 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
if stat.Status == pt.ParacrossNodeQuited {
stat = &pt.ParaNodeIdStatus{
Id: calcParaNodeIdKey(config.Title, common.ToHex(a.txhash)),
Id: calcParaNodeIDKey(config.Title, common.ToHex(a.txhash)),
Status: pt.ParacrossNodeJoining,
Title: config.Title,
TargetAddr: config.Addr,
......@@ -271,7 +275,7 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
func (a *action) nodeQuit(config *pt.ParaNodeAddrConfig) (*types.Receipt, error) {
stat, err := getNodeId(a.db, config.Id)
stat, err := getNodeID(a.db, config.Id)
if err != nil {
return nil, err
}
......@@ -404,7 +408,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return nil, errors.Wrapf(pt.ErrNodeNotForTheTitle, "not validNode:%s", a.fromaddr)
}
stat, err := getNodeId(a.db, config.Id)
stat, err := getNodeID(a.db, config.Id)
if err != nil {
return nil, err
}
......@@ -657,7 +661,7 @@ func (a *action) nodeGroupApply(config *pt.ParaNodeGroupConfig) (*types.Receipt,
}
stat := &pt.ParaNodeGroupStatus{
Id: calcParaNodeGroupIdKey(config.Title, common.ToHex(a.txhash)),
Id: calcParaNodeGroupIDKey(config.Title, common.ToHex(a.txhash)),
Status: pt.ParacrossNodeGroupApply,
Title: config.Title,
TargetAddrs: strings.Join(addrs, ","),
......@@ -665,7 +669,7 @@ func (a *action) nodeGroupApply(config *pt.ParaNodeGroupConfig) (*types.Receipt,
MainHeight: a.exec.GetMainHeight(),
EmptyBlockInterval: config.EmptyBlockInterval,
FromAddr: a.fromaddr}
r := makeNodeGroupIdReceipt(a.fromaddr, nil, stat)
r := makeNodeGroupIDReceipt(a.fromaddr, nil, stat)
receipt.KV = append(receipt.KV, r.KV...)
receipt.Logs = append(receipt.Logs, r.Logs...)
......@@ -675,13 +679,13 @@ func (a *action) nodeGroupApply(config *pt.ParaNodeGroupConfig) (*types.Receipt,
func (a *action) nodeGroupModify(config *pt.ParaNodeGroupConfig) (*types.Receipt, error) {
receipt := &types.Receipt{Ty: types.ExecOk}
stat := &pt.ParaNodeGroupStatus{
Id: calcParaNodeGroupIdKey(config.Title, common.ToHex(a.txhash)),
Id: calcParaNodeGroupIDKey(config.Title, common.ToHex(a.txhash)),
Status: pt.ParacrossNodeGroupModify,
Title: config.Title,
CoinsFrozen: config.CoinsFrozen,
MainHeight: a.exec.GetMainHeight(),
EmptyBlockInterval: config.EmptyBlockInterval}
r := makeNodeGroupIdReceipt(a.fromaddr, nil, stat)
r := makeNodeGroupIDReceipt(a.fromaddr, nil, stat)
receipt.KV = append(receipt.KV, r.KV...)
receipt.Logs = append(receipt.Logs, r.Logs...)
......@@ -689,7 +693,7 @@ func (a *action) nodeGroupModify(config *pt.ParaNodeGroupConfig) (*types.Receipt
}
func (a *action) nodeGroupQuit(config *pt.ParaNodeGroupConfig) (*types.Receipt, error) {
status, err := getNodeGroupId(a.db, config.Id)
status, err := getNodeGroupID(a.db, config.Id)
if err != nil {
return nil, err
}
......@@ -720,7 +724,7 @@ func (a *action) nodeGroupQuit(config *pt.ParaNodeGroupConfig) (*types.Receipt,
copyStat := *status
status.Status = pt.ParacrossNodeGroupQuit
r := makeNodeGroupIdReceipt(a.fromaddr, &copyStat, status)
r := makeNodeGroupIDReceipt(a.fromaddr, &copyStat, status)
receipt.KV = append(receipt.KV, r.KV...)
receipt.Logs = append(receipt.Logs, r.Logs...)
......@@ -743,7 +747,7 @@ func (a *action) nodeGroupApproveModify(config *pt.ParaNodeGroupConfig, modify *
copyModify := *modify
modify.Status = pt.ParacrossNodeGroupApprove
r := makeNodeGroupIdReceipt(a.fromaddr, &copyModify, modify)
r := makeNodeGroupIDReceipt(a.fromaddr, &copyModify, modify)
receipt.KV = append(receipt.KV, r.KV...)
receipt.Logs = append(receipt.Logs, r.Logs...)
......@@ -784,7 +788,7 @@ func (a *action) nodeGroupApproveApply(config *pt.ParaNodeGroupConfig, apply *pt
apply.Status = pt.ParacrossNodeGroupApprove
apply.MainHeight = a.exec.GetMainHeight()
r = makeNodeGroupIdReceipt(a.fromaddr, &copyStat, apply)
r = makeNodeGroupIDReceipt(a.fromaddr, &copyStat, apply)
receipt.KV = append(receipt.KV, r.KV...)
receipt.Logs = append(receipt.Logs, r.Logs...)
......@@ -803,7 +807,7 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
return nil, types.ErrNotAllow
}
id, err := getNodeGroupId(a.db, config.Id)
id, err := getNodeGroupID(a.db, config.Id)
if err != nil {
return nil, err
}
......
......@@ -104,7 +104,7 @@ func checkGroupApplyReceipt(suite *NodeManageTestSuite, receipt *types.Receipt)
assert.Len(suite.T(), receipt.KV, 1)
assert.Len(suite.T(), receipt.Logs, 1)
var stat pt.ParaNodeAddrStatus
var stat pt.ParaNodeIdStatus
err := types.Decode(receipt.KV[0].Value, &stat)
assert.Nil(suite.T(), err, "decode ParaNodeAddrStatus failed")
//suite.T().Log("titleHeight", titleHeight)
......@@ -120,7 +120,7 @@ func checkGroupApproveReceipt(suite *NodeManageTestSuite, receipt *types.Receipt
len := len(receipt.KV)
var stat pt.ParaNodeAddrStatus
var stat pt.ParaNodeIdStatus
err := types.Decode(receipt.KV[len-1].Value, &stat)
assert.Nil(suite.T(), err, "decode ParaNodeAddrStatus failed")
//suite.T().Log("titleHeight", titleHeight)
......@@ -134,7 +134,7 @@ func checkJoinReceipt(suite *NodeManageTestSuite, receipt *types.Receipt) {
assert.Len(suite.T(), receipt.KV, 1)
assert.Len(suite.T(), receipt.Logs, 1)
var stat pt.ParaNodeAddrStatus
var stat pt.ParaNodeIdStatus
err := types.Decode(receipt.KV[0].Value, &stat)
assert.Nil(suite.T(), err, "decode ParaNodeAddrStatus failed")
//suite.T().Log("titleHeight", titleHeight)
......@@ -149,7 +149,7 @@ func checkQuitReceipt(suite *NodeManageTestSuite, receipt *types.Receipt) {
assert.Len(suite.T(), receipt.KV, 1)
assert.Len(suite.T(), receipt.Logs, 1)
var stat pt.ParaNodeAddrStatus
var stat pt.ParaNodeIdStatus
err := types.Decode(receipt.KV[0].Value, &stat)
assert.Nil(suite.T(), err, "decode ParaNodeAddrStatus failed")
//suite.T().Log("titleHeight", titleHeight)
......@@ -164,7 +164,7 @@ func checkVoteReceipt(suite *NodeManageTestSuite, receipt *types.Receipt, count
assert.Len(suite.T(), receipt.KV, 1)
assert.Len(suite.T(), receipt.Logs, 1)
var stat pt.ParaNodeAddrStatus
var stat pt.ParaNodeIdStatus
err := types.Decode(receipt.KV[0].Value, &stat)
assert.Nil(suite.T(), err, "decode ParaNodeAddrStatus failed")
assert.Len(suite.T(), stat.Votes.Votes, count)
......@@ -176,7 +176,7 @@ func checkVoteDoneReceipt(suite *NodeManageTestSuite, receipt *types.Receipt, co
assert.Len(suite.T(), receipt.KV, 2)
assert.Len(suite.T(), receipt.Logs, 3)
var stat pt.ParaNodeAddrStatus
var stat pt.ParaNodeIdStatus
err := types.Decode(receipt.KV[0].Value, &stat)
assert.Nil(suite.T(), err, "decode ParaNodeAddrStatus failed")
assert.Len(suite.T(), stat.Votes.Votes, count)
......
......@@ -94,6 +94,7 @@ const (
ParaNodeQuit
)
// node vote op
const (
ParaNodeVoteInvalid = iota
ParaNodeVoteYes
......@@ -101,6 +102,7 @@ const (
ParaNodeVoteEnd
)
// ParaNodeVoteStr
var ParaNodeVoteStr = []string{"invalid", "yes", "no"}
const (
......
......@@ -64,7 +64,7 @@ func (p *ParacrossType) GetLogMap() map[int64]*types.LogInfo {
TyLogParaNodeConfig: {Ty: reflect.TypeOf(ReceiptParaNodeConfig{}), Name: "LogParaNodeConfig"},
TyLogParaNodeGroupAddrsUpdate: {Ty: reflect.TypeOf(types.ReceiptConfig{}), Name: "LogParaNodeGroupAddrsUpdate"},
TyLogParaNodeVoteDone: {Ty: reflect.TypeOf(ReceiptParaNodeVoteDone{}), Name: "LogParaNodeVoteDone"},
TyLogParaNodeGroupConfig: {Ty: reflect.TypeOf(ReceiptParaNodeGroupConfig{}), Name: "LogParaNodeGroupApply"},
TyLogParaNodeGroupConfig: {Ty: reflect.TypeOf(ReceiptParaNodeGroupConfig{}), Name: "LogParaNodeGroupConfig"},
TyLogParaNodeGroupStatusUpdate: {Ty: reflect.TypeOf(ReceiptParaNodeGroupConfig{}), Name: "LogParaNodeGroupStatusUpdate"},
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment