Merge pull request #1533 from chaosma/master

add ToShardID verification
pull/1525/head
chaosma 5 years ago committed by GitHub
commit dd4a038949
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      node/node_cross_shard.go
  2. 7
      node/node_newblock.go

@ -221,6 +221,12 @@ func (node *Node) verifyIncomingReceipts(block *types.Block) error {
} }
m[hash] = true m[hash] = true
for _, item := range cxp.Receipts {
if item.ToShardID != node.Blockchain().ShardID() {
return ctxerror.New("[verifyIncomingReceipts] Invalid ToShardID", "myShardID", node.Blockchain().ShardID(), "expectShardID", item.ToShardID)
}
}
if err := core.IsValidCXReceiptsProof(cxp); err != nil { if err := core.IsValidCXReceiptsProof(cxp); err != nil {
return ctxerror.New("[verifyIncomingReceipts] verification failed").WithCause(err) return ctxerror.New("[verifyIncomingReceipts] verification failed").WithCause(err)
} }

@ -207,6 +207,7 @@ func (node *Node) proposeReceiptsProof() []*types.CXReceiptsProof {
m := make(map[common.Hash]bool) m := make(map[common.Hash]bool)
Loop:
for _, cxp := range node.pendingCXReceipts { for _, cxp := range node.pendingCXReceipts {
if numProposed > IncomingReceiptsLimit { if numProposed > IncomingReceiptsLimit {
pendingReceiptsList = append(pendingReceiptsList, cxp) pendingReceiptsList = append(pendingReceiptsList, cxp)
@ -225,6 +226,12 @@ func (node *Node) proposeReceiptsProof() []*types.CXReceiptsProof {
m[hash] = true m[hash] = true
} }
for _, item := range cxp.Receipts {
if item.ToShardID != node.Blockchain().ShardID() {
continue Loop
}
}
if err := core.IsValidCXReceiptsProof(cxp); err != nil { if err := core.IsValidCXReceiptsProof(cxp); err != nil {
utils.Logger().Error().Err(err).Msg("[proposeReceiptsProof] Invalid CXReceiptsProof") utils.Logger().Error().Err(err).Msg("[proposeReceiptsProof] Invalid CXReceiptsProof")
continue continue

Loading…
Cancel
Save