Skip to content

Commit

Permalink
feat: spartan proving (#9584)
Browse files Browse the repository at this point in the history
This PR adds K8s config to deploy a network with proving enabled

---------

Co-authored-by: PhilWindle <[email protected]>
Co-authored-by: ludamad <[email protected]>
  • Loading branch information
3 people authored Oct 31, 2024
1 parent bf53f5e commit 392114a
Show file tree
Hide file tree
Showing 12 changed files with 242 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ template <typename FF_> class MegaArith {
this->delta_range = 25000;
this->elliptic = 80000;
this->aux = 100000;
this->poseidon2_external = 30000;
this->poseidon2_internal = 150000;
this->poseidon2_external = 30128;
this->poseidon2_internal = 172000;
this->lookup = 200000;
}
};
Expand Down Expand Up @@ -248,4 +248,4 @@ using MegaArithmetization = MegaArith<bb::fr>;

template <typename T>
concept HasAdditionalSelectors = IsAnyOf<T, MegaArith<bb::fr>>;
} // namespace bb
} // namespace bb
58 changes: 58 additions & 0 deletions spartan/aztec-network/templates/deploy-l1-verifier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{{- if .Values.network.setupL2Contracts }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "aztec-network.fullname" . }}-deploy-l1-verifier
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
template:
metadata:
labels:
{{- include "aztec-network.selectorLabels" . | nindent 8 }}
app: deploy-l1-verifier
spec:
restartPolicy: OnFailure
containers:
- name: deploy-l1-verifier
image: {{ .Values.images.aztec.image }}
command:
- /bin/bash
- -c
- |
set -e
[ $ENABLE = "true" ] || exit 0
until curl -s -X GET "$AZTEC_NODE_URL/status"; do
echo "Waiting for Aztec node $AZTEC_NODE_URL..."
sleep 5
done
echo "Boot node is ready!"
export ROLLUP_CONTRACT_ADDRESS=$(curl -X POST -H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","method":"node_getL1ContractAddresses","params":[],"id":1}' \
"$AZTEC_NODE_URL" \
| jq -r '.result.rollupAddress.data')
echo "Rollup contract address: $ROLLUP_CONTRACT_ADDRESS"
node /usr/src/yarn-project/aztec/dest/bin/index.js deploy-l1-verifier --verifier real
echo "L1 verifier deployed"
env:
- name: ENABLE
value: {{ .Values.jobs.deployL1Verifier.enable | quote }}
- name: NODE_NO_WARNINGS
value: "1"
- name: DEBUG
value: "aztec:*"
- name: LOG_LEVEL
value: "debug"
- name: ETHEREUM_HOST
value: {{ include "aztec-network.ethereumHost" . | quote }}
- name: L1_CHAIN_ID
value: {{ .Values.ethereum.chainId | quote }}
- name: PRIVATE_KEY
value: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
- name: AZTEC_NODE_URL
value: {{ include "aztec-network.bootNodeUrl" . | quote }}
{{ end }}
73 changes: 73 additions & 0 deletions spartan/aztec-network/templates/prover-agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{- if .Values.proverAgent.enabled }}
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: {{ include "aztec-network.fullname" . }}-prover-agent
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.proverAgent.replicas }}
selector:
matchLabels:
{{- include "aztec-network.selectorLabels" . | nindent 6 }}
app: prover-agent
template:
metadata:
labels:
{{- include "aztec-network.selectorLabels" . | nindent 8 }}
app: prover-agent
spec:
initContainers:
- name: wait-for-prover-node
image: {{ .Values.images.curl.image }}
command:
- /bin/sh
- -c
- |
until curl -s -X POST "$PROVER_JOB_SOURCE_URL/status"; do
echo "Waiting for Prover node $PROVER_JOB_SOURCE_URL ..."
sleep 5
done
echo "Prover node is ready!"
{{- if .Values.telemetry.enabled }}
until curl --head --silent {{ include "aztec-network.otelCollectorMetricsEndpoint" . }} > /dev/null; do
echo "Waiting for OpenTelemetry collector..."
sleep 5
done
echo "OpenTelemetry collector is ready!"
{{- end }}
env:
- name: PROVER_JOB_SOURCE_URL
value: http://{{ include "aztec-network.fullname" . }}-prover-node.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.proverNode.service.nodePort }}
containers:
- name: prover-agent
image: "{{ .Values.images.aztec.image }}"
imagePullPolicy: {{ .Values.images.aztec.pullPolicy }}
command:
- "/bin/bash"
- "-c"
- "node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --prover"
env:
- name: LOG_LEVEL
value: "{{ .Values.proverAgent.logLevel }}"
- name: LOG_JSON
value: "1"
- name: DEBUG
value: "{{ .Values.proverAgent.debug }}"
- name: PROVER_REAL_PROOFS
value: "{{ .Values.proverAgent.realProofs }}"
- name: PROVER_JOB_SOURCE_URL
value: http://{{ include "aztec-network.fullname" . }}-prover-node.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.proverNode.service.nodePort }}
- name: PROVER_AGENT_ENABLED
value: "true"
- name: PROVER_AGENT_CONCURRENCY
value: {{ .Values.proverAgent.concurrency | quote }}
- name: HARDWARE_CONCURRENCY
value: {{ .Values.proverAgent.bb.hardwareConcurrency | quote }}
- name: OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
value: {{ include "aztec-network.otelCollectorMetricsEndpoint" . | quote }}
- name: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
value: {{ include "aztec-network.otelCollectorTracesEndpoint" . | quote }}
- name: OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
value: {{ include "aztec-network.otelCollectorLogsEndpoint" . | quote }}
{{- end }}
4 changes: 2 additions & 2 deletions spartan/aztec-network/templates/prover-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ spec:
command:
- "/bin/bash"
- "-c"
- "source /shared/contracts.env && env && node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --prover-node --prover --archiver"
- "source /shared/contracts.env && env && node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --prover-node --archiver"
volumeMounts:
- name: shared-volume
mountPath: /shared
Expand Down Expand Up @@ -163,4 +163,4 @@ spec:
- port: {{ .Values.proverNode.service.nodePort }}
name: node
{{ end }}
{{ end }}
{{ end }}
4 changes: 3 additions & 1 deletion spartan/aztec-network/templates/pxe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ spec:
value: "{{ .Values.pxe.logLevel }}"
- name: DEBUG
value: "{{ .Values.pxe.debug }}"
- name: PXE_PROVER_ENABLED
value: "{{ .Values.pxe.proverEnabled }}"
ports:
- name: http
containerPort: {{ .Values.pxe.service.port }}
Expand Down Expand Up @@ -119,4 +121,4 @@ spec:
nodePort: {{ .Values.pxe.service.nodePort }}
{{- end }}
{{ end }}
{{- end }}
{{- end }}
22 changes: 18 additions & 4 deletions spartan/aztec-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bootNode:
p2pUdpPort: 40400
nodePort: 8080
logLevel: "debug"
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*"
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream*"
coinbaseAddress: "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
sequencer:
maxSecondsBetweenBlocks: 0
Expand Down Expand Up @@ -67,7 +67,7 @@ validator:
p2pUdpPort: 40400
nodePort: 8080
logLevel: "debug"
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*"
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream*"
sequencer:
maxSecondsBetweenBlocks: 0
minTxsPerBlock: 1
Expand All @@ -88,9 +88,9 @@ proverNode:
service:
nodePort: 8080
logLevel: "debug"
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*"
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream*"
realProofs: false
proverAgentEnabled: true
proverAgentEnabled: false
resources:
requests:
memory: "2Gi"
Expand All @@ -102,6 +102,7 @@ pxe:
externalHost: ""
logLevel: "debug"
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*"
proverEnable: false
replicas: 1
service:
port: 8080
Expand Down Expand Up @@ -176,3 +177,16 @@ ethereum:
memory: "2Gi"
cpu: "200m"
storage: "8Gi"

proverAgent:
enabled: true
replicas: 1
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream*"
realProofs: false
concurrency: 1
bb:
hardwareConcurrency: ""

jobs:
deployL1Verifier:
enable: false
37 changes: 37 additions & 0 deletions spartan/aztec-network/values/1-validator-with-proving.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
validator:
replicas: 1
validatorKeys:
- 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
validatorAddresses:
- 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
validator:
disabled: false

bootNode:
validator:
disabled: true

proverNode:
realProofs: true

proverAgent:
replicas: 6
realProofs: true
bb:
hardwareConcurrency: 16

pxe:
proverEnabled: true

bot:
enabled: true
pxeProverEnabled: true
txIntervalSeconds: 200

jobs:
deployL1Verifier:
enable: true

telemetry:
enabled: true
otelCollectorEndpoint: http://metrics-opentelemetry-collector.metrics:4318
1 change: 0 additions & 1 deletion spartan/aztec-network/values/1-validators.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
validator:
debug: "aztec:*,-aztec:avm_simulator:*,-aztec:libp2p_service"
replicas: 1
validatorKeys:
- 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/bot/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
description: 'Which chain the bot follows',
defaultValue: 'NONE',
parseEnv(val) {
if (!botFollowChain.includes(val as any)) {
if (!(botFollowChain as readonly string[]).includes(val.toUpperCase())) {
throw new Error(`Invalid value for BOT_FOLLOW_CHAIN: ${val}`);
}
return val as BotFollowChain;
Expand Down
30 changes: 23 additions & 7 deletions yarn-project/cli/src/cmds/l1/deploy_l1_verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { type DebugLogger, type LogFn } from '@aztec/foundation/log';
import { InvalidOptionArgumentError } from 'commander';
// @ts-expect-error solc-js doesn't publish its types https://github.com/ethereum/solc-js/issues/689
import solc from 'solc';
import { getContract } from 'viem';
import { type Hex, getContract } from 'viem';

export async function deployUltraHonkVerifier(
rollupAddress: Hex | undefined,
ethRpcUrl: string,
l1ChainId: string,
privateKey: string | undefined,
Expand All @@ -32,14 +33,21 @@ export async function deployUltraHonkVerifier(
createEthereumChain(ethRpcUrl, l1ChainId).chainInfo,
);

const pxe = await createCompatibleClient(pxeRpcUrl, debugLogger);
const { l1ContractAddresses } = await pxe.getNodeInfo();
if (!rollupAddress && pxeRpcUrl) {
const pxe = await createCompatibleClient(pxeRpcUrl, debugLogger);
const { l1ContractAddresses } = await pxe.getNodeInfo();
rollupAddress = l1ContractAddresses.rollupAddress.toString();
}

if (!rollupAddress) {
throw new InvalidOptionArgumentError('Missing rollup address');
}

const { RollupAbi } = await import('@aztec/l1-artifacts');

const rollup = getContract({
abi: RollupAbi,
address: l1ContractAddresses.rollupAddress.toString(),
address: rollupAddress,
client: walletClient,
});

Expand All @@ -64,6 +72,7 @@ export async function deployUltraHonkVerifier(
}

export async function deployMockVerifier(
rollupAddress: Hex | undefined,
ethRpcUrl: string,
l1ChainId: string,
privateKey: string | undefined,
Expand All @@ -87,12 +96,19 @@ export async function deployMockVerifier(
);
log(`Deployed MockVerifier at ${mockVerifierAddress.toString()}`);

const pxe = await createCompatibleClient(pxeRpcUrl, debugLogger);
const { l1ContractAddresses } = await pxe.getNodeInfo();
if (!rollupAddress && pxeRpcUrl) {
const pxe = await createCompatibleClient(pxeRpcUrl, debugLogger);
const { l1ContractAddresses } = await pxe.getNodeInfo();
rollupAddress = l1ContractAddresses.rollupAddress.toString();
}

if (!rollupAddress) {
throw new InvalidOptionArgumentError('Missing rollup address');
}

const rollup = getContract({
abi: RollupAbi,
address: l1ContractAddresses.rollupAddress.toString(),
address: rollupAddress,
client: walletClient,
});

Expand Down
Loading

0 comments on commit 392114a

Please sign in to comment.