Skip to content

Commit

Permalink
feat: aztec-packages 0.66.0 (#234)
Browse files Browse the repository at this point in the history
And improvements to event-cannon
  • Loading branch information
FilipHarald authored Dec 13, 2024
1 parent d38a74e commit 2b1bd51
Show file tree
Hide file tree
Showing 70 changed files with 1,717 additions and 1,416 deletions.
2 changes: 1 addition & 1 deletion k8s/local/aztec-sandbox-node/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
app: aztec-sandbox-node
spec:
containers:
- image: aztecprotocol/aztec:0.65.2
- image: aztecprotocol/aztec:0.66.0
name: aztec-sandbox-node
resources:
limits:
Expand Down
2 changes: 1 addition & 1 deletion packages/backend-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint-base": "yarn run g:lint"
},
"dependencies": {
"@aztec/aztec.js": "0.65.2",
"@aztec/aztec.js": "0.66.0",
"@chicmoz-pkg/types": "workspace:^"
},
"devDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions packages/backend-utils/src/parse-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const getTxEffectWithHashes = (txEffects: L2Block["body"]["txEffects"]) => {
return txEffects.map((txEffect) => {
return {
...txEffect,
unencryptedLogslength: txEffect.unencryptedLogsLength.toNumber(),
privateLogs: txEffect.privateLogs.map((log) => log.toFields()),
hash: "0x" + txEffect.hash().toString("hex"),
txHash: txEffect.txHash.toString(),
};
Expand Down
2 changes: 1 addition & 1 deletion packages/message-registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint-base": "yarn run g:lint"
},
"dependencies": {
"@aztec/aztec.js": "0.65.2",
"@aztec/aztec.js": "0.66.0",
"@chicmoz-pkg/types": "workspace:^"
},
"devDependencies": {
Expand Down
5 changes: 2 additions & 3 deletions packages/types/src/aztec/l2Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@ export const chicmozL2ContractClassRegisteredEventSchema = z.object({
version: z.number(),
artifactHash: frSchema,
privateFunctionsRoot: frSchema,
packedPublicBytecode: bufferSchema,
packedBytecode: bufferSchema,
});

export type ChicmozL2ContractClassRegisteredEvent = z.infer<
typeof chicmozL2ContractClassRegisteredEventSchema
>;

const functionSelectorSchema = z.object({
type: z.enum(["FunctionSelector"]),
value: z.string(),
value: z.number(),
});

export const chicmozL2PrivateFunctionBroadcastedEventSchema = z.object({
Expand Down
18 changes: 2 additions & 16 deletions packages/types/src/aztec/l2TxEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,12 @@ import { z } from "zod";
import { hexStringSchema } from "../general.js";
import { aztecAddressSchema, bufferSchema, frNumberSchema, frSchema } from "./utils.js";

export const noteEncryptedLogEntrySchema = z.object({
data: bufferSchema,
});

export const encryptedLogEntrySchema = z.object({
data: bufferSchema,
maskedContractAddress: frSchema,
});

export const unencryptedLogEntrySchema = z.object({
data: bufferSchema,
contractAddress: aztecAddressSchema,
});

const logsSchema = (logEntrySchema: typeof noteEncryptedLogEntrySchema | typeof encryptedLogEntrySchema | typeof unencryptedLogEntrySchema) =>
const logsSchema = (logEntrySchema: typeof unencryptedLogEntrySchema) =>
z.object({
functionLogs: z.array(
z.object({
Expand Down Expand Up @@ -72,16 +63,11 @@ export const chicmozL2TxEffectSchema = z.object({
publicDataWrites: z.array(
z.object({ leafSlot: frSchema, value: frSchema }),
),
noteEncryptedLogsLength: frNumberSchema,
encryptedLogsLength: frNumberSchema,
unencryptedLogsLength: frNumberSchema,
noteEncryptedLogs: logsSchema(noteEncryptedLogEntrySchema),
encryptedLogs: logsSchema(encryptedLogEntrySchema),
privateLogs: z.array(z.array(frSchema)),
unencryptedLogs: logsSchema(unencryptedLogEntrySchema),
});

export type NoteEncryptedLogEntry = z.infer<typeof noteEncryptedLogEntrySchema>;
export type EncryptedLogEntry = z.infer<typeof encryptedLogEntrySchema>;
export type UnencryptedLogEntry = z.infer<typeof unencryptedLogEntrySchema>;

export type ChicmozL2PendingTx = z.infer<typeof chicmozL2PendingTxSchema>;
Expand Down
15 changes: 14 additions & 1 deletion packages/types/src/aztec/special.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,24 @@ import {
} from "./l2Contract.js";
import { chicmozL2TxEffectSchema } from "./l2TxEffect.js";

export const chicmozL2VerifiedContractAddressDataSchema = z.object({
contractInstanceAddress: z.string(),
name: z.string(),
details: z.string(),
contact: z.string(),
uiUrl: z.string(),
repoUrl: z.string(),
});

export type ChicmozL2VerifiedContractAddressData = z.infer<
typeof chicmozL2VerifiedContractAddressDataSchema
>;

export const chicmozL2ContractInstanceDeluxeSchema = z.object({
...chicmozL2ContractInstanceDeployedEventSchema.shape,
...chicmozL2ContractClassRegisteredEventSchema.shape,
blockHeight: chicmozL2BlockSchema.shape.height.optional(),
aztecScoutVerified: z.boolean().optional(),
verifiedInfo: chicmozL2VerifiedContractAddressDataSchema.optional(),
});

export type ChicmozL2ContractInstanceDeluxe = z.infer<
Expand Down
4 changes: 2 additions & 2 deletions services/aztec-listener/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"main": "index.js",
"license": "Apache-2.0",
"dependencies": {
"@aztec/aztec.js": "0.65.2",
"@aztec/circuits.js": "0.65.2",
"@aztec/aztec.js": "0.66.0",
"@aztec/circuits.js": "0.66.0",
"@chicmoz-pkg/logger-server": "workspace:^",
"@chicmoz-pkg/message-bus": "workspace:^",
"@chicmoz-pkg/message-registry": "workspace:^",
Expand Down
13 changes: 10 additions & 3 deletions services/aztec-listener/src/aztec/txs_poller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Tx } from "@aztec/aztec.js";
import { TX_POLL_INTERVAL_MS } from "../constants.js";
import { getPendingTxs } from "./network-client.js";
import { onPendingTxs } from "../event-handler/index.js";
import { logger } from "../logger.js";

let pollInterval: NodeJS.Timeout;

Expand All @@ -18,13 +19,19 @@ export const stopPolling = () => {
};

const internalOnPendingTxs = async (pendingTxs: Tx[]) => {
const newPendingTxs = pendingTxs.filter((tx) => !handledTxs.includes(tx.getTxHash().toString()));
const newPendingTxs = pendingTxs.filter(
(tx) => !handledTxs.includes(tx.getTxHash().toString())
);
if (newPendingTxs.length === 0) return;
await onPendingTxs(pendingTxs);
handledTxs = pendingTxs.map((tx) => tx.getTxHash().toString());
};

const fetchAndPublishPendingTxs = async () => {
const txs = await getPendingTxs();
await internalOnPendingTxs(txs);
try {
const txs = await getPendingTxs();
await internalOnPendingTxs(txs);
} catch (error) {
logger.warn("Error fetching pending txs", error);
}
};
4 changes: 2 additions & 2 deletions services/ethereum-listener/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
],
"license": "Apache-2.0",
"dependencies": {
"@aztec/aztec.js": "0.65.2",
"@aztec/l1-artifacts": "0.65.2",
"@aztec/aztec.js": "0.66.0",
"@aztec/l1-artifacts": "0.66.0",
"@chicmoz-pkg/logger-server": "workspace:^",
"@chicmoz-pkg/message-bus": "workspace:^",
"@chicmoz-pkg/message-registry": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion services/event-cannon/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Compile contracts (if changed, or updated version)

aztec-up 0.65.2
aztec-up 0.66.0

cd contract-projects/YOUR_PROJECT
aztec-nargo compile
Expand Down
8 changes: 4 additions & 4 deletions services/event-cannon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
],
"license": "Apache-2.0",
"dependencies": {
"@aztec/accounts": "0.65.2",
"@aztec/aztec.js": "0.65.2",
"@aztec/l1-artifacts": "0.65.2",
"@aztec/noir-contracts.js": "0.65.2",
"@aztec/accounts": "0.66.0",
"@aztec/aztec.js": "0.66.0",
"@aztec/l1-artifacts": "0.66.0",
"@aztec/noir-contracts.js": "0.66.0",
"@chicmoz-pkg/logger-server": "workspace:^"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions services/event-cannon/src/artifacts/SimpleLogging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ export class SimpleLoggingContract extends ContractBase {
/** get_counter_value(counter_id: field) */
get_counter_value: ((counter_id: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;

/** increace_counter_private(counter_id: field) */
increace_counter_private: ((counter_id: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
/** increase_counter_private(counter_id: field) */
increase_counter_private: ((counter_id: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;

/** increase_counter_public(counter_id: field) */
increase_counter_public: ((counter_id: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
Expand Down
26 changes: 10 additions & 16 deletions services/event-cannon/src/cannon/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { logger } from "../logger.js";
import { setup } from "./pxe.js";
import { run as deployAndInteractFunctionsVote } from "./scenarios/deploy-and-interact-vote-contract.js";
import { run as deploySimpleContract } from "./scenarios/simple-deploy-contract.js";
import { run as deploySimpleDefaultAccount } from "./scenarios/deploy-simple-default-account.js";
import { run as deployAndInteractTokenContract } from "./scenarios/deploy-and-interact-token-contract.js";
import { run as deploySimpleLog } from "./scenarios/deploy-and-run-simple-log.js";
import { run as l1L2PublicMessaging } from "./scenarios/l1-l2-public-messaging.js";
import { run as l1L2PrivateMessaging } from "./scenarios/l1-l2-private-messaging.js";
import * as scenarios from "./scenarios/index.js";

export async function init() {
logger.info("Initializing Cannon...");
Expand All @@ -22,14 +16,14 @@ export async function init() {

export const start = async () => {
logger.info("Starting Cannon...");
const scenarios = [
deploySimpleDefaultAccount,
deployAndInteractTokenContract,
deployAndInteractFunctionsVote,
deploySimpleContract,
deploySimpleLog,
l1L2PublicMessaging,
l1L2PrivateMessaging,
const scenariosToRun = [
scenarios.deploySimpleDefaultAccount,
scenarios.deployAndInteractTokenContract,
scenarios.deployAndInteractFunctionsVote,
scenarios.deploySimpleContract,
scenarios.deploySimpleLog,
scenarios.l1L2PublicMessaging,
scenarios.l1L2PrivateMessaging,
] as (() => Promise<void>)[];
for (const fn of scenarios) await fn();
for (const fn of scenariosToRun) await fn();
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Contract, DeploySentTx, waitForPXE } from "@aztec/aztec.js";
import {
Contract,
DeploySentTx,
waitForPXE,
} from "@aztec/aztec.js";
import { logger } from "../../logger.js";
import { getPxe, getWallets } from "../pxe.js";
import { getAztecNodeClient, getPxe, getWallets } from "../pxe.js";
import { deployContract, logAndWaitForTx } from "./utils/index.js";
import { TokenContract } from "@aztec/noir-contracts.js";

Expand All @@ -24,6 +28,7 @@ export async function run() {
9
).send();
},
node: getAztecNodeClient(),
});

await Promise.all([
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Contract, DeploySentTx, Fr, waitForPXE } from "@aztec/aztec.js";
import {
Contract,
DeploySentTx,
Fr,
waitForPXE,
} from "@aztec/aztec.js";
import { logger } from "../../logger.js";
import { getPxe, getWallets } from "../pxe.js";
import { getAztecNodeClient, getPxe, getWallets } from "../pxe.js";
import { deployContract, logAndWaitForTx } from "./utils/index.js";
import {
EasyPrivateVotingContract,
Expand All @@ -21,6 +26,7 @@ export async function run() {
deployFn: (): DeploySentTx<EasyPrivateVotingContract> =>
EasyPrivateVotingContract.deploy(deployerWallet, votingAdmin).send(),
broadcastWithWallet: deployerWallet, // NOTE: comment this out to not broadcast
node: getAztecNodeClient(),
});

const votingContractAlice = await Contract.at(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DeploySentTx, waitForPXE } from "@aztec/aztec.js";
import { SimpleLoggingContract } from "../../artifacts/SimpleLogging.js";
import { logger } from "../../logger.js";
import { getPxe, getWallets } from "../pxe.js";
import { getAztecNodeClient, getPxe, getWallets } from "../pxe.js";
import { deployContract, logAndWaitForTx } from "./utils/index.js";

export async function run() {
Expand All @@ -15,7 +15,8 @@ export async function run() {
const simpleLoggingContractDeployer = await deployContract({
contractLoggingName: "Voting Contract",
deployFn: (): DeploySentTx<SimpleLoggingContract> =>
SimpleLoggingContract.deploy(deployerWallet).send()
SimpleLoggingContract.deploy(deployerWallet).send(),
node: getAztecNodeClient(),
});
await logAndWaitForTx(
simpleLoggingContractDeployer.methods.increase_counter_public(1).send(),
Expand Down
7 changes: 7 additions & 0 deletions services/event-cannon/src/cannon/scenarios/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export { run as deployAndInteractFunctionsVote } from "./deploy-and-interact-vote-contract.js";
export { run as deploySimpleContract } from "./simple-deploy-contract.js";
export { run as deploySimpleDefaultAccount } from "./deploy-simple-default-account.js";
export { run as deployAndInteractTokenContract } from "./deploy-and-interact-token-contract.js";
export { run as deploySimpleLog } from "./deploy-and-run-simple-log.js";
export { run as l1L2PublicMessaging } from "./l1-l2-public-messaging.js";
export { run as l1L2PrivateMessaging } from "./l1-l2-private-messaging.js";
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import {
} from "viem";
import { mnemonicToAccount } from "viem/accounts";
import { foundry } from "viem/chains";
import { ETHEREUM_RPC_URL } from "../../environment.js";
import {
ETHEREUM_RPC_URL,
} from "../../environment.js";
import {
RollupAbi,
TestERC20Abi,
Expand Down Expand Up @@ -100,6 +102,7 @@ export const run = async () => {
18
).send();
},
node: getAztecNodeClient(),
});

const bridge = await deployContract({
Expand All @@ -111,6 +114,7 @@ export const run = async () => {
tokenPortalAddress
).send();
},
node: getAztecNodeClient(),
});

if ((await token.methods.get_admin().simulate()) !== owner.toBigInt())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import {
} from "viem";
import { mnemonicToAccount } from "viem/accounts";
import { foundry } from "viem/chains";
import { ETHEREUM_RPC_URL } from "../../environment.js";
import {
ETHEREUM_RPC_URL,
} from "../../environment.js";
import {
RollupAbi,
TestERC20Abi,
Expand Down Expand Up @@ -103,6 +105,7 @@ export const run = async () => {
18
).send();
},
node: getAztecNodeClient(),
});

const bridge = await deployContract({
Expand All @@ -114,6 +117,7 @@ export const run = async () => {
tokenPortalAddress
).send();
},
node: getAztecNodeClient(),
});

if ((await token.methods.get_admin().simulate()) !== owner.toBigInt())
Expand Down
Loading

0 comments on commit 2b1bd51

Please sign in to comment.