-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: validator witness + using reqwest blocking
- Loading branch information
Showing
11 changed files
with
105 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
plonky2x/src/frontend/eth/beacon/generators/validator_witness.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::env; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::frontend::eth::beacon::vars::BeaconValidatorVariable; | ||
use crate::frontend::generator::simple::hint::Hint; | ||
use crate::frontend::uint::uint64::U64Variable; | ||
use crate::frontend::vars::ValueStream; | ||
use crate::prelude::{Bytes32Variable, PlonkParameters}; | ||
use crate::utils::eth::beacon::BeaconClient; | ||
use crate::utils::hex; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct BeaconValidatorWitnessGenerator {} | ||
|
||
impl<L: PlonkParameters<D>, const D: usize> Hint<L, D> for BeaconValidatorWitnessGenerator { | ||
fn hint(&self, input_stream: &mut ValueStream<L, D>, output_stream: &mut ValueStream<L, D>) { | ||
let client = BeaconClient::new(env::var("CONSENSUS_RPC_1").unwrap()); | ||
let header_root = input_stream.read_value::<Bytes32Variable>(); | ||
let validator_index = input_stream.read_value::<U64Variable>(); | ||
|
||
let response = client | ||
.get_validator_witness(hex!(header_root), validator_index.as_u64()) | ||
.unwrap(); | ||
|
||
output_stream.write_value::<BeaconValidatorVariable>(response.validator); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.