diff --git a/consensus/spos/bls/v1/subroundBlock.go b/consensus/spos/bls/v1/subroundBlock.go index eac4a7c9204..31485aec724 100644 --- a/consensus/spos/bls/v1/subroundBlock.go +++ b/consensus/spos/bls/v1/subroundBlock.go @@ -415,9 +415,14 @@ func (sr *subroundBlock) receivedBlockBodyAndHeader(ctx context.Context, cnsDta return false } + header := sr.BlockProcessor().DecodeBlockHeader(cnsDta.Header) + if headerHasProof(header) { + return false + } + sr.SetData(cnsDta.BlockHeaderHash) sr.SetBody(sr.BlockProcessor().DecodeBlockBody(cnsDta.Body)) - sr.SetHeader(sr.BlockProcessor().DecodeBlockHeader(cnsDta.Header)) + sr.SetHeader(header) isInvalidData := check.IfNil(sr.GetBody()) || sr.isInvalidHeaderOrData() if isInvalidData { @@ -514,8 +519,13 @@ func (sr *subroundBlock) receivedBlockHeader(ctx context.Context, cnsDta *consen return false } + header := sr.BlockProcessor().DecodeBlockHeader(cnsDta.Header) + if headerHasProof(header) { + return false + } + sr.SetData(cnsDta.BlockHeaderHash) - sr.SetHeader(sr.BlockProcessor().DecodeBlockHeader(cnsDta.Header)) + sr.SetHeader(header) if sr.isInvalidHeaderOrData() { return false @@ -535,6 +545,13 @@ func (sr *subroundBlock) receivedBlockHeader(ctx context.Context, cnsDta *consen return blockProcessedWithSuccess } +func headerHasProof(headerHandler data.HeaderHandler) bool { + if check.IfNil(headerHandler) { + return true + } + return headerHandler.GetPreviousProof() != nil +} + func (sr *subroundBlock) processReceivedBlock(ctx context.Context, cnsDta *consensus.Message) bool { if check.IfNil(sr.GetBody()) { return false diff --git a/consensus/spos/bls/v2/subroundBlock.go b/consensus/spos/bls/v2/subroundBlock.go index 890cf0c5c3c..2454ad3643e 100644 --- a/consensus/spos/bls/v2/subroundBlock.go +++ b/consensus/spos/bls/v2/subroundBlock.go @@ -9,6 +9,7 @@ import ( "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/check" "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-go/common" "github.com/multiversx/mx-chain-go/consensus" "github.com/multiversx/mx-chain-go/consensus/spos" @@ -110,7 +111,6 @@ func (sr *subroundBlock) doBlockJob(ctx context.Context) bool { return false } - // todo: check again the block proof verification & leader signature verification // block proof verification should be done over the header that contains the leader signature leaderSignature, err := sr.signBlockHeader(header) if err != nil { @@ -177,7 +177,7 @@ func printLogMessage(ctx context.Context, baseMessage string, err error) { log.Debug(baseMessage, "error", err.Error()) } -func (sr *subroundBlock) sendBlock(header data.HeaderHandler, body data.BodyHandler, leader string) bool { +func (sr *subroundBlock) sendBlock(header data.HeaderHandler, body data.BodyHandler, _ string) bool { marshalledBody, err := sr.Marshalizer().Marshal(body) if err != nil { log.Debug("sendBlock.Marshal: body", "error", err.Error())