Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
44effd8
early exit on peer authentication messages, but keep broadcast them f…
sstanculeanu Apr 23, 2026
bb16d6b
save the messages even though map already exists
sstanculeanu Apr 23, 2026
c9efcbd
return error when peer already authenticated
sstanculeanu Apr 23, 2026
248ee7a
latest vm common from master
miiu96 Apr 24, 2026
1d1ca92
Merge remote-tracking branch 'upstream/integrate-vm-common-master' in…
miiu96 Apr 27, 2026
0e6e94c
add maxChunks check
BeniaminDrasovean Apr 28, 2026
0dac63f
add time limit for requesting trie chunks
BeniaminDrasovean Apr 28, 2026
6251fad
add resolver exception recover
ssd04 Apr 29, 2026
41f2050
fix ai finding
sstanculeanu Apr 29, 2026
819d455
replace hard-coded val with const
BeniaminDrasovean Apr 30, 2026
7cb8f54
bloom filter
miiu96 Apr 30, 2026
62b4bf1
Merge branch 'master' into bloom-filter-level-db
miiu96 Apr 30, 2026
a1637fe
verify padding bits
AdoAdoAdo Apr 30, 2026
d89e809
fix #137
sstanculeanu Apr 30, 2026
f90753f
add try set busy
ssd04 Apr 30, 2026
cfa6b18
add try set busy
ssd04 Apr 30, 2026
3dea03d
do not update the timer if the index exists
BeniaminDrasovean May 4, 2026
270033f
UpdatePeerIDPublicKeyPair now gets the timestamp from payload
sstanculeanu May 4, 2026
cfb0310
finish implementation on psm
sstanculeanu May 5, 2026
267bb41
extra miniblocks checks
ssd04 May 6, 2026
8914f4c
early exit on peer authentication messages, but keep broadcast them f…
sstanculeanu Apr 23, 2026
f1f1d01
save the messages even though map already exists
sstanculeanu Apr 23, 2026
ab36a85
return error when peer already authenticated
sstanculeanu May 6, 2026
32317e9
latest vm common from master
miiu96 Apr 24, 2026
a73bf23
add resolver exception recover
ssd04 Apr 29, 2026
46deaef
fix #137
sstanculeanu Apr 30, 2026
bab3199
UpdatePeerIDPublicKeyPair now gets the timestamp from payload
sstanculeanu May 4, 2026
c1d246c
finish implementation on psm
sstanculeanu May 5, 2026
90414e5
Merge remote-tracking branch 'origin/advisory-fix' into advisory-fix
sstanculeanu May 6, 2026
2e1dcfc
add more checks
ssd04 May 6, 2026
d60a040
refactor tx immunization
BeniaminDrasovean May 7, 2026
6929c28
fix failing test
BeniaminDrasovean May 7, 2026
2d26452
fixes after review
BeniaminDrasovean May 11, 2026
e6a91d5
meta mbs extra checks
ssd04 May 12, 2026
1aa75bf
new version
miiu96 May 12, 2026
c2adf39
add miniblock check when consensus message received
BeniaminDrasovean May 12, 2026
6cec44a
Merge branch 'master' into bitmap-check
AdoAdoAdo May 12, 2026
fe3d887
trigger broadcast on proof received
AdoAdoAdo May 12, 2026
722c8a2
update tests
AdoAdoAdo May 12, 2026
0ded82a
update tests
AdoAdoAdo May 13, 2026
1c5e3fb
move intercepted messages checks before Verify call
sstanculeanu May 13, 2026
50d8964
added check for minimum blocks per epoch in trigger
raduchis May 13, 2026
50c42b6
fixes after review
AdoAdoAdo May 13, 2026
7978b61
mb check return err on fail
ssd04 May 13, 2026
94cd773
fixes after review
miiu96 May 14, 2026
470c79f
concurrent checks + test
ssd04 May 14, 2026
392840b
fix after review
sstanculeanu May 14, 2026
436c64c
update test
ssd04 May 14, 2026
7d7996b
fixes after review
ssd04 May 14, 2026
95302cb
update shard id check vars
ssd04 May 14, 2026
a5c613a
fix after review
sstanculeanu May 14, 2026
cd35f24
fix after review
sstanculeanu May 14, 2026
b2a731b
integrate storage-go
ssd04 May 15, 2026
ba0e4e5
vm common with fixes
miiu96 May 15, 2026
ca1f087
Merge branch 'advisory-fix' into fixes-and-updates
miiu96 May 15, 2026
ea9b3b0
go mod tidy
miiu96 May 15, 2026
f470629
Merge branch 'master' into refactor-trie-nodes-chunk-processor
miiu96 May 15, 2026
92a193c
Merge branch 'refactor-trie-nodes-chunk-processor' into fixes-and-upd…
miiu96 May 15, 2026
1da2689
Merge branch 'ai-fix' into fixes-and-updates
miiu96 May 15, 2026
7449863
Merge branch 'bitmap-check' into fixes-and-updates
miiu96 May 15, 2026
6ad1c3a
Merge branch 'master' into set-busy-fix
miiu96 May 15, 2026
461880d
Merge branch 'set-busy-fix' into fixes-and-updates
miiu96 May 15, 2026
8869afa
Merge branch 'miniblock-checks' into fixes-and-updates
miiu96 May 15, 2026
ea1be11
Merge branch 'delayed-broadcast-update' into fixes-and-updates
miiu96 May 15, 2026
e10a3b9
Merge branch 'move-interceptors-checks' into fixes-and-updates
miiu96 May 15, 2026
b33d97a
Merge branch 'min-blocks-per-epoch' into fixes-and-updates
miiu96 May 15, 2026
bc77e55
optimisations and fixes
AdoAdoAdo May 15, 2026
0851f3d
peer mb check
ssd04 May 18, 2026
7aafb46
peer mb check - shard
ssd04 May 18, 2026
22e081d
remove shard check
ssd04 May 18, 2026
1c838c5
remove shard check
ssd04 May 18, 2026
3b18432
add tests
AdoAdoAdo May 18, 2026
bbf878f
refactor mb checks func
ssd04 May 18, 2026
1049ade
Merge pull request #2 from multiversx/optimisation
AdoAdoAdo May 18, 2026
9c9bc75
fixes after review
BeniaminDrasovean May 19, 2026
e9fb044
mb ordering cross check
AdoAdoAdo May 19, 2026
555a842
extra check for first tx processed
sstanculeanu May 19, 2026
cde8193
fixes failing tests
AdoAdoAdo May 19, 2026
172c0a4
extra checks scheduled data
miiu96 May 19, 2026
5369616
extra checks construction state and processing type
AdoAdoAdo May 19, 2026
8df01a1
fixes processing type and construction state checks
AdoAdoAdo May 20, 2026
ad37a26
Merge remote-tracking branch 'privatefork/fix-txs-immunization' into …
BeniaminDrasovean May 20, 2026
983155e
avoid duplicated hashes on request
sstanculeanu May 20, 2026
5a15dc2
update go mod
BeniaminDrasovean May 20, 2026
957d3cd
fixes processing type and construction state checks
AdoAdoAdo May 20, 2026
8b24f53
Merge branch 'txs-immunization-fixes' into fixes-and-updates
miiu96 May 20, 2026
283fee0
go mod tidy
miiu96 May 20, 2026
63d6cb9
add allowed combination
AdoAdoAdo May 20, 2026
245c0e2
leading scheduled checks
AdoAdoAdo May 20, 2026
17a53ef
additional verification
AdoAdoAdo May 20, 2026
2bad8f8
Merge branch 'fixes-and-updates' into peer-mb-checks
ssd04 May 20, 2026
63ce50c
Merge branch 'fixes-and-updates' of https://github.com/multiversx/mx-…
sstanculeanu May 20, 2026
c37db94
Merge branch 'fixes-and-updates' of https://github.com/multiversx/mx-…
sstanculeanu May 20, 2026
7e9e910
Merge branch 'fixes-and-updates' into ordering-check
AdoAdoAdo May 20, 2026
fda056c
Merge branch 'fixes-and-updates' into construction-processing-checks
AdoAdoAdo May 20, 2026
eb6cf16
Merge branch 'fixes-and-updates' of https://github.com/multiversx/mx-…
sstanculeanu May 20, 2026
f20169b
request proof if missing in trigger
ssd04 May 21, 2026
a0094b8
Merge branch 'fixes-and-updates' into trigger-missing-proof
ssd04 May 21, 2026
7f48610
return nil on already authenticated
sstanculeanu May 21, 2026
8a2f382
fix comment
sstanculeanu May 21, 2026
545228d
proper checks on peer authentication interceptor
sstanculeanu May 22, 2026
9ec1abf
improve intercepted peer auth checks
sstanculeanu May 22, 2026
d2bf767
fixes after review
sstanculeanu May 22, 2026
ab7bf5a
fix tests after fixes after review
sstanculeanu May 22, 2026
a061750
fix silent encode
sstanculeanu May 25, 2026
dc69183
fix fallback shard
sstanculeanu May 25, 2026
1d3fe6e
use deadline on direct send
AdoAdoAdo May 26, 2026
0f82bf1
added peerAuthentication identifiers to whiteList
raduchis May 26, 2026
867c06b
added peer authentication identifier trim method to common
raduchis May 26, 2026
b644862
updated core-go and communication-go tags
sstanculeanu May 27, 2026
ba2f712
fix after audit, pass peer id
sstanculeanu May 27, 2026
652c3c8
fix for multikey as well
sstanculeanu May 27, 2026
5977c70
fix tests
sstanculeanu May 27, 2026
ed386cb
fix tests
sstanculeanu May 27, 2026
df0e297
fixes after ai review
sstanculeanu May 27, 2026
8e28ad5
fix tests
sstanculeanu May 27, 2026
d285c33
updated deps to tags
sstanculeanu May 27, 2026
e1698c7
Merge commit from fork
AdoAdoAdo May 27, 2026
adf0114
fix linter in tests
AdoAdoAdo May 27, 2026
2a7aae2
Merge pull request #7859 from multiversx/fix-linter-merge
AdoAdoAdo May 27, 2026
1ba932c
recreate interceptors on bootstrap
AdoAdoAdo May 28, 2026
05f1e32
fixes after review
AdoAdoAdo May 28, 2026
96b9d52
more bootstrap optimizations
raduchis May 28, 2026
0436b9d
add nil checks
AdoAdoAdo May 28, 2026
87c1564
Merge pull request #7862 from multiversx/start-in-epoch-reload-interc…
AdoAdoAdo May 28, 2026
94ed12d
unregister all processors on tear down
sstanculeanu May 29, 2026
f0c8c15
Merge pull request #7865 from multiversx/completely-unregister
sstanculeanu Jun 2, 2026
5ef8d69
Merge branch 'master' into merge-master-supernova-02June2026
AdoAdoAdo Jun 8, 2026
e3c0cad
update versions
AdoAdoAdo Jun 8, 2026
8714377
fixes after merge
AdoAdoAdo Jun 8, 2026
6c90a54
fixes after merge
AdoAdoAdo Jun 8, 2026
50d7695
fixes after merge
AdoAdoAdo Jun 8, 2026
196aee5
fixes after merge
AdoAdoAdo Jun 8, 2026
b7d18ad
fixes
AdoAdoAdo Jun 8, 2026
41f132c
fixes after merge
AdoAdoAdo Jun 8, 2026
42892c1
fix test
AdoAdoAdo Jun 8, 2026
8f510f0
fixes after review
AdoAdoAdo Jun 9, 2026
18d7927
port request SOE meta watchdog
AdoAdoAdo Jun 9, 2026
55c16e0
remove Andromeda request gate
AdoAdoAdo Jun 9, 2026
682e1ff
add meta sync watchdog for epoch start block
AdoAdoAdo Jun 9, 2026
d496a32
Merge branch 'start-in-epoch-reload-interceptors' into fix-transition…
AdoAdoAdo Jun 9, 2026
98c228b
fix after review
AdoAdoAdo Jun 9, 2026
2064a96
fix after review
AdoAdoAdo Jun 10, 2026
2ea25ab
Merge pull request #7876 from multiversx/fix-transition-on-msg-revers…
AdoAdoAdo Jun 10, 2026
1dfe150
fix tests
AdoAdoAdo Jun 10, 2026
48c6755
fix lock
AdoAdoAdo Jun 10, 2026
ba99de8
Merge pull request #7861 from multiversx/start-in-epoch-reload-interc…
AdoAdoAdo Jun 10, 2026
bfbeebe
Merge branch 'master' into merge-master-supernova-june2026
AdoAdoAdo Jun 10, 2026
e3af0a4
fixes after merge
AdoAdoAdo Jun 10, 2026
fc64c23
fix bootstrap requests after merge
AdoAdoAdo Jun 11, 2026
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
38 changes: 36 additions & 2 deletions cmd/node/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[ReceiptsStorage]
[ReceiptsStorage.Cache]
Expand All @@ -189,6 +190,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[ScheduledSCRsStorage]
[ScheduledSCRsStorage.Cache]
Expand All @@ -202,6 +204,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[PeerBlockBodyStorage]
[PeerBlockBodyStorage.Cache]
Expand All @@ -215,6 +218,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[BlockHeaderStorage]
[BlockHeaderStorage.Cache]
Expand All @@ -228,6 +232,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10
ShardIDProviderType = "BinarySplit"
NumShards = 4

Expand All @@ -243,6 +248,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[MetaBlockStorage]
[MetaBlockStorage.Cache]
Expand All @@ -256,6 +262,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10
ShardIDProviderType = "BinarySplit"
NumShards = 4

Expand All @@ -271,6 +278,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[ExecutionResultsStorage]
[ExecutionResultsStorage.Cache]
Expand All @@ -297,6 +305,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 30000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10
ShardIDProviderType = "BinarySplit"
NumShards = 4

Expand All @@ -312,6 +321,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 20000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[RewardTxStorage]
[RewardTxStorage.Cache]
Expand All @@ -325,6 +335,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 20000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[SmartContractsStorage]
[SmartContractsStorage.Cache]
Expand All @@ -338,6 +349,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[SmartContractsStorageSimulate]
[SmartContractsStorageSimulate.Cache]
Expand All @@ -351,6 +363,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[SmartContractsStorageForSCQuery]
[SmartContractsStorageForSCQuery.Cache]
Expand All @@ -364,6 +377,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[StatusMetricsStorage]
[StatusMetricsStorage.Cache]
Expand All @@ -376,6 +390,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[TrieEpochRootHashStorage]
[TrieEpochRootHashStorage.Cache]
Expand All @@ -389,6 +404,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 500
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[ShardHdrNonceHashStorage]
[ShardHdrNonceHashStorage.Cache]
Expand All @@ -402,6 +418,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[MetaHdrNonceHashStorage]
[MetaHdrNonceHashStorage.Cache]
Expand All @@ -415,6 +432,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[AccountsTrieStorage]
[AccountsTrieStorage.Cache]
Expand Down Expand Up @@ -443,6 +461,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[PeerAccountsTrieStorage]
[PeerAccountsTrieStorage.Cache]
Expand All @@ -469,6 +488,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[TrieStorageManagerConfig]
PruningBufferLen = 100000
Expand Down Expand Up @@ -636,16 +656,18 @@
MaxBatchSize = 45000
MaxOpenFiles = 10
UseTmpAsFilePath = true
BloomFilterBitsPerKey = 10

[Antiflood]
Enabled = true
MaxAllowedTrieNodeChunks = 10
TrieNodeChunksInactivityTimeoutInSec = 10

[[Antiflood.ConfigsByRound]]
Round = 0
NumConcurrentResolverJobs = 50
NumConcurrentResolvingTrieNodesJobs = 3

[Antiflood.ConfigsByRound.FastReacting]
[Antiflood.ConfigsByRound.FastReacting]
IntervalInSeconds = 1
ReservedPercent = 20.0
[Antiflood.ConfigsByRound.FastReacting.PeerMaxInput]
Expand Down Expand Up @@ -967,6 +989,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 1000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10
[Hardfork.ExportKeysStorageConfig]
[Hardfork.ExportKeysStorageConfig.Cache]
Name = "HardFork.ExportKeysStorageConfig"
Expand All @@ -978,6 +1001,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 1000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10
[Hardfork.ExportTriesStorageConfig]
[Hardfork.ExportTriesStorageConfig.Cache]
Name = "HardFork.ExportTriesStorageConfig"
Expand All @@ -989,6 +1013,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 1000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10
[Hardfork.ImportStateStorageConfig]
[Hardfork.ImportStateStorageConfig.Cache]
Name = "HardFork.ImportStateStorageConfig"
Expand All @@ -1000,6 +1025,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 1000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10
[Hardfork.ImportKeysStorageConfig]
[Hardfork.ImportKeysStorageConfig.Cache]
Name = "HardFork.ImportKeysStorageConfig"
Expand All @@ -1011,6 +1037,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 1000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[Debug]
[Debug.InterceptorResolver]
Expand Down Expand Up @@ -1073,6 +1100,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[DbLookupExtensions]
Enabled = false
Expand All @@ -1087,6 +1115,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 20000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10
[DbLookupExtensions.MiniblockHashByTxHashStorageConfig.Cache]
Name = "DbLookupExtensions.MiniblockHashByTxHashStorage"
Capacity = 20000
Expand All @@ -1097,6 +1126,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 20000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10
ShardIDProviderType = "BinarySplit"
NumShards = 4
[DbLookupExtensions.EpochByHashStorageConfig.Cache]
Expand All @@ -1109,6 +1139,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 20000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10
ShardIDProviderType = "BinarySplit"
NumShards = 4
[DbLookupExtensions.ResultsHashesByTxHashStorageConfig.Cache]
Expand All @@ -1121,6 +1152,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 20000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10
[DbLookupExtensions.ESDTSuppliesStorageConfig.Cache]
Name = "DbLookupExtensions.ESDTSuppliesStorage"
Capacity = 20000
Expand All @@ -1131,6 +1163,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 20000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10
[DbLookupExtensions.RoundHashStorageConfig.Cache]
Name = "DbLookupExtensions.RoundHashStorage"
Capacity = 20000
Expand All @@ -1141,6 +1174,7 @@
BatchDelaySeconds = 2
MaxBatchSize = 20000
MaxOpenFiles = 10
BloomFilterBitsPerKey = 10

[Logs]
LogFileLifeSpanInMB = 1024 # 1GB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"testing"

"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-go/config"
"github.com/stretchr/testify/require"

"github.com/multiversx/mx-chain-go/config"
)

func TestNewChainParametersNotifier(t *testing.T) {
Expand Down Expand Up @@ -112,12 +113,15 @@ func TestChainParametersNotifier_ConcurrentOperations(t *testing.T) {
}

type dummyNotifee struct {
receivedChainParameters config.ChainParametersByEpochConfig
receivedChainParameters config.ChainParametersByEpochConfig
mutReceivedChainParameters sync.RWMutex
}

// ChainParametersChanged -
func (dn *dummyNotifee) ChainParametersChanged(chainParameters config.ChainParametersByEpochConfig) {
dn.mutReceivedChainParameters.Lock()
dn.receivedChainParameters = chainParameters
dn.mutReceivedChainParameters.Unlock()
}

// IsInterfaceNil -
Expand Down
10 changes: 9 additions & 1 deletion common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/data"
"github.com/multiversx/mx-chain-core-go/data/block"
"github.com/multiversx/mx-chain-go/errors"
logger "github.com/multiversx/mx-chain-logger-go"

"github.com/multiversx/mx-chain-go/config"
"github.com/multiversx/mx-chain-go/errors"
)

const (
Expand Down Expand Up @@ -153,6 +153,14 @@ func IsConsensusBitmapValid(
return ErrWrongSizeBitmap
}

paddingBits := consensusSize % 8
if paddingBits != 0 {
paddingMask := byte(0xFF << paddingBits)
if bitmap[len(bitmap)-1]&paddingMask != 0 {
return ErrPaddingBitsSet
}
}

numOfOnesInBitmap := 0
for index := range bitmap {
numOfOnesInBitmap += bits.OnesCount8(bitmap[index])
Expand Down
23 changes: 23 additions & 0 deletions common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,29 @@ func TestIsConsensusBitmapValid(t *testing.T) {
require.Equal(t, common.ErrNotEnoughSignatures, err)
})

t.Run("padding bits set should return error", func(t *testing.T) {
t.Parallel()

// consensus size is 10, so bitmap should have 2 bytes
bitmap := make([]byte, len(pubKeys)/8+1)
bitmap[0] = 0xFF
bitmap[1] = 0x07

err := common.IsConsensusBitmapValid(log, pubKeys, bitmap, false)
require.Equal(t, common.ErrPaddingBitsSet, err)
})

t.Run("padding bits not set should return nil", func(t *testing.T) {
t.Parallel()

bitmap := make([]byte, len(pubKeys)/8+1)
bitmap[0] = 0xFF
bitmap[1] = 0x03

err := common.IsConsensusBitmapValid(log, pubKeys, bitmap, false)
require.Nil(t, err)
})

t.Run("should work", func(t *testing.T) {
t.Parallel()

Expand Down
3 changes: 3 additions & 0 deletions common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ var ErrInvalidHashShardKey = errors.New("invalid hash shard key")
// ErrInvalidNonceShardKey signals that the provided nonce-shard key is invalid
var ErrInvalidNonceShardKey = errors.New("invalid nonce shard key")

// ErrPaddingBitsSet signals that the provided bitmap has padding bits set to 1 instead of 0
var ErrPaddingBitsSet = errors.New("padding bits in the bitmap should be zero")

// ErrNilCommonConfigsHandler signals that a nil common configs handler has been provided
var ErrNilCommonConfigsHandler = errors.New("nil common configs handler")

Expand Down
14 changes: 14 additions & 0 deletions common/peerAuthentication.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package common

// MaxPeerAuthenticationPublicKeyIdentifierLen is the maximum number of public key bytes used as
// a peer authentication request/whitelist identifier.
const MaxPeerAuthenticationPublicKeyIdentifierLen = 32

// PeerAuthenticationPublicKeyIdentifier returns the public key prefix used as request/whitelist identifier.
func PeerAuthenticationPublicKeyIdentifier(publicKey []byte) []byte {
if len(publicKey) > MaxPeerAuthenticationPublicKeyIdentifierLen {
publicKey = publicKey[:MaxPeerAuthenticationPublicKeyIdentifierLen]
}

return append([]byte(nil), publicKey...)
}
Loading
Loading