-
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
Changes from 4 commits
8238e5b
be4806f
e071567
6b6e478
053fe06
617da1e
abc1890
1b49b5a
a885724
b210638
56bcfb7
19b2db2
fbe6f81
55b9939
5601282
961bb62
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 |
|---|---|---|
|
|
@@ -62,7 +62,6 @@ type filter interface { | |
| type Node struct { | ||
| initialNodesPubkeys map[uint32][]string | ||
| roundDuration uint64 | ||
| consensusGroupSize int | ||
|
Contributor
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. 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
Contributor
Author
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'll happily delete those unit tests when merging 😄 |
||
| genesisTime time.Time | ||
| peerDenialEvaluator p2p.PeerDenialEvaluator | ||
| esdtStorageHandler vmcommon.ESDTNFTStorageHandler | ||
|
|
@@ -148,11 +147,6 @@ func (n *Node) CreateShardedStores() error { | |
| return nil | ||
| } | ||
|
|
||
| // GetConsensusGroupSize returns the configured consensus size | ||
| func (n *Node) GetConsensusGroupSize() int { | ||
| return n.consensusGroupSize | ||
| } | ||
|
|
||
| // GetBalance gets the balance for a specific address | ||
| func (n *Node) GetBalance(address string, options api.AccountQueryOptions) (*big.Int, api.BlockInfo, error) { | ||
| userAccount, blockInfo, err := n.loadUserAccountHandlerByAddress(address, options) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2519,3 +2519,97 @@ func TestIndexHashedNodesCoordinator_GetShardValidatorInfoData(t *testing.T) { | |
| require.Equal(t, svi, shardValidatorInfo) | ||
| }) | ||
| } | ||
|
|
||
| func TestNodesCoordinator_CustomConsensusGroupSize(t *testing.T) { | ||
| arguments := createArguments() | ||
| eligibleMap := createDummyNodesMap(3, 2, "eligible") | ||
| waitingMap := createDummyNodesMap(0, 2, "waiting") | ||
| arguments.EligibleNodes = eligibleMap | ||
| arguments.WaitingNodes = waitingMap | ||
| arguments.ValidatorInfoCacher = dataPool.NewCurrentEpochValidatorInfoPool() | ||
| arguments.ChainParametersHandler = &shardingmock.ChainParametersHandlerStub{ | ||
| ChainParametersForEpochCalled: func(epoch uint32) (config.ChainParametersByEpochConfig, error) { | ||
| if epoch < 3 { | ||
| return config.ChainParametersByEpochConfig{ | ||
| ShardConsensusGroupSize: 2, | ||
| ShardMinNumNodes: 2, | ||
| MetachainConsensusGroupSize: 3, | ||
| MetachainMinNumNodes: 3, | ||
| }, nil | ||
| } | ||
|
|
||
| if epoch < 6 { | ||
| return config.ChainParametersByEpochConfig{ | ||
| ShardConsensusGroupSize: 3, | ||
| ShardMinNumNodes: 3, | ||
| MetachainConsensusGroupSize: 3, | ||
| MetachainMinNumNodes: 3, | ||
| }, nil | ||
| } | ||
|
|
||
| if epoch < 9 { | ||
|
||
| return config.ChainParametersByEpochConfig{ | ||
| ShardConsensusGroupSize: 3, | ||
| ShardMinNumNodes: 3, | ||
| MetachainConsensusGroupSize: 2, | ||
| MetachainMinNumNodes: 2, | ||
| }, nil | ||
| } | ||
|
|
||
| return config.ChainParametersByEpochConfig{ | ||
| ShardConsensusGroupSize: 3, | ||
| ShardMinNumNodes: 3, | ||
| MetachainConsensusGroupSize: 3, | ||
| MetachainMinNumNodes: 3, | ||
| }, nil | ||
| }, | ||
| } | ||
|
|
||
| ihnc, _ := NewIndexHashedNodesCoordinator(arguments) | ||
| require.NotNil(t, ihnc) | ||
|
|
||
| header := &block.MetaBlock{ | ||
| PrevRandSeed: []byte("rand seed"), | ||
| EpochStart: block.EpochStart{LastFinalizedHeaders: []block.EpochStartShardData{{}}}, | ||
| } | ||
|
|
||
| // change to epoch 1 - should have 3 eligible per shard, 3 per meta | ||
|
||
| epoch := uint32(1) | ||
| header.Epoch = epoch | ||
| ihnc.nodesConfig[epoch] = ihnc.nodesConfig[0] | ||
| body := createBlockBodyFromNodesCoordinator(ihnc, epoch, ihnc.validatorInfoCacher) | ||
| ihnc.EpochStartPrepare(header, body) | ||
| ihnc.EpochStartAction(header) | ||
| require.Len(t, ihnc.nodesConfig[epoch].eligibleMap[0], 2) | ||
| require.Len(t, ihnc.nodesConfig[epoch].eligibleMap[common.MetachainShardId], 3) | ||
|
|
||
| // change to epoch 5 - should have 3 eligible per shard, 3 per meta | ||
| epoch = 5 | ||
| header.Epoch = epoch | ||
| ihnc.nodesConfig[epoch] = ihnc.nodesConfig[0] | ||
| body = createBlockBodyFromNodesCoordinator(ihnc, epoch, ihnc.validatorInfoCacher) | ||
| ihnc.EpochStartPrepare(header, body) | ||
| ihnc.EpochStartAction(header) | ||
| require.Len(t, ihnc.nodesConfig[epoch].eligibleMap[0], 3) | ||
| require.Len(t, ihnc.nodesConfig[epoch].eligibleMap[common.MetachainShardId], 3) | ||
|
|
||
| // change to epoch 7 - should have 3 eligible per shard, 2 per meta | ||
| epoch = 7 | ||
| header.Epoch = epoch | ||
| ihnc.nodesConfig[epoch] = ihnc.nodesConfig[5] | ||
| body = createBlockBodyFromNodesCoordinator(ihnc, epoch, ihnc.validatorInfoCacher) | ||
| ihnc.EpochStartPrepare(header, body) | ||
| ihnc.EpochStartAction(header) | ||
| require.Len(t, ihnc.nodesConfig[epoch].eligibleMap[0], 3) | ||
| require.Len(t, ihnc.nodesConfig[epoch].eligibleMap[common.MetachainShardId], 2) | ||
|
|
||
| // change to epoch 12 - should have 3 eligible per shard, 3 per meta | ||
| epoch = 12 | ||
| header.Epoch = epoch | ||
| ihnc.nodesConfig[epoch] = ihnc.nodesConfig[5] | ||
| body = createBlockBodyFromNodesCoordinator(ihnc, epoch, ihnc.validatorInfoCacher) | ||
| ihnc.EpochStartPrepare(header, body) | ||
| ihnc.EpochStartAction(header) | ||
| require.Len(t, ihnc.nodesConfig[epoch].eligibleMap[0], 3) | ||
| require.Len(t, ihnc.nodesConfig[epoch].eligibleMap[common.MetachainShardId], 3) | ||
| } | ||
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.
👍