@aztec/aztec 0.0.0-test.1 → 0.0.1-commit.0208eb9
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/README.md +1 -1
- package/dest/bin/index.d.ts +1 -1
- package/dest/bin/index.js +23 -12
- 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 +40 -40
- package/dest/cli/aztec_start_options.d.ts +5 -3
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +146 -225
- package/dest/cli/cli.d.ts +1 -1
- package/dest/cli/cli.d.ts.map +1 -1
- package/dest/cli/cli.js +12 -7
- package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
- package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
- package/dest/cli/cmds/migrate_ha_db.js +27 -0
- package/dest/cli/cmds/start_archiver.d.ts +1 -1
- package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
- package/dest/cli/cmds/start_archiver.js +24 -18
- package/dest/cli/cmds/start_bot.d.ts +4 -7
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +25 -14
- package/dest/cli/cmds/start_node.d.ts +2 -2
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +68 -81
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
- package/dest/cli/cmds/start_p2p_bootstrap.js +10 -6
- package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_agent.js +35 -6
- 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 +12 -6
- package/dest/cli/cmds/start_prover_node.d.ts +1 -1
- package/dest/cli/cmds/start_prover_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_node.js +44 -46
- package/dest/cli/cmds/start_txe.d.ts +1 -1
- package/dest/cli/index.d.ts +1 -1
- package/dest/cli/preload_crs.d.ts +3 -0
- package/dest/cli/preload_crs.d.ts.map +1 -0
- package/dest/cli/preload_crs.js +6 -0
- package/dest/cli/release_version.d.ts +2 -0
- package/dest/cli/release_version.d.ts.map +1 -0
- package/dest/cli/release_version.js +14 -0
- package/dest/cli/util.d.ts +38 -7
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +198 -28
- package/dest/cli/versioning.d.ts +1 -1
- package/dest/cli/versioning.js +3 -3
- package/dest/examples/token.d.ts +1 -1
- package/dest/examples/token.js +31 -18
- package/dest/examples/util.d.ts +5 -6
- package/dest/examples/util.d.ts.map +1 -1
- package/dest/examples/util.js +5 -6
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/local-network/banana_fpc.d.ts +10 -0
- package/dest/local-network/banana_fpc.d.ts.map +1 -0
- package/dest/{sandbox → local-network}/banana_fpc.js +22 -24
- package/dest/local-network/index.d.ts +4 -0
- package/dest/local-network/index.d.ts.map +1 -0
- package/dest/local-network/index.js +3 -0
- package/dest/local-network/local-network.d.ts +71 -0
- package/dest/local-network/local-network.d.ts.map +1 -0
- package/dest/local-network/local-network.js +194 -0
- package/dest/local-network/sponsored_fpc.d.ts +5 -0
- package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
- package/dest/local-network/sponsored_fpc.js +18 -0
- package/dest/mnemonic.d.ts +1 -1
- package/dest/splash.d.ts +1 -1
- package/dest/testing/anvil_test_watcher.d.ts +34 -0
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -0
- package/dest/testing/anvil_test_watcher.js +144 -0
- package/dest/testing/cheat_codes.d.ts +43 -0
- package/dest/testing/cheat_codes.d.ts.map +1 -0
- package/dest/testing/cheat_codes.js +62 -0
- package/dest/testing/epoch_test_settler.d.ts +19 -0
- package/dest/testing/epoch_test_settler.d.ts.map +1 -0
- package/dest/testing/epoch_test_settler.js +62 -0
- package/dest/testing/index.d.ts +5 -0
- package/dest/testing/index.d.ts.map +1 -0
- package/dest/testing/index.js +4 -0
- package/package.json +55 -45
- package/scripts/aztec.sh +63 -0
- package/scripts/compile.sh +44 -0
- package/scripts/extract_function.js +47 -0
- package/scripts/flamegraph.sh +59 -0
- package/scripts/init.sh +35 -0
- package/scripts/new.sh +59 -0
- package/scripts/setup_project.sh +31 -0
- package/src/bin/index.ts +28 -12
- package/src/cli/aztec_start_action.ts +36 -38
- package/src/cli/aztec_start_options.ts +161 -222
- package/src/cli/cli.ts +20 -11
- package/src/cli/cmds/migrate_ha_db.ts +43 -0
- package/src/cli/cmds/start_archiver.ts +15 -20
- package/src/cli/cmds/start_bot.ts +36 -13
- package/src/cli/cmds/start_node.ts +91 -86
- package/src/cli/cmds/start_p2p_bootstrap.ts +14 -6
- package/src/cli/cmds/start_prover_agent.ts +26 -14
- package/src/cli/cmds/start_prover_broker.ts +29 -5
- package/src/cli/cmds/start_prover_node.ts +54 -51
- package/src/cli/preload_crs.ts +7 -0
- package/src/cli/release_version.ts +21 -0
- package/src/cli/util.ts +208 -34
- package/src/cli/versioning.ts +3 -3
- package/src/examples/token.ts +21 -19
- package/src/examples/util.ts +6 -8
- package/src/index.ts +5 -6
- package/src/{sandbox → local-network}/banana_fpc.ts +27 -28
- package/src/local-network/index.ts +7 -0
- package/src/local-network/local-network.ts +240 -0
- package/src/local-network/sponsored_fpc.ts +26 -0
- package/src/testing/anvil_test_watcher.ts +166 -0
- package/src/testing/cheat_codes.ts +79 -0
- package/src/testing/epoch_test_settler.ts +71 -0
- package/src/testing/index.ts +4 -0
- package/dest/cli/chain_l2_config.d.ts +0 -19
- package/dest/cli/chain_l2_config.d.ts.map +0 -1
- package/dest/cli/chain_l2_config.js +0 -56
- package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
- package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
- package/dest/cli/cmds/start_blob_sink.js +0 -17
- package/dest/cli/cmds/start_faucet.d.ts +0 -4
- package/dest/cli/cmds/start_faucet.d.ts.map +0 -1
- package/dest/cli/cmds/start_faucet.js +0 -20
- package/dest/cli/cmds/start_pxe.d.ts +0 -16
- package/dest/cli/cmds/start_pxe.d.ts.map +0 -1
- package/dest/cli/cmds/start_pxe.js +0 -95
- package/dest/cli/get_l1_config.d.ts +0 -7
- package/dest/cli/get_l1_config.d.ts.map +0 -1
- package/dest/cli/get_l1_config.js +0 -13
- package/dest/sandbox/banana_fpc.d.ts +0 -11
- package/dest/sandbox/banana_fpc.d.ts.map +0 -1
- package/dest/sandbox/index.d.ts +0 -5
- package/dest/sandbox/index.d.ts.map +0 -1
- package/dest/sandbox/index.js +0 -4
- package/dest/sandbox/sandbox.d.ts +0 -76
- package/dest/sandbox/sandbox.d.ts.map +0 -1
- package/dest/sandbox/sandbox.js +0 -181
- package/dest/sandbox/sponsored_fee_payment_method.d.ts +0 -23
- package/dest/sandbox/sponsored_fee_payment_method.d.ts.map +0 -1
- package/dest/sandbox/sponsored_fee_payment_method.js +0 -36
- package/dest/sandbox/sponsored_fpc.d.ts +0 -6
- package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
- package/dest/sandbox/sponsored_fpc.js +0 -26
- package/src/cli/chain_l2_config.ts +0 -74
- package/src/cli/cmds/start_blob_sink.ts +0 -31
- package/src/cli/cmds/start_faucet.ts +0 -34
- package/src/cli/cmds/start_pxe.ts +0 -129
- package/src/cli/get_l1_config.ts +0 -18
- package/src/sandbox/index.ts +0 -5
- package/src/sandbox/sandbox.ts +0 -229
- package/src/sandbox/sponsored_fee_payment_method.ts +0 -46
- package/src/sandbox/sponsored_fpc.ts +0 -38
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
// Simple script to extract a contract function as a separate Noir artifact.
|
|
6
|
+
// We need to use this since the transpiling that we do on public functions make the contract artifacts
|
|
7
|
+
// unreadable by noir tooling, since they are no longer following the noir artifact format.
|
|
8
|
+
async function main() {
|
|
9
|
+
let [contractArtifactPath, functionName] = process.argv.slice(2);
|
|
10
|
+
if (!contractArtifactPath || !functionName) {
|
|
11
|
+
console.log('Usage: node extractFunctionAsNoirArtifact.js <contractArtifactPath> <functionName>');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const contractArtifact = JSON.parse(await fs.readFile(contractArtifactPath, 'utf8'));
|
|
16
|
+
const func = contractArtifact.functions.find(f => f.name === functionName);
|
|
17
|
+
if (!func) {
|
|
18
|
+
console.error(`Function ${functionName} not found in ${contractArtifactPath}`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const artifact = {
|
|
23
|
+
noir_version: contractArtifact.noir_version,
|
|
24
|
+
hash: 0,
|
|
25
|
+
abi: func.abi,
|
|
26
|
+
bytecode: func.bytecode,
|
|
27
|
+
debug_symbols: func.debug_symbols,
|
|
28
|
+
file_map: contractArtifact.file_map,
|
|
29
|
+
expression_width: {
|
|
30
|
+
Bounded: {
|
|
31
|
+
width: 4,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const outputDir = path.dirname(contractArtifactPath);
|
|
37
|
+
const outputName = path.basename(contractArtifactPath, '.json') + `-${functionName}.json`;
|
|
38
|
+
|
|
39
|
+
const outPath = path.join(outputDir, outputName);
|
|
40
|
+
|
|
41
|
+
await fs.writeFile(outPath, JSON.stringify(artifact, null, 2));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
main().catch(err => {
|
|
45
|
+
console.error(err);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
# If first arg is -h or --help, print usage.
|
|
5
|
+
if [ $# -lt 2 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
|
|
6
|
+
cat << 'EOF'
|
|
7
|
+
Aztec Flamegraph - Generate a gate count flamegraph for an aztec contract function.
|
|
8
|
+
|
|
9
|
+
Usage: aztec flamegraph <contract_artifact> <function>
|
|
10
|
+
|
|
11
|
+
Options:
|
|
12
|
+
-h, --help Print help
|
|
13
|
+
|
|
14
|
+
Will output an svg at <artifact_path>/<contract>-<function>-flamegraph.svg.
|
|
15
|
+
You can open it in your browser to view it.
|
|
16
|
+
|
|
17
|
+
EOF
|
|
18
|
+
exit 0
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
cleanup() {
|
|
22
|
+
set +e
|
|
23
|
+
if [ -f "$function_artifact" ]; then
|
|
24
|
+
rm -f "$function_artifact"
|
|
25
|
+
fi
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
trap cleanup EXIT
|
|
29
|
+
|
|
30
|
+
# Get the directory of the script
|
|
31
|
+
script_dir=$(realpath $(dirname $0))
|
|
32
|
+
|
|
33
|
+
PROFILER=${PROFILER_PATH:-noir-profiler}
|
|
34
|
+
BB=${BB:-bb}
|
|
35
|
+
|
|
36
|
+
# first console arg is contract name in camel case or path to contract artifact
|
|
37
|
+
contract=$1
|
|
38
|
+
|
|
39
|
+
# second console arg is the contract function
|
|
40
|
+
function=$2
|
|
41
|
+
|
|
42
|
+
if [ ! -f "$contract" ]; then
|
|
43
|
+
echo "Error: Contract artifact not found at: $contract"
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
artifact_path=$contract
|
|
47
|
+
function_artifact="${artifact_path%%.json}-${function}.json"
|
|
48
|
+
output_dir=$(dirname "$artifact_path")
|
|
49
|
+
|
|
50
|
+
# Extract artifact for the specific function.
|
|
51
|
+
node $script_dir/extract_function.js "$artifact_path" $function
|
|
52
|
+
|
|
53
|
+
# Generate the flamegraph
|
|
54
|
+
$PROFILER gates --artifact-path "$function_artifact" --backend-path "$BB" --backend-gates-command "gates" --output "$output_dir" --scheme chonk --include_gates_per_opcode
|
|
55
|
+
|
|
56
|
+
# Save as $artifact_name-$function-flamegraph.svg
|
|
57
|
+
output_file="${function_artifact%%.json}-flamegraph.svg"
|
|
58
|
+
mv "$output_dir/__aztec_nr_internals__${function}_gates.svg" "$output_file"
|
|
59
|
+
echo "Flamegraph generated at: $output_file"
|
package/scripts/init.sh
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
NARGO=${NARGO:-nargo}
|
|
5
|
+
script_path=$(realpath $(dirname "$0"))
|
|
6
|
+
|
|
7
|
+
for arg in "$@"; do
|
|
8
|
+
if [ "$arg" == "--help" ] || [ "$arg" == "-h" ]; then
|
|
9
|
+
cat << 'EOF'
|
|
10
|
+
Aztec Init - Create a new Aztec Noir project in the current directory
|
|
11
|
+
|
|
12
|
+
Usage: aztec init [OPTIONS]
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
--name <NAME> Name of the package [default: current directory name]
|
|
16
|
+
--lib Use a library template
|
|
17
|
+
-h, --help Print help
|
|
18
|
+
|
|
19
|
+
This command creates a new Aztec Noir project in the current directory using nargo
|
|
20
|
+
and automatically adds the Aztec.nr dependency to your Nargo.toml file.
|
|
21
|
+
|
|
22
|
+
EOF
|
|
23
|
+
exit 0
|
|
24
|
+
fi
|
|
25
|
+
if [ "$arg" == "--lib" ]; then
|
|
26
|
+
is_contract=0
|
|
27
|
+
fi
|
|
28
|
+
done
|
|
29
|
+
|
|
30
|
+
echo "Initializing Noir project..."
|
|
31
|
+
$NARGO init "$@"
|
|
32
|
+
|
|
33
|
+
if [ "${is_contract:-1}" -eq 1 ]; then
|
|
34
|
+
$script_path/setup_project.sh
|
|
35
|
+
fi
|
package/scripts/new.sh
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
NARGO=${NARGO:-nargo}
|
|
5
|
+
script_path=$(realpath $(dirname "$0"))
|
|
6
|
+
|
|
7
|
+
type_arg="--contract"
|
|
8
|
+
|
|
9
|
+
while [[ $# -gt 0 ]]; do
|
|
10
|
+
case $1 in
|
|
11
|
+
--help|-h)
|
|
12
|
+
cat << 'EOF'
|
|
13
|
+
Aztec New - Create a new Aztec Noir project in a new directory
|
|
14
|
+
|
|
15
|
+
Usage: aztec new [OPTIONS] <PATH>
|
|
16
|
+
|
|
17
|
+
Arguments:
|
|
18
|
+
<PATH> The path to save the new project
|
|
19
|
+
|
|
20
|
+
Options:
|
|
21
|
+
--name <NAME> Name of the package [default: package directory name]
|
|
22
|
+
--lib Create a library template instead of a contract
|
|
23
|
+
-h, --help Print help
|
|
24
|
+
|
|
25
|
+
This command creates a new Aztec Noir project using nargo and automatically
|
|
26
|
+
adds the Aztec.nr dependency to your Nargo.toml file.
|
|
27
|
+
EOF
|
|
28
|
+
exit 0
|
|
29
|
+
;;
|
|
30
|
+
--lib)
|
|
31
|
+
type_arg="--lib"
|
|
32
|
+
shift
|
|
33
|
+
;;
|
|
34
|
+
--name)
|
|
35
|
+
name_arg="--name $2"
|
|
36
|
+
shift 2
|
|
37
|
+
;;
|
|
38
|
+
*)
|
|
39
|
+
project_path=$1
|
|
40
|
+
shift
|
|
41
|
+
break
|
|
42
|
+
;;
|
|
43
|
+
esac
|
|
44
|
+
done
|
|
45
|
+
|
|
46
|
+
if [ -z "$project_path" ]; then
|
|
47
|
+
echo "Error: PATH argument is required"
|
|
48
|
+
echo "Usage: aztec new [OPTIONS] <PATH>"
|
|
49
|
+
echo "Run 'aztec new --help' for more information"
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
echo "Creating new Noir project at $project_path..."
|
|
54
|
+
$NARGO new $type_arg ${name_arg:-} $project_path
|
|
55
|
+
|
|
56
|
+
if [ "$type_arg" == "--contract" ]; then
|
|
57
|
+
cd $project_path
|
|
58
|
+
$script_path/setup_project.sh
|
|
59
|
+
fi
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Get the actual aztec version for the git tag.
|
|
5
|
+
AZTEC_VERSION=$(jq -r '.version' $(dirname $0)/../package.json)
|
|
6
|
+
NARGO_TOML_PATH="Nargo.toml"
|
|
7
|
+
MAIN_NR_PATH="src/main.nr"
|
|
8
|
+
|
|
9
|
+
if [ ! -f "$NARGO_TOML_PATH" ]; then
|
|
10
|
+
>&2 echo "Warning: Could not find Nargo.toml at $NARGO_TOML_PATH to add aztec dependency"
|
|
11
|
+
exit 1
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
if [ ! -f "$MAIN_NR_PATH" ]; then
|
|
15
|
+
>&2 echo "Warning: Could not find main.nr at $MAIN_NR_PATH"
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
# Add aztec dependency to Nargo.toml
|
|
20
|
+
echo "" >> "$NARGO_TOML_PATH"
|
|
21
|
+
echo "aztec = { git=\"https://github.com/AztecProtocol/aztec-nr\", tag=\"v${AZTEC_VERSION}\", directory=\"aztec\" }" >> "$NARGO_TOML_PATH"
|
|
22
|
+
echo "Added aztec dependency (v${AZTEC_VERSION}) to Nargo.toml"
|
|
23
|
+
|
|
24
|
+
# Replace the contents of main.nr with the Aztec contract template
|
|
25
|
+
cat > "$MAIN_NR_PATH" << 'EOF'
|
|
26
|
+
use aztec::macros::aztec;
|
|
27
|
+
|
|
28
|
+
#[aztec]
|
|
29
|
+
contract Main {}
|
|
30
|
+
EOF
|
|
31
|
+
echo "Created main.nr with Aztec contract template"
|
package/src/bin/index.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
//
|
|
3
3
|
import { injectCommands as injectBuilderCommands } from '@aztec/builder';
|
|
4
|
-
import { injectCommands as
|
|
4
|
+
import { injectCommands as injectAztecNodeCommands } from '@aztec/cli/aztec_node';
|
|
5
|
+
import { enrichEnvironmentWithChainName } from '@aztec/cli/config/chain';
|
|
6
|
+
import { enrichEnvironmentWithNetworkConfig } from '@aztec/cli/config/network';
|
|
5
7
|
import { injectCommands as injectContractCommands } from '@aztec/cli/contracts';
|
|
6
|
-
import { injectCommands as injectDevnetCommands } from '@aztec/cli/devnet';
|
|
7
8
|
import { injectCommands as injectInfrastructureCommands } from '@aztec/cli/infrastructure';
|
|
8
9
|
import { injectCommands as injectL1Commands } from '@aztec/cli/l1';
|
|
9
10
|
import { injectCommands as injectMiscCommands } from '@aztec/cli/misc';
|
|
10
|
-
import { injectCommands as
|
|
11
|
+
import { injectCommands as injectValidatorKeysCommands } from '@aztec/cli/validator_keys';
|
|
12
|
+
import { getActiveNetworkName } from '@aztec/foundation/config';
|
|
11
13
|
import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
|
|
12
|
-
import { fileURLToPath } from '@aztec/foundation/url';
|
|
13
14
|
|
|
14
15
|
import { Command } from 'commander';
|
|
15
|
-
import { readFileSync } from 'fs';
|
|
16
|
-
import { dirname, resolve } from 'path';
|
|
17
16
|
|
|
17
|
+
import { injectMigrateCommand } from '../cli/cmds/migrate_ha_db.js';
|
|
18
18
|
import { injectAztecCommands } from '../cli/index.js';
|
|
19
|
+
import { getCliVersion } from '../cli/release_version.js';
|
|
20
|
+
|
|
21
|
+
const NETWORK_FLAG = 'network';
|
|
19
22
|
|
|
20
23
|
const userLog = createConsoleLogger();
|
|
21
24
|
const debugLogger = createLogger('cli');
|
|
@@ -28,19 +31,32 @@ async function main() {
|
|
|
28
31
|
process.once('SIGINT', shutdown);
|
|
29
32
|
process.once('SIGTERM', shutdown);
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
// Intercept the setting of a network and enrich the environment with defaults for that network
|
|
35
|
+
let networkValue: string | undefined;
|
|
36
|
+
|
|
37
|
+
const args = process.argv.slice(2);
|
|
38
|
+
const networkIndex = args.findIndex(arg => arg.startsWith(`--${NETWORK_FLAG}=`) || arg === `--${NETWORK_FLAG}`);
|
|
39
|
+
|
|
40
|
+
if (networkIndex !== -1) {
|
|
41
|
+
networkValue = args[networkIndex].split('=')[1] || args[networkIndex + 1];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const networkName = getActiveNetworkName(networkValue);
|
|
45
|
+
await enrichEnvironmentWithNetworkConfig(networkName);
|
|
46
|
+
enrichEnvironmentWithChainName(networkName);
|
|
47
|
+
|
|
48
|
+
const cliVersion = getCliVersion();
|
|
33
49
|
let program = new Command('aztec');
|
|
34
50
|
program.description('Aztec command line interface').version(cliVersion);
|
|
35
51
|
program = injectAztecCommands(program, userLog, debugLogger);
|
|
36
52
|
program = injectBuilderCommands(program);
|
|
37
53
|
program = injectContractCommands(program, userLog, debugLogger);
|
|
38
|
-
program = injectInfrastructureCommands(program, userLog
|
|
54
|
+
program = injectInfrastructureCommands(program, userLog);
|
|
39
55
|
program = injectL1Commands(program, userLog, debugLogger);
|
|
40
|
-
program =
|
|
56
|
+
program = injectAztecNodeCommands(program, userLog, debugLogger);
|
|
41
57
|
program = injectMiscCommands(program, userLog);
|
|
42
|
-
program =
|
|
43
|
-
program =
|
|
58
|
+
program = injectValidatorKeysCommands(program, userLog);
|
|
59
|
+
program = injectMigrateCommand(program, userLog);
|
|
44
60
|
|
|
45
61
|
await program.parseAsync(process.argv);
|
|
46
62
|
}
|
|
@@ -4,43 +4,42 @@ import {
|
|
|
4
4
|
startHttpRpcServer,
|
|
5
5
|
} from '@aztec/foundation/json-rpc/server';
|
|
6
6
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
7
|
-
import { fileURLToPath } from '@aztec/foundation/url';
|
|
8
7
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
9
|
-
import { AztecNodeApiSchema
|
|
8
|
+
import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
10
9
|
import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
|
|
11
10
|
import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
|
|
12
11
|
|
|
13
|
-
import {
|
|
14
|
-
import { dirname, resolve } from 'path';
|
|
15
|
-
|
|
16
|
-
import { createSandbox } from '../sandbox/index.js';
|
|
12
|
+
import { createLocalNetwork } from '../local-network/index.js';
|
|
17
13
|
import { github, splash } from '../splash.js';
|
|
18
|
-
import {
|
|
14
|
+
import { getCliVersion } from './release_version.js';
|
|
19
15
|
import { extractNamespacedOptions, installSignalHandlers } from './util.js';
|
|
20
16
|
import { getVersions } from './versioning.js';
|
|
21
17
|
|
|
22
|
-
const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
|
|
23
|
-
const cliVersion: string = JSON.parse(readFileSync(packageJsonPath).toString()).version;
|
|
24
|
-
|
|
25
18
|
export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logger) {
|
|
26
19
|
// list of 'stop' functions to call when process ends
|
|
27
20
|
const signalHandlers: Array<() => Promise<void>> = [];
|
|
28
21
|
const services: NamespacedApiHandlers = {};
|
|
22
|
+
const adminServices: NamespacedApiHandlers = {};
|
|
29
23
|
let config: ChainConfig | undefined = undefined;
|
|
30
24
|
|
|
31
|
-
if (options.
|
|
32
|
-
const
|
|
33
|
-
const
|
|
25
|
+
if (options.localNetwork) {
|
|
26
|
+
const cliVersion = getCliVersion();
|
|
27
|
+
const localNetwork = extractNamespacedOptions(options, 'local-network');
|
|
28
|
+
localNetwork.testAccounts = true;
|
|
34
29
|
userLog(`${splash}\n${github}\n\n`);
|
|
35
|
-
userLog(`Setting up Aztec
|
|
30
|
+
userLog(`Setting up Aztec local network ${cliVersion}, please stand by...`);
|
|
36
31
|
|
|
37
|
-
const { node,
|
|
32
|
+
const { node, stop } = await createLocalNetwork(
|
|
38
33
|
{
|
|
39
|
-
l1Mnemonic:
|
|
34
|
+
l1Mnemonic: localNetwork.l1Mnemonic,
|
|
40
35
|
l1RpcUrls: options.l1RpcUrls,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
testAccounts: localNetwork.testAccounts,
|
|
37
|
+
realProofs: false,
|
|
38
|
+
// Setting the epoch duration to 4 by default for local network. This allows the epoch to be "proven" faster, so
|
|
39
|
+
// the users can consume out hash without having to wait for a long time.
|
|
40
|
+
// Note: We are not proving anything in the local network (realProofs == false). But in `createLocalNetwork`,
|
|
41
|
+
// the EpochTestSettler will set the out hash to the outbox when an epoch is complete.
|
|
42
|
+
aztecEpochDuration: 4,
|
|
44
43
|
},
|
|
45
44
|
userLog,
|
|
46
45
|
);
|
|
@@ -48,31 +47,16 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
48
47
|
// Start Node and PXE JSON-RPC server
|
|
49
48
|
signalHandlers.push(stop);
|
|
50
49
|
services.node = [node, AztecNodeApiSchema];
|
|
51
|
-
if (!sandboxOptions.noPXE) {
|
|
52
|
-
services.pxe = [pxe, PXESchema];
|
|
53
|
-
} else {
|
|
54
|
-
userLog(`Not exposing PXE API through JSON-RPC server`);
|
|
55
|
-
}
|
|
56
50
|
} else {
|
|
57
|
-
// If a network is specified, enrich the environment with the chain config
|
|
58
|
-
if (options.network) {
|
|
59
|
-
await enrichEnvironmentWithChainConfig(options.network);
|
|
60
|
-
}
|
|
61
51
|
if (options.node) {
|
|
62
52
|
const { startNode } = await import('./cmds/start_node.js');
|
|
63
|
-
({ config } = await startNode(options, signalHandlers, services, userLog));
|
|
53
|
+
({ config } = await startNode(options, signalHandlers, services, adminServices, userLog));
|
|
64
54
|
} else if (options.bot) {
|
|
65
55
|
const { startBot } = await import('./cmds/start_bot.js');
|
|
66
56
|
await startBot(options, signalHandlers, services, userLog);
|
|
67
57
|
} else if (options.proverNode) {
|
|
68
58
|
const { startProverNode } = await import('./cmds/start_prover_node.js');
|
|
69
59
|
({ config } = await startProverNode(options, signalHandlers, services, userLog));
|
|
70
|
-
} else if (options.blobSink) {
|
|
71
|
-
const { startBlobSink } = await import('./cmds/start_blob_sink.js');
|
|
72
|
-
await startBlobSink(options, signalHandlers, userLog);
|
|
73
|
-
} else if (options.pxe) {
|
|
74
|
-
const { startPXE } = await import('./cmds/start_pxe.js');
|
|
75
|
-
({ config } = await startPXE(options, signalHandlers, services, userLog));
|
|
76
60
|
} else if (options.archiver) {
|
|
77
61
|
const { startArchiver } = await import('./cmds/start_archiver.js');
|
|
78
62
|
({ config } = await startArchiver(options, signalHandlers, services));
|
|
@@ -91,9 +75,6 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
91
75
|
} else if (options.sequencer) {
|
|
92
76
|
userLog(`Cannot run a standalone sequencer without a node`);
|
|
93
77
|
process.exit(1);
|
|
94
|
-
} else if (options.faucet) {
|
|
95
|
-
const { startFaucet } = await import('./cmds/start_faucet.js');
|
|
96
|
-
await startFaucet(options, signalHandlers, services, userLog);
|
|
97
78
|
} else {
|
|
98
79
|
userLog(`No module specified to start`);
|
|
99
80
|
process.exit(1);
|
|
@@ -102,13 +83,30 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
102
83
|
|
|
103
84
|
installSignalHandlers(debugLogger.info, signalHandlers);
|
|
104
85
|
const versions = getVersions(config);
|
|
86
|
+
|
|
87
|
+
// Start the main JSON-RPC server
|
|
105
88
|
if (Object.entries(services).length > 0) {
|
|
106
89
|
const rpcServer = createNamespacedSafeJsonRpcServer(services, {
|
|
107
90
|
http200OnError: false,
|
|
108
91
|
log: debugLogger,
|
|
109
92
|
middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
|
|
93
|
+
maxBatchSize: options.rpcMaxBatchSize,
|
|
94
|
+
maxBodySizeBytes: options.rpcMaxBodySize,
|
|
110
95
|
});
|
|
111
96
|
const { port } = await startHttpRpcServer(rpcServer, { port: options.port });
|
|
112
97
|
debugLogger.info(`Aztec Server listening on port ${port}`, versions);
|
|
113
98
|
}
|
|
99
|
+
|
|
100
|
+
// If there are any admin services, start a separate JSON-RPC server for them
|
|
101
|
+
if (Object.entries(adminServices).length > 0) {
|
|
102
|
+
const rpcServer = createNamespacedSafeJsonRpcServer(adminServices, {
|
|
103
|
+
http200OnError: false,
|
|
104
|
+
log: debugLogger,
|
|
105
|
+
middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
|
|
106
|
+
maxBatchSize: options.rpcMaxBatchSize,
|
|
107
|
+
maxBodySizeBytes: options.rpcMaxBodySize,
|
|
108
|
+
});
|
|
109
|
+
const { port } = await startHttpRpcServer(rpcServer, { port: options.adminPort });
|
|
110
|
+
debugLogger.info(`Aztec Server admin API listening on port ${port}`, versions);
|
|
111
|
+
}
|
|
114
112
|
}
|