Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
41597fe
Merge pull request #157 from multiversx/merge-main-in-supernova
miiu96 Aug 12, 2025
3dcc4e5
update go mod
danielradu10 Oct 7, 2025
a127d3d
fix
danielradu10 Oct 7, 2025
572525f
Merge pull request #167 from multiversx/update-go-mod
sstanculeanu Oct 7, 2025
86a5743
update
danielradu10 Oct 9, 2025
4d71f58
Merge pull request #168 from multiversx/update-rc-supernova
danielradu10 Oct 9, 2025
e9bc316
updated mx-chain-go
sstanculeanu Oct 14, 2025
7eb0e77
Merge pull request #169 from multiversx/fix-genesis-time-mismatch-in-…
sstanculeanu Oct 14, 2025
f9f5817
updated mx-chain-go
sstanculeanu Oct 17, 2025
6eb2769
Merge pull request #170 from multiversx/time-duration-fix-manual-roun…
sstanculeanu Oct 17, 2025
0bdb3c4
updated mx-chain-go
sstanculeanu Oct 21, 2025
e333969
Merge pull request #171 from multiversx/fix-custom-configs-chain-simu…
sstanculeanu Oct 28, 2025
9e68456
updated mx-chain-go with the latest chain simulator arguments
sstanculeanu Oct 28, 2025
9dfa7f7
updated mx-chain-go
sstanculeanu Oct 28, 2025
7ec3cec
updated mx-chain-go
sstanculeanu Oct 29, 2025
16860d5
Merge pull request #174 from multiversx/update-node
sstanculeanu Oct 29, 2025
14983c2
bump mx-chain-go
ssd04 Nov 11, 2025
7c159da
Merge pull request #178 from multiversx/update-mx-chain-go
ssd04 Nov 11, 2025
1c67899
Merge branch 'rc/supernova' of https://github.com/multiversx/mx-chain…
sstanculeanu Nov 12, 2025
a7725b3
go mod tidy
sstanculeanu Nov 12, 2025
06082d8
increase timeout
sstanculeanu Nov 12, 2025
f347825
Merge pull request #173 from multiversx/new-parameters
sstanculeanu Nov 12, 2025
c4d8ef2
fix supernova activation round
miiu96 Nov 13, 2025
8cac912
Merge branch 'main' of https://github.com/multiversx/mx-chain-simulat…
sstanculeanu Nov 24, 2025
f9f6fb6
updated mx-chain-go after merge
sstanculeanu Nov 24, 2025
c28e818
Merge pull request #181 from multiversx/merge-main-into-rc-supernova
sstanculeanu Nov 24, 2025
3173352
Merge branch 'rc/supernova' into fix-supernova-actionvation-round
miiu96 Nov 27, 2025
7fdd69f
update
miiu96 Nov 27, 2025
6461d6f
testing with ram
raduchis Nov 28, 2025
2964329
latest commit
miiu96 Dec 2, 2025
22aab80
cpu profile added
raduchis Dec 2, 2025
b5b9d4d
Bypass blocks signature
axenteoctavian Dec 2, 2025
048498d
fix go.mod
axenteoctavian Dec 2, 2025
f66e0e5
updated name to enable-profiling
raduchis Dec 2, 2025
43d56b1
Merge pull request #180 from multiversx/fix-supernova-actionvation-round
axenteoctavian Dec 3, 2025
71da764
Merge branch 'rc/supernova' into bypass-blocks-signature
axenteoctavian Dec 3, 2025
61815e7
Merge branch 'main' of https://github.com/multiversx/mx-chain-simulat…
sstanculeanu Dec 8, 2025
87808d5
updated mx-chain-go
sstanculeanu Dec 8, 2025
52726eb
Update go.mod
axenteoctavian Dec 8, 2025
c1b3e2f
fix
miiu96 Dec 8, 2025
2d34f31
Merge pull request #190 from multiversx/merge-main-into-rc/supernova-…
sstanculeanu Dec 8, 2025
662771d
go.mod update
axenteoctavian Dec 10, 2025
71e8fa6
Merge branch 'rc/supernova' into bypass-blocks-signature
axenteoctavian Dec 12, 2025
8c773ac
Update go.mod
axenteoctavian Dec 12, 2025
954e2f9
Update go.mod
axenteoctavian Dec 12, 2025
baacc71
updated mx-chain-go to v1.11.2-0.20251215095623-aaca4d73f477
raduchis Dec 15, 2025
6d12db1
Merge pull request #192 from multiversx/supernova-to-chain-simulator-…
raduchis Dec 15, 2025
a6dc946
latest
miiu96 Dec 15, 2025
205b7bc
Merge branch 'refs/heads/rc/supernova' into bypass-blocks-signature
axenteoctavian Dec 16, 2025
5030edd
Update go.mod
axenteoctavian Dec 16, 2025
3a46bd4
fixes after review
axenteoctavian Dec 16, 2025
7f0959c
Merge branch 'rc/supernova' into pprof-and-shutdown
raduchis Dec 16, 2025
b7705e0
Merge pull request #185 from multiversx/pprof-and-shutdown
raduchis Dec 16, 2025
2e3b313
go.mod update
axenteoctavian Dec 16, 2025
bec59cc
go.mod mx-chain-go update to fixes-async-exe
axenteoctavian Dec 16, 2025
70f2390
go.mod mx-chain-proxy-go update to update-core-go
axenteoctavian Dec 16, 2025
cd1e2e4
go.mod mx-chain-go update to latest fixes-async-exec
axenteoctavian Dec 16, 2025
8ce4793
fix test
axenteoctavian Dec 17, 2025
58b0b9e
Update go.mod
axenteoctavian Dec 17, 2025
afdf5d0
Merge branch 'rc/supernova' into bypass-blocks-signature
axenteoctavian Dec 17, 2025
6a11acd
Merge pull request #183 from multiversx/bypass-blocks-signature
axenteoctavian Dec 17, 2025
de59cbe
Merge pull request #194 from multiversx/fix-receipts-go-mod
axenteoctavian Dec 18, 2025
e4a0b50
Update go.mod
axenteoctavian Dec 18, 2025
d37ac0a
Update go.mod
axenteoctavian Dec 18, 2025
06cb7cb
change num of block to generate
miiu96 Dec 22, 2025
be699b1
update proxy
miiu96 Dec 22, 2025
e3ff735
fix action
miiu96 Dec 22, 2025
f25ef8d
one more blocks
miiu96 Dec 22, 2025
f50b798
one more blocks
miiu96 Dec 22, 2025
780dffd
rollback
miiu96 Dec 22, 2025
785b2ec
Merge pull request #193 from multiversx/lastestd-commit-chain-sim-asy…
miiu96 Dec 22, 2025
c4f8681
Update go.mod
axenteoctavian Dec 23, 2025
a4648cc
Merge branch 'feat/supernova-async-exec' into update-go-mod-23-dec
axenteoctavian Dec 23, 2025
b2f1688
Update go.mod
axenteoctavian Dec 23, 2025
7df2138
Merge pull request #196 from multiversx/update-go-mod-23-dec
axenteoctavian Dec 23, 2025
df9d2cc
Merge branch 'rc/supernova' into merge-rc-supernova-into-feat-9-ian
axenteoctavian Jan 9, 2026
9b1ccfe
update go.mod
axenteoctavian Jan 9, 2026
4b59698
Merge pull request #198 from multiversx/merge-rc-supernova-into-feat-…
axenteoctavian Jan 9, 2026
76b8ae7
Update go.mod with latest feat/supernova-async-exec
axenteoctavian Jan 12, 2026
35d7f99
Merge pull request #199 from multiversx/update-go-mod-12-ian
axenteoctavian Jan 12, 2026
92dd999
Update go.mod with latest feat/supernova-async-exec
axenteoctavian Jan 14, 2026
0dfb361
Merge pull request #200 from multiversx/update-go-mod-14-ian
axenteoctavian Jan 14, 2026
861acb6
Update go.mod with latest feat/supernova-async-exec
axenteoctavian Jan 21, 2026
37fa2d6
Merge pull request #202 from multiversx/update-go-mod-21-ian
axenteoctavian Jan 21, 2026
eb54366
update supernova async
miiu96 Jan 28, 2026
535d51e
Merge pull request #204 from multiversx/update-supernova-async
miiu96 Jan 28, 2026
7300a12
Create block time and bypass flags
axenteoctavian Jan 29, 2026
07c8d1f
Merge pull request #205 from multiversx/create-block-time-check-flags
sstanculeanu Feb 2, 2026
c6bc8bb
Update go.mod
axenteoctavian Feb 2, 2026
b211bb0
update go.mod
axenteoctavian Feb 2, 2026
22de031
update go.mod
axenteoctavian Feb 3, 2026
441fb5f
Merge pull request #206 from multiversx/update-go-mod-2-feb
AdoAdoAdo Feb 3, 2026
cb020a9
update go.mod
axenteoctavian Feb 4, 2026
132fbd1
Merge pull request #207 from multiversx/update-go-mod-4-feb
axenteoctavian Feb 4, 2026
87617f6
update go.mod
axenteoctavian Feb 6, 2026
72c689a
Merge pull request #208 from multiversx/update-go-mod-6-feb
axenteoctavian Feb 6, 2026
b2bce1d
update go.mod
axenteoctavian Feb 9, 2026
aea172a
Merge pull request #209 from multiversx/update-go-mod-9-feb
axenteoctavian Feb 9, 2026
a299852
update go.mod
axenteoctavian Feb 11, 2026
6ca39c7
Merge pull request #210 from multiversx/update-go-mod-11-feb
axenteoctavian Feb 11, 2026
b0a3d16
update go.mod
axenteoctavian Feb 16, 2026
b8d72cf
Merge pull request #211 from multiversx/update-go-mod-16-feb
axenteoctavian Feb 16, 2026
31d836d
go.mod update
axenteoctavian Feb 17, 2026
742a5cc
Merge pull request #213 from multiversx/enable-rounds-api-route
axenteoctavian Feb 17, 2026
436686e
go.mod update
axenteoctavian Feb 24, 2026
c56eb52
Merge pull request #214 from multiversx/update-go-mod-24-feb
axenteoctavian Feb 24, 2026
05a3be8
go.mod update
axenteoctavian Mar 2, 2026
a730321
Merge pull request #215 from multiversx/update-go-mod-2-mar
axenteoctavian Mar 2, 2026
c9f4a36
go.mod update
axenteoctavian Mar 9, 2026
6c6637c
Merge pull request #216 from multiversx/update-go-mod-9-mar
axenteoctavian Mar 9, 2026
37d9d25
go.mod update
axenteoctavian Mar 19, 2026
976e06f
Merge pull request #217 from multiversx/update-go-mod-19-mar
axenteoctavian Mar 19, 2026
8af1afe
updated deps
sstanculeanu Apr 3, 2026
e9f6679
Merge pull request #218 from multiversx/update-deps-supernova
miiu96 Apr 3, 2026
f10bde7
Merge pull request #203 from multiversx/feat/supernova-async-exec
sstanculeanu Apr 6, 2026
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
38 changes: 37 additions & 1 deletion cmd/chainsimulator/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"time"

logger "github.com/multiversx/mx-chain-logger-go"
"github.com/multiversx/mx-chain-simulator-go/config"
"github.com/urfave/cli"

"github.com/multiversx/mx-chain-simulator-go/config"
)

const nodeOverrideDefaultFilename = "nodeOverrideDefault.toml"
Expand Down Expand Up @@ -66,6 +67,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,10 +87,28 @@ 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)",
}
bypassBlocksSignature = cli.BoolTFlag{
Name: "bypass-blocks-signature",
Usage: "This flag is used to bypass the blocks signature verification (by default true)",
}
bypassCreateBlockTimeCheck = cli.BoolTFlag{
Name: "bypass-create-block-time-check",
Usage: "This flag is used to bypass the create block time check (by default true)",
}
createBlockMaxTimePercent = cli.Float64Flag{
Name: "create-block-max-time-percent",
Usage: "The max time percent of round duration to create block (by default 25%)",
Value: 0.25,
}
numValidatorsPerShard = cli.IntFlag{
Name: "num-validators-per-shard",
Usage: "This flag is used to specify the number of validators per shard",
Expand Down Expand Up @@ -137,13 +161,21 @@ var (
Name: "fetch-configs-and-close",
Usage: "This flag is used to specify to fetch all configs and close the chain simulator after",
}
enableProfiling = cli.BoolFlag{
Name: "enable-profiling",
Usage: "Boolean option for enabling CPU profiling. If set, CPU profile will be saved to a file.",
}
)

func applyFlags(ctx *cli.Context, cfg *config.Config) {
if ctx.IsSet(roundsPerEpoch.Name) {
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 +188,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
151 changes: 130 additions & 21 deletions cmd/chainsimulator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ package main
import (
"errors"
"fmt"
"net/http"
"os"
"os/signal"
"runtime/debug"
"runtime/pprof"
"strconv"
"strings"
"syscall"
"time"

"github.com/gin-gonic/gin"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/core/closing"
Expand All @@ -20,14 +23,15 @@ import (
"github.com/multiversx/mx-chain-go/node/chainSimulator/components/api"
logger "github.com/multiversx/mx-chain-logger-go"
"github.com/multiversx/mx-chain-logger-go/file"
"github.com/urfave/cli"

"github.com/multiversx/mx-chain-simulator-go/config"
"github.com/multiversx/mx-chain-simulator-go/pkg/facade"
"github.com/multiversx/mx-chain-simulator-go/pkg/factory"
endpoints "github.com/multiversx/mx-chain-simulator-go/pkg/proxy/api"
"github.com/multiversx/mx-chain-simulator-go/pkg/proxy/configs"
"github.com/multiversx/mx-chain-simulator-go/pkg/proxy/configs/git"
"github.com/multiversx/mx-chain-simulator-go/pkg/proxy/creator"
"github.com/urfave/cli"
)

const timeToAllowProxyToStart = time.Millisecond * 10
Expand Down Expand Up @@ -68,10 +72,15 @@ func main() {
pathToProxyConfigs,
startTime,
roundsPerEpoch,
supernovaRoundsPerEpoch,
numOfShards,
serverPort,
roundDurationInMs,
supernovaRoundDurationInMs,
bypassTransactionsSignature,
bypassBlocksSignature,
createBlockMaxTimePercent,
bypassCreateBlockTimeCheck,
numValidatorsPerShard,
numWaitingValidatorsPerShard,
numValidatorsMeta,
Expand All @@ -84,6 +93,7 @@ func main() {
skipConfigsDownload,
fetchConfigsAndClose,
pathWhereToSaveLogs,
enableProfiling,
}

app.Authors = []cli.Author{
Expand Down Expand Up @@ -136,12 +146,21 @@ func startChainSimulator(ctx *cli.Context) error {
}

bypassTxsSignature := ctx.GlobalBool(bypassTransactionsSignature.Name)
log.Warn("signature", "bypass", bypassTxsSignature)
log.Debug("signature", "bypass", bypassTxsSignature)
bypassBlocksSignature := ctx.GlobalBool(bypassBlocksSignature.Name)
log.Debug("blocks", "bypass", bypassBlocksSignature)
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),
}
createBlockMaxTimePercent := ctx.GlobalFloat64(createBlockMaxTimePercent.Name)
bypassCreateBlockTimeCheck := ctx.GlobalBool(bypassCreateBlockTimeCheck.Name)

numValidatorsShard := ctx.GlobalInt(numValidatorsPerShard.Name)
if numValidatorsShard < 1 {
Expand Down Expand Up @@ -170,23 +189,45 @@ func startChainSimulator(ctx *cli.Context) error {
return err
}

// CPU profiling setup - only if enable-profiling flag is set
var profileFile *os.File
profilingEnabled := ctx.GlobalBool(enableProfiling.Name)
if profilingEnabled {
pathLogsSave := ctx.GlobalString(pathWhereToSaveLogs.Name)
profileFile, err = startCPUProfiling(pathLogsSave, startTimeUnix)
if err != nil {
return fmt.Errorf("%w while starting CPU profiling", err)
}

// Ensure pprof is stopped and file is synced/closed even on early exits
defer func() {
log.Info("stopping CPU profile (defer)")
stopCPUProfiling(profileFile)
}()
}

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,
BypassBlockSignatureCheck: bypassBlocksSignature,
BypassCreateBlockTimeCheck: bypassCreateBlockTimeCheck,
CreateBlockMaxTimePercent: createBlockMaxTimePercent,
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 Expand Up @@ -268,7 +309,28 @@ func startChainSimulator(ctx *cli.Context) error {
return err
}

err = endpointsProc.ExtendProxyServer(proxyInstance.GetHttpServer())
// Create a channel for programmatic shutdown
shutdownChan := make(chan struct{})

// Add a shutdown endpoint before extending the proxy server
httpServer := proxyInstance.GetHttpServer()
ginEngine, ok := httpServer.Handler.(*gin.Engine)
if !ok {
return fmt.Errorf("cannot cast httpServer.Handler to gin.Engine")
}

ginEngine.POST("/simulator/shutdown", func(c *gin.Context) {
log.Info("shutdown requested via HTTP endpoint")
c.JSON(http.StatusOK, gin.H{"message": "shutdown initiated"})

// Trigger shutdown in a goroutine to allow the response to be sent
go func() {
time.Sleep(100 * time.Millisecond)
close(shutdownChan)
}()
})

err = endpointsProc.ExtendProxyServer(httpServer)
if err != nil {
return err
}
Expand All @@ -280,9 +342,19 @@ func startChainSimulator(ctx *cli.Context) error {

interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM)
<-interrupt

log.Info("close")
// Wait for either signal or programmatic shutdown
select {
case sig := <-interrupt:
log.Info("close", "signal", sig)
case <-shutdownChan:
log.Info("close", "trigger", "HTTP shutdown endpoint")
}

// Stop CPU profiling FIRST and flush to disk (only if profiling is enabled)
if profilingEnabled {
stopCPUProfiling(profileFile)
}

generator.Close()

Expand All @@ -297,6 +369,43 @@ func startChainSimulator(ctx *cli.Context) error {
return nil
}

func startCPUProfiling(pathLogsSave string, startTimeUnix int64) (*os.File, error) {
timestampMilisecond := time.Unix(startTimeUnix, 0).UnixNano() / 1000000
cpuProfilePath := fmt.Sprintf("%s/cpu-%d.pprof", pathLogsSave, timestampMilisecond)

profileFile, err := os.Create(cpuProfilePath)
if err != nil {
return nil, fmt.Errorf("could not create CPU profile: %w", err)
}

if err := pprof.StartCPUProfile(profileFile); err != nil {
_ = profileFile.Close()
return nil, fmt.Errorf("could not start CPU profile: %w", err)
}

log.Info("CPU profiling started", "path", cpuProfilePath)
return profileFile, nil
}

func stopCPUProfiling(profileFile *os.File) {
if profileFile == nil {
return
}

log.Info("stopping CPU profile")
pprof.StopCPUProfile()

if err := profileFile.Sync(); err != nil {
log.Error("error syncing CPU profile file", "err", err)
}

if err := profileFile.Close(); err != nil {
log.Error("error closing CPU profile file", "err", err)
} else {
log.Info("CPU profile file closed successfully")
}
}

func initializeLogger(ctx *cli.Context, cfg config.Config) (closing.Closer, error) {
logLevelFlagValue := ctx.GlobalString(logLevel.Name)
err := logger.SetLogLevel(logLevelFlagValue)
Expand All @@ -313,7 +422,7 @@ func initializeLogger(ctx *cli.Context, cfg config.Config) (closing.Closer, erro
fileLogging, err := file.NewFileLogging(file.ArgsFileLogging{
WorkingDir: pathLogsSave,
DefaultLogsPath: cfg.Config.Logs.LogsPath,
LogFilePrefix: cfg.Config.Logs.LogFilePrefix,
LogFilePrefix: cfg.Config.Logs.LogFilePrefix + "-" + strconv.Itoa(cfg.Config.Simulator.ServerPort),
})
if err != nil {
return nil, fmt.Errorf("%w creating a log file", err)
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
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def main():
if status.status != "pending":
sys.exit(f"incorrect status of transaction: expected->pending, received->{status}")

provider.do_post_generic(f"{GENERATE_BLOCKS_URL}/3", {})
status = status = provider.get_transaction_status(tx_hash)
provider.do_post_generic(f"{GENERATE_BLOCKS_URL}/6", {})
status = provider.get_transaction_status(tx_hash)
if status.status != "fail":
sys.exit(f"incorrect status of transaction: expected->fail, received->{status}")

Expand Down
Loading
Loading