Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] add crate prefix to type_ids #218

Merged
merged 3 commits into from
Nov 14, 2023
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
3 changes: 2 additions & 1 deletion halo2-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ During `synthesize()`, the advice values of all `Context`s are concatenated into

For parallel witness generation, multiple `Context`s are created for each parallel operation. After parallel witness generation, these `Context`'s are combined to form a single "virtual column" as above. Note that while the witness generation can be multi-threaded, the ordering of the contents in each `Context`, and the order of the `Context`s themselves, must be deterministic.

**Warning:** If you create your own `Context` in a new virtual region not provided by our libraries, you must ensure that the `type_id: &str` of the context is a globally unique identifier for the virtual region, distinct from the other `type_id` strings used to identify other virtual regions. In the future we will introduce a macro to check this uniqueness at compile time.
**Warning:** If you create your own `Context` in a new virtual region not provided by our libraries, you must ensure that the `type_id: &str` of the context is a globally unique identifier for the virtual region, distinct from the other `type_id` strings used to identify other virtual regions. We suggest that you either include your crate name as a prefix in the `type_id` or use [`module_path!`](https://doc.rust-lang.org/std/macro.module_path.html) to generate a prefix.
In the future we will introduce a macro to check this uniqueness at compile time.

### [**AssignedValue**](./src/lib.rs):

Expand Down
6 changes: 3 additions & 3 deletions halo2-base/src/gates/flex_gate/threads/single_phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ impl<F: ScalarField> SinglePhaseCoreManager<F> {
/// A distinct tag for this particular type of virtual manager, which is different for each phase.
pub fn type_of(&self) -> &'static str {
match self.phase {
0 => "SinglePhaseCoreManager: FirstPhase",
1 => "SinglePhaseCoreManager: SecondPhase",
2 => "SinglePhaseCoreManager: ThirdPhase",
0 => "halo2-base:SinglePhaseCoreManager:FirstPhase",
1 => "halo2-base:SinglePhaseCoreManager:SecondPhase",
2 => "halo2-base:SinglePhaseCoreManager:ThirdPhase",
_ => panic!("Unsupported phase"),
}
}
Expand Down
6 changes: 6 additions & 0 deletions halo2-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ pub struct ContextCell {

impl ContextCell {
/// Creates a new [ContextCell] with the given `type_id`, `context_id`, and `offset`.
///
/// **Warning:** If you create your own `Context` in a new virtual region not provided by our libraries, you must ensure that the `type_id: &str` of the context is a globally unique identifier for the virtual region, distinct from the other `type_id` strings used to identify other virtual regions. We suggest that you either include your crate name as a prefix in the `type_id` or use [`module_path!`](https://doc.rust-lang.org/std/macro.module_path.html) to generate a prefix.
/// In the future we will introduce a macro to check this uniqueness at compile time.
pub fn new(type_id: &'static str, context_id: usize, offset: usize) -> Self {
Self { type_id, context_id, offset }
}
Expand Down Expand Up @@ -203,6 +206,9 @@ impl<F: ScalarField> Context<F> {
/// Creates a new [Context] with the given `context_id` and witness generation enabled/disabled by the `witness_gen_only` flag.
/// * `witness_gen_only`: flag to determine whether public key generation or only witness generation is being performed.
/// * `context_id`: identifier to reference advice cells from this [Context] later.
///
/// **Warning:** If you create your own `Context` in a new virtual region not provided by our libraries, you must ensure that the `type_id: &str` of the context is a globally unique identifier for the virtual region, distinct from the other `type_id` strings used to identify other virtual regions. We suggest that you either include your crate name as a prefix in the `type_id` or use [`module_path!`](https://doc.rust-lang.org/std/macro.module_path.html) to generate a prefix.
/// In the future we will introduce a macro to check this uniqueness at compile time.
pub fn new(
witness_gen_only: bool,
phase: usize,
Expand Down
3 changes: 2 additions & 1 deletion halo2-base/src/virtual_region/copy_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ impl<F: Field + Ord> CopyConstraintManager<F> {
}

fn load_external_cell_impl(&mut self, cell: Option<Cell>) -> ContextCell {
let context_cell = ContextCell::new("External Raw Halo2 Cell", 0, self.external_cell_count);
let context_cell =
ContextCell::new("halo2-base:External Raw Halo2 Cell", 0, self.external_cell_count);
self.external_cell_count += 1;
if let Some(cell) = cell {
self.assigned_advices.insert(context_cell, cell);
Expand Down
Loading