Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,12 @@ The **_[config.toml](./cmd/chainsimulator/config/config.toml)_** file:
num-of-shards = 3
# round-duration-in-milliseconds parameter specifies the duration of a simulated round. The timestamp between two headers will correspond to the round duration but will not reflect real-time
round-duration-in-milliseconds = 6000
# supernova-round-duration-in-milliseconds parameter specifies the duration of a simulated round after supernova. The timestamp between two headers will correspond to the round duration but will not reflect real-time
supernova-round-duration-in-milliseconds = 600
# rounds-per-epoch specifies the number of rounds per epoch
rounds-per-epoch = 20
# supernova-rounds-per-epoch specifies the number of rounds per epoch after supernova
supernova-rounds-per-epoch = 200
# initial-round specifies with what round the chain simulator will start
initial-round = 0
# initial-nonce specifies with what nonce the chain simulator will start
Expand Down
4 changes: 4 additions & 0 deletions cmd/chainsimulator/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
num-of-shards = 3
# round-duration-in-milliseconds parameter specifies the duration of a simulated round. The timestamp between two headers will correspond to the round duration but will not reflect real-time
round-duration-in-milliseconds = 6000
# supernova-round-duration-in-milliseconds parameter specifies the duration of a simulated round after supernova. The timestamp between two headers will correspond to the round duration but will not reflect real-time
supernova-round-duration-in-milliseconds = 600
# rounds-per-epoch specifies the number of rounds per epoch
rounds-per-epoch = 20
# supernova-rounds-per-epoch specifies the number of rounds per epoch after supernova
supernova-rounds-per-epoch = 200
# initial-round when the chain simulator will start
initial-round = 0
# initial-epoch when the chain simulator will start
Expand Down
18 changes: 18 additions & 0 deletions cmd/chainsimulator/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ var (
Usage: "The number of rounds per epoch",
Value: 20,
}
supernovaRoundsPerEpoch = cli.IntFlag{
Name: "supernova-rounds-per-epoch",
Usage: "The number of rounds per epoch after supernova",
Value: 200,
}
numOfShards = cli.IntFlag{
Name: "num-of-shards",
Usage: "The number of shards",
Expand All @@ -81,6 +86,11 @@ var (
Usage: "The round duration in milliseconds",
Value: 6000,
}
supernovaRoundDurationInMs = cli.IntFlag{
Name: "supernova-round-duration",
Usage: "The round duration in milliseconds after supernova",
Value: 600,
}
bypassTransactionsSignature = cli.BoolTFlag{
Name: "bypass-txs-signature",
Usage: "This flag is used to bypass the transactions signature verification (by default true)",
Expand Down Expand Up @@ -144,6 +154,10 @@ func applyFlags(ctx *cli.Context, cfg *config.Config) {
cfg.Config.Simulator.RoundsPerEpoch = ctx.GlobalInt(roundsPerEpoch.Name)
}

if ctx.IsSet(supernovaRoundsPerEpoch.Name) {
cfg.Config.Simulator.SupernovaRoundsPerEpoch = ctx.GlobalInt(supernovaRoundsPerEpoch.Name)
}

if ctx.IsSet(numOfShards.Name) {
cfg.Config.Simulator.NumOfShards = ctx.GlobalInt(numOfShards.Name)
}
Expand All @@ -156,6 +170,10 @@ func applyFlags(ctx *cli.Context, cfg *config.Config) {
cfg.Config.Simulator.RoundDurationInMs = ctx.GlobalInt(roundDurationInMs.Name)
}

if ctx.IsSet(supernovaRoundDurationInMs.Name) {
cfg.Config.Simulator.SupernovaRoundDurationInMs = ctx.GlobalInt(supernovaRoundDurationInMs.Name)
}

if ctx.IsSet(initialRound.Name) {
cfg.Config.Simulator.InitialRound = ctx.GlobalInt64(initialRound.Name)
}
Expand Down
39 changes: 24 additions & 15 deletions cmd/chainsimulator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ func main() {
pathToProxyConfigs,
startTime,
roundsPerEpoch,
supernovaRoundsPerEpoch,
numOfShards,
serverPort,
roundDurationInMs,
supernovaRoundDurationInMs,
bypassTransactionsSignature,
numValidatorsPerShard,
numWaitingValidatorsPerShard,
Expand Down Expand Up @@ -138,10 +140,15 @@ func startChainSimulator(ctx *cli.Context) error {
bypassTxsSignature := ctx.GlobalBool(bypassTransactionsSignature.Name)
log.Warn("signature", "bypass", bypassTxsSignature)
roundDurationInMillis := uint64(cfg.Config.Simulator.RoundDurationInMs)
supernovaRoundDurationInMillis := uint64(cfg.Config.Simulator.SupernovaRoundDurationInMs)
rounds := core.OptionalUint64{
HasValue: true,
Value: uint64(cfg.Config.Simulator.RoundsPerEpoch),
}
supernovaRounds := core.OptionalUint64{
HasValue: true,
Value: uint64(cfg.Config.Simulator.SupernovaRoundsPerEpoch),
}

numValidatorsShard := ctx.GlobalInt(numValidatorsPerShard.Name)
if numValidatorsShard < 1 {
Expand Down Expand Up @@ -172,21 +179,23 @@ func startChainSimulator(ctx *cli.Context) error {

var alterConfigsError error
argsChainSimulator := chainSimulator.ArgsChainSimulator{
BypassTxSignatureCheck: bypassTxsSignature,
TempDir: tempDir,
PathToInitialConfig: nodeConfigs,
NumOfShards: uint32(cfg.Config.Simulator.NumOfShards),
GenesisTimestamp: startTimeUnix,
RoundDurationInMillis: roundDurationInMillis,
RoundsPerEpoch: rounds,
ApiInterface: apiConfigurator,
MinNodesPerShard: uint32(numValidatorsShard),
NumNodesWaitingListShard: uint32(numWaitingValidatorsShard),
MetaChainMinNodes: uint32(numValidatorsMetaShard),
NumNodesWaitingListMeta: uint32(numWaitingValidatorsMetaShard),
InitialRound: cfg.Config.Simulator.InitialRound,
InitialNonce: cfg.Config.Simulator.InitialNonce,
InitialEpoch: cfg.Config.Simulator.InitialEpoch,
BypassTxSignatureCheck: bypassTxsSignature,
TempDir: tempDir,
PathToInitialConfig: nodeConfigs,
NumOfShards: uint32(cfg.Config.Simulator.NumOfShards),
GenesisTimestamp: startTimeUnix,
RoundDurationInMillis: roundDurationInMillis,
SupernovaRoundDurationInMillis: supernovaRoundDurationInMillis,
RoundsPerEpoch: rounds,
SupernovaRoundsPerEpoch: supernovaRounds,
ApiInterface: apiConfigurator,
MinNodesPerShard: uint32(numValidatorsShard),
NumNodesWaitingListShard: uint32(numWaitingValidatorsShard),
MetaChainMinNodes: uint32(numValidatorsMetaShard),
NumNodesWaitingListMeta: uint32(numWaitingValidatorsMetaShard),
InitialRound: cfg.Config.Simulator.InitialRound,
InitialNonce: cfg.Config.Simulator.InitialNonce,
InitialEpoch: cfg.Config.Simulator.InitialEpoch,
AlterConfigsFunction: func(cfg *nodeConfig.Configs) {
alterConfigsError = overridableConfig.OverrideConfigValues(overrideCfg.OverridableConfigTomlValues, cfg)
},
Expand Down
20 changes: 11 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import "github.com/multiversx/mx-chain-go/config"
type Config struct {
Config struct {
Simulator struct {
ServerPort int `toml:"server-port"`
NumOfShards int `toml:"num-of-shards"`
RoundsPerEpoch int `toml:"rounds-per-epoch"`
RoundDurationInMs int `toml:"round-duration-in-milliseconds"`
InitialRound int64 `toml:"initial-round"`
InitialNonce uint64 `toml:"initial-nonce"`
InitialEpoch uint32 `toml:"initial-epoch"`
MxChainRepo string `toml:"mx-chain-go-repo"`
MxProxyRepo string `toml:"mx-chain-proxy-go-repo"`
ServerPort int `toml:"server-port"`
NumOfShards int `toml:"num-of-shards"`
RoundsPerEpoch int `toml:"rounds-per-epoch"`
SupernovaRoundsPerEpoch int `toml:"supernova-rounds-per-epoch"`
RoundDurationInMs int `toml:"round-duration-in-milliseconds"`
SupernovaRoundDurationInMs int `toml:"supernova-round-duration-in-milliseconds"`
InitialRound int64 `toml:"initial-round"`
InitialNonce uint64 `toml:"initial-nonce"`
InitialEpoch uint32 `toml:"initial-epoch"`
MxChainRepo string `toml:"mx-chain-go-repo"`
MxProxyRepo string `toml:"mx-chain-proxy-go-repo"`
} `toml:"simulator"`
Logs struct {
LogFileLifeSpanInMB int `toml:"log-file-life-span-in-mb"`
Expand Down
2 changes: 1 addition & 1 deletion examples/generateBlocks/epoch-reached.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def main():
# create a network provider config to increase timeout
config = NetworkProviderConfig(requests_options={"timeout": 10})
config = NetworkProviderConfig(requests_options={"timeout": 200})

# create a network provider
provider = ProxyNetworkProvider(url=SIMULATOR_URL, config=config)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,6 @@ github.com/multiversx/mx-chain-crypto-go v1.3.0 h1:0eK2bkDOMi8VbSPrB1/vGJSYT81IB
github.com/multiversx/mx-chain-crypto-go v1.3.0/go.mod h1:nPIkxxzyTP8IquWKds+22Q2OJ9W7LtusC7cAosz7ojM=
github.com/multiversx/mx-chain-es-indexer-go v1.9.3-0.20251021150757-bd6aa66a0a90 h1:Hf6AqpCSHccBo5ZV5Bfaxz3UdPYhtYCynU+3CF4jAa8=
github.com/multiversx/mx-chain-es-indexer-go v1.9.3-0.20251021150757-bd6aa66a0a90/go.mod h1:t1rkD2vHXSI4EClig0h7+kRCSUCRrMF+emr4DHxFtfA=
github.com/multiversx/mx-chain-go v1.10.9-0.20251028084017-ecdfafd4dd8f h1:BafeoM9LwVwXNcD9lMWYDAgeNJUKjo0uGFSRhUvaF8U=
github.com/multiversx/mx-chain-go v1.10.9-0.20251028084017-ecdfafd4dd8f/go.mod h1:G2LX81y+A75W5EqJod9p4fRAdnp22vpQrB+374pAveQ=
github.com/multiversx/mx-chain-go v1.10.9-0.20251110154005-e75d4545a6b9 h1:HYeYL/524eNl2DA5Mqps8UCeF3EgO7ZWXt0aTNnuYy0=
github.com/multiversx/mx-chain-go v1.10.9-0.20251110154005-e75d4545a6b9/go.mod h1:G2LX81y+A75W5EqJod9p4fRAdnp22vpQrB+374pAveQ=
github.com/multiversx/mx-chain-logger-go v1.1.0 h1:97x84A6L4RfCa6YOx1HpAFxZp1cf/WI0Qh112whgZNM=
Expand Down
Loading