diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index c2630961cc3..229708560a0 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -1,6 +1,7 @@ import { CallContext, CircuitsWasm, + ContractStorageRead, FunctionData, GlobalVariables, HistoricBlockData, @@ -174,23 +175,20 @@ describe('ACIR public execution simulator', () => { expect(result.contractStorageReads).toEqual([]); }); - // Contract storage reads and update requests are implemented as built-ins, which at the moment Noir does not - // now whether they have side-effects or not, so they get run even when their code path - // is not picked by a conditional. Once that's fixed, we should re-enable this test. - // Task to repair this test: https://github.com/AztecProtocol/aztec-packages/issues/1588 - it.skip('should run the transfer function without enough sender balance', async () => { + it('should fail the transfer function without enough sender balance', async () => { const senderBalance = new Fr(10n); const recipientBalance = new Fr(20n); mockStore(senderBalance, recipientBalance); const result = await executor.execute(execution, GlobalVariables.empty()); - expect(result.returnValues[0]).toEqual(recipientBalance); - expect(result.contractStorageReads).toEqual([ - { storageSlot: recipientStorageSlot, value: recipientBalance }, - { storageSlot: senderStorageSlot, value: senderBalance }, - ]); + expect(result.contractStorageReads).toEqual( + [ + { storageSlot: senderStorageSlot, currentValue: senderBalance, sideEffectCounter: 0 }, + { storageSlot: recipientStorageSlot, currentValue: recipientBalance, sideEffectCounter: 1 }, + ].map(ContractStorageRead.from), + ); expect(result.contractStorageUpdateRequests).toEqual([]); }); diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index 9bbcfe872d3..523b9c22526 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -49,8 +49,12 @@ export class ContractStorageRead { * Value read from the storage slot. */ currentValue: Fr; + /** + * Optional side effect counter tracking position of this event in tx execution. + */ + sideEffectCounter?: number; }) { - return new ContractStorageRead(args.storageSlot, args.currentValue); + return new ContractStorageRead(args.storageSlot, args.currentValue, args.sideEffectCounter); } toBuffer() {