Skip to content

Commit 71b4de0

Browse files
authored
Create ARCHITECTURE.md
1 parent b9362c2 commit 71b4de0

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

ARCHITECTURE.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# 🏗️ Architecture – Celo Wallet Activity Simulator
2+
3+
This document explains the **internal design** of the simulator, covering personas, execution flow, and logging.
4+
5+
---
6+
7+
## 🔹 High-Level Overview
8+
9+
```
10+
+-----------------+ +-----------------+ +-----------------+
11+
| Personas DB | ---> | Simulation | ---> | RPC Endpoints |
12+
| (personas.json)| | Loop Engine | | (Celo RPCs) |
13+
+-----------------+ +-----------------+ +-----------------+
14+
| | |
15+
| v |
16+
| +-----------------+ |
17+
| | Tx Generator | |
18+
| +-----------------+ |
19+
| | |
20+
v v v
21+
+-----------------+ +-----------------+ +-----------------+
22+
| Configurable | ---> | Transaction Log | ---> | CSV Export |
23+
| Parameters | | (memory buf) | | (tx_log_*.csv) |
24+
+-----------------+ +-----------------+ +-----------------+
25+
```
26+
27+
---
28+
29+
## 🎭 Personas
30+
31+
Each wallet has a **persona**, stored in `personas.json`.
32+
Personas define:
33+
34+
* **Behavioral biases** (`idleBias`, `pingBias`)
35+
* **Transaction ranges** (`minAmount`, `maxAmount`)
36+
* **Active hours** (UTC windows)
37+
* **Error handling** (`cooldownAfterFail`, `retryBias`)
38+
* **Lifecycle** (`maxNonce`, `failCount`)
39+
40+
This creates **organic, wallet-specific activity patterns**.
41+
42+
---
43+
44+
## 🔄 Execution Loop
45+
46+
The simulator runs in **per-wallet cycles**:
47+
48+
1. **Check active hours**
49+
50+
* Skip if outside `activeHours`.
51+
52+
2. **Apply persona biases**
53+
54+
* Random chance to idle (`idleBias`).
55+
* Random chance to send **0-value tx** (`pingBias`).
56+
57+
3. **Generate transaction**
58+
59+
* Choose recipient from cache.
60+
* Pick amount within `[minAmount, maxAmount]`.
61+
* Add gas checks and random delays.
62+
63+
4. **Send via RPC**
64+
65+
* Rotate through RPC endpoints.
66+
* Retry if failure, respecting cooldown rules.
67+
68+
5. **Log result**
69+
70+
* Save `tx_hash`, gas used, status, fee → CSV.
71+
72+
---
73+
74+
## ⏳ Wait Logic
75+
76+
Instead of a fixed delay, each persona has an **adaptive wait**:
77+
78+
```js
79+
let waitSec = Math.floor(
80+
profile.avgWait * (0.8 + Math.random() * 0.4)
81+
);
82+
```
83+
84+
* Ensures wait time varies **±20% around avgWait**.
85+
* Prevents uniform activity (more natural).
86+
87+
Example:
88+
89+
* `avgWait = 120s` → range: **96–144s**
90+
91+
---
92+
93+
## 📂 File Structure
94+
95+
```
96+
celo-wallet-simulator/
97+
│── index.js # Main loop engine
98+
│── personas.json # Wallet behavior profiles
99+
│── key.txt # Wallet private keys (1 per line)
100+
│── logs/ # Transaction logs (CSV)
101+
│── USAGE.md
102+
│── ARCHITECTURE.md
103+
│── package.json
104+
```
105+
106+
---
107+
108+
## 📝 Logging
109+
110+
Transactions are written to **daily CSV logs**:
111+
112+
* **timestamp** – ISO UTC time
113+
* **wallet** – sender address
114+
* **tx\_hash** – transaction hash
115+
* **nonce** – sender’s nonce
116+
* **gas\_used** – consumed gas
117+
* **gas\_price\_gwei** – gas price in Gwei
118+
* **fee\_celo** – total fee in CELO
119+
* **status** – confirmed, failed, timeout
120+
* **action** – normal, ping
121+
122+
---
123+
124+
## 🚀 Key Features
125+
126+
✅ Persona-driven wallet activity
127+
✅ Natural transaction spacing
128+
✅ Multi-RPC rotation (Celo endpoints)
129+
✅ Configurable via JSON
130+
✅ CSV-based structured logging
131+
132+
---
133+
134+
## ⚠️ Disclaimer
135+
136+
This tool is intended for **development, infra testing, and monitoring use cases** within the Celo ecosystem.
137+
It should **not** be used for spam, abuse, or production financial activity.

0 commit comments

Comments
 (0)