Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: spartan proving #9584

Merged
merged 27 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ad29ca3
fix: stop bot in case of tx errors
alexghr Oct 24, 2024
99dc9ac
fix: build l1-artifacts first
alexghr Oct 25, 2024
ae82246
fix: close container
alexghr Oct 25, 2024
d886a14
refactor: config
alexghr Oct 25, 2024
ab4afb3
fix: handle reorgs in the p2p-client
alexghr Oct 25, 2024
160b7a3
chore: restore commented out code
alexghr Oct 28, 2024
29baee5
feat: add mined txs back to pending set
alexghr Oct 28, 2024
e9e66d9
fix: add missing method
alexghr Oct 28, 2024
5a81e43
fix: expose env var for batch size
alexghr Oct 29, 2024
6a2547c
fix: block build reorg
alexghr Oct 30, 2024
8eb1c99
fix: only move back to pending txs that were actually reorged
alexghr Oct 30, 2024
d583dd6
fix: correctly use historical header
alexghr Oct 30, 2024
63748cb
chore: bump ClientIVC block sizes
alexghr Oct 30, 2024
95e0770
chore: normalize case
alexghr Oct 30, 2024
2ccee2e
feat: pass rollup address or pxe URL when deploying verifier
alexghr Oct 30, 2024
dae0504
feat: add prover-agent pods
alexghr Oct 30, 2024
2e5c703
Merge branch 'master' into ag/spartan-proving
PhilWindle Oct 30, 2024
c0c6b7a
chore: bump slot duration and epoch size
alexghr Oct 30, 2024
a810863
chore: update fixtures
alexghr Oct 30, 2024
d29928c
Update constants.nr
ludamad Oct 30, 2024
70f1523
Update prover-agent.yaml
ludamad Oct 30, 2024
2365781
Update ConstantsGen.sol
ludamad Oct 30, 2024
a0383d7
Update ConstantsGen.sol
ludamad Oct 30, 2024
52f94a4
Update constants.gen.ts
ludamad Oct 30, 2024
bd21a7f
Update constants.gen.ts
ludamad Oct 30, 2024
9be0941
Merge branch 'master' into ag/spartan-proving
ludamad Oct 30, 2024
a2f8f96
undo constants change
ludamad Oct 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Collaborator

@ludamad ludamad Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could probably be bumped to a rounder number unless we have reason to think this will be stably 'enough'

this->poseidon2_external = 30128;
this->poseidon2_internal = 172000;
this->lookup = 200000;
}
};
Expand Down Expand Up @@ -247,4 +247,4 @@ using MegaArithmetization = MegaArith<bb::fr>;

template <typename T>
concept HasAdditionalSelectors = IsAnyOf<T, MegaArith<bb::fr>>;
} // namespace bb
} // namespace bb
4 changes: 3 additions & 1 deletion docker-compose.provernet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ services:
BOT_PUBLIC_TRANSFERS_PER_TX: 0
BOT_NO_WAIT_FOR_TRANSFERS: true
BOT_NO_START: false
BOT_MAX_CONSECUTIVE_ERRORS: 3
BOT_STOP_WHEN_UNHEALTHY: true
PXE_PROVER_ENABLED: "${PROVER_REAL_PROOFS:-false}"
PROVER_REAL_PROOFS: "${PROVER_REAL_PROOFS:-false}"
BB_SKIP_CLEANUP: "${BB_SKIP_CLEANUP:-0}" # Persist tmp dirs for debugging
Expand All @@ -150,7 +152,7 @@ services:
test: [ "CMD", "curl", "-fSs", "http://127.0.0.1:80/status" ]
interval: 3s
timeout: 30s
start_period: 10s
start_period: 90s
restart: on-failure:5
command: [ "start", "--bot", "--pxe" ]

Expand Down
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 }}
71 changes: 71 additions & 0 deletions spartan/aztec-network/templates/prover-agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{{- 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 }}
{{- 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/archiver/src/archiver/archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export class Archiver implements ArchiveSource {
localBlockForDestinationProvenBlockNumber &&
provenArchive === localBlockForDestinationProvenBlockNumber.archive.root.toString()
) {
this.log.info(`Updating the proven block number to ${provenBlockNumber} and epoch to ${provenEpochNumber}`);
this.log.verbose(`Updating the proven block number to ${provenBlockNumber} and epoch to ${provenEpochNumber}`);
await this.store.setProvenL2BlockNumber(Number(provenBlockNumber));
// if we are here then we must have a valid proven epoch number
await this.store.setProvenL2EpochNumber(Number(provenEpochNumber));
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/archiver/src/test/mock_l2_block_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export class MockL2BlockSource implements L2BlockSource {
return Promise.resolve(this.l2Blocks.length);
}

public async getProvenBlockNumber(): Promise<number> {
return this.provenBlockNumber ?? (await this.getBlockNumber());
public getProvenBlockNumber(): Promise<number> {
return Promise.resolve(this.provenBlockNumber);
}

public getProvenL2EpochNumber(): Promise<number | undefined> {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function injectAztecCommands(program: Command, userLog: LogFn, debugLogge

const app = rpcServer.getApp(options.apiPrefix);
// add status route
const statusRouter = createStatusRouter(options.apiPrefix);
const statusRouter = createStatusRouter(() => rpcServer.isHealthy(), options.apiPrefix);
app.use(statusRouter.routes()).use(statusRouter.allowedMethods());

const httpServer = http.createServer(app.callback());
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec/src/cli/cmds/start_txe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const startTXE = (options: any, debugLogger: DebugLogger) => {
const txeServer = createTXERpcServer(debugLogger);
const app = txeServer.getApp();
// add status route
const statusRouter = createStatusRouter();
const statusRouter = createStatusRouter(() => txeServer.isHealthy());
app.use(statusRouter.routes()).use(statusRouter.allowedMethods());

const httpServer = http.createServer(app.callback());
Expand Down
16 changes: 15 additions & 1 deletion yarn-project/bot/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export type BotConfig = {
daGasLimit: number | undefined;
/** Token contract to use */
contract: SupportedTokenContracts;
/** The maximum number of consecutive errors before the bot shuts down */
maxConsecutiveErrors: number;
/** Stops the bot if service becomes unhealthy */
stopWhenUnhealthy: boolean;
};

export const botConfigMappings: ConfigMappingsType<BotConfig> = {
Expand Down Expand Up @@ -118,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 Expand Up @@ -164,6 +168,16 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
return val as SupportedTokenContracts;
},
},
maxConsecutiveErrors: {
env: 'BOT_MAX_CONSECUTIVE_ERRORS',
description: 'The maximum number of consecutive errors before the bot shuts down',
...numberConfigHelper(0),
},
stopWhenUnhealthy: {
env: 'BOT_STOP_WHEN_UNHEALTHY',
description: 'Stops the bot if service becomes unhealthy',
...booleanConfigHelper(false),
},
};

export function getBotConfigFromEnv(): BotConfig {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/bot/src/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ import { type BotRunner } from './runner.js';
* @returns An JSON-RPC HTTP server
*/
export function createBotRunnerRpcServer(botRunner: BotRunner) {
return new JsonRpcServer(botRunner, { AztecAddress, EthAddress, Fr, TxHash }, {}, []);
return new JsonRpcServer(botRunner, { AztecAddress, EthAddress, Fr, TxHash }, {}, [], () => botRunner.isHealthy());
}
Loading
Loading