-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #512 from lidofinance/upload-state
feat: State dump CID in tree dump
- Loading branch information
Showing
25 changed files
with
386 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import json | ||
from collections import defaultdict | ||
from dataclasses import asdict, dataclass, field | ||
|
||
from src.modules.csm.state import AttestationsAccumulator | ||
from src.types import EpochNumber, NodeOperatorId | ||
|
||
|
||
class LogJSONEncoder(json.JSONEncoder): | ||
def default(self, o): | ||
if isinstance(o, AttestationsAccumulator): | ||
return asdict(o) | ||
return super().default(o) | ||
|
||
|
||
@dataclass | ||
class ValidatorFrameSummary: | ||
perf: AttestationsAccumulator = field(default_factory=AttestationsAccumulator) | ||
slashed: bool = False | ||
|
||
|
||
@dataclass | ||
class OperatorFrameSummary: | ||
distributed: int = 0 | ||
validators: dict[str, ValidatorFrameSummary] = field(default_factory=lambda: defaultdict(ValidatorFrameSummary)) | ||
stuck: bool = False | ||
|
||
|
||
@dataclass | ||
class FramePerfLog: | ||
"""A log of performance assessed per operator in the given frame""" | ||
|
||
frame: tuple[EpochNumber, EpochNumber] | ||
threshold: float = 0.0 | ||
operators: dict[NodeOperatorId, OperatorFrameSummary] = field( | ||
default_factory=lambda: defaultdict(OperatorFrameSummary) | ||
) | ||
|
||
def encode(self) -> bytes: | ||
return ( | ||
LogJSONEncoder( | ||
indent=None, | ||
separators=(',', ':'), | ||
sort_keys=True, | ||
) | ||
.encode(asdict(self)) | ||
.encode() | ||
) |
Oops, something went wrong.