You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PublicImmutable Storage struct is expected to hold arbitrary data types provided as template parameters. While this functionality works for ordinary elements, like Field, it fails when attempting to use arrays such as [Field; 3]. The compiler crashes with a panic.
use dep::aztec::macros::aztec;#[aztec]
contract ArrayPublicImmutable{
use aztec::macros::{functions::{initializer, public},storage::storage};use aztec::prelude::PublicImmutable;#[storage]structStorage<Context>{state:PublicImmutable<[Field;3],Context>,}#[initializer]#[public]fninitialize(arr:[Field;3]){
storage.state.initialize(arr);}}
Compile the contract:
aztec-nargo compile
Check the error log.
error: Assertionfailed
┌─ std/option.nr:33:16
│
33 │ assert(self._is_some);
│ -------------
│
=Callstack:
[..omitted]
error: Couldnotresolve'init' inpath
┌─ src/main.nr:19:1
│
19 │
│
│
error: Objecttypeisunknowninfieldaccess
┌─ src/main.nr:16:17
│
16 │ storage.state.initialize(arr);
│ ----- Type must be known by this point
│
=TryaddingatypeannotationfortheobjecttypebeforethisexpressionAbortingdueto3previouserrors
Expected Behavior
The PublicImmutable Storage struct should seamlessly handle arrays like [Field; 3] without any issues.
Actual Behavior
The program crashes with a panic when trying to use [Field; 3] as the parameter.
Notes
The bug occurs in noir-projects/aztec-nr/aztec/src/macros/utils.nr:227:5. Here, the program tries to compute the serialized size of the element provided as the template parameter, which apparently does not work for arrays.
I implemented a temporary fix for my use case, but someone with more expertise should address this properly.
The text was updated successfully, but these errors were encountered:
Version
I am using
aztec-packages-v0.69.1
.Problem
The
PublicImmutable
Storage struct is expected to hold arbitrary data types provided as template parameters. While this functionality works for ordinary elements, likeField
, it fails when attempting to use arrays such as[Field; 3]
. The compiler crashes with a panic.Steps to Reproduce
Setup inspired by the Counter Tutorial:
mkdir immutable-array cd immutable-array mkdir contracts
cd contracts aztec-nargo new --contract immutable_array
Nargo.toml
:Expected Behavior
The
PublicImmutable
Storage struct should seamlessly handle arrays like[Field; 3]
without any issues.Actual Behavior
The program crashes with a panic when trying to use
[Field; 3]
as the parameter.Notes
The bug occurs in
noir-projects/aztec-nr/aztec/src/macros/utils.nr:227:5
. Here, the program tries to compute the serialized size of the element provided as the template parameter, which apparently does not work for arrays.I implemented a temporary fix for my use case, but someone with more expertise should address this properly.
The text was updated successfully, but these errors were encountered: