Skip to content

Commit b2ff327

Browse files
authored
chore: run formatter (#5)
* run nargo fmt * add ci test
1 parent 5e785a2 commit b2ff327

File tree

122 files changed

+13717
-2261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+13717
-2261
lines changed

.github/workflows/circuits_test.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Noir tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
MINIMUM_NOIR_VERSION: 1.0.0-beta.16
12+
13+
jobs:
14+
noir-version-list:
15+
name: Query supported Noir versions
16+
runs-on: ubuntu-latest
17+
outputs:
18+
noir_versions: ${{ steps.get_versions.outputs.versions }}
19+
20+
steps:
21+
- name: Checkout sources
22+
id: get_versions
23+
run: |
24+
# gh returns the Noir releases in reverse chronological order so we keep all releases published after the minimum supported version.
25+
VERSIONS=$(gh release list -R noir-lang/noir --exclude-pre-releases --json tagName -q 'map(.tagName) | index(env.MINIMUM_NOIR_VERSION) as $index | if $index then .[0:$index+1] else [env.MINIMUM_NOIR_VERSION] end')
26+
echo "versions=$VERSIONS"
27+
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
28+
env:
29+
GH_TOKEN: ${{ github.token }}
30+
31+
test:
32+
needs: [noir-version-list]
33+
name: Test on Nargo ${{matrix.toolchain}}
34+
runs-on: ubuntu-latest
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
toolchain: ${{ fromJson( needs.noir-version-list.outputs.noir_versions )}}
39+
include:
40+
- toolchain: nightly
41+
steps:
42+
- name: Checkout sources
43+
uses: actions/checkout@v4
44+
45+
- name: Install Nargo
46+
uses: noir-lang/[email protected]
47+
with:
48+
toolchain: ${{ matrix.toolchain }}
49+
50+
- name: Run Noir tests
51+
run: nargo test
52+
53+
rust-equivalence-tests:
54+
name: Test for equivalence against Rust impl
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Checkout sources
58+
uses: actions/checkout@v4
59+
60+
- name: Install Nargo
61+
uses: noir-lang/[email protected]
62+
with:
63+
toolchain: ${{ env.MINIMUM_NOIR_VERSION }}
64+
65+
format:
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Checkout sources
69+
uses: actions/checkout@v4
70+
71+
- name: Install Nargo
72+
uses: noir-lang/[email protected]
73+
with:
74+
toolchain: ${{ env.MINIMUM_NOIR_VERSION }}
75+
76+
- name: Run formatter
77+
run: nargo fmt --check
78+
79+
# This is a job which depends on all test jobs and reports the overall status.
80+
# This allows us to add/remove test jobs without having to update the required workflows.
81+
tests-end:
82+
name: Noir End
83+
runs-on: ubuntu-latest
84+
# We want this job to always run (even if the dependant jobs fail) as we want this job to fail rather than skipping.
85+
if: ${{ always() }}
86+
needs:
87+
- test
88+
- rust-equivalence-tests
89+
- format
90+
91+
steps:
92+
- name: Report overall success
93+
run: |
94+
if [[ $FAIL == true ]]; then
95+
exit 1
96+
else
97+
exit 0
98+
fi
99+
env:
100+
# We treat any cancelled, skipped or failing jobs as a failure for the workflow as a whole.
101+
FAIL: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}

ethereum/circuits/get_account/src/main.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use dep::ethereum::account::{get_account, AccountWithinBlock};
1+
use dep::ethereum::account::{AccountWithinBlock, get_account};
22
use dep::ethereum::misc::types::Address;
33

44
fn main(chain_id: pub Field, block_no: pub u64, address: pub Address) -> pub AccountWithinBlock {

ethereum/circuits/get_header/src/main.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use dep::ethereum::header::{get_header, BlockHeaderPartial};
1+
use dep::ethereum::header::{BlockHeaderPartial, get_header};
22

33
fn main(chain_id: pub Field, block_no: pub u64) -> pub BlockHeaderPartial {
44
get_header(chain_id, block_no)

ethereum/circuits/get_log/src/main.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main(
77
chain_id: pub Field,
88
block_number: pub u64,
99
tx_idx: pub Field,
10-
log_idx: pub u32
10+
log_idx: pub u32,
1111
) -> pub LogWithinBlock<MAX_LOG_DATA_LEN> {
1212
get_log::<MAX_LOG_DATA_LEN, MAX_LOGS_COUNT>(chain_id, block_number, tx_idx, log_idx)
1313
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
use dep::ethereum::{account_with_storage::{get_account_with_storage, StorageWithinBlock}, misc::types::{Address, Bytes32}};
1+
use dep::ethereum::{
2+
account_with_storage::{get_account_with_storage, StorageWithinBlock},
3+
misc::types::{Address, Bytes32},
4+
};
25

36
fn main(
47
chain_id: pub Field,
58
block_number: pub u64,
69
address: pub Address,
7-
storage_key: pub Bytes32
10+
storage_key: pub Bytes32,
811
) -> pub StorageWithinBlock<1> {
912
get_account_with_storage(chain_id, block_number, address, storage_key)
1013
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
use dep::ethereum::{account_with_storage::{get_account_with_storage, StorageWithinBlock}, misc::types::{Address, Bytes32}};
1+
use dep::ethereum::{
2+
account_with_storage::{get_account_with_storage, StorageWithinBlock},
3+
misc::types::{Address, Bytes32},
4+
};
25

36
#[recursive]
47
fn main(
58
chain_id: pub Field,
69
block_number: pub u64,
710
address: pub Address,
8-
storage_key: pub Bytes32
11+
storage_key: pub Bytes32,
912
) -> pub StorageWithinBlock<1> {
1013
get_account_with_storage(chain_id, block_number, address, storage_key)
1114
}

ethereum/circuits/get_transaction/src/main.nr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ global MAX_DATA_LEN_M = 1000;
55
fn main(
66
chain_id: pub Field,
77
block_number: pub u64,
8-
tx_idx: pub Field
8+
tx_idx: pub Field,
99
) -> pub TransactionWithinBlock<MAX_DATA_LEN_M> {
10-
let transaction_within_block: TransactionWithinBlock<MAX_DATA_LEN_M> = get_transaction(chain_id, block_number, tx_idx);
10+
let transaction_within_block: TransactionWithinBlock<MAX_DATA_LEN_M> =
11+
get_transaction(chain_id, block_number, tx_idx);
1112
transaction_within_block
1213
}

ethereum/circuits/lib/src/account_int_test.nr

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
use crate::account::get_account;
22
use crate::chain::ETHEREUM_MAINNET_ID;
33
use crate::fixtures::mainnet::{
4-
paris::{
5-
usdc_circle::{
6-
header::{number, state_root, block_header_partial, block_header_rlp}, account::{account, address},
7-
state_proof::proof_input_serialized as state_proof_input_serialized
8-
}
9-
},
104
london::vitalik_balance::{
11-
account::{account as account_from_different_header, address as address_from_different_header},
12-
header::state_root as state_root_from_different_header,
13-
state_proof::proof_input_serialized as state_proof_input_from_different_header_serialized
14-
}
5+
account::{
6+
account as account_from_different_header, address as address_from_different_header,
7+
},
8+
header::state_root as state_root_from_different_header,
9+
state_proof::proof_input_serialized as state_proof_input_from_different_header_serialized,
10+
},
11+
paris::usdc_circle::{
12+
account::{account, address},
13+
header::{block_header_partial, block_header_rlp, number, state_root},
14+
state_proof::proof_input_serialized as state_proof_input_serialized,
15+
},
1516
};
1617
use dep::std::test::OracleMock;
1718

@@ -33,7 +34,9 @@ fn test_get_account_success() {
3334
#[test(should_fail)]
3435
fn test_get_account_wrong_state_root() {
3536
let _ = OracleMock::mock("get_header").returns((block_header_partial, block_header_rlp));
36-
let _ = OracleMock::mock("get_account").returns((account_from_different_header, state_proof_input_from_different_header_serialized));
37+
let _ = OracleMock::mock("get_account").returns((
38+
account_from_different_header, state_proof_input_from_different_header_serialized,
39+
));
3740

3841
let _ = get_account(ETHEREUM_MAINNET_ID, number, address_from_different_header);
3942
}

ethereum/circuits/lib/src/account_with_storage.nr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ pub fn get_account_with_storage(
106106
address: Address,
107107
storage_key: Bytes32,
108108
) -> StorageWithinBlock<1> {
109-
let BlockHeaderPartial { number: _, hash, state_root, transactions_root: _, receipts_root: _ } =
110-
get_header(chain_id, block_number);
109+
let BlockHeaderPartial { number: _, hash, state_root, transactions_root: _, receipts_root: _ }
110+
= get_header(chain_id, block_number);
111111
let StateAndStorageProofInput { account, state_proof_input, storage_proof_input } =
112112
get_proof_unconstrained(chain_id, block_number, address, storage_key);
113113

0 commit comments

Comments
 (0)