Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Aug 26, 2024
1 parent 3749211 commit b114ec5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/contract/batch_call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class BatchCall extends BaseContractInteraction {

const [unconstrainedResults, simulatedTx] = await Promise.all([
Promise.all(unconstrainedCalls),
this.wallet.simulateTx(txRequest, true, options?.from),
this.wallet.simulateTx(txRequest, true, options?.from, options?.skipTxValidation),
]);

const results: any[] = [];
Expand Down
7 changes: 5 additions & 2 deletions yarn-project/end-to-end/src/e2e_prover/full.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ describe('full_prover', () => {
});

afterEach(async () => {
await t.tokenSim.check();
// Tx validation is skipped here because checking the simulation fails the proof validation
await t.tokenSim.check(true);
});

it(
Expand All @@ -41,7 +42,9 @@ describe('full_prover', () => {
expect(privateSendAmount).toBeGreaterThan(0n);
const privateInteraction = provenAssets[0].methods.transfer(accounts[1].address, privateSendAmount);

const publicBalance = await provenAssets[1].methods.balance_of_public(accounts[0].address).simulate();
const publicBalance = await provenAssets[1].methods.balance_of_public(accounts[0].address).simulate({
skipTxValidation: true,
});
const publicSendAmount = publicBalance / 2n;
expect(publicSendAmount).toBeGreaterThan(0n);
const publicInteraction = provenAssets[1].methods.transfer_public(
Expand Down
3 changes: 2 additions & 1 deletion yarn-project/end-to-end/src/e2e_prover/with_padding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ describe('full_prover_with_padding_tx', () => {
});

afterEach(async () => {
await t.tokenSim.check();
// Tx validation is skipped here because checking the simulation fails the proof validation
await t.tokenSim.check(true);
});

it(
Expand Down
30 changes: 22 additions & 8 deletions yarn-project/end-to-end/src/simulators/token_simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,21 @@ export class TokenSimulator {
return this.balancesPrivate.get(address.toString()) || 0n;
}

async checkPublic() {
async checkPublic(skipTxValidation: boolean = false) {
// public calls
const calls = [this.token.methods.total_supply().request()];
for (const address of this.accounts) {
calls.push(this.token.methods.balance_of_public(address).request());
}

const results = (
await Promise.all(chunk(calls, 4).map(batch => new BatchCall(this.defaultWallet, batch).simulate()))
await Promise.all(
chunk(calls, 4).map(batch =>
new BatchCall(this.defaultWallet, batch).simulate({
skipTxValidation,
}),
),
)
).flat();
expect(results[0]).toEqual(this.totalSupply);

Expand All @@ -115,7 +121,7 @@ export class TokenSimulator {
}
}

async checkPrivate() {
async checkPrivate(skipTxValidation: boolean = false) {
// Private calls
const defaultLookups = [];
const nonDefaultLookups = [];
Expand All @@ -133,7 +139,13 @@ export class TokenSimulator {
defaultCalls.push(this.token.methods.balance_of_private(address).request());
}
const results = (
await Promise.all(chunk(defaultCalls, 4).map(batch => new BatchCall(this.defaultWallet, batch).simulate()))
await Promise.all(
chunk(defaultCalls, 4).map(batch =>
new BatchCall(this.defaultWallet, batch).simulate({
skipTxValidation,
}),
),
)
).flat();
for (let i = 0; i < defaultLookups.length; i++) {
expect(results[i]).toEqual(this.balanceOfPrivate(defaultLookups[i]));
Expand All @@ -145,13 +157,15 @@ export class TokenSimulator {
const wallet = this.lookupProvider.get(address.toString());
const asset = wallet ? this.token.withWallet(wallet) : this.token;

const actualPrivateBalance = await asset.methods.balance_of_private({ address }).simulate();
const actualPrivateBalance = await asset.methods.balance_of_private({ address }).simulate({
skipTxValidation,
});
expect(actualPrivateBalance).toEqual(this.balanceOfPrivate(address));
}
}

public async check() {
await this.checkPublic();
await this.checkPrivate();
public async check(skipTxValidation: boolean = false) {
await this.checkPublic(skipTxValidation);
await this.checkPrivate(skipTxValidation);
}
}
2 changes: 1 addition & 1 deletion yarn-project/pxe/src/pxe_service/pxe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export class PXEService implements PXE {
txRequest: TxExecutionRequest,
simulatePublic: boolean,
msgSender: AztecAddress | undefined = undefined,
skipTxValidation: boolean = true, // TODO(#7956): make the default be false
skipTxValidation: boolean = false,
scopes?: AztecAddress[],
): Promise<SimulatedTx> {
return await this.jobQueue.put(async () => {
Expand Down

0 comments on commit b114ec5

Please sign in to comment.