eth-mcp 0.2.0__py3-none-any.whl

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.
@@ -0,0 +1,300 @@
1
+ """Expert guidance system for curated Ethereum interpretations.
2
+
3
+ This module provides curated expert knowledge that goes beyond
4
+ what's explicitly stated in the specs. It captures nuances,
5
+ gotchas, and insights from EF discussions.
6
+
7
+ NOTE: This is a stub that can be populated incrementally.
8
+ The full guidance document (~50 pages) is not currently available.
9
+ """
10
+
11
+ from dataclasses import dataclass
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class GuidanceEntry:
16
+ """A curated guidance entry."""
17
+
18
+ topic: str
19
+ summary: str
20
+ key_points: list[str]
21
+ gotchas: list[str]
22
+ references: list[str]
23
+
24
+
25
+ # Guidance database - populated incrementally
26
+ # Each entry captures nuanced understanding beyond the raw specs
27
+ GUIDANCE_DB: dict[str, GuidanceEntry] = {
28
+ "churn": GuidanceEntry(
29
+ topic="Validator Churn and Queue Mechanics",
30
+ summary="Electra uses Gwei-based churn with SEPARATE pools for activations and exits.",
31
+ key_points=[
32
+ "Electra switched from counting validators to counting Gwei for churn",
33
+ "MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA = 128 ETH (floor for each pool)",
34
+ "MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT = 256 ETH",
35
+ "ACTIVATIONS and EXITS have SEPARATE 256 ETH/epoch caps (not shared!)",
36
+ "Total theoretical throughput: 512 ETH/epoch (256 activation + 256 exit)",
37
+ "Partial withdrawals, full exits (CL and EL-triggered) share the EXIT pool",
38
+ "Consolidations use remaining churn after activation/exit allocation",
39
+ ],
40
+ gotchas=[
41
+ "Spec naming misleading - 'get_activation_exit_churn_limit' sounds shared but separate",
42
+ "Partial withdrawals DO consume from exit churn - they share queue with full exits",
43
+ "The difference is outcome: partial withdrawals skip sweep, validator stays active",
44
+ "A validator with pending partial withdrawals cannot full exit until processed",
45
+ "EL-triggered exits (EIP-7002) and CL voluntary exits use identical queue mechanics",
46
+ "With ~34M ETH staked, both pools capped at 256 ETH (dynamic calc would be ~519 ETH)",
47
+ ],
48
+ references=[
49
+ "specs/electra/beacon-chain.md - process_withdrawal_request",
50
+ "specs/electra/beacon-chain.md - compute_exit_epoch_and_update_churn",
51
+ "specs/electra/beacon-chain.md - get_activation_exit_churn_limit",
52
+ "EIP-7002 - Execution layer triggerable exits",
53
+ ],
54
+ ),
55
+ "slashing": GuidanceEntry(
56
+ topic="Slashing Mechanics",
57
+ summary="Slashing penalties evolved across forks, with Electra adjusting for higher MaxEB.",
58
+ key_points=[
59
+ "Two slashable offenses: proposer double-sign, attester double-vote/surround-vote",
60
+ "Immediate penalty: effective_balance // MIN_SLASHING_PENALTY_QUOTIENT",
61
+ "Proportional penalty: processed later based on total slashed in ~36-day window",
62
+ "Phase0: quotient=128, multiplier=1 (conservative)",
63
+ "Altair: quotient=64, multiplier=2",
64
+ "Bellatrix: quotient=32, multiplier=3 (final security values)",
65
+ "Electra: quotient=4096 (adjusted for MaxEB up to 2048 ETH)",
66
+ ],
67
+ gotchas=[
68
+ "Electra's 1/4096 quotient looks larger but it's a SMALLER initial penalty",
69
+ "This incentivizes consolidation to larger validators (less penalty per ETH)",
70
+ "A 2048 ETH validator at 1/32 would lose 64 ETH immediately - too harsh",
71
+ "At 1/4096, a 2048 ETH validator loses only 0.5 ETH initially",
72
+ "Proportional penalty still punishes correlated slashing events heavily",
73
+ "Withdrawable epoch extended by EPOCHS_PER_SLASHINGS_VECTOR (~36 days)",
74
+ ],
75
+ references=[
76
+ "specs/phase0/beacon-chain.md - slash_validator",
77
+ "specs/electra/beacon-chain.md - MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA",
78
+ ],
79
+ ),
80
+ "maxeb": GuidanceEntry(
81
+ topic="Maximum Effective Balance (MaxEB)",
82
+ summary="Electra increased MaxEB from 32 ETH to 2048 ETH for compounding validators.",
83
+ key_points=[
84
+ "MIN_ACTIVATION_BALANCE = 32 ETH (unchanged)",
85
+ "MAX_EFFECTIVE_BALANCE_ELECTRA = 2048 ETH (for 0x02 credentials)",
86
+ "Validators can consolidate multiple 32 ETH validators into one",
87
+ "Reduces total validator count, improves network efficiency",
88
+ "Compounding credentials (0x02) required for balances > 32 ETH",
89
+ "0x01 credentials remain capped at 32 ETH effective balance",
90
+ ],
91
+ gotchas=[
92
+ "Consolidation consumes from consolidation churn (separate from exit churn)",
93
+ "Source validator exits, target validator receives the balance",
94
+ "Both validators must have same withdrawal credentials",
95
+ "Slashed validators cannot complete pending consolidations",
96
+ ],
97
+ references=[
98
+ "specs/electra/beacon-chain.md - MAX_EFFECTIVE_BALANCE_ELECTRA",
99
+ "specs/electra/beacon-chain.md - process_pending_consolidations",
100
+ "EIP-7251 - Increase MAX_EFFECTIVE_BALANCE",
101
+ ],
102
+ ),
103
+ "withdrawals": GuidanceEntry(
104
+ topic="Withdrawal Mechanics",
105
+ summary="Capella enabled withdrawals; Electra added partial withdrawal requests via EL.",
106
+ key_points=[
107
+ "Automatic withdrawals: sweep processes validators with excess balance",
108
+ "Full withdrawals: exited validators get full balance returned",
109
+ "Partial withdrawals (Electra): request specific amount via EL",
110
+ "EIP-7002: Execution layer can trigger both partial withdrawals and full exits",
111
+ "Withdrawal amount = 0 signals full exit request",
112
+ "Withdrawal amount > 0 signals partial withdrawal request",
113
+ ],
114
+ gotchas=[
115
+ "Partial withdrawal requests consume exit queue churn",
116
+ "They don't go through the normal withdrawal sweep",
117
+ "pending_partial_withdrawals queue is separate from exit queue",
118
+ "But the CHURN is shared - that's the key nuance",
119
+ "MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP = 8 per payload",
120
+ ],
121
+ references=[
122
+ "specs/capella/beacon-chain.md - process_withdrawals",
123
+ "specs/electra/beacon-chain.md - process_withdrawal_request",
124
+ "EIP-7002 - Execution layer triggerable exits",
125
+ ],
126
+ ),
127
+ # ===================
128
+ # MEV / PBS
129
+ # ===================
130
+ "mev": GuidanceEntry(
131
+ topic="MEV (Maximal Extractable Value)",
132
+ summary="Value extracted by reordering, inserting, or censoring transactions in a block.",
133
+ key_points=[
134
+ "MEV sources: DEX arbitrage, liquidations, sandwich attacks, NFT sniping",
135
+ "Pre-merge: miners extracted MEV directly",
136
+ "Post-merge: validators propose blocks, can extract MEV or outsource to builders",
137
+ "MEV-boost: middleware connecting validators to block builders",
138
+ "Flashbots: primary MEV infrastructure provider (relay, builder, protect RPC)",
139
+ "Current MEV flow: Searchers → Builders → Relays → Validators",
140
+ "~90% of Ethereum blocks use MEV-boost as of 2025",
141
+ ],
142
+ gotchas=[
143
+ "MEV is not inherently bad - arbitrage improves market efficiency",
144
+ "Harmful MEV: sandwich attacks extract value from users",
145
+ "Flashbots Protect: RPC that shields users from sandwich attacks",
146
+ "MEV-Share: protocol for sharing MEV profits with users",
147
+ "Relays are trusted - they could theoretically censor or steal",
148
+ "Builder dominance is a centralization concern",
149
+ ],
150
+ references=[
151
+ "flashbots/mev-boost - MEV middleware",
152
+ "flashbots/builder - Block builder reference",
153
+ "ethereum/builder-specs - Builder API",
154
+ "https://writings.flashbots.net/",
155
+ ],
156
+ ),
157
+ "pbs": GuidanceEntry(
158
+ topic="PBS (Proposer-Builder Separation)",
159
+ summary="Protocol separating proposing (validators) from building (specialized actors).",
160
+ key_points=[
161
+ "Current state: out-of-protocol PBS via MEV-boost",
162
+ "Proposer: validator selected to propose a block, chooses highest bid",
163
+ "Builder: specialized actor that constructs blocks, bids for inclusion",
164
+ "Relay: trusted intermediary between builders and proposers",
165
+ "Builder commits to block header, proposer signs without seeing contents",
166
+ "If builder doesn't deliver, proposer can propose empty block (no penalty)",
167
+ "ePBS (enshrined PBS): PBS built into the protocol itself",
168
+ ],
169
+ gotchas=[
170
+ "Current PBS relies on trusted relays - protocol doesn't enforce builder honesty",
171
+ "Relay operators see full block contents - potential for frontrunning",
172
+ "Builder concentration: top 3 builders often build >90% of blocks",
173
+ "ePBS aims to make PBS trustless via protocol-level commitments",
174
+ "Inclusion lists (IL): mechanism for proposers to guarantee certain tx inclusion",
175
+ "ePBS is complex - still being researched and specified",
176
+ ],
177
+ references=[
178
+ "ethereum/builder-specs - Current builder API",
179
+ "specs/_features/eip7732 - ePBS specification",
180
+ "EIP-7732 - Enshrined Proposer-Builder Separation",
181
+ "EIP-7547 - Inclusion lists",
182
+ ],
183
+ ),
184
+ "epbs": GuidanceEntry(
185
+ topic="ePBS (Enshrined Proposer-Builder Separation)",
186
+ summary="Protocol-native PBS removing reliance on trusted relays.",
187
+ key_points=[
188
+ "EIP-7732: Enshrined Proposer-Builder Separation",
189
+ "Removes need for trusted relays",
190
+ "Two-slot mechanism: slot N commits to builder, slot N+1 reveals block",
191
+ "Execution attestations: attest to execution payload validity",
192
+ "Unconditional payment: builder pays proposer even if block invalid",
193
+ "PTC (Payload Timeliness Committee): attests to payload delivery",
194
+ "Expected: post-Fulu fork (2026+)",
195
+ ],
196
+ gotchas=[
197
+ "Increases slot time considerations (two-phase commit)",
198
+ "Complexity: new committee type, new attestation type",
199
+ "Still doesn't solve builder centralization directly",
200
+ "Inclusion lists (IL) complement ePBS for censorship resistance",
201
+ "Execution tickets: alternative design being researched",
202
+ "MEV burn: proposal to burn MEV instead of paying proposers",
203
+ ],
204
+ references=[
205
+ "EIP-7732 - ePBS specification",
206
+ "specs/_features/eip7732 - ePBS beacon chain changes",
207
+ "EIP-7547 - Inclusion lists (related)",
208
+ "https://ethresear.ch/t/unbundling-pbs/",
209
+ ],
210
+ ),
211
+ "mev_boost": GuidanceEntry(
212
+ topic="MEV-Boost Architecture",
213
+ summary="Out-of-protocol PBS implementation connecting validators to block builders.",
214
+ key_points=[
215
+ "Sidecar to consensus client (runs alongside beacon node)",
216
+ "Validator registers with relays at epoch boundaries",
217
+ "At block proposal time, MEV-boost queries registered relays",
218
+ "Relays return bids from builders (block header + bid amount)",
219
+ "MEV-boost selects highest bid, returns to validator",
220
+ "Validator signs blinded block (header only)",
221
+ "Relay reveals full block to network after signature",
222
+ ],
223
+ gotchas=[
224
+ "Validator never sees block contents until after signing",
225
+ "Trust assumption: relay will deliver valid block",
226
+ "If relay fails, validator can fall back to local block building",
227
+ "Multiple relays can be configured for redundancy",
228
+ "Relay selection affects block censorship (some relays OFAC-compliant)",
229
+ "~6 major relays: Flashbots, bloXroute, Ultrasound, Agnostic, Aestus, Titan",
230
+ "min-bid flag: minimum bid to accept from builders (default: 0)",
231
+ ],
232
+ references=[
233
+ "flashbots/mev-boost - Implementation",
234
+ "flashbots/mev-boost-relay - Relay implementation",
235
+ "https://boost.flashbots.net/ - Flashbots relay",
236
+ "https://mevboost.pics/ - MEV-boost statistics",
237
+ ],
238
+ ),
239
+ "flashbots": GuidanceEntry(
240
+ topic="Flashbots Ecosystem",
241
+ summary="Research and development org building MEV infrastructure.",
242
+ key_points=[
243
+ "Founded 2020 to mitigate MEV externalities",
244
+ "MEV-Geth (deprecated): early solution for miners",
245
+ "MEV-Boost: current standard for validators (post-merge)",
246
+ "Flashbots Relay: largest MEV relay by volume",
247
+ "Flashbots Builder: reference block builder implementation",
248
+ "Flashbots Protect: RPC endpoint protecting users from frontrunning",
249
+ "MEV-Share: protocol for MEV redistribution to users",
250
+ "SUAVE: upcoming chain for decentralized block building",
251
+ ],
252
+ gotchas=[
253
+ "Flashbots relay was OFAC-compliant (censored Tornado Cash txs) until 2023",
254
+ "Switched to 'neutral' mode but still debated in community",
255
+ "rbuilder: new Rust builder for better performance",
256
+ "MEV-Share can reduce harmful MEV but adds complexity",
257
+ "SUAVE is a separate chain (not Ethereum L1/L2)",
258
+ "Flashbots is a for-profit company despite open source contributions",
259
+ ],
260
+ references=[
261
+ "flashbots/mev-boost",
262
+ "flashbots/builder",
263
+ "flashbots/mev-boost-relay",
264
+ "flashbots/rbuilder",
265
+ "https://docs.flashbots.net/",
266
+ ],
267
+ ),
268
+ }
269
+
270
+
271
+ def get_expert_guidance(topic: str) -> GuidanceEntry | None:
272
+ """
273
+ Get expert guidance for a topic.
274
+
275
+ Searches for exact match first, then partial matches.
276
+ """
277
+ topic_lower = topic.lower()
278
+
279
+ # Exact match
280
+ if topic_lower in GUIDANCE_DB:
281
+ return GUIDANCE_DB[topic_lower]
282
+
283
+ # Partial match
284
+ for key, entry in GUIDANCE_DB.items():
285
+ if topic_lower in key or key in topic_lower:
286
+ return entry
287
+ if topic_lower in entry.summary.lower():
288
+ return entry
289
+
290
+ return None
291
+
292
+
293
+ def list_guidance_topics() -> list[str]:
294
+ """List all available guidance topics."""
295
+ return list(GUIDANCE_DB.keys())
296
+
297
+
298
+ def add_guidance(entry: GuidanceEntry) -> None:
299
+ """Add a new guidance entry."""
300
+ GUIDANCE_DB[entry.topic.lower()] = entry
@@ -0,0 +1,8 @@
1
+ """Indexing pipeline for Ethereum specs."""
2
+
3
+ from .chunker import chunk_documents
4
+ from .compiler import compile_specs
5
+ from .downloader import download_specs
6
+ from .embedder import embed_and_store
7
+
8
+ __all__ = ["download_specs", "compile_specs", "chunk_documents", "embed_and_store"]