From 49dfdb3ec7d86942e7cc48680658b51865367820 Mon Sep 17 00:00:00 2001 From: ssd04 Date: Mon, 29 Jun 2026 13:35:34 +0300 Subject: [PATCH 01/13] hardening invalid signers verification --- .../spos/bls/proxy/subroundsHandler_test.go | 1 + consensus/spos/bls/v2/common.go | 27 ++++++ consensus/spos/bls/v2/common_test.go | 90 +++++++++++++++++++ consensus/spos/bls/v2/errors.go | 6 ++ consensus/spos/bls/v2/subroundEndRound.go | 23 +++-- .../spos/bls/v2/subroundEndRound_test.go | 69 ++++++++++++++ consensus/spos/bls/v2/subroundSignature.go | 14 +-- consensus/spos/consensusCore.go | 14 +++ consensus/spos/consensusCoreValidator.go | 3 + consensus/spos/consensusCoreValidator_test.go | 13 +++ consensus/spos/consensusCore_test.go | 15 ++++ consensus/spos/interface.go | 2 + factory/consensus/consensusComponents.go | 1 + testscommon/consensus/mockTestInitializer.go | 2 + 14 files changed, 254 insertions(+), 26 deletions(-) create mode 100644 consensus/spos/bls/v2/common.go create mode 100644 consensus/spos/bls/v2/common_test.go diff --git a/consensus/spos/bls/proxy/subroundsHandler_test.go b/consensus/spos/bls/proxy/subroundsHandler_test.go index 287e2701eee..0cdae687285 100644 --- a/consensus/spos/bls/proxy/subroundsHandler_test.go +++ b/consensus/spos/bls/proxy/subroundsHandler_test.go @@ -78,6 +78,7 @@ func getDefaultArgumentsSubroundHandler() (*SubroundsHandlerArgs, *spos.Consensu consensusCore.SetScheduledProcessor(&consensus.ScheduledProcessorStub{}) consensusCore.SetMessageSigningHandler(&mock2.MessageSigningHandlerStub{}) consensusCore.SetPeerBlacklistHandler(&mock2.PeerBlacklistHandlerStub{}) + consensusCore.SetPeerSignatureHandler(&cryptoMocks.PeerSignatureHandlerStub{}) consensusCore.SetSigningHandler(&consensus.SigningHandlerStub{}) consensusCore.SetEnableEpochsHandler(epochsEnable) consensusCore.SetEquivalentProofsPool(&dataRetriever.ProofsPoolMock{}) diff --git a/consensus/spos/bls/v2/common.go b/consensus/spos/bls/v2/common.go new file mode 100644 index 00000000000..41f04a2e610 --- /dev/null +++ b/consensus/spos/bls/v2/common.go @@ -0,0 +1,27 @@ +package v2 + +import ( + "context" + "fmt" + "time" + + "github.com/multiversx/mx-chain-core-go/core" + + "github.com/multiversx/mx-chain-go/consensus/spos" +) + +func checkGoRoutinesThrottler(ctx context.Context, throttler core.Throttler) error { + for { + if throttler.CanProcess() { + break + } + + select { + case <-time.After(time.Millisecond): + continue + case <-ctx.Done(): + return fmt.Errorf("%w while checking the throttler", spos.ErrTimeIsOut) + } + } + return nil +} diff --git a/consensus/spos/bls/v2/common_test.go b/consensus/spos/bls/v2/common_test.go new file mode 100644 index 00000000000..94de6c05fa4 --- /dev/null +++ b/consensus/spos/bls/v2/common_test.go @@ -0,0 +1,90 @@ +package v2 + +import ( + "context" + "sync/atomic" + "testing" + "time" + + "github.com/stretchr/testify/assert" + + dataRetrieverMock "github.com/multiversx/mx-chain-go/dataRetriever/mock" +) + +func TestCheckGoRoutinesThrottler(t *testing.T) { + t.Parallel() + + t.Run("CanProcess returns true should return nil immediately", func(t *testing.T) { + t.Parallel() + + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + + throttler := &dataRetrieverMock.ThrottlerStub{ + CanProcessCalled: func() bool { + return true + }, + } + + err := checkGoRoutinesThrottler(ctx, throttler) + assert.Nil(t, err) + }) + + t.Run("CanProcess returns false for a period of time, then true, should return nil", func(t *testing.T) { + t.Parallel() + + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + + var numCalls int32 + throttler := &dataRetrieverMock.ThrottlerStub{ + CanProcessCalled: func() bool { + return atomic.AddInt32(&numCalls, 1) >= 5 + }, + } + + err := checkGoRoutinesThrottler(ctx, throttler) + assert.Nil(t, err) + assert.GreaterOrEqual(t, atomic.LoadInt32(&numCalls), int32(5)) + }) + + t.Run("CanProcess always returns false should return error when context is done", func(t *testing.T) { + t.Parallel() + + ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond) + defer cancel() + + var numCalls int32 + throttler := &dataRetrieverMock.ThrottlerStub{ + CanProcessCalled: func() bool { + atomic.AddInt32(&numCalls, 1) + return false + }, + } + + err := checkGoRoutinesThrottler(ctx, throttler) + assert.NotNil(t, err) + assert.ErrorContains(t, err, "time is out") + assert.ErrorContains(t, err, "while checking the throttler") + assert.Greater(t, atomic.LoadInt32(&numCalls), int32(1)) + }) + + t.Run("context already canceled and CanProcess returns false should return error without retrying", func(t *testing.T) { + t.Parallel() + + ctx, cancel := context.WithCancel(context.Background()) + cancel() + + var numCalls int32 + throttler := &dataRetrieverMock.ThrottlerStub{ + CanProcessCalled: func() bool { + atomic.AddInt32(&numCalls, 1) + return false + }, + } + + err := checkGoRoutinesThrottler(ctx, throttler) + assert.NotNil(t, err) + assert.ErrorContains(t, err, "time is out") + }) +} diff --git a/consensus/spos/bls/v2/errors.go b/consensus/spos/bls/v2/errors.go index 0966f935032..6ae0b01f25c 100644 --- a/consensus/spos/bls/v2/errors.go +++ b/consensus/spos/bls/v2/errors.go @@ -16,3 +16,9 @@ var ErrValidSignatureFromInvalidSigner = errors.New("valid signature from invali // ErrHeaderHashMismatch signals that header hash does not match var ErrHeaderHashMismatch = errors.New("header hash does not match") + +// ErrPublicKeyMismatch signals that the BLS public key in the message does not belong to the transport sender +var ErrPublicKeyMismatch = errors.New("public key does not match the message sender") + +// ErrSignerNotInConsensusGroup signals that the signer is not part of the current consensus group +var ErrSignerNotInConsensusGroup = errors.New("signer is not part of the consensus group") diff --git a/consensus/spos/bls/v2/subroundEndRound.go b/consensus/spos/bls/v2/subroundEndRound.go index 3f4575e913f..41f0e81bf39 100644 --- a/consensus/spos/bls/v2/subroundEndRound.go +++ b/consensus/spos/bls/v2/subroundEndRound.go @@ -220,11 +220,20 @@ func (sr *subroundEndRound) verifyInvalidSigner( return "", spos.ErrInvalidMessageType } + if !sr.IsNodeInConsensusGroup(string(cnsMsg.PubKey)) { + return "", ErrSignerNotInConsensusGroup + } + err = sr.MessageSigningHandler().Verify(msg) if err != nil { return "", err } + err = sr.PeerSignatureHandler().VerifyPeerSignature(cnsMsg.PubKey, msg.Peer(), cnsMsg.Signature) + if err != nil { + return "", ErrPublicKeyMismatch + } + if !bytes.Equal(headerHash, cnsMsg.BlockHeaderHash) { return "", ErrHeaderHashMismatch } @@ -441,19 +450,7 @@ func (sr *subroundEndRound) aggregateSigsAndHandleInvalidSigners(bitmap []byte, } func (sr *subroundEndRound) checkGoRoutinesThrottler(ctx context.Context) error { - for { - if sr.signatureThrottler.CanProcess() { - break - } - - select { - case <-time.After(time.Millisecond): - continue - case <-ctx.Done(): - return spos.ErrTimeIsOut - } - } - return nil + return checkGoRoutinesThrottler(ctx, sr.signatureThrottler) } // verifySignature implements parallel signature verification diff --git a/consensus/spos/bls/v2/subroundEndRound_test.go b/consensus/spos/bls/v2/subroundEndRound_test.go index 6a38beb4baf..c0b4a43aade 100644 --- a/consensus/spos/bls/v2/subroundEndRound_test.go +++ b/consensus/spos/bls/v2/subroundEndRound_test.go @@ -34,6 +34,7 @@ import ( "github.com/multiversx/mx-chain-go/testscommon" consensusMocks "github.com/multiversx/mx-chain-go/testscommon/consensus" "github.com/multiversx/mx-chain-go/testscommon/consensus/initializers" + "github.com/multiversx/mx-chain-go/testscommon/cryptoMocks" "github.com/multiversx/mx-chain-go/testscommon/dataRetriever" "github.com/multiversx/mx-chain-go/testscommon/enableEpochsHandlerMock" "github.com/multiversx/mx-chain-go/testscommon/p2pmocks" @@ -1757,6 +1758,43 @@ func TestVerifyInvalidSigners(t *testing.T) { require.Equal(t, expectedErr, err) }) + t.Run("peer signature binding fails should error with ErrPublicKeyMismatch", func(t *testing.T) { + t.Parallel() + + container := consensusMocks.InitConsensusCore() + + consensusMsg := &consensus.Message{ + BlockHeaderHash: headerHash, + PubKey: pubKey, + MsgType: int64(bls.MtSignature), + } + consensusMsgBytes, _ := container.Marshalizer().Marshal(consensusMsg) + + invalidSigners := []p2p.MessageP2P{&factory.Message{ + FromField: []byte("attackerPid"), + DataField: consensusMsgBytes, + }} + invalidSignersBytes, _ := container.Marshalizer().Marshal(invalidSigners) + + messageSigningHandler := &mock.MessageSigningHandlerStub{ + DeserializeCalled: func(messagesBytes []byte) ([]p2p.MessageP2P, error) { + return invalidSigners, nil + }, + } + container.SetMessageSigningHandler(messageSigningHandler) + + container.SetPeerSignatureHandler(&cryptoMocks.PeerSignatureHandlerStub{ + VerifyPeerSignatureCalled: func(pk []byte, pid core.PeerID, signature []byte) error { + return expectedErr + }, + }) + + sr := initSubroundEndRoundWithContainer(container, &statusHandler.AppStatusHandlerStub{}) + + _, err := sr.VerifyInvalidSigners(headerHash, invalidSignersBytes) + require.Equal(t, v2.ErrPublicKeyMismatch, err) + }) + t.Run("invalid message type should err", func(t *testing.T) { t.Parallel() @@ -1799,6 +1837,37 @@ func TestVerifyInvalidSigners(t *testing.T) { require.False(t, wasCalled) }) + t.Run("signer not in consensus group should err", func(t *testing.T) { + t.Parallel() + + container := consensusMocks.InitConsensusCore() + + unknownPubKey := []byte("unknownKey") + consensusMsg := &consensus.Message{ + PubKey: unknownPubKey, + MsgType: int64(bls.MtSignature), + } + consensusMsgBytes, _ := container.Marshalizer().Marshal(consensusMsg) + + invalidSigners := []p2p.MessageP2P{&factory.Message{ + FromField: []byte("from"), + DataField: consensusMsgBytes, + }} + invalidSignersBytes, _ := container.Marshalizer().Marshal(invalidSigners) + + messageSigningHandler := &mock.MessageSigningHandlerStub{ + DeserializeCalled: func(messagesBytes []byte) ([]p2p.MessageP2P, error) { + return invalidSigners, nil + }, + } + container.SetMessageSigningHandler(messageSigningHandler) + + sr := initSubroundEndRoundWithContainer(container, &statusHandler.AppStatusHandlerStub{}) + + _, err := sr.VerifyInvalidSigners(headerHash, invalidSignersBytes) + require.Equal(t, v2.ErrSignerNotInConsensusGroup, err) + }) + t.Run("failed to verify signature share", func(t *testing.T) { t.Parallel() diff --git a/consensus/spos/bls/v2/subroundSignature.go b/consensus/spos/bls/v2/subroundSignature.go index d6cb7fddddc..380b01e5b89 100644 --- a/consensus/spos/bls/v2/subroundSignature.go +++ b/consensus/spos/bls/v2/subroundSignature.go @@ -2,7 +2,6 @@ package v2 import ( "context" - "fmt" "sync" "sync/atomic" "time" @@ -268,18 +267,7 @@ func (sr *subroundSignature) sendSignatureForManagedKey(idx int, pk string) bool } func (sr *subroundSignature) checkGoRoutinesThrottler(ctx context.Context) error { - for { - if sr.signatureThrottler.CanProcess() { - break - } - select { - case <-time.After(timeSpentBetweenChecks): - continue - case <-ctx.Done(): - return fmt.Errorf("%w while checking the throttler", spos.ErrTimeIsOut) - } - } - return nil + return checkGoRoutinesThrottler(ctx, sr.signatureThrottler) } func (sr *subroundSignature) doSignatureJobForSingleKey() bool { diff --git a/consensus/spos/consensusCore.go b/consensus/spos/consensusCore.go index 79fe05c65e7..863382f789f 100644 --- a/consensus/spos/consensusCore.go +++ b/consensus/spos/consensusCore.go @@ -4,6 +4,7 @@ import ( "github.com/multiversx/mx-chain-core-go/data" "github.com/multiversx/mx-chain-core-go/hashing" "github.com/multiversx/mx-chain-core-go/marshal" + crypto "github.com/multiversx/mx-chain-crypto-go" "github.com/multiversx/mx-chain-go/common" cryptoCommon "github.com/multiversx/mx-chain-go/common/crypto" @@ -39,6 +40,7 @@ type ConsensusCore struct { scheduledProcessor consensus.ScheduledProcessor messageSigningHandler consensus.P2PSigningHandler peerBlacklistHandler consensus.PeerBlacklistHandler + peerSignatureHandler crypto.PeerSignatureHandler signingHandler consensus.SigningHandler enableEpochsHandler common.EnableEpochsHandler equivalentProofsPool consensus.EquivalentProofsPool @@ -70,6 +72,7 @@ type ConsensusCoreArgs struct { ScheduledProcessor consensus.ScheduledProcessor MessageSigningHandler consensus.P2PSigningHandler PeerBlacklistHandler consensus.PeerBlacklistHandler + PeerSignatureHandler crypto.PeerSignatureHandler SigningHandler consensus.SigningHandler EnableEpochsHandler common.EnableEpochsHandler EquivalentProofsPool consensus.EquivalentProofsPool @@ -104,6 +107,7 @@ func NewConsensusCore( scheduledProcessor: args.ScheduledProcessor, messageSigningHandler: args.MessageSigningHandler, peerBlacklistHandler: args.PeerBlacklistHandler, + peerSignatureHandler: args.PeerSignatureHandler, signingHandler: args.SigningHandler, enableEpochsHandler: args.EnableEpochsHandler, equivalentProofsPool: args.EquivalentProofsPool, @@ -230,6 +234,11 @@ func (cc *ConsensusCore) PeerBlacklistHandler() consensus.PeerBlacklistHandler { return cc.peerBlacklistHandler } +// PeerSignatureHandler will return the peer signature handler +func (cc *ConsensusCore) PeerSignatureHandler() crypto.PeerSignatureHandler { + return cc.peerSignatureHandler +} + // SigningHandler will return the signing handler component func (cc *ConsensusCore) SigningHandler() consensus.SigningHandler { return cc.signingHandler @@ -340,6 +349,11 @@ func (cc *ConsensusCore) SetPeerBlacklistHandler(peerBlacklistHandler consensus. cc.peerBlacklistHandler = peerBlacklistHandler } +// SetPeerSignatureHandler sets peer signature handler +func (cc *ConsensusCore) SetPeerSignatureHandler(peerSignatureHandler crypto.PeerSignatureHandler) { + cc.peerSignatureHandler = peerSignatureHandler +} + // SetHeaderSigVerifier sets header sig verifier func (cc *ConsensusCore) SetHeaderSigVerifier(headerSigVerifier consensus.HeaderSigVerifier) { cc.headerSigVerifier = headerSigVerifier diff --git a/consensus/spos/consensusCoreValidator.go b/consensus/spos/consensusCoreValidator.go index 3e684106304..526385682b9 100644 --- a/consensus/spos/consensusCoreValidator.go +++ b/consensus/spos/consensusCoreValidator.go @@ -73,6 +73,9 @@ func ValidateConsensusCore(container ConsensusCoreHandler) error { if check.IfNil(container.PeerBlacklistHandler()) { return ErrNilPeerBlacklistHandler } + if check.IfNil(container.PeerSignatureHandler()) { + return ErrNilPeerSignatureHandler + } if check.IfNil(container.SigningHandler()) { return ErrNilSigningHandler } diff --git a/consensus/spos/consensusCoreValidator_test.go b/consensus/spos/consensusCoreValidator_test.go index 9cae557056d..0808bef9f14 100644 --- a/consensus/spos/consensusCoreValidator_test.go +++ b/consensus/spos/consensusCoreValidator_test.go @@ -42,6 +42,7 @@ func initConsensusDataContainer() *spos.ConsensusCore { scheduledProcessor := &consensusMocks.ScheduledProcessorStub{} messageSigningHandler := &mock.MessageSigningHandlerStub{} peerBlacklistHandler := &mock.PeerBlacklistHandlerStub{} + peerSignatureHandler := &cryptoMocks.PeerSignatureHandlerStub{} multiSignerContainer := cryptoMocks.NewMultiSignerContainerMock(multiSignerMock) signingHandler := &consensusMocks.SigningHandlerStub{} enableEpochsHandler := &enableEpochsHandlerMock.EnableEpochsHandlerStub{} @@ -72,6 +73,7 @@ func initConsensusDataContainer() *spos.ConsensusCore { ScheduledProcessor: scheduledProcessor, MessageSigningHandler: messageSigningHandler, PeerBlacklistHandler: peerBlacklistHandler, + PeerSignatureHandler: peerSignatureHandler, SigningHandler: signingHandler, EnableEpochsHandler: enableEpochsHandler, EquivalentProofsPool: proofsPool, @@ -344,6 +346,17 @@ func TestConsensusContainerValidator_ValidateNilPeerBlacklistHandlerShouldFail(t assert.Equal(t, spos.ErrNilPeerBlacklistHandler, err) } +func TestConsensusContainerValidator_ValidateNilPeerSignatureHandlerShouldFail(t *testing.T) { + t.Parallel() + + container := initConsensusDataContainer() + container.SetPeerSignatureHandler(nil) + + err := spos.ValidateConsensusCore(container) + + assert.Equal(t, spos.ErrNilPeerSignatureHandler, err) +} + func TestConsensusContainerValidator_ValidateNilEquivalentProofPoolShouldFail(t *testing.T) { t.Parallel() diff --git a/consensus/spos/consensusCore_test.go b/consensus/spos/consensusCore_test.go index 8b726e1ceb2..db9ce29e3fc 100644 --- a/consensus/spos/consensusCore_test.go +++ b/consensus/spos/consensusCore_test.go @@ -39,6 +39,7 @@ func createDefaultConsensusCoreArgs() *spos.ConsensusCoreArgs { ScheduledProcessor: scheduledProcessor, MessageSigningHandler: consensusCoreMock.MessageSigningHandler(), PeerBlacklistHandler: consensusCoreMock.PeerBlacklistHandler(), + PeerSignatureHandler: consensusCoreMock.PeerSignatureHandler(), SigningHandler: consensusCoreMock.SigningHandler(), EnableEpochsHandler: consensusCoreMock.EnableEpochsHandler(), EquivalentProofsPool: consensusCoreMock.EquivalentProofsPool(), @@ -341,6 +342,20 @@ func TestConsensusCore_WithNilPeerBlacklistHandlerShouldFail(t *testing.T) { assert.Equal(t, spos.ErrNilPeerBlacklistHandler, err) } +func TestConsensusCore_WithNilPeerSignatureHandlerShouldFail(t *testing.T) { + t.Parallel() + + args := createDefaultConsensusCoreArgs() + args.PeerSignatureHandler = nil + + consensusCore, err := spos.NewConsensusCore( + args, + ) + + assert.Nil(t, consensusCore) + assert.Equal(t, spos.ErrNilPeerSignatureHandler, err) +} + func TestConsensusCore_WithNilEnableEpochsHandlerShouldFail(t *testing.T) { t.Parallel() diff --git a/consensus/spos/interface.go b/consensus/spos/interface.go index 6adf54723bb..c64950289c3 100644 --- a/consensus/spos/interface.go +++ b/consensus/spos/interface.go @@ -9,6 +9,7 @@ import ( "github.com/multiversx/mx-chain-core-go/data/outport" "github.com/multiversx/mx-chain-core-go/hashing" "github.com/multiversx/mx-chain-core-go/marshal" + crypto "github.com/multiversx/mx-chain-crypto-go" "github.com/multiversx/mx-chain-go/common" cryptoCommon "github.com/multiversx/mx-chain-go/common/crypto" @@ -44,6 +45,7 @@ type ConsensusCoreHandler interface { ScheduledProcessor() consensus.ScheduledProcessor MessageSigningHandler() consensus.P2PSigningHandler PeerBlacklistHandler() consensus.PeerBlacklistHandler + PeerSignatureHandler() crypto.PeerSignatureHandler SigningHandler() consensus.SigningHandler EnableEpochsHandler() common.EnableEpochsHandler EquivalentProofsPool() consensus.EquivalentProofsPool diff --git a/factory/consensus/consensusComponents.go b/factory/consensus/consensusComponents.go index 04f425392b3..b27a9063e43 100644 --- a/factory/consensus/consensusComponents.go +++ b/factory/consensus/consensusComponents.go @@ -267,6 +267,7 @@ func (ccf *consensusComponentsFactory) Create() (*consensusComponents, error) { ScheduledProcessor: ccf.scheduledProcessor, MessageSigningHandler: p2pSigningHandler, PeerBlacklistHandler: cc.peerBlacklistHandler, + PeerSignatureHandler: ccf.cryptoComponents.PeerSignatureHandler(), SigningHandler: ccf.cryptoComponents.ConsensusSigningHandler(), EnableEpochsHandler: ccf.coreComponents.EnableEpochsHandler(), EquivalentProofsPool: ccf.dataComponents.Datapool().Proofs(), diff --git a/testscommon/consensus/mockTestInitializer.go b/testscommon/consensus/mockTestInitializer.go index 11b80a6cb0c..20b0bfc49a1 100644 --- a/testscommon/consensus/mockTestInitializer.go +++ b/testscommon/consensus/mockTestInitializer.go @@ -214,6 +214,7 @@ func InitConsensusCoreWithMultiSigner(multiSigner crypto.MultiSigner) *spos.Cons scheduledProcessor := &ScheduledProcessorStub{} messageSigningHandler := &mock.MessageSigningHandlerStub{} peerBlacklistHandler := &mock.PeerBlacklistHandlerStub{} + peerSignatureHandler := &cryptoMocks.PeerSignatureHandlerStub{} multiSignerContainer := cryptoMocks.NewMultiSignerContainerMock(multiSigner) signingHandler := &SigningHandlerStub{} enableEpochsHandler := &enableEpochsHandlerMock.EnableEpochsHandlerStub{} @@ -243,6 +244,7 @@ func InitConsensusCoreWithMultiSigner(multiSigner crypto.MultiSigner) *spos.Cons ScheduledProcessor: scheduledProcessor, MessageSigningHandler: messageSigningHandler, PeerBlacklistHandler: peerBlacklistHandler, + PeerSignatureHandler: peerSignatureHandler, SigningHandler: signingHandler, EnableEpochsHandler: enableEpochsHandler, EquivalentProofsPool: equivalentProofsPool, From 43e956ee37b70fbbab549f1bccd14f4ac782fb8c Mon Sep 17 00:00:00 2001 From: ssd04 Date: Mon, 29 Jun 2026 13:40:05 +0300 Subject: [PATCH 02/13] update unit tests --- consensus/spos/bls/v2/common_test.go | 8 ++++---- consensus/spos/bls/v2/subroundEndRound_test.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/consensus/spos/bls/v2/common_test.go b/consensus/spos/bls/v2/common_test.go index 94de6c05fa4..575a8cf545e 100644 --- a/consensus/spos/bls/v2/common_test.go +++ b/consensus/spos/bls/v2/common_test.go @@ -14,7 +14,7 @@ import ( func TestCheckGoRoutinesThrottler(t *testing.T) { t.Parallel() - t.Run("CanProcess returns true should return nil immediately", func(t *testing.T) { + t.Run("throttler cannot process should return nil immediately", func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), time.Second) @@ -30,7 +30,7 @@ func TestCheckGoRoutinesThrottler(t *testing.T) { assert.Nil(t, err) }) - t.Run("CanProcess returns false for a period of time, then true, should return nil", func(t *testing.T) { + t.Run("throttler can process for a period of time, then cannot, should return nil", func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), time.Second) @@ -48,7 +48,7 @@ func TestCheckGoRoutinesThrottler(t *testing.T) { assert.GreaterOrEqual(t, atomic.LoadInt32(&numCalls), int32(5)) }) - t.Run("CanProcess always returns false should return error when context is done", func(t *testing.T) { + t.Run("throttler cannot process should return error when context is done", func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond) @@ -69,7 +69,7 @@ func TestCheckGoRoutinesThrottler(t *testing.T) { assert.Greater(t, atomic.LoadInt32(&numCalls), int32(1)) }) - t.Run("context already canceled and CanProcess returns false should return error without retrying", func(t *testing.T) { + t.Run("context already canceled and throttler cannot process should return error without retrying", func(t *testing.T) { t.Parallel() ctx, cancel := context.WithCancel(context.Background()) diff --git a/consensus/spos/bls/v2/subroundEndRound_test.go b/consensus/spos/bls/v2/subroundEndRound_test.go index c0b4a43aade..516047c0a7b 100644 --- a/consensus/spos/bls/v2/subroundEndRound_test.go +++ b/consensus/spos/bls/v2/subroundEndRound_test.go @@ -1758,7 +1758,7 @@ func TestVerifyInvalidSigners(t *testing.T) { require.Equal(t, expectedErr, err) }) - t.Run("peer signature binding fails should error with ErrPublicKeyMismatch", func(t *testing.T) { + t.Run("peer signature binding fails should error", func(t *testing.T) { t.Parallel() container := consensusMocks.InitConsensusCore() From 660de994fe7820c45344989dee74817363359a56 Mon Sep 17 00:00:00 2001 From: robertsasu Date: Wed, 1 Jul 2026 18:59:40 +0300 Subject: [PATCH 03/13] updated VM --- go.mod | 2 ++ go.sum | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 6256916351d..85c855d0344 100644 --- a/go.mod +++ b/go.mod @@ -208,3 +208,5 @@ require ( ) replace github.com/gogo/protobuf => github.com/multiversx/protobuf v1.3.2 + +replace github.com/multiversx/mx-chain-vm-go v1.5.45 => github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260701141126-01ee78e95fed diff --git a/go.sum b/go.sum index c0393302443..5efc939a155 100644 --- a/go.sum +++ b/go.sum @@ -415,8 +415,8 @@ github.com/multiversx/mx-chain-storage-go v1.1.1 h1:Ko29uUNSRCxqkl3l8+4aIy4BKGi+ github.com/multiversx/mx-chain-storage-go v1.1.1/go.mod h1:o6Jm7cjfPmcc6XpyihYWrd6sx3sgqwurrunw3ZrfyxI= github.com/multiversx/mx-chain-vm-common-go v1.6.7 h1:oX2/RMXdhqUkJSebK+cosknBjNBX0DFAEDR6ZqNTN80= github.com/multiversx/mx-chain-vm-common-go v1.6.7/go.mod h1:Lc7r4VDPYRDS0CVIaWAoLtf3YQn6PZEYHv4QtaOE2Z0= -github.com/multiversx/mx-chain-vm-go v1.5.45 h1:0JBB/imgI8wa6muXtdGMDrW685sdsRwH/+gMPuX96OU= -github.com/multiversx/mx-chain-vm-go v1.5.45/go.mod h1:Qc2Sckw+EfQwnapkzghFfhuUAOGv29oSZgvj8LJ+xWQ= +github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260701141126-01ee78e95fed h1:YpChjvvWlxwK8ddM/gNfT2kuZCOefvW4vX/NoKj9rwM= +github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260701141126-01ee78e95fed/go.mod h1:Qc2Sckw+EfQwnapkzghFfhuUAOGv29oSZgvj8LJ+xWQ= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69 h1:5gSR3IMw1mcp/v5oO+vZ5YOyWO8w7O2qKhCKNPwsWNE= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69/go.mod h1:Qqn+B6IBlOi5huybKlvqNYDMsAHognVI6a6uiSZvaj0= github.com/multiversx/mx-chain-vm-v1_3-go v1.3.70 h1:UnTw+KJcLLqkqTR6EoZksqiM8PP4/BI6RcJlx25H9hc= From 7c7d803d5ab0fc9a0ac692132c6a976a95301fb3 Mon Sep 17 00:00:00 2001 From: ssd04 Date: Fri, 3 Jul 2026 11:56:47 +0300 Subject: [PATCH 04/13] fix unit test names --- consensus/spos/bls/v2/common_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/consensus/spos/bls/v2/common_test.go b/consensus/spos/bls/v2/common_test.go index 575a8cf545e..40cd0b190b3 100644 --- a/consensus/spos/bls/v2/common_test.go +++ b/consensus/spos/bls/v2/common_test.go @@ -14,7 +14,7 @@ import ( func TestCheckGoRoutinesThrottler(t *testing.T) { t.Parallel() - t.Run("throttler cannot process should return nil immediately", func(t *testing.T) { + t.Run("throttler can process should return nil immediately", func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), time.Second) @@ -30,7 +30,7 @@ func TestCheckGoRoutinesThrottler(t *testing.T) { assert.Nil(t, err) }) - t.Run("throttler can process for a period of time, then cannot, should return nil", func(t *testing.T) { + t.Run("throttler cannot process for a period of time, then can process, should return nil", func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), time.Second) From 3edce58871719d98749bfce978d91feceaec8c0f Mon Sep 17 00:00:00 2001 From: BeniaminDrasovean Date: Fri, 3 Jul 2026 12:02:11 +0300 Subject: [PATCH 05/13] add extra checks for trie --- trie/extensionNode.go | 4 ++++ trie/extensionNode_test.go | 20 ++++++++++++++++++++ trie/node.go | 23 +++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/trie/extensionNode.go b/trie/extensionNode.go index 9ff667a7b63..041889f4108 100644 --- a/trie/extensionNode.go +++ b/trie/extensionNode.go @@ -705,6 +705,10 @@ func (en *extensionNode) getNextHashAndKey(key []byte) (bool, []byte, []byte) { return false, nil, nil } + if len(en.Key) > len(key) || !bytes.HasPrefix(key, en.Key) { + return false, nil, nil + } + nextKey := key[len(en.Key):] wantHash := en.EncodedChild diff --git a/trie/extensionNode_test.go b/trie/extensionNode_test.go index e1c099e77a4..e794aad3e4f 100644 --- a/trie/extensionNode_test.go +++ b/trie/extensionNode_test.go @@ -986,6 +986,26 @@ func TestExtensionNode_getNextHashAndKeyNilNode(t *testing.T) { assert.Nil(t, nextKey) } +func TestExtensionNode_getNextHashAndKeyInvalidKeyShouldNotAdvance(t *testing.T) { + t.Parallel() + + _, collapsedEn := getEnAndCollapsedEn() + + collapsedEn.Key = []byte("dog") + proofVerified, nextHash, nextKey := collapsedEn.getNextHashAndKey([]byte("do")) + + assert.False(t, proofVerified) + assert.Nil(t, nextHash) + assert.Nil(t, nextKey) + + collapsedEn.Key = []byte("dog") + proofVerified, nextHash, nextKey = collapsedEn.getNextHashAndKey([]byte("cat")) + + assert.False(t, proofVerified) + assert.Nil(t, nextHash) + assert.Nil(t, nextKey) +} + func TestExtensionNode_SizeInBytes(t *testing.T) { t.Parallel() diff --git a/trie/node.go b/trie/node.go index 63f7a69c1e1..a9d81836ab9 100644 --- a/trie/node.go +++ b/trie/node.go @@ -3,6 +3,7 @@ package trie import ( "context" + "fmt" "runtime/debug" "time" @@ -197,12 +198,34 @@ func decodeNode(encNode []byte, marshalizer marshal.Marshalizer, hasher hashing. return nil, err } + err = validateDecodedNode(newNode) + if err != nil { + return nil, err + } + newNode.setMarshalizer(marshalizer) newNode.setHasher(hasher) return newNode, nil } +func validateDecodedNode(n node) error { + bn, ok := n.(*branchNode) + if !ok { + return nil + } + + if len(bn.EncodedChildren) != nrOfChildren { + return fmt.Errorf("%w for EncodedChildren, len is %d", ErrInvalidEncoding, len(bn.EncodedChildren)) + } + + if len(bn.ChildrenVersion) != 0 && len(bn.ChildrenVersion) != nrOfChildren { + return fmt.Errorf("%w for ChildrenVersion, len is %d", ErrInvalidEncoding, len(bn.ChildrenVersion)) + } + + return nil +} + func getEmptyNodeOfType(t byte) (node, error) { switch t { case extension: From daf9a95fbbbfc027f5cb2f4c7637e6525e267174 Mon Sep 17 00:00:00 2001 From: robertsasu Date: Tue, 7 Jul 2026 12:20:25 +0300 Subject: [PATCH 06/13] updated VM --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 85c855d0344..33a8f6f3d60 100644 --- a/go.mod +++ b/go.mod @@ -209,4 +209,4 @@ require ( replace github.com/gogo/protobuf => github.com/multiversx/protobuf v1.3.2 -replace github.com/multiversx/mx-chain-vm-go v1.5.45 => github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260701141126-01ee78e95fed +replace github.com/multiversx/mx-chain-vm-go v1.5.45 => github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707083806-8d1e7aefc687 diff --git a/go.sum b/go.sum index 5efc939a155..78e347d374d 100644 --- a/go.sum +++ b/go.sum @@ -415,8 +415,8 @@ github.com/multiversx/mx-chain-storage-go v1.1.1 h1:Ko29uUNSRCxqkl3l8+4aIy4BKGi+ github.com/multiversx/mx-chain-storage-go v1.1.1/go.mod h1:o6Jm7cjfPmcc6XpyihYWrd6sx3sgqwurrunw3ZrfyxI= github.com/multiversx/mx-chain-vm-common-go v1.6.7 h1:oX2/RMXdhqUkJSebK+cosknBjNBX0DFAEDR6ZqNTN80= github.com/multiversx/mx-chain-vm-common-go v1.6.7/go.mod h1:Lc7r4VDPYRDS0CVIaWAoLtf3YQn6PZEYHv4QtaOE2Z0= -github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260701141126-01ee78e95fed h1:YpChjvvWlxwK8ddM/gNfT2kuZCOefvW4vX/NoKj9rwM= -github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260701141126-01ee78e95fed/go.mod h1:Qc2Sckw+EfQwnapkzghFfhuUAOGv29oSZgvj8LJ+xWQ= +github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707083806-8d1e7aefc687 h1:0Yi7vghxK8yNZASkobxir4fGq0IMQwYMG4+F/VWxjQk= +github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707083806-8d1e7aefc687/go.mod h1:Qc2Sckw+EfQwnapkzghFfhuUAOGv29oSZgvj8LJ+xWQ= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69 h1:5gSR3IMw1mcp/v5oO+vZ5YOyWO8w7O2qKhCKNPwsWNE= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69/go.mod h1:Qqn+B6IBlOi5huybKlvqNYDMsAHognVI6a6uiSZvaj0= github.com/multiversx/mx-chain-vm-v1_3-go v1.3.70 h1:UnTw+KJcLLqkqTR6EoZksqiM8PP4/BI6RcJlx25H9hc= From 10ec3e28686a17d2ed46879759d202b8b3db1e52 Mon Sep 17 00:00:00 2001 From: robertsasu Date: Tue, 7 Jul 2026 13:48:04 +0300 Subject: [PATCH 07/13] updated VM --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 33a8f6f3d60..76d1bbbc291 100644 --- a/go.mod +++ b/go.mod @@ -209,4 +209,4 @@ require ( replace github.com/gogo/protobuf => github.com/multiversx/protobuf v1.3.2 -replace github.com/multiversx/mx-chain-vm-go v1.5.45 => github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707083806-8d1e7aefc687 +replace github.com/multiversx/mx-chain-vm-go v1.5.45 => github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707104617-b077b5c47e40 diff --git a/go.sum b/go.sum index 78e347d374d..2c457970ee3 100644 --- a/go.sum +++ b/go.sum @@ -415,8 +415,8 @@ github.com/multiversx/mx-chain-storage-go v1.1.1 h1:Ko29uUNSRCxqkl3l8+4aIy4BKGi+ github.com/multiversx/mx-chain-storage-go v1.1.1/go.mod h1:o6Jm7cjfPmcc6XpyihYWrd6sx3sgqwurrunw3ZrfyxI= github.com/multiversx/mx-chain-vm-common-go v1.6.7 h1:oX2/RMXdhqUkJSebK+cosknBjNBX0DFAEDR6ZqNTN80= github.com/multiversx/mx-chain-vm-common-go v1.6.7/go.mod h1:Lc7r4VDPYRDS0CVIaWAoLtf3YQn6PZEYHv4QtaOE2Z0= -github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707083806-8d1e7aefc687 h1:0Yi7vghxK8yNZASkobxir4fGq0IMQwYMG4+F/VWxjQk= -github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707083806-8d1e7aefc687/go.mod h1:Qc2Sckw+EfQwnapkzghFfhuUAOGv29oSZgvj8LJ+xWQ= +github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707104617-b077b5c47e40 h1:mjDVosqWUEWpDOEQuXhRIlSARaxfRdWsKZY7JWteIkI= +github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707104617-b077b5c47e40/go.mod h1:Qc2Sckw+EfQwnapkzghFfhuUAOGv29oSZgvj8LJ+xWQ= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69 h1:5gSR3IMw1mcp/v5oO+vZ5YOyWO8w7O2qKhCKNPwsWNE= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69/go.mod h1:Qqn+B6IBlOi5huybKlvqNYDMsAHognVI6a6uiSZvaj0= github.com/multiversx/mx-chain-vm-v1_3-go v1.3.70 h1:UnTw+KJcLLqkqTR6EoZksqiM8PP4/BI6RcJlx25H9hc= From 8014dfe739e0126715476ce057e34e3e6c80dd04 Mon Sep 17 00:00:00 2001 From: BeniaminDrasovean Date: Wed, 8 Jul 2026 14:02:36 +0300 Subject: [PATCH 08/13] request proof only if proofByNonce missing --- process/block/baseProcess.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/process/block/baseProcess.go b/process/block/baseProcess.go index 13c0a20c60a..0bca274306b 100644 --- a/process/block/baseProcess.go +++ b/process/block/baseProcess.go @@ -1221,7 +1221,14 @@ func (bp *baseProcessor) requestMissingFinalityAttestingHeaders( usedInBlock: false, } - bp.requestProofIfNeeded(headersHashes[index], headers[index]) + if !bp.enableEpochsHandler.IsFlagEnabledInEpoch(common.AndromedaFlag, headers[index].GetEpoch()) { + continue + } + + _, err = bp.proofsPool.GetProofByNonce(i, shardID) + if err != nil { + bp.requestProofIfNeeded(headersHashes[index], headers[index]) + } } } From f9528d61f067a2b0ca1861fa975609379e4022e2 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Wed, 8 Jul 2026 15:17:58 +0300 Subject: [PATCH 09/13] updated vm go --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 76d1bbbc291..ae4e6ae9247 100644 --- a/go.mod +++ b/go.mod @@ -209,4 +209,4 @@ require ( replace github.com/gogo/protobuf => github.com/multiversx/protobuf v1.3.2 -replace github.com/multiversx/mx-chain-vm-go v1.5.45 => github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707104617-b077b5c47e40 +replace github.com/multiversx/mx-chain-vm-go v1.5.45 => github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707113730-ef93d7c24266 diff --git a/go.sum b/go.sum index 2c457970ee3..8630647d229 100644 --- a/go.sum +++ b/go.sum @@ -415,8 +415,8 @@ github.com/multiversx/mx-chain-storage-go v1.1.1 h1:Ko29uUNSRCxqkl3l8+4aIy4BKGi+ github.com/multiversx/mx-chain-storage-go v1.1.1/go.mod h1:o6Jm7cjfPmcc6XpyihYWrd6sx3sgqwurrunw3ZrfyxI= github.com/multiversx/mx-chain-vm-common-go v1.6.7 h1:oX2/RMXdhqUkJSebK+cosknBjNBX0DFAEDR6ZqNTN80= github.com/multiversx/mx-chain-vm-common-go v1.6.7/go.mod h1:Lc7r4VDPYRDS0CVIaWAoLtf3YQn6PZEYHv4QtaOE2Z0= -github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707104617-b077b5c47e40 h1:mjDVosqWUEWpDOEQuXhRIlSARaxfRdWsKZY7JWteIkI= -github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707104617-b077b5c47e40/go.mod h1:Qc2Sckw+EfQwnapkzghFfhuUAOGv29oSZgvj8LJ+xWQ= +github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707113730-ef93d7c24266 h1:QlKvq+t4OFah0fTyR5ip8Jjm6aaSDn3MDXBVPZDXQk4= +github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707113730-ef93d7c24266/go.mod h1:Qc2Sckw+EfQwnapkzghFfhuUAOGv29oSZgvj8LJ+xWQ= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69 h1:5gSR3IMw1mcp/v5oO+vZ5YOyWO8w7O2qKhCKNPwsWNE= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69/go.mod h1:Qqn+B6IBlOi5huybKlvqNYDMsAHognVI6a6uiSZvaj0= github.com/multiversx/mx-chain-vm-v1_3-go v1.3.70 h1:UnTw+KJcLLqkqTR6EoZksqiM8PP4/BI6RcJlx25H9hc= From 24bbc7ba6a27e1eee98d8a920eaa0ca0edfe80bd Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Wed, 8 Jul 2026 16:21:59 +0300 Subject: [PATCH 10/13] updated vm go --- go.mod | 4 +--- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index ae4e6ae9247..30740c3cb6a 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/multiversx/mx-chain-scenario-go v1.6.0 github.com/multiversx/mx-chain-storage-go v1.1.1 github.com/multiversx/mx-chain-vm-common-go v1.6.7 - github.com/multiversx/mx-chain-vm-go v1.5.45 + github.com/multiversx/mx-chain-vm-go v1.5.46 github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69 github.com/multiversx/mx-chain-vm-v1_3-go v1.3.70 github.com/multiversx/mx-chain-vm-v1_4-go v1.4.99 @@ -208,5 +208,3 @@ require ( ) replace github.com/gogo/protobuf => github.com/multiversx/protobuf v1.3.2 - -replace github.com/multiversx/mx-chain-vm-go v1.5.45 => github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707113730-ef93d7c24266 diff --git a/go.sum b/go.sum index 8630647d229..7f6e3507cb2 100644 --- a/go.sum +++ b/go.sum @@ -415,8 +415,8 @@ github.com/multiversx/mx-chain-storage-go v1.1.1 h1:Ko29uUNSRCxqkl3l8+4aIy4BKGi+ github.com/multiversx/mx-chain-storage-go v1.1.1/go.mod h1:o6Jm7cjfPmcc6XpyihYWrd6sx3sgqwurrunw3ZrfyxI= github.com/multiversx/mx-chain-vm-common-go v1.6.7 h1:oX2/RMXdhqUkJSebK+cosknBjNBX0DFAEDR6ZqNTN80= github.com/multiversx/mx-chain-vm-common-go v1.6.7/go.mod h1:Lc7r4VDPYRDS0CVIaWAoLtf3YQn6PZEYHv4QtaOE2Z0= -github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707113730-ef93d7c24266 h1:QlKvq+t4OFah0fTyR5ip8Jjm6aaSDn3MDXBVPZDXQk4= -github.com/multiversx/mx-chain-vm-go-ghsa-hwg4-v7gq-phfc v1.6.1-0.20260707113730-ef93d7c24266/go.mod h1:Qc2Sckw+EfQwnapkzghFfhuUAOGv29oSZgvj8LJ+xWQ= +github.com/multiversx/mx-chain-vm-go v1.5.46 h1:v9NWNdIgZwNc7oMB34YNHKEbyZggK084CFc2RqBTTdQ= +github.com/multiversx/mx-chain-vm-go v1.5.46/go.mod h1:Qc2Sckw+EfQwnapkzghFfhuUAOGv29oSZgvj8LJ+xWQ= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69 h1:5gSR3IMw1mcp/v5oO+vZ5YOyWO8w7O2qKhCKNPwsWNE= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69/go.mod h1:Qqn+B6IBlOi5huybKlvqNYDMsAHognVI6a6uiSZvaj0= github.com/multiversx/mx-chain-vm-v1_3-go v1.3.70 h1:UnTw+KJcLLqkqTR6EoZksqiM8PP4/BI6RcJlx25H9hc= From 4761f29e4d64728d9092a2a361b812114fb0426f Mon Sep 17 00:00:00 2001 From: miiu Date: Thu, 9 Jul 2026 16:23:53 +0300 Subject: [PATCH 11/13] fixes after merge --- go.mod | 2 +- go.sum | 4 ++-- process/block/headerForBlock/headersForBlock.go | 9 ++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index a7672e78f69..46a90221854 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/multiversx/mx-chain-scenario-go v1.6.0 github.com/multiversx/mx-chain-storage-go v1.1.2-0.20260608080818-1fde35395146 github.com/multiversx/mx-chain-vm-common-go v1.6.7 - github.com/multiversx/mx-chain-vm-go v1.5.46 + github.com/multiversx/mx-chain-vm-go v1.6.1-0.20260709131117-b8afa5c1796f github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69 github.com/multiversx/mx-chain-vm-v1_3-go v1.3.70 github.com/multiversx/mx-chain-vm-v1_4-go v1.4.99 diff --git a/go.sum b/go.sum index 4f47bde9148..33eafaf0605 100644 --- a/go.sum +++ b/go.sum @@ -415,8 +415,8 @@ github.com/multiversx/mx-chain-storage-go v1.1.2-0.20260608080818-1fde35395146 h github.com/multiversx/mx-chain-storage-go v1.1.2-0.20260608080818-1fde35395146/go.mod h1:o6Jm7cjfPmcc6XpyihYWrd6sx3sgqwurrunw3ZrfyxI= github.com/multiversx/mx-chain-vm-common-go v1.6.7 h1:oX2/RMXdhqUkJSebK+cosknBjNBX0DFAEDR6ZqNTN80= github.com/multiversx/mx-chain-vm-common-go v1.6.7/go.mod h1:Lc7r4VDPYRDS0CVIaWAoLtf3YQn6PZEYHv4QtaOE2Z0= -github.com/multiversx/mx-chain-vm-go v1.5.46 h1:v9NWNdIgZwNc7oMB34YNHKEbyZggK084CFc2RqBTTdQ= -github.com/multiversx/mx-chain-vm-go v1.5.46/go.mod h1:Qc2Sckw+EfQwnapkzghFfhuUAOGv29oSZgvj8LJ+xWQ= +github.com/multiversx/mx-chain-vm-go v1.6.1-0.20260709131117-b8afa5c1796f h1:de4qEkVPj2efb4tprAN+rG03eUUmhPFdTJMZpRnxVLg= +github.com/multiversx/mx-chain-vm-go v1.6.1-0.20260709131117-b8afa5c1796f/go.mod h1:Qc2Sckw+EfQwnapkzghFfhuUAOGv29oSZgvj8LJ+xWQ= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69 h1:5gSR3IMw1mcp/v5oO+vZ5YOyWO8w7O2qKhCKNPwsWNE= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.69/go.mod h1:Qqn+B6IBlOi5huybKlvqNYDMsAHognVI6a6uiSZvaj0= github.com/multiversx/mx-chain-vm-v1_3-go v1.3.70 h1:UnTw+KJcLLqkqTR6EoZksqiM8PP4/BI6RcJlx25H9hc= diff --git a/process/block/headerForBlock/headersForBlock.go b/process/block/headerForBlock/headersForBlock.go index f3f3a3863a6..4a5d147ab91 100644 --- a/process/block/headerForBlock/headersForBlock.go +++ b/process/block/headerForBlock/headersForBlock.go @@ -581,7 +581,14 @@ func (hfb *headersForBlock) requestMissingFinalityAttestingHeaders( false, ) - hfb.requestProofIfNeeded(headersHashes[index], headers[index]) + if !hfb.enableEpochsHandler.IsFlagEnabledInEpoch(common.AndromedaFlag, headers[index].GetEpoch()) { + continue + } + + _, err = hfb.dataPool.Proofs().GetProofByNonce(i, shardID) + if err != nil { + hfb.requestProofIfNeeded(headersHashes[index], headers[index]) + } } } From cea3b681edf5fbc9410b003b9b647b2083ca05f4 Mon Sep 17 00:00:00 2001 From: miiu Date: Thu, 9 Jul 2026 16:25:26 +0300 Subject: [PATCH 12/13] fix tests --- dataRetriever/txpool/memorytests/memory_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataRetriever/txpool/memorytests/memory_test.go b/dataRetriever/txpool/memorytests/memory_test.go index 1a899f742ab..4980929c57d 100644 --- a/dataRetriever/txpool/memorytests/memory_test.go +++ b/dataRetriever/txpool/memorytests/memory_test.go @@ -48,7 +48,7 @@ func TestShardedTxPool_MemoryFootprint(t *testing.T) { // With larger memory footprint journals = append(journals, runScenario(t, newScenario(100000, 3, 650, "0"), memoryAssertion{290, 340}, memoryAssertion{80, 148})) - journals = append(journals, runScenario(t, newScenario(150000, 2, 650, "0"), memoryAssertion{290, 340}, memoryAssertion{90, 160})) + journals = append(journals, runScenario(t, newScenario(150000, 2, 650, "0"), memoryAssertion{290, 340}, memoryAssertion{90, 163})) journals = append(journals, runScenario(t, newScenario(300000, 1, 650, "0"), memoryAssertion{290, 340}, memoryAssertion{100, 190})) journals = append(journals, runScenario(t, newScenario(30, 10000, 650, "0"), memoryAssertion{290, 340}, memoryAssertion{60, 132})) journals = append(journals, runScenario(t, newScenario(300, 1000, 650, "0"), memoryAssertion{290, 340}, memoryAssertion{60, 148})) From 756a40e02c92683834389e4f3febe6d6178f937d Mon Sep 17 00:00:00 2001 From: miiu Date: Fri, 10 Jul 2026 10:11:43 +0300 Subject: [PATCH 13/13] fix unit tests --- process/block/headerForBlock/headersForBlock_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/process/block/headerForBlock/headersForBlock_test.go b/process/block/headerForBlock/headersForBlock_test.go index 9abb4912ab6..da6b718179a 100644 --- a/process/block/headerForBlock/headersForBlock_test.go +++ b/process/block/headerForBlock/headersForBlock_test.go @@ -973,6 +973,9 @@ func TestHeadersForBlock_RequestMissingFinalityAttestingShardHeaders(t *testing. HasProofCalled: func(shardID uint32, headerHash []byte) bool { return false // no proof available for the attestation header }, + GetProofByNonceCalled: func(headerNonce uint64, shardID uint32) (data.HeaderProofHandler, error) { + return nil, errors.New("GetProofByNonce error") + }, }) args.BlockTracker = &mock.BlockTrackerStub{