Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6ecd517
adapt integration tests for consensus v2
ssd04 Dec 18, 2024
5c42932
Merge branch 'feat/equivalent-messages' into consensus-v2-integration…
AdoAdoAdo Dec 19, 2024
30f6c12
added separate single keys test with equivalent proofs
ssd04 Dec 23, 2024
4a4f9b2
remove unused code
ssd04 Jan 9, 2025
e9ec8bf
Merge branch 'equivalent-proofs-feat-stabilization' into consensus-v2…
ssd04 Jan 15, 2025
c7c2154
Merge branch 'feat/equivalent-messages' into consensus-v2-integration…
ssd04 Jan 20, 2025
27a42c9
Merge branch 'feat/equivalent-messages' into consensus-v2-integration…
ssd04 Jan 26, 2025
528d092
Merge branch 'equivalent-proofs-stabilization-2' into consensus-v2-in…
ssd04 Jan 27, 2025
6f29b71
added full integration test - without equivalent proofs activation
ssd04 Jan 26, 2025
e45434e
integration tests meta chain fixes
ssd04 Jan 28, 2025
bba0165
check for genesis block
ssd04 Jan 28, 2025
06ff80e
integration tests meta chain fixes
ssd04 Jan 28, 2025
22598c3
sync test fixes
ssd04 Jan 28, 2025
1451498
cleanup unused code
ssd04 Jan 28, 2025
9f6e666
include genesis header check
ssd04 Jan 28, 2025
ad69364
update integration test with invalid signers
ssd04 Jan 31, 2025
8b53a28
added trace log messages
ssd04 Jan 31, 2025
1887e15
added sync test with more meta nodes
ssd04 Jan 31, 2025
c21a678
Merge branch 'feat/equivalent-messages' into consensus-v2-integration…
ssd04 Jan 31, 2025
84b2255
fix linter issues
ssd04 Jan 31, 2025
2893cf2
Merge branch 'feat/equivalent-messages' into consensus-v2-integration…
ssd04 Jan 31, 2025
0ef4c06
Merge branch 'feat/equivalent-messages' into consensus-v2-integration…
ssd04 Jan 31, 2025
92c1f0b
fix config after merge
ssd04 Jan 31, 2025
a32849b
use common function for full node start
ssd04 Jan 31, 2025
22edddc
fix linter issue
ssd04 Jan 31, 2025
2716384
fixes after review
ssd04 Feb 5, 2025
8a3ca7a
remove duplicated code
ssd04 Feb 6, 2025
e5eb36a
update check + additional check for genesis block
ssd04 Feb 6, 2025
14e6645
Merge branch 'feat/equivalent-messages' into consensus-v2-integration…
sstanculeanu Feb 6, 2025
ecbb55f
fix genesis time
ssd04 Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion consensus/spos/bls/v2/subroundBlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,10 @@ func (sr *subroundBlock) isHeaderForCurrentConsensus(header data.HeaderHandler)
func (sr *subroundBlock) getLeaderForHeader(headerHandler data.HeaderHandler) ([]byte, error) {
nc := sr.NodesCoordinator()

prevBlockEpoch := sr.Blockchain().GetCurrentBlockHeader().GetEpoch()
prevBlockEpoch := uint32(0)
if sr.Blockchain().GetCurrentBlockHeader() != nil {
prevBlockEpoch = sr.Blockchain().GetCurrentBlockHeader().GetEpoch()
}
// TODO: remove this if first block in new epoch will be validated by epoch validators
// first block in epoch is validated by previous epoch validators
selectionEpoch := headerHandler.GetEpoch()
Expand Down
8 changes: 7 additions & 1 deletion consensus/spos/bls/v2/subroundEndRound.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (sr *subroundEndRound) checkGoRoutinesThrottler(ctx context.Context) error
func (sr *subroundEndRound) verifySignature(i int, pk string, sigShare []byte) error {
err := sr.SigningHandler().VerifySignatureShare(uint16(i), sigShare, sr.GetData(), sr.GetHeader().GetEpoch())
if err != nil {
log.Trace("VerifySignatureShare returned an error: ", err)
log.Trace("VerifySignatureShare returned an error: ", "error", err)
errSetJob := sr.SetJobDone(pk, bls.SrSignature, false)
if errSetJob != nil {
return errSetJob
Expand Down Expand Up @@ -541,6 +541,12 @@ func (sr *subroundEndRound) computeAggSigOnValidNodes() ([]byte, []byte, error)
return nil, nil, err
}

log.Trace("computeAggSigOnValidNodes",
"bitmap", bitmap,
"threshold", threshold,
"numValidSigShares", numValidSigShares,
)

return bitmap, sig, nil
}

Expand Down
5 changes: 5 additions & 0 deletions consensus/spos/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@ func (wrk *Worker) doJobOnMessageWithSignature(cnsMsg *consensus.Message, p2pMsg
wrk.mapDisplayHashConsensusMessage[hash] = append(wrk.mapDisplayHashConsensusMessage[hash], cnsMsg)

wrk.consensusState.AddMessageWithSignature(string(cnsMsg.PubKey), p2pMsg)

log.Trace("received message with signature",
"from", core.GetTrimmedPk(hex.EncodeToString(cnsMsg.PubKey)),
"header hash", cnsMsg.BlockHeaderHash,
)
}

func (wrk *Worker) addBlockToPool(bodyBytes []byte) {
Expand Down
64 changes: 34 additions & 30 deletions integrationTests/consensus/consensusSigning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"bytes"
"encoding/hex"
"fmt"
"sync"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-go/integrationTests"
)

Expand All @@ -20,25 +21,27 @@ func initNodesWithTestSigner(
numInvalid uint32,
roundTime uint64,
consensusType string,
) map[uint32][]*integrationTests.TestConsensusNode {
) map[uint32][]*integrationTests.TestFullNode {

fmt.Println("Step 1. Setup nodes...")

equivalentProofsActivationEpoch := uint32(0)

enableEpochsConfig := integrationTests.CreateEnableEpochsConfig()
nodes := integrationTests.CreateNodesWithTestConsensusNode(
enableEpochsConfig.EquivalentMessagesEnableEpoch = equivalentProofsActivationEpoch
enableEpochsConfig.FixedOrderInConsensusEnableEpoch = equivalentProofsActivationEpoch

nodes := integrationTests.CreateNodesWithTestFullNode(
int(numMetaNodes),
int(numNodes),
int(consensusSize),
roundTime,
consensusType,
1,
enableEpochsConfig,
false,
)

for shardID, nodesList := range nodes {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the nodes started somewehere else now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, added a common function for this

displayAndStartNodes(shardID, nodesList)
}

time.Sleep(p2pBootstrapDelay)

for shardID := range nodes {
Expand All @@ -54,7 +57,7 @@ func initNodesWithTestSigner(
// sig share with invalid size
invalidSigShare = bytes.Repeat([]byte("a"), 3)
}
log.Warn("invalid sig share from ", "pk", getPkEncoded(nodes[shardID][ii].NodeKeys.Pk), "sig", invalidSigShare)
log.Warn("invalid sig share from ", "pk", getPkEncoded(nodes[shardID][ii].NodeKeys.MainKey.Pk), "sig", invalidSigShare)

return invalidSigShare, nil
}
Expand All @@ -75,7 +78,6 @@ func TestConsensusWithInvalidSigners(t *testing.T) {
consensusSize := uint32(4)
numInvalid := uint32(1)
roundTime := uint64(1000)
numCommBlock := uint64(8)

nodes := initNodesWithTestSigner(numMetaNodes, numNodes, consensusSize, numInvalid, roundTime, blsConsensusType)

Expand All @@ -92,27 +94,29 @@ func TestConsensusWithInvalidSigners(t *testing.T) {
fmt.Println("Start consensus...")
time.Sleep(time.Second)

for shardID := range nodes {
mutex := &sync.Mutex{}
nonceForRoundMap := make(map[uint64]uint64)
totalCalled := 0

err := startNodesWithCommitBlock(nodes[shardID], mutex, nonceForRoundMap, &totalCalled)
assert.Nil(t, err)

chDone := make(chan bool)
go checkBlockProposedEveryRound(numCommBlock, nonceForRoundMap, mutex, chDone, t)

extraTime := uint64(2)
endTime := time.Duration(roundTime)*time.Duration(numCommBlock+extraTime)*time.Millisecond + time.Minute
select {
case <-chDone:
case <-time.After(endTime):
mutex.Lock()
log.Error("currently saved nonces for rounds", "nonceForRoundMap", nonceForRoundMap)
assert.Fail(t, "consensus too slow, not working.")
mutex.Unlock()
return
for _, nodesList := range nodes {
for _, n := range nodesList {
err := startFullConsensusNode(n)
require.Nil(t, err)
}
}

fmt.Println("Wait for several rounds...")

time.Sleep(15 * time.Second)

fmt.Println("Checking shards...")

expectedNonce := uint64(10)
for _, nodesList := range nodes {
for _, n := range nodesList {
for i := 1; i < len(nodes); i++ {
if check.IfNil(n.Node.GetDataComponents().Blockchain().GetCurrentBlockHeader()) {
assert.Fail(t, fmt.Sprintf("Node with idx %d does not have a current block", i))
} else {
assert.GreaterOrEqual(t, n.Node.GetDataComponents().Blockchain().GetCurrentBlockHeader().GetNonce(), expectedNonce)
}
}
}
}
}
Loading