purgatory 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ronan Sandford
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Purgatory
|
|
2
|
+
|
|
3
|
+
A local mempool proxy for Ethereum that intercepts, holds, and controls transaction forwarding to upstream nodes. Perfect for debugging, testing, and understanding mempool behavior.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Purgatory acts as an RPC proxy between your application and an Ethereum node. It intercepts `eth_sendRawTransaction` calls, stores transactions in a local mempool, and gives you full control over when and how they're forwarded to the actual network.
|
|
8
|
+
|
|
9
|
+
### Key Features
|
|
10
|
+
|
|
11
|
+
- **Transaction Interception**: Captures all `eth_sendRawTransaction` calls
|
|
12
|
+
- **Gas Price Filtering**: Set minimum gas price thresholds
|
|
13
|
+
- **Auto-Forward Control**: Toggle automatic forwarding to upstream node
|
|
14
|
+
- **Transaction Replacement**: Configurable replacement bump requirements (like EIP-1559 pools)
|
|
15
|
+
- **Batch Operations**: Include or drop multiple transactions at once
|
|
16
|
+
- **REST API**: Full mempool management via REST endpoints
|
|
17
|
+
- **Web Dashboard**: Visual UI for monitoring and managing transactions
|
|
18
|
+
- **Multi-Platform**: Deploy on Node.js or Cloudflare Workers
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### Prerequisites
|
|
23
|
+
|
|
24
|
+
- Node.js 18+
|
|
25
|
+
- pnpm
|
|
26
|
+
|
|
27
|
+
### Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm i purgatory
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Using it
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
purgatory [options]
|
|
38
|
+
|
|
39
|
+
Options:
|
|
40
|
+
-p, --port <port> Port to listen on (default: 8545)
|
|
41
|
+
--db <sqlite.db> Path to SQLite database file (default: in-memory)
|
|
42
|
+
--rpc-url <url> RPC URL for the upstream Ethereum node
|
|
43
|
+
--reset-db Reset the database on startup
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Architecture
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
|
50
|
+
│ Your DApp │────▶│ Purgatory │────▶│ Ethereum Node │
|
|
51
|
+
│ │ │ (port 8545) │ │ (port 8546) │
|
|
52
|
+
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
|
53
|
+
│
|
|
54
|
+
▼
|
|
55
|
+
┌───────────┐
|
|
56
|
+
│ SQLite │
|
|
57
|
+
│ Storage │
|
|
58
|
+
└───────────┘
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## API Reference
|
|
62
|
+
|
|
63
|
+
### JSON-RPC Endpoint
|
|
64
|
+
|
|
65
|
+
**POST** `/`
|
|
66
|
+
|
|
67
|
+
Standard Ethereum JSON-RPC proxy. All methods are forwarded to the upstream node except for intercepted methods:
|
|
68
|
+
|
|
69
|
+
#### Intercepted Methods
|
|
70
|
+
|
|
71
|
+
- **`eth_sendRawTransaction`**: Transactions are decoded, validated, and stored in the local mempool. Forwarding depends on the `autoForward` setting.
|
|
72
|
+
|
|
73
|
+
- **`eth_getTransactionByHash`**: Returns transactions from local mempool if pending locally, otherwise queries upstream.
|
|
74
|
+
|
|
75
|
+
- **`eth_getTransactionCount`**: Accounts for local pending transactions when `blockTag` is `"pending"`.
|
|
76
|
+
|
|
77
|
+
### REST API
|
|
78
|
+
|
|
79
|
+
#### State Management
|
|
80
|
+
|
|
81
|
+
| Method | Endpoint | Description |
|
|
82
|
+
|--------|----------|-------------|
|
|
83
|
+
| GET | `/api/mempool/state` | Get current mempool state |
|
|
84
|
+
| POST | `/api/mempool/gas-price` | Set minimum gas price |
|
|
85
|
+
| POST | `/api/mempool/auto-forward` | Enable/disable auto-forwarding |
|
|
86
|
+
| POST | `/api/mempool/replacement-mode` | Enable/disable transaction replacement |
|
|
87
|
+
| POST | `/api/mempool/replacement-bump` | Set minimum replacement bump percentage |
|
|
88
|
+
|
|
89
|
+
#### Transaction Queries
|
|
90
|
+
|
|
91
|
+
| Method | Endpoint | Description |
|
|
92
|
+
|--------|----------|-------------|
|
|
93
|
+
| GET | `/api/mempool/stats` | Get mempool statistics |
|
|
94
|
+
| GET | `/api/mempool/pending` | List all pending transactions |
|
|
95
|
+
| GET | `/api/mempool/history` | Get transaction history |
|
|
96
|
+
| GET | `/api/mempool/tx/:hash` | Get specific transaction |
|
|
97
|
+
| GET | `/api/mempool/sender/:address` | Get transactions by sender |
|
|
98
|
+
|
|
99
|
+
#### Transaction Management
|
|
100
|
+
|
|
101
|
+
| Method | Endpoint | Description |
|
|
102
|
+
|--------|----------|-------------|
|
|
103
|
+
| POST | `/api/mempool/include/:hash` | Forward a specific transaction |
|
|
104
|
+
| POST | `/api/mempool/drop/:hash` | Drop a pending transaction |
|
|
105
|
+
| POST | `/api/mempool/include-batch` | Forward multiple transactions |
|
|
106
|
+
| POST | `/api/mempool/drop-batch` | Drop multiple transactions |
|
|
107
|
+
| POST | `/api/mempool/flush` | Forward all pending transactions |
|
|
108
|
+
| DELETE | `/api/mempool/clear` | Clear all pending transactions |
|
|
109
|
+
|
|
110
|
+
#### Health
|
|
111
|
+
|
|
112
|
+
| Method | Endpoint | Description |
|
|
113
|
+
|--------|----------|-------------|
|
|
114
|
+
| GET | `/health` | Health check |
|
|
115
|
+
| GET | `/health/upstream` | Upstream node health check |
|
|
116
|
+
|
|
117
|
+
### Web Dashboard
|
|
118
|
+
|
|
119
|
+
Access the visual dashboard at `/ui` to:
|
|
120
|
+
- View pending, forwarded, and dropped transactions
|
|
121
|
+
- Monitor mempool statistics
|
|
122
|
+
- Control auto-forward and gas price settings
|
|
123
|
+
- Manually include or drop transactions
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
## Development
|
|
127
|
+
|
|
128
|
+
### Running Tests
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Run all tests
|
|
132
|
+
pnpm test
|
|
133
|
+
|
|
134
|
+
# Run server tests
|
|
135
|
+
cd packages/server
|
|
136
|
+
pnpm test
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Development Mode
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Start with hot reload
|
|
143
|
+
pnpm nodejs:dev
|
|
144
|
+
|
|
145
|
+
# Or run the full local setup with Zellij
|
|
146
|
+
pnpm start:nodejs
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Formatting
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
pnpm format # Format all files
|
|
153
|
+
pnpm format:check # Check formatting
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT
|
|
159
|
+
|
|
160
|
+
## Contributing
|
|
161
|
+
|
|
162
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "purgatory",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"ldenv": "^0.3.12",
|
|
21
21
|
"named-logs-context": "^0.1.1",
|
|
22
22
|
"remote-sql-libsql": "^0.0.6",
|
|
23
|
-
"purgatory-core": "0.0.
|
|
23
|
+
"purgatory-core": "0.0.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^22.13.10",
|