Skip to content

Commit a51780b

Browse files
authored
Merge pull request #6849 from multiversx/chain-simulator-integration-andromeda
Chain simulator integration andromeda
2 parents 6c3bc6f + 7041d2c commit a51780b

File tree

8 files changed

+218
-62
lines changed

8 files changed

+218
-62
lines changed

integrationTests/chainSimulator/relayedTx/relayedTx_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func TestRelayedV3WithChainSimulator(t *testing.T) {
5656
t.Skip("this is not a short test")
5757
}
5858

59+
t.Run("successful intra shard guarded move balance", testRelayedV3MoveBalance(0, 0, false, true))
5960
t.Run("sender == relayer move balance should consume fee", testRelayedV3RelayedBySenderMoveBalance())
6061
t.Run("receiver == relayer move balance should consume fee", testRelayedV3RelayedByReceiverMoveBalance())
6162
t.Run("successful intra shard move balance", testRelayedV3MoveBalance(0, 0, false, false))
@@ -104,7 +105,6 @@ func testRelayedV3MoveBalance(
104105
guardedTx bool,
105106
) func(t *testing.T) {
106107
return func(t *testing.T) {
107-
108108
providedActivationEpoch := uint32(1)
109109
alterConfigsFunc := func(cfg *config.Configs) {
110110
cfg.EpochConfig.EnableEpochs.FixRelayedBaseCostEnableEpoch = providedActivationEpoch

node/chainSimulator/chainSimulator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func NewChainSimulator(args ArgsChainSimulator) (*simulator, error) {
8686
return NewBaseChainSimulator(ArgsBaseChainSimulator{
8787
ArgsChainSimulator: args,
8888
ConsensusGroupSize: configs.ChainSimulatorConsensusGroupSize,
89-
MetaChainConsensusGroupSize: configs.ChainSimulatorConsensusGroupSize,
89+
MetaChainConsensusGroupSize: args.MetaChainMinNodes,
9090
})
9191
}
9292

node/chainSimulator/chainSimulator_test.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,25 @@ func TestNewChainSimulator(t *testing.T) {
3636
NumOfShards: 3,
3737
GenesisTimestamp: startTime,
3838
RoundDurationInMillis: roundDurationInMillis,
39-
RoundsPerEpoch: core.OptionalUint64{},
40-
ApiInterface: api.NewNoApiInterface(),
41-
MinNodesPerShard: 1,
42-
MetaChainMinNodes: 1,
39+
RoundsPerEpoch: core.OptionalUint64{
40+
HasValue: true,
41+
Value: 20,
42+
},
43+
ApiInterface: api.NewNoApiInterface(),
44+
MinNodesPerShard: 3,
45+
MetaChainMinNodes: 3,
4346
})
4447
require.Nil(t, err)
4548
require.NotNil(t, chainSimulator)
4649

50+
for i := 0; i < 8; i++ {
51+
err = chainSimulator.ForceChangeOfEpoch()
52+
require.Nil(t, err)
53+
}
54+
55+
err = chainSimulator.GenerateBlocks(50)
56+
require.Nil(t, err)
57+
4758
time.Sleep(time.Second)
4859

4960
chainSimulator.Close()

node/chainSimulator/components/coreComponents.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ func CreateCoreComponents(args ArgsCoreComponentsHolder) (*coreComponentsHolder,
184184
return nil, err
185185
}
186186

187-
if err != nil {
188-
return nil, err
189-
}
190-
191187
argsEconomicsHandler := economics.ArgsNewEconomicsData{
192188
TxVersionChecker: instance.txVersionChecker,
193189
Economics: &args.EconomicsConfig,

node/chainSimulator/configs/configs.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/multiversx/mx-chain-go/common/factory"
1515
"github.com/multiversx/mx-chain-go/config"
1616
"github.com/multiversx/mx-chain-go/genesis/data"
17-
"github.com/multiversx/mx-chain-go/integrationTests"
1817
"github.com/multiversx/mx-chain-go/node"
1918
"github.com/multiversx/mx-chain-go/node/chainSimulator/dtos"
2019
"github.com/multiversx/mx-chain-go/sharding"
@@ -117,7 +116,6 @@ func CreateChainSimulatorConfigs(args ArgsChainSimulatorConfigs) (*ArgsConfigsSi
117116

118117
// set compatible trie configs
119118
configs.GeneralConfig.StateTriesConfig.SnapshotsEnabled = false
120-
121119
// enable db lookup extension
122120
configs.GeneralConfig.DbLookupExtensions.Enabled = true
123121

@@ -134,23 +132,13 @@ func CreateChainSimulatorConfigs(args ArgsChainSimulatorConfigs) (*ArgsConfigsSi
134132
return nil, err
135133
}
136134

137-
for idx := 0; idx < len(configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch); idx++ {
138-
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[idx].ShardMinNumNodes = args.MinNodesPerShard
139-
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[idx].MetachainMinNumNodes = args.MetaChainMinNodes
140-
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[idx].MetachainConsensusGroupSize = args.MetaChainConsensusGroupSize
141-
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[idx].ShardConsensusGroupSize = args.ConsensusGroupSize
142-
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[idx].RoundDuration = args.RoundDurationInMillis
143-
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[idx].Hysteresis = args.Hysteresis
144-
}
145-
146-
// TODO[Sorin]: remove this once all equivalent messages PRs are merged
147-
configs.EpochConfig.EnableEpochs.EquivalentMessagesEnableEpoch = integrationTests.UnreachableEpoch
148-
configs.EpochConfig.EnableEpochs.FixedOrderInConsensusEnableEpoch = integrationTests.UnreachableEpoch
149-
135+
updateConfigsChainParameters(args, configs)
150136
node.ApplyArchCustomConfigs(configs)
151137

152138
if args.AlterConfigsFunction != nil {
153139
args.AlterConfigsFunction(configs)
140+
// this is needed to keep in sync EquivalentMessage flag and the second entry from chain parameters
141+
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[1].EnableEpoch = configs.EpochConfig.EnableEpochs.EquivalentMessagesEnableEpoch
154142
}
155143

156144
return &ArgsConfigsSimulator{
@@ -161,6 +149,21 @@ func CreateChainSimulatorConfigs(args ArgsChainSimulatorConfigs) (*ArgsConfigsSi
161149
}, nil
162150
}
163151

152+
func updateConfigsChainParameters(args ArgsChainSimulatorConfigs, configs *config.Configs) {
153+
for idx := 0; idx < len(configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch); idx++ {
154+
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[idx].ShardMinNumNodes = args.MinNodesPerShard
155+
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[idx].MetachainMinNumNodes = args.MetaChainMinNodes
156+
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[idx].MetachainConsensusGroupSize = args.MetaChainConsensusGroupSize
157+
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[idx].ShardConsensusGroupSize = args.ConsensusGroupSize
158+
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[idx].RoundDuration = args.RoundDurationInMillis
159+
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[idx].Hysteresis = args.Hysteresis
160+
}
161+
162+
if len(configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch) > 1 {
163+
configs.GeneralConfig.GeneralSettings.ChainParametersByEpoch[1].ShardConsensusGroupSize = args.MinNodesPerShard
164+
}
165+
}
166+
164167
// SetMaxNumberOfNodesInConfigs will correctly set the max number of nodes in configs
165168
func SetMaxNumberOfNodesInConfigs(cfg *config.Configs, eligibleNodes uint32, waitingNodes uint32, numOfShards uint32) {
166169
cfg.SystemSCConfig.StakingSystemSCConfig.MaxNumberOfNodesForStake = uint64(eligibleNodes + waitingNodes)

0 commit comments

Comments
 (0)