Skip to content

Commit

Permalink
add PyVrfSk in native blockifier
Browse files Browse the repository at this point in the history
  • Loading branch information
0xChqrles committed Dec 10, 2023
1 parent cd1e210 commit fcc24ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/native_blockifier/src/py_block_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct PyGeneralConfig {
pub cairo_resource_fee_weights: Arc<HashMap<String, f64>>,
pub invoke_tx_max_n_steps: u32,
pub validate_max_n_steps: u32,
pub ecvrf_private_key: VrfSk,
pub ecvrf_private_key: PyVrfPk,
}

impl FromPyObject<'_> for PyGeneralConfig {
Expand Down Expand Up @@ -93,7 +93,7 @@ pub fn into_block_context(
) -> NativeBlockifierResult<BlockContext> {
let starknet_os_config = general_config.starknet_os_config.clone();
let block_number = BlockNumber(py_attr(block_info, "block_number")?);
let ecvrf_private_key = general_config.ecvrf_private_key;
let ecvrf_private_key = general_config.ecvrf_private_key.0;
let ecvrf_public_key = VrfPk::new(&ecvrf_private_key);

let block_context = BlockContext {
Expand Down
4 changes: 4 additions & 0 deletions crates/native_blockifier/src/py_utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::convert::TryFrom;

use blockifier::transaction::errors::TransactionExecutionError;
use ecvrf::VrfPk;
use num_bigint::BigUint;
use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;
Expand All @@ -13,6 +14,9 @@ use crate::errors::NativeBlockifierResult;
#[derive(Eq, FromPyObject, Hash, PartialEq, Clone, Copy)]
pub struct PyFelt(#[pyo3(from_py_with = "int_to_stark_felt")] pub StarkFelt);

#[derive(Eq, FromPyObject, Hash, PartialEq, Clone, Copy)]
pub struct PyVrfPk(#[pyo3(from_py_with = "int_to_stark_felt")] pub VrfPk);

impl IntoPy<PyObject> for PyFelt {
fn into_py(self, py: Python<'_>) -> PyObject {
BigUint::from_bytes_be(self.0.bytes()).into_py(py)
Expand Down

0 comments on commit fcc24ed

Please sign in to comment.