From ada7c8696aecabdb9c7b217ee0fde70f9f9f8fc7 Mon Sep 17 00:00:00 2001 From: John Guibas Date: Wed, 30 Aug 2023 13:02:30 -0700 Subject: [PATCH 01/13] feat: get validator via dynamic index --- plonky2x/src/frontend/eth/beacon/builder.rs | 47 ++++++++++++++----- .../eth/beacon/generators/validator.rs | 30 ++++++++---- 2 files changed, 57 insertions(+), 20 deletions(-) diff --git a/plonky2x/src/frontend/eth/beacon/builder.rs b/plonky2x/src/frontend/eth/beacon/builder.rs index f543183bb..3784ccf58 100644 --- a/plonky2x/src/frontend/eth/beacon/builder.rs +++ b/plonky2x/src/frontend/eth/beacon/builder.rs @@ -6,6 +6,7 @@ use super::vars::{BeaconValidatorVariable, BeaconValidatorsVariable}; use crate::frontend::builder::CircuitBuilder; use crate::frontend::eth::beacon::generators::validators::BeaconValidatorsRootGenerator; use crate::frontend::vars::Bytes32Variable; +use crate::prelude::Variable; impl, const D: usize> CircuitBuilder { /// Get the validators for a given block root. @@ -25,7 +26,24 @@ impl, const D: usize> CircuitBuilder { } } - /// Get a validator from a given index. + /// Get a beacon validator from a given dynamic index. + pub fn get_beacon_validator( + &mut self, + validators: BeaconValidatorsVariable, + index: Variable, + ) -> BeaconValidatorVariable { + let generator = BeaconValidatorGenerator::new( + self, + validators.block_root, + validators.validators_root, + None, + Some(index), + ); + self.add_simple_generator(&generator); + generator.validator + } + + /// Get a validator from a given deterministic index. pub fn get_beacon_validator_from_u64( &mut self, validators: BeaconValidatorsVariable, @@ -35,7 +53,8 @@ impl, const D: usize> CircuitBuilder { self, validators.block_root, validators.validators_root, - index, + Some(index), + None, ); self.add_simple_generator(&generator); generator.validator @@ -46,20 +65,21 @@ impl, const D: usize> CircuitBuilder { pub(crate) mod tests { use std::env; - use itertools::Itertools; + use curta::math::prelude::Field; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::iop::witness::PartialWitness; use plonky2::plonk::config::PoseidonGoldilocksConfig; use crate::frontend::builder::CircuitBuilder; use crate::frontend::vars::Bytes32Variable; + use crate::prelude::Variable; + use crate::utils::bytes32; use crate::utils::eth::beacon::BeaconClient; - use crate::utils::{bytes32, setup_logger}; #[test] #[cfg_attr(feature = "ci", ignore)] fn test_get_validator_generator() { - setup_logger(); + env_logger::init(); dotenv::dotenv().ok(); type F = GoldilocksField; @@ -78,13 +98,16 @@ pub(crate) mod tests { )); let validators = builder.get_beacon_validators(block_root); - let balances = (0..4) - .map(|i| { - let validator = builder.get_beacon_validator_from_u64(validators, i); - validator.effective_balance - }) - .collect_vec(); - println!("balances: {:?}", balances); + (0..1).for_each(|i| { + let validator = builder.get_beacon_validator_from_u64(validators, i); + builder.watch(&validator.effective_balance, "hi"); + }); + + (0..1).for_each(|i| { + let idx = builder.constant::(F::from_canonical_u64(i)); + let validator = builder.get_beacon_validator(validators, idx); + builder.watch(&validator.effective_balance, "hi"); + }); let circuit = builder.build::(); let pw = PartialWitness::new(); diff --git a/plonky2x/src/frontend/eth/beacon/generators/validator.rs b/plonky2x/src/frontend/eth/beacon/generators/validator.rs index 1f62df24d..0e57e76a3 100644 --- a/plonky2x/src/frontend/eth/beacon/generators/validator.rs +++ b/plonky2x/src/frontend/eth/beacon/generators/validator.rs @@ -1,5 +1,6 @@ use core::marker::PhantomData; +use curta::math::prelude::PrimeField64; use plonky2::field::extension::Extendable; use plonky2::hash::hash_types::RichField; use plonky2::iop::generator::{GeneratedValues, SimpleGenerator}; @@ -12,6 +13,7 @@ use tokio::runtime::Runtime; use crate::frontend::builder::CircuitBuilder; use crate::frontend::eth::beacon::vars::BeaconValidatorVariable; use crate::frontend::vars::{Bytes32Variable, CircuitVariable}; +use crate::prelude::Variable; use crate::utils::eth::beacon::BeaconClient; use crate::utils::hex; @@ -20,7 +22,8 @@ pub struct BeaconValidatorGenerator, const D: usize client: BeaconClient, block_root: Bytes32Variable, validators_root: Bytes32Variable, - idx: u64, + deterministic_idx: Option, + dynamic_idx: Option, pub validator: BeaconValidatorVariable, _phantom: PhantomData, } @@ -30,13 +33,15 @@ impl, const D: usize> BeaconValidatorGenerator, block_root: Bytes32Variable, validators_root: Bytes32Variable, - idx: u64, + deterministic_idx: Option, + dynamic_idx: Option, ) -> Self { Self { client: builder.beacon_client.clone().unwrap(), block_root, validators_root, - idx, + deterministic_idx, + dynamic_idx, validator: builder.init::(), _phantom: PhantomData, } @@ -61,10 +66,18 @@ impl, const D: usize> SimpleGenerator let block_root = self.block_root.get(witness); let rt = Runtime::new().expect("failed to create tokio runtime"); let result = rt.block_on(async { - self.client - .get_validator(hex!(block_root), self.idx) - .await - .expect("failed to get validator") + if self.deterministic_idx.is_some() { + self.client + .get_validator(hex!(block_root), self.deterministic_idx.unwrap()) + .await + .expect("failed to get validator") + } else { + let idx = self.dynamic_idx.unwrap().get(witness).as_canonical_u64(); + self.client + .get_validator(hex!(block_root), idx) + .await + .expect("failed to get validator") + } }); self.validator.set(out_buffer, result.validator); } @@ -117,7 +130,8 @@ pub(crate) mod tests { &mut builder, validators.block_root, validators.validators_root, - 0, + Some(0), + None, ); builder.add_simple_generator(&generator); From 79666e0dbade54c1b03b81cd19df0b7c676f2f11 Mon Sep 17 00:00:00 2001 From: John Guibas Date: Wed, 30 Aug 2023 15:41:06 -0700 Subject: [PATCH 02/13] balance support --- plonky2x/src/frontend/eth/beacon/builder.rs | 21 +++ .../frontend/eth/beacon/generators/balance.rs | 143 ++++++++++++++++++ .../src/frontend/eth/beacon/generators/mod.rs | 1 + plonky2x/src/utils/eth/beacon/mod.rs | 32 ++++ 4 files changed, 197 insertions(+) create mode 100644 plonky2x/src/frontend/eth/beacon/generators/balance.rs diff --git a/plonky2x/src/frontend/eth/beacon/builder.rs b/plonky2x/src/frontend/eth/beacon/builder.rs index 3784ccf58..a723ae89e 100644 --- a/plonky2x/src/frontend/eth/beacon/builder.rs +++ b/plonky2x/src/frontend/eth/beacon/builder.rs @@ -1,10 +1,12 @@ use plonky2::field::extension::Extendable; use plonky2::hash::hash_types::RichField; +use super::generators::balance::BeaconValidatorBalanceGenerator; use super::generators::validator::BeaconValidatorGenerator; use super::vars::{BeaconValidatorVariable, BeaconValidatorsVariable}; use crate::frontend::builder::CircuitBuilder; use crate::frontend::eth::beacon::generators::validators::BeaconValidatorsRootGenerator; +use crate::frontend::uint::uint256::U256Variable; use crate::frontend::vars::Bytes32Variable; use crate::prelude::Variable; @@ -59,6 +61,23 @@ impl, const D: usize> CircuitBuilder { self.add_simple_generator(&generator); generator.validator } + + /// Get a validator balance from a given deterministic index. + pub fn get_beacon_validator_balance( + &mut self, + validators: BeaconValidatorsVariable, + index: Variable, + ) -> U256Variable { + let generator = BeaconValidatorBalanceGenerator::new( + self, + validators.block_root, + validators.validators_root, + None, + Some(index), + ); + self.add_simple_generator(&generator); + generator.balance + } } #[cfg(test)] @@ -106,6 +125,8 @@ pub(crate) mod tests { (0..1).for_each(|i| { let idx = builder.constant::(F::from_canonical_u64(i)); let validator = builder.get_beacon_validator(validators, idx); + let balance = builder.get_beacon_validator_balance(validators, idx); + builder.watch(&balance, "balance"); builder.watch(&validator.effective_balance, "hi"); }); diff --git a/plonky2x/src/frontend/eth/beacon/generators/balance.rs b/plonky2x/src/frontend/eth/beacon/generators/balance.rs new file mode 100644 index 000000000..72b81b771 --- /dev/null +++ b/plonky2x/src/frontend/eth/beacon/generators/balance.rs @@ -0,0 +1,143 @@ +use core::marker::PhantomData; + +use curta::math::prelude::PrimeField64; +use plonky2::field::extension::Extendable; +use plonky2::hash::hash_types::RichField; +use plonky2::iop::generator::{GeneratedValues, SimpleGenerator}; +use plonky2::iop::target::Target; +use plonky2::iop::witness::PartitionWitness; +use plonky2::plonk::circuit_data::CommonCircuitData; +use plonky2::util::serialization::{Buffer, IoResult}; +use tokio::runtime::Runtime; + +use crate::frontend::builder::CircuitBuilder; +use crate::frontend::uint::uint256::U256Variable; +use crate::frontend::vars::{Bytes32Variable, CircuitVariable}; +use crate::prelude::Variable; +use crate::utils::eth::beacon::BeaconClient; +use crate::utils::hex; + +#[derive(Debug, Clone)] +pub struct BeaconValidatorBalanceGenerator, const D: usize> { + client: BeaconClient, + block_root: Bytes32Variable, + validators_root: Bytes32Variable, + deterministic_idx: Option, + dynamic_idx: Option, + pub balance: U256Variable, + _phantom: PhantomData, +} + +impl, const D: usize> BeaconValidatorBalanceGenerator { + pub fn new( + builder: &mut CircuitBuilder, + block_root: Bytes32Variable, + validators_root: Bytes32Variable, + deterministic_idx: Option, + dynamic_idx: Option, + ) -> Self { + Self { + client: builder.beacon_client.clone().unwrap(), + block_root, + validators_root, + deterministic_idx, + dynamic_idx, + balance: builder.init::(), + _phantom: PhantomData, + } + } +} + +impl, const D: usize> SimpleGenerator + for BeaconValidatorBalanceGenerator +{ + fn id(&self) -> String { + "BeaconValidatorBalanceGenerator".to_string() + } + + fn dependencies(&self) -> Vec { + let mut targets = Vec::new(); + targets.extend(self.block_root.targets()); + targets.extend(self.validators_root.targets()); + targets + } + + fn run_once(&self, witness: &PartitionWitness, out_buffer: &mut GeneratedValues) { + let block_root = self.block_root.get(witness); + let rt = Runtime::new().expect("failed to create tokio runtime"); + let result = rt.block_on(async { + if self.deterministic_idx.is_some() { + self.client + .get_validator_balance(hex!(block_root), self.deterministic_idx.unwrap()) + .await + .expect("failed to get validator") + } else { + let idx = self.dynamic_idx.unwrap().get(witness).as_canonical_u64(); + self.client + .get_validator_balance(hex!(block_root), idx) + .await + .expect("failed to get validator") + } + }); + self.balance.set(out_buffer, result); + } + + #[allow(unused_variables)] + fn serialize(&self, dst: &mut Vec, common_data: &CommonCircuitData) -> IoResult<()> { + todo!() + } + + #[allow(unused_variables)] + fn deserialize(src: &mut Buffer, common_data: &CommonCircuitData) -> IoResult { + todo!() + } +} + +#[cfg(test)] +pub(crate) mod tests { + use std::env; + + use plonky2::field::goldilocks_field::GoldilocksField; + use plonky2::iop::witness::PartialWitness; + use plonky2::plonk::config::PoseidonGoldilocksConfig; + + use crate::frontend::builder::CircuitBuilder; + use crate::frontend::eth::beacon::generators::validator::BeaconValidatorGenerator; + use crate::frontend::vars::Bytes32Variable; + use crate::utils::bytes32; + use crate::utils::eth::beacon::BeaconClient; + + #[test] + #[cfg_attr(feature = "ci", ignore)] + fn test_get_validator_generator() { + dotenv::dotenv().ok(); + + type F = GoldilocksField; + type C = PoseidonGoldilocksConfig; + const D: usize = 2; + + let consensus_rpc = env::var("CONSENSUS_RPC_URL").unwrap(); + let client = BeaconClient::new(consensus_rpc); + + let mut builder = CircuitBuilder::::new(); + builder.set_beacon_client(client); + + let block_root = builder.constant::(bytes32!( + "0xe6d6e23b8e07e15b98811579e5f6c36a916b749fd7146d009196beeddc4a6670" + )); + let validators = builder.get_beacon_validators(block_root); + let generator = BeaconValidatorGenerator::new( + &mut builder, + validators.block_root, + validators.validators_root, + Some(0), + None, + ); + builder.add_simple_generator(&generator); + + let circuit = builder.build::(); + let pw = PartialWitness::new(); + let proof = circuit.data.prove(pw).unwrap(); + circuit.data.verify(proof).unwrap(); + } +} diff --git a/plonky2x/src/frontend/eth/beacon/generators/mod.rs b/plonky2x/src/frontend/eth/beacon/generators/mod.rs index d1572f916..ab37b73b7 100644 --- a/plonky2x/src/frontend/eth/beacon/generators/mod.rs +++ b/plonky2x/src/frontend/eth/beacon/generators/mod.rs @@ -1,2 +1,3 @@ +pub mod balance; pub mod validator; pub mod validators; diff --git a/plonky2x/src/utils/eth/beacon/mod.rs b/plonky2x/src/utils/eth/beacon/mod.rs index d02c24cf3..9d061b89e 100644 --- a/plonky2x/src/utils/eth/beacon/mod.rs +++ b/plonky2x/src/utils/eth/beacon/mod.rs @@ -1,4 +1,5 @@ use anyhow::Result; +use ethers::types::U256; use num::BigInt; use reqwest::Client; use serde::Deserialize; @@ -55,12 +56,43 @@ pub struct GetBeaconValidatorsRoot { pub description: String, } +#[derive(Debug, Deserialize)] +struct InnerData { + index: String, + balance: String, +} + +#[derive(Debug, Deserialize)] +struct Data { + data: Vec, + execution_optimistic: bool, + finalized: bool, +} + +#[derive(Debug, Deserialize)] +struct Wrapper { + data: Data, +} + impl BeaconClient { /// Creates a new BeaconClient based on a rpc url. pub fn new(rpc_url: String) -> Self { Self { rpc_url } } + pub async fn get_validator_balance(&self, _: String, validator_idx: u64) -> Result { + let endpoint = format!( + "{}/eth/v1/beacon/states/head/validator_balances?id={}", + self.rpc_url, validator_idx + ); + println!("{}", endpoint); + let client = Client::new(); + let response = client.get(endpoint).send().await?; + let response: Wrapper = response.json().await?; + let balance = response.data.data[0].balance.parse::()?; + Ok(U256::from(balance)) + } + /// Gets the validators root based on a beacon_id and the SSZ proof from /// `stateRoot -> validatorsRoot`. pub async fn get_validators_root(&self, beacon_id: String) -> Result { From e79ae732d61cdbe48f176cac59c2596a6cc42091 Mon Sep 17 00:00:00 2001 From: John Guibas Date: Wed, 30 Aug 2023 16:46:30 -0700 Subject: [PATCH 03/13] boom --- plonky2x/src/frontend/eth/beacon/generators/balance.rs | 3 +++ plonky2x/src/frontend/eth/beacon/generators/validator.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/plonky2x/src/frontend/eth/beacon/generators/balance.rs b/plonky2x/src/frontend/eth/beacon/generators/balance.rs index 72b81b771..d35540fab 100644 --- a/plonky2x/src/frontend/eth/beacon/generators/balance.rs +++ b/plonky2x/src/frontend/eth/beacon/generators/balance.rs @@ -59,6 +59,9 @@ impl, const D: usize> SimpleGenerator let mut targets = Vec::new(); targets.extend(self.block_root.targets()); targets.extend(self.validators_root.targets()); + if self.dynamic_idx.is_some() { + targets.extend(self.dynamic_idx.unwrap().targets()); + } targets } diff --git a/plonky2x/src/frontend/eth/beacon/generators/validator.rs b/plonky2x/src/frontend/eth/beacon/generators/validator.rs index 0e57e76a3..2b795cec8 100644 --- a/plonky2x/src/frontend/eth/beacon/generators/validator.rs +++ b/plonky2x/src/frontend/eth/beacon/generators/validator.rs @@ -59,6 +59,9 @@ impl, const D: usize> SimpleGenerator let mut targets = Vec::new(); targets.extend(self.block_root.targets()); targets.extend(self.validators_root.targets()); + if self.dynamic_idx.is_some() { + targets.extend(self.dynamic_idx.unwrap().targets()); + } targets } From 581ecf0751e267494897823d23cb78b011905c75 Mon Sep 17 00:00:00 2001 From: John Guibas Date: Wed, 30 Aug 2023 17:23:32 -0700 Subject: [PATCH 04/13] boom --- .../frontend/eth/beacon/generators/balance.rs | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/plonky2x/src/frontend/eth/beacon/generators/balance.rs b/plonky2x/src/frontend/eth/beacon/generators/balance.rs index d35540fab..c883cc66d 100644 --- a/plonky2x/src/frontend/eth/beacon/generators/balance.rs +++ b/plonky2x/src/frontend/eth/beacon/generators/balance.rs @@ -7,7 +7,7 @@ use plonky2::iop::generator::{GeneratedValues, SimpleGenerator}; use plonky2::iop::target::Target; use plonky2::iop::witness::PartitionWitness; use plonky2::plonk::circuit_data::CommonCircuitData; -use plonky2::util::serialization::{Buffer, IoResult}; +use plonky2::util::serialization::{Buffer, IoResult, Read, Write}; use tokio::runtime::Runtime; use crate::frontend::builder::CircuitBuilder; @@ -87,12 +87,43 @@ impl, const D: usize> SimpleGenerator #[allow(unused_variables)] fn serialize(&self, dst: &mut Vec, common_data: &CommonCircuitData) -> IoResult<()> { - todo!() + dst.write_target_vec(&self.block_root.targets())?; + dst.write_target_vec(&self.validators_root.targets())?; + dst.write_bool(self.deterministic_idx.is_some())?; + if self.deterministic_idx.is_some() { + dst.write_usize(self.deterministic_idx.unwrap() as usize)?; + } else { + dst.write_target_vec(&self.dynamic_idx.unwrap().targets())?; + } + dst.write_target_vec(&self.balance.targets())?; + Ok(()) } #[allow(unused_variables)] fn deserialize(src: &mut Buffer, common_data: &CommonCircuitData) -> IoResult { - todo!() + let block_root = Bytes32Variable::from_targets(&src.read_target_vec()?); + let validators_root = Bytes32Variable::from_targets(&src.read_target_vec()?); + let is_deterministic = src.read_bool()?; + let deterministic_idx = if is_deterministic { + Some(src.read_usize()? as u64) + } else { + None + }; + let dynamic_idx = if is_deterministic { + None + } else { + Some(Variable::from_targets(&src.read_target_vec()?)) + }; + let balance = U256Variable::from_targets(&src.read_target_vec()?); + Ok(Self { + client: BeaconClient::new("https://beaconapi.succinct.xyz".to_string()), + block_root, + validators_root, + deterministic_idx, + dynamic_idx, + balance, + _phantom: PhantomData, + }) } } From 85001cb5ca8134e6857f25c4d9c8a1cc6e656df0 Mon Sep 17 00:00:00 2001 From: John Guibas Date: Wed, 30 Aug 2023 17:29:43 -0700 Subject: [PATCH 05/13] boom --- plonky2x/src/backend/circuit/utils.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plonky2x/src/backend/circuit/utils.rs b/plonky2x/src/backend/circuit/utils.rs index ef986e1a0..a2e68027b 100644 --- a/plonky2x/src/backend/circuit/utils.rs +++ b/plonky2x/src/backend/circuit/utils.rs @@ -28,6 +28,9 @@ use plonky2::plonk::config::{AlgebraicHasher, GenericConfig}; use plonky2::recursion::dummy_circuit::DummyProofGenerator; use plonky2::util::serialization::{Buffer, IoResult, WitnessGeneratorSerializer}; +use crate::frontend::eth::beacon::generators::balance::BeaconValidatorBalanceGenerator; +use crate::frontend::eth::beacon::generators::validator::BeaconValidatorGenerator; +use crate::frontend::eth::beacon::generators::validators::BeaconValidatorsRootGenerator; use crate::frontend::eth::storage::generators::block::EthBlockGenerator; use crate::frontend::eth::storage::generators::storage::{ EthLogGenerator, EthStorageKeyGenerator, EthStorageProofGenerator, @@ -147,6 +150,9 @@ where EthLogGenerator, "EthLogGenerator", EthBlockGenerator, "EthBlockGenerator", EthStorageKeyGenerator, "EthStorageKeyGenerator", - Keccack256Generator, "Keccak256Generator" + Keccack256Generator, "Keccak256Generator", + BeaconValidatorBalanceGenerator, "BeaconValidatorBalanceGenerator", + BeaconValidatorGenerator, "BeaconValidatorGenerator", + BeaconValidatorsRootGenerator, "BeaconValidatorsRootGenerator", } } From 620924e7d7e5f83b4bf979be05013ac8df17ade9 Mon Sep 17 00:00:00 2001 From: John Guibas Date: Wed, 30 Aug 2023 17:50:36 -0700 Subject: [PATCH 06/13] test --- plonky2x/src/backend/circuit/mod.rs | 6 ++++++ plonky2x/src/backend/circuit/utils.rs | 2 +- .../frontend/eth/beacon/generators/validators.rs | 14 +++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/plonky2x/src/backend/circuit/mod.rs b/plonky2x/src/backend/circuit/mod.rs index 730c482e8..da44f0d05 100644 --- a/plonky2x/src/backend/circuit/mod.rs +++ b/plonky2x/src/backend/circuit/mod.rs @@ -122,14 +122,19 @@ where let (gate_serializer, generator_serializer) = Self::serializers(); // Setup buffer. + println!("1"); let mut buffer = Vec::new(); let circuit_bytes = self .data .to_bytes(&gate_serializer, &generator_serializer)?; + println!("2"); buffer.write_usize(circuit_bytes.len())?; + println!("3"); buffer.write_all(&circuit_bytes)?; + println!("4"); if self.io.evm.is_some() { + println!("5"); let io = self.io.evm.as_ref().unwrap(); buffer.write_usize(0)?; buffer.write_target_vec( @@ -148,6 +153,7 @@ where .as_slice(), )?; } else if self.io.field.is_some() { + println!("6"); let io = self.io.field.as_ref().unwrap(); buffer.write_usize(1)?; buffer.write_target_vec( diff --git a/plonky2x/src/backend/circuit/utils.rs b/plonky2x/src/backend/circuit/utils.rs index a2e68027b..f54a334cd 100644 --- a/plonky2x/src/backend/circuit/utils.rs +++ b/plonky2x/src/backend/circuit/utils.rs @@ -153,6 +153,6 @@ where Keccack256Generator, "Keccak256Generator", BeaconValidatorBalanceGenerator, "BeaconValidatorBalanceGenerator", BeaconValidatorGenerator, "BeaconValidatorGenerator", - BeaconValidatorsRootGenerator, "BeaconValidatorsRootGenerator", + BeaconValidatorsRootGenerator, "BeaconValidatorsGenerator", } } diff --git a/plonky2x/src/frontend/eth/beacon/generators/validators.rs b/plonky2x/src/frontend/eth/beacon/generators/validators.rs index 3a9c00d7b..a4846fb16 100644 --- a/plonky2x/src/frontend/eth/beacon/generators/validators.rs +++ b/plonky2x/src/frontend/eth/beacon/generators/validators.rs @@ -6,7 +6,7 @@ use plonky2::iop::generator::{GeneratedValues, SimpleGenerator}; use plonky2::iop::target::Target; use plonky2::iop::witness::PartitionWitness; use plonky2::plonk::circuit_data::CommonCircuitData; -use plonky2::util::serialization::{Buffer, IoResult}; +use plonky2::util::serialization::{Buffer, IoResult, Read, Write}; use tokio::runtime::Runtime; use crate::frontend::builder::CircuitBuilder; @@ -65,12 +65,20 @@ impl, const D: usize> SimpleGenerator #[allow(unused_variables)] fn serialize(&self, dst: &mut Vec, common_data: &CommonCircuitData) -> IoResult<()> { - todo!() + dst.write_target_vec(&self.block_root.targets())?; + dst.write_target_vec(&self.validators_root.targets())?; } #[allow(unused_variables)] fn deserialize(src: &mut Buffer, common_data: &CommonCircuitData) -> IoResult { - todo!() + let block_root = Bytes32Variable::from_targets(&src.read_target_vec()?); + let validators_root = Bytes32Variable::from_targets(&src.read_target_vec()?); + Ok(Self { + client: BeaconClient::new("https://beaconapi.succinct.xyz".to_string()), + block_root, + validators_root, + _phantom: Default::default(), + }) } } From 356f27c1f285af9870bf8c1fb5e9f86b6a64da15 Mon Sep 17 00:00:00 2001 From: John Guibas Date: Wed, 30 Aug 2023 18:15:59 -0700 Subject: [PATCH 07/13] boom --- plonky2x/src/backend/circuit/mod.rs | 1 + plonky2x/src/backend/circuit/utils.rs | 3 ++- plonky2x/src/frontend/builder/watch.rs | 2 +- plonky2x/src/frontend/eth/beacon/generators/validator.rs | 4 ++-- plonky2x/src/frontend/eth/beacon/generators/validators.rs | 1 + 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/plonky2x/src/backend/circuit/mod.rs b/plonky2x/src/backend/circuit/mod.rs index da44f0d05..354dba3b6 100644 --- a/plonky2x/src/backend/circuit/mod.rs +++ b/plonky2x/src/backend/circuit/mod.rs @@ -226,6 +226,7 @@ where } pub fn save(&self, path: &String) { + println!("{:#?}", self.data); let bytes = self.serialize().unwrap(); fs::write(path, bytes).unwrap(); } diff --git a/plonky2x/src/backend/circuit/utils.rs b/plonky2x/src/backend/circuit/utils.rs index f54a334cd..8da94f1ac 100644 --- a/plonky2x/src/backend/circuit/utils.rs +++ b/plonky2x/src/backend/circuit/utils.rs @@ -28,6 +28,7 @@ use plonky2::plonk::config::{AlgebraicHasher, GenericConfig}; use plonky2::recursion::dummy_circuit::DummyProofGenerator; use plonky2::util::serialization::{Buffer, IoResult, WitnessGeneratorSerializer}; +use crate::frontend::builder::watch::WatchGenerator; use crate::frontend::eth::beacon::generators::balance::BeaconValidatorBalanceGenerator; use crate::frontend::eth::beacon::generators::validator::BeaconValidatorGenerator; use crate::frontend::eth::beacon::generators::validators::BeaconValidatorsRootGenerator; @@ -153,6 +154,6 @@ where Keccack256Generator, "Keccak256Generator", BeaconValidatorBalanceGenerator, "BeaconValidatorBalanceGenerator", BeaconValidatorGenerator, "BeaconValidatorGenerator", - BeaconValidatorsRootGenerator, "BeaconValidatorsGenerator", + BeaconValidatorsRootGenerator, "BeaconValidatorsGenerator" } } diff --git a/plonky2x/src/frontend/builder/watch.rs b/plonky2x/src/frontend/builder/watch.rs index 49caef036..62e521c84 100644 --- a/plonky2x/src/frontend/builder/watch.rs +++ b/plonky2x/src/frontend/builder/watch.rs @@ -30,7 +30,7 @@ impl, V: CircuitVariable, const D: usize> SimpleGen for WatchGenerator { fn id(&self) -> String { - todo!() + "WatchGenerator".to_string() } fn dependencies(&self) -> Vec { diff --git a/plonky2x/src/frontend/eth/beacon/generators/validator.rs b/plonky2x/src/frontend/eth/beacon/generators/validator.rs index 2b795cec8..2fe2b753e 100644 --- a/plonky2x/src/frontend/eth/beacon/generators/validator.rs +++ b/plonky2x/src/frontend/eth/beacon/generators/validator.rs @@ -87,12 +87,12 @@ impl, const D: usize> SimpleGenerator #[allow(unused_variables)] fn serialize(&self, dst: &mut Vec, common_data: &CommonCircuitData) -> IoResult<()> { - todo!() + panic!("not implemented") } #[allow(unused_variables)] fn deserialize(src: &mut Buffer, common_data: &CommonCircuitData) -> IoResult { - todo!() + panic!("not implemented") } } diff --git a/plonky2x/src/frontend/eth/beacon/generators/validators.rs b/plonky2x/src/frontend/eth/beacon/generators/validators.rs index a4846fb16..92e50843e 100644 --- a/plonky2x/src/frontend/eth/beacon/generators/validators.rs +++ b/plonky2x/src/frontend/eth/beacon/generators/validators.rs @@ -67,6 +67,7 @@ impl, const D: usize> SimpleGenerator fn serialize(&self, dst: &mut Vec, common_data: &CommonCircuitData) -> IoResult<()> { dst.write_target_vec(&self.block_root.targets())?; dst.write_target_vec(&self.validators_root.targets())?; + Ok(()) } #[allow(unused_variables)] From 48d3e293d4893080465bfcf1d5a31f7cb424ea6b Mon Sep 17 00:00:00 2001 From: John Guibas Date: Wed, 30 Aug 2023 18:40:03 -0700 Subject: [PATCH 08/13] tesT --- plonky2x/src/backend/circuit/mod.rs | 1 - plonky2x/src/backend/circuit/utils.rs | 65 ++++++++++++++++++++------- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/plonky2x/src/backend/circuit/mod.rs b/plonky2x/src/backend/circuit/mod.rs index 354dba3b6..da44f0d05 100644 --- a/plonky2x/src/backend/circuit/mod.rs +++ b/plonky2x/src/backend/circuit/mod.rs @@ -226,7 +226,6 @@ where } pub fn save(&self, path: &String) { - println!("{:#?}", self.data); let bytes = self.serialize().unwrap(); fs::write(path, bytes).unwrap(); } diff --git a/plonky2x/src/backend/circuit/utils.rs b/plonky2x/src/backend/circuit/utils.rs index 8da94f1ac..123135b2c 100644 --- a/plonky2x/src/backend/circuit/utils.rs +++ b/plonky2x/src/backend/circuit/utils.rs @@ -6,19 +6,24 @@ use plonky2::gadgets::arithmetic_extension::QuotientGeneratorExtension; use plonky2::gadgets::range_check::LowHighGenerator; use plonky2::gadgets::split_base::BaseSumGenerator; use plonky2::gadgets::split_join::{SplitGenerator, WireSplitGenerator}; -use plonky2::gates::arithmetic_base::ArithmeticBaseGenerator; -use plonky2::gates::arithmetic_extension::ArithmeticExtensionGenerator; -use plonky2::gates::base_sum::BaseSplitGenerator; -use plonky2::gates::coset_interpolation::InterpolationGenerator; -use plonky2::gates::exponentiation::ExponentiationGenerator; -use plonky2::gates::lookup::LookupGenerator; -use plonky2::gates::lookup_table::LookupTableGenerator; -use plonky2::gates::multiplication_extension::MulExtensionGenerator; -use plonky2::gates::poseidon::PoseidonGenerator; -use plonky2::gates::poseidon_mds::PoseidonMdsGenerator; -use plonky2::gates::random_access::RandomAccessGenerator; -use plonky2::gates::reducing::ReducingGenerator; -use plonky2::gates::reducing_extension::ReducingGenerator as ReducingExtensionGenerator; +use plonky2::gates::arithmetic_base::{ArithmeticBaseGenerator, ArithmeticGate}; +use plonky2::gates::arithmetic_extension::{ArithmeticExtensionGate, ArithmeticExtensionGenerator}; +use plonky2::gates::base_sum::{BaseSplitGenerator, BaseSumGate}; +use plonky2::gates::constant::ConstantGate; +use plonky2::gates::coset_interpolation::{CosetInterpolationGate, InterpolationGenerator}; +use plonky2::gates::exponentiation::{ExponentiationGate, ExponentiationGenerator}; +use plonky2::gates::lookup::{LookupGate, LookupGenerator}; +use plonky2::gates::lookup_table::{LookupTableGate, LookupTableGenerator}; +use plonky2::gates::multiplication_extension::{MulExtensionGate, MulExtensionGenerator}; +use plonky2::gates::noop::NoopGate; +use plonky2::gates::poseidon::{PoseidonGate, PoseidonGenerator}; +use plonky2::gates::poseidon_mds::{PoseidonMdsGate, PoseidonMdsGenerator}; +use plonky2::gates::public_input::PublicInputGate; +use plonky2::gates::random_access::{RandomAccessGate, RandomAccessGenerator}; +use plonky2::gates::reducing::{ReducingGate, ReducingGenerator}; +use plonky2::gates::reducing_extension::{ + ReducingExtensionGate, ReducingGenerator as ReducingExtensionGenerator, +}; use plonky2::hash::hash_types::RichField; use plonky2::iop::generator::{ ConstantGenerator, CopyGenerator, NonzeroTestGenerator, RandomValueGenerator, @@ -26,7 +31,8 @@ use plonky2::iop::generator::{ use plonky2::plonk::circuit_data::CommonCircuitData; use plonky2::plonk::config::{AlgebraicHasher, GenericConfig}; use plonky2::recursion::dummy_circuit::DummyProofGenerator; -use plonky2::util::serialization::{Buffer, IoResult, WitnessGeneratorSerializer}; +use plonky2::util::serialization::{Buffer, GateSerializer, IoResult, WitnessGeneratorSerializer}; +use plonky2::{get_gate_tag_impl, impl_gate_serializer, read_gate_impl}; use crate::frontend::builder::watch::WatchGenerator; use crate::frontend::eth::beacon::generators::balance::BeaconValidatorBalanceGenerator; @@ -37,6 +43,7 @@ use crate::frontend::eth::storage::generators::storage::{ EthLogGenerator, EthStorageKeyGenerator, EthStorageProofGenerator, }; use crate::frontend::hash::keccak::keccak256::Keccack256Generator; +use crate::frontend::num::u32::gates::add_many_u32::{U32AddManyGate, U32AddManyGenerator}; #[macro_export] macro_rules! impl_generator_serializer { @@ -46,6 +53,7 @@ macro_rules! impl_generator_serializer { buf: &mut Buffer, common_data: &CommonCircuitData, ) -> IoResult> { + println!("read generator"); let tag = plonky2::util::serialization::Read::read_u32(buf)?; read_generator_impl! { buf, @@ -61,6 +69,7 @@ macro_rules! impl_generator_serializer { generator: &plonky2::iop::generator::WitnessGeneratorRef, common_data: &CommonCircuitData, ) -> IoResult<()> { + println!("write generator"); let tag = get_generator_tag_impl! { generator, $( $generator, $name ),* @@ -154,6 +163,32 @@ where Keccack256Generator, "Keccak256Generator", BeaconValidatorBalanceGenerator, "BeaconValidatorBalanceGenerator", BeaconValidatorGenerator, "BeaconValidatorGenerator", - BeaconValidatorsRootGenerator, "BeaconValidatorsGenerator" + BeaconValidatorsRootGenerator, "BeaconValidatorsGenerator", + U32AddManyGenerator, "U32AddManyGenerator", + } +} + +pub struct CustomGateSerializer; + +impl, const D: usize> GateSerializer for CustomGateSerializer { + impl_gate_serializer! { + DefaultGateSerializer, + ArithmeticGate, + ArithmeticExtensionGate, + BaseSumGate<2>, + ConstantGate, + CosetInterpolationGate, + ExponentiationGate, + LookupGate, + LookupTableGate, + MulExtensionGate, + NoopGate, + PoseidonMdsGate, + PoseidonGate, + PublicInputGate, + RandomAccessGate, + ReducingExtensionGate, + ReducingGate, + U32AddManyGate } } From 08c3e31988622df08290cfe031580c8e524269b8 Mon Sep 17 00:00:00 2001 From: John Guibas Date: Wed, 30 Aug 2023 23:10:48 -0700 Subject: [PATCH 09/13] fixes --- plonky2x/src/backend/circuit/mod.rs | 14 ++++---------- plonky2x/src/backend/circuit/utils.rs | 12 ++++-------- plonky2x/src/frontend/hash/keccak/keccak256.rs | 7 +++---- plonky2x/src/frontend/hash/keccak/mod.rs | 4 ++-- plonky2x/src/utils/eth/beacon/mod.rs | 1 - 5 files changed, 13 insertions(+), 25 deletions(-) diff --git a/plonky2x/src/backend/circuit/mod.rs b/plonky2x/src/backend/circuit/mod.rs index da44f0d05..3468d577b 100644 --- a/plonky2x/src/backend/circuit/mod.rs +++ b/plonky2x/src/backend/circuit/mod.rs @@ -11,10 +11,10 @@ use plonky2::iop::witness::PartialWitness; use plonky2::plonk::circuit_data::CircuitData; use plonky2::plonk::config::{AlgebraicHasher, GenericConfig}; use plonky2::plonk::proof::ProofWithPublicInputs; -use plonky2::util::serialization::{Buffer, DefaultGateSerializer, IoResult, Read, Write}; +use plonky2::util::serialization::{Buffer, IoResult, Read, Write}; use self::io::{CircuitInput, CircuitOutput}; -use self::utils::CustomGeneratorSerializer; +use self::utils::{CustomGateSerializer, CustomGeneratorSerializer}; use crate::frontend::builder::io::{EvmIO, FieldIO}; use crate::frontend::builder::CircuitIO; use crate::prelude::{ByteVariable, CircuitVariable, Variable}; @@ -97,8 +97,8 @@ where self.data.verify(proof.clone()).unwrap(); } - fn serializers() -> (DefaultGateSerializer, CustomGeneratorSerializer) { - let gate_serializer = DefaultGateSerializer; + fn serializers() -> (CustomGateSerializer, CustomGeneratorSerializer) { + let gate_serializer = CustomGateSerializer; let generator_serializer = CustomGeneratorSerializer:: { _phantom: PhantomData, }; @@ -122,19 +122,14 @@ where let (gate_serializer, generator_serializer) = Self::serializers(); // Setup buffer. - println!("1"); let mut buffer = Vec::new(); let circuit_bytes = self .data .to_bytes(&gate_serializer, &generator_serializer)?; - println!("2"); buffer.write_usize(circuit_bytes.len())?; - println!("3"); buffer.write_all(&circuit_bytes)?; - println!("4"); if self.io.evm.is_some() { - println!("5"); let io = self.io.evm.as_ref().unwrap(); buffer.write_usize(0)?; buffer.write_target_vec( @@ -153,7 +148,6 @@ where .as_slice(), )?; } else if self.io.field.is_some() { - println!("6"); let io = self.io.field.as_ref().unwrap(); buffer.write_usize(1)?; buffer.write_target_vec( diff --git a/plonky2x/src/backend/circuit/utils.rs b/plonky2x/src/backend/circuit/utils.rs index 123135b2c..36cf554a5 100644 --- a/plonky2x/src/backend/circuit/utils.rs +++ b/plonky2x/src/backend/circuit/utils.rs @@ -34,7 +34,6 @@ use plonky2::recursion::dummy_circuit::DummyProofGenerator; use plonky2::util::serialization::{Buffer, GateSerializer, IoResult, WitnessGeneratorSerializer}; use plonky2::{get_gate_tag_impl, impl_gate_serializer, read_gate_impl}; -use crate::frontend::builder::watch::WatchGenerator; use crate::frontend::eth::beacon::generators::balance::BeaconValidatorBalanceGenerator; use crate::frontend::eth::beacon::generators::validator::BeaconValidatorGenerator; use crate::frontend::eth::beacon::generators::validators::BeaconValidatorsRootGenerator; @@ -42,7 +41,7 @@ use crate::frontend::eth::storage::generators::block::EthBlockGenerator; use crate::frontend::eth::storage::generators::storage::{ EthLogGenerator, EthStorageKeyGenerator, EthStorageProofGenerator, }; -use crate::frontend::hash::keccak::keccak256::Keccack256Generator; +use crate::frontend::hash::keccak::keccak256::Keccak256Generator; use crate::frontend::num::u32::gates::add_many_u32::{U32AddManyGate, U32AddManyGenerator}; #[macro_export] @@ -53,7 +52,6 @@ macro_rules! impl_generator_serializer { buf: &mut Buffer, common_data: &CommonCircuitData, ) -> IoResult> { - println!("read generator"); let tag = plonky2::util::serialization::Read::read_u32(buf)?; read_generator_impl! { buf, @@ -69,7 +67,6 @@ macro_rules! impl_generator_serializer { generator: &plonky2::iop::generator::WitnessGeneratorRef, common_data: &CommonCircuitData, ) -> IoResult<()> { - println!("write generator"); let tag = get_generator_tag_impl! { generator, $( $generator, $name ),* @@ -89,8 +86,7 @@ macro_rules! get_generator_tag_impl { Ok(tag) } else)* { - log::log!(log::Level::Error, "attempted to serialize generator with id {} which is unsupported by this generator serializer", $generator.0.id()); - Err(plonky2::util::serialization::IoError) + panic!("attempted to serialize generator with id {} which is unsupported by this generator serializer", $generator.0.id()); } }}; } @@ -160,7 +156,7 @@ where EthLogGenerator, "EthLogGenerator", EthBlockGenerator, "EthBlockGenerator", EthStorageKeyGenerator, "EthStorageKeyGenerator", - Keccack256Generator, "Keccak256Generator", + Keccak256Generator, "Keccak256Generator", BeaconValidatorBalanceGenerator, "BeaconValidatorBalanceGenerator", BeaconValidatorGenerator, "BeaconValidatorGenerator", BeaconValidatorsRootGenerator, "BeaconValidatorsGenerator", @@ -172,7 +168,7 @@ pub struct CustomGateSerializer; impl, const D: usize> GateSerializer for CustomGateSerializer { impl_gate_serializer! { - DefaultGateSerializer, + CustomGateSerializer, ArithmeticGate, ArithmeticExtensionGate, BaseSumGate<2>, diff --git a/plonky2x/src/frontend/hash/keccak/keccak256.rs b/plonky2x/src/frontend/hash/keccak/keccak256.rs index 1a6edf59a..4b12cd428 100644 --- a/plonky2x/src/frontend/hash/keccak/keccak256.rs +++ b/plonky2x/src/frontend/hash/keccak/keccak256.rs @@ -13,7 +13,7 @@ use plonky2::util::serialization::{Buffer, IoResult, Read, Write}; use crate::frontend::vars::{ByteVariable, Bytes32Variable, CircuitVariable, Variable}; #[derive(Debug, Clone)] -pub struct Keccack256Generator, const D: usize> { +pub struct Keccak256Generator, const D: usize> { pub input: Vec, pub output: Bytes32Variable, pub length: Option, @@ -21,10 +21,10 @@ pub struct Keccack256Generator, const D: usize> { } impl, const D: usize> SimpleGenerator - for Keccack256Generator + for Keccak256Generator { fn id(&self) -> String { - "Keccack256Generator".to_string() + "Keccak256Generator".to_string() } fn dependencies(&self) -> Vec { @@ -42,7 +42,6 @@ impl, const D: usize> SimpleGenerator } fn run_once(&self, witness: &PartitionWitness, out_buffer: &mut GeneratedValues) { - println!("Running keccak256 generator"); let mut length = self.input.len(); if let Some(length_variable) = self.length { length = length_variable.get(witness).to_canonical_u64() as usize; diff --git a/plonky2x/src/frontend/hash/keccak/mod.rs b/plonky2x/src/frontend/hash/keccak/mod.rs index 933b91348..fdd14bd5b 100644 --- a/plonky2x/src/frontend/hash/keccak/mod.rs +++ b/plonky2x/src/frontend/hash/keccak/mod.rs @@ -3,7 +3,7 @@ use plonky2::field::extension::Extendable; use plonky2::hash::hash_types::RichField; -use self::keccak256::Keccack256Generator; +use self::keccak256::Keccak256Generator; use crate::frontend::vars::Bytes32Variable; use crate::prelude::{ByteVariable, CircuitBuilder}; @@ -11,7 +11,7 @@ pub mod keccak256; impl, const D: usize> CircuitBuilder { pub fn keccak256(&mut self, bytes: &[ByteVariable]) -> Bytes32Variable { - let generator = Keccack256Generator { + let generator = Keccak256Generator { input: bytes.to_vec(), output: self.init(), length: None, diff --git a/plonky2x/src/utils/eth/beacon/mod.rs b/plonky2x/src/utils/eth/beacon/mod.rs index 9d061b89e..115a17d92 100644 --- a/plonky2x/src/utils/eth/beacon/mod.rs +++ b/plonky2x/src/utils/eth/beacon/mod.rs @@ -85,7 +85,6 @@ impl BeaconClient { "{}/eth/v1/beacon/states/head/validator_balances?id={}", self.rpc_url, validator_idx ); - println!("{}", endpoint); let client = Client::new(); let response = client.get(endpoint).send().await?; let response: Wrapper = response.json().await?; From f3de17a4c2b86c5b08d850466771adf92422e29c Mon Sep 17 00:00:00 2001 From: John Guibas Date: Thu, 31 Aug 2023 11:01:33 -0700 Subject: [PATCH 10/13] boom --- plonky2x/src/utils/eth/beacon/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plonky2x/src/utils/eth/beacon/mod.rs b/plonky2x/src/utils/eth/beacon/mod.rs index 115a17d92..4783c0436 100644 --- a/plonky2x/src/utils/eth/beacon/mod.rs +++ b/plonky2x/src/utils/eth/beacon/mod.rs @@ -58,15 +58,15 @@ pub struct GetBeaconValidatorsRoot { #[derive(Debug, Deserialize)] struct InnerData { - index: String, - balance: String, + pub index: String, + pub balance: String, } #[derive(Debug, Deserialize)] struct Data { - data: Vec, - execution_optimistic: bool, - finalized: bool, + pub data: Vec, + pub execution_optimistic: bool, + pub finalized: bool, } #[derive(Debug, Deserialize)] From 66d9465c3ca652eb8b9543ef755413ce0197f964 Mon Sep 17 00:00:00 2001 From: John Guibas Date: Thu, 31 Aug 2023 11:05:56 -0700 Subject: [PATCH 11/13] boom --- plonky2x/src/utils/eth/beacon/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plonky2x/src/utils/eth/beacon/mod.rs b/plonky2x/src/utils/eth/beacon/mod.rs index 4783c0436..b4ae6e8dc 100644 --- a/plonky2x/src/utils/eth/beacon/mod.rs +++ b/plonky2x/src/utils/eth/beacon/mod.rs @@ -58,15 +58,15 @@ pub struct GetBeaconValidatorsRoot { #[derive(Debug, Deserialize)] struct InnerData { - pub index: String, + _index: String, pub balance: String, } #[derive(Debug, Deserialize)] struct Data { pub data: Vec, - pub execution_optimistic: bool, - pub finalized: bool, + _execution_optimistic: bool, + _finalized: bool, } #[derive(Debug, Deserialize)] From 0c7fd25921d222470d7c899b7b3100387d2fe83b Mon Sep 17 00:00:00 2001 From: John Guibas Date: Thu, 31 Aug 2023 11:14:56 -0700 Subject: [PATCH 12/13] leanup for chris --- plonky2x/src/frontend/eth/beacon/builder.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/plonky2x/src/frontend/eth/beacon/builder.rs b/plonky2x/src/frontend/eth/beacon/builder.rs index a723ae89e..810b6724d 100644 --- a/plonky2x/src/frontend/eth/beacon/builder.rs +++ b/plonky2x/src/frontend/eth/beacon/builder.rs @@ -119,15 +119,12 @@ pub(crate) mod tests { (0..1).for_each(|i| { let validator = builder.get_beacon_validator_from_u64(validators, i); - builder.watch(&validator.effective_balance, "hi"); }); (0..1).for_each(|i| { let idx = builder.constant::(F::from_canonical_u64(i)); let validator = builder.get_beacon_validator(validators, idx); let balance = builder.get_beacon_validator_balance(validators, idx); - builder.watch(&balance, "balance"); - builder.watch(&validator.effective_balance, "hi"); }); let circuit = builder.build::(); From e95ca526a50fb0de05e28a04434bf2a41ed8231a Mon Sep 17 00:00:00 2001 From: John Guibas Date: Thu, 31 Aug 2023 11:15:24 -0700 Subject: [PATCH 13/13] boom --- plonky2x/src/frontend/eth/beacon/builder.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plonky2x/src/frontend/eth/beacon/builder.rs b/plonky2x/src/frontend/eth/beacon/builder.rs index 810b6724d..2423a8d42 100644 --- a/plonky2x/src/frontend/eth/beacon/builder.rs +++ b/plonky2x/src/frontend/eth/beacon/builder.rs @@ -118,13 +118,13 @@ pub(crate) mod tests { let validators = builder.get_beacon_validators(block_root); (0..1).for_each(|i| { - let validator = builder.get_beacon_validator_from_u64(validators, i); + builder.get_beacon_validator_from_u64(validators, i); }); (0..1).for_each(|i| { let idx = builder.constant::(F::from_canonical_u64(i)); - let validator = builder.get_beacon_validator(validators, idx); - let balance = builder.get_beacon_validator_balance(validators, idx); + builder.get_beacon_validator(validators, idx); + builder.get_beacon_validator_balance(validators, idx); }); let circuit = builder.build::();