-
Notifications
You must be signed in to change notification settings - Fork 215
chain parameters notifier #4927
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
chain parameters notifier #4927
Conversation
| } | ||
|
|
||
| // New creates a new instance of a chainParametersNotifier component | ||
| func New() *chainParametersNotifier { |
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.
NewChainParametersNotifier to be consistent with the rest of the project
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.
ok :(
| cpn.currentChainParameters = params | ||
| cpn.mutData.Unlock() | ||
|
|
||
| cpn.mutHandler.RLock() |
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.
L32-L46 ensures that the handlers are called only once for each epoch change regardless of the number of UpdateCurrentChainParameters calls. However, if the calls for different epochs are called in extremely fast manner in parallel, some calls on the handlers can be made in a different order. I do not think this will be an issue because the processing is done in sync.
| SetPeerValidatorMapper(validatorMapper process.PeerValidatorMapper) error | ||
| SetTopicsForAll(topics ...string) | ||
| ApplyConsensusSize(size int) | ||
| SetConsensusSizeNotifier(chainParametersNotifier process.ChainParametersSubscriber, shardID uint32) |
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.
let's inject this into the constructor. No need for a setter.
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.
Since the shard ID is unknown when creating the antiflood components, I cannot make this change
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.
ok
| Value: shardID, | ||
| } | ||
|
|
||
| chainParametersNotifier.RegisterNotifyHandler(af) |
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.
this can be called on the constructor
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.
Since the shard ID is unknown when creating the antiflood components, I cannot make this change
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.
ok
|
|
||
| // ChainParametersChanged will be called when new chain parameters are confirmed on the network | ||
| func (af *p2pAntiflood) ChainParametersChanged(chainParameters config.ChainParametersByEpochConfig) { | ||
| size := chainParameters.ShardConsensusGroupSize |
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.
concurrency issues on the usage of the af.shardID ?
Also why do we need the set on L76?
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.
added a mutex. the setter is needed for computing the consensus size in case of shard vs meta
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestNew(t *testing.T) { |
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.
TestNewChainParametersNotifier ?
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.
done
|
|
||
| // Close will call the close function on all sub components | ||
| func (af *p2pAntiflood) Close() error { | ||
| af.mutDebugger.Lock() |
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.
👍
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## feat/consensus-size-changes #4927 +/- ##
==============================================================
Coverage ? 70.91%
==============================================================
Files ? 677
Lines ? 87950
Branches ? 0
==============================================================
Hits ? 62370
Misses ? 20897
Partials ? 4683 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
…fier # Conflicts: # common/interface.go # factory/consensus/consensusComponents.go # integrationTests/testConsensusNode.go # process/throttle/antiflood/p2pAntiflood_test.go
| } | ||
| cc := &consensusComponents{} | ||
|
|
||
| consensusGroupSize, err := getConsensusGroupSize(ccf.coreComponents.GenesisNodesSetup(), ccf.processComponents.ShardCoordinator()) |
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.
👍
| Value: shardID, | ||
| } | ||
|
|
||
| chainParametersNotifier.RegisterNotifyHandler(af) |
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.
ok
| type Node struct { | ||
| initialNodesPubkeys map[uint32][]string | ||
| roundDuration uint64 | ||
| consensusGroupSize int |
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.
minor conflicts here when we will bring the rc/v1.5.0 in rc/v1.6.0 because I've added unit test for the getter & setter of the consensus group size
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.
I'll happily delete those unit tests when merging 😄
| }, nil | ||
| } | ||
|
|
||
| if epoch < 9 { |
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.
👍 nice approach to avoid calls like if (epoch < 9) && (epoch >= 6) {...
| EpochStart: block.EpochStart{LastFinalizedHeaders: []block.EpochStartShardData{{}}}, | ||
| } | ||
|
|
||
| // change to epoch 1 - should have 3 eligible per shard, 3 per meta |
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.
I would also add tests for epochs 2, 3, 4, 6, 8, 9, 10, and 11 to test the correct change conditions
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.
refactored the unit test and now it checks from epoch 0 to epoch 100
gabi-vuls
left a comment
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.
@@ Log scanner @@
chain-params-notifier-test-mar30
================================================================================
- Known Warnings 11
- New Warnings 5
- Known Errors 0
- New Errors 0
- Panics 0
================================================================================ - block hash does not match 10501
- wrong nonce in block 3632
- miniblocks does not match 0
- num miniblocks does not match 0
- miniblock hash does not match 0
- block bodies does not match 0
- receipts hash missmatch 0
================================================================================ - No jailed nodes on the thestnet
================================================================================
|
|
||
| afm.ApplyConsensusSize(expectedSize) | ||
| chainParamsSubscriber := chainparametersnotifier.NewChainParametersNotifier() | ||
| afm.SetConsensusSizeNotifier(chainParamsSubscriber, 5) |
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.
can you use a variable/constant instead of literal 5?
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.
done
|
|
||
| // Close will call the close function on all sub components | ||
| func (af *p2pAntiflood) Close() error { | ||
| af.mutDebugger.Lock() |
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.
rlock?
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.
done
961bb62
gabi-vuls
left a comment
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.
System test passed
Reasoning behind the pull request
Proposed changes
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
featbranch created?featbranch merging, do all satellite projects have a proper tag insidego.mod?