1
1
from __future__ import annotations
2
2
3
3
from abc import ABC , abstractmethod
4
+ from enum import IntEnum
4
5
from pathlib import Path
5
6
from typing import TYPE_CHECKING
6
7
12
13
from chiapos import DiskProver
13
14
14
15
16
+ class PlotVersion (IntEnum ):
17
+ """Enum for plot format versions"""
18
+
19
+ V1 = 1
20
+ V2 = 2
21
+
22
+
15
23
class ProverProtocol (ABC ):
16
24
@abstractmethod
17
25
def get_filename (self ) -> Path :
@@ -34,7 +42,7 @@ def get_compression_level(self) -> uint8:
34
42
"""Returns the compression level"""
35
43
36
44
@abstractmethod
37
- def get_version (self ) -> int :
45
+ def get_version (self ) -> PlotVersion :
38
46
"""Returns the plot version"""
39
47
40
48
@abstractmethod
@@ -64,7 +72,6 @@ class V2Prover(ProverProtocol):
64
72
65
73
def __init__ (self , filename : str ):
66
74
self ._filename = filename
67
- # TODO: todo_v2_plots Implement plot file parsing and validation
68
75
69
76
def get_filename (self ) -> Path :
70
77
return Path (self ._filename )
@@ -74,40 +81,39 @@ def get_filename_str(self) -> str:
74
81
75
82
def get_size (self ) -> uint8 :
76
83
# TODO: todo_v2_plots get k size from plot
77
- return uint8 ( 32 ) # Stub value
84
+ raise NotImplementedError ( "V2 plot format is not yet implemented" )
78
85
79
86
def get_memo (self ) -> bytes :
80
87
# TODO: todo_v2_plots
81
- return b"" # Stub value
88
+ raise NotImplementedError ( "V2 plot format is not yet implemented" )
82
89
83
90
def get_compression_level (self ) -> uint8 :
84
- # TODO: Extract compression level from V2 plot file
85
- return uint8 ( 0 ) # Stub value
91
+ # TODO: todo_v2_plots implement compression level retrieval
92
+ raise NotImplementedError ( "V2 plot format is not yet implemented" )
86
93
87
- def get_version (self ) -> int :
88
- return 2
94
+ def get_version (self ) -> PlotVersion :
95
+ return PlotVersion . V2
89
96
90
97
def __bytes__ (self ) -> bytes :
91
98
# TODO: todo_v2_plots Implement prover serialization for caching
92
- # For now, just serialize the filename as a placeholder
93
- return self ._filename .encode ("utf-8" )
99
+ raise NotImplementedError ("V2 plot format is not yet implemented" )
94
100
95
101
def get_id (self ) -> bytes32 :
96
102
# TODO: Extract plot ID from V2 plot file
97
- return bytes32 ( b"" ) # Stub value
103
+ raise NotImplementedError ( "V2 plot format is not yet implemented" )
98
104
99
- def get_qualities_for_challenge (self , challenge : bytes ) -> list [bytes32 ]:
105
+ def get_qualities_for_challenge (self , _challenge : bytes ) -> list [bytes32 ]:
100
106
# TODO: todo_v2_plots Implement plot quality lookup
101
- return [] # Stub value
107
+ raise NotImplementedError ( "V2 plot format is not yet implemented" )
102
108
103
- def get_full_proof (self , challenge : bytes , index : int , parallel_read : bool = True ) -> bytes :
109
+ def get_full_proof (self , _challenge : bytes , _index : int , _parallel_read : bool = True ) -> bytes :
104
110
# TODO: todo_v2_plots Implement plot proof generation
105
- return b""
111
+ raise NotImplementedError ( "V2 plot format is not yet implemented" )
106
112
107
113
@classmethod
108
- def from_bytes (cls , data : bytes ) -> V2Prover :
109
- filename = data . decode ( "utf-8" )
110
- return cls ( filename )
114
+ def from_bytes (cls , _data : bytes ) -> V2Prover :
115
+ # TODO: todo_v2_plots Implement prover deserialization from cache
116
+ raise NotImplementedError ( "V2 plot format is not yet implemented" )
111
117
112
118
113
119
class V1Prover (ProverProtocol ):
@@ -131,8 +137,8 @@ def get_memo(self) -> bytes:
131
137
def get_compression_level (self ) -> uint8 :
132
138
return uint8 (self ._disk_prover .get_compression_level ())
133
139
134
- def get_version (self ) -> int :
135
- return 1
140
+ def get_version (self ) -> PlotVersion :
141
+ return PlotVersion . V1
136
142
137
143
def __bytes__ (self ) -> bytes :
138
144
return bytes (self ._disk_prover )
0 commit comments