@aztec/aztec 0.0.1-commit.42ee6df9b → 0.0.1-commit.431c48d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/index.js +3 -1
- package/dest/cli/aztec_start_action.d.ts +1 -1
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +33 -33
- package/dest/cli/aztec_start_options.d.ts +2 -2
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +21 -16
- package/dest/cli/cmds/compile.d.ts +1 -1
- package/dest/cli/cmds/compile.d.ts.map +1 -1
- package/dest/cli/cmds/compile.js +30 -24
- package/dest/cli/cmds/profile.d.ts +1 -1
- package/dest/cli/cmds/profile.d.ts.map +1 -1
- package/dest/cli/cmds/profile.js +1 -1
- package/dest/cli/cmds/profile_gates.d.ts +2 -2
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
- package/dest/cli/cmds/profile_gates.js +21 -3
- package/dest/cli/cmds/prover.d.ts +4 -0
- package/dest/cli/cmds/prover.d.ts.map +1 -0
- package/dest/cli/cmds/prover.js +24 -0
- package/dest/cli/cmds/standby.d.ts +30 -6
- package/dest/cli/cmds/standby.d.ts.map +1 -1
- package/dest/cli/cmds/standby.js +48 -5
- package/dest/cli/cmds/start_bot.d.ts +1 -1
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +8 -4
- package/dest/cli/cmds/start_node.d.ts +1 -1
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +20 -32
- package/dest/cli/cmds/start_prover_agent.js +2 -2
- package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_broker.js +11 -8
- package/dest/cli/cmds/start_txe.d.ts +2 -2
- package/dest/cli/cmds/start_txe.d.ts.map +1 -1
- package/dest/cli/cmds/start_txe.js +6 -5
- package/dest/cli/cmds/utils/artifacts.d.ts +6 -1
- package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -1
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +2 -2
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -1
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +35 -15
- package/dest/cli/util.d.ts +10 -5
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +26 -53
- package/dest/deploy/bridging.d.ts +84 -0
- package/dest/deploy/bridging.d.ts.map +1 -0
- package/dest/deploy/bridging.js +121 -0
- package/dest/deploy/fees.d.ts +120 -0
- package/dest/deploy/fees.d.ts.map +1 -0
- package/dest/deploy/fees.js +278 -0
- package/dest/deploy/graph.d.ts +40 -0
- package/dest/deploy/graph.d.ts.map +1 -0
- package/dest/deploy/graph.js +120 -0
- package/dest/deploy/index.d.ts +19 -0
- package/dest/deploy/index.d.ts.map +1 -0
- package/dest/deploy/index.js +15 -0
- package/dest/deploy/reporter.d.ts +106 -0
- package/dest/deploy/reporter.d.ts.map +1 -0
- package/dest/deploy/reporter.js +76 -0
- package/dest/deploy/runner.d.ts +8 -0
- package/dest/deploy/runner.d.ts.map +1 -0
- package/dest/deploy/runner.js +886 -0
- package/dest/deploy/state.d.ts +19 -0
- package/dest/deploy/state.d.ts.map +1 -0
- package/dest/deploy/state.js +59 -0
- package/dest/deploy/types.d.ts +233 -0
- package/dest/deploy/types.d.ts.map +1 -0
- package/dest/deploy/types.js +9 -0
- package/dest/examples/token.js +3 -3
- package/dest/local-network/auth_registry.d.ts +5 -0
- package/dest/local-network/auth_registry.d.ts.map +1 -0
- package/dest/local-network/auth_registry.js +17 -0
- package/dest/local-network/banana_fpc.d.ts +3 -2
- package/dest/local-network/banana_fpc.d.ts.map +1 -1
- package/dest/local-network/banana_fpc.js +11 -7
- package/dest/local-network/local-network.d.ts +10 -32
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +52 -73
- package/dest/testing/cheat_codes.d.ts +17 -23
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +17 -43
- package/dest/testing/epoch_test_settler.d.ts +2 -2
- package/dest/testing/epoch_test_settler.d.ts.map +1 -1
- package/dest/testing/epoch_test_settler.js +6 -25
- package/dest/testing/index.d.ts +2 -2
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +1 -1
- package/dest/testing/local-network.d.ts +51 -0
- package/dest/testing/local-network.d.ts.map +1 -0
- package/dest/testing/local-network.js +60 -0
- package/dest/testing/token_allowed_setup.d.ts +9 -4
- package/dest/testing/token_allowed_setup.d.ts.map +1 -1
- package/dest/testing/token_allowed_setup.js +12 -8
- package/package.json +37 -34
- package/scripts/add_crate.sh +11 -60
- package/scripts/aztec.sh +6 -2
- package/scripts/init.sh +5 -5
- package/scripts/new.sh +2 -2
- package/scripts/setup_workspace.sh +3 -2
- package/scripts/templates/blank/contract/Nargo.toml +6 -0
- package/scripts/templates/blank/contract/src/main.nr +10 -0
- package/scripts/templates/blank/test/Nargo.toml +7 -0
- package/scripts/templates/blank/test/src/lib.nr +11 -0
- package/scripts/templates/counter/contract/Nargo.toml +7 -0
- package/scripts/templates/counter/contract/src/main.nr +48 -0
- package/scripts/templates/counter/test/Nargo.toml +7 -0
- package/scripts/templates/counter/test/src/lib.nr +32 -0
- package/src/bin/index.ts +3 -1
- package/src/cli/aztec_start_action.ts +38 -25
- package/src/cli/aztec_start_options.ts +27 -23
- package/src/cli/cmds/compile.ts +35 -24
- package/src/cli/cmds/profile.ts +2 -1
- package/src/cli/cmds/profile_gates.ts +20 -4
- package/src/cli/cmds/prover.ts +42 -0
- package/src/cli/cmds/standby.ts +59 -7
- package/src/cli/cmds/start_bot.ts +9 -6
- package/src/cli/cmds/start_node.ts +25 -32
- package/src/cli/cmds/start_prover_agent.ts +2 -2
- package/src/cli/cmds/start_prover_broker.ts +10 -11
- package/src/cli/cmds/start_txe.ts +7 -5
- package/src/cli/cmds/utils/artifacts.ts +5 -0
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +37 -15
- package/src/cli/util.ts +27 -68
- package/src/deploy/bridging.ts +191 -0
- package/src/deploy/fees.ts +322 -0
- package/src/deploy/graph.ts +137 -0
- package/src/deploy/index.ts +41 -0
- package/src/deploy/reporter.ts +184 -0
- package/src/deploy/runner.ts +936 -0
- package/src/deploy/state.ts +66 -0
- package/src/deploy/types.ts +244 -0
- package/src/examples/token.ts +11 -3
- package/src/local-network/auth_registry.ts +19 -0
- package/src/local-network/banana_fpc.ts +12 -8
- package/src/local-network/local-network.ts +61 -83
- package/src/testing/cheat_codes.ts +18 -49
- package/src/testing/epoch_test_settler.ts +8 -31
- package/src/testing/index.ts +1 -1
- package/src/testing/local-network.ts +97 -0
- package/src/testing/token_allowed_setup.ts +15 -8
- package/dest/cli/cmds/start_archiver.d.ts +0 -9
- package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
- package/dest/cli/cmds/start_archiver.js +0 -48
- package/dest/testing/anvil_test_watcher.d.ts +0 -42
- package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
- package/dest/testing/anvil_test_watcher.js +0 -181
- package/src/cli/cmds/start_archiver.ts +0 -50
- package/src/testing/anvil_test_watcher.ts +0 -210
|
@@ -2,19 +2,23 @@ import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
|
2
2
|
import { buildAllowedElement } from '@aztec/p2p/msg_validators';
|
|
3
3
|
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
4
4
|
/**
|
|
5
|
-
* Returns
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
* Returns the allowlist entries needed for FPC-based fee payments, keyed by the contract class of
|
|
6
|
+
* the `artifact` actually deployed as the fee token (defaults to canonical Token). The setup-phase
|
|
7
|
+
* validator matches these entries by class id, so a test deploying the codegen'd TestToken as its
|
|
8
|
+
* fee vehicle must pass `TestTokenContract.artifact` here -- otherwise the FPC fee calls are matched
|
|
9
|
+
* against the wrong class and rejected. Test-only: FPC fee payment with custom tokens won't work on
|
|
10
|
+
* mainnet alpha.
|
|
11
|
+
*/ export async function getTokenAllowedSetupFunctions(artifact = TokenContractArtifact) {
|
|
12
|
+
const tokenClassId = (await getContractClassFromArtifact(artifact)).id;
|
|
9
13
|
const target = {
|
|
10
14
|
classId: tokenClassId
|
|
11
15
|
};
|
|
12
16
|
return Promise.all([
|
|
13
|
-
//
|
|
14
|
-
buildAllowedElement(
|
|
17
|
+
// needed for private transfers via FPC (transfer_to_public enqueues this)
|
|
18
|
+
buildAllowedElement(artifact, target, '_increase_public_balance', {
|
|
15
19
|
onlySelf: true
|
|
16
20
|
}),
|
|
17
|
-
//
|
|
18
|
-
buildAllowedElement(
|
|
21
|
+
// needed for public transfers via FPC (fee_entrypoint_public enqueues this)
|
|
22
|
+
buildAllowedElement(artifact, target, 'transfer_in_public')
|
|
19
23
|
]);
|
|
20
24
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.431c48d",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
7
|
+
"./deploy": "./dest/deploy/index.js",
|
|
7
8
|
"./testing": "./dest/testing/index.js"
|
|
8
9
|
},
|
|
9
10
|
"bin": "./scripts/aztec.sh",
|
|
@@ -28,38 +29,39 @@
|
|
|
28
29
|
"../package.common.json"
|
|
29
30
|
],
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
32
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
33
|
-
"@aztec/aztec-node": "0.0.1-commit.
|
|
34
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
35
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
36
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
37
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
38
|
-
"@aztec/bot": "0.0.1-commit.
|
|
39
|
-
"@aztec/builder": "0.0.1-commit.
|
|
40
|
-
"@aztec/cli": "0.0.1-commit.
|
|
41
|
-
"@aztec/constants": "0.0.1-commit.
|
|
42
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
43
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
44
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
45
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
46
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
47
|
-
"@aztec/node-lib": "0.0.1-commit.
|
|
48
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
49
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
50
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
51
|
-
"@aztec/p2p-bootstrap": "0.0.1-commit.
|
|
52
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
53
|
-
"@aztec/prover-client": "0.0.1-commit.
|
|
54
|
-
"@aztec/prover-node": "0.0.1-commit.
|
|
55
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
56
|
-
"@aztec/sequencer-client": "0.0.1-commit.
|
|
57
|
-
"@aztec/
|
|
58
|
-
"@aztec/
|
|
59
|
-
"@aztec/
|
|
60
|
-
"@aztec/
|
|
61
|
-
"@aztec/
|
|
62
|
-
"@aztec/
|
|
32
|
+
"@aztec/accounts": "0.0.1-commit.431c48d",
|
|
33
|
+
"@aztec/archiver": "0.0.1-commit.431c48d",
|
|
34
|
+
"@aztec/aztec-node": "0.0.1-commit.431c48d",
|
|
35
|
+
"@aztec/aztec.js": "0.0.1-commit.431c48d",
|
|
36
|
+
"@aztec/bb-prover": "0.0.1-commit.431c48d",
|
|
37
|
+
"@aztec/bb.js": "0.0.1-commit.431c48d",
|
|
38
|
+
"@aztec/blob-client": "0.0.1-commit.431c48d",
|
|
39
|
+
"@aztec/bot": "0.0.1-commit.431c48d",
|
|
40
|
+
"@aztec/builder": "0.0.1-commit.431c48d",
|
|
41
|
+
"@aztec/cli": "0.0.1-commit.431c48d",
|
|
42
|
+
"@aztec/constants": "0.0.1-commit.431c48d",
|
|
43
|
+
"@aztec/entrypoints": "0.0.1-commit.431c48d",
|
|
44
|
+
"@aztec/ethereum": "0.0.1-commit.431c48d",
|
|
45
|
+
"@aztec/foundation": "0.0.1-commit.431c48d",
|
|
46
|
+
"@aztec/kv-store": "0.0.1-commit.431c48d",
|
|
47
|
+
"@aztec/l1-artifacts": "0.0.1-commit.431c48d",
|
|
48
|
+
"@aztec/node-lib": "0.0.1-commit.431c48d",
|
|
49
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.431c48d",
|
|
50
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.431c48d",
|
|
51
|
+
"@aztec/p2p": "0.0.1-commit.431c48d",
|
|
52
|
+
"@aztec/p2p-bootstrap": "0.0.1-commit.431c48d",
|
|
53
|
+
"@aztec/protocol-contracts": "0.0.1-commit.431c48d",
|
|
54
|
+
"@aztec/prover-client": "0.0.1-commit.431c48d",
|
|
55
|
+
"@aztec/prover-node": "0.0.1-commit.431c48d",
|
|
56
|
+
"@aztec/pxe": "0.0.1-commit.431c48d",
|
|
57
|
+
"@aztec/sequencer-client": "0.0.1-commit.431c48d",
|
|
58
|
+
"@aztec/standard-contracts": "0.0.1-commit.431c48d",
|
|
59
|
+
"@aztec/stdlib": "0.0.1-commit.431c48d",
|
|
60
|
+
"@aztec/telemetry-client": "0.0.1-commit.431c48d",
|
|
61
|
+
"@aztec/txe": "0.0.1-commit.431c48d",
|
|
62
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.431c48d",
|
|
63
|
+
"@aztec/wallets": "0.0.1-commit.431c48d",
|
|
64
|
+
"@aztec/world-state": "0.0.1-commit.431c48d",
|
|
63
65
|
"@iarna/toml": "^2.2.5",
|
|
64
66
|
"@types/chalk": "^2.2.0",
|
|
65
67
|
"abitype": "^0.8.11",
|
|
@@ -67,7 +69,8 @@
|
|
|
67
69
|
"commander": "^12.1.0",
|
|
68
70
|
"koa": "^2.16.1",
|
|
69
71
|
"koa-router": "^13.1.1",
|
|
70
|
-
"viem": "npm:@aztec/viem@2.38.2"
|
|
72
|
+
"viem": "npm:@aztec/viem@2.38.2",
|
|
73
|
+
"zod": "^4"
|
|
71
74
|
},
|
|
72
75
|
"files": [
|
|
73
76
|
"dest",
|
package/scripts/add_crate.sh
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
4
|
# Creates a contract+test crate pair and adds them to an existing workspace.
|
|
5
|
-
# Usage: add_crate.sh <crate_name>
|
|
5
|
+
# Usage: add_crate.sh <crate_name> <template>
|
|
6
6
|
# Must be called from a workspace root that already has Nargo.toml with [workspace].
|
|
7
7
|
|
|
8
8
|
crate_name=$1
|
|
9
|
+
template=$2
|
|
9
10
|
|
|
10
11
|
if [ -z "$crate_name" ]; then
|
|
11
12
|
echo "Error: crate name is required"
|
|
@@ -31,72 +32,22 @@ fi
|
|
|
31
32
|
|
|
32
33
|
# Get the actual aztec version for the git tag.
|
|
33
34
|
AZTEC_VERSION=$(jq -r '.version' $(dirname $0)/../package.json)
|
|
35
|
+
TEMPLATE_DIR="$(dirname $0)/templates/$template"
|
|
34
36
|
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
[dependencies]
|
|
43
|
-
aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v${AZTEC_VERSION}", directory="aztec" }
|
|
44
|
-
CEOF
|
|
45
|
-
|
|
46
|
-
cat > "$contract_dir/src/main.nr" << 'EOF'
|
|
47
|
-
use aztec::macros::aztec;
|
|
48
|
-
|
|
49
|
-
#[aztec]
|
|
50
|
-
pub contract Main {
|
|
51
|
-
use aztec::macros::functions::{external, initializer};
|
|
52
|
-
|
|
53
|
-
#[initializer]
|
|
54
|
-
#[external("private")]
|
|
55
|
-
fn constructor() {}
|
|
56
|
-
}
|
|
57
|
-
EOF
|
|
58
|
-
|
|
59
|
-
# Create test crate
|
|
60
|
-
mkdir -p "$test_dir/src"
|
|
61
|
-
cat > "$test_dir/Nargo.toml" << TEOF
|
|
62
|
-
[package]
|
|
63
|
-
name = "${crate_name}_test"
|
|
64
|
-
type = "lib"
|
|
65
|
-
|
|
66
|
-
[dependencies]
|
|
67
|
-
aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v${AZTEC_VERSION}", directory="aztec" }
|
|
68
|
-
${crate_name}_contract = { path = "../${contract_dir}" }
|
|
69
|
-
TEOF
|
|
70
|
-
|
|
71
|
-
cat > "$test_dir/src/lib.nr" << 'NOIR'
|
|
72
|
-
use aztec::test::helpers::test_environment::TestEnvironment;
|
|
73
|
-
use __CRATE_NAME___contract::Main;
|
|
74
|
-
|
|
75
|
-
#[test]
|
|
76
|
-
unconstrained fn test_constructor() {
|
|
77
|
-
let mut env = TestEnvironment::new();
|
|
78
|
-
let deployer = env.create_light_account();
|
|
79
|
-
|
|
80
|
-
// Deploy the contract with the default constructor:
|
|
81
|
-
let contract_address = env.deploy("@__CRATE_NAME___contract/Main").with_private_initializer(
|
|
82
|
-
deployer,
|
|
83
|
-
Main::interface().constructor(),
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// Deploy without an initializer:
|
|
87
|
-
let contract_address = env.deploy("@__CRATE_NAME___contract/Main").without_initializer();
|
|
88
|
-
}
|
|
89
|
-
NOIR
|
|
90
|
-
|
|
91
|
-
sed -i "s/__CRATE_NAME__/${crate_name}/g" "$test_dir/src/lib.nr"
|
|
37
|
+
# Copy template crates and substitute placeholders
|
|
38
|
+
cp -r "$TEMPLATE_DIR/contract" "$contract_dir"
|
|
39
|
+
cp -r "$TEMPLATE_DIR/test" "$test_dir"
|
|
40
|
+
# Use perl -i for portability across os.
|
|
41
|
+
find "$contract_dir" "$test_dir" -type f -exec \
|
|
42
|
+
perl -i -pe "s/__CRATE_NAME__/${crate_name}/g; s/__AZTEC_VERSION__/${AZTEC_VERSION}/g" {} +
|
|
92
43
|
|
|
93
44
|
# Add members to workspace Nargo.toml
|
|
94
45
|
if grep -q 'members\s*=\s*\[\s*\]' Nargo.toml; then
|
|
95
46
|
# Empty array: members = []
|
|
96
|
-
|
|
47
|
+
perl -i -pe "s|members\s*=\s*\[\s*\]|members = [\"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
|
|
97
48
|
else
|
|
98
49
|
# Non-empty array: add before closing ]
|
|
99
|
-
|
|
50
|
+
perl -i -pe "s|(members\s*=\s*\[.*)\]|\1, \"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
|
|
100
51
|
fi
|
|
101
52
|
|
|
102
53
|
echo "Created crates '${contract_dir}' and '${test_dir}'"
|
package/scripts/aztec.sh
CHANGED
|
@@ -23,13 +23,17 @@ case $cmd in
|
|
|
23
23
|
# Attempt to compile, no-op if there are no changes
|
|
24
24
|
node --no-warnings "$script_dir/../dest/bin/index.js" compile
|
|
25
25
|
|
|
26
|
-
export LOG_LEVEL="${LOG_LEVEL:-"error;trace:
|
|
26
|
+
export LOG_LEVEL="${LOG_LEVEL:-"error;trace:^contract:"}"
|
|
27
27
|
aztec start --txe --port 8081 &
|
|
28
28
|
server_pid=$!
|
|
29
29
|
trap 'kill $server_pid &>/dev/null || true' EXIT
|
|
30
|
+
if ! command -v nc &>/dev/null; then
|
|
31
|
+
echo "Error: 'nc' (netcat) is required but not installed." >&2
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
30
34
|
while ! nc -z 127.0.0.1 8081 &>/dev/null; do sleep 0.2; done
|
|
31
35
|
export NARGO_FOREIGN_CALL_TIMEOUT=300000
|
|
32
|
-
nargo test --silence-warnings --oracle-resolver http://127.0.0.1:8081
|
|
36
|
+
nargo test --silence-warnings --oracle-resolver http://127.0.0.1:8081 "$@"
|
|
33
37
|
;;
|
|
34
38
|
start)
|
|
35
39
|
if [ "${1:-}" == "--local-network" ]; then
|
package/scripts/init.sh
CHANGED
|
@@ -16,11 +16,11 @@ Options:
|
|
|
16
16
|
-h, --help Print help
|
|
17
17
|
|
|
18
18
|
This command creates a new Aztec Noir project in the current directory with
|
|
19
|
-
a workspace containing a contract
|
|
20
|
-
|
|
19
|
+
a workspace containing a Counter contract example with tests. The Counter
|
|
20
|
+
demonstrates private state, private functions, and utility reads.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
Use 'aztec new <name>' to create a blank contract project, or to add another
|
|
23
|
+
contract to an existing workspace.
|
|
24
24
|
EOF
|
|
25
25
|
exit 0
|
|
26
26
|
;;
|
|
@@ -36,4 +36,4 @@ done
|
|
|
36
36
|
package_name="$(basename $(pwd))"
|
|
37
37
|
|
|
38
38
|
echo "Initializing Aztec contract project..."
|
|
39
|
-
$script_path/setup_workspace.sh "$package_name"
|
|
39
|
+
$script_path/setup_workspace.sh "$package_name" counter
|
package/scripts/new.sh
CHANGED
|
@@ -68,7 +68,7 @@ fi
|
|
|
68
68
|
if [ -f "Nargo.toml" ] && grep -q '\[workspace\]' Nargo.toml; then
|
|
69
69
|
# Add crate pair to existing workspace
|
|
70
70
|
echo "Adding contract '$package_name' to existing workspace..."
|
|
71
|
-
$script_path/add_crate.sh "$package_name"
|
|
71
|
+
$script_path/add_crate.sh "$package_name" blank
|
|
72
72
|
else
|
|
73
73
|
# Create new workspace
|
|
74
74
|
if [ -d "$project_path" ] && [ "$(ls -A $project_path 2>/dev/null)" ]; then
|
|
@@ -79,5 +79,5 @@ else
|
|
|
79
79
|
echo "Creating new Aztec contract project at $project_path..."
|
|
80
80
|
mkdir -p "$project_path"
|
|
81
81
|
cd "$project_path"
|
|
82
|
-
$script_path/setup_workspace.sh "$package_name"
|
|
82
|
+
$script_path/setup_workspace.sh "$package_name" blank
|
|
83
83
|
fi
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
4
|
# Creates an Aztec contract workspace with a contract crate and a test crate.
|
|
5
|
-
# Usage: setup_workspace.sh <package_name>
|
|
5
|
+
# Usage: setup_workspace.sh <package_name> <template>
|
|
6
6
|
# Must be called from the workspace root directory.
|
|
7
7
|
|
|
8
8
|
package_name=$1
|
|
9
|
+
template=$2
|
|
9
10
|
script_path=$(realpath $(dirname "$0"))
|
|
10
11
|
|
|
11
12
|
if [ -z "$package_name" ]; then
|
|
@@ -26,7 +27,7 @@ members = []
|
|
|
26
27
|
EOF
|
|
27
28
|
|
|
28
29
|
# Create the first crate pair
|
|
29
|
-
$script_path/add_crate.sh "$package_name"
|
|
30
|
+
$script_path/add_crate.sh "$package_name" "$template"
|
|
30
31
|
|
|
31
32
|
# Create README
|
|
32
33
|
cat > README.md << REOF
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
use aztec::test::helpers::test_environment::TestEnvironment;
|
|
2
|
+
use __CRATE_NAME___contract::Main;
|
|
3
|
+
|
|
4
|
+
#[test]
|
|
5
|
+
unconstrained fn test_constructor() {
|
|
6
|
+
let mut env = TestEnvironment::new();
|
|
7
|
+
let deployer = env.create_light_account();
|
|
8
|
+
|
|
9
|
+
let _contract_address = env.deploy("@__CRATE_NAME___contract/Main")
|
|
10
|
+
.with_private_initializer(deployer, Main::interface().constructor());
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "__CRATE_NAME___contract"
|
|
3
|
+
type = "contract"
|
|
4
|
+
|
|
5
|
+
[dependencies]
|
|
6
|
+
aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v__AZTEC_VERSION__", directory="aztec" }
|
|
7
|
+
balance_set = { git="https://github.com/AztecProtocol/aztec-nr", tag="v__AZTEC_VERSION__", directory="balance-set" }
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
use aztec::macros::aztec;
|
|
2
|
+
|
|
3
|
+
#[aztec]
|
|
4
|
+
pub contract Counter {
|
|
5
|
+
use aztec::{
|
|
6
|
+
macros::{functions::{external, initializer}, storage::storage},
|
|
7
|
+
messages::delivery::MessageDelivery,
|
|
8
|
+
protocol::address::AztecAddress,
|
|
9
|
+
state_vars::Owned,
|
|
10
|
+
};
|
|
11
|
+
use balance_set::BalanceSet;
|
|
12
|
+
|
|
13
|
+
#[storage]
|
|
14
|
+
struct Storage<Context> {
|
|
15
|
+
// Each owner has their own counter, stored as private encrypted notes.
|
|
16
|
+
// Owned: dictates who will receive the encrypted notes.
|
|
17
|
+
// BalanceSet: manages the underlying notes, providing add/sub/balance_of.
|
|
18
|
+
counters: Owned<BalanceSet<Context>, Context>,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Sets the owner's counter to an initial value.
|
|
22
|
+
//
|
|
23
|
+
// #[external("private")]: executes on the user's device, inputs are hidden from everyone.
|
|
24
|
+
#[initializer]
|
|
25
|
+
#[external("private")]
|
|
26
|
+
fn constructor(initial_value: u128, owner: AztecAddress) {
|
|
27
|
+
// Delivers the note to the recipient onchain.
|
|
28
|
+
// Without delivery, the recipient can't find or decrypt the note.
|
|
29
|
+
self.storage.counters.at(owner).add(initial_value).deliver(
|
|
30
|
+
MessageDelivery::onchain_unconstrained(),
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Adds 1 to the owner's counter.
|
|
35
|
+
#[external("private")]
|
|
36
|
+
fn increment(owner: AztecAddress) {
|
|
37
|
+
self.storage.counters.at(owner).add(1).deliver(MessageDelivery::onchain_unconstrained());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Returns the current value of the owner's counter.
|
|
41
|
+
//
|
|
42
|
+
// #[external("utility")]: runs off-chain, no transaction created, no cost.
|
|
43
|
+
// Only the owner can decrypt and read their own counter.
|
|
44
|
+
#[external("utility")]
|
|
45
|
+
unconstrained fn get_counter(owner: AztecAddress) -> u128 {
|
|
46
|
+
self.storage.counters.at(owner).balance_of()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
use aztec::{protocol::address::AztecAddress, test::helpers::test_environment::TestEnvironment};
|
|
2
|
+
use __CRATE_NAME___contract::Counter;
|
|
3
|
+
|
|
4
|
+
unconstrained fn setup(initial_value: u128) -> (TestEnvironment, AztecAddress, AztecAddress) {
|
|
5
|
+
let mut env = TestEnvironment::new();
|
|
6
|
+
let owner = env.create_light_account();
|
|
7
|
+
|
|
8
|
+
let contract_address = env.deploy("@__CRATE_NAME___contract/Counter")
|
|
9
|
+
.with_private_initializer(owner, Counter::interface().constructor(initial_value, owner));
|
|
10
|
+
|
|
11
|
+
(env, contract_address, owner)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[test]
|
|
15
|
+
unconstrained fn test_constructor() {
|
|
16
|
+
let initial_value = 5;
|
|
17
|
+
let (env, contract_address, owner) = setup(initial_value);
|
|
18
|
+
|
|
19
|
+
let counter = env.execute_utility(Counter::at(contract_address).get_counter(owner));
|
|
20
|
+
assert_eq(counter, initial_value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#[test]
|
|
24
|
+
unconstrained fn test_increment() {
|
|
25
|
+
let initial_value = 5;
|
|
26
|
+
let (mut env, contract_address, owner) = setup(initial_value);
|
|
27
|
+
|
|
28
|
+
env.call_private(owner, Counter::at(contract_address).increment(owner));
|
|
29
|
+
|
|
30
|
+
let counter = env.execute_utility(Counter::at(contract_address).get_counter(owner));
|
|
31
|
+
assert_eq(counter, initial_value + 1);
|
|
32
|
+
}
|
package/src/bin/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { Command } from 'commander';
|
|
|
18
18
|
import { injectCompileCommand } from '../cli/cmds/compile.js';
|
|
19
19
|
import { injectMigrateCommand } from '../cli/cmds/migrate_ha_db.js';
|
|
20
20
|
import { injectProfileCommand } from '../cli/cmds/profile.js';
|
|
21
|
+
import { injectProverCommand } from '../cli/cmds/prover.js';
|
|
21
22
|
import { injectAztecCommands } from '../cli/index.js';
|
|
22
23
|
|
|
23
24
|
const NETWORK_FLAG = 'network';
|
|
@@ -47,7 +48,7 @@ async function main() {
|
|
|
47
48
|
await enrichEnvironmentWithNetworkConfig(networkName);
|
|
48
49
|
enrichEnvironmentWithChainName(networkName);
|
|
49
50
|
|
|
50
|
-
const cliVersion = getPackageVersion()
|
|
51
|
+
const cliVersion = getPackageVersion();
|
|
51
52
|
let program = new Command('aztec');
|
|
52
53
|
program.description('Aztec command line interface').version(cliVersion).enablePositionalOptions();
|
|
53
54
|
program = injectAztecCommands(program, userLog, debugLogger);
|
|
@@ -61,6 +62,7 @@ async function main() {
|
|
|
61
62
|
program = injectCompileCommand(program, userLog);
|
|
62
63
|
program = injectProfileCommand(program, userLog);
|
|
63
64
|
program = injectMigrateCommand(program, userLog);
|
|
65
|
+
program = injectProverCommand(program, userLog);
|
|
64
66
|
|
|
65
67
|
await program.parseAsync(process.argv);
|
|
66
68
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { registerAztecNodeRpcHandlers } from '@aztec/aztec-node';
|
|
1
2
|
import { getActiveNetworkName } from '@aztec/foundation/config';
|
|
2
3
|
import {
|
|
3
4
|
type NamespacedApiHandlers,
|
|
@@ -6,11 +7,14 @@ import {
|
|
|
6
7
|
startHttpRpcServer,
|
|
7
8
|
} from '@aztec/foundation/json-rpc/server';
|
|
8
9
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
9
|
-
import type
|
|
10
|
-
import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
10
|
+
import { type ChainConfig, getRpcCorsAllowedOrigins } from '@aztec/stdlib/config';
|
|
11
11
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
12
12
|
import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
getOtelJsonRpcDiagnosticsMiddleware,
|
|
15
|
+
getOtelJsonRpcPropagationMiddleware,
|
|
16
|
+
getOtelJsonRpcServerMetricsMiddleware,
|
|
17
|
+
} from '@aztec/telemetry-client';
|
|
14
18
|
|
|
15
19
|
import { createLocalNetwork } from '../local-network/index.js';
|
|
16
20
|
import { github, splash } from '../splash.js';
|
|
@@ -27,30 +31,22 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
27
31
|
let config: ChainConfig | undefined = undefined;
|
|
28
32
|
|
|
29
33
|
if (options.localNetwork) {
|
|
30
|
-
const localNetwork = extractNamespacedOptions(options, '
|
|
31
|
-
localNetwork.testAccounts = true;
|
|
34
|
+
const localNetwork = extractNamespacedOptions(options, 'localNetwork');
|
|
32
35
|
userLog(`${splash}\n${github}\n\n`);
|
|
33
|
-
userLog(`Setting up Aztec local network ${packageVersion
|
|
36
|
+
userLog(`Setting up Aztec local network ${packageVersion}, please stand by...`);
|
|
34
37
|
|
|
35
38
|
const { node, stop } = await createLocalNetwork(
|
|
36
39
|
{
|
|
37
40
|
l1Mnemonic: localNetwork.l1Mnemonic,
|
|
38
41
|
l1RpcUrls: options.l1RpcUrls,
|
|
39
42
|
testAccounts: localNetwork.testAccounts,
|
|
40
|
-
realProofs: false,
|
|
41
|
-
// Setting the epoch duration to 2 by default for local network. This allows the epoch to be "proven" faster, so
|
|
42
|
-
// the users can consume out hash without having to wait for a long time.
|
|
43
|
-
// Note: We are not proving anything in the local network (realProofs == false). But in `createLocalNetwork`,
|
|
44
|
-
// the EpochTestSettler will set the out hash to the outbox when an epoch is complete.
|
|
45
|
-
aztecEpochDuration: 2,
|
|
46
43
|
},
|
|
47
44
|
userLog,
|
|
48
45
|
);
|
|
49
46
|
|
|
50
47
|
// Start Node and PXE JSON-RPC server
|
|
51
48
|
signalHandlers.push(stop);
|
|
52
|
-
|
|
53
|
-
adminServices.node = [node, AztecNodeAdminApiSchema];
|
|
49
|
+
registerAztecNodeRpcHandlers(node, services, adminServices, { debug: true });
|
|
54
50
|
} else {
|
|
55
51
|
// Route --prover-node through startNode
|
|
56
52
|
if (options.proverNode && !options.node) {
|
|
@@ -64,9 +60,6 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
64
60
|
} else if (options.bot) {
|
|
65
61
|
const { startBot } = await import('./cmds/start_bot.js');
|
|
66
62
|
await startBot(options, signalHandlers, services, userLog);
|
|
67
|
-
} else if (options.archiver) {
|
|
68
|
-
const { startArchiver } = await import('./cmds/start_archiver.js');
|
|
69
|
-
({ config } = await startArchiver(options, signalHandlers, services));
|
|
70
63
|
} else if (options.p2pBootstrap) {
|
|
71
64
|
const { startP2PBootstrap } = await import('./cmds/start_p2p_bootstrap.js');
|
|
72
65
|
({ config } = await startP2PBootstrap(options, signalHandlers, services, userLog));
|
|
@@ -78,7 +71,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
78
71
|
await startProverBroker(options, signalHandlers, services, userLog);
|
|
79
72
|
} else if (options.txe) {
|
|
80
73
|
const { startTXE } = await import('./cmds/start_txe.js');
|
|
81
|
-
await startTXE(options, debugLogger);
|
|
74
|
+
await startTXE(options, signalHandlers, debugLogger);
|
|
82
75
|
} else if (options.sequencer) {
|
|
83
76
|
userLog(`Cannot run a standalone sequencer without a node`);
|
|
84
77
|
process.exit(1);
|
|
@@ -94,21 +87,36 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
94
87
|
|
|
95
88
|
// Start the main JSON-RPC server
|
|
96
89
|
if (Object.entries(services).length > 0) {
|
|
90
|
+
if (services.aztec) {
|
|
91
|
+
const { BarretenbergSync } = await import('@aztec/bb.js');
|
|
92
|
+
// JSON-RPC schema parsing may decompress compressed Chonk proofs before the node handler runs.
|
|
93
|
+
await BarretenbergSync.initSingleton();
|
|
94
|
+
}
|
|
95
|
+
|
|
97
96
|
const rpcServer = createNamespacedSafeJsonRpcServer(services, {
|
|
97
|
+
diagnostic: getOtelJsonRpcDiagnosticsMiddleware(),
|
|
98
98
|
http200OnError: false,
|
|
99
99
|
log: debugLogger,
|
|
100
|
-
middlewares: [
|
|
100
|
+
middlewares: [
|
|
101
|
+
getOtelJsonRpcServerMetricsMiddleware(),
|
|
102
|
+
getOtelJsonRpcPropagationMiddleware(),
|
|
103
|
+
getVersioningMiddleware(versions, versioningOpts),
|
|
104
|
+
],
|
|
101
105
|
maxBatchSize: options.rpcMaxBatchSize,
|
|
102
106
|
maxBodySizeBytes: options.rpcMaxBodySize,
|
|
107
|
+
corsAllowedHeaders: options.rpcCorsAllowedHeaders ?? [],
|
|
108
|
+
corsAllowedOrigins: getRpcCorsAllowedOrigins(options),
|
|
109
|
+
});
|
|
110
|
+
const { port } = await startHttpRpcServer(rpcServer, {
|
|
111
|
+
port: options.port,
|
|
112
|
+
keepAliveTimeoutMs: options.rpcHttpKeepAliveTimeoutMs,
|
|
113
|
+
headersTimeoutMs: options.rpcHttpHeadersTimeoutMs,
|
|
103
114
|
});
|
|
104
|
-
const { port } = await startHttpRpcServer(rpcServer, { port: options.port });
|
|
105
115
|
debugLogger.info(`Aztec Server listening on port ${port}`, versions);
|
|
106
116
|
}
|
|
107
117
|
|
|
108
118
|
// If there are any admin services, start a separate JSON-RPC server for them
|
|
109
119
|
if (Object.entries(adminServices).length > 0) {
|
|
110
|
-
const adminMiddlewares = [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions, versioningOpts)];
|
|
111
|
-
|
|
112
120
|
// Resolve the admin API key (auto-generated and persisted, or opt-out)
|
|
113
121
|
const apiKeyResolution = await resolveAdminApiKey(
|
|
114
122
|
{
|
|
@@ -119,13 +127,18 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
119
127
|
},
|
|
120
128
|
debugLogger,
|
|
121
129
|
);
|
|
122
|
-
if (apiKeyResolution) {
|
|
123
|
-
adminMiddlewares.unshift(getApiKeyAuthMiddleware(apiKeyResolution.apiKeyHash));
|
|
124
|
-
} else {
|
|
130
|
+
if (!apiKeyResolution) {
|
|
125
131
|
debugLogger.warn('No admin API key set — admin endpoint is unauthenticated');
|
|
126
132
|
}
|
|
133
|
+
const adminMiddlewares = [
|
|
134
|
+
getOtelJsonRpcServerMetricsMiddleware(),
|
|
135
|
+
...(apiKeyResolution ? [getApiKeyAuthMiddleware(apiKeyResolution.apiKeyHash)] : []),
|
|
136
|
+
getOtelJsonRpcPropagationMiddleware(),
|
|
137
|
+
getVersioningMiddleware(versions, versioningOpts),
|
|
138
|
+
];
|
|
127
139
|
|
|
128
140
|
const rpcServer = createNamespacedSafeJsonRpcServer(adminServices, {
|
|
141
|
+
diagnostic: getOtelJsonRpcDiagnosticsMiddleware(),
|
|
129
142
|
http200OnError: false,
|
|
130
143
|
log: debugLogger,
|
|
131
144
|
middlewares: adminMiddlewares,
|