Skip to content
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: View functions with static context enforcing #6338

Merged
merged 59 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
06ec063
wip
Thunkar May 7, 2024
488220b
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 7, 2024
480c568
wip
Thunkar May 7, 2024
20fb28a
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 8, 2024
462b372
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 8, 2024
18ab020
wip
Thunkar May 8, 2024
8b2eba1
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 9, 2024
e3a1fb0
added dep
Thunkar May 9, 2024
067e2b8
wip
Thunkar May 10, 2024
6588645
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 10, 2024
633e23d
fix
Thunkar May 10, 2024
e417335
fix
Thunkar May 10, 2024
874f6c6
working version
Thunkar May 10, 2024
aec8ced
removed isStatic from entrypoints
Thunkar May 10, 2024
3efc83c
updated constants
Thunkar May 10, 2024
3317312
fixed eq
Thunkar May 13, 2024
d62a168
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 13, 2024
f875ba6
avm working, renaming, lsp
Thunkar May 13, 2024
9d129e0
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 13, 2024
efc5c6f
renaming
Thunkar May 13, 2024
bf501bd
clippy pass
Thunkar May 13, 2024
503058c
comments from review
Thunkar May 14, 2024
dfc965f
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 14, 2024
54d9cc5
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 14, 2024
884d8e4
updated snapshots
Thunkar May 14, 2024
7b26b42
entrypoints now return values
Thunkar May 14, 2024
80aba0c
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 14, 2024
8d11eef
removed only
Thunkar May 14, 2024
b5134a6
uncommented test code, added comment
Thunkar May 14, 2024
f3bd8c0
recursive retrieval of return values from callstack
Thunkar May 16, 2024
7ac837d
corrected avm assertion tests
Thunkar May 16, 2024
652dcd5
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 16, 2024
dd99093
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 16, 2024
3b3ac95
updated snapshots and merge changes
Thunkar May 16, 2024
26c7440
Merge branch 'master' into gj/contract_fn_mutability
Thunkar May 16, 2024
5c7326f
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 16, 2024
e0b6144
Merge branch 'gj/contract_fn_mutability' of github.com:AztecProtocol/…
Thunkar May 16, 2024
8c13b54
updated error messages in test
Thunkar May 16, 2024
652a6d1
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 17, 2024
1e00571
updated fixtures
Thunkar May 17, 2024
751c0d6
corrected from
Thunkar May 17, 2024
f21c900
added migration notes
Thunkar May 17, 2024
b9e1c7e
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 17, 2024
52db791
missing migration notes
Thunkar May 17, 2024
9566571
error messages and fixtures
Thunkar May 17, 2024
d134298
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 17, 2024
492728b
comments from PR review
Thunkar May 17, 2024
2c17e7a
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 17, 2024
4c0a8a3
prettier pass
Thunkar May 17, 2024
da7a733
fixed imports
Thunkar May 17, 2024
52f3382
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 17, 2024
8552b7a
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 17, 2024
c0c2555
updated snapshots for the upteenth time
Thunkar May 17, 2024
9f60bf4
Merge branch 'master' into gj/contract_fn_mutability
Thunkar May 17, 2024
015cc3c
Merge branch 'master' into gj/contract_fn_mutability
Thunkar May 17, 2024
c5a5ee1
Merge branch 'master' into gj/contract_fn_mutability
Thunkar May 17, 2024
e5deb6a
fix list of avm opcodes in cpp
dbanks12 May 18, 2024
0035d2e
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar May 20, 2024
66c294d
Merge branch 'gj/contract_fn_mutability' of github.com:AztecProtocol/…
Thunkar May 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ library Constants {
uint256 internal constant CONTRACT_STORAGE_READ_LENGTH = 2;
uint256 internal constant CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH = 2;
uint256 internal constant ETH_ADDRESS_LENGTH = 1;
uint256 internal constant FUNCTION_DATA_LENGTH = 2;
uint256 internal constant FUNCTION_DATA_LENGTH = 3;
Thunkar marked this conversation as resolved.
Show resolved Hide resolved
uint256 internal constant FUNCTION_LEAF_PREIMAGE_LENGTH = 5;
uint256 internal constant GLOBAL_VARIABLES_LENGTH = 6 + GAS_FEES_LENGTH;
uint256 internal constant APPEND_ONLY_TREE_SNAPSHOT_LENGTH = 2;
Expand Down
10 changes: 5 additions & 5 deletions l1-contracts/test/fixtures/empty_block_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x092e7b5812f430a11de252abb67ba28c237b78aa717cf67a0a7d13ac229cb476",
"archive": "0x1b453eef755f3b6f9c2cbbdb22452273a2d686e39530f7a7d3171e9865283f9f",
"body": "0x00000000",
"txsEffectsHash": "0x0041e05321b3603fcde9458e9c664d50a08187c7fdeeb6a1cf39932849df577c",
"decodedHeader": {
Expand All @@ -23,8 +23,8 @@
"chainId": 31337,
"timestamp": 0,
"version": 1,
"coinbase": "0xb35cee29ec094ab8b8be05b158e0bf50d2432952",
"feeRecipient": "0x2e318034e3a2c52d895e8af8e14f8b95c5e49c461d12b4657ab8c85539013b02",
"coinbase": "0xfcf4475898af95a08b5d46753a19a6d0b07875fe",
"feeRecipient": "0x2353452624444e5e66095f3efd3a4800675d16f07d29ee67be84ff1e5757227c",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
Expand Down Expand Up @@ -55,8 +55,8 @@
}
}
},
"header": "0x067a48e3140b6f15d71751ededfa0cccde3d436bb71aa7fec226b0bfe51dc5cf0000000100000000000000000000000000000000000000000000000000000000000000010041e05321b3603fcde9458e9c664d50a08187c7fdeeb6a1cf39932849df577c00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000001016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000000800bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000001000572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000000800000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000b35cee29ec094ab8b8be05b158e0bf50d24329522e318034e3a2c52d895e8af8e14f8b95c5e49c461d12b4657ab8c85539013b0200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00ae98c27e880d898c1dd0cdb9b2da88de6719f7b3bf0707a4f13381ac22dce8",
"header": "0x067a48e3140b6f15d71751ededfa0cccde3d436bb71aa7fec226b0bfe51dc5cf0000000100000000000000000000000000000000000000000000000000000000000000010041e05321b3603fcde9458e9c664d50a08187c7fdeeb6a1cf39932849df577c00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000001016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000000800bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000001000572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000000800000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000fcf4475898af95a08b5d46753a19a6d0b07875fe2353452624444e5e66095f3efd3a4800675d16f07d29ee67be84ff1e5757227c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x0061426d084f86e2e86e94fc4211130129f4cc29b3fe84452ce79cf76bb0ea0b",
"numTxs": 0
}
}
14 changes: 7 additions & 7 deletions l1-contracts/test/fixtures/empty_block_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x0a195ab304da7c6cf916ff7a40cb570f728481aac14b2d5df776c5306d0671f5",
"archive": "0x214645523614db0a5f9388fc00135e2f4dbe4da5ab7e5d1e1928d6c70774cc1d",
"body": "0x00000000",
"txsEffectsHash": "0x0041e05321b3603fcde9458e9c664d50a08187c7fdeeb6a1cf39932849df577c",
"decodedHeader": {
Expand All @@ -21,18 +21,18 @@
"globalVariables": {
"blockNumber": 2,
"chainId": 31337,
"timestamp": 1714575319,
"timestamp": 1715355875,
"version": 1,
"coinbase": "0xb35cee29ec094ab8b8be05b158e0bf50d2432952",
"feeRecipient": "0x2e318034e3a2c52d895e8af8e14f8b95c5e49c461d12b4657ab8c85539013b02",
"coinbase": "0xfcf4475898af95a08b5d46753a19a6d0b07875fe",
"feeRecipient": "0x2353452624444e5e66095f3efd3a4800675d16f07d29ee67be84ff1e5757227c",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
}
},
"lastArchive": {
"nextAvailableLeafIndex": 2,
"root": "0x092e7b5812f430a11de252abb67ba28c237b78aa717cf67a0a7d13ac229cb476"
"root": "0x1b453eef755f3b6f9c2cbbdb22452273a2d686e39530f7a7d3171e9865283f9f"
},
"stateReference": {
"l1ToL2MessageTree": {
Expand All @@ -55,8 +55,8 @@
}
}
},
"header": "0x092e7b5812f430a11de252abb67ba28c237b78aa717cf67a0a7d13ac229cb4760000000200000000000000000000000000000000000000000000000000000000000000010041e05321b3603fcde9458e9c664d50a08187c7fdeeb6a1cf39932849df577c00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000002016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000001000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000001800572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000000c00000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000663257d7b35cee29ec094ab8b8be05b158e0bf50d24329522e318034e3a2c52d895e8af8e14f8b95c5e49c461d12b4657ab8c85539013b0200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00dde76c303e0e4d99151f2178e0b6cca10687f5a956084cae2fe6d320e3b9ec",
"header": "0x1b453eef755f3b6f9c2cbbdb22452273a2d686e39530f7a7d3171e9865283f9f0000000200000000000000000000000000000000000000000000000000000000000000010041e05321b3603fcde9458e9c664d50a08187c7fdeeb6a1cf39932849df577c00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000002016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000001000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000001800572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000000c00000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000663e40e3fcf4475898af95a08b5d46753a19a6d0b07875fe2353452624444e5e66095f3efd3a4800675d16f07d29ee67be84ff1e5757227c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00f1efe2694bd2a1d0cce8e628b805d687cec041a30f24f873f4538e23c8d4b3",
"numTxs": 0
}
}
10 changes: 5 additions & 5 deletions l1-contracts/test/fixtures/mixed_block_0.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions l1-contracts/test/fixtures/mixed_block_1.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions noir-projects/aztec-nr/authwit/src/entrypoint/app.nr
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use dep::aztec::protocol_types::{constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD,
use crate::entrypoint::function_call::{FunctionCall, FUNCTION_CALL_SIZE_IN_BYTES};

// FUNCTION_CALL_SIZE * ACCOUNT_MAX_CALLS + 1
global APP_PAYLOAD_SIZE: u64 = 17;
global APP_PAYLOAD_SIZE: u64 = 21;
// FUNCTION_CALL_SIZE_IN_BYTES * ACCOUNT_MAX_CALLS + 32
global APP_PAYLOAD_SIZE_IN_BYTES: u64 = 420;
global APP_PAYLOAD_SIZE_IN_BYTES: u64 = 424;

global ACCOUNT_MAX_CALLS: u64 = 4;

Expand Down Expand Up @@ -62,15 +62,15 @@ impl AppPayload {
call.target_address,
call.function_selector,
call.args_hash,
false,
call.is_static,
Thunkar marked this conversation as resolved.
Show resolved Hide resolved
false
);
} else {
let _result = context.call_private_function_with_packed_args(
call.target_address,
call.function_selector,
call.args_hash,
false,
call.is_static,
false
);
}
Expand Down
12 changes: 6 additions & 6 deletions noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use dep::aztec::prelude::PrivateContext;
use dep::aztec::protocol_types::{constants::GENERATOR_INDEX__FEE_PAYLOAD, hash::pedersen_hash, traits::{Hash, Serialize}};
use crate::entrypoint::function_call::FunctionCall;

// 2 * 4 (function call) + 1
global FEE_PAYLOAD_SIZE: Field = 9;
// 2 * 5 (function call) + 1
global FEE_PAYLOAD_SIZE: Field = 11;

// 2*97 + 32
global FEE_PAYLOAD_SIZE_IN_BYTES: Field = 226;
// 2*98 + 32
Thunkar marked this conversation as resolved.
Show resolved Hide resolved
global FEE_PAYLOAD_SIZE_IN_BYTES: Field = 228;

global MAX_FEE_FUNCTION_CALLS = 2;

Expand Down Expand Up @@ -58,15 +58,15 @@ impl FeePayload {
call.target_address,
call.function_selector,
call.args_hash,
false,
call.is_static,
false
);
} else {
let _result = context.call_private_function_with_packed_args(
call.target_address,
call.function_selector,
call.args_hash,
false,
call.is_static,
false
);
}
Expand Down
12 changes: 7 additions & 5 deletions noir-projects/aztec-nr/authwit/src/entrypoint/function_call.nr
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress, traits::Serialize};

// 1 (ARGS_HASH) + 1 (FUNCTION_SELECTOR) + 1 (TARGET_ADDRESS) + 1 (IS_PUBLIC)
global FUNCTION_CALL_SIZE: Field = 4;
// 3 * 32 + 1
global FUNCTION_CALL_SIZE_IN_BYTES: Field = 97;
// 1 (ARGS_HASH) + 1 (FUNCTION_SELECTOR) + 1 (TARGET_ADDRESS) + 1 (IS_PUBLIC) + 1 (IS_STATIC)
global FUNCTION_CALL_SIZE: Field = 5;
// 3 * 32 + 2
global FUNCTION_CALL_SIZE_IN_BYTES: Field = 98;
Thunkar marked this conversation as resolved.
Show resolved Hide resolved

struct FunctionCall {
args_hash: Field,
function_selector: FunctionSelector,
target_address: AztecAddress,
is_public: bool,
is_static: bool,
}

impl Serialize<FUNCTION_CALL_SIZE> for FunctionCall {
fn serialize(self) -> [Field; FUNCTION_CALL_SIZE] {
[self.args_hash, self.function_selector.to_field(), self.target_address.to_field(), self.is_public as Field]
[self.args_hash, self.function_selector.to_field(), self.target_address.to_field(), self.is_public as Field, self.is_static as Field]
}
}

Expand All @@ -34,6 +35,7 @@ impl FunctionCall {
bytes[i + 64] = target_address_bytes[i];
}
bytes[96] = self.is_public as u8;
bytes[97] = self.is_static as u8;
bytes
}
}
10 changes: 7 additions & 3 deletions noir-projects/aztec-nr/aztec/src/context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ mod private_context;
mod public_context;
mod avm_context;
mod interface;
mod call_interfaces;
mod gas;

use interface::{
ContextInterface, PrivateCallInterface, PublicCallInterface, PrivateVoidCallInterface,
PublicVoidCallInterface, AvmCallInterface, AvmVoidCallInterface
use interface::ContextInterface;
use call_interfaces::{
PrivateCallInterface, PrivateStaticCallInterface, PublicCallInterface, PublicStaticCallInterface,
PrivateVoidCallInterface, PrivateStaticVoidCallInterface, PublicVoidCallInterface,
PublicStaticVoidCallInterface, AvmCallInterface, AvmStaticCallInterface, AvmVoidCallInterface,
AvmStaticVoidCallInterface
};
use private_context::PrivateContext;
use private_context::PackedReturns;
Expand Down
Loading
Loading