Skip to content

Commit

Permalink
chore: make structs pub (#8760)
Browse files Browse the repository at this point in the history
This makes all structs `pub` to remove the warnings associated with them
being private and therefore not available. Some structs we may wish to
keep private, or to only make them available inside the crate, but I
find that the vast majority should simply be public, and that's the
current behavior anyway since any module can import anything. We can
later make the exports more strict if desired.
  • Loading branch information
nventuro authored Sep 25, 2024
1 parent e92da1f commit 7bb2a38
Show file tree
Hide file tree
Showing 249 changed files with 1,814 additions and 362 deletions.
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/address-note/src/address_note.nr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use dep::aztec::{
// docs:start:address_note_struct
// Stores an address
#[note]
struct AddressNote {
pub struct AddressNote {
address: AztecAddress,
// The nullifying public key hash is used with the nsk_app to ensure that the note can be privately spent.
npk_m_hash: Field,
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/authwit/src/account.nr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use dep::aztec::{
use crate::entrypoint::{app::AppPayload, fee::FeePayload};
use crate::auth::{IS_VALID_SELECTOR, compute_authwit_message_hash};

struct AccountActions<Context> {
pub struct AccountActions<Context> {
context: Context,
is_valid_impl: fn(&mut PrivateContext, Field) -> bool,
}
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/authwit/src/entrypoint/app.nr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ global ACCOUNT_MAX_CALLS: u32 = 4;

// Note: If you change the following struct you have to update default_entrypoint.ts
// docs:start:app-payload-struct
struct AppPayload {
pub struct AppPayload {
function_calls: [FunctionCall; ACCOUNT_MAX_CALLS],
nonce: Field,
}
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ global FEE_PAYLOAD_SIZE_IN_BYTES: u32 = 228;
global MAX_FEE_FUNCTION_CALLS: u32 = 2;

// docs:start:fee-payload-struct
struct FeePayload {
pub struct FeePayload {
function_calls: [FunctionCall; MAX_FEE_FUNCTION_CALLS],
nonce: Field,
is_fee_payer: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ global FUNCTION_CALL_SIZE: u32 = 5;
// 3 * 32 + 2
global FUNCTION_CALL_SIZE_IN_BYTES: u32 = 98;

struct FunctionCall {
pub struct FunctionCall {
args_hash: Field,
function_selector: FunctionSelector,
target_address: AztecAddress,
Expand Down
18 changes: 9 additions & 9 deletions noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::context::{
use crate::oracle::arguments::pack_arguments;
use crate::hash::hash_args;

trait CallInterface<let N: u32, T, P, Env> {
pub trait CallInterface<let N: u32, T, P, Env> {
fn get_original(self) -> fn[Env](T) -> P;

fn get_args(self) -> [Field] {
Expand Down Expand Up @@ -41,7 +41,7 @@ impl<let N: u32, T, P, Env> CallInterface<N, PrivateContextInputs, PrivateCircui
}
}

struct PrivateCallInterface<let N: u32, T, Env> {
pub struct PrivateCallInterface<let N: u32, T, Env> {
target_contract: AztecAddress,
selector: FunctionSelector,
name: str<N>,
Expand Down Expand Up @@ -84,7 +84,7 @@ impl<let N: u32, T, P, Env> CallInterface<N, PrivateContextInputs, PrivateCircui
}
}

struct PrivateVoidCallInterface<let N: u32, Env> {
pub struct PrivateVoidCallInterface<let N: u32, Env> {
target_contract: AztecAddress,
selector: FunctionSelector,
name: str<N>,
Expand Down Expand Up @@ -123,7 +123,7 @@ impl<let N: u32, T, P, Env> CallInterface<N, PrivateContextInputs, PrivateCircui
}
}

struct PrivateStaticCallInterface<let N: u32, T, Env> {
pub struct PrivateStaticCallInterface<let N: u32, T, Env> {
target_contract: AztecAddress,
selector: FunctionSelector,
name: str<N>,
Expand All @@ -147,7 +147,7 @@ impl<let N: u32, T, P, Env> CallInterface<N, PrivateContextInputs, PrivateCircui
}
}

struct PrivateStaticVoidCallInterface<let N: u32, Env> {
pub struct PrivateStaticVoidCallInterface<let N: u32, Env> {
target_contract: AztecAddress,
selector: FunctionSelector,
name: str<N>,
Expand All @@ -170,7 +170,7 @@ impl<let N: u32, T, P, Env> CallInterface<N, PublicContextInputs, T, Env> for Pu
}
}

struct PublicCallInterface<let N: u32, T, Env> {
pub struct PublicCallInterface<let N: u32, T, Env> {
target_contract: AztecAddress,
selector: FunctionSelector,
name: str<N>,
Expand Down Expand Up @@ -244,7 +244,7 @@ impl<let N: u32, T, P, Env> CallInterface<N, PublicContextInputs, (), Env> for P
}
}

struct PublicVoidCallInterface<let N: u32, Env> {
pub struct PublicVoidCallInterface<let N: u32, Env> {
target_contract: AztecAddress,
selector: FunctionSelector,
name: str<N>,
Expand Down Expand Up @@ -318,7 +318,7 @@ impl<let N: u32, T, P, Env> CallInterface<N, PublicContextInputs, T, Env> for Pu
}
}

struct PublicStaticCallInterface<let N: u32, T, Env> {
pub struct PublicStaticCallInterface<let N: u32, T, Env> {
target_contract: AztecAddress,
selector: FunctionSelector,
name: str<N>,
Expand Down Expand Up @@ -359,7 +359,7 @@ impl<let N: u32, T, P, Env> CallInterface<N, PublicContextInputs, (), Env> for P
}
}

struct PublicStaticVoidCallInterface<let N: u32, Env> {
pub struct PublicStaticVoidCallInterface<let N: u32, Env> {
target_contract: AztecAddress,
selector: FunctionSelector,
name: str<N>,
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/context/gas.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
struct GasOpts {
pub struct GasOpts {
l2_gas: Option<Field>,
da_gas: Option<Field>,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use dep::protocol_types::{transaction::tx_context::TxContext, abis::{call_contex

// PrivateContextInputs are expected to be provided to each private function
// docs:start:private-context-inputs
struct PrivateContextInputs {
pub struct PrivateContextInputs {
call_context : CallContext,
historical_header: Header,
tx_context: TxContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::protocol_types::traits::Empty;

// These inputs will likely go away once the AVM processes 1 public kernel per enqueued call.
struct PublicContextInputs {
pub struct PublicContextInputs {
// TODO: Remove this structure and get calldata size at compile time.
calldata_length: Field,
// This is currently unused but it's here to avoid changing serialization.
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/context/packed_returns.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{hash::hash_args_array, oracle::returns::unpack_returns};
use dep::protocol_types::traits::Deserialize;

struct PackedReturns {
pub struct PackedReturns {
packed_returns: Field,
}

Expand Down
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/aztec/src/context/public_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::context::inputs::public_context_inputs::PublicContextInputs;
use crate::context::gas::GasOpts;
use crate::hash::ArgsHasher;

struct PublicContext {
pub struct PublicContext {
inputs: PublicContextInputs,
args_hash: Option<Field>
}
Expand Down Expand Up @@ -418,7 +418,7 @@ unconstrained fn storage_read_opcode(storage_slot: Field) -> Field {}
#[oracle(avmOpcodeStorageWrite)]
unconstrained fn storage_write_opcode(storage_slot: Field, value: Field) {}

struct FunctionReturns<let N: u32> {
pub struct FunctionReturns<let N: u32> {
values: [Field; N]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::protocol_types::{address::AztecAddress, traits::Deserialize};
use crate::oracle::{execution::{get_chain_id, get_version, get_contract_address, get_block_number}, storage::storage_read};

struct UnconstrainedContext {
pub struct UnconstrainedContext {
block_number: u32,
contract_address: AztecAddress,
version: Field,
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::keys::{point_to_symmetric_key::point_to_symmetric_key, public_keys::T

use std::aes128::aes128_encrypt;

struct EncryptedLogHeader {
pub struct EncryptedLogHeader {
address: AztecAddress,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use dep::protocol_types::{scalar::Scalar};
use std::aes128::aes128_encrypt;
use crate::keys::{point_to_symmetric_key::point_to_symmetric_key, public_keys::IvpkM};

struct EncryptedLogIncomingBody<let N: u32> {
pub struct EncryptedLogIncomingBody<let N: u32> {
plaintext: [u8; N * 32 + 64]
}

Expand Down Expand Up @@ -121,7 +121,7 @@ mod test {
buffer
}

fn compute_note_hash(self) -> Field {
fn compute_note_hash(_self: Self) -> Field {
crate::generators::Ga1.x
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::aes128::aes128_encrypt;

use crate::{keys::public_keys::IvpkM, utils::point::point_to_bytes};

struct EncryptedLogOutgoingBody {
pub struct EncryptedLogOutgoingBody {
eph_sk: Scalar,
recipient: AztecAddress,
recipient_ivpk: IvpkM,
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/hash.nr
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn compute_message_nullifier(message_hash: Field, secret: Field, leaf_index:
)
}

struct ArgsHasher {
pub struct ArgsHasher {
fields: [Field],
}

Expand Down
12 changes: 6 additions & 6 deletions noir-projects/aztec-nr/aztec/src/keys/public_keys.nr
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ use dep::protocol_types::{

global PUBLIC_KEYS_LENGTH: u32 = 12;

struct PublicKeys {
pub struct PublicKeys {
npk_m: NpkM,
ivpk_m: IvpkM,
ovpk_m: OvpkM,
tpk_m: TpkM,
}

trait ToPoint {
pub trait ToPoint {
fn to_point(self) -> Point;
}

struct NpkM {
pub struct NpkM {
inner: Point
}

Expand All @@ -40,7 +40,7 @@ impl Hash for NpkM {
}
}

struct IvpkM {
pub struct IvpkM {
inner: Point
}

Expand All @@ -56,7 +56,7 @@ impl Serialize<POINT_LENGTH> for IvpkM {
}
}

struct OvpkM {
pub struct OvpkM {
inner: Point
}

Expand All @@ -78,7 +78,7 @@ impl Serialize<POINT_LENGTH> for OvpkM {
}
}

struct TpkM {
pub struct TpkM {
inner: Point
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub(crate) comptime fn create_fn_abi_export(f: FunctionDefinition) -> Quoted {
$parameters

#[abi(functions)]
struct $abi_struct_name {
pub struct $abi_struct_name {
parameters: $parameters_struct_name,
$return_type
}
Expand Down
6 changes: 3 additions & 3 deletions noir-projects/aztec-nr/aztec/src/note/note_emission.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* A note emission struct containing the information required for emitting a note.
* The exact `emit` logic is passed in by the application code
*/
struct NoteEmission<Note> {
pub struct NoteEmission<Note> {
note: Note
}

Expand All @@ -23,10 +23,10 @@ impl<Note> NoteEmission<Note> {
* This is the struct provided to application codes, which can be used to emit
* only when a note was actually inserted.
* It is fairly common to have cases where a function conditionally inserts,
* and this allows us to keep the same API for emission in both cases (e.g. inserting
* and this allows us to keep the same API for emission in both cases (e.g. inserting
* a change note in a token's transfer function only when there is "change" left).
*/
struct OuterNoteEmission<Note> {
pub struct OuterNoteEmission<Note> {
emission: Option<NoteEmission<Note>>,
}

Expand Down
13 changes: 7 additions & 6 deletions noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use std::option::Option;
use dep::protocol_types::{constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, traits::ToField};
use crate::note::note_interface::NoteInterface;

struct PropertySelector {
pub struct PropertySelector {
index: u8, // index of the field in the serialized note array
offset: u8, // offset in the byte representation of the field (selected with index above) from which to reading
length: u8, // number of bytes to read after the offset
}

struct Select {
pub struct Select {
property_selector: PropertySelector,
comparator: u8,
value: Field,
Expand All @@ -22,7 +22,7 @@ impl Select {
}
}

struct SortOrderEnum {
pub struct SortOrderEnum {
DESC: u8,
ASC: u8,
}
Expand All @@ -32,7 +32,7 @@ global SortOrder = SortOrderEnum {
ASC: 2,
};

struct Sort {
pub struct Sort {
property_selector: PropertySelector,
order: u8,
}
Expand All @@ -43,7 +43,7 @@ impl Sort {
}
}

struct NoteStatusEnum {
pub struct NoteStatusEnum {
ACTIVE: u8,
ACTIVE_OR_NULLIFIED: u8,
}
Expand All @@ -54,6 +54,7 @@ global NoteStatus = NoteStatusEnum {
// TODO 4217: add 'NULLIFIED'
};

// This is the default filter and preprocessor, which does nothing
fn return_all_notes<Note>(
notes: [Option<Note>; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL],
_p: Field
Expand All @@ -62,7 +63,7 @@ fn return_all_notes<Note>(
}

// docs:start:NoteGetterOptions
struct NoteGetterOptions<Note, let N: u32, PREPROCESSOR_ARGS, FILTER_ARGS> {
pub struct NoteGetterOptions<Note, let N: u32, PREPROCESSOR_ARGS, FILTER_ARGS> {
selects: BoundedVec<Option<Select>, N>,
sorts: BoundedVec<Option<Sort>, N>,
limit: u32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::note::note_interface::NoteInterface;
use crate::note::constants::MAX_NOTES_PER_PAGE;

// docs:start:NoteViewerOptions
struct NoteViewerOptions<Note, let N: u32> {
pub struct NoteViewerOptions<Note, let N: u32> {
selects: BoundedVec<Option<Select>, N>,
sorts: BoundedVec<Option<Sort>, N>,
limit: u32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ global ARCHIVE_TREE_ID = 4;
//
// Another way to do it would be to add "type_hint: [Field; T]" as argument to `get_membership_witness` but that's
// a bit too boilerplatey for my taste.
struct MembershipWitness<let N: u32, let M: u32> {
pub struct MembershipWitness<let N: u32, let M: u32> {
index: Field,
path: [Field; N],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use dep::protocol_types::{
// INDEX_LENGTH + NULLIFIER_LEAF_PREIMAGE_LENGTH + NULLIFIER_TREE_HEIGHT
global NULLIFIER_MEMBERSHIP_WITNESS: u32 = 24;

struct NullifierMembershipWitness {
pub struct NullifierMembershipWitness {
index: Field,
leaf_preimage: NullifierLeafPreimage,
path: [Field; NULLIFIER_TREE_HEIGHT],
Expand Down
Loading

0 comments on commit 7bb2a38

Please sign in to comment.