Skip to content

Commit f2aaf16

Browse files
committed
fix
1 parent cfbfd2d commit f2aaf16

File tree

22 files changed

+103
-76
lines changed

22 files changed

+103
-76
lines changed

ethereum/circuits/get_account/src/main.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ 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 {
5-
get_account(chain_id, block_no, address)
5+
get_account(chain_id as u32, block_no, address)
66
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use dep::ethereum::header::{BlockHeaderPartial, get_header};
22

3-
fn main(chain_id: pub Field, block_no: pub u64) -> pub BlockHeaderPartial {
3+
fn main(chain_id: pub u32, block_no: pub u64) -> pub BlockHeaderPartial {
44
get_header(chain_id, block_no)
55
}

ethereum/circuits/get_log/src/main.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ fn main(
99
tx_idx: pub Field,
1010
log_idx: pub u32,
1111
) -> pub LogWithinBlock<MAX_LOG_DATA_LEN> {
12-
get_log::<MAX_LOG_DATA_LEN, MAX_LOGS_COUNT>(chain_id, block_number, tx_idx, log_idx)
12+
get_log::<MAX_LOG_DATA_LEN, MAX_LOGS_COUNT>(chain_id as u32, block_number, tx_idx, log_idx)
1313
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use dep::ethereum::receipt::{get_receipt, TxReceiptWithinBlock};
22

33
fn main(chain_id: pub Field, block_number: pub u64, tx_idx: pub Field) -> pub TxReceiptWithinBlock {
4-
get_receipt(chain_id, block_number, tx_idx)
4+
get_receipt(chain_id as u32, block_number, tx_idx)
55
}

ethereum/circuits/get_storage/src/main.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ fn main(
99
address: pub Address,
1010
storage_key: pub Bytes32,
1111
) -> pub StorageWithinBlock<1> {
12-
get_account_with_storage(chain_id, block_number, address, storage_key)
12+
get_account_with_storage(chain_id as u32, block_number, address, storage_key)
1313
}

ethereum/circuits/get_storage_recursive/src/main.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ fn main(
1010
address: pub Address,
1111
storage_key: pub Bytes32,
1212
) -> pub StorageWithinBlock<1> {
13-
get_account_with_storage(chain_id, block_number, address, storage_key)
13+
get_account_with_storage(chain_id as u32, block_number, address, storage_key)
1414
}

ethereum/circuits/get_transaction/src/main.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ fn main(
88
tx_idx: pub Field,
99
) -> pub TransactionWithinBlock<MAX_DATA_LEN_M> {
1010
let transaction_within_block: TransactionWithinBlock<MAX_DATA_LEN_M> =
11-
get_transaction(chain_id, block_number, tx_idx);
11+
get_transaction(chain_id as u32, block_number, tx_idx);
1212
transaction_within_block
1313
}

ethereum/circuits/lib/src/account.nr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pub(crate) global MAX_ACCOUNT_STATE_LEN: u32 = 110; // Values taken from account
1313
pub(crate) global MAX_ACCOUNT_LEAF_LEN: u32 = 148;
1414

1515
pub struct AccountWithinBlock {
16-
account: Account,
17-
block_hash: Bytes32,
16+
pub(crate) account: Account,
17+
pub(crate) block_hash: Bytes32,
1818
}
1919

2020
impl Eq for AccountWithinBlock {
@@ -27,7 +27,7 @@ type AccountWithStateProofM = (Account, ProofInput<MAX_PREFIXED_KEY_NIBBLE_LEN,
2727

2828
type ProofInputSerialized<let LEN: u32> = [Field; LEN];
2929

30-
pub fn get_account(chain_id: Field, block_no: u64, address: Address) -> AccountWithinBlock {
30+
pub fn get_account(chain_id: u32, block_no: u64, address: Address) -> AccountWithinBlock {
3131
let (account, state_proof) = get_account_unconstrained_M(chain_id, block_no, address);
3232
let header = get_header(chain_id, block_no);
3333
verify_account(address, account, state_proof, header.state_root);
@@ -36,13 +36,13 @@ pub fn get_account(chain_id: Field, block_no: u64, address: Address) -> AccountW
3636

3737
#[oracle(get_account)]
3838
unconstrained fn get_account_oracle<let PROOF_INPUT_LEN: u32>(
39-
_chain_id: Field,
39+
_chain_id: u32,
4040
_block_no: u64,
4141
_address: [u8; 20],
4242
) -> (Account, ProofInputSerialized<PROOF_INPUT_LEN>) {}
4343

4444
unconstrained fn get_account_unconstrained_M(
45-
chain_id: Field,
45+
chain_id: u32,
4646
block_no: u64,
4747
address: Address,
4848
) -> AccountWithStateProofM {

ethereum/circuits/lib/src/account_int_test.nr

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ use dep::std::test::OracleMock;
1818

1919
#[test]
2020
fn test_get_account_success() {
21-
let _ = OracleMock::mock("get_header").returns((block_header_partial, block_header_rlp));
22-
let _ = OracleMock::mock("get_account").returns((account, state_proof_input_serialized));
21+
// Unsafe: test
22+
let _ =
23+
unsafe { OracleMock::mock("get_header").returns((block_header_partial, block_header_rlp)) };
24+
// Unsafe: test
25+
let _ =
26+
unsafe { OracleMock::mock("get_account").returns((account, state_proof_input_serialized)) };
2327

2428
let account_within_block = get_account(ETHEREUM_MAINNET_ID, number, address);
2529

@@ -33,10 +37,14 @@ fn test_get_account_success() {
3337

3438
#[test(should_fail)]
3539
fn test_get_account_wrong_state_root() {
36-
let _ = OracleMock::mock("get_header").returns((block_header_partial, block_header_rlp));
37-
let _ = OracleMock::mock("get_account").returns((
38-
account_from_different_header, state_proof_input_from_different_header_serialized,
39-
));
40-
40+
// Unsafe: test
41+
let _ =
42+
unsafe { OracleMock::mock("get_header").returns((block_header_partial, block_header_rlp)) };
43+
// Unsafe: test
44+
let _ = unsafe {
45+
OracleMock::mock("get_account").returns((
46+
account_from_different_header, state_proof_input_from_different_header_serialized,
47+
))
48+
};
4149
let _ = get_account(ETHEREUM_MAINNET_ID, number, address_from_different_header);
4250
}

ethereum/circuits/lib/src/account_with_storage.nr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ struct StateAndStorageProofInput {
4545
}
4646

4747
pub struct StorageWithinBlock<let N: u32> {
48-
pub block_hash: Bytes32,
49-
account: Account,
50-
values: [Bytes32; N],
48+
pub(crate) block_hash: Bytes32,
49+
pub(crate) account: Account,
50+
pub(crate) values: [Bytes32; N],
5151
}
5252

5353
type ProofInputSerialized<let LEN: u32> = [Field; LEN];
@@ -101,7 +101,7 @@ fn get_storage_value(
101101
}
102102

103103
pub fn get_account_with_storage(
104-
chain_id: Field,
104+
chain_id: u32,
105105
block_number: u64,
106106
address: Address,
107107
storage_key: Bytes32,
@@ -125,14 +125,14 @@ pub fn get_account_with_storage(
125125

126126
#[oracle(get_proof)]
127127
unconstrained fn get_proof_oracle<let STATE_PROOF_INPUT_LEN: u32, let STORAGE_PROOF_INPUT: u32>(
128-
_chain_id: Field,
128+
_chain_id: u32,
129129
_block_no: u64,
130130
_address: Address,
131131
_storage_key: Bytes32,
132132
) -> (Account, ProofInputSerialized<STATE_PROOF_INPUT_LEN>, ProofInputSerialized<STORAGE_PROOF_INPUT>) {}
133133

134134
unconstrained fn get_proof_unconstrained(
135-
chain_id: Field,
135+
chain_id: u32,
136136
block_no: u64,
137137
address: Address,
138138
storage_key: Bytes32,

0 commit comments

Comments
 (0)