Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ subspecifications that the Lean Ethereum protocol relies on.
- `prop` → `proposal`, `conn` → `connection`, `addr` → `address`, `cert` → `certificate`
- `privkey` → `private_key`, `elem` → `element`, `buf` → `buffer`, `dir` → `directory`
- `len` → `length` (inside a name, never the `len()` builtin), `fe` → `field_elements`
- `exc` / `e` → `exception` (in `except X as exc:` clauses, use `exception`; the stdlib
`exc_info` name is still kept verbatim)
- Use the correct domain term, not just any expansion: a validator is referenced by its
INDEX, so `validator_id` → `validator_index` (never `validator_id`).
- KEEP canonical protocol identifiers that genuinely use "ID": `peer_id`, `node_id`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def _make_decode_failure(self) -> dict[str, Any]:
exception_raised: Exception | None = None
try:
decoder(raw)
except Exception as exc:
exception_raised = exc
except Exception as exception:
exception_raised = exception

if exception_raised is None:
raise AssertionError(
Expand Down
4 changes: 2 additions & 2 deletions packages/testing/src/consensus_testing/test_fixtures/ssz.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def _make_decode_failure(self) -> "SSZTest":
exception_raised: Exception | None = None
try:
decoder.decode_bytes(raw)
except Exception as exc:
exception_raised = exc
except Exception as exception:
exception_raised = exception

if exception_raised is None:
raise AssertionError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def make_fixture(self) -> VerifyProofsTest:
# a comparable "expected X got Y" message instead of crashing the filler.
try:
candidate.verify(public_keys, message, slot)
except Exception as exc:
exception_raised = exc
except Exception as exception:
exception_raised = exception

if self.expect_exception is None:
if exception_raised is not None:
Expand Down
4 changes: 2 additions & 2 deletions src/lean_spec/cli/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ def from_cli_args(cls, args: CliArgs) -> NodeBootstrap:
for s in args.aggregate_subnet_ids_raw.split(",")
if s.strip()
)
except ValueError as exc:
except ValueError as exception:
raise CliValidationError(
"--aggregate-subnet-ids expects comma-separated integers, "
f"got {args.aggregate_subnet_ids_raw!r}"
) from exc
) from exception

# Genesis load.
logger.info("Loading genesis from %s", args.genesis_path)
Expand Down
4 changes: 2 additions & 2 deletions src/lean_spec/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def main() -> None:
# Validate cross-field rules and load referenced files.
try:
boot = NodeBootstrap.from_cli_args(args)
except (CliValidationError, FileNotFoundError) as exc:
logger.error("%s", exc)
except (CliValidationError, FileNotFoundError) as exception:
logger.error("%s", exception)
sys.exit(1)

# Run the node under an event loop until shutdown or a fatal error.
Expand Down
4 changes: 2 additions & 2 deletions src/lean_spec/node/api/endpoints/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ async def handle_toggle(request: web.Request) -> web.Response:

try:
payload = await request.json()
except json.JSONDecodeError as exc:
raise web.HTTPBadRequest(reason="Invalid JSON body") from exc
except json.JSONDecodeError as exception:
raise web.HTTPBadRequest(reason="Invalid JSON body") from exception

if not isinstance(payload, dict) or "enabled" not in payload:
raise web.HTTPBadRequest(reason="Missing 'enabled' field in body")
Expand Down
4 changes: 2 additions & 2 deletions src/lean_spec/node/networking/client/event_source/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ async def start_serving(
logger.info("Connecting to bootnode %s", multiaddr)
try:
peer_id = await self.dial(multiaddr)
except Exception as exc:
logger.warning("Failed to connect to bootnode %s: %s", multiaddr, exc)
except Exception as exception:
logger.warning("Failed to connect to bootnode %s: %s", multiaddr, exception)
continue
if peer_id is not None:
logger.info("Connected to bootnode, peer_id=%s", peer_id)
Expand Down
12 changes: 6 additions & 6 deletions src/lean_spec/node/sync/checkpoint_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ async def fetch_finalized_state(url: str, state_class: type[State]) -> State:

return state

except httpx.RequestError as exc:
except httpx.RequestError as exception:
raise CheckpointSyncError(
f"Network error while connecting to {exc.request.url}: {exc}"
) from exc
except httpx.HTTPStatusError as exc:
f"Network error while connecting to {exception.request.url}: {exception}"
) from exception
except httpx.HTTPStatusError as exception:
raise CheckpointSyncError(
f"HTTP error {exc.response.status_code}: {exc.response.text[:200]}"
) from exc
f"HTTP error {exception.response.status_code}: {exception.response.text[:200]}"
) from exception
except Exception as e:
raise CheckpointSyncError(f"Failed to fetch state: {e}") from e

Expand Down
4 changes: 2 additions & 2 deletions src/lean_spec/node/sync/head_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@ async def _process_cached_descendants(
)
processed_count += description_count

except Exception as exc:
except Exception as exception:
# Processing failed. Leave in cache for retry or discard.
# Do not cascade the error; continue with other children.
logger.debug("Failed to process cached descendant: %s", exc)
logger.debug("Failed to process cached descendant: %s", exception)

finally:
self._processing.discard(child_root)
Expand Down
4 changes: 2 additions & 2 deletions src/lean_spec/node/sync/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ def _deconstruct_block_into_store(
else:
# Data unseen locally: nothing to merge, use as-is.
combined = block_single_message_aggregate
except (AggregationError, AssertionError, KeyError, ValueError) as exc:
logger.debug("Post-block re-aggregation failed for %s: %s", data_root, exc)
except (AggregationError, AssertionError, KeyError, ValueError) as exception:
logger.debug("Post-block re-aggregation failed for %s: %s", data_root, exception)
continue

# The combined proof is a superset of every local partial that
Expand Down
26 changes: 16 additions & 10 deletions src/lean_spec/spec/forks/lstar/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def aggregate(
children_bytes or None,
mode=LEAN_ENV,
)
except Exception as exc:
raise AggregationError(str(exc)) from exc
except Exception as exception:
raise AggregationError(str(exception)) from exception

return cls(
participants=participants,
Expand Down Expand Up @@ -267,8 +267,10 @@ def verify(
bytes(self.proof.data),
mode=LEAN_ENV,
)
except Exception as exc:
raise AggregationError(f"single-message aggregate verification failed: {exc}") from exc
except Exception as exception:
raise AggregationError(
f"single-message aggregate verification failed: {exception}"
) from exception

def __hash__(self) -> int:
"""Content-deterministic hash via SSZ encoding."""
Expand Down Expand Up @@ -341,8 +343,8 @@ def aggregate(
LOG_INV_RATE,
mode=LEAN_ENV,
)
except Exception as exc:
raise AggregationError(str(exc)) from exc
except Exception as exception:
raise AggregationError(str(exception)) from exception

return cls(proof=ByteList512KiB(data=multi_message_aggregate_wire))

Expand Down Expand Up @@ -391,8 +393,10 @@ def split_by_message(
LOG_INV_RATE,
mode=LEAN_ENV,
)
except Exception as exc:
raise AggregationError(f"multi-message aggregate split failed: {exc}") from exc
except Exception as exception:
raise AggregationError(
f"multi-message aggregate split failed: {exception}"
) from exception

return SingleMessageAggregate(
participants=participants,
Expand Down Expand Up @@ -446,8 +450,10 @@ def verify(
bytes(self.proof.data),
mode=LEAN_ENV,
)
except Exception as exc:
raise AggregationError(f"multi-message aggregate verification failed: {exc}") from exc
except Exception as exception:
raise AggregationError(
f"multi-message aggregate verification failed: {exception}"
) from exception

def __hash__(self) -> int:
"""Content-deterministic hash via SSZ encoding."""
Expand Down
10 changes: 5 additions & 5 deletions src/lean_spec/spec/forks/lstar/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,8 @@ def verify_signatures(
public_keys_per_message=public_keys_per_message,
messages=message_bindings,
)
except AggregationError as exc:
raise AssertionError(f"Block proof verification failed: {exc}") from exc
except AggregationError as exception:
raise AssertionError(f"Block proof verification failed: {exception}") from exception

return True

Expand Down Expand Up @@ -1175,10 +1175,10 @@ def on_gossip_aggregated_attestation(
message=hash_tree_root(data),
slot=data.slot,
)
except AggregationError as exc:
except AggregationError as exception:
raise AssertionError(
f"Committee aggregation signature verification failed: {exc}"
) from exc
f"Committee aggregation signature verification failed: {exception}"
) from exception

store.latest_new_aggregated_payloads.setdefault(data, set()).add(proof)

Expand Down
4 changes: 2 additions & 2 deletions src/lean_spec/spec/forks/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ def get_fork(self, name: str) -> ForkProtocol:
"""
try:
return self._by_name[name]
except KeyError as exc:
except KeyError as exception:
known = sorted(self._by_name)
raise KeyError(f"Unknown fork: {name!r}. Known: {known}") from exc
raise KeyError(f"Unknown fork: {name!r}. Known: {known}") from exception
Loading