Skip to content

Commit 8c6db75

Browse files
authored
Merge pull request #173 from AztecProtocol/chore/upgrade-aztec-2.0.2
updating to 2.0.2
2 parents d7e356c + a7531b3 commit 8c6db75

19 files changed

+570
-478
lines changed

.github/workflows/tests.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
- name: Set Aztec version and start sandbox
3838
run: |
39-
VERSION=1.2.0 aztec-up
39+
VERSION=2.0.2 aztec-up
4040
aztec start --sandbox &
4141
4242
- name: Install project dependencies
@@ -46,15 +46,15 @@ jobs:
4646
run: script -e -c "${AZTEC_NARGO:-aztec-nargo} compile"
4747

4848
- name: Codegen
49-
run: script -e -c "aztec codegen target --outdir src/artifacts"
49+
run: script -e -c "aztec codegen target --outdir src/artifacts && aztec-postprocess-contract"
5050

5151
- name: Change ownership # to get around Docker issues
5252
run: sudo chown -R $(whoami) ~/nargo && sudo chown -R $(whoami) ~/nargo/github.com
5353

5454
- name: Run tests
5555
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"
5656

57-
- name: Deploy account and capture SECRET/SALT
57+
- name: Deploy account and capture SECRET/SIGNING_KEY/SALT
5858
run: |
5959
script -e -c "yarn clear-store"
6060
# Create a temporary file to store the output
@@ -73,24 +73,27 @@ jobs:
7373
# Show the full output for debugging
7474
cat "$TEMP_OUTPUT"
7575
76-
# Extract SECRET and SALT from the output
76+
# Extract SECRET, SIGNING_KEY, and SALT from the output
7777
SECRET_KEY=$(grep -o "🔑 Secret key generated: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/🔑 Secret key generated: //' || echo "")
78+
SIGNING_KEY=$(grep -o "🖊️ Signing key generated: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/🖊️ Signing key generated: //' || echo "")
7879
SALT_VALUE=$(grep -o "🧂 Salt generated: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/🧂 Salt generated: //' || echo "")
7980
8081
# Clean up temp file
8182
rm "$TEMP_OUTPUT"
8283
8384
# Validate and create .env file
84-
if [ -n "$SECRET_KEY" ] && [ -n "$SALT_VALUE" ]; then
85+
if [ -n "$SECRET_KEY" ] && [ -n "$SIGNING_KEY" ] && [ -n "$SALT_VALUE" ]; then
8586
8687
# Create .env file with all necessary values
8788
echo "SECRET=\"$SECRET_KEY\"" >> .env
89+
echo "SIGNING_KEY=\"$SIGNING_KEY\"" >> .env
8890
echo "SALT=\"$SALT_VALUE\"" >> .env
8991
echo "📋 Current .env file contents:"
9092
cat .env
9193
else
92-
echo "❌ Failed to extract SECRET and/or SALT from deploy output"
94+
echo "❌ Failed to extract SECRET, SIGNING_KEY and/or SALT from deploy output"
9395
echo "🔍 SECRET_KEY: '$SECRET_KEY'"
96+
echo "🔍 SIGNING_KEY: '$SIGNING_KEY'"
9497
echo "🔍 SALT_VALUE: '$SALT_VALUE'"
9598
exit 1
9699
fi

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 = "v1.2.0", directory = "noir-projects/aztec-nr/aztec" }
8+
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v2.0.2", directory = "noir-projects/aztec-nr/aztec" }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bash -i <(curl -s https://install.aztec.network)
4545
Install the correct version of the toolkit with:
4646

4747
```bash
48-
aztec-up 1.2.0
48+
aztec-up 2.0.2
4949
```
5050

5151
Start the sandbox with:

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"clean": "rm -rf ./src/artifacts ./target",
1313
"clear-store": "rm -rf ./store",
1414
"codegen": "aztec codegen target --outdir src/artifacts",
15-
"compile": "${AZTEC_NARGO:-aztec-nargo} compile",
15+
"compile": "${AZTEC_NARGO:-aztec-nargo} compile && aztec-postprocess-contract",
1616
"deploy": "node --loader ts-node/esm scripts/deploy_contract.ts",
1717
"deploy-account": "node --loader ts-node/esm scripts/deploy_account.ts",
1818
"interaction-existing-contract": "node --loader ts-node/esm scripts/interaction_existing_contract.ts",
@@ -26,12 +26,12 @@
2626
"update-readme-version": "node ./.github/scripts/update-readme-version.js"
2727
},
2828
"dependencies": {
29-
"@aztec/accounts": "1.2.0",
30-
"@aztec/aztec.js": "1.2.0",
31-
"@aztec/noir-contracts.js": "1.2.0",
32-
"@aztec/protocol-contracts": "1.2.0",
33-
"@aztec/pxe": "1.2.0",
34-
"@aztec/stdlib": "1.2.0"
29+
"@aztec/accounts": "2.0.2",
30+
"@aztec/aztec.js": "2.0.2",
31+
"@aztec/noir-contracts.js": "2.0.2",
32+
"@aztec/protocol-contracts": "2.0.2",
33+
"@aztec/pxe": "2.0.2",
34+
"@aztec/stdlib": "2.0.2"
3535
},
3636
"devDependencies": {
3737
"@types/jest": "^29.5.11",

scripts/deploy_contract.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EasyPrivateVotingContract } from "../src/artifacts/EasyPrivateVoting.js"
1+
import { PrivateVotingContract } from "../src/artifacts/PrivateVoting.js"
22
import { createLogger, PXE, Logger, SponsoredFeePaymentMethod, Fr } from "@aztec/aztec.js";
33
import { TokenContract } from "@aztec/noir-contracts.js/Token"
44
import { setupPXE } from "../src/utils/setup_pxe.js";
@@ -23,7 +23,7 @@ async function main() {
2323
logger.info('💰 Setting up sponsored fee payment contract...');
2424
const sponsoredFPC = await getSponsoredFPCInstance();
2525
logger.info(`💰 Sponsored FPC instance obtained at: ${sponsoredFPC.address}`);
26-
26+
2727
logger.info('📝 Registering sponsored FPC contract with PXE...');
2828
await pxe.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact });
2929
const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(sponsoredFPC.address);
@@ -39,30 +39,33 @@ async function main() {
3939
// Deploy voting contract
4040
logger.info('🗳️ Starting voting contract deployment...');
4141
logger.info(`📋 Admin address for voting contract: ${address}`);
42-
43-
const deployTx = EasyPrivateVotingContract.deploy(wallet, address).send({
44-
fee: { paymentMethod: sponsoredPaymentMethod }
42+
43+
const deployTx = PrivateVotingContract.deploy(wallet, address).send({
44+
from: wallet.getAddress(),
45+
fee: { paymentMethod: sponsoredPaymentMethod }
4546
});
46-
47+
4748
logger.info('⏳ Waiting for deployment transaction to be mined...');
4849
const votingContract = await deployTx.deployed({ timeout: 120000 });
49-
50+
5051
logger.info(`🎉 Voting Contract deployed successfully!`);
5152
logger.info(`📍 Contract address: ${votingContract.address}`);
5253
logger.info(`👤 Admin address: ${address}`);
53-
54+
5455
// Verify deployment
5556
logger.info('🔍 Verifying contract deployment...');
5657
try {
5758
// Test a read operation
5859
logger.info('🧪 Testing contract read operation...');
59-
const initialVoteCount = await votingContract.methods.get_vote(Fr.fromString("1")).simulate();
60+
const initialVoteCount = await votingContract.methods.get_vote(Fr.fromString("1")).simulate({
61+
from: wallet.getAddress()
62+
});
6063
logger.info(`📊 Initial vote count for candidate 1: ${initialVoteCount}`);
61-
64+
6265
} catch (error) {
6366
logger.error(`❌ Contract verification failed: ${error}`);
6467
}
65-
68+
6669
logger.info('🏁 Deployment process completed successfully!');
6770
logger.info(`📋 Summary:`);
6871
logger.info(` - Contract Address: ${votingContract.address}`);
@@ -75,4 +78,4 @@ main().catch((error) => {
7578
logger.error(`❌ Deployment failed: ${error.message}`);
7679
logger.error(`📋 Error details: ${error.stack}`);
7780
process.exit(1);
78-
});
81+
});

scripts/fees.ts

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@ import { foundry } from 'viem/chains'
66
import { mnemonicToAccount } from 'viem/accounts';
77
import { FeeJuiceContract } from "@aztec/noir-contracts.js/FeeJuice";
88
import { FPCContract } from "@aztec/noir-contracts.js/FPC";
9-
import { EasyPrivateVotingContract } from "../src/artifacts/EasyPrivateVoting.js"
9+
import { PrivateVotingContract } from "../src/artifacts/PrivateVoting.js"
1010
import { TokenContract } from "@aztec/noir-contracts.js/Token";
1111
// TODO: replace with import from aztec.js when published
1212
import { SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee/testing'
1313
import { getDeployedSponsoredFPCAddress, getSponsoredFPCInstance } from "../src/utils/sponsored_fpc.js";
1414
import { createEthereumChain, createExtendedL1Client } from "@aztec/ethereum";
1515
import { deploySchnorrAccount } from "../src/utils/deploy_account.js";
1616
import { setupPXE } from "../src/utils/setup_pxe.js";
17-
import { createLogger, FeeJuicePaymentMethod, FeeJuicePaymentMethodWithClaim, Fr, L1FeeJuicePortalManager, Logger, PrivateFeePaymentMethod, PublicFeePaymentMethod, PXE } from '@aztec/aztec.js';
17+
import { createLogger, FeeJuicePaymentMethod, FeeJuicePaymentMethodWithClaim, Fq, Fr, L1FeeJuicePortalManager, Logger, PrivateFeePaymentMethod, PublicFeePaymentMethod, PXE } from '@aztec/aztec.js';
1818
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
1919
import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
2020
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
21-
import { deriveSigningKey } from '@aztec/stdlib/keys';
2221

2322
const MNEMONIC = 'test test test test test test test test test test test junk';
24-
const FEE_FUNDING_FOR_TESTER_ACCOUNT = 1000000000000000000n;
23+
const FEE_FUNDING_FOR_TESTER_ACCOUNT = 1000000000000000000000n;
2524

2625
async function main() {
2726

@@ -43,8 +42,9 @@ async function main() {
4342
const wallet1 = await account1.getWallet();
4443

4544
let secretKey = Fr.random();
45+
let signingKey = Fq.random();
4646
let salt = Fr.random();
47-
let account2 = await getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt);
47+
let account2 = await getSchnorrAccount(pxe, secretKey, signingKey, salt);
4848
const wallet2 = await account2.getWallet();
4949
const feeJuiceRecipient = account2.getAddress();
5050

@@ -67,8 +67,14 @@ async function main() {
6767
const paymentMethod = new SponsoredFeePaymentMethod(sponsoredFPC.address);
6868

6969
// Two arbitrary txs to make the L1 message available on L2
70-
const votingContract = await EasyPrivateVotingContract.deploy(wallet1, wallet1.getAddress()).send({ fee: { paymentMethod } }).deployed();
71-
const bananaCoin = await TokenContract.deploy(wallet1, wallet1.getAddress(), "bananaCoin", "BNC", 18).send({ fee: { paymentMethod } }).deployed()
70+
const votingContract = await PrivateVotingContract.deploy(wallet1, wallet1.getAddress()).send({
71+
from: wallet1.getAddress(),
72+
fee: { paymentMethod }
73+
}).deployed();
74+
const bananaCoin = await TokenContract.deploy(wallet1, wallet1.getAddress(), "bananaCoin", "BNC", 18).send({
75+
from: wallet1.getAddress(),
76+
fee: { paymentMethod }
77+
}).deployed()
7278

7379
// Claim Fee Juice & Pay Fees yourself
7480

@@ -80,7 +86,10 @@ async function main() {
8086

8187
// Create a new voting contract instance, interacting from the newWallet
8288
const useFeeJuice = new FeeJuicePaymentMethod(account2.getAddress())
83-
await votingContract.withWallet(wallet2).methods.cast_vote(wallet1.getAddress()).send({ fee: { paymentMethod: useFeeJuice } }).wait()
89+
await votingContract.withWallet(wallet2).methods.cast_vote(wallet1.getAddress()).send({
90+
from: wallet2.getAddress(),
91+
fee: { paymentMethod: useFeeJuice }
92+
}).wait()
8493
logger.info(`Vote cast from new account, paying fees via newWallet.`)
8594

8695
// Private Fee Payments via FPC
@@ -89,40 +98,62 @@ async function main() {
8998
// Need to deploy an FPC to use Private Fee payment methods
9099

91100
// This uses bananaCoin as the fee paying asset that will be exchanged for fee juice
92-
const fpc = await FPCContract.deploy(wallet1, bananaCoin.address, wallet1.getAddress()).send({ fee: { paymentMethod } }).deployed()
101+
const fpc = await FPCContract.deploy(wallet1, bananaCoin.address, wallet1.getAddress()).send({
102+
from: wallet1.getAddress(),
103+
fee: { paymentMethod }
104+
}).deployed()
93105
const fpcClaim = await feeJuicePortalManager.bridgeTokensPublic(fpc.address, FEE_FUNDING_FOR_TESTER_ACCOUNT, true);
94106
// 2 public txs to make the bridged fee juice available
95107
// Mint some bananaCoin and send to the newWallet to pay fees privately
96-
await bananaCoin.methods.mint_to_private(wallet1.getAddress(), wallet2.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT).send({ fee: { paymentMethod } }).wait()
108+
await bananaCoin.methods.mint_to_private(wallet2.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT).send({
109+
from: wallet1.getAddress(),
110+
fee: { paymentMethod }
111+
}).wait()
97112
// mint some public bananaCoin to the newWallet to pay fees publicly
98-
await bananaCoin.methods.mint_to_public(wallet2.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT).send({ fee: { paymentMethod } }).wait()
99-
const bananaBalance = await bananaCoin.withWallet(wallet2).methods.balance_of_private(wallet2.getAddress()).simulate()
113+
await bananaCoin.methods.mint_to_public(wallet2.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT).send({
114+
from: wallet1.getAddress(),
115+
fee: { paymentMethod }
116+
}).wait()
117+
const bananaBalance = await bananaCoin.withWallet(wallet2).methods.balance_of_private(wallet2.getAddress()).simulate({
118+
from: wallet2.getAddress()
119+
})
100120

101121
logger.info(`BananaCoin balance of newWallet is ${bananaBalance}`)
102122

103123
const feeJuiceInstance = await getCanonicalFeeJuice();
104124
const feeJuice = await FeeJuiceContract.at(feeJuiceInstance.address, wallet2)
105-
await feeJuice.methods.claim(fpc.address, fpcClaim.claimAmount, fpcClaim.claimSecret, fpcClaim.messageLeafIndex).send().wait()
125+
await feeJuice.methods.claim(fpc.address, fpcClaim.claimAmount, fpcClaim.claimSecret, fpcClaim.messageLeafIndex).send({ from: wallet2.getAddress() }).wait()
106126

107-
logger.info(`Fpc fee juice balance ${await feeJuice.methods.balance_of_public(fpc.address).simulate()}`)
127+
logger.info(`Fpc fee juice balance ${await feeJuice.methods.balance_of_public(fpc.address).simulate({
128+
from: wallet2.getAddress()
129+
})}`)
108130

109131
const privateFee = new PrivateFeePaymentMethod(fpc.address, wallet2)
110-
await bananaCoin.withWallet(wallet2).methods.transfer_in_private(wallet2.getAddress(), wallet1.getAddress(), 10, 0).send({ fee: { paymentMethod: privateFee } }).wait()
132+
await bananaCoin.withWallet(wallet2).methods.transfer_in_private(wallet2.getAddress(), wallet1.getAddress(), 10, 0).send({
133+
from: wallet2.getAddress(),
134+
fee: { paymentMethod: privateFee }
135+
}).wait()
111136

112137
logger.info(`Transfer paid with fees via the FPC, privately.`)
113138

114139
// Public Fee Payments via FPC
115140

116141
const publicFee = new PublicFeePaymentMethod(fpc.address, wallet2)
117-
await bananaCoin.withWallet(wallet2).methods.transfer_in_private(wallet2.getAddress(), wallet1.getAddress(), 10, 0).send({ fee: { paymentMethod: publicFee } }).wait()
142+
await bananaCoin.withWallet(wallet2).methods.transfer_in_private(wallet2.getAddress(), wallet1.getAddress(), 10, 0).send({
143+
from: wallet2.getAddress(),
144+
fee: { paymentMethod: publicFee }
145+
}).wait()
118146
logger.info(`Transfer paid with fees via the FPC, publicly.`)
119147

120148
// Sponsored Fee Payment
121149

122150
// This method will only work in environments where there is a sponsored fee contract deployed
123151
const deployedSponsoredFPC = await getDeployedSponsoredFPCAddress(pxe);
124152
const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(deployedSponsoredFPC);
125-
await bananaCoin.withWallet(wallet2).methods.transfer_in_private(wallet2.getAddress(), wallet1.getAddress(), 10, 0).send({ fee: { paymentMethod: sponsoredPaymentMethod } }).wait()
153+
await bananaCoin.withWallet(wallet2).methods.transfer_in_private(wallet2.getAddress(), wallet1.getAddress(), 10, 0).send({
154+
from: wallet2.getAddress(),
155+
fee: { paymentMethod: sponsoredPaymentMethod }
156+
}).wait()
126157
logger.info(`Transfer paid with fees from Sponsored FPC.`)
127158
}
128159

@@ -137,4 +168,3 @@ function getL1WalletClient(rpcUrl: string, index: number) {
137168
transport: http(rpcUrl),
138169
});
139170
}
140-

scripts/interaction_existing_contract.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createLogger, Logger, SponsoredFeePaymentMethod, Fr, AztecAddress } from "@aztec/aztec.js";
2-
import { EasyPrivateVotingContract } from "../src/artifacts/EasyPrivateVoting.js";
2+
import { PrivateVotingContract } from "../src/artifacts/PrivateVoting.js";
33
import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC";
44
import { setupPXE } from "../src/utils/setup_pxe.js";
55
import { getSponsoredFPCInstance } from "../src/utils/sponsored_fpc.js";
@@ -29,7 +29,7 @@ async function main() {
2929
}
3030

3131
logger.info(`Connecting to voting contract at: ${contractAddress}`);
32-
const votingContract = await EasyPrivateVotingContract.at(
32+
const votingContract = await PrivateVotingContract.at(
3333
AztecAddress.fromString(contractAddress),
3434
wallet
3535
);
@@ -39,19 +39,26 @@ async function main() {
3939

4040
// First get_vote call - check initial vote count
4141
logger.info("Getting initial vote count...");
42-
const initialVoteCount = await votingContract.methods.get_vote(candidate).simulate();
42+
const initialVoteCount = await votingContract.methods.get_vote(candidate).simulate({
43+
from: wallet.getAddress()
44+
});
4345
logger.info(`Initial vote count for candidate ${candidate}: ${initialVoteCount}`);
4446

4547
// Cast a vote
4648
logger.info("Casting vote...");
4749
await votingContract.methods.cast_vote(candidate)
48-
.send({ fee: { paymentMethod: sponsoredPaymentMethod } })
50+
.send({
51+
from: wallet.getAddress(),
52+
fee: { paymentMethod: sponsoredPaymentMethod }
53+
})
4954
.wait({ timeout: 120000 });
5055
logger.info("Vote cast successfully!");
5156

5257
// Second get_vote call - check updated vote count
5358
logger.info("Getting updated vote count...");
54-
const updatedVoteCount = await votingContract.methods.get_vote(candidate).simulate();
59+
const updatedVoteCount = await votingContract.methods.get_vote(candidate).simulate({
60+
from: wallet.getAddress()
61+
});
5562
logger.info(`Updated vote count for candidate ${candidate}: ${updatedVoteCount}`);
5663

5764
logger.info(`Vote count increased from ${initialVoteCount} to ${updatedVoteCount}`);
@@ -60,4 +67,4 @@ async function main() {
6067
main().catch((error) => {
6168
console.error("Error:", error);
6269
process.exit(1);
63-
});
70+
});

0 commit comments

Comments
 (0)