halo2_axiom/plonk/
error.rs1use std::error;
2use std::fmt;
3use std::io;
4
5use super::TableColumn;
6use super::{Any, Column};
7
8#[derive(Debug)]
11pub enum Error {
12 Synthesis,
15 InvalidInstances,
17 ConstraintSystemFailure,
19 BoundsFailure,
21 Opening,
23 Transcript(io::Error),
25 NotEnoughRowsAvailable {
27 current_k: u32,
29 },
30 InstanceTooLarge,
32 NotEnoughColumnsForConstants,
37 ColumnNotInPermutation(Column<Any>),
40 TableError(TableError),
42}
43
44impl From<io::Error> for Error {
45 fn from(error: io::Error) -> Self {
46 Error::Transcript(error)
48 }
49}
50
51impl Error {
52 pub(crate) fn not_enough_rows_available(current_k: u32) -> Self {
54 Error::NotEnoughRowsAvailable { current_k }
55 }
56}
57
58impl fmt::Display for Error {
59 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
60 match self {
61 Error::Synthesis => write!(f, "General synthesis error"),
62 Error::InvalidInstances => write!(f, "Provided instances do not match the circuit"),
63 Error::ConstraintSystemFailure => write!(f, "The constraint system is not satisfied"),
64 Error::BoundsFailure => write!(f, "An out-of-bounds index was passed to the backend"),
65 Error::Opening => write!(f, "Multi-opening proof was invalid"),
66 Error::Transcript(e) => write!(f, "Transcript error: {}", e),
67 Error::NotEnoughRowsAvailable { current_k } => write!(
68 f,
69 "k = {} is too small for the given circuit. Try using a larger value of k",
70 current_k,
71 ),
72 Error::InstanceTooLarge => write!(f, "Instance vectors are larger than the circuit"),
73 Error::NotEnoughColumnsForConstants => {
74 write!(
75 f,
76 "Too few fixed columns are enabled for global constants usage"
77 )
78 }
79 Error::ColumnNotInPermutation(column) => write!(
80 f,
81 "Column {:?} must be included in the permutation. Help: try applying `meta.enable_equalty` on the column",
82 column
83 ),
84 Error::TableError(error) => write!(f, "{}", error)
85 }
86 }
87}
88
89impl error::Error for Error {
90 fn source(&self) -> Option<&(dyn error::Error + 'static)> {
91 match self {
92 Error::Transcript(e) => Some(e),
93 _ => None,
94 }
95 }
96}
97
98#[derive(Debug)]
100pub enum TableError {
101 ColumnNotAssigned(TableColumn),
103 UnevenColumnLengths((TableColumn, usize), (TableColumn, usize)),
105 UsedColumn(TableColumn),
107 OverwriteDefault(TableColumn, String, String),
109}
110
111impl fmt::Display for TableError {
112 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
113 match self {
114 TableError::ColumnNotAssigned(col) => {
115 write!(
116 f,
117 "{:?} not fully assigned. Help: assign a value at offset 0.",
118 col
119 )
120 }
121 TableError::UnevenColumnLengths((col, col_len), (table, table_len)) => write!(
122 f,
123 "{:?} has length {} while {:?} has length {}",
124 col, col_len, table, table_len
125 ),
126 TableError::UsedColumn(col) => {
127 write!(f, "{:?} has already been used", col)
128 }
129 TableError::OverwriteDefault(col, default, val) => {
130 write!(
131 f,
132 "Attempted to overwrite default value {} with {} in {:?}",
133 default, val, col
134 )
135 }
136 }
137 }
138}