-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(bb-prover): avm test skip and split (#11717)
- Loading branch information
Showing
7 changed files
with
619 additions
and
0 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit1.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { | ||
type ContractClassPublic, | ||
type ContractInstanceWithAddress, | ||
FunctionSelector, | ||
MAX_L2_TO_L1_MSGS_PER_TX, | ||
MAX_NOTE_HASHES_PER_TX, | ||
MAX_NULLIFIERS_PER_TX, | ||
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, | ||
MAX_PUBLIC_LOGS_PER_TX, | ||
PUBLIC_DISPATCH_SELECTOR, | ||
} from '@aztec/circuits.js'; | ||
import { makeContractClassPublic, makeContractInstanceFromClassId } from '@aztec/circuits.js/testing'; | ||
import { Fr } from '@aztec/foundation/fields'; | ||
import { AvmTestContractArtifact } from '@aztec/noir-contracts.js/AvmTest'; | ||
import { getAvmTestContractBytecode } from '@aztec/simulator/public/fixtures'; | ||
|
||
import { AvmProvingTester } from './avm_proving_tester.js'; | ||
|
||
const TIMEOUT = 300_000; | ||
const DISPATCH_FN_NAME = 'public_dispatch'; | ||
const DISPATCH_SELECTOR = new FunctionSelector(PUBLIC_DISPATCH_SELECTOR); | ||
|
||
describe('AVM WitGen & Circuit – check circuit', () => { | ||
const avmTestContractClassSeed = 0; | ||
const avmTestContractBytecode = getAvmTestContractBytecode(DISPATCH_FN_NAME); | ||
let avmTestContractClass: ContractClassPublic; | ||
let avmTestContractInstance: ContractInstanceWithAddress; | ||
let tester: AvmProvingTester; | ||
|
||
beforeEach(async () => { | ||
avmTestContractClass = await makeContractClassPublic( | ||
/*seed=*/ avmTestContractClassSeed, | ||
/*publicDispatchFunction=*/ { bytecode: avmTestContractBytecode, selector: DISPATCH_SELECTOR }, | ||
); | ||
avmTestContractInstance = await makeContractInstanceFromClassId( | ||
avmTestContractClass.id, | ||
/*seed=*/ avmTestContractClassSeed, | ||
); | ||
tester = await AvmProvingTester.create(/*checkCircuitOnly*/ true); | ||
await tester.addContractClass(avmTestContractClass, AvmTestContractArtifact); | ||
await tester.addContractInstance(avmTestContractInstance); | ||
}); | ||
|
||
it( | ||
'perform too many storage writes and revert', | ||
async () => { | ||
await tester.simProveVerifyAppLogic( | ||
{ | ||
address: avmTestContractInstance.address, | ||
fnName: 'n_storage_writes', | ||
args: [new Fr(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX + 1)], | ||
}, | ||
/*expectRevert=*/ true, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
it( | ||
'create too many note hashes and revert', | ||
async () => { | ||
await tester.simProveVerifyAppLogic( | ||
{ | ||
address: avmTestContractInstance.address, | ||
fnName: 'n_new_note_hashes', | ||
args: [new Fr(MAX_NOTE_HASHES_PER_TX + 1)], | ||
}, | ||
/*expectRevert=*/ true, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
it( | ||
'create too many nullifiers and revert', | ||
async () => { | ||
await tester.simProveVerifyAppLogic( | ||
{ | ||
address: avmTestContractInstance.address, | ||
fnName: 'n_new_nullifiers', | ||
args: [new Fr(MAX_NULLIFIERS_PER_TX + 1)], | ||
}, | ||
/*expectRevert=*/ true, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
it( | ||
'create too many l2tol1 messages and revert', | ||
async () => { | ||
await tester.simProveVerifyAppLogic( | ||
{ | ||
address: avmTestContractInstance.address, | ||
fnName: 'n_new_l2_to_l1_msgs', | ||
args: [new Fr(MAX_L2_TO_L1_MSGS_PER_TX + 1)], | ||
}, | ||
/*expectRevert=*/ true, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
it( | ||
'create too many public logs and revert', | ||
async () => { | ||
await tester.simProveVerifyAppLogic( | ||
{ | ||
address: avmTestContractInstance.address, | ||
fnName: 'n_new_public_logs', | ||
args: [new Fr(MAX_PUBLIC_LOGS_PER_TX + 1)], | ||
}, | ||
/*expectRevert=*/ true, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
}); |
118 changes: 118 additions & 0 deletions
118
yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit2.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { | ||
AztecAddress, | ||
type ContractClassPublic, | ||
type ContractInstanceWithAddress, | ||
FunctionSelector, | ||
PUBLIC_DISPATCH_SELECTOR, | ||
} from '@aztec/circuits.js'; | ||
import { makeContractClassPublic, makeContractInstanceFromClassId } from '@aztec/circuits.js/testing'; | ||
import { Fr } from '@aztec/foundation/fields'; | ||
import { AvmTestContractArtifact } from '@aztec/noir-contracts.js/AvmTest'; | ||
import { getAvmTestContractBytecode } from '@aztec/simulator/public/fixtures'; | ||
|
||
import { AvmProvingTester } from './avm_proving_tester.js'; | ||
|
||
const TIMEOUT = 300_000; | ||
const DISPATCH_FN_NAME = 'public_dispatch'; | ||
const DISPATCH_SELECTOR = new FunctionSelector(PUBLIC_DISPATCH_SELECTOR); | ||
|
||
describe('AVM WitGen & Circuit – check circuit', () => { | ||
const sender = AztecAddress.fromNumber(42); | ||
const avmTestContractClassSeed = 0; | ||
const avmTestContractBytecode = getAvmTestContractBytecode(DISPATCH_FN_NAME); | ||
let avmTestContractClass: ContractClassPublic; | ||
let avmTestContractInstance: ContractInstanceWithAddress; | ||
let tester: AvmProvingTester; | ||
|
||
beforeEach(async () => { | ||
avmTestContractClass = await makeContractClassPublic( | ||
/*seed=*/ avmTestContractClassSeed, | ||
/*publicDispatchFunction=*/ { bytecode: avmTestContractBytecode, selector: DISPATCH_SELECTOR }, | ||
); | ||
avmTestContractInstance = await makeContractInstanceFromClassId( | ||
avmTestContractClass.id, | ||
/*seed=*/ avmTestContractClassSeed, | ||
); | ||
tester = await AvmProvingTester.create(/*checkCircuitOnly*/ true); | ||
await tester.addContractClass(avmTestContractClass, AvmTestContractArtifact); | ||
await tester.addContractInstance(avmTestContractInstance); | ||
}); | ||
|
||
it( | ||
'an exceptional halt due to a nested call to non-existent contract is propagated to top-level', | ||
async () => { | ||
await tester.simProveVerifyAppLogic( | ||
{ address: avmTestContractInstance.address, fnName: 'nested_call_to_nothing', args: [] }, | ||
/*expectRevert=*/ true, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
it( | ||
'an exceptional halt due to a nested call to non-existent contract is recovered from in caller', | ||
async () => { | ||
await tester.simProveVerifyAppLogic( | ||
{ address: avmTestContractInstance.address, fnName: 'nested_call_to_nothing_recovers', args: [] }, | ||
/*expectRevert=*/ false, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
it.skip('top-level exceptional halts due to a non-existent contract in app-logic and teardown', async () => { | ||
// don't insert contracts into trees, and make sure retrieval fails | ||
const tester = await AvmProvingTester.create(/*checkCircuitOnly=*/ true, /*skipContractDeployments=*/ true); | ||
await tester.simProveVerify( | ||
sender, | ||
/*setupCalls=*/ [], | ||
/*appCalls=*/ [ | ||
{ address: avmTestContractInstance.address, fnName: 'add_args_return', args: [new Fr(1), new Fr(2)] }, | ||
], | ||
/*teardownCall=*/ { | ||
address: avmTestContractInstance.address, | ||
fnName: 'add_args_return', | ||
args: [new Fr(1), new Fr(2)], | ||
}, | ||
/*expectRevert=*/ true, | ||
); | ||
}); | ||
it( | ||
'enqueued calls in every phase, with enqueued calls that depend on each other', | ||
async () => { | ||
await tester.simProveVerify( | ||
sender, | ||
/*setupCalls=*/ [ | ||
{ address: avmTestContractInstance.address, fnName: 'read_assert_storage_single', args: [new Fr(0)] }, | ||
{ address: avmTestContractInstance.address, fnName: 'set_storage_single', args: [new Fr(5)] }, | ||
], | ||
/*appCalls=*/ [ | ||
{ address: avmTestContractInstance.address, fnName: 'read_assert_storage_single', args: [new Fr(5)] }, | ||
{ address: avmTestContractInstance.address, fnName: 'set_storage_single', args: [new Fr(10)] }, | ||
], | ||
/*teardownCall=*/ { | ||
address: avmTestContractInstance.address, | ||
fnName: 'read_assert_storage_single', | ||
args: [new Fr(10)], | ||
}, | ||
/*expectRevert=*/ false, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
it( | ||
'Should prove and verify a TX that reverts in teardown', | ||
async () => { | ||
await tester.simProveVerify( | ||
sender, | ||
/*setupCalls=*/ [], | ||
/*appCalls=*/ [], | ||
/*teardownCall=*/ { | ||
address: avmTestContractInstance.address, | ||
fnName: 'read_assert_storage_single', | ||
args: [new Fr(10)], | ||
}, | ||
/*expectRevert=*/ true, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
}); |
106 changes: 106 additions & 0 deletions
106
yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit3.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { | ||
AztecAddress, | ||
type ContractClassPublic, | ||
type ContractInstanceWithAddress, | ||
FunctionSelector, | ||
PUBLIC_DISPATCH_SELECTOR, | ||
} from '@aztec/circuits.js'; | ||
import { makeContractClassPublic, makeContractInstanceFromClassId } from '@aztec/circuits.js/testing'; | ||
import { Fr } from '@aztec/foundation/fields'; | ||
import { AvmTestContractArtifact } from '@aztec/noir-contracts.js/AvmTest'; | ||
import { getAvmTestContractBytecode } from '@aztec/simulator/public/fixtures'; | ||
|
||
import { AvmProvingTester } from './avm_proving_tester.js'; | ||
|
||
const TIMEOUT = 300_000; | ||
const DISPATCH_FN_NAME = 'public_dispatch'; | ||
const DISPATCH_SELECTOR = new FunctionSelector(PUBLIC_DISPATCH_SELECTOR); | ||
|
||
describe('AVM WitGen & Circuit – check circuit', () => { | ||
const sender = AztecAddress.fromNumber(42); | ||
const avmTestContractClassSeed = 0; | ||
const avmTestContractBytecode = getAvmTestContractBytecode(DISPATCH_FN_NAME); | ||
let avmTestContractClass: ContractClassPublic; | ||
let avmTestContractInstance: ContractInstanceWithAddress; | ||
let tester: AvmProvingTester; | ||
|
||
beforeEach(async () => { | ||
avmTestContractClass = await makeContractClassPublic( | ||
/*seed=*/ avmTestContractClassSeed, | ||
/*publicDispatchFunction=*/ { bytecode: avmTestContractBytecode, selector: DISPATCH_SELECTOR }, | ||
); | ||
avmTestContractInstance = await makeContractInstanceFromClassId( | ||
avmTestContractClass.id, | ||
/*seed=*/ avmTestContractClassSeed, | ||
); | ||
tester = await AvmProvingTester.create(/*checkCircuitOnly*/ true); | ||
await tester.addContractClass(avmTestContractClass, AvmTestContractArtifact); | ||
await tester.addContractInstance(avmTestContractInstance); | ||
}); | ||
|
||
it( | ||
'top-level exceptional halts in both app logic and teardown', | ||
async () => { | ||
await tester.simProveVerify( | ||
sender, | ||
/*setupCalls=*/ [], | ||
/*appCalls=*/ [{ address: avmTestContractInstance.address, fnName: 'divide_by_zero', args: [] }], | ||
/*teardownCall=*/ undefined, | ||
/*expectRevert=*/ true, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
it( | ||
'top-level exceptional halt in app logic, but teardown succeeds', | ||
async () => { | ||
await tester.simProveVerify( | ||
sender, | ||
/*setupCalls=*/ [], | ||
/*appCalls=*/ [{ address: avmTestContractInstance.address, fnName: 'divide_by_zero', args: [] }], | ||
/*teardownCall=*/ { | ||
address: avmTestContractInstance.address, | ||
fnName: 'add_args_return', | ||
args: [new Fr(1), new Fr(2)], | ||
}, | ||
/*expectRevert=*/ true, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
it( | ||
'top-level exceptional halt in teardown, but app logic succeeds', | ||
async () => { | ||
await tester.simProveVerify( | ||
sender, | ||
/*setupCalls=*/ [], | ||
/*appCalls=*/ [ | ||
{ address: avmTestContractInstance.address, fnName: 'add_args_return', args: [new Fr(1), new Fr(2)] }, | ||
], | ||
/*teardownCall=*/ { address: avmTestContractInstance.address, fnName: 'divide_by_zero', args: [] }, | ||
/*expectRevert=*/ true, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
it( | ||
'a nested exceptional halt propagate to top-level', | ||
async () => { | ||
await tester.simProveVerifyAppLogic( | ||
{ address: avmTestContractInstance.address, fnName: 'external_call_to_divide_by_zero', args: [] }, | ||
/*expectRevert=*/ true, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
it( | ||
'a nested exceptional halt is recovered from in caller', | ||
async () => { | ||
await tester.simProveVerifyAppLogic( | ||
{ address: avmTestContractInstance.address, fnName: 'external_call_to_divide_by_zero_recovers', args: [] }, | ||
/*expectRevert=*/ false, | ||
); | ||
}, | ||
TIMEOUT, | ||
); | ||
}); |
Oops, something went wrong.