-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Message validation optimization #6462
base: feat/equivalent-messages
Are you sure you want to change the base?
Changes from 14 commits
10afdba
aaa9d4b
603bd69
57f009e
f5a6f2e
8eec330
a733097
bab3b05
c3f7120
b62e37b
c00f8ee
94a64c1
d77e367
d59c5bd
396cd8e
a44129f
afdceb1
d8d8113
fe2082c
c6b7a0f
f59fc85
d00c7ab
f21e24f
f40d222
3a327c4
a756a1f
ff8eaa9
cde6c80
e0cf24b
9504263
b622085
f0b34ef
b05c650
5dc6bba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,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" | ||
|
||
"github.com/multiversx/mx-chain-go/common" | ||
"github.com/multiversx/mx-chain-go/config" | ||
"github.com/multiversx/mx-chain-go/epochStart" | ||
|
@@ -17,6 +18,7 @@ import ( | |
"github.com/multiversx/mx-chain-go/process/interceptors" | ||
interceptorsFactory "github.com/multiversx/mx-chain-go/process/interceptors/factory" | ||
"github.com/multiversx/mx-chain-go/sharding" | ||
"github.com/multiversx/mx-chain-go/storage" | ||
) | ||
|
||
var _ epochStart.StartOfEpochMetaSyncer = (*epochStartMetaSyncer)(nil) | ||
|
@@ -91,14 +93,15 @@ func NewEpochStartMetaSyncer(args ArgsNewEpochStartMetaSyncer) (*epochStartMetaS | |
|
||
e.singleDataInterceptor, err = interceptors.NewSingleDataInterceptor( | ||
interceptors.ArgSingleDataInterceptor{ | ||
Topic: factory.MetachainBlocksTopic, | ||
DataFactory: interceptedMetaHdrDataFactory, | ||
Processor: args.MetaBlockProcessor, | ||
Throttler: disabled.NewThrottler(), | ||
AntifloodHandler: disabled.NewAntiFloodHandler(), | ||
WhiteListRequest: args.WhitelistHandler, | ||
CurrentPeerId: args.Messenger.ID(), | ||
PreferredPeersHolder: disabled.NewPreferredPeersHolder(), | ||
Topic: factory.MetachainBlocksTopic, | ||
DataFactory: interceptedMetaHdrDataFactory, | ||
Processor: args.MetaBlockProcessor, | ||
Throttler: disabled.NewThrottler(), | ||
AntifloodHandler: disabled.NewAntiFloodHandler(), | ||
WhiteListRequest: args.WhitelistHandler, | ||
CurrentPeerId: args.Messenger.ID(), | ||
PreferredPeersHolder: disabled.NewPreferredPeersHolder(), | ||
ProcessedMessagesCacheMap: make(map[string]storage.Cacher), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should not be allocated here, but received through the arguments. |
||
}, | ||
) | ||
if err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1501,6 +1501,8 @@ func (pcf *processComponentsFactory) newInterceptorContainerFactory( | |
nodeOperationMode = common.FullArchiveMode | ||
} | ||
|
||
processedMessagesCacheMap := make(map[string]storage.Cacher) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should not be initialized here, but received in the arguments so we can also mock it in tests. |
||
|
||
shardCoordinator := pcf.bootstrapComponents.ShardCoordinator() | ||
if shardCoordinator.SelfId() < shardCoordinator.NumberOfShards() { | ||
return pcf.newShardInterceptorContainerFactory( | ||
|
@@ -1513,6 +1515,7 @@ func (pcf *processComponentsFactory) newInterceptorContainerFactory( | |
fullArchivePeerShardMapper, | ||
hardforkTrigger, | ||
nodeOperationMode, | ||
processedMessagesCacheMap, | ||
) | ||
} | ||
if shardCoordinator.SelfId() == core.MetachainShardId { | ||
|
@@ -1526,6 +1529,7 @@ func (pcf *processComponentsFactory) newInterceptorContainerFactory( | |
fullArchivePeerShardMapper, | ||
hardforkTrigger, | ||
nodeOperationMode, | ||
processedMessagesCacheMap, | ||
) | ||
} | ||
|
||
|
@@ -1665,6 +1669,7 @@ func (pcf *processComponentsFactory) newShardInterceptorContainerFactory( | |
fullArchivePeerShardMapper *networksharding.PeerShardMapper, | ||
hardforkTrigger factory.HardforkTrigger, | ||
nodeOperationMode common.NodeOperation, | ||
processedMessagesCacheMap map[string]storage.Cacher, | ||
) (process.InterceptorsContainerFactory, process.TimeCacher, error) { | ||
headerBlackList := cache.NewTimeCache(timeSpanForBadHeaders) | ||
shardInterceptorsContainerFactoryArgs := interceptorscontainer.CommonInterceptorsContainerFactoryArgs{ | ||
|
@@ -1698,6 +1703,7 @@ func (pcf *processComponentsFactory) newShardInterceptorContainerFactory( | |
FullArchivePeerShardMapper: fullArchivePeerShardMapper, | ||
HardforkTrigger: hardforkTrigger, | ||
NodeOperationMode: nodeOperationMode, | ||
ProcessedMessagesCacheMap: processedMessagesCacheMap, | ||
} | ||
|
||
interceptorContainerFactory, err := interceptorscontainer.NewShardInterceptorsContainerFactory(shardInterceptorsContainerFactoryArgs) | ||
|
@@ -1718,6 +1724,7 @@ func (pcf *processComponentsFactory) newMetaInterceptorContainerFactory( | |
fullArchivePeerShardMapper *networksharding.PeerShardMapper, | ||
hardforkTrigger factory.HardforkTrigger, | ||
nodeOperationMode common.NodeOperation, | ||
processedMessageCacheMap map[string]storage.Cacher, | ||
) (process.InterceptorsContainerFactory, process.TimeCacher, error) { | ||
headerBlackList := cache.NewTimeCache(timeSpanForBadHeaders) | ||
metaInterceptorsContainerFactoryArgs := interceptorscontainer.CommonInterceptorsContainerFactoryArgs{ | ||
|
@@ -1751,6 +1758,7 @@ func (pcf *processComponentsFactory) newMetaInterceptorContainerFactory( | |
FullArchivePeerShardMapper: fullArchivePeerShardMapper, | ||
HardforkTrigger: hardforkTrigger, | ||
NodeOperationMode: nodeOperationMode, | ||
ProcessedMessagesCacheMap: processedMessageCacheMap, | ||
} | ||
|
||
interceptorContainerFactory, err := interceptorscontainer.NewMetaInterceptorsContainerFactory(metaInterceptorsContainerFactoryArgs) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check all intializations of this map, as we might end up with multiple versions of this.