diff --git a/yarn-project/aztec.js/Dockerfile b/yarn-project/aztec.js/Dockerfile index 2e4ade811397..897d53e6feb6 100644 --- a/yarn-project/aztec.js/Dockerfile +++ b/yarn-project/aztec.js/Dockerfile @@ -1,6 +1,6 @@ FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project-base AS builder COPY . . -RUN cd aztec-js && yarn build +RUN cd aztec.js && yarn build WORKDIR /usr/src/yarn-project/aztec.js RUN yarn build && yarn formatting && yarn test diff --git a/yarn-project/aztec.js/package.json b/yarn-project/aztec.js/package.json index 00390360420b..355088819b89 100644 --- a/yarn-project/aztec.js/package.json +++ b/yarn-project/aztec.js/package.json @@ -31,6 +31,7 @@ "dependencies": { "@aztec/aztec-rpc": "workspace:^", "@aztec/foundation": "workspace:^", + "@aztec/sequencer-client": "workspace:^", "@aztec/tx": "workspace:^", "tslib": "^2.4.0" }, diff --git a/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts index 6fe9a49a39ab..b0405c817014 100644 --- a/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts @@ -1,114 +1,114 @@ -import { AztecNode } from '@aztec/aztec-node'; -import { AztecAddress, AztecRPCServer, Contract, ContractDeployer, Fr } from '@aztec/aztec.js'; -import { EthAddress } from '@aztec/ethereum.js/eth_address'; -import { EthereumRpc } from '@aztec/ethereum.js/eth_rpc'; -import { WalletProvider } from '@aztec/ethereum.js/provider'; -import { createDebugLogger } from '@aztec/foundation'; -import { ZkTokenContractAbi } from '@aztec/noir-contracts/examples'; -import { createAztecNode } from './create_aztec_node.js'; -import { createAztecRpcServer } from './create_aztec_rpc_client.js'; -import { createProvider, deployRollupContract, deployYeeterContract } from './deploy_l1_contracts.js'; - -const ETHEREUM_HOST = 'http://localhost:8545'; -const MNEMONIC = 'test test test test test test test test test test test junk'; - -const logger = createDebugLogger('aztec:e2e_zk_token_contract'); - -describe('e2e_zk_token_contract', () => { - let provider: WalletProvider; - let node: AztecNode; - let aztecRpcServer: AztecRPCServer; - let rollupAddress: EthAddress; - let yeeterAddress: EthAddress; - let accounts: AztecAddress[]; - let contract: Contract; - - beforeAll(async () => { - provider = createProvider(ETHEREUM_HOST, MNEMONIC, 1); - const ethRpc = new EthereumRpc(provider); - logger('Deploying contracts...'); - rollupAddress = await deployRollupContract(provider, ethRpc); - yeeterAddress = await deployYeeterContract(provider, ethRpc); - logger('Deployed contracts...'); - }); - - beforeEach(async () => { - node = await createAztecNode(rollupAddress, yeeterAddress, ETHEREUM_HOST, provider.getPrivateKey(0)!); - aztecRpcServer = await createAztecRpcServer(1, node); - accounts = await aztecRpcServer.getAccounts(); - }); - - afterEach(async () => { - await node.stop(); - await aztecRpcServer.stop(); - }); - - const expectStorageSlot = async (accountIdx: number, expectedBalance: bigint) => { - // We only generate 1 note in each test. Balance is the first field of the only note. - // TBD - how to calculate storage slot? - const storageSlot = Fr.ZERO; - const [[balance]] = await aztecRpcServer.getStorageAt(contract.address, storageSlot); - logger(`Account ${accountIdx} balance: ${balance}`); - expect(balance).toBe(expectedBalance); - }; - - const expectBalance = async (accountIdx: number, expectedBalance: bigint) => { - const balance = await contract.methods.getBalance().call({ from: accounts[accountIdx] }); - logger(`Account ${accountIdx} balance: ${balance}`); - expect(balance).toBe(expectedBalance); - }; - - const deployContract = async (initialBalance = 0n) => { - const deployer = new ContractDeployer(ZkTokenContractAbi, aztecRpcServer); - const receipt = await deployer.deploy(initialBalance).send().getReceipt(); - return new Contract(receipt.contractAddress!, ZkTokenContractAbi, aztecRpcServer); - }; - - /** - * Milestone 1.3 - * https://hackmd.io/AG5rb9DyTRu3y7mBptWauA - */ - it.skip('should deploy zk token contract with initial token minted to the account', async () => { - const initialBalance = 987n; - await deployContract(initialBalance); - await expectStorageSlot(0, initialBalance); - await expectStorageSlot(1, 0n); - }); - - /** - * Milestone 1.4 - */ - it.skip('should call mint and increase balance', async () => { - const mintAmount = 65n; - - await deployContract(); - - await expectStorageSlot(0, 0n); - await expectStorageSlot(1, 0n); - - const receipt = await contract.methods.mint(mintAmount).send({ from: accounts[1] }).getReceipt(); - expect(receipt.status).toBe(true); - - await expectStorageSlot(0, 0n); - await expectStorageSlot(1, mintAmount); - }); - - /** - * Milestone 1.5 - */ - it.skip('should call transfer and increase balance of another account', async () => { - const initialBalance = 987n; - const transferAmount = 654n; - - await deployContract(initialBalance); - - await expectBalance(0, initialBalance); - await expectBalance(1, 0n); - - const receipt = await contract.methods.transfer(accounts[1]).send({ from: accounts[0] }).getReceipt(); - expect(receipt.status).toBe(true); - - await expectBalance(0, initialBalance - transferAmount); - await expectBalance(1, transferAmount); - }); -}); +// import { AztecNode } from '@aztec/aztec-node'; +// import { AztecAddress, AztecRPCServer, Contract, ContractDeployer, Fr } from '@aztec/aztec.js'; +// import { EthAddress } from '@aztec/ethereum.js/eth_address'; +// import { EthereumRpc } from '@aztec/ethereum.js/eth_rpc'; +// import { WalletProvider } from '@aztec/ethereum.js/provider'; +// import { createDebugLogger } from '@aztec/foundation'; +// import { ZkTokenContractAbi } from '@aztec/noir-contracts/examples'; +// import { createAztecNode } from './create_aztec_node.js'; +// import { createAztecRpcServer } from './create_aztec_rpc_client.js'; +// import { createProvider, deployRollupContract, deployYeeterContract } from './deploy_l1_contracts.js'; + +// const ETHEREUM_HOST = 'http://localhost:8545'; +// const MNEMONIC = 'test test test test test test test test test test test junk'; + +// const logger = createDebugLogger('aztec:e2e_zk_token_contract'); + +// describe('e2e_zk_token_contract', () => { +// let provider: WalletProvider; +// let node: AztecNode; +// let aztecRpcServer: AztecRPCServer; +// let rollupAddress: EthAddress; +// let yeeterAddress: EthAddress; +// let accounts: AztecAddress[]; +// let contract: Contract; + +// beforeAll(async () => { +// provider = createProvider(ETHEREUM_HOST, MNEMONIC, 1); +// const ethRpc = new EthereumRpc(provider); +// logger('Deploying contracts...'); +// rollupAddress = await deployRollupContract(provider, ethRpc); +// yeeterAddress = await deployYeeterContract(provider, ethRpc); +// logger('Deployed contracts...'); +// }); + +// beforeEach(async () => { +// node = await createAztecNode(rollupAddress, yeeterAddress, ETHEREUM_HOST, provider.getPrivateKey(0)!); +// aztecRpcServer = await createAztecRpcServer(1, node); +// accounts = await aztecRpcServer.getAccounts(); +// }); + +// afterEach(async () => { +// await node.stop(); +// await aztecRpcServer.stop(); +// }); + +// const expectStorageSlot = async (accountIdx: number, expectedBalance: bigint) => { +// // We only generate 1 note in each test. Balance is the first field of the only note. +// // TBD - how to calculate storage slot? +// const storageSlot = Fr.ZERO; +// const [[balance]] = await aztecRpcServer.getStorageAt(contract.address, storageSlot); +// logger(`Account ${accountIdx} balance: ${balance}`); +// expect(balance).toBe(expectedBalance); +// }; + +// const expectBalance = async (accountIdx: number, expectedBalance: bigint) => { +// const balance = await contract.methods.getBalance().call({ from: accounts[accountIdx] }); +// logger(`Account ${accountIdx} balance: ${balance}`); +// expect(balance).toBe(expectedBalance); +// }; + +// const deployContract = async (initialBalance = 0n) => { +// const deployer = new ContractDeployer(ZkTokenContractAbi, aztecRpcServer); +// const receipt = await deployer.deploy(initialBalance).send().getReceipt(); +// return new Contract(receipt.contractAddress!, ZkTokenContractAbi, aztecRpcServer); +// }; + +// /** +// * Milestone 1.3 +// * https://hackmd.io/AG5rb9DyTRu3y7mBptWauA +// */ +// it.skip('should deploy zk token contract with initial token minted to the account', async () => { +// const initialBalance = 987n; +// await deployContract(initialBalance); +// await expectStorageSlot(0, initialBalance); +// await expectStorageSlot(1, 0n); +// }); + +// /** +// * Milestone 1.4 +// */ +// it.skip('should call mint and increase balance', async () => { +// const mintAmount = 65n; + +// await deployContract(); + +// await expectStorageSlot(0, 0n); +// await expectStorageSlot(1, 0n); + +// const receipt = await contract.methods.mint(mintAmount).send({ from: accounts[1] }).getReceipt(); +// expect(receipt.status).toBe(true); + +// await expectStorageSlot(0, 0n); +// await expectStorageSlot(1, mintAmount); +// }); + +// /** +// * Milestone 1.5 +// */ +// it.skip('should call transfer and increase balance of another account', async () => { +// const initialBalance = 987n; +// const transferAmount = 654n; + +// await deployContract(initialBalance); + +// await expectBalance(0, initialBalance); +// await expectBalance(1, 0n); + +// const receipt = await contract.methods.transfer(accounts[1]).send({ from: accounts[0] }).getReceipt(); +// expect(receipt.status).toBe(true); + +// await expectBalance(0, initialBalance - transferAmount); +// await expectBalance(1, transferAmount); +// }); +// }); diff --git a/yarn-project/sequencer-client/src/sequencer/circuit_powered_block_builder.test.ts b/yarn-project/sequencer-client/src/sequencer/circuit_powered_block_builder.test.ts index ac7333197dbe..d99c4a17b541 100644 --- a/yarn-project/sequencer-client/src/sequencer/circuit_powered_block_builder.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/circuit_powered_block_builder.test.ts @@ -44,6 +44,7 @@ describe('sequencer/circuit_block_builder', () => { let wasm: BarretenbergWasm; const emptyProof = new UInt8Vector(Buffer.alloc(32, 0)); + const emptyUnverifiedData = Buffer.alloc(0); beforeAll(async () => { wasm = new BarretenbergWasm(); @@ -83,9 +84,6 @@ describe('sequencer/circuit_block_builder', () => { [MerkleTreeId.DATA_TREE, MerkleTreeId.DATA_TREE_ROOTS_TREE], [MerkleTreeId.CONTRACT_TREE, MerkleTreeId.CONTRACT_TREE_ROOTS_TREE], ] as const) { - if (rootTree === MerkleTreeId.CONTRACT_TREE_ROOTS_TREE) { - await inspectTree(expectsDb, rootTree); - } const newTreeInfo = await expectsDb.getTreeInfo(newTree); await expectsDb.appendLeaves(rootTree, [newTreeInfo.root]); } @@ -109,7 +107,7 @@ describe('sequencer/circuit_block_builder', () => { it('builds an L2 block', async () => { // Assemble a fake transaction, we'll tweak some fields below - const tx = new Tx(makePrivateKernelPublicInputs(), emptyProof); + const tx = new Tx(makePrivateKernelPublicInputs(), emptyProof, emptyUnverifiedData); const txsLeft = [tx, makeEmptyTx()]; const txsRight = [makeEmptyTx(), makeEmptyTx()]; const txs = [...txsLeft, ...txsRight]; @@ -129,8 +127,6 @@ describe('sequencer/circuit_block_builder', () => { baseRollupOutputLeft.endNullifierTreeSnapshot = await getTreeSnapshot(MerkleTreeId.NULLIFIER_TREE); baseRollupOutputLeft.endPrivateDataTreeSnapshot = await getTreeSnapshot(MerkleTreeId.DATA_TREE); - await inspectTree(expectsDb, MerkleTreeId.CONTRACT_TREE); - // Same for the two txs on the right await updateExpectedTreesFromTxs(txsRight); baseRollupOutputRight.endContractTreeSnapshot = await getTreeSnapshot(MerkleTreeId.CONTRACT_TREE); diff --git a/yarn-project/sequencer-client/src/sequencer/circuit_powered_block_builder.ts b/yarn-project/sequencer-client/src/sequencer/circuit_powered_block_builder.ts index 170a5851991c..6f6ec48a5824 100644 --- a/yarn-project/sequencer-client/src/sequencer/circuit_powered_block_builder.ts +++ b/yarn-project/sequencer-client/src/sequencer/circuit_powered_block_builder.ts @@ -14,6 +14,7 @@ import { PreviousKernelData, PreviousRollupData, PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT, + ROLLUP_VK_TREE_HEIGHT, RootRollupInputs, RootRollupPublicInputs, UInt8Vector, @@ -274,7 +275,7 @@ export class CircuitPoweredBlockBuilder { // MembershipWitness for a VK tree to be implemented in the future FUTURE_NUM, - Array(VK_TREE_HEIGHT).fill(FUTURE_FR), + new MembershipWitness(ROLLUP_VK_TREE_HEIGHT, FUTURE_NUM, Array(ROLLUP_VK_TREE_HEIGHT).fill(FUTURE_FR)), ); } diff --git a/yarn-project/world-state/src/world-state-db/index.ts b/yarn-project/world-state/src/world-state-db/index.ts index 481a48450133..b828e78a7de9 100644 --- a/yarn-project/world-state/src/world-state-db/index.ts +++ b/yarn-project/world-state/src/world-state-db/index.ts @@ -63,7 +63,7 @@ export interface MerkleTreeDb extends MerkleTreeOperations { */ export async function inspectTree(db: MerkleTreeOperations, treeId: MerkleTreeId) { const info = await db.getTreeInfo(treeId); - let output = [`Tree id=${treeId} size=${info.size} root=0x${info.root.toString('hex')}`]; + const output = [`Tree id=${treeId} size=${info.size} root=0x${info.root.toString('hex')}`]; for (let i = 0; i < info.size; i++) { output.push( ` Leaf ${i}: ${await db.getLeafValue(treeId, BigInt(i)).then(x => x?.toString('hex') ?? '[undefined]')}`, diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index b608472236a9..dc4834d95d2f 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -138,6 +138,7 @@ __metadata: dependencies: "@aztec/aztec-rpc": "workspace:^" "@aztec/foundation": "workspace:^" + "@aztec/sequencer-client": "workspace:^" "@aztec/tx": "workspace:^" "@jest/globals": ^29.4.3 "@rushstack/eslint-patch": ^1.1.4