- 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
Add TPS monitoring tool #2
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
ba0e89c
              088f93a
              9b2793d
              883b6bd
              21c391e
              7175944
              045a33f
              138e027
              3abc506
              2670ddb
              c7e9119
              56eda61
              3238559
              43cd860
              b45cea7
              0a5ce5f
              263e8a1
              5598e1d
              758beb5
              06ba6ee
              afe4a34
              d12b29c
              c49075b
              78f07fe
              4f96afd
              6580385
              c76c1e7
              cac9c25
              263b4c4
              1a2fa00
              ca178f3
              9f6a3e7
              c9e9ff4
              e1336eb
              93f19b9
              773440d
              416caa2
              078789e
              e6008d4
              ac44ebe
              b598a2e
              c11de81
              93ee192
              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 | 
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| node_modules/ | ||
| *.log | ||
| .DS_Store | ||
| tps_stats_*.csv | ||
| package-lock.json | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| # 🚀 TPS-Real: Substrate TPS Measurement Tool | ||
| 
     | 
||
| A tool for measuring real TPS (transactions per second) in Polkadot/Substrate blockchains with QuantumFusion support. | ||
| 
     | 
||
| ## 🎯 Features | ||
| 
     | 
||
| - ✅ **QuantumFusion support** - works with transferAllowDeath and other modern Substrate runtimes | ||
| - ✅ **Correct TPS measurement** - analyzes blocks, not sending speed | ||
| - ✅ **Universal balance transfers** - supports transfer, transferAllowDeath, transferKeepAlive | ||
| - ✅ **Optimized logging** - clean output with essential information only | ||
| - ✅ **Manual nonce management** - supports multiple transactions | ||
| - ✅ **Interactive CLI** - change frequency in real time | ||
| - ✅ **Multiple instances** - distributed load from different accounts | ||
| - ✅ **Real-time monitoring** - separate program for measuring actual TPS | ||
| - ✅ **Data export** - save statistics to CSV | ||
| 
     | 
||
| ## 📦 Installation | ||
| 
     | 
||
| ```bash | ||
| # Clone the repository | ||
| git clone <repository-url> | ||
| cd tps-real | ||
| 
     | 
||
| # Install dependencies | ||
| npm install | ||
| ``` | ||
| 
     | 
||
| ## 🔧 Requirements | ||
| 
     | 
||
| - Node.js >= 16.0.0 | ||
| 
         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. Please add   | 
||
| - Access to Polkadot/Substrate node via WebSocket | ||
| - Accounts with balance for testing | ||
| 
     | 
||
| ## 🚀 Usage | ||
| 
     | 
||
| ### 1. Transaction Sender | ||
| 
     | 
||
| Program for generating load: | ||
| 
     | 
||
| ```bash | ||
| # Interactive mode (transfers to self) | ||
| node src/transaction_sender.js -n ws://localhost:9944 -s "//Alice" | ||
| 
     | 
||
| # Transfers between accounts | ||
| node src/transaction_sender.js -n ws://localhost:9944 -s "//Alice" -r "//Bob" | ||
| 
     | 
||
| # Automatic mode with parameters | ||
| node src/transaction_sender.js \ | ||
| -n ws://localhost:9944 \ | ||
| -s "//Alice" \ | ||
| -r "//Bob" \ | ||
| --rate 10 \ | ||
| --amount 1000000 \ | ||
| --auto | ||
| ``` | ||
| 
     | 
||
| #### Parameters: | ||
| - `-n, --node <url>` - Node URL (required) | ||
| - `-s, --sender <seed>` - Sender seed phrase (required) | ||
| - `-r, --recipient <seed>` - Recipient seed phrase (default = sender) | ||
| - `--rate <number>` - Sending frequency tx/sec (default: 1) | ||
| - `--amount <number>` - Transfer amount (default: 1000000) | ||
| - `--auto` - Automatic mode without interactivity | ||
| 
     | 
||
| #### Interactive commands: | ||
| - `start` - start sending transactions | ||
| - `stop` - stop sending | ||
| - `stats` - show statistics | ||
| - `<number>` - change frequency (example: `5` for 5 tx/sec) | ||
| - `exit` - exit the program | ||
| 
     | 
||
| ### 2. TPS Monitoring | ||
| 
     | 
||
| Program for measuring real TPS: | ||
| 
     | 
||
| ```bash | ||
| # Monitor all transactions | ||
| node src/tps_monitor.js -n ws://localhost:9944 | ||
| 
     | 
||
| # Monitor specific addresses with CSV export | ||
| node src/tps_monitor.js \ | ||
| -n ws://localhost:9944 \ | ||
| -a "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" \ | ||
| -o tps_data.csv | ||
| ``` | ||
| 
     | 
||
| #### Parameters: | ||
| - `-n, --node <url>` - Node URL (required) | ||
| - `-o, --output <file>` - File to save CSV data | ||
| - `-a, --addresses <addresses>` - Tracked addresses (comma-separated) | ||
| 
     | 
||
| ## 🏃♂️ Complete Testing Example | ||
| 
     | 
||
| ### Step 1: Start monitoring | ||
| ```bash | ||
| # Terminal 1 - TPS monitoring | ||
| node src/tps_monitor.js -n ws://localhost:9944 -o results.csv | ||
| ``` | ||
| 
     | 
||
| ### Step 2: Start senders | ||
| ```bash | ||
| # Terminal 2 - Alice sends to herself | ||
| node src/transaction_sender.js -n ws://localhost:9944 -s "//Alice" --rate 5 --auto | ||
| 
     | 
||
| # Terminal 3 - Bob sends to Charlie | ||
| node src/transaction_sender.js -n ws://localhost:9944 -s "//Bob" -r "//Charlie" --rate 3 --auto | ||
| 
     | 
||
| # Terminal 4 - Charlie sends to Alice | ||
| node src/transaction_sender.js -n ws://localhost:9944 -s "//Charlie" -r "//Alice" --rate 2 --auto | ||
| ``` | ||
| 
     | 
||
| ### Step 3: Analyze results | ||
| The monitor will show: | ||
| - Real TPS in the network | ||
| - Number of our vs all transactions | ||
| - Block statistics | ||
| - Data will be saved to `results.csv` | ||
| 
     | 
||
| ## 📊 Result Interpretation | ||
| 
     | 
||
| ### TPS calculation: | ||
| ``` | ||
| TPS = (transactions in block) × 10 blocks/sec | ||
| ``` | ||
| 
     | 
||
| ### Example monitor output: | ||
| ``` | ||
| 🧱 Block #1234 | Total TX: 8 | Our TX: 5 | TPS: 80 (50 ours) | ||
| ``` | ||
| 
     | 
||
| This means: | ||
| - 8 transactions got into the block | ||
| - 5 of them are our test transactions | ||
| - Theoretical maximum: 80 TPS | ||
| - Our contribution: 50 TPS | ||
| 
     | 
||
| ## 🔍 Differences from Original Script | ||
| 
     | 
||
| ### ❌ Errors in original: | ||
| 1. **Wrong transaction type**: `system.remark` → `balances.transfer` | ||
| 2. **Automatic nonce**: led to transaction rejections | ||
| 3. **Measuring sending speed**: instead of real TPS | ||
| 4. **One-time execution**: sending batch and terminating | ||
| 
     | 
||
| ### ✅ Fixes: | ||
| 1. **Balance transfer** - real money transfers | ||
| 2. **Manual nonce** - correct handling of multiple transactions | ||
| 3. **Block reading** - measuring real TPS | ||
| 4. **Continuous operation** - configurable sending frequency | ||
| 5. **Block monitoring** - separate program for analysis | ||
| 
     | 
||
| ## 🛠️ Troubleshooting | ||
| 
     | 
||
| ### Transactions don't go through: | ||
| - Check account balance | ||
| - Verify seed phrases are correct | ||
| - Check node connection | ||
| 
     | 
||
| ### Low TPS: | ||
| - Try reducing sending frequency | ||
| - Run multiple instances with different accounts | ||
| - Check node load | ||
| 
     | 
||
| ### Nonce errors: | ||
| - Restart sender (nonce will be recalculated) | ||
| - Use different accounts for parallel instances | ||
| 
     | 
||
| ## 📈 Gradual Load Increase | ||
| 
     | 
||
| ```bash | ||
| # Start with low load | ||
| node src/transaction_sender.js -n ws://localhost:9944 -s "//Alice" --rate 1 | ||
| 
     | 
||
| # In interactive mode, gradually increase: | ||
| # 1 → 5 → 10 → 20 → 50... | ||
| # Until you find the bottleneck | ||
| ``` | ||
                
       | 
||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "name": "tps-real", | ||
| "version": "1.0.0", | ||
| 
         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. 0.1.0?  | 
||
| "description": "Real TPS measurement tool for Polkadot/Substrate blockchains with QuantumFusion support", | ||
| "type": "module", | ||
| "main": "src/transaction_sender.js", | ||
| "scripts": { | ||
| "sender": "node src/transaction_sender.js", | ||
| "monitor": "node src/tps_monitor.js", | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, | ||
| "dependencies": { | ||
| "@polkadot/api": "^14.2.2", | ||
| "@polkadot/util-crypto": "^13.1.1", | ||
| "commander": "^11.1.0" | ||
| }, | ||
| "keywords": [ | ||
| "polkadot", | ||
| "substrate", | ||
| "quantumfusion", | ||
| "tps", | ||
| "blockchain", | ||
| "performance", | ||
| "measurement" | ||
| ], | ||
| "author": "Your Name", | ||
| "license": "MIT", | ||
| "engines": { | ||
| "node": ">=16.0.0" | ||
| } | ||
| } | ||
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.
Why?