Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
e1190bc
changed storage macro to look for attribute
Thunkar Mar 19, 2024
c41eba8
added abi exports to contract artifact
Thunkar Mar 22, 2024
6caea1e
changed storage macro to look for attribute
Thunkar Mar 19, 2024
01506c9
added abi exports to contract artifact
Thunkar Mar 22, 2024
3873a65
reverted change
Thunkar Mar 22, 2024
ce6b163
removed unused variable
Thunkar Mar 22, 2024
733f0ec
clippy pass
Thunkar Mar 22, 2024
9b6af4b
fixes and consistency
Thunkar Mar 22, 2024
ad2a62f
cleanup and test
Thunkar Mar 26, 2024
445b9e6
updated snapshots, types
Thunkar Mar 26, 2024
2124cfa
changed integer serialization
Thunkar Mar 26, 2024
3a388be
added abi exports to contract artifact
Thunkar Mar 22, 2024
85596ec
added abi exports to contract artifact
Thunkar Mar 22, 2024
46df9a5
reverted change
Thunkar Mar 22, 2024
0132139
clippy pass
Thunkar Mar 22, 2024
6545eec
wip
Thunkar Mar 22, 2024
7c6544f
wip
Thunkar Mar 22, 2024
efe757d
storage layout export and note ids
Thunkar Mar 26, 2024
82ca876
working storage layout and notes
Thunkar Mar 26, 2024
1fa96db
experimental support
Thunkar Mar 22, 2024
f367d15
updated snapshot
Thunkar Mar 26, 2024
84bf37a
better codegen and fixed test
Thunkar Mar 26, 2024
f1baaf0
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 26, 2024
614942a
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 26, 2024
3c0787c
Merge branch 'gj/contract_abi_exports' into gj/storage_layout
Thunkar Mar 26, 2024
e4cf336
Merge branch 'master' into gj/contract_abi_exports
Thunkar Mar 27, 2024
7b8eed6
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Mar 27, 2024
9f94e95
removed macro pass, general cleanup and fixes
Thunkar Mar 27, 2024
1e238d8
used in e2e, clippy
Thunkar Mar 27, 2024
28ce5e6
fixed snapshot
Thunkar Mar 27, 2024
edba6f1
prettier run
Thunkar Mar 27, 2024
654fa04
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Mar 27, 2024
423537e
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 27, 2024
99c5128
yet another snapshot. fun
Thunkar Mar 27, 2024
7227650
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 27, 2024
be95f17
Merge branch 'master' into gj/contract_abi_exports
Thunkar Mar 27, 2024
a176860
Merge branch 'gj/contract_abi_exports' into gj/storage_layout
Thunkar Mar 27, 2024
92e4397
Merge branch 'master' into gj/contract_abi_exports
Thunkar Mar 27, 2024
04b7b19
Merge branch 'gj/contract_abi_exports' into gj/storage_layout
Thunkar Mar 27, 2024
ba59549
Merge branch 'master' into gj/contract_abi_exports
Thunkar Mar 27, 2024
08a3374
Merge branch 'gj/contract_abi_exports' into gj/storage_layout
Thunkar Mar 27, 2024
328108f
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 1, 2024
a75c843
updated snapshots
Thunkar Apr 1, 2024
1c1e156
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 1, 2024
e4f75eb
merge changes
Thunkar Apr 1, 2024
80df865
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 1, 2024
5482aee
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 1, 2024
2859f5f
updated artifact hash
Thunkar Apr 1, 2024
53918d9
correct hash
Thunkar Apr 1, 2024
9a20ff4
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 1, 2024
3d8deb1
merge conflicts
Thunkar Apr 1, 2024
ccd1b7b
fmt
Thunkar Apr 1, 2024
f16ec80
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 2, 2024
622ef04
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 2, 2024
e0f2ca2
Update noir/noir-repo/aztec_macros/src/lib.rs
Thunkar Apr 2, 2024
b0b796e
Merge branch 'gj/contract_abi_exports' into gj/storage_layout
Thunkar Apr 2, 2024
d34e4a3
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 2, 2024
2d18874
guess what
Thunkar Apr 2, 2024
2e61cda
increased test machine size, hash
Thunkar Apr 2, 2024
9ab84fd
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 2, 2024
a6aa905
avoid oom
Thunkar Apr 2, 2024
4b8464d
PR changes
Thunkar Apr 2, 2024
0c175fd
more pr improvements
Thunkar Apr 2, 2024
db649f8
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 2, 2024
c2febc9
reverted abi tag error
Thunkar Apr 2, 2024
95e5025
clippy pass
Thunkar Apr 2, 2024
93b6cb1
Merge branch 'master' into gj/contract_abi_exports
Thunkar Apr 2, 2024
38e17fa
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 2, 2024
f5b158a
correct order
Thunkar Apr 2, 2024
bd89f36
reverted ci changes
Thunkar Apr 2, 2024
8f7d587
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 2, 2024
5ad4ce5
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 2, 2024
ef571c9
pr comment
Thunkar Apr 2, 2024
3b7d7b5
added tuple values
Thunkar Apr 2, 2024
ce404c9
removed unused import
Thunkar Apr 2, 2024
31996d9
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 2, 2024
2bcdac7
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 2, 2024
b673d1c
fixed integer conversion
Thunkar Apr 2, 2024
8feb6d4
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 2, 2024
1794b8e
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 2, 2024
fa353be
fixed constants
Thunkar Apr 2, 2024
7185448
fixed artifact hash
Thunkar Apr 2, 2024
ecd305b
changed approach
Thunkar Apr 3, 2024
45914ba
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 3, 2024
a586479
restrict abi tag again
Thunkar Apr 3, 2024
a8536aa
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 3, 2024
9479047
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 3, 2024
8a28659
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 3, 2024
6455797
clippy pass
Thunkar Apr 3, 2024
564f438
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 3, 2024
defffbb
updated snapshot
Thunkar Apr 3, 2024
0faea97
updated snapshot
Thunkar Apr 3, 2024
2ed4aaf
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 4, 2024
2e5d302
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 4, 2024
0329e06
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 4, 2024
95be1cd
fixed merge conflicts
Thunkar Apr 4, 2024
db2a411
hash
Thunkar Apr 4, 2024
7a2d041
removed repeated block
Thunkar Apr 4, 2024
e7ee0c2
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 4, 2024
cf1f97b
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 4, 2024
52c6db0
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 4, 2024
8e49bb5
Merge branch 'gj/contract_abi_exports' into gj/storage_layout
Thunkar Apr 4, 2024
940c39e
Merge branch 'gj/storage_layout' into gj_lh/fn_return_values
Thunkar Apr 4, 2024
f339ffb
updated artifact hash
Thunkar Apr 4, 2024
5d1bdcc
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 4, 2024
3e7cf15
updated artifact hash
Thunkar Apr 4, 2024
8861e7d
Merge branch 'master' into gj/storage_layout
Thunkar Apr 4, 2024
97372a9
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 4, 2024
9524c9c
merge conflicts
Thunkar Apr 4, 2024
a229328
another hash
Thunkar Apr 5, 2024
0a18551
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 8, 2024
7674111
added docs
Thunkar Apr 8, 2024
904a791
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 8, 2024
88e6858
migration notes
Thunkar Apr 8, 2024
c1b64b0
Merge branch 'gj/storage_layout' into gj_lh/fn_return_values
Thunkar Apr 8, 2024
d08e7bb
updated hash
Thunkar Apr 8, 2024
8a4d9fe
just to see ci fail
Thunkar Apr 8, 2024
cd60d9b
fix
Thunkar Apr 8, 2024
088536c
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 8, 2024
d7e2e22
guess what
Thunkar Apr 8, 2024
e631507
wait for red
Thunkar Apr 8, 2024
2b88ea2
merge conflicts
Thunkar Apr 8, 2024
7f99205
updated constants
Thunkar Apr 8, 2024
163b397
fix
Thunkar Apr 8, 2024
6e3ffe8
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 9, 2024
539e4ff
added comment
Thunkar Apr 9, 2024
bdc49d8
artifact hash
Thunkar Apr 9, 2024
81e7e6b
artifact hash
Thunkar Apr 9, 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 @@ -83,7 +83,7 @@ library Constants {
uint256 internal constant DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE =
0x85864497636cf755ae7bde03f267ce01a520981c21c3682aaf82a631;
uint256 internal constant DEPLOYER_CONTRACT_ADDRESS =
0x12bcd3e09e8d8559c75d59552db47471f63c72fbbc9decb59c517b4e58634a72;
0x1b628eeb6349f2a4c000b703942eb8a625bfe5e6ee34ccc210748cf9ae05af98;
uint256 internal constant L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 17;
uint256 internal constant MAX_NOTE_FIELDS_LENGTH = 20;
uint256 internal constant GET_NOTE_ORACLE_RETURN_LENGTH = 23;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ global REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE = 0xe7af8166354
// CONTRACT INSTANCE CONSTANTS
// sha224sum 'struct ContractInstanceDeployed'
global DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE = 0x85864497636cf755ae7bde03f267ce01a520981c21c3682aaf82a631;
global DEPLOYER_CONTRACT_ADDRESS = 0x12bcd3e09e8d8559c75d59552db47471f63c72fbbc9decb59c517b4e58634a72;
global DEPLOYER_CONTRACT_ADDRESS = 0x1b628eeb6349f2a4c000b703942eb8a625bfe5e6ee34ccc210748cf9ae05af98;

// NOIR CONSTANTS - constants used only in yarn-packages/noir-contracts
// Some are defined here because Noir doesn't yet support globals referencing other globals yet.
Expand Down
3 changes: 2 additions & 1 deletion noir/noir-repo/aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod utils;
use transforms::{
compute_note_hash_and_nullifier::inject_compute_note_hash_and_nullifier,
events::{generate_selector_impl, transform_events},
functions::{transform_function, transform_unconstrained},
functions::{export_fn_abi, transform_function, transform_unconstrained},
note_interface::{generate_note_interface_impl, inject_note_exports},
storage::{
assign_storage_slots, check_for_storage_definition, check_for_storage_implementation,
Expand Down Expand Up @@ -129,6 +129,7 @@ fn transform_module(module: &mut SortedModule) -> Result<bool, AztecMacroError>

// Apply transformations to the function based on collected attributes
if is_private || is_public || is_public_vm {
export_fn_abi(&mut module.types, func)?;
transform_function(
if is_private {
"Private"
Expand Down
94 changes: 90 additions & 4 deletions noir/noir-repo/aztec_macros/src/transforms/functions.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use convert_case::{Case, Casing};
use noirc_errors::Span;
use noirc_frontend::{
macros_api::FieldElement, BlockExpression, ConstrainKind, ConstrainStatement, Distinctness,
Expression, ExpressionKind, ForLoopStatement, ForRange, FunctionReturnType, Ident, Literal,
NoirFunction, Param, PathKind, Pattern, Signedness, Statement, StatementKind, UnresolvedType,
UnresolvedTypeData, Visibility,
macros_api::FieldElement, parse_program, BlockExpression, ConstrainKind, ConstrainStatement,
Distinctness, Expression, ExpressionKind, ForLoopStatement, ForRange, FunctionReturnType,
Ident, Literal, NoirFunction, NoirStruct, Param, PathKind, Pattern, Signedness, Statement,
StatementKind, UnresolvedType, UnresolvedTypeData, Visibility,
};

use crate::{
Expand Down Expand Up @@ -113,6 +113,92 @@ pub fn transform_function(
Ok(())
}

// Generates a global struct containing the original (before transform_function gets executed) function abi that gets exported
// in the contract artifact after compilation. The abi will be later used to decode the function return values in the simulator.
pub fn export_fn_abi(
types: &mut Vec<NoirStruct>,
func: &NoirFunction,
) -> Result<(), AztecMacroError> {
let mut parameters_struct_source: Option<&str> = None;

let struct_source = format!(
"
struct {}_parameters {{
{}
}}
",
func.name(),
func.parameters()
.iter()
.map(|param| {
let param_name = match param.pattern.clone() {
Pattern::Identifier(ident) => Ok(ident.0.contents),
_ => Err(AztecMacroError::CouldNotExportFunctionAbi {
span: Some(param.span),
secondary_message: Some(
"Only identifier patterns are supported".to_owned(),
),
}),
};

format!(
"{}: {}",
param_name.unwrap(),
param.typ.typ.to_string().replace("plain::", "")
)
})
.collect::<Vec<String>>()
.join(",\n"),
);

if !func.parameters().is_empty() {
parameters_struct_source = Some(&struct_source);
}

let mut program = String::new();

let parameters = if let Some(parameters_struct_source) = parameters_struct_source {
program.push_str(parameters_struct_source);
format!("parameters: {}_parameters,\n", func.name())
} else {
"".to_string()
};

let return_type_str = func.return_type().typ.to_string().replace("plain::", "");
let return_type = if return_type_str != "()" {
format!("return_type: {},\n", return_type_str)
} else {
"".to_string()
};

let export_struct_source = format!(
"
#[abi(functions)]
struct {}_abi {{
{}{}
}}",
func.name(),
parameters,
return_type
);

program.push_str(&export_struct_source);

let (ast, errors) = parse_program(&program);
if !errors.is_empty() {
return Err(AztecMacroError::CouldNotExportFunctionAbi {
span: None,
secondary_message: Some(
format!("Failed to parse Noir macro code (struct {}_abi). This is either a bug in the compiler or the Noir macro code", func.name())
)
});
}

let sorted_ast = ast.into_sorted();
types.extend(sorted_ast.types);
Ok(())
}

/// Transform Unconstrained
///
/// Inserts the following code at the beginning of an unconstrained function
Expand Down
6 changes: 6 additions & 0 deletions noir/noir-repo/aztec_macros/src/utils/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub enum AztecMacroError {
CouldNotImplementNoteInterface { span: Option<Span>, secondary_message: Option<String> },
MultipleStorageDefinitions { span: Option<Span> },
CouldNotExportStorageLayout { span: Option<Span>, secondary_message: Option<String> },
CouldNotExportFunctionAbi { span: Option<Span>, secondary_message: Option<String> },
EventError { span: Span, message: String },
UnsupportedAttributes { span: Span, secondary_message: Option<String> },
}
Expand Down Expand Up @@ -60,6 +61,11 @@ impl From<AztecMacroError> for MacroError {
secondary_message,
span,
},
AztecMacroError::CouldNotExportFunctionAbi { secondary_message, span } => MacroError {
primary_message: "Could not generate and export function abi".to_string(),
secondary_message,
span,
},
AztecMacroError::EventError { span, message } => MacroError {
primary_message: message,
secondary_message: None,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE =
0xe7af816635466f128568edb04c9fa024f6c87fb9010fdbffa68b3d99n;
export const DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE =
0x85864497636cf755ae7bde03f267ce01a520981c21c3682aaf82a631n;
export const DEPLOYER_CONTRACT_ADDRESS = 0x12bcd3e09e8d8559c75d59552db47471f63c72fbbc9decb59c517b4e58634a72n;
export const DEPLOYER_CONTRACT_ADDRESS = 0x1b628eeb6349f2a4c000b703942eb8a625bfe5e6ee34ccc210748cf9ae05af98n;
export const L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 17;
export const MAX_NOTE_FIELDS_LENGTH = 20;
export const GET_NOTE_ORACLE_RETURN_LENGTH = 23;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('ArtifactHash', () => {
it('calculates the artifact hash', () => {
const artifact = getBenchmarkContractArtifact();
expect(computeArtifactHash(artifact).toString()).toMatchInlineSnapshot(
`"0x011603d7f02ebec628e8f1b2458edff811648ea3af5399cec32302aab6217b26"`,
`"0x2000991c126ffc45142660f7c3ad26f65aeb853a3b9c7e5906ba8205a2556128"`,
);
});
});