Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
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
39 changes: 3 additions & 36 deletions bin/client/src/precompiles/bls12_g1_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
//!
//! [revm implementation]: https://github.com/bluealloy/revm/blob/main/crates/precompile/src/bls12_381/g1_add.rs

use crate::{HINT_WRITER, ORACLE_READER};
use crate::precompiles::utils::precompile_run;
use alloc::{string::ToString, vec::Vec};
use alloy_primitives::{address, keccak256, Address, Bytes};
use kona_preimage::{
errors::PreimageOracleError, PreimageKey, PreimageKeyType, PreimageOracleClient,
};
use kona_proof::{errors::OracleProviderError, HintType};
use revm::{
precompile::{Error as PrecompileError, Precompile, PrecompileResult, PrecompileWithAddress},
primitives::PrecompileOutput,
Expand Down Expand Up @@ -50,37 +46,8 @@
.into());
}

let result_data = kona_proof::block_on(async move {
// Write the hint for the ecrecover precompile run.
let hint_data = &[BLS12_G1_ADD_CHECK.as_ref(), input.as_ref()];
HintType::L1Precompile.with_data(hint_data).send(&HINT_WRITER).await?;

// Construct the key hash for the ecrecover precompile run.
let raw_key_data = hint_data.iter().copied().flatten().copied().collect::<Vec<u8>>();
let key_hash = keccak256(&raw_key_data);

// Fetch the result of the ecrecover precompile run from the host.
let result_data = ORACLE_READER
.get(PreimageKey::new(*key_hash, PreimageKeyType::Precompile))
.await
.map_err(OracleProviderError::Preimage)?;

// Ensure we've received valid result data.
if result_data.is_empty() {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Invalid result data".to_string(),
)));
}

// Ensure we've not received an error from the host.
if result_data[0] == 0 {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Error executing ecrecover precompile in host".to_string(),
)));
}

// Return the result data.
Ok(result_data[1..].to_vec())
let result_data = kona_proof::block_on(precompile_run! {
&[BLS12_G1_ADD_CHECK.as_ref(), input.as_ref()]

Check warning on line 50 in bin/client/src/precompiles/bls12_g1_add.rs

View check run for this annotation

Codecov / codecov/patch

bin/client/src/precompiles/bls12_g1_add.rs#L49-L50

Added lines #L49 - L50 were not covered by tests
})
.map_err(|e| PrecompileError::Other(e.to_string()))?;

Expand Down
39 changes: 3 additions & 36 deletions bin/client/src/precompiles/bls12_g1_msm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
//!
//! [revm implementation]: https://github.com/bluealloy/revm/blob/main/crates/precompile/src/bls12_381/g1_msm.rs

use crate::{precompiles::utils::msm_required_gas, HINT_WRITER, ORACLE_READER};
use crate::precompiles::utils::{msm_required_gas, precompile_run};
use alloc::{string::ToString, vec::Vec};
use alloy_primitives::{address, keccak256, Address, Bytes};
use kona_preimage::{
errors::PreimageOracleError, PreimageKey, PreimageKeyType, PreimageOracleClient,
};
use kona_proof::{errors::OracleProviderError, HintType};
use revm::{
precompile::{Error as PrecompileError, Precompile, PrecompileResult, PrecompileWithAddress},
primitives::PrecompileOutput,
Expand Down Expand Up @@ -67,37 +63,8 @@
return Err(PrecompileError::OutOfGas.into());
}

let result_data = kona_proof::block_on(async move {
// Write the hint for the ecrecover precompile run.
let hint_data = &[BLS12_G1_MSM_CHECK.as_ref(), input.as_ref()];
HintType::L1Precompile.with_data(hint_data).send(&HINT_WRITER).await?;

// Construct the key hash for the ecrecover precompile run.
let raw_key_data = hint_data.iter().copied().flatten().copied().collect::<Vec<u8>>();
let key_hash = keccak256(&raw_key_data);

// Fetch the result of the ecrecover precompile run from the host.
let result_data = ORACLE_READER
.get(PreimageKey::new(*key_hash, PreimageKeyType::Precompile))
.await
.map_err(OracleProviderError::Preimage)?;

// Ensure we've received valid result data.
if result_data.is_empty() {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Invalid result data".to_string(),
)));
}

// Ensure we've not received an error from the host.
if result_data[0] == 0 {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Error executing ecrecover precompile in host".to_string(),
)));
}

// Return the result data.
Ok(result_data[1..].to_vec())
let result_data = kona_proof::block_on(precompile_run! {
&[BLS12_G1_MSM_CHECK.as_ref(), input.as_ref()]

Check warning on line 67 in bin/client/src/precompiles/bls12_g1_msm.rs

View check run for this annotation

Codecov / codecov/patch

bin/client/src/precompiles/bls12_g1_msm.rs#L66-L67

Added lines #L66 - L67 were not covered by tests
})
.map_err(|e| PrecompileError::Other(e.to_string()))?;

Expand Down
39 changes: 3 additions & 36 deletions bin/client/src/precompiles/bls12_g2_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
//!
//! [revm implementation]: https://github.com/bluealloy/revm/blob/main/crates/precompile/src/bls12_381/g2_add.rs

use crate::{HINT_WRITER, ORACLE_READER};
use crate::precompiles::utils::precompile_run;
use alloc::{string::ToString, vec::Vec};
use alloy_primitives::{address, keccak256, Address, Bytes};
use kona_preimage::{
errors::PreimageOracleError, PreimageKey, PreimageKeyType, PreimageOracleClient,
};
use kona_proof::{errors::OracleProviderError, HintType};
use revm::{
precompile::{Error as PrecompileError, Precompile, PrecompileResult, PrecompileWithAddress},
primitives::PrecompileOutput,
Expand Down Expand Up @@ -50,37 +46,8 @@
.into());
}

let result_data = kona_proof::block_on(async move {
// Write the hint for the ecrecover precompile run.
let hint_data = &[BLS12_G2_ADD_CHECK.as_ref(), input.as_ref()];
HintType::L1Precompile.with_data(hint_data).send(&HINT_WRITER).await?;

// Construct the key hash for the ecrecover precompile run.
let raw_key_data = hint_data.iter().copied().flatten().copied().collect::<Vec<u8>>();
let key_hash = keccak256(&raw_key_data);

// Fetch the result of the ecrecover precompile run from the host.
let result_data = ORACLE_READER
.get(PreimageKey::new(*key_hash, PreimageKeyType::Precompile))
.await
.map_err(OracleProviderError::Preimage)?;

// Ensure we've received valid result data.
if result_data.is_empty() {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Invalid result data".to_string(),
)));
}

// Ensure we've not received an error from the host.
if result_data[0] == 0 {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Error executing ecrecover precompile in host".to_string(),
)));
}

// Return the result data.
Ok(result_data[1..].to_vec())
let result_data = kona_proof::block_on(precompile_run! {
&[BLS12_G2_ADD_CHECK.as_ref(), input.as_ref()]

Check warning on line 50 in bin/client/src/precompiles/bls12_g2_add.rs

View check run for this annotation

Codecov / codecov/patch

bin/client/src/precompiles/bls12_g2_add.rs#L49-L50

Added lines #L49 - L50 were not covered by tests
})
.map_err(|e| PrecompileError::Other(e.to_string()))?;

Expand Down
39 changes: 3 additions & 36 deletions bin/client/src/precompiles/bls12_g2_msm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
//!
//! [revm implementation]: https://github.com/bluealloy/revm/blob/main/crates/precompile/src/bls12_381/g2_msm.rs

use crate::{precompiles::utils::msm_required_gas, HINT_WRITER, ORACLE_READER};
use crate::precompiles::utils::{msm_required_gas, precompile_run};
use alloc::{string::ToString, vec::Vec};
use alloy_primitives::{address, keccak256, Address, Bytes};
use kona_preimage::{
errors::PreimageOracleError, PreimageKey, PreimageKeyType, PreimageOracleClient,
};
use kona_proof::{errors::OracleProviderError, HintType};
use revm::{
precompile::{Error as PrecompileError, Precompile, PrecompileResult, PrecompileWithAddress},
primitives::PrecompileOutput,
Expand Down Expand Up @@ -67,37 +63,8 @@
return Err(PrecompileError::OutOfGas.into());
}

let result_data = kona_proof::block_on(async move {
// Write the hint for the ecrecover precompile run.
let hint_data = &[BLS12_G2_MSM_CHECK.as_ref(), input.as_ref()];
HintType::L1Precompile.with_data(hint_data).send(&HINT_WRITER).await?;

// Construct the key hash for the ecrecover precompile run.
let raw_key_data = hint_data.iter().copied().flatten().copied().collect::<Vec<u8>>();
let key_hash = keccak256(&raw_key_data);

// Fetch the result of the ecrecover precompile run from the host.
let result_data = ORACLE_READER
.get(PreimageKey::new(*key_hash, PreimageKeyType::Precompile))
.await
.map_err(OracleProviderError::Preimage)?;

// Ensure we've received valid result data.
if result_data.is_empty() {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Invalid result data".to_string(),
)));
}

// Ensure we've not received an error from the host.
if result_data[0] == 0 {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Error executing ecrecover precompile in host".to_string(),
)));
}

// Return the result data.
Ok(result_data[1..].to_vec())
let result_data = kona_proof::block_on(precompile_run! {
&[BLS12_G2_MSM_CHECK.as_ref(), input.as_ref()]

Check warning on line 67 in bin/client/src/precompiles/bls12_g2_msm.rs

View check run for this annotation

Codecov / codecov/patch

bin/client/src/precompiles/bls12_g2_msm.rs#L66-L67

Added lines #L66 - L67 were not covered by tests
})
.map_err(|e| PrecompileError::Other(e.to_string()))?;

Expand Down
39 changes: 3 additions & 36 deletions bin/client/src/precompiles/bls12_map_fp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
//!
//! [revm implementation]: https://github.com/bluealloy/revm/blob/main/crates/precompile/src/bls12_381/map_fp_to_g1.rs

use crate::{HINT_WRITER, ORACLE_READER};
use crate::precompiles::utils::precompile_run;
use alloc::{string::ToString, vec::Vec};
use alloy_primitives::{address, keccak256, Address, Bytes};
use kona_preimage::{
errors::PreimageOracleError, PreimageKey, PreimageKeyType, PreimageOracleClient,
};
use kona_proof::{errors::OracleProviderError, HintType};
use revm::{
precompile::{Error as PrecompileError, Precompile, PrecompileResult, PrecompileWithAddress},
primitives::PrecompileOutput,
Expand Down Expand Up @@ -50,37 +46,8 @@
.into());
}

let result_data = kona_proof::block_on(async move {
// Write the hint for the ecrecover precompile run.
let hint_data = &[BLS12_MAP_FP_CHECK.as_ref(), input.as_ref()];
HintType::L1Precompile.with_data(hint_data).send(&HINT_WRITER).await?;

// Construct the key hash for the ecrecover precompile run.
let raw_key_data = hint_data.iter().copied().flatten().copied().collect::<Vec<u8>>();
let key_hash = keccak256(&raw_key_data);

// Fetch the result of the ecrecover precompile run from the host.
let result_data = ORACLE_READER
.get(PreimageKey::new(*key_hash, PreimageKeyType::Precompile))
.await
.map_err(OracleProviderError::Preimage)?;

// Ensure we've received valid result data.
if result_data.is_empty() {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Invalid result data".to_string(),
)));
}

// Ensure we've not received an error from the host.
if result_data[0] == 0 {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Error executing ecrecover precompile in host".to_string(),
)));
}

// Return the result data.
Ok(result_data[1..].to_vec())
let result_data = kona_proof::block_on(precompile_run! {
&[BLS12_MAP_FP_CHECK.as_ref(), input.as_ref()]

Check warning on line 50 in bin/client/src/precompiles/bls12_map_fp.rs

View check run for this annotation

Codecov / codecov/patch

bin/client/src/precompiles/bls12_map_fp.rs#L49-L50

Added lines #L49 - L50 were not covered by tests
})
.map_err(|e| PrecompileError::Other(e.to_string()))?;

Expand Down
39 changes: 3 additions & 36 deletions bin/client/src/precompiles/bls12_map_fp2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
//!
//! [revm implementation]: https://github.com/bluealloy/revm/blob/main/crates/precompile/src/bls12_381/map_fp_to_g1.rs

use crate::{HINT_WRITER, ORACLE_READER};
use crate::precompiles::utils::precompile_run;
use alloc::{string::ToString, vec::Vec};
use alloy_primitives::{address, keccak256, Address, Bytes};
use kona_preimage::{
errors::PreimageOracleError, PreimageKey, PreimageKeyType, PreimageOracleClient,
};
use kona_proof::{errors::OracleProviderError, HintType};
use revm::{
precompile::{Error as PrecompileError, Precompile, PrecompileResult, PrecompileWithAddress},
primitives::PrecompileOutput,
Expand Down Expand Up @@ -50,37 +46,8 @@
.into());
}

let result_data = kona_proof::block_on(async move {
// Write the hint for the ecrecover precompile run.
let hint_data = &[BLS12_MAP_FP2_CHECK.as_ref(), input.as_ref()];
HintType::L1Precompile.with_data(hint_data).send(&HINT_WRITER).await?;

// Construct the key hash for the ecrecover precompile run.
let raw_key_data = hint_data.iter().copied().flatten().copied().collect::<Vec<u8>>();
let key_hash = keccak256(&raw_key_data);

// Fetch the result of the ecrecover precompile run from the host.
let result_data = ORACLE_READER
.get(PreimageKey::new(*key_hash, PreimageKeyType::Precompile))
.await
.map_err(OracleProviderError::Preimage)?;

// Ensure we've received valid result data.
if result_data.is_empty() {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Invalid result data".to_string(),
)));
}

// Ensure we've not received an error from the host.
if result_data[0] == 0 {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Error executing ecrecover precompile in host".to_string(),
)));
}

// Return the result data.
Ok(result_data[1..].to_vec())
let result_data = kona_proof::block_on(precompile_run! {
&[BLS12_MAP_FP2_CHECK.as_ref(), input.as_ref()]

Check warning on line 50 in bin/client/src/precompiles/bls12_map_fp2.rs

View check run for this annotation

Codecov / codecov/patch

bin/client/src/precompiles/bls12_map_fp2.rs#L49-L50

Added lines #L49 - L50 were not covered by tests
})
.map_err(|e| PrecompileError::Other(e.to_string()))?;

Expand Down
39 changes: 3 additions & 36 deletions bin/client/src/precompiles/bls12_pairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
//!
//! [revm implementation]: https://github.com/bluealloy/revm/blob/main/crates/precompile/src/bls12_381/pairing.rs

use crate::{HINT_WRITER, ORACLE_READER};
use crate::precompiles::utils::precompile_run;
use alloc::{string::ToString, vec::Vec};
use alloy_primitives::{address, keccak256, Address, Bytes};
use kona_preimage::{
errors::PreimageOracleError, PreimageKey, PreimageKeyType, PreimageOracleClient,
};
use kona_proof::{errors::OracleProviderError, HintType};
use revm::{
precompile::{Error as PrecompileError, Precompile, PrecompileResult, PrecompileWithAddress},
primitives::PrecompileOutput,
Expand Down Expand Up @@ -53,37 +49,8 @@
return Err(PrecompileError::OutOfGas.into());
}

let result_data = kona_proof::block_on(async move {
// Write the hint for the ecrecover precompile run.
let hint_data = &[BLS12_PAIRING_CHECK.as_ref(), input.as_ref()];
HintType::L1Precompile.with_data(hint_data).send(&HINT_WRITER).await?;

// Construct the key hash for the ecrecover precompile run.
let raw_key_data = hint_data.iter().copied().flatten().copied().collect::<Vec<u8>>();
let key_hash = keccak256(&raw_key_data);

// Fetch the result of the ecrecover precompile run from the host.
let result_data = ORACLE_READER
.get(PreimageKey::new(*key_hash, PreimageKeyType::Precompile))
.await
.map_err(OracleProviderError::Preimage)?;

// Ensure we've received valid result data.
if result_data.is_empty() {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Invalid result data".to_string(),
)));
}

// Ensure we've not received an error from the host.
if result_data[0] == 0 {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"Error executing ecrecover precompile in host".to_string(),
)));
}

// Return the result data.
Ok(result_data[1..].to_vec())
let result_data = kona_proof::block_on(precompile_run! {
&[BLS12_PAIRING_CHECK.as_ref(), input.as_ref()]

Check warning on line 53 in bin/client/src/precompiles/bls12_pairing.rs

View check run for this annotation

Codecov / codecov/patch

bin/client/src/precompiles/bls12_pairing.rs#L52-L53

Added lines #L52 - L53 were not covered by tests
})
.map_err(|e| PrecompileError::Other(e.to_string()))?;

Expand Down
Loading