-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: docs #8
Merged
feat: docs #8
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0a5013a
feat: initial docs (readme + /sdk)
rpalakkal c9dce4b
chore: re-export ethers
rpalakkal fcedc2c
chore: update examples to use re-export
rpalakkal c08b5f8
chore: add examples to ci
rpalakkal 18fc497
fix: create data dir for ci tests
rpalakkal 1301ba4
fix: docs + re-exports
rpalakkal 2362860
fix: doc tests
rpalakkal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
"num_fixed": 1, | ||
"num_lookup_advice_per_phase": [ | ||
5, | ||
0, | ||
0 | ||
], | ||
"lookup_bits": 14, | ||
|
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 |
---|---|---|
|
@@ -7,8 +7,7 @@ | |
"num_fixed": 1, | ||
"num_lookup_advice_per_phase": [ | ||
5, | ||
1, | ||
0 | ||
1 | ||
], | ||
"lookup_bits": 14, | ||
"num_rlc_columns": 1 | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,14 @@ use crate::{ | |
Fr, | ||
}; | ||
|
||
/// Axiom Circuit API for making both subquery calls (e.g. `get_account`, `get_header`, etc.) and for more general ZK primitives (e.g. `add`, `mul`, etc.). | ||
pub struct AxiomAPI<'a> { | ||
/// The `halo2-lib` struct used to construct the circuit | ||
pub builder: &'a mut RlcCircuitBuilder<Fr>, | ||
/// The main chip for ZK primitives | ||
pub range: &'a RangeChip<Fr>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment this is main chip for zk primitives |
||
pub subquery_caller: Arc<Mutex<SubqueryCaller<Http, Fr>>>, | ||
/// The struct that manages all subquery calls | ||
subquery_caller: Arc<Mutex<SubqueryCaller<Http, Fr>>>, | ||
} | ||
|
||
impl<'a> AxiomAPI<'a> { | ||
|
@@ -43,24 +47,41 @@ impl<'a> AxiomAPI<'a> { | |
} | ||
} | ||
|
||
/// Returns a thread-safe [SubqueryCaller] object. | ||
pub fn subquery_caller(&self) -> Arc<Mutex<SubqueryCaller<Http, Fr>>> { | ||
self.subquery_caller.clone() | ||
} | ||
|
||
/// Returns a mutable reference to the [Context] of a gate thread. Spawns a new thread for the given phase, if none exists. | ||
/// * `phase`: The challenge phase (as an index) of the gate thread. | ||
pub fn ctx(&mut self) -> &mut Context<Fr> { | ||
self.builder.base.main(0) | ||
} | ||
|
||
/// Returns an `AssignedValue<Fr>` from a `HiLo<AssignedValue<Fr>>`. | ||
/// | ||
/// NOTE: this can fail if the hi-lo pair is greater than the `Fr` modulus. See `check_hi_lo` for what is constrained. | ||
/// | ||
/// * `hilo` - The `HiLo<AssignedValue<Fr>>` object to convert. | ||
pub fn from_hi_lo(&mut self, hilo: HiLo<AssignedValue<Fr>>) -> AssignedValue<Fr> { | ||
let ctx = self.builder.base.main(0); | ||
from_hi_lo(ctx, self.range, hilo) | ||
} | ||
|
||
/// Returns a 256-bit `HiLo<AssignedValue<Fr>>` from a `AssignedValue<Fr>`. | ||
/// | ||
/// See `check_hi_lo` for what is constrained. | ||
/// | ||
/// * `val` - The `AssignedValue<Fr>` object to convert. | ||
pub fn to_hi_lo(&mut self, val: AssignedValue<Fr>) -> HiLo<AssignedValue<Fr>> { | ||
let ctx = self.builder.base.main(0); | ||
to_hi_lo(ctx, self.range, val) | ||
} | ||
|
||
/// Returns an [Account] builder given block number and address. | ||
/// | ||
/// * `block_number` - The block number as an `AssignedValue<Fr>`. | ||
/// * `addr` - The address as an `AssignedValue<Fr>`. | ||
pub fn get_account( | ||
&mut self, | ||
block_number: AssignedValue<Fr>, | ||
|
@@ -70,11 +91,19 @@ impl<'a> AxiomAPI<'a> { | |
get_account(ctx, self.subquery_caller.clone(), block_number, addr) | ||
} | ||
|
||
/// Returns a [Header] builder given block number. | ||
/// | ||
/// * `block_number` - The block number as an `AssignedValue<Fr>`. | ||
pub fn get_header(&mut self, block_number: AssignedValue<Fr>) -> Header { | ||
let ctx = self.builder.base.main(0); | ||
get_header(ctx, self.subquery_caller.clone(), block_number) | ||
} | ||
|
||
/// Returns a [SolidityMapping] builder given block number, address, and mapping slot. | ||
/// | ||
/// * `block_number` - The block number as an `AssignedValue<Fr>`. | ||
/// * `addr` - The address as an `AssignedValue<Fr>`. | ||
/// * `mapping_slot` - The mapping slot as a `HiLo<AssignedValue<Fr>`. | ||
pub fn get_mapping( | ||
&mut self, | ||
block_number: AssignedValue<Fr>, | ||
|
@@ -91,6 +120,10 @@ impl<'a> AxiomAPI<'a> { | |
) | ||
} | ||
|
||
/// Returns a [Receipt] builder given block number and transaction index. | ||
/// | ||
/// * `block_number` - The block number as an `AssignedValue<Fr>`. | ||
/// * `tx_idx` - The transaction index as an `AssignedValue<Fr>`. | ||
pub fn get_receipt( | ||
&mut self, | ||
block_number: AssignedValue<Fr>, | ||
|
@@ -100,6 +133,10 @@ impl<'a> AxiomAPI<'a> { | |
get_receipt(ctx, self.subquery_caller.clone(), block_number, tx_idx) | ||
} | ||
|
||
/// Returns a [Storage] builder given block number and address. | ||
/// | ||
/// * `block_number` - The block number as an `AssignedValue<Fr>`. | ||
/// * `addr` - The address as an `AssignedValue<Fr>`. | ||
pub fn get_storage( | ||
&mut self, | ||
block_number: AssignedValue<Fr>, | ||
|
@@ -109,6 +146,10 @@ impl<'a> AxiomAPI<'a> { | |
get_storage(ctx, self.subquery_caller.clone(), block_number, addr) | ||
} | ||
|
||
/// Returns a [Tx] builder given block number and transaction index. | ||
/// | ||
/// * `block_number` - The block number as an `AssignedValue<Fr>`. | ||
/// * `tx_idx` - The transaction index as an `AssignedValue<Fr>`. | ||
pub fn get_tx(&mut self, block_number: AssignedValue<Fr>, tx_idx: AssignedValue<Fr>) -> Tx { | ||
let ctx = self.builder.base.main(0); | ||
get_tx(ctx, self.subquery_caller.clone(), block_number, tx_idx) | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add basic comment this is an axiom-eth / halo2-lib struct