Skip to content

Commit

Permalink
feat: add function verify_proof_and_register (#5)
Browse files Browse the repository at this point in the history
* feat: add function verify_proof_and_register

* fix: flow_test

* chore: more info about transactions

* feat: optimize verify_proof_and_register

* fix: tx

* fix(CI): increase timeout for tarpaulin

---------

Co-authored-by: Steve Nguyen <[email protected]>
Co-authored-by: draply <[email protected]>
  • Loading branch information
3 people authored Sep 17, 2024
1 parent 4059291 commit 242c91f
Show file tree
Hide file tree
Showing 23 changed files with 4,043 additions and 74 deletions.
8 changes: 4 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export APTOS_PRIVATE_KEY="0x3d31ef06ed8003c3a85125b6e6287967a7b80a3e4367ccf2649e
export APTOS_MODULE_ADDRESS="852578629621677c02f4b9679622f25cac00b4fe17d1fd8b197ba52a2627ee3b"
export CHAIN_ID="testnet"

export APTOS_TESTCONTAINER__ACCOUNTS="0xe47491c27051639d2bc0167af9370dd39f6df3479edfb51658a2eb0a16239cf6,0xdbba3d6050eab8b8683598fad3f80ba1282664a9fca018d629fe883e59889241"
export APTOS_TESTCONTAINER__NODE_URL="https://api.testnet.aptoslabs.com/v1"
export APTOS_TESTCONTAINER__ENABLE_NODE=true
export APTOS_TESTCONTAINER__ACCOUNTS="0xb6c8ce69f296d08fc217b953c7fba5eb25fe14ce0c764b1360ddea4e7e21470a,0x054031364b8a623c093277d30ce9fefe0df363226c23b1cb130d6382f4a1162a"
export APTOS_TESTCONTAINER__NODE_URL="http://10.20.21.121:8888"
export APTOS_TESTCONTAINER__ENABLE_NODE=false
export APTOS_TESTCONTAINER__DEPLOY_CONTRACT=true
export APTOS_TESTCONTAINER__CHAIN_ID=2
export APTOS_TESTCONTAINER__CHAIN_ID=4
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
test-and-coverage:
name: Test and Coverage
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -58,4 +59,4 @@ jobs:
- name: Set PKG_CONFIG_PATH
run: echo "PKG_CONFIG_PATH=/usr/lib/pkgconfig" >> $GITHUB_ENV
- name: Run tests
run: cargo tarpaulin --all-features --verbose --tests --skip-clean
run: cargo tarpaulin --all-features --verbose --tests --skip-clean --timeout 600
85 changes: 73 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ tokio = { version = "1.39.3", features = ["macros", "rt-multi-thread"] }
url = { version = "2.4.0", features = ["serde"] }

[dev-dependencies]
aptos-testcontainer = { git = "https://github.com/sota-zk-labs/aptos-testcontainer.git", tag = "v0.0.3", features = [
"testing",
] }
aptos-testcontainer = { version = "0.1.2", features = ["testing"] }

[patch.crates-io]
merlin = { git = "https://github.com/aptos-labs/merlin" }
Expand Down
2 changes: 1 addition & 1 deletion contracts/navori
Submodule navori updated 48 files
+1 −1 .github/workflows/aptos_test.yaml
+21 −0 LICENSE
+3 −0 README.md
+19 −0 cpu-constraint-poly/Move.toml
+3,952 −0 cpu-constraint-poly/sources/cpu_constraint_poly.move
+19 −0 cpu/Move.toml
+20 −0 cpu/sources/cairo_bootloader_program.move
+893 −0 cpu/sources/layout7/cpu_oods.move
+333 −0 cpu/sources/layout7/layout_specific.move
+24 −0 cpu/sources/layout7/memory_access_utils.move
+46 −0 cpu/sources/layout7/poseidon_poseidon_full_round_key_0_column.move
+32 −0 cpu/sources/layout7/poseidon_poseidon_full_round_key_1_column.move
+32 −0 cpu/sources/layout7/poseidon_poseidon_full_round_key_2_column.move
+171 −0 cpu/sources/layout7/poseidon_poseidon_partial_round_key_0_column.move
+93 −0 cpu/sources/layout7/poseidon_poseidon_partial_round_key_1_column.move
+42 −0 cpu/sources/layout7/public_memory_offsets.move
+1,288 −0 cpu/sources/periodic_columns/pedersen_hash_points_x_column.move
+1,288 −0 cpu/sources/periodic_columns/pedersen_hash_points_y_column.move
+2,566 −0 cpu/sources/tests/cpu_oods_7_test_data.move
+67 −70 libs/sources/bytes.move
+76 −23 libs/sources/prime_field_element_0.move
+54 −0 libs/sources/vector.move
+9 −3 verifier/Move.toml
+748 −0 verifier/scripts/script.move
+10 −4 verifier/sources/components/fact_registry.move
+25 −0 verifier/sources/cpu/cairo_verifier_contract.move
+14 −0 verifier/sources/cpu/layout7/cpu_verifier.move
+141 −0 verifier/sources/cpu/layout7/fri.move
+233 −0 verifier/sources/cpu/layout7/fri_statement_verifier.move
+1,098 −0 verifier/sources/cpu/layout7/stark_verifier.move
+103 −206 verifier/sources/cpu/memory_page_fact_registry.move
+23 −24 verifier/sources/fri_layer.move
+13 −7 verifier/sources/fri_statement_contract.move
+10 −15 verifier/sources/fri_transform.move
+270 −0 verifier/sources/gps/gps_output_parser.move
+462 −0 verifier/sources/gps/gps_statement_verifier.move
+60 −0 verifier/sources/horner_evaluator.move
+2 −2 verifier/sources/merkle_statement_contract.move
+35 −0 verifier/sources/merkle_statement_verifier.move
+4 −4 verifier/sources/merkle_verifier.move
+36 −0 verifier/sources/prng.move
+751 −0 verifier/sources/test/constructor.move
+1,737 −0 verifier/sources/test/fri_statement_verifier_7_test_data.move
+3,593 −0 verifier/sources/test/gps_statement_verifier_test_data.move
+138 −0 verifier/sources/test/test_gps_statement_verifier.move
+2 −1 verifier/sources/test/test_verify_fri_statement.move
+2 −1 verifier/sources/test/test_verify_merkle_statement.move
+241 −0 verifier/sources/verifier_channel.move
2 changes: 2 additions & 0 deletions src/contracts_caller/gps/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod types;
pub mod verify_proof_and_register;
1 change: 1 addition & 0 deletions src/contracts_caller/gps/types/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod verify_proof_and_register;
58 changes: 58 additions & 0 deletions src/contracts_caller/gps/types/verify_proof_and_register.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use std::str::FromStr;

use aptos_sdk::move_types::u256::U256;
use serde::Deserialize;

#[derive(Debug)]
pub struct VerifyProofAndRegisterData {
pub proof_params: Vec<U256>,
pub proof: Vec<U256>,
pub task_metadata: Vec<U256>,
pub cairo_aux_input: Vec<U256>,
pub cairo_verifier_id: U256,
pub pre_registered_facts: Vec<U256>,
}

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VerifyProofAndRegisterDataJson {
pub proof_params: Vec<String>,
pub proof: Vec<String>,
pub task_metadata: Vec<String>,
pub cairo_aux_input: Vec<String>,
pub cairo_verifier_id: String,
pub pre_registered_facts: Vec<String>,
}

impl From<VerifyProofAndRegisterDataJson> for VerifyProofAndRegisterData {
fn from(value: VerifyProofAndRegisterDataJson) -> Self {
VerifyProofAndRegisterData {
proof_params: value
.proof_params
.iter()
.map(|x| U256::from_str(x).unwrap())
.collect(),
proof: value
.proof
.iter()
.map(|x| U256::from_str(x).unwrap())
.collect(),
task_metadata: value
.task_metadata
.iter()
.map(|x| U256::from_str(x).unwrap())
.collect(),
cairo_aux_input: value
.cairo_aux_input
.iter()
.map(|x| U256::from_str(x).unwrap())
.collect(),
cairo_verifier_id: U256::from_str(value.cairo_verifier_id.as_str()).unwrap(),
pre_registered_facts: value
.pre_registered_facts
.iter()
.map(|x| U256::from_str(x).unwrap())
.collect(),
}
}
}
Loading

0 comments on commit 242c91f

Please sign in to comment.