Skip to content

Commit b86945f

Browse files
authored
Merge pull request #58 from AztecProtocol/jc/0.77.0
update to 0.77.1
2 parents 7a7241d + 04a6a87 commit b86945f

File tree

10 files changed

+169
-244
lines changed

10 files changed

+169
-244
lines changed

.github/scripts/update-readme-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'url';
44

55
// Read Nargo.toml
66
const nargoContent = readFileSync('Nargo.toml', 'utf8');
7-
const versionMatch = nargoContent.match(/tag\s*=\s*"aztec-packages-v([^"]+)"/);
7+
const versionMatch = nargoContent.match(/tag\s*=\s*"v([^"]+)"/);
88
const version = versionMatch ? versionMatch[1] : null;
99

1010
if (!version) {

.github/workflows/tests.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
- name: Set Aztec version and start sandbox
3030
run: |
31-
VERSION=0.76.4 aztec-up
31+
VERSION=0.77.1 aztec-up
3232
aztec start --sandbox &
3333
3434
- name: Install project dependencies
@@ -40,5 +40,8 @@ jobs:
4040
- name: Codegen
4141
run: script -e -c "aztec codegen target --outdir src/artifacts"
4242

43+
- name: Change ownership # to get around Docker issues
44+
run: sudo chown -R $(whoami) ~/nargo && sudo chown -R $(whoami) ~/nargo/github.com
45+
4346
- name: Run tests
4447
run: script -e -c "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json && aztec test"

Nargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ authors = [ "" ]
55
compiler_version = ">=0.18.0"
66

77
[dependencies]
8-
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "aztec-packages-v0.76.4", directory = "noir-projects/aztec-nr/aztec" }
8+
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v0.77.1", directory = "noir-projects/aztec-nr/aztec" }

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The corresponding tutorial can be found in the [Aztec docs here](https://docs.az
2727

2828
## 🚀 **Getting Started**
2929

30-
Use **Node.js version 18**.
30+
Use **Node.js version 20.18.1**.
3131

3232
[Start your codespace from the codespace dropdown](https://docs.github.com/en/codespaces/getting-started/quickstart).
3333

@@ -40,7 +40,7 @@ bash -i <(curl -s https://install.aztec.network)
4040
Install the correct version of the toolkit with:
4141

4242
```bash
43-
aztec-up 0.76.4
43+
aztec-up 0.77.1
4444
```
4545

4646
Start the sandbox with:
@@ -99,6 +99,8 @@ yarn test
9999

100100
Testing will run the **TypeScript tests** defined in `index.test.ts` inside `./src/test`, as well as the [Aztec Testing eXecution Environment (TXE)](https://docs.aztec.network/guides/developer_guides/smart_contracts/testing) tests defined in [`first.nr`](./src/test/first.nr) (imported in the contract file with `mod test;`).
101101

102+
Note: The Typescript tests spawn an instance of the sandbox to test against, and close it once once the TS tests are complete.
103+
102104
---
103105

104106
## **Error Resolution**

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
"test": "yarn test:js && yarn test:nr",
1717
"test:js": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json",
1818
"test:nr": "aztec test",
19-
"update": "aztec update --contract . && ./.github/scripts/update_contract.sh $(grep -oP 'tag\\s*=\\s*\"\\K[^\"]+' \"Nargo.toml\" | head -1) && yarn && yarn update-readme-version",
19+
"update": "./.github/scripts/update_contract.sh $(grep -oP 'tag\\s*=\\s*\"\\K[^\"]+' \"Nargo.toml\" | head -1) && yarn && yarn update-readme-version",
2020
"update-readme-version": "node ./.github/scripts/update-readme-version.js"
2121
},
2222
"dependencies": {
23-
"@aztec/accounts": "0.76.4",
24-
"@aztec/aztec.js": "0.76.4",
25-
"@aztec/noir-contracts.js": "0.76.4",
23+
"@aztec/accounts": "0.77.1",
24+
"@aztec/aztec.js": "0.77.1",
25+
"@aztec/noir-contracts.js": "0.77.1",
26+
"@aztec/stdlib": "0.77.1",
2627
"@types/node": "^22.5.1"
2728
},
2829
"devDependencies": {

scripts/deploy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EasyPrivateVotingContract } from "../src/artifacts/EasyPrivateVoting.js"
22
import { AccountWallet, CompleteAddress, createLogger, Fr, PXE, waitForPXE, createPXEClient, Logger } from "@aztec/aztec.js";
33
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
4-
import { deriveSigningKey } from '@aztec/circuits.js';
4+
import { deriveSigningKey } from '@aztec/stdlib/keys';
55
import { getInitialTestAccountsWallets } from "@aztec/accounts/testing";
66
import { TokenContract } from "@aztec/noir-contracts.js/Token"
77

@@ -28,7 +28,7 @@ async function main() {
2828
let salt = Fr.random();
2929

3030
let schnorrAccount = await getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt);
31-
const { address, publicKeys, partialAddress } = await schnorrAccount.getCompleteAddress();
31+
const { address, publicKeys, partialAddress } = await schnorrAccount.getCompleteAddress()
3232
let tx = await schnorrAccount.deploy().wait();
3333
let wallet = await schnorrAccount.getWallet();
3434

scripts/getBlock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async function main() {
1414

1515
let block = await pxe.getBlock(1);
1616
console.log(block)
17-
console.log(block?.hash())
17+
console.log(await block?.hash())
1818
}
1919

2020
main();

src/main.nr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ pub contract EasyPrivateVoting {
88
macros::{functions::{initializer, internal, private, public}, storage::storage},
99
};
1010
use dep::aztec::prelude::{AztecAddress, Map, PublicImmutable, PublicMutable};
11+
use dep::aztec::protocol_types::traits::{Hash, ToField};
12+
1113
#[storage]
1214
struct Storage<Context> {
1315
admin: PublicMutable<AztecAddress, Context>, // admin can end vote

src/test/index.test.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
import { EasyPrivateVotingContractArtifact, EasyPrivateVotingContract } from "../artifacts/EasyPrivateVoting.js"
22
import { AccountWallet, CompleteAddress, ContractDeployer, createLogger, Fr, PXE, waitForPXE, TxStatus, createPXEClient, getContractInstanceFromDeployParams, Logger } from "@aztec/aztec.js";
33
import { getInitialTestAccountsWallets } from "@aztec/accounts/testing"
4+
import { spawn } from 'child_process';
45

56
const setupSandbox = async () => {
67
const { PXE_URL = 'http://localhost:8080' } = process.env;
78
const pxe = createPXEClient(PXE_URL);
89
await waitForPXE(pxe);
910
return pxe;
1011
};
12+
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
1113

1214
describe("Voting", () => {
1315
let pxe: PXE;
1416
let wallets: AccountWallet[] = [];
1517
let accounts: CompleteAddress[] = [];
1618
let logger: Logger;
19+
let sandboxInstance;
1720

1821
beforeAll(async () => {
22+
sandboxInstance = spawn("aztec", ["start", "--sandbox"], {
23+
detached: true,
24+
stdio: 'ignore'
25+
})
26+
sleep(15000)
1927
logger = createLogger('aztec:aztec-starter');
2028
logger.info("Aztec-Starter tests running.")
2129

@@ -25,6 +33,10 @@ describe("Voting", () => {
2533
accounts = wallets.map(w => w.getCompleteAddress())
2634
})
2735

36+
afterAll(async () => {
37+
sandboxInstance!.kill();
38+
})
39+
2840
it("Deploys the contract", async () => {
2941
const salt = Fr.random();
3042
const VotingContractArtifact = EasyPrivateVotingContractArtifact
@@ -72,16 +84,18 @@ describe("Voting", () => {
7284
it("It should fail when trying to vote twice", async () => {
7385
const candidate = new Fr(1)
7486

75-
const contract = await EasyPrivateVotingContract.deploy(wallets[0], accounts[0].address).send().deployed();
76-
await contract.methods.cast_vote(candidate).send().wait();
87+
const votingContract = await EasyPrivateVotingContract.deploy(wallets[0], accounts[0].address).send().deployed();
88+
await votingContract.methods.cast_vote(candidate).send().wait();
89+
expect(await votingContract.methods.get_vote(candidate).simulate()).toBe(1n);
7790

7891
// We try voting again, but our TX is dropped due to trying to emit duplicate nullifiers
7992
// first confirm that it fails simulation
80-
await expect(contract.methods.cast_vote(candidate).send().wait()).rejects.toThrow(/Nullifier collision/);
81-
// if we skip simulation, tx is dropped
93+
await expect(votingContract.methods.cast_vote(candidate).send().wait()).rejects.toThrow(/Nullifier collision/);
94+
// if we skip simulation before submitting the tx,
95+
// tx will be included in a block but with app logic reverted
8296
await expect(
83-
contract.methods.cast_vote(candidate).send({ skipPublicSimulation: true }).wait(),
84-
).rejects.toThrow('Reason: Tx dropped by P2P node.');
97+
votingContract.methods.cast_vote(candidate).send({ skipPublicSimulation: true }).wait(),
98+
).rejects.toThrow(TxStatus.APP_LOGIC_REVERTED);
8599

86100
}, 300_000)
87101

0 commit comments

Comments
 (0)