Skip to content

Commit

Permalink
Merge branch 'master' into sync-noir
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Nov 27, 2024
2 parents 144907c + 1bfc15e commit 7d27f23
Show file tree
Hide file tree
Showing 19 changed files with 199 additions and 76 deletions.
2 changes: 1 addition & 1 deletion docs/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ deploy-preview:
COPY --dir ../yarn-project/+scripts-prod/usr/src/yarn-project /usr/src
COPY ./netlify.toml .
COPY ./deploy_preview.sh .
RUN NETLIFY_AUTH_TOKEN=$NETLIFY_AUTH_TOKEN NETLIFY_SITE_ID=$NETLIFY_SITE_ID ./deploy_preview.sh $PR $AZTEC_BOT_COMMENTER_GITHUB_TOKEN
RUN NETLIFY_AUTH_TOKEN=$NETLIFY_AUTH_TOKEN NETLIFY_SITE_ID=$NETLIFY_SITE_ID ./deploy_preview.sh "$PR" "$AZTEC_BOT_COMMENTER_GITHUB_TOKEN"

deploy-prod:
BUILD ../yarn-project/+scripts-prod
Expand Down
4 changes: 3 additions & 1 deletion docs/deploy_preview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ DOCS_PREVIEW_URL=$(echo "$DEPLOY_OUTPUT" | grep -E "https://.*aztec-docs-dev.net
echo "Unique deploy URL: $DOCS_PREVIEW_URL"

cd ../yarn-project/scripts
AZTEC_BOT_COMMENTER_GITHUB_TOKEN=$AZTEC_BOT_COMMENTER_GITHUB_TOKEN PR_NUMBER=$PR_NUMBER DOCS_PREVIEW_URL=$DOCS_PREVIEW_URL yarn docs-preview-comment
if [ -n "$PR_NUMBER" ] ; then
AZTEC_BOT_COMMENTER_GITHUB_TOKEN=$AZTEC_BOT_COMMENTER_GITHUB_TOKEN PR_NUMBER=$PR_NUMBER DOCS_PREVIEW_URL=$DOCS_PREVIEW_URL yarn docs-preview-comment
fi
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ contract AvmTest {
dep::aztec::oracle::debug_log::debug_log("pedersen_hash_with_index");
let _ = pedersen_hash_with_index(args_field);
dep::aztec::oracle::debug_log::debug_log("test_get_contract_instance");
test_get_contract_instance(context.this_address());
test_get_contract_instance(AztecAddress::from_field(args_field[0]));
dep::aztec::oracle::debug_log::debug_log("get_address");
let _ = get_address();
dep::aztec::oracle::debug_log::debug_log("get_sender");
Expand Down
18 changes: 6 additions & 12 deletions yarn-project/bb-prover/src/avm_proving.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@ import path from 'path';
import { type BBSuccess, BB_RESULT, generateAvmProof, verifyAvmProof } from './bb/execute.js';
import { extractAvmVkData } from './verification_key/verification_key_data.js';

const TIMEOUT = 180_000;

describe('AVM WitGen, proof generation and verification', () => {
it(
'Should prove and verify bulk_testing',
async () => {
await proveAndVerifyAvmTestContract(
'bulk_testing',
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x)),
);
},
TIMEOUT,
);
it('Should prove and verify bulk_testing', async () => {
await proveAndVerifyAvmTestContract(
'bulk_testing',
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x)),
);
}, 180_000);
});

async function proveAndVerifyAvmTestContract(functionName: string, calldata: Fr[] = []) {
Expand Down
6 changes: 4 additions & 2 deletions yarn-project/circuits.js/src/contract/artifact_hash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { readFileSync } from 'fs';
import { getPathToFixture, getTestContractArtifact } from '../tests/fixtures.js';
import { computeArtifactHash } from './artifact_hash.js';

const TEST_CONTRACT_ARTIFACT_HASH = `"0x08f4e5d2a0be9dc5c31894f88aaa93d353918078cd7fdfbbc7818ec3f2268b77"`;
const TEST_CONTRACT_ARTIFACT_HASH = `"0x1d429080e986cf55e59203b4229063bf9b4d875e832fe56c5257303075110190"`;

describe('ArtifactHash', () => {
it('calculates the artifact hash', () => {
Expand All @@ -30,8 +30,10 @@ describe('ArtifactHash', () => {
it('calculates the test contract artifact hash multiple times to ensure deterministic hashing', () => {
const testArtifact = getTestContractArtifact();

const calculatedArtifactHash = computeArtifactHash(testArtifact).toString();
expect(calculatedArtifactHash).toMatchInlineSnapshot(TEST_CONTRACT_ARTIFACT_HASH);
for (let i = 0; i < 1000; i++) {
expect(computeArtifactHash(testArtifact).toString()).toMatchInlineSnapshot(TEST_CONTRACT_ARTIFACT_HASH);
expect(computeArtifactHash(testArtifact).toString()).toBe(calculatedArtifactHash);
}
});

Expand Down
3 changes: 2 additions & 1 deletion yarn-project/end-to-end/scripts/e2e_test_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ tests:
e2e_state_vars: {}
e2e_static_calls: {}
e2e_synching: {}
e2e_token_contract: {}
e2e_token_contract:
with_alerts: true
e2e_p2p_gossip:
test_path: 'e2e_p2p/gossip_network.test.ts'
with_alerts: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
import { TokenSimulator } from '../simulators/token_simulator.js';

const { E2E_DATA_PATH: dataPath } = process.env;
const { E2E_DATA_PATH: dataPath, METRICS_PORT: metricsPort } = process.env;

export class TokenContractTest {
static TOKEN_NAME = 'USDC';
Expand All @@ -30,7 +30,9 @@ export class TokenContractTest {

constructor(testName: string) {
this.logger = createDebugLogger(`aztec:e2e_token_contract:${testName}`);
this.snapshotManager = createSnapshotManager(`e2e_token_contract/${testName}`, dataPath);
this.snapshotManager = createSnapshotManager(`e2e_token_contract/${testName}`, dataPath, {
metricsPort: metricsPort ? parseInt(metricsPort) : undefined,
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
import { Fr } from '@aztec/aztec.js';

import { U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js';
import { AlertChecker, type AlertConfig } from '../quality_of_service/alert_checker.js';
import { TokenContractTest } from './token_contract_test.js';

const CHECK_ALERTS = process.env.CHECK_ALERTS === 'true';

const qosAlerts: AlertConfig[] = [
{
// Dummy alert to check that the metric is being emitted.
// Separate benchmark tests will use dedicated machines with the published system requirements.
alert: 'publishing_mana_per_second',
expr: 'rate(aztec_public_executor_simulation_mana_per_second_per_second_sum[5m]) / rate(aztec_public_executor_simulation_mana_per_second_per_second_count[5m]) < 10',
for: '5m',
annotations: {},
labels: {},
},
];

describe('e2e_token_contract transfer public', () => {
const t = new TokenContractTest('transfer_in_public');
let { asset, accounts, tokenSim, wallets, badAccount } = t;
Expand All @@ -17,6 +32,10 @@ describe('e2e_token_contract transfer public', () => {

afterAll(async () => {
await t.teardown();
if (CHECK_ALERTS) {
const alertChecker = new AlertChecker(t.logger);
await alertChecker.runAlertCheck(qosAlerts);
}
});

afterEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/fixtures/snapshot_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ async function setupFromFresh(
aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
}

const telemetry = await getEndToEndTestTelemetryClient(opts.metricsPort, /*serviceName*/ 'basenode');
const telemetry = await getEndToEndTestTelemetryClient(opts.metricsPort, /*serviceName*/ statePath);

logger.verbose('Creating and synching an aztec node...');
const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, { telemetry });
Expand Down
6 changes: 1 addition & 5 deletions yarn-project/ivc-integration/src/avm_integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { BufferReader } from '@aztec/foundation/serialize';
import { type FixedLengthArray } from '@aztec/noir-protocol-circuits-types/types';
import { simulateAvmTestContractGenerateCircuitInputs } from '@aztec/simulator/public/fixtures';

import { jest } from '@jest/globals';
import fs from 'fs/promises';
import { tmpdir } from 'node:os';
import os from 'os';
Expand All @@ -23,9 +22,6 @@ import { MockPublicBaseCircuit, witnessGenMockPublicBaseCircuit } from './index.

// Auto-generated types from noir are not in camel case.
/* eslint-disable camelcase */

jest.setTimeout(240_000);

const logger = createDebugLogger('aztec:avm-integration');

describe('AVM Integration', () => {
Expand Down Expand Up @@ -120,7 +116,7 @@ describe('AVM Integration', () => {
);

expect(verifyResult.status).toBe(BB_RESULT.SUCCESS);
});
}, 240_000);
});

async function proveAvmTestContract(functionName: string, calldata: Fr[] = []): Promise<BBSuccess> {
Expand Down
24 changes: 23 additions & 1 deletion yarn-project/simulator/src/public/executor_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ import {
type Histogram,
Metrics,
type TelemetryClient,
type Tracer,
type UpDownCounter,
ValueType,
linearBuckets,
} from '@aztec/telemetry-client';

export class ExecutorMetrics {
public readonly tracer: Tracer;
private fnCount: UpDownCounter;
private fnDuration: Histogram;
private manaPerSecond: Histogram;

constructor(client: TelemetryClient, name = 'PublicExecutor') {
this.tracer = client.getTracer(name);
const meter = client.getMeter(name);

this.fnCount = meter.createUpDownCounter(Metrics.PUBLIC_EXECUTOR_SIMULATION_COUNT, {
Expand All @@ -23,13 +28,30 @@ export class ExecutorMetrics {
unit: 'ms',
valueType: ValueType.INT,
});

this.manaPerSecond = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_SIMULATION_MANA_PER_SECOND, {
description: 'Mana used per second',
unit: 'mana/s',
valueType: ValueType.INT,
advice: {
explicitBucketBoundaries: linearBuckets(0, 10_000_000, 10),
},
});
}

recordFunctionSimulation(durationMs: number) {
recordFunctionSimulation(durationMs: number, manaUsed: number, fnName: string) {
this.fnCount.add(1, {
[Attributes.OK]: true,
[Attributes.APP_CIRCUIT_NAME]: fnName,
[Attributes.MANA_USED]: manaUsed,
});
this.fnDuration.record(Math.ceil(durationMs));
if (durationMs > 0 && manaUsed > 0) {
const manaPerSecond = Math.round((manaUsed * 1000) / durationMs);
this.manaPerSecond.record(manaPerSecond, {
[Attributes.APP_CIRCUIT_NAME]: fnName,
});
}
}

recordFunctionSimulationFailure() {
Expand Down
Loading

0 comments on commit 7d27f23

Please sign in to comment.