[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FJ129W93VHJQRRY6Y2MDC0":3,"skill-same:01M6FJ129W93VHJQRRY6Y2MDC0":48},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":21,"linkOnly":22,"markdownContent":23,"markdownBody":23,"frontMatter":24,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M6FJ129W93VHJQRRY6Y2MDC0","subsystem-summary-of-simulation",null,"ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fstellar\u002Fstellar-core\u002Fsubsystem-summary-of-simulation\u002FSKILL.md",[],[18,19,20],"simulation","summary","subsystem summary of simulation","2026-11-10 10:12:30",false,"# Simulation Subsystem — Technical Summary\n\n## Overview\n\nThe simulation subsystem provides infrastructure for creating multi-node network simulations and generating synthetic transaction load for testing and benchmarking stellar-core. It has four major components: (1) `Simulation` — orchestrates multiple `Application` instances as virtual or TCP-connected nodes, (2) `Topologies` — factory functions producing pre-configured network shapes, (3) `LoadGenerator` — drives sustained transaction submission at configurable rates, and (4) `ApplyLoad` — a closed-loop benchmarking harness that bypasses the overlay to measure raw ledger-close performance. A shared `TxGenerator` class constructs all transaction types (classic payments, Soroban uploads, invocations, SAC transfers, upgrades).\n\n## Key Files\n\n- **Simulation.h \u002F Simulation.cpp** — `Simulation` class; manages nodes, clocks, loopback\u002FTCP connections, and event-loop cranking.\n- **Topologies.h \u002F Topologies.cpp** — Static factory methods producing `Simulation` instances with specific network topologies.\n- **LoadGenerator.h \u002F LoadGenerator.cpp** — `LoadGenerator` class; timer-driven load submission loop, account management, metrics, completion tracking.\n- **TxGenerator.h \u002F TxGenerator.cpp** — `TxGenerator` class; creates all transaction types (payments, Soroban upload\u002Finvoke\u002Fupgrade, SAC, batch transfer).\n- **ApplyLoad.h \u002F ApplyLoad.cpp** — `ApplyLoad` class; offline benchmarking: sets up contracts, populates bucket list, runs ledger-close iterations, binary-searches for maximum throughput.\n\n---\n\n## Key Classes and Data Structures\n\n### `Simulation`\n\nOrchestrates a multi-node stellar-core network within a single process. Used extensively in integration and consensus tests.\n\n**Enums:**\n- `Mode` — `OVER_LOOPBACK` (in-process, virtual clocks) or `OVER_TCP` (real sockets, real clocks).\n\n**Type aliases:**\n- `ConfigGen` — `std::function\u003CConfig(int)>`, generates per-node configs.\n- `QuorumSetAdjuster` — `std::function\u003CSCPQuorumSet(SCPQuorumSet const&)>`, post-processes quorum sets.\n- `QuorumSetSpec` — `std::variant\u003CSCPQuorumSet, std::vector\u003CValidatorEntry>>`, allows explicit or auto-generated quorum sets.\n\n**Key members:**\n- `mNodes` (`std::map\u003CNodeID, Node>`) — Maps node public keys to `Node` structs. Each `Node` owns a `VirtualClock` and an `Application::pointer`.\n- `mPendingConnections` (`std::vector\u003Cstd::pair\u003CNodeID, NodeID>>`) — Connections queued before `startAllNodes()`.\n- `mLoopbackConnections` (`std::vector\u003Cstd::shared_ptr\u003CLoopbackPeerConnection>>`) — Active in-process connections (loopback mode only).\n- `mClock` (`VirtualClock`) — The simulation-level master clock.\n- `mIdleApp` (`Application::pointer`) — A \"background\" application used for the master clock's IO context and timers.\n- `mPeerMap` (`std::unordered_map\u003Cunsigned short, std::weak_ptr\u003CApplication>>`) — Maps `PEER_PORT` to application; enables `LoopbackOverlayManager` to resolve connection targets.\n- `mConfigGen` — Optional config generator; defaults to `getTestConfig()`.\n- `mQuorumSetAdjuster` — Optional quorum-set postprocessor.\n- `mSetupForSorobanUpgrade` (`bool`) — Flag indicating Soroban upgrade readiness.\n\n**Key functions:**\n- `addNode(SecretKey, QuorumSetSpec, Config*, bool)` — Creates a new `Application` on its own `VirtualClock`, registers it in `mNodes` and `mPeerMap`. Supports both explicit `SCPQuorumSet` and auto-generated quorum from `ValidatorEntry` vectors.\n- `addPendingConnection(NodeID, NodeID)` — Queues a connection to be established when `startAllNodes()` runs.\n- `fullyConnectAllPending()` — Adds pending connections between all pairs of nodes (mesh).\n- `startAllNodes()` — Calls `app->start()` on each node, then establishes all pending connections.\n- `stopAllNodes()` — Gracefully stops all nodes and cranks until clocks stop.\n- `removeNode(NodeID)` — Gracefully stops a node, drops all its connections, removes from maps.\n- `crankNode(NodeID, time_point)` — Drives one node's clock forward by up to one `quantum` (100 ms) in virtual mode, or just catches up in real-time mode. Also updates the node's survey manager.\n- `crankAllNodes(int nbTicks)` — Advances the entire simulation by `nbTicks` meaningful events. Iterates all node clocks until they catch up to the master clock, then cranks the master clock.\n- `crankForAtMost \u002F crankForAtLeast \u002F crankUntil` — Convenience wrappers that crank the simulation until a time limit or predicate is met.\n- `haveAllExternalized(uint32, uint32, bool)` — Returns true if all (or validator-only) nodes have externalized at least ledger `num`. Throws if spread exceeds `maxSpread`.\n- `addConnection \u002F dropConnection` — Immediately create\u002Fdrop a loopback or TCP connection.\n- `metricsSummary(string)` — Dumps all metrics (or a domain) from the first node using a custom `ConsoleReporterWithSum`.\n\n### `Simulation::Node` (inner struct)\n\n- `mClock` (`shared_ptr\u003CVirtualClock>`) — Per-node clock.\n- `mApp` (`Application::pointer`) — The node's application. Destructor ensures app is destroyed before its clock.\n\n### `LoopbackOverlayManager` (extends `OverlayManagerImpl`)\n\nOverrides `connectToImpl` to resolve the target from `Simulation::mPeerMap` and create a `LoopbackPeer` pair instead of opening a TCP socket.\n\n### `ApplicationLoopbackOverlay` (extends `TestApplication`)\n\nA test application variant that creates `LoopbackOverlayManager` as its overlay and holds a back-reference to the owning `Simulation`.\n\n---\n\n### `Topologies`\n\nA static utility class with factory methods that create fully configured `Simulation` instances with common network shapes. All methods accept optional `ConfigGen` and `QuorumSetAdjuster`.\n\n**Factory methods:**\n- `pair(mode, networkID)` — Two mutually-trusting validators, one connection.\n- `cycle4(networkID)` — Four nodes in a cyclic quorum (loopback only), with cross-connections.\n- `core(nNodes, threshold, mode, networkID)` — Fully-connected mesh of `nNodes` with shared quorum set.\n- `cycle(nNodes, threshold, mode, networkID)` — Same quorum as `core`, but connections form a one-way ring.\n- `branchedcycle(nNodes, ...)` — Ring plus antipodal shortcuts.\n- `separate(nNodes, threshold, mode, networkID, numWatchers)` — Shared quorum, no connections (callers add connections). Optionally includes watcher nodes.\n- `separateAllHighQuality(nNodes, mode, networkID, confGen)` — Uses automatic quorum generation with all nodes marked `VALIDATOR_HIGH_QUALITY`.\n- `hierarchicalQuorum(nBranches, ...)` — 4-node core plus mid-tier branches, connected round-robin.\n- `hierarchicalQuorumSimplified(coreSize, nbOuterNodes, ...)` — Core plus outer nodes that trust core + self.\n- `customA(mode, networkID)` — 7-node topology (A–S) for resilience tests; node I is dead.\n- `asymmetric(mode, networkID)` — 10-node `core` topology plus 4 extra nodes on one validator for asymmetry tests.\n\n---\n\n### `LoadGenMode` (enum)\n\nDefines the type of load the `LoadGenerator` produces:\n- `PAY` — Classic native payment transactions.\n- `SOROBAN_UPLOAD` — Upload random Wasm blobs (overlay\u002Fherder testing).\n- `SOROBAN_INVOKE_SETUP` — Deploy contracts for subsequent `SOROBAN_INVOKE`.\n- `SOROBAN_INVOKE` — Invoke resource-intensive Soroban contracts.\n- `SOROBAN_UPGRADE_SETUP` — Deploy the config-upgrade contract instance.\n- `SOROBAN_CREATE_UPGRADE` — Submit a single config upgrade transaction.\n- `MIXED_CLASSIC_SOROBAN` — Weighted blend of `PAY`, `SOROBAN_UPLOAD`, and `SOROBAN_INVOKE`.\n- `PAY_PREGENERATED` — Read pre-serialized payment transactions from an XDR file.\n- `SOROBAN_INVOKE_APPLY_LOAD` — Generate invoke transactions matching `ApplyLoad`'s V2 transaction shape.\n\n### `GeneratedLoadConfig`\n\nValue struct parameterizing a load-generation run.\n\n**Key fields:**\n- `mode` (`LoadGenMode`) — What type of transactions to generate.\n- `nAccounts`, `offset`, `nTxs`, `txRate` — Account pool size, starting offset, total transactions, target tx\u002Fs.\n- `spikeInterval`, `spikeSize` — Periodic traffic spikes.\n- `maxGeneratedFeeRate` — When set, randomize fee rates up to this value.\n- `skipLowFeeTxs` — If true, skip transactions rejected for low fee instead of failing.\n- `preloadedTransactionsFile` — Path for `PAY_PREGENERATED` mode.\n\n**Inner structs:**\n- `SorobanConfig` — `nInstances`, `nWasms` counts for Soroban setup modes.\n- `MixClassicSorobanConfig` — `payWeight`, `sorobanUploadWeight`, `sorobanInvokeWeight` for `MIXED_CLASSIC_SOROBAN`.\n\n**Key methods:**\n- `isDone()`, `areTxsRemaining()`, `isLoad()`, `isSoroban()`, `isSorobanSetup()` — State predicates.\n- `modeInvokes()`, `modeSetsUpInvoke()`, `modeUploads()` — Check what sub-modes the current mode encompasses.\n- `getStatus()` — Returns a JSON summary of the run.\n- `copySorobanNetworkConfigToUpgradeConfig(base, updated)` — Copies diffs from Soroban network config into `SorobanUpgradeConfig`.\n- Static factories: `createSorobanInvokeSetupLoad`, `createSorobanUpgradeSetupLoad`, `txLoad`, `pregeneratedTxLoad`.\n\n### `SorobanUpgradeConfig`\n\nLarge struct of `std::optional\u003C>` fields covering every Soroban network configuration parameter (compute, ledger access, bandwidth, state archival, parallel execution, SCP timing). Used by both `LoadGenerator` and `ApplyLoad` to construct on-chain config upgrade transactions.\n\n---\n\n### `LoadGenerator`\n\nDrives transaction submission against a live herder at a configurable rate. Created per-`Application`.\n\n**Key members:**\n- `mTxGenerator` (`TxGenerator`) — Constructs all transaction types.\n- `mApp` (`Application&`) — The application receiving transactions.\n- `mLoadTimer` (`unique_ptr\u003CVirtualTimer>`) — Fires every `STEP_MSECS` (100 ms) to submit a batch of transactions.\n- `mStartTime` — Timestamp when load generation began; used to compute cumulative target count.\n- `mTotalSubmitted` (`int64_t`) — Running count of successfully submitted transactions.\n- `mAccountsInUse` \u002F `mAccountsAvailable` (`unordered_set\u003Cuint64_t>`) — Track source-account availability to avoid submitting transactions with pending source accounts.\n- `mContractInstanceKeys` (`UnorderedSet\u003CLedgerKey>`) — Persists across runs; holds deployed contract instance keys.\n- `mCodeKey` (`optional\u003CLedgerKey>`) — The Wasm code key from `SOROBAN_INVOKE_SETUP`.\n- `mContactOverheadBytes` (`uint64_t`) — Wasm size + overhead, used for resource estimation.\n- `mContractInstances` (`UnorderedMap\u003Cuint64_t, ContractInstance>`) — Maps account IDs to their assigned contract instance (rebuilt each invoke run).\n- `mRoot` (`TestAccountPtr`) — The root\u002Fgenesis account.\n- `mFailed`, `mStarted` (`bool`) — Run state flags.\n\n**Key functions:**\n- `generateLoad(GeneratedLoadConfig)` — Main entry point. Calls `start()` once, then runs the step loop: computes `txPerStep`, iterates creating and submitting transactions via `submitTx()`, decrements `cfg.nTxs`, and schedules the next step via `scheduleLoadGeneration()`.\n- `start(cfg)` — One-time initialization: populates `mAccountsAvailable`, sets up contract instance mapping for invoke modes, opens preloaded transaction file if needed.\n- `scheduleLoadGeneration(cfg)` — Validates configuration, checks protocol version, then schedules `generateLoad` via `mLoadTimer` if the app is synced (otherwise waits 10 s and retries).\n- `submitTx(cfg, generateTx)` — Calls the transaction-generator lambda, submits via `execute()`, retries up to `TX_SUBMIT_MAX_TRIES` on `txBAD_SEQ` by refreshing sequence numbers.\n- `execute(txf, mode, code)` — Submits a transaction to the herder via `recvTransaction()`, records per-mode metrics, broadcasts on success.\n- `getTxPerStep(txRate, spikeInterval, spikeSize)` — Computes total target transactions based on elapsed time and spike schedule, returns the delta since last submission.\n- `cleanupAccounts()` — Moves accounts from `mAccountsInUse` back to `mAccountsAvailable` once no longer pending in the herder.\n- `waitTillComplete(cfg)` — After all transactions are submitted, waits up to `TIMEOUT_NUM_LEDGERS` for account sequence numbers and Soroban state to sync with the database, then marks completion or failure.\n- `checkAccountSynced(app)` — Compares cached account sequence numbers against the database.\n- `checkSorobanStateSynced(app, cfg)` — Verifies contract instance and code keys exist in the ledger.\n- `checkMinimumSorobanSuccess(cfg)` — Checks whether the configured minimum Soroban success percentage was met.\n- `stop()` — Cancels the load timer and resets state.\n- `reset()` — Clears per-run state (accounts, timer, counters) but preserves `mContractInstanceKeys` and `mCodeKey`.\n- `resetSorobanState()` — Clears contract keys and code key (only on setup failures).\n\n**Control flow:**\n1. External caller invokes `generateLoad(cfg)`.\n2. `start()` initializes accounts and contract mappings.\n3. Each 100 ms step: compute target tx count, generate and submit transactions in a loop, decrement remaining count.\n4. When `nTxs` reaches 0, switch to `waitTillComplete()` which polls per-ledger until DB state is consistent.\n5. Mark `mLoadgenComplete` or `mLoadgenFail` and call `reset()`.\n\n**Constants:**\n- `STEP_MSECS = 100` — Step interval.\n- `TX_SUBMIT_MAX_TRIES = 10` — Max retries per transaction.\n- `TIMEOUT_NUM_LEDGERS = 20` — Max ledgers to wait for completion.\n- `MIN_UNIQUE_ACCOUNT_MULTIPLIER = 3` — Ensures enough unique accounts for sustained rate.\n\n---\n\n### `TxGenerator`\n\nConstructs transaction frames for all supported load types. Shared by `LoadGenerator` and `ApplyLoad`.\n\n**Key members:**\n- `mApp` (`Application&`) — Application reference.\n- `mAccounts` (`std::map\u003Cuint64_t, TestAccountPtr>`) — Account cache, keyed by numeric ID.\n- `mMinBalance` (`int64`) — Cached minimum balance for account creation.\n- `mApplySorobanSuccess \u002F mApplySorobanFailure` (`medida::Counter&`) — Track Soroban apply outcomes.\n- `mPrePopulatedArchivedEntries` \u002F `mNextKeyToRestore` — State for simulating hot-archive disk reads in V2 load.\n\n**Key constants:**\n- `ROOT_ACCOUNT_ID = UINT64_MAX` — Sentinel for root account.\n- `SAC_TX_INSTRUCTIONS = 250'000` — Instructions per SAC transfer.\n- `BATCH_TRANSFER_TX_INSTRUCTIONS = 500'000` — Instructions per batch transfer.\n\n**Transaction creation functions:**\n- `paymentTransaction(...)` — Classic XLM payment of 1 stroop between two random accounts.\n- `createUploadWasmTransaction(...)` — Uploads a Wasm blob via `HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM`.\n- `createContractTransaction(...)` — Instantiates a contract from an uploaded Wasm.\n- `createSACTransaction(...)` — Creates a Stellar Asset Contract for a given asset.\n- `sorobanRandomWasmTransaction(...)` — Uploads a random-sized Wasm blob with randomized resources sampled from config distributions.\n- `invokeSorobanLoadTransaction(...)` — V1 invoke: calls `do_work(guestCycles, hostCycles, numEntries, kbPerEntry)` on the loadgen contract. Resources (instructions, IO, tx size) are sampled from configurable distributions.\n- `invokeSorobanLoadTransactionV2(...)` — V2 invoke: calls `do_cpu_only_work(guestCycles, hostCycles, eventCount)` with separate RW entries and archived-entry auto-restore. Used by `ApplyLoad`.\n- `invokeSACPayment(...)` — Invokes SAC `transfer` function between accounts.\n- `invokeBatchTransfer(...)` — Invokes a batch-transfer contract that performs multiple SAC transfers in one transaction.\n- `invokeSorobanCreateUpgradeTransaction(...)` — Writes config upgrade bytes into the upgrade contract.\n- `getConfigUpgradeSetFromLoadConfig(SorobanUpgradeConfig)` — Reads current config settings from the ledger, applies deltas from `SorobanUpgradeConfig`, serializes as `ConfigUpgradeSet`.\n\n**Utility functions:**\n- `findAccount(id, ledgerNum)` — Looks up or creates a `TestAccount` in the cache.\n- `createAccounts(start, count, ledgerNum, initial)` — Creates `createAccount` operations in bulk.\n- `createTransactionFramePtr(from, ops, maxFeeRate, byteCount)` — Wraps operations into a signed `TransactionFrame`, optionally padded to a target byte count.\n- `generateFee(maxGeneratedFeeRate, opsCnt)` — Generates a fee, optionally randomized up to `maxGeneratedFeeRate`.\n- `loadAccount(account)` — Refreshes an account's sequence number from the ledger.\n- `pickAccountPair(...)` — Selects source and random destination accounts for payments.\n- `reset()` — Clears the account cache.\n\n---\n\n### `ApplyLoadMode` (enum)\n\n- `LIMIT_BASED` — Generate load within configured ledger limits, measure close time.\n- `FIND_LIMITS_FOR_MODEL_TX` — Binary-search for max number of a \"model\" transaction that fits in target close time.\n- `MAX_SAC_TPS` — Binary-search for max SAC transfer TPS, ignoring ledger limits.\n\n### `ApplyLoad`\n\nOffline benchmarking harness. Bypasses overlay\u002Fherder flooding; directly closes ledgers with generated transaction sets.\n\n**Key members:**\n- `mApp` (`Application&`), `mMode` (`ApplyLoadMode`), `mRoot` (`TestAccountPtr`).\n- `mTxGenerator` (`TxGenerator`) — Owns its own `TxGenerator` (separate from `LoadGenerator`'s).\n- `mNumAccounts` (`uint32_t`) — Total test accounts, computed from config and mode.\n- `mUpgradeCodeKey`, `mUpgradeInstanceKey` — Keys for the config-upgrade contract.\n- `mLoadCodeKey`, `mLoadInstance` — Keys\u002Finstance for the loadgen contract (V2 invocations).\n- `mSACInstanceXLM` — SAC contract instance for native XLM.\n- `mBatchTransferInstances` (`vector\u003CContractInstance>`) — One batch-transfer contract per parallel cluster.\n- `mDataEntryCount`, `mDataEntrySize` — Dimensions of pre-populated bucket-list data entries.\n- Utilization histograms: `mTxCountUtilization`, `mInstructionUtilization`, `mTxSizeUtilization`, `mDiskReadByteUtilization`, `mWriteByteUtilization`, `mDiskReadEntryUtilization`, `mWriteEntryUtilization`.\n\n**Key functions:**\n- `execute()` — Dispatches to `benchmarkLimits()`, `findMaxSacTps()`, or `findMaxLimitsForModelTransaction()`.\n- `setup()` — Master setup: loads root account, upgrades max tx set size, calls `setupAccounts`, `setupUpgradeContract`, `setupLoadContract`, `setupXLMContract`, optionally `setupBatchTransferContracts` and `setupBucketList`.\n- `setupAccounts()` — Creates `mNumAccounts` test accounts in batches via `closeLedger`.\n- `setupUpgradeContract()` — Uploads the `write_bytes` Wasm, instantiates it; stores keys in `mUpgradeCodeKey` \u002F `mUpgradeInstanceKey`.\n- `setupLoadContract()` — Uploads the `test_wasm_loadgen` Wasm, instantiates it; stores in `mLoadCodeKey` \u002F `mLoadInstance`.\n- `setupXLMContract()` — Creates the native-asset SAC; stores in `mSACInstanceXLM`.\n- `setupBatchTransferContracts()` — Uploads the SAC-transfer contract, creates one instance per cluster, funds each with XLM.\n- `setupBucketList()` — Pre-populates the live and hot-archive bucket lists with synthetic contract data entries over simulated ledgers.\n- `closeLedger(txs, upgrades, recordUtilization)` — Creates a `TxSet` from transactions, optionally records resource utilization metrics, then closes the ledger.\n- `benchmarkLimits()` — Runs `APPLY_LOAD_NUM_LEDGERS` iterations of `benchmarkLimitsIteration`, logs timing and utilization statistics.\n- `benchmarkLimitsIteration()` — Generates classic payments + Soroban V2 invoke transactions up to scaled ledger limits, closes one ledger with utilization recording.\n- `findMaxLimitsForModelTransaction()` — Binary-searches over tx count: for each candidate, calls `updateSettingsForTxCount`, upgrades network config, runs `benchmarkLimitsIteration` several times, checks if mean close time is within `APPLY_LOAD_TARGET_CLOSE_TIME_MS`.\n- `findMaxSacTps()` — Binary-searches over TPS: generates SAC payment transactions, times just the application phase, finds maximum sustainable TPS.\n- `benchmarkSacTps(txsPerLedger)` — Runs `APPLY_LOAD_NUM_LEDGERS` SAC-payment ledgers, returns average close time.\n- `generateSacPayments(txs, count)` — Generates SAC payment or batch-transfer transactions with unique destinations to avoid RW conflicts.\n- `upgradeSettings()` — Applies the LIMIT_BASED upgrade config via `applyConfigUpgrade`.\n- `upgradeSettingsForMaxTPS(txsToGenerate)` — Computes high-limit config for MAX_SAC_TPS mode.\n- `applyConfigUpgrade(config)` — Creates an upgrade transaction, validates it, closes a ledger with the upgrade.\n- `updateSettingsForTxCount(txsPerLedger)` — Computes rounded ledger limits for a given tx count, returns the config and actual max txs.\n- `warmAccountCache()` — Loads all accounts into the BucketListDB cache.\n- `successRate()` — Returns fraction of apply-time successes.\n- `getKeyForArchivedEntry(index)` (static) — Deterministic `LedgerKey` for a pre-populated hot-archive entry.\n- `calculateRequiredHotArchiveEntries(mode, config)` (static) — Estimates total hot-archive entries needed for disk-read simulation.\n\n---\n\n## Key Data Flows\n\n### Simulation Node Lifecycle\n1. `Simulation` constructor creates a master `VirtualClock` and an idle `Application`.\n2. `addNode()` creates a `Node` with its own clock and an `ApplicationLoopbackOverlay` (or `TestApplication` for TCP mode).\n3. `addPendingConnection()` queues connections; `startAllNodes()` starts apps and establishes connections.\n4. `crankAllNodes()` drives the main clock and all node clocks forward in lockstep (virtual mode) or lets them run freely (real-time mode).\n5. Tests call `haveAllExternalized()` to check consensus progress.\n\n### LoadGenerator Transaction Flow\n1. Caller invokes `generateLoad(cfg)` via the HTTP command interface or test code.\n2. `start()` initializes account pools and contract mappings.\n3. Every 100 ms step, `generateLoad` computes the target batch size, creates transactions via mode-specific lambdas calling `TxGenerator`, and submits each via `execute()` → `Herder::recvTransaction()`.\n4. Successful transactions are broadcast to the overlay. Failed transactions (bad seq) trigger account reload and regeneration.\n5. After all transactions are submitted, `waitTillComplete()` polls account\u002FSoroban state consistency across ledger closes.\n\n### ApplyLoad Benchmark Flow\n1. `ApplyLoad` constructor calls `setup()` which creates accounts, deploys contracts, populates bucket lists, and applies config upgrades.\n2. `execute()` dispatches to the selected benchmark mode.\n3. In `LIMIT_BASED` mode: each iteration generates a full ledger of mixed classic + Soroban transactions, calls `closeLedger()`, records utilization.\n4. In `FIND_LIMITS_FOR_MODEL_TX` mode: binary search adjusts ledger limits, runs multiple iterations per candidate, checks mean close time against target.\n5. In `MAX_SAC_TPS` mode: binary search over TPS, generates SAC payments (individual or batched), times the application phase.\n\n---\n\n## Ownership Relationships\n\n- `Simulation` owns `mNodes` (map of `Node` structs), each `Node` owns a `VirtualClock` and `Application`.\n- `Simulation` owns `mLoopbackConnections` (shared pointers to `LoopbackPeerConnection`).\n- `Simulation` owns `mIdleApp` for the master clock's IO context.\n- `LoadGenerator` is owned by `Application` (one per app). It owns a `TxGenerator`, a `VirtualTimer`, and the account\u002Fcontract state.\n- `ApplyLoad` is a standalone object created for benchmarking. It owns its own `TxGenerator` and all contract\u002Faccount state.\n- `TxGenerator` is owned by either `LoadGenerator` or `ApplyLoad`. It owns the account cache (`mAccounts`).\n- `GeneratedLoadConfig` and `SorobanUpgradeConfig` are value types passed by copy through the load-generation pipeline.\n\n## Threading Model\n\n- In `OVER_LOOPBACK` mode all nodes share a single thread; `crankAllNodes()` advances node clocks sequentially.\n- In `OVER_TCP` mode each node has a real-time clock; `crankAllNodes()` spins and sleeps.\n- `LoadGenerator` runs entirely on the main thread, driven by `VirtualTimer` callbacks.\n- `ApplyLoad` runs synchronously on the main thread; it directly closes ledgers without involving the overlay or herder flooding.\n",{},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fstellar\u002Fstellar-core\u002Fsubsystem-summary-of-simulation",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":7,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill subsystem-summary-of-simulation",{"tool":40,"command":41},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill subsystem-summary-of-simulation",{"tool":43,"command":44},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill subsystem-summary-of-simulation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fstellar\u002Fstellar-core\u002Fsubsystem-summary-of-simulation\u002FSKILL.md",true,[],[49,58,67,76,82,88],{"skillNo":50,"name":51,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":21},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[55,56,57],"model","model hierarchy","model hierarchy skill",{"skillNo":59,"name":60,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":21},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[64,65,66],"MCP","zoom","zoom mcp",{"skillNo":68,"name":69,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":21},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[73,74,75,65],"sdk","zoom apps sdk","apps",{"skillNo":77,"name":78,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":21},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[78],{"skillNo":83,"name":84,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":21},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[84],{"skillNo":89,"name":90,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":21},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[90]]