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

Corrupted bounded vec after branch not taken #4600

Closed
sirasistant opened this issue Mar 20, 2024 · 9 comments · Fixed by #4783
Closed

Corrupted bounded vec after branch not taken #4600

sirasistant opened this issue Mar 20, 2024 · 9 comments · Fixed by #4783
Labels
bug Something isn't working

Comments

@sirasistant
Copy link
Contributor

sirasistant commented Mar 20, 2024

Aim

Running in the aztec sandbox this test that runs this function

    #[aztec(private)]
    fn request_attestation(
        from: AztecAddress,
        attestor: AztecAddress,
        blacklist_root: Field,
        proofs: [Field; DEPTH * BOUNDED_VEC_LEN],
        nonce: Field
    ) {
        if (!from.eq(context.msg_sender())) {
            assert_current_call_valid_authwit(&mut context, from);
        } else {
            assert(nonce == 0, "invalid nonce");
        }

        let maybe_note = storage.balances.last_unattested_note(from, attestor);
        if maybe_note.is_some() {
            let note = maybe_note.unwrap_unchecked();

            let attested = Attestor::at(attestor).request_attestation(&mut context, note.partition_table, blacklist_root, proofs)[0] as bool;
            if attested {
                storage.balances.add_attestation(from, note, attestor);
            }
        }
    }

Expected Behavior

The function should run normally

Bug

The simulator complains that the private_call_stack_hashes exposed by the function do not match the oracle calls emitted to call other functions. Digging into the code with debug logs:

    #[aztec(private)]
    fn request_attestation(
        from: AztecAddress,
        attestor: AztecAddress,
        blacklist_root: Field,
        proofs: [Field; DEPTH * BOUNDED_VEC_LEN],
        nonce: Field
    ) {
        dep::aztec::oracle::debug_log::debug_log_array_with_prefix(
            "Start request_attestation",
            context.private_call_stack_hashes.storage
        );
        if (!from.eq(context.msg_sender())) {
            assert_current_call_valid_authwit(&mut context, from);
        } else {
            assert(nonce == 0, "invalid nonce");
        }

        let maybe_note = storage.balances.last_unattested_note(from, attestor);
        dep::aztec::oracle::debug_log::debug_log_array_with_prefix("Maybe_note is some", [maybe_note.is_some()]);
        if maybe_note.is_some() {
            let note = maybe_note.unwrap_unchecked();

            let attested = Attestor::at(attestor).request_attestation(&mut context, note.partition_table, blacklist_root, proofs)[0] as bool;
            dep::aztec::oracle::debug_log::debug_log_array_with_prefix("Attested", [attested]);
            dep::aztec::oracle::debug_log::debug_log_array_with_prefix("Before if", context.private_call_stack_hashes.storage);
            if attested {
                dep::aztec::oracle::debug_log::debug_log_array_with_prefix(
                    "Should not appear",
                    context.private_call_stack_hashes.storage
                );
                storage.balances.add_attestation(from, note, attestor);
            }
            dep::aztec::oracle::debug_log::debug_log_array_with_prefix("After if", context.private_call_stack_hashes.storage);
        }
    }

We can see that the bounded vec that stores the private_call_stack_hashes gets corrupted after the if attested {} that is not taken in runtime:

2024-03-20T13:56:52.766Z aztec:simulator:oracle Start request_attestation: 0x00000000
2024-03-20T13:56:53.106Z aztec:simulator:oracle Maybe_note is some: 0x0000000000000000000000000000000000000000000000000000000000000001
2024-03-20T13:56:53.468Z aztec:simulator:oracle Attested: 0x0000000000000000000000000000000000000000000000000000000000000000
2024-03-20T13:56:53.468Z aztec:simulator:oracle Before if: [0x013fd03529742b8117424d1ed6c26da57fbc732224fa42976c2544b644b5f15a, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000]
2024-03-20T13:56:53.497Z aztec:simulator:oracle After if: [0x013fd03529742b8117424d1ed6c26da57fbc732224fa42976c2544b644b5f15a, 0x013fd03529742b8117424d1ed6c26da57fbc732224fa42976c2544b644b5f15a, 0x013fd03529742b8117424d1ed6c26da57fbc732224fa42976c2544b644b5f15a, 0x013fd03529742b8117424d1ed6c26da57fbc732224fa42976c2544b644b5f15a]

Where the initial item gets duplicated to all other items.
The call_stack_item_hashes is only written in assert_current_call_valid_authwit (which isn't executed, so no item is pushed) and request_attestation (which is executed, and that where the initial item that gets duplicated comes from)

To Reproduce

  1. Clone the repo
  2. aztec-up 0.29.0
  3. run yarn compile && yarn codegen && yarn test -t "Request attestation after blacklisting"

Project Impact

None

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Installation Method

None

Nargo Version

No response

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@sirasistant sirasistant added the bug Something isn't working label Mar 20, 2024
@sirasistant
Copy link
Contributor Author

I'm trying to get a minimal reproduction, but it's quite a bit complicated

@sirasistant
Copy link
Contributor Author

Note: rewriting it in this form:

    #[aztec(private)]
    fn request_attestation(
        from: AztecAddress,
        attestor: AztecAddress,
        blacklist_root: Field,
        proofs: [Field; DEPTH * BOUNDED_VEC_LEN],
        nonce: Field
    ) {
        if (!from.eq(context.msg_sender())) {
            assert_current_call_valid_authwit(&mut context, from);
        } else {
            assert(nonce == 0, "invalid nonce");
        }

        let maybe_note = storage.balances.last_unattested_note(from, attestor);
        let mut attested = false;

        if maybe_note.is_some() {
            let note = maybe_note.unwrap_unchecked();

            attested = Attestor::at(attestor).request_attestation(&mut context, note.partition_table, blacklist_root, proofs)[0] as bool;
        }

        if attested {
            storage.balances.add_attestation(from, maybe_note.unwrap(), attestor);
        }
    }

Makes the corruption no longer happen

@sirasistant
Copy link
Contributor Author

Unfortunately I didn't manage to simplify it to a point where the SSA isn't huge :/

@TomAFrench
Copy link
Member

I'm thinking that we should make the --show-ssa more selective. Oftentimes we are interested in a single pass but get a wall of text where the majority is irrelevant.

@sirasistant
Copy link
Contributor Author

sirasistant commented Mar 21, 2024

This is the simplest I could make it while still reproducing the corruption:

  use crate::types::token_note::OwnedNote;
    use dep::aztec::protocol_types::{
        constants::{MAX_NOTES_PER_PAGE, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL},
        abis::side_effect::{SideEffect, SideEffectLinkedToNoteHash}
    };
    use dep::aztec::context::{PrivateContext, PublicContext, Context};
    use dep::aztec::note::{
        lifecycle::{create_note, create_note_hash_from_public, destroy_note},
        note_getter::{get_notes, view_notes}, note_interface::NoteInterface,
        note_viewer_options::NoteViewerOptions, utils::compute_note_hash_for_consumption
    };
    use dep::aztec::oracle::notes::{notify_created_note, notify_nullified_note};
    use dep::aztec::{hash::pedersen_hash};

    #[contract_library_method]
    fn compute_nullifier(hash: Field, account: AztecAddress, context: &mut PrivateContext) -> Field {
        let secret = context.request_nullifier_secret_key(account);
        pedersen_hash(
            [
            hash,
            secret.low,
            secret.high
        ],
            0
        )
    }

    // TODO: Recursively call `request_attestation` until all attestations are received?
    #[aztec(private)]
    fn request_attestation(
        from: AztecAddress,
        attestor: AztecAddress,
        blacklist_root: Field,
        proofs: [Field; DEPTH * BOUNDED_VEC_LEN],
        nonce: Field
    ) {
        dep::aztec::oracle::debug_log::debug_log_array_with_prefix(
            "Start request_attestation",
            context.private_call_stack_hashes.storage
        );
        if (!from.eq(context.msg_sender())) {
            assert_current_call_valid_authwit(&mut context, from);
        } else {
            assert(nonce == 0, "invalid nonce");
        }

        let maybe_note = storage.balances.last_unattested_note(from, attestor);
        let note = maybe_note.unwrap();

        let attested = Attestor::at(attestor).request_attestation(&mut context, note.partition_table, blacklist_root, proofs)[0] as bool;
        dep::aztec::oracle::debug_log::debug_log_array_with_prefix("Attested", [attested]);
        dep::aztec::oracle::debug_log::debug_log_array_with_prefix("Before if", context.private_call_stack_hashes.storage);
        if attested {
            dep::aztec::oracle::debug_log::debug_log_array_with_prefix(
                "Should not appear",
                context.private_call_stack_hashes.storage
            );

            let mut nullifier = 0;
            let mut consumed_note_hash: Field = 0;
            nullifier = compute_nullifier(27, from, &mut context);

            context.push_new_nullifier(nullifier, consumed_note_hash);
        }
        dep::aztec::oracle::debug_log::debug_log_array_with_prefix("After if", context.private_call_stack_hashes.storage);
    }

I've attached the SSA
ssa.zip

I think the corrupt private_call_stack_hashes are v750230, v750233, v750236, v750239. I think the last two items should always be zero and the compiler is not realizing it

The error still reproduces with this simpler (in SSA terms) code:

aztec-1     | 2024-03-21T11:18:04.905Z aztec:simulator:acvm Oracle callback debugLogWithPrefix
aztec-1     | 2024-03-21T11:18:04.905Z aztec:simulator:oracle Attested: 0x0000000000000000000000000000000000000000000000000000000000000000
aztec-1     | 2024-03-21T11:18:04.905Z aztec:simulator:acvm Oracle callback debugLogWithPrefix
aztec-1     | 2024-03-21T11:18:04.905Z aztec:simulator:oracle Before if: [0x28ffa2130e5ca1389da85a9d1fa3c8be24fc95033830541262d930f44f9e7d18, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000]
aztec-1     | 2024-03-21T11:18:04.909Z aztec:simulator:acvm Oracle callback debugLogWithPrefix
aztec-1     | 2024-03-21T11:18:04.909Z aztec:simulator:oracle After if: [0x28ffa2130e5ca1389da85a9d1fa3c8be24fc95033830541262d930f44f9e7d18, 0x28ffa2130e5ca1389da85a9d1fa3c8be24fc95033830541262d930f44f9e7d18, 0x28ffa2130e5ca1389da85a9d1fa3c8be24fc95033830541262d930f44f9e7d18, 0x28ffa2130e5ca1389da85a9d1fa3c8be24fc95033830541262d930f44f9e7d18]
aztec-1     | 2024-03-21T11:18:05.097Z aztec:simulator:secret_execution Returning from call to 0x013d5acf9aba0896f9286c637245fab484890922fb6962305ecabfa94ee0ed56:0x0717c66c

@sirasistant sirasistant changed the title Corrupted bounded vec after branch not took Corrupted bounded vec after branch not taken Apr 10, 2024
@spalladino
Copy link
Contributor

We seem to have hit a similar instance of this issue in the branch palla/04-09-fix_use_entrypoint_instead_of_pay_init_fee-with-a-stupid-number-of-logs of aztec-packages. Running ENABLE_GAS=1 yarn test e2e_account_init_fees -t 'minimal example for empty app payload issue' > log.txt 2>&1 in yarn-project/end-to-end should generate a log that showcases the error.

In this case, the function causing issues is this one:

    fn execute_calls(self, context: &mut PrivateContext) {
        dep::aztec::oracle::debug_log::debug_log("Starting execute calls");
        context.print_note_hash_read_requests();
        for call in self.function_calls {
            if !call.target_address.is_zero() {
                dep::aztec::oracle::debug_log::debug_log_format(
                    "Executing function call to={0} args={1}",
                    [call.target_address.to_field(), call.args_hash]
                );
                if call.is_public {
                    context.call_public_function_with_packed_args(
                        call.target_address,
                        call.function_selector,
                        call.args_hash,
                        false,
                        false
                    );
                } else {
                    let _result = context.call_private_function_with_packed_args(
                        call.target_address,
                        call.function_selector,
                        call.args_hash,
                        false,
                        false
                    );
                }
            }
        }
        dep::aztec::oracle::debug_log::debug_log("Ended execute calls");
        context.print_note_hash_read_requests();
    }

The logs that correspond to a run where self.function_calls is an array of empty structs (meaning target_address is zero for all of them, so the conditional is not taken, which can be seen in the logs by the absence of the debug log) show that the note_hash_read_requests of the PrivateContext (a BoundedVec in the struct) are filled with copies of the first two items:

2024-04-09T19:56:58.479Z aztec:simulator:oracle Starting execute calls
2024-04-09T19:56:58.479Z aztec:simulator:acvm Oracle callback debugLogWithPrefix
2024-04-09T19:56:58.479Z aztec:simulator:oracle Printing note hash read requests: [0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000]
2024-04-09T19:56:58.529Z aztec:simulator:acvm Oracle callback debugLog
2024-04-09T19:56:58.529Z aztec:simulator:oracle Ended execute calls
2024-04-09T19:56:58.529Z aztec:simulator:acvm Oracle callback debugLogWithPrefix
2024-04-09T19:56:58.529Z aztec:simulator:oracle Printing note hash read requests: [0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b, 0x060657913957bf5535951df734bc7886e9ccf62d9def3eb8c5c3d1196268773b]

We have also tried to reproduce this in a noir circuit outside aztec-packages, in noir-projects/bug-repro (note that compiling that one requires commenting out a few lines in noir-projects/noir-protocol-circuits/crates/types/src/debug_log.nr which are flagged with a note), but with no luck. Running nargo prove or nargo test there works fine.

@jfecher
Copy link
Contributor

jfecher commented Apr 11, 2024

I wonder if this is related to the constant folding bug I found in #4716. These cases both seem similar in that branches not taken in an if statement are affecting the result of the program.

If you make this change: https://github.com/noir-lang/noir/pull/4716/files#diff-1d0f0549b989551a60174308917ce4e7cbd5615ef86813e1729ac60e903f3702R281-R285 does it fix the issue?

@spalladino
Copy link
Contributor

@jfecher that worked, thanks so much!! Does it make sense to submit a PR with just that change, or is it best to wait for 4716 to be ready?

2024-04-11T15:17:46.641Z aztec:simulator:oracle Gonna call app payload execute calls
2024-04-11T15:17:46.642Z aztec:simulator:acvm Oracle callback debugLogWithPrefix
2024-04-11T15:17:46.642Z aztec:simulator:oracle Printing note hash read requests: [0x21aa9972aba518dbb557c751c7cc79a9545d83b18e58ee4f845c0d6c33ca110e, 0x21aa9972aba518dbb557c751c7cc79a9545d83b18e58ee4f845c0d6c33ca110e, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000]
2024-04-11T15:17:46.690Z aztec:simulator:acvm Oracle callback debugLog
2024-04-11T15:17:46.690Z aztec:simulator:oracle Called app payload execute calls
2024-04-11T15:17:46.690Z aztec:simulator:acvm Oracle callback debugLogWithPrefix
2024-04-11T15:17:46.691Z aztec:simulator:oracle Printing note hash read requests: [0x21aa9972aba518dbb557c751c7cc79a9545d83b18e58ee4f845c0d6c33ca110e, 0x21aa9972aba518dbb557c751c7cc79a9545d83b18e58ee4f845c0d6c33ca110e, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000000]

@jfecher
Copy link
Contributor

jfecher commented Apr 11, 2024

@spalladino good to hear! I'll make a separate PR with that change now.

#4716 may not be ready for a while since there is 1 remaining failing test in it that is very tricky to fix.

github-merge-queue bot pushed a commit that referenced this issue Apr 11, 2024
# Description

## Problem\*

Resolves #4600

## Summary\*

Array sets and gets are not pure. Listing them as such can cause
constant folding to fold away enabled array gets for ones in disabled
contexts (enable_side_effects_if u1 0). When used in disabled contexts
they will only ever retrieve from index zero.

## Additional Context

No reproduceable test case unfortunately. The ones in #4600 all require
aztec as a dependency and the ones in #4717 only trigger with the
remove_if_else pass added there.

I'm going to add a SSA unit test instead where two array get
instructions should survive constant folding. This PR is a draft until I
add that.

## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants