Skip to content

Commit

Permalink
Fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-six committed Mar 12, 2024
1 parent 35151f0 commit fd52cc1
Show file tree
Hide file tree
Showing 23 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion axiom-core/src/aggregation/intermediate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl EthBlockHeaderChainIntermediateAggregationCircuit {
}

/// The input to create an intermediate [AggregationCircuit] that aggregates [crate::header_chain::EthBlockHeaderChainCircuit]s.
/// These are intemediate aggregations because they do not perform additional keccaks. Therefore the public instance format (after excluding accumulators) is
/// These are intermediate aggregations because they do not perform additional keccaks. Therefore the public instance format (after excluding accumulators) is
/// different from that of the original [crate::header_chain::EthBlockHeaderChainCircuit]s.
#[derive(Clone, Debug)]
pub struct EthBlockHeaderChainIntermediateAggregationInput {
Expand Down
2 changes: 1 addition & 1 deletion axiom-eth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ These are traits that specify interfaces for variations of the functions:
- `virtual_assign_phase1`
- `raw_synthesize_phase1`

These four functions are all called in sequence in the `Circuit::synthesize` trait implementation in raw Halo2, with the phase0 columns being commited to between `raw_synthesize_phase0` and `virtual_assign_phase1` so that the challenge values are availabe starting in `virtual_assign_phase1`. (The other technical distinction is that `virtual_assign_*` can be called outside of `Circuit::synthesize` without a `Layouter`, for any precomputation purposes.)
These four functions are all called in sequence in the `Circuit::synthesize` trait implementation in raw Halo2, with the phase0 columns being committed to between `raw_synthesize_phase0` and `virtual_assign_phase1` so that the challenge values are available starting in `virtual_assign_phase1`. (The other technical distinction is that `virtual_assign_*` can be called outside of `Circuit::synthesize` without a `Layouter`, for any precomputation purposes.)

Most of the time, one circuit builder can be re-used for different circuit implementations:
the `raw_synthesize_*` logic stays the same, and you only need to specify the `virtual_assign_*` instructions to quickly write new circuits.
Expand Down
6 changes: 3 additions & 3 deletions axiom-eth/src/keccak/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct KeccakFixedLenQuery<F: ScalarField> {
/// Input in bytes
pub input_assigned: Vec<AssignedValue<F>>,
/// The hash digest, in bytes
// For backwards compatbility we always compute this; we can consider computing it on-demand in the future
// For backwards compatibility we always compute this; we can consider computing it on-demand in the future
pub output_bytes: SafeBytes32<F>,
/// The hash digest, hi 128 bits (range checked by lookup table)
pub output_hi: AssignedValue<F>,
Expand All @@ -66,7 +66,7 @@ pub struct KeccakVarLenQuery<F: ScalarField> {
pub length: AssignedValue<F>,
pub input_assigned: Vec<AssignedValue<F>>,
/// The hash digest, in bytes
// For backwards compatbility we always compute this; we can consider computing it on-demand in the future
// For backwards compatibility we always compute this; we can consider computing it on-demand in the future
pub output_bytes: SafeBytes32<F>,
/// The hash digest, hi 128 bits (range checked by lookup table)
pub output_hi: AssignedValue<F>,
Expand Down Expand Up @@ -94,7 +94,7 @@ pub struct OutputKeccakShard {
}

impl OutputKeccakShard {
/// Createa a dummy OutputKeccakShard with the given capacity.
/// Create a dummy OutputKeccakShard with the given capacity.
pub fn create_dummy(capacity: usize) -> Self {
Self { responses: vec![], capacity }
}
Expand Down
2 changes: 1 addition & 1 deletion axiom-eth/src/rlc/circuit/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl<F: ScalarField> RlcCircuitBuilder<F> {
///
/// (We are only imposing the copy constraints on the instance column, not assigning values to the instance column --
/// The instance values are provided in `create_proof` as an argument, and that is what is used for Fiat-Shamir.
/// Therefore the equality constraints on instance columsn can also be done in SecondPhase instead.
/// Therefore the equality constraints on instance column can also be done in SecondPhase instead.
/// We keep it in FirstPhase for logical clarity.)
pub fn raw_synthesize_phase0(&self, config: &RlcConfig<F>, mut layouter: impl Layouter<F>) {
let usable_rows = config.rlc.usable_rows;
Expand Down
2 changes: 1 addition & 1 deletion axiom-eth/src/utils/build_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pub mod aggregation;
pub mod dummy;
#[cfg(feature = "keygen")]
pub mod keygen;
/// Circut pinning instructions
/// Circuit pinning instructions
pub mod pinning;
2 changes: 1 addition & 1 deletion axiom-eth/src/utils/circuit_utils/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use halo2_base::{
use crate::utils::hilo::HiLo;

/// Takes `bytes` as fixed length byte array, left pads with 0s, and then converts
/// to HiLo form. Optmization where if `bytes` is less than 16 bytes, it can
/// to HiLo form. Optimization where if `bytes` is less than 16 bytes, it can
/// skip the Hi part.
pub fn pack_bytes_to_hilo<F: ScalarField>(
ctx: &mut Context<F>,
Expand Down
4 changes: 2 additions & 2 deletions axiom-eth/src/utils/component/circuit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub trait CoreBuilder<F: Field>: ComponentBuilder<F, Params: CoreBuilderParams>
builder: &mut RlcCircuitBuilder<F>,
// Core circuits can make promise calls.
promise_caller: PromiseCaller<F>,
// TODO: Output commitmment
// TODO: Output commitment
) -> CoreBuilderOutput<F, Self::CompType>;
/// Synthesize for phase0. Any data passing to other steps should be stored inside `self`.
#[allow(unused_variables)]
Expand All @@ -110,7 +110,7 @@ pub struct LoaderParamsPerComponentType {
/// A ComponentModule load promise results from other components and owns some columns and corresponding gates.
/// All ComponentModules in a single circuit share a RlcCircuitBuilder and they communicate with each other through PromiseCollector.
pub trait PromiseBuilder<F: Field>: ComponentBuilder<F> {
/// Get component type dependencies of this ComponentBuilder in a determinstic order.
/// Get component type dependencies of this ComponentBuilder in a deterministic order.
fn get_component_type_dependencies() -> Vec<ComponentTypeId>;
/// Extract loader params per component type from circuit params.
/// Assumption: Return value is in a deterministic order which we use to compute the promise commit.
Expand Down
4 changes: 2 additions & 2 deletions axiom-eth/src/utils/component/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub trait LogicalInputValue<F: Field>:
Debug + Send + Sync + Clone + Eq + Serialize + DeserializeOwned + 'static
{
/// Get the capacity of this logical input.
/// The default implementaion is for the fixed length case.
/// The default implementation is for the fixed length case.
fn get_capacity(&self) -> usize;
}
/// A format of a promise call to component type T.
Expand All @@ -55,7 +55,7 @@ pub trait PromiseCallWitness<F: Field>: Debug + Send + Sync + 'static {
/// Get the capacity of this promise call.
fn get_capacity(&self) -> usize;
/// Encode the promise call into RLC.
/// TODO: maybe pass builder here for better flexiability? but constructing chips are slow.
/// TODO: maybe pass builder here for better flexibility? but constructing chips are slow.
fn to_rlc(
&self,
ctx_pair: (&mut Context<F>, &mut Context<F>),
Expand Down
12 changes: 6 additions & 6 deletions axiom-eth/src/utils/component/promise_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub struct PromiseCollector<F: Field> {
promise_results_ready: bool,
}

/// This is to limit PromiseCollector's interfaces exposed to implementaion.
/// This is to limit PromiseCollector's interfaces exposed to implementation.
pub trait PromiseCallsGetter<F: Field> {
/// Get promise calls by component type id. This is used to add these promises into lookup columns.
/// TODO: This should return `Vec<PromiseResultWitness<F>>` because the order is determined at that time. But it's tricky to
Expand All @@ -69,7 +69,7 @@ pub trait PromiseCallsGetter<F: Field> {
) -> Option<&BTreeMap<ContextTag, Vec<PromiseResultWitness<F>>>>;
}

/// This is to limit PromiseCollector's interfaces exposed to implementaion.
/// This is to limit PromiseCollector's interfaces exposed to implementation.
pub trait PromiseResultsGetter<F: Field> {
/// Get promise results by component type id. This is used to add these promises into lookup columns.
fn get_results_by_component_type_id(
Expand All @@ -78,7 +78,7 @@ pub trait PromiseResultsGetter<F: Field> {
) -> Option<&ComponentPromiseResultsInMerkle<F>>;
}

/// This is to limit PromiseCollector's interfaces exposed to implementaion.
/// This is to limit PromiseCollector's interfaces exposed to implementation.
pub trait PromiseCommitSetter<F: Field> {
/// Get promise results by component type id. This is used to add these promises into lookup columns.
fn set_commit_by_component_type_id(
Expand Down Expand Up @@ -171,7 +171,7 @@ impl<F: Field> PromiseCollector<F> {

let component_type_id = witness_input.get_component_type_id();
if !is_virtual && !self.dependencies_lookup.contains(&component_type_id) {
return Err(anyhow!("Unsupport component type id {:?}.", component_type_id));
return Err(anyhow!("Unsupported component type id {:?}.", component_type_id));
}

let value_serialized_input = witness_input.to_typeless_logical_input();
Expand All @@ -181,8 +181,8 @@ impl<F: Field> PromiseCollector<F> {
let witness_output = if !is_virtual && self.promise_results_ready {
// Hack: there is no direct way to get field size information.
let mut flatten_output = witness_input.get_mock_output();
// If promise results are fullfilled, use the results directly.
// Crash if the promise result is not fullfilled.
// If promise results are fulfilled, use the results directly.
// Crash if the promise result is not fulfilled.
flatten_output.fields =
call_results.unwrap().get(&value_serialized_input).unwrap().clone();
flatten_output.assign(ctx)
Expand Down
4 changes: 2 additions & 2 deletions axiom-eth/src/utils/component/promise_loader/comp_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl<F: Field, T: ComponentType<F>> SingleComponentLoader<F> for SingleComponent
// It will compute the merkle root of [a, b, c, d] where `4` is a private witness.
// Then it may have `selected_shards = [0, 2]`, meaning it only de-commits the shards for a, c. It does this by using `select_from_idx` on `[a, b, c, d]` to get `a, c`.
// Because we always decommit the leaves, meaning we dictate that the leaves much be flat hashes of virtual tables of fixed size (given by `shard_caps`), the
// private witness for the true height (in this example `4`), is commited to by the merkle root we generate.
// private witness for the true height (in this example `4`), is committed to by the merkle root we generate.
// In other words, our definition of shard commitment provides domain separation for the merkle leaves.

// The loader's behavior should not depend on inputs. So the loader always computes a merkle tree with a pre-defined height.
Expand Down Expand Up @@ -342,7 +342,7 @@ pub trait ComponentCommiter<F: Field> {
) -> AssignedValue<F>;
/// The implementor **must** enforce that the output of this function
/// is the same as the output value of `compute_commitment`.
/// We allow a separate implemenation purely for performance, as the native commitmnt
/// We allow a separate implementation purely for performance, as the native commitment
/// computation is much faster than doing it in the circuit.
fn compute_native_commitment(witness_promise_results: &[(Flatten<F>, Flatten<F>)]) -> F;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
},
};

// Just for teseting purpose
// Just for testing purpose
struct DummyRlcAdapter {}
impl RlcAdapter<Fr> for DummyRlcAdapter {
fn to_rlc(
Expand Down
2 changes: 1 addition & 1 deletion axiom-eth/src/utils/component/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<T: Copy> From<Flatten<T>> for Vec<T> {
}
}

/// A logical input/output should be able to convert to a flatten logical input/ouptut.
/// A logical input/output should be able to convert to a flatten logical input/output.
pub trait FixLenLogical<T: Copy>:
TryFrom<Flatten<T>, Error = anyhow::Error> + Into<Flatten<T>> + Clone
{
Expand Down
2 changes: 1 addition & 1 deletion axiom-eth/src/utils/component/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn compress_flatten_pair<F: Field>(
.zip_eq(input.field_size.iter().chain(output.field_size))
{
let bits = *bits;
// If bits > capacity, this is a hacky way to speicify this field taking a whole witness.
// If bits > capacity, this is a hacky way to specify this field taking a whole witness.
if used_bits + bits <= (F::CAPACITY as usize) {
let const_mul = ctx.load_constant(range_chip.gate.pow_of_two[used_bits]);
witness_current = range_chip.gate.mul_add(ctx, const_mul, *a, witness_current);
Expand Down
2 changes: 1 addition & 1 deletion axiom-eth/src/utils/eth_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<F: Field> EthConfig<F> {
let params: EthCircuitParams = params.into();
let k = params.k();
let mut rlc_config = RlcConfig::configure(meta, params.rlc);
// TODO: allow 0 columns here for more flexility
// TODO: allow 0 columns here for more flexibility
let keccak = PromiseLoaderConfig {
dyn_lookup_config: BasicDynLookupConfig::new(meta, || SecondPhase, 1),
};
Expand Down
2 changes: 1 addition & 1 deletion axiom-query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ These promise tables are _a priori_ grouped by subquery types. Moreover they may

The join is currently done in the `table` module; it will be moved to `MultiPromiseLoader` in a coming PR.

The reason this component circuit has no component output is that the true outputs of the circuit are: `resultsRoot`, `resultsRootPoseidon`, and `subqueryHash`s. These are outward/user facing outputs, and for future compatibilty their format depends on the number of subqueries (e.g., `resultsRoot` is a padded Merkle root up to next power of 2 of `numSubqueries`). As such there is no automatic way to compute these commitments and we have custom implementations for them.
The reason this component circuit has no component output is that the true outputs of the circuit are: `resultsRoot`, `resultsRootPoseidon`, and `subqueryHash`s. These are outward/user facing outputs, and for future compatibility their format depends on the number of subqueries (e.g., `resultsRoot` is a padded Merkle root up to next power of 2 of `numSubqueries`). As such there is no automatic way to compute these commitments and we have custom implementations for them.

## [Keccak Component Shard Circuit](https://github.com/axiom-crypto/halo2-lib/blob/main/hashes/zkevm/src/keccak/component/circuit/shard.rs)

Expand Down
2 changes: 1 addition & 1 deletion axiom-query/src/components/results/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<F: Field> CoreBuilder<F> for CoreBuilderResultsRoot<F> {
fn feed_input(&mut self, mut input: Self::CoreInput) -> anyhow::Result<()> {
if input.subqueries.len() > self.params.capacity {
anyhow::bail!(
"Subquery results table is greater than capcaity - {} > {}",
"Subquery results table is greater than capacity - {} > {}",
input.subqueries.len(),
self.params.capacity
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Types are separated into:
//! - Circuit metadata that along with the circuit type determines the circuit configuration completely.
//! - Human readable _logical_ input and output to the circuit. These include private inputs and outputs that are only commited to in the public output.
//! - Human readable _logical_ input and output to the circuit. These include private inputs and outputs that are only committed to in the public output.
//! - The in-circuit formatted versions of logical inputs and outputs. These include formatting in terms of field elements and accounting for all lengths needing to be fixed at compile time.
//! - We then provide conversion functions from human-readable to circuit formats.
//! - A struct for the public instances (IO) of the circuit, excluding the circuit's own component commitment and the promise commitments from any component calls.
Expand Down
2 changes: 1 addition & 1 deletion axiom-query/src/components/subqueries/receipt/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Types are separated into:
//! - Circuit metadata that along with the circuit type determines the circuit configuration completely.
//! - Human readable _logical_ input and output to the circuit. These include private inputs and outputs that are only commited to in the public output.
//! - Human readable _logical_ input and output to the circuit. These include private inputs and outputs that are only committed to in the public output.
//! - The in-circuit formatted versions of logical inputs and outputs. These include formatting in terms of field elements and accounting for all lengths needing to be fixed at compile time.
//! - We then provide conversion functions from human-readable to circuit formats.
//! - This circuit has no public instances (IO) other than the circuit's own component commitment and the promise commitments from any component calls.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Types are separated into:
//! - Circuit metadata that along with the circuit type determines the circuit configuration completely.
//! - Human readable _logical_ input and output to the circuit. These include private inputs and outputs that are only commited to in the public output.
//! - Human readable _logical_ input and output to the circuit. These include private inputs and outputs that are only committed to in the public output.
//! - The in-circuit formatted versions of logical inputs and outputs. These include formatting in terms of field elements and accounting for all lengths needing to be fixed at compile time.
//! - We then provide conversion functions from human-readable to circuit formats.
//! - This circuit has no public instances (IO) other than the circuit's own component commitment and the promise commitments from any component calls.
Expand Down
2 changes: 1 addition & 1 deletion axiom-query/src/components/subqueries/transaction/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Types are separated into:
//! - Circuit metadata that along with the circuit type determines the circuit configuration completely.
//! - Human readable _logical_ input and output to the circuit. These include private inputs and outputs that are only commited to in the public output.
//! - Human readable _logical_ input and output to the circuit. These include private inputs and outputs that are only committed to in the public output.
//! - The in-circuit formatted versions of logical inputs and outputs. These include formatting in terms of field elements and accounting for all lengths needing to be fixed at compile time.
//! - We then provide conversion functions from human-readable to circuit formats.
//! - This circuit has no public instances (IO) other than the circuit's own component commitment and the promise commitments from any component calls.
Expand Down
2 changes: 1 addition & 1 deletion axiom-query/src/subquery_aggregation/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl InputSubqueryAggregation {
// ======== results root =========
// MUST match order in `InputResultsRootShard::build`
let type_ids = SubqueryDependencies::<F>::get_component_type_ids();
// We now collect the promises from snarks in the order they were commited to in ResultsRoot
// We now collect the promises from snarks in the order they were committed to in ResultsRoot
let mut results_deps_commits = Vec::new();
results_deps_commits.push(promise_keccak);
for t_id in &type_ids {
Expand Down
2 changes: 1 addition & 1 deletion axiom-query/src/verify_compute/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl CircuitMetadata for CoreBuilderVerifyCompute {
Some((0..NUM_FE_ACCUMULATOR).map(|i| (0, NUM_COMPONENT_OWNED_INSTANCES + i)).collect())
}
fn num_instance(&self) -> Vec<usize> {
// For reference only, overriden by `num_instance` in `ComponentCircuitImpl`
// For reference only, overridden by `num_instance` in `ComponentCircuitImpl`
vec![
NUM_COMPONENT_OWNED_INSTANCES + NUM_FE_ACCUMULATOR + super::types::NUM_LOGICAL_INSTANCE,
]
Expand Down
2 changes: 1 addition & 1 deletion axiom-query/src/verify_compute/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! # Verify Compute Circuit
//!
//! Verifies the user proof (`computeQuery`) and calculates the query hash
//! by de-commiting subquery results and subquery hashes from two public instances.
//! by de-committing subquery results and subquery hashes from two public instances.
//!
//! The Axiom Aggregation Circuit **must** check that these public instances agree
//! with the public instances from the Subquery Aggregation Circuit.
Expand Down

0 comments on commit fd52cc1

Please sign in to comment.