Skip to content

Commit

Permalink
Merge pull request #2470 from AleoNet/revert-revert-canary-network-trait
Browse files Browse the repository at this point in the history
Re-introduce Canary network trait
  • Loading branch information
zosorock authored May 29, 2024
2 parents 393b8fb + 788fac2 commit 57b16db
Show file tree
Hide file tree
Showing 48 changed files with 1,845 additions and 4 deletions.
409 changes: 409 additions & 0 deletions circuit/environment/src/canary_circuit.rs

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion circuit/environment/src/helpers/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::{Circuit, LinearCombination, TestnetCircuit, Variable, R1CS};
use crate::{CanaryCircuit, Circuit, LinearCombination, TestnetCircuit, Variable, R1CS};
use snarkvm_curves::edwards_bls12::Fq;
use snarkvm_fields::PrimeField;

Expand Down Expand Up @@ -44,6 +44,16 @@ impl snarkvm_algorithms::r1cs::ConstraintSynthesizer<Fq> for TestnetCircuit {
}
}

impl snarkvm_algorithms::r1cs::ConstraintSynthesizer<Fq> for CanaryCircuit {
/// Synthesizes the constraints from the environment into a `snarkvm_algorithms::r1cs`-compliant constraint system.
fn generate_constraints<CS: snarkvm_algorithms::r1cs::ConstraintSystem<Fq>>(
&self,
cs: &mut CS,
) -> Result<(), snarkvm_algorithms::r1cs::SynthesisError> {
crate::canary_circuit::CANARY_CIRCUIT.with(|circuit| circuit.borrow().generate_constraints(cs))
}
}

impl<F: PrimeField> R1CS<F> {
/// Synthesizes the constraints from the environment into a `snarkvm_algorithms::r1cs`-compliant constraint system.
fn generate_constraints<CS: snarkvm_algorithms::r1cs::ConstraintSystem<F>>(
Expand Down
3 changes: 3 additions & 0 deletions circuit/environment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ extern crate snarkvm_circuit_environment_witness;

pub use snarkvm_circuit_environment_witness::rename_selfs;

pub mod canary_circuit;
pub use canary_circuit::*;

pub mod circuit;
pub use circuit::*;

Expand Down
Loading

0 comments on commit 57b16db

Please sign in to comment.