Skip to content

Commit

Permalink
Merge branch 'equivalent-proofs-feat-stabilization' of github.com:mul…
Browse files Browse the repository at this point in the history
…tiversx/mx-chain-go into equivalent-proofs-feat-stabilization
  • Loading branch information
AdoAdoAdo committed Jan 9, 2025
2 parents 5f650fb + bbbeb98 commit b7d1990
Show file tree
Hide file tree
Showing 7 changed files with 338 additions and 17 deletions.
1 change: 1 addition & 0 deletions consensus/spos/bls/v2/subroundEndRound.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ func (sr *subroundEndRound) createAndBroadcastProof(signature []byte, bitmap []b
HeaderEpoch: sr.GetHeader().GetEpoch(),
HeaderNonce: sr.GetHeader().GetNonce(),
HeaderShardId: sr.GetHeader().GetShardID(),
HeaderRound: sr.GetHeader().GetRound(),
}

err := sr.BroadcastMessenger().BroadcastEquivalentProof(headerProof, []byte(sr.SelfPubKey()))
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/klauspost/cpuid/v2 v2.2.5
github.com/mitchellh/mapstructure v1.5.0
github.com/multiversx/mx-chain-communication-go v1.0.15-0.20240508074652-e128a1c05c8e
github.com/multiversx/mx-chain-core-go v1.2.21-0.20241204105459-ddd46264c030
github.com/multiversx/mx-chain-core-go v1.2.21-0.20250109123731-7ff31f3e3af6
github.com/multiversx/mx-chain-crypto-go v1.2.12-0.20240508074452-cc21c1b505df
github.com/multiversx/mx-chain-es-indexer-go v1.7.2-0.20240619122842-05143459c554
github.com/multiversx/mx-chain-logger-go v1.0.15-0.20240508072523-3f00a726af57
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ github.com/multiversx/concurrent-map v0.1.4 h1:hdnbM8VE4b0KYJaGY5yJS2aNIW9TFFsUY
github.com/multiversx/concurrent-map v0.1.4/go.mod h1:8cWFRJDOrWHOTNSqgYCUvwT7c7eFQ4U2vKMOp4A/9+o=
github.com/multiversx/mx-chain-communication-go v1.0.15-0.20240508074652-e128a1c05c8e h1:Tsmwhu+UleE+l3buPuqXSKTqfu5FbPmzQ4MjMoUvCWA=
github.com/multiversx/mx-chain-communication-go v1.0.15-0.20240508074652-e128a1c05c8e/go.mod h1:2yXl18wUbuV3cRZr7VHxM1xo73kTaC1WUcu2kx8R034=
github.com/multiversx/mx-chain-core-go v1.2.21-0.20241204105459-ddd46264c030 h1:4XI4z1ceZC3OUXxTeMQD+6gmTgu9I934nsYlV6P8X4A=
github.com/multiversx/mx-chain-core-go v1.2.21-0.20241204105459-ddd46264c030/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-core-go v1.2.21-0.20250109123731-7ff31f3e3af6 h1:y6qLlkmLp+H2pztSmJDJkf0j9HlpkXvaRd9xjx3J360=
github.com/multiversx/mx-chain-core-go v1.2.21-0.20250109123731-7ff31f3e3af6/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-crypto-go v1.2.12-0.20240508074452-cc21c1b505df h1:clihfi78bMEOWk/qw6WA4uQbCM2e2NGliqswLAvw19k=
github.com/multiversx/mx-chain-crypto-go v1.2.12-0.20240508074452-cc21c1b505df/go.mod h1:gtJYB4rR21KBSqJlazn+2z6f9gFSqQP3KvAgL7Qgxw4=
github.com/multiversx/mx-chain-es-indexer-go v1.7.2-0.20240619122842-05143459c554 h1:Fv8BfzJSzdovmoh9Jh/by++0uGsOVBlMP3XiN5Svkn4=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func createEquivalentProof(marshaller marshal.Marshalizer, buff []byte) (*block.
"header shard", headerProof.HeaderShardId,
"header epoch", headerProof.HeaderEpoch,
"header nonce", headerProof.HeaderNonce,
"header round", headerProof.HeaderRound,
"bitmap", logger.DisplayByteSlice(headerProof.PubKeysBitmap),
"signature", logger.DisplayByteSlice(headerProof.AggregatedSignature),
)
Expand Down
13 changes: 1 addition & 12 deletions process/sync/baseSync.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,17 +716,6 @@ func (boot *baseBootstrap) handleEquivalentProof(
return nil
}

prevHeader, err := boot.blockBootstrapper.getHeaderWithHashRequestingIfMissing(header.GetPrevHash())
if err != nil {
return err
}

if !boot.enableEpochsHandler.IsFlagEnabledInEpoch(common.EquivalentMessagesFlag, prevHeader.GetEpoch()) {
// no need to check proof for first block after activation
log.Info("handleEquivalentProof: no need to check equivalent proof for first activation block")
return nil
}

// process block only if there is a proof for it
hasProof := boot.proofs.HasProof(header.GetShardID(), headerHash)
if hasProof {
Expand All @@ -735,7 +724,7 @@ func (boot *baseBootstrap) handleEquivalentProof(

log.Trace("baseBootstrap.handleEquivalentProof: did not have proof for header, will try again", "headerHash", headerHash)

_, _, err = boot.blockBootstrapper.getHeaderWithNonceRequestingIfMissing(header.GetNonce() + 1)
_, _, err := boot.blockBootstrapper.getHeaderWithNonceRequestingIfMissing(header.GetNonce() + 1)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions process/sync/metablock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,7 @@ func TestMetaBootstrap_HandleEquivalentProof(t *testing.T) {
require.Nil(t, err)
})

t.Run("should return nil if first block after activation", func(t *testing.T) {
t.Run("should fail if first block after activation and no proof for it", func(t *testing.T) {
t.Parallel()

prevHeader := &block.MetaBlock{
Expand Down Expand Up @@ -1932,7 +1932,7 @@ func TestMetaBootstrap_HandleEquivalentProof(t *testing.T) {
require.Nil(t, err)

err = bs.HandleEquivalentProof(header, headerHash1)
require.Nil(t, err)
require.Error(t, err)
})

t.Run("should work, proof already in pool", func(t *testing.T) {
Expand Down
Loading

0 comments on commit b7d1990

Please sign in to comment.