Skip to content

Commit

Permalink
feat: token transfer in network + CI
Browse files Browse the repository at this point in the history
  • Loading branch information
just-mitch committed Aug 23, 2024
1 parent dd88e3d commit 23aacc5
Show file tree
Hide file tree
Showing 20 changed files with 408 additions and 57 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,35 @@ jobs:
export FORCE_COLOR=1
../../scripts/earthly-ci -P --no-output +${{ matrix.test }}
# all the network end-to-end tests for aztec (not required to merge)
network-e2e:
needs: [build, changes]
if: ${{ needs.changes.outputs.non-barretenberg-cpp == 'true' }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with: { ref: "${{ env.GIT_COMMIT }}" }
- uses: ./.github/ci-setup-action
- name: Setup and Test
uses: ./.github/ensure-tester-with-images
timeout-minutes: 45
with:
runner_type: ${{ contains(matrix.test, 'prover') && '64core-tester-x86' || '16core-tester-x86' }}
builder_type: builder-x86
# these are copied to the tester and expected by the earthly command below
# if they fail to copy, it will try to build them on the tester and fail
builder_images_to_copy: aztecprotocol/aztec:${{ env.GIT_COMMIT }} aztecprotocol/end-to-end:${{ env.GIT_COMMIT }}
# command to produce the images in case they don't exist
builder_command: scripts/earthly-ci ./yarn-project+export-e2e-test-images
tester_ttl: 40
run: |
set -eux
cd ./yarn-project/end-to-end/
./scripts/setup_local_k8s.sh
export FORCE_COLOR=1
export EARTHLY_BUILD_ARGS="${{ env.EARTHLY_BUILD_ARGS }}"
../../scripts/earthly-ci --exec-stats -P --no-output ./+network-transfer
# all the benchmarking end-to-end integration tests for aztec (not required to merge)
bench-e2e:
needs: [build, changes]
Expand Down
6 changes: 6 additions & 0 deletions helm-charts/aztec-network/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ http://{{ include "aztec-network.fullname" . }}-ethereum.{{ .Release.Namespace }
{{- define "aztec-network.pxeUrl" -}}
http://{{ include "aztec-network.fullname" . }}-pxe.{{ .Release.Namespace }}:{{ .Values.pxe.service.port }}
{{- end -}}

{{- define "aztec-network.bootNodeUrl" -}}
http://{{ include "aztec-network.fullname" . }}-boot-node-0.{{ include "aztec-network.fullname" . }}-boot-node.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.bootNode.service.nodePort }}
{{- end -}}


Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ spec:
[
"/bin/bash",
"-c",
"source /shared/contracts.env && env && node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --node --archiver --sequencer",
"source /shared/contracts.env && env && node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --node --archiver --sequencer --pxe",
]
volumeMounts:
- name: shared-volume
Expand Down Expand Up @@ -91,8 +91,8 @@ spec:
- name: VALIDATOR_PRIVATE_KEY
value: "0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a"
ports:
- containerPort: "{{ .Values.bootNode.service.nodePort }}"
- containerPort: "{{ .Values.bootNode.service.p2pPort }}"
- containerPort: {{ .Values.bootNode.service.nodePort }}
- containerPort: {{ .Values.bootNode.service.p2pPort }}
resources:
{{- toYaml .Values.bootNode.resources | nindent 12 }}
volumes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data:
set -e
# Ask the bootnode for l1 contract addresses
output=$(node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js get-node-info -u http://{{ include "aztec-network.fullname" . }}-boot-node-0.{{ include "aztec-network.fullname" . }}-boot-node.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.bootNode.service.nodePort }})
output=$(node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js get-node-info -u {{ include "aztec-network.bootNodeUrl" . }})
echo "$output"
Expand Down
36 changes: 36 additions & 0 deletions helm-charts/aztec-network/templates/deploy-l2-contracts.job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "aztec-network.fullname" . }}-deploy-l2-contracts
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
template:
metadata:
labels:
{{- include "aztec-network.selectorLabels" . | nindent 8 }}
app: deploy-l2-contracts
spec:
restartPolicy: OnFailure
containers:
- name: deploy-l2-contracts
image: {{ .Values.images.aztec.image }}
command:
- /bin/bash
- -c
- |
until curl -s -X POST -H 'content-type: application/json' \
-d '{"jsonrpc":"2.0","method":"pxe_getNodeInfo","params":[],"id":67}' \
{{ include "aztec-network.pxeUrl" . }} | grep -q '"enr:-'; do
echo "Waiting for PXE service..."
sleep 5
done
echo "PXE service is ready!"
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-protocol-contracts
env:
- name: PXE_URL
value: {{ include "aztec-network.pxeUrl" . | quote }}
- name: DEBUG
value: "aztec:*"
- name: LOG_LEVEL
value: "debug"
14 changes: 14 additions & 0 deletions helm-charts/aztec-network/templates/prover-node.service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "aztec-network.fullname" . }}-prover-node
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
clusterIP: None
selector:
{{- include "aztec-network.selectorLabels" . | nindent 4 }}
app: prover-node
ports:
- port: {{ .Values.proverNode.service.nodePort }}
name: node
87 changes: 87 additions & 0 deletions helm-charts/aztec-network/templates/prover-node.stateful-set.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "aztec-network.fullname" . }}-prover-node
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
serviceName: {{ include "aztec-network.fullname" . }}-prover-node
replicas: {{ .Values.proverNode.replicas }}
selector:
matchLabels:
{{- include "aztec-network.selectorLabels" . | nindent 6 }}
app: prover-node
template:
metadata:
labels:
{{- include "aztec-network.selectorLabels" . | nindent 8 }}
app: prover-node
spec:
initContainers:
- name: configure-validator-env
image: "{{ .Values.images.aztec.image }}"
imagePullPolicy: {{ .Values.images.aztec.pullPolicy }}
command:
- "/bin/sh"
- "-c"
- "cp /scripts/configure-validator-env.sh /tmp/configure-validator-env.sh && chmod +x /tmp/configure-validator-env.sh && /tmp/configure-validator-env.sh"
volumeMounts:
- name: shared-volume
mountPath: /shared
- name: scripts
mountPath: /scripts
env:
- name: ETHEREUM_HOST
value: {{ include "aztec-network.ethereumHost" . | quote }}
containers:
- name: aztec
image: "{{ .Values.images.aztec.image }}"
imagePullPolicy: {{ .Values.images.aztec.pullPolicy }}
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"
volumeMounts:
- name: shared-volume
mountPath: /shared
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_DNS_NAME
value: "$(POD_NAME).{{ include "aztec-network.fullname" . }}-prover-node.$(POD_NAMESPACE).svc.cluster.local"
- name: PORT
value: "{{ .Values.proverNode.service.nodePort }}"
- name: LOG_LEVEL
value: "{{ .Values.proverNode.logLevel }}"
- name: DEBUG
value: "{{ .Values.proverNode.debug }}"
- name: ETHEREUM_HOST
value: {{ include "aztec-network.ethereumHost" . | quote }}
- name: PROVER_REAL_PROOFS
value: "{{ .Values.proverNode.realProofs }}"
- name: PROVER_AGENT_ENABLED
value: "{{ .Values.proverNode.proverAgentEnabled }}"
- name: PROVER_PUBLISHER_PRIVATE_KEY
value: "0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97"
# get private proofs from the boot node
- name: TX_PROVIDER_NODE_URL
value: {{ include "aztec-network.bootNodeUrl" . | quote }}
# prover agent gets jobs from itself
- name: AZTEC_NODE_URL
value: "$(POD_DNS_NAME):{{ .Values.proverNode.service.nodePort }}"
ports:
- containerPort: {{ .Values.proverNode.service.nodePort }}
resources:
{{- toYaml .Values.proverNode.resources | nindent 12 }}
volumes:
- name: shared-volume
emptyDir: {}
- name: scripts
configMap:
name: {{ include "aztec-network.fullname" . }}-configure-validator-env
4 changes: 2 additions & 2 deletions helm-charts/aztec-network/templates/pxe.deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ spec:
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --pxe
env:
- name: ETHEREUM_HOST
value: "http://{{ include "aztec-network.fullname" . }}-ethereum.{{ .Release.Namespace }}:{{ .Values.ethereum.service.port }}"
value: {{ include "aztec-network.ethereumHost" . | quote }}
- name: AZTEC_NODE_URL
value: "http://{{ include "aztec-network.fullname" . }}-boot-node-0.{{ include "aztec-network.fullname" . }}-boot-node.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.bootNode.service.nodePort }}"
value: {{ include "aztec-network.bootNodeUrl" . | quote }}
ports:
- name: http
containerPort: {{ .Values.pxe.service.port }}
Expand Down
14 changes: 12 additions & 2 deletions helm-charts/aztec-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bootNode:
p2pPort: 40400
nodePort: 8080
logLevel: "debug"
debug: "discv5:*,aztec:*"
debug: "aztec:*"
p2p:
enabled: "true"
resources: {}
Expand All @@ -29,11 +29,21 @@ validator:
p2pPort: 40400
nodePort: 8080
logLevel: "debug"
debug: "discv5:*,aztec:*"
debug: "aztec:*"
p2p:
enabled: "true"
resources: {}

proverNode:
replicas: 1
service:
nodePort: 8080
logLevel: "debug"
debug: "aztec:*"
realProofs: false
proverAgentEnabled: true
resources: {}

pxe:
replicas: 1
service:
Expand Down
5 changes: 2 additions & 3 deletions yarn-project/aztec.js/src/contract/deploy_sent_tx.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type PXE, type TxHash, type TxReceipt } from '@aztec/circuit-types';
import { type AztecAddress } from '@aztec/circuits.js';
import { createDebugLogger } from '@aztec/foundation/log';
import { type FieldsOf } from '@aztec/foundation/types';
import { type ContractInstanceWithAddress } from '@aztec/types/contracts';

Expand All @@ -25,8 +24,6 @@ export type DeployTxReceipt<TContract extends ContractBase = Contract> = FieldsO
* A contract deployment transaction sent to the network, extending SentTx with methods to create a contract instance.
*/
export class DeploySentTx<TContract extends Contract = Contract> extends SentTx {
private log = createDebugLogger('aztec:js:deploy_sent_tx');

constructor(
wallet: PXE | Wallet,
txHashPromise: Promise<TxHash>,
Expand Down Expand Up @@ -55,7 +52,9 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
*/
public override async wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>> {
const receipt = await super.wait(opts);
this.log.debug(`Returned from wait for ${await this.getTxHash()}: final status ${receipt.status}`);
const contract = await this.getContractObject(opts?.wallet);
this.log.debug(`Contract instance created for ${this.instance.address.toString()}`);
return { ...receipt, contract };
}

Expand Down
9 changes: 9 additions & 0 deletions yarn-project/aztec.js/src/contract/sent_tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type TxReceipt,
TxStatus,
} from '@aztec/circuit-types';
import { createDebugLogger } from '@aztec/foundation/log';
import { retryUntil } from '@aztec/foundation/retry';
import { type FieldsOf } from '@aztec/foundation/types';

Expand Down Expand Up @@ -43,6 +44,7 @@ export const DefaultWaitOpts: WaitOpts = {
* its hash, receipt, and mining status.
*/
export class SentTx {
protected log = createDebugLogger('aztec:js:sent_tx');
constructor(protected pxe: PXE, protected txHashPromise: Promise<TxHash>) {}

/**
Expand Down Expand Up @@ -84,6 +86,7 @@ export class SentTx {
);
}
if (opts?.proven && receipt.blockNumber !== undefined) {
this.log.info(`Waiting for tx ${await this.getTxHash()} to be proven`);
await this.waitForProven(receipt.blockNumber, opts);
}
if (opts?.debug) {
Expand Down Expand Up @@ -128,6 +131,7 @@ export class SentTx {
return await retryUntil(
async () => {
const txReceipt = await this.pxe.getTxReceipt(txHash);
this.log.debug(`Got receipt for tx ${txHash}: ${txReceipt.status}`);
// If receipt is not yet available, try again
if (txReceipt.status === TxStatus.PENDING) {
return undefined;
Expand All @@ -141,10 +145,15 @@ export class SentTx {
if (!waitForNotesSync) {
return txReceipt;
}
this.log.debug(`Waiting for notes to sync for tx ${txHash}`);
// Check if all sync blocks on the PXE Service are greater or equal than the block in which the tx was mined
const { blocks, notes } = await this.pxe.getSyncStatus();

this.log.debug(`Got sync status for tx ${txHash}: ${blocks} ${JSON.stringify(notes)}`);
const targetBlock = txReceipt.blockNumber!;
this.log.debug(`Target block for tx ${txHash}: ${targetBlock}`);
const areNotesSynced = blocks >= targetBlock && Object.values(notes).every(block => block >= targetBlock);
this.log.debug(`Are notes synced for tx ${txHash}: ${areNotesSynced}`);
return areNotesSynced ? txReceipt : undefined;
},
'isMined',
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec/src/cli/cmds/start_prover_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const startProverNode = async (
process.exit(1);
}

if (options.prover) {
if (options.prover || options.proverAgentEnabled) {
userLog(`Running prover node with local prover agent.`);
proverConfig.proverAgentEnabled = true;
} else {
Expand Down
13 changes: 10 additions & 3 deletions yarn-project/end-to-end/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ NETWORK_TEST:
RUN kubectl delete namespace $namespace --ignore-not-found=true --wait=true --now --timeout=10m
END


RUN helm install spartan ../../helm-charts/aztec-network \
--namespace $namespace --create-namespace \
--set images.test.image="aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG" \
--set images.aztec.image="aztecprotocol/aztec:$AZTEC_DOCKER_TAG" \
--set test="$test"
--set test="$test" \
--wait \
--wait-for-jobs=true \
--timeout=10m

RUN kubectl wait pod -l app==pxe --for=condition=Ready -n $namespace --timeout=10m

Expand Down Expand Up @@ -296,4 +298,9 @@ e2e-cli-wallet:
DO +E2E_COMPOSE_TEST --test=e2e_cli_wallet --compose_file=scripts/docker-compose-wallet.yml

network-smoke:
DO +NETWORK_TEST --fresh_install=true --namespace=smoke --test=./src/spartan/smoke.test.ts
ARG force_build
DO +NETWORK_TEST --force_build=$force_build --fresh_install=true --namespace=smoke --test=./src/spartan/smoke.test.ts

network-transfer:
ARG force_build
DO +NETWORK_TEST --force_build=$force_build --fresh_install=true --namespace=transfer --test=./src/spartan/transfer.test.ts
Loading

0 comments on commit 23aacc5

Please sign in to comment.