diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr index 31171f75b1c..2d6bef36da2 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ hash::{poseidon2_hash, poseidon2_hash_with_separator}, address::AztecAddress, - traits::{FromField, ToField} + traits::{FromField, ToField}, utils::arrays::array_concat }; use crate::context::{PrivateContext, PublicContext, UnconstrainedContext}; @@ -32,17 +32,6 @@ global HASH_SEPARATOR: u32 = 2; // can actually use it here impl Storage for SharedMutable {} -fn concat_arrays(arr_n: [Field; N], arr_m: [Field; M]) -> [Field; N + M] { - let mut out: [Field; N + M] = [0; N + M]; - for i in 0..N { - out[i] = arr_n[i]; - } - for i in 0..M { - out[N+i] = arr_m[i]; - } - out -} - // SharedMutable stores a value of type T that is: // - publicly known (i.e. unencrypted) // - mutable in public @@ -220,7 +209,7 @@ impl SharedMutable, delay_change: ScheduledDelayChange ) -> Field { - let concatenated: [Field; 4] = concat_arrays(value_change.serialize(), delay_change.serialize()); + let concatenated: [Field; 4] = array_concat(value_change.serialize(), delay_change.serialize()); poseidon2_hash(concatenated) } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/mod.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/mod.nr index 9c7a400ea9c..88b0236e421 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/mod.nr @@ -9,15 +9,3 @@ pub use eth_address::EthAddress; pub use partial_address::PartialAddress; pub use public_keys_hash::PublicKeysHash; pub use salted_initialization_hash::SaltedInitializationHash; - -use crate::{constants::GENERATOR_INDEX__CONSTRUCTOR, hash::poseidon2_hash_with_separator}; - -pub fn compute_initialization_hash(selector: Field, args_hash: Field) -> Field { - poseidon2_hash_with_separator( - [ - selector, - args_hash - ], - GENERATOR_INDEX__CONSTRUCTOR - ) -} diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr index c69e6234ed1..718f83ef761 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr @@ -93,9 +93,8 @@ pub fn array_length(array: [T; N]) -> u32 where T: Empty + Eq { length } -pub fn array_concat(array1: [T; N], array2: [T; M]) -> [T; S] { - assert_eq(N + M, S, "combined array length does not match return array length"); - let mut result = [array1[0]; S]; +pub fn array_concat(array1: [T; N], array2: [T; M]) -> [T; N + M] { + let mut result = [array1[0]; N + M]; for i in 1..N { result[i] = array1[i]; } @@ -228,13 +227,6 @@ fn test_array_concat() { assert_eq(concated, [1, 2, 3, 4, 5]); } -#[test(should_fail_with="combined array length does not match return array length")] -fn array_concat_fails_inconsistent_lengths() { - let array0 = [1, 2, 3]; - let array1 = [4, 5]; - let _concated: [Field; 4] = array_concat(array0, array1); -} - #[test] fn check_permutation_basic_test() { let original_array = [1, 2, 3]; diff --git a/scripts/run_on_tester b/scripts/run_on_tester index 1443ebc67c0..fda1b756998 100755 --- a/scripts/run_on_tester +++ b/scripts/run_on_tester @@ -22,4 +22,5 @@ ENV_VARS=" # Format the environment variables for the SSH command ENV_EXPORTS=$(printf 'export %s; ' $ENV_VARS) +echo "Running on tester at IP: $SPOT_IP" ssh -o ControlMaster=auto -o ControlPath=~/.ssh_mux_%h_%p_%r -o ControlPersist=30s -o TCPKeepAlive=no -o ServerAliveCountMax=5 -o ServerAliveInterval=30 -o StrictHostKeyChecking=no -i "$SPOT_KEY" ubuntu@"$SPOT_IP" "$ENV_EXPORTS $@" diff --git a/spartan/aztec-network/templates/tests/run-tests.yaml b/spartan/aztec-network/templates/tests/run-tests.yaml deleted file mode 100644 index bc32cfd7b00..00000000000 --- a/spartan/aztec-network/templates/tests/run-tests.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ .Release.Name }}-test" - labels: {{- include "aztec-network.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test -spec: - restartPolicy: Never - containers: - - name: test - image: {{ .Values.images.test.image }} - args: - - {{ .Values.test }} - env: - - name: SCENARIO - value: {{ .Values.scenario }} - - name: PXE_URL - value: {{ include "aztec-network.pxeUrl" . | quote }} - - name: DEBUG - value: "aztec:*" - - name: LOG_LEVEL - value: "debug" - - name: LOG_JSON - value: "1" diff --git a/spartan/aztec-network/values.yaml b/spartan/aztec-network/values.yaml index 1f1c8146c76..228a3750b99 100644 --- a/spartan/aztec-network/values.yaml +++ b/spartan/aztec-network/values.yaml @@ -1,14 +1,8 @@ -test: "sample" -scenario: "default" - network: public: false enableBots: true images: - test: - image: aztecprotocol/end-to-end - pullPolicy: IfNotPresent aztec: image: aztecprotocol/aztec pullPolicy: IfNotPresent @@ -182,4 +176,4 @@ metrics: periodSeconds: 10 timeoutSeconds: 5 successThreshold: 1 - failureThreshold: 3 + failureThreshold: 3 \ No newline at end of file diff --git a/spartan/scripts/forward_metrics_dashboard.sh b/spartan/scripts/forward_metrics_dashboard.sh new file mode 100755 index 00000000000..8619cbe5cc8 --- /dev/null +++ b/spartan/scripts/forward_metrics_dashboard.sh @@ -0,0 +1,4 @@ +#!/bin/bash +echo "Run this script after the metrics pods all come up. After running this script, port forward 5601 locally" +echo "Then navigate to https://localhost:5601 and login with user elastic password admin" +kubectl port-forward -n metrics service/metrics-eck-kibana-kb-http 5601:5601 \ No newline at end of file diff --git a/spartan/scripts/setup_local_k8s.sh b/spartan/scripts/setup_local_k8s.sh index 68d59939613..37eaadf85e5 100755 --- a/spartan/scripts/setup_local_k8s.sh +++ b/spartan/scripts/setup_local_k8s.sh @@ -30,4 +30,8 @@ if ! command -v helm &> /dev/null; then rm get_helm.sh fi -kind create cluster +if kind get clusters | grep -q "^kind$"; then + echo "Cluster 'kind' already exists. Skipping creation." +else + kind create cluster +fi \ No newline at end of file diff --git a/spartan/scripts/setup_metrics_dashboard.sh b/spartan/scripts/setup_metrics_dashboard.sh new file mode 100755 index 00000000000..3b618116883 --- /dev/null +++ b/spartan/scripts/setup_metrics_dashboard.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts +helm repo add elastic https://helm.elastic.co +helm repo update +helm dependency build "$(git rev-parse --show-toplevel)/spartan/metrics/" +kubectl create -f https://download.elastic.co/downloads/eck/2.14.0/crds.yaml 2>/dev/null +kubectl create secret generic elasticsearch-es-elastic-user --from-literal=elastic=admin -n metrics +kubectl apply -f https://download.elastic.co/downloads/eck/2.14.0/operator.yaml +helm upgrade --install metrics "$(git rev-parse --show-toplevel)/spartan/metrics/" --wait --namespace metrics --create-namespace --wait-for-jobs=true --timeout=30m \ No newline at end of file diff --git a/yarn-project/end-to-end/Earthfile b/yarn-project/end-to-end/Earthfile index 41ab2b0e79c..a8346f103d8 100644 --- a/yarn-project/end-to-end/Earthfile +++ b/yarn-project/end-to-end/Earthfile @@ -295,9 +295,9 @@ e2e-cli-wallet: network-smoke: ARG values_file LOCALLY - RUN NAMESPACE=smoke FRESH_INSTALL=true FORCE_BUILD=$force_build VALUES_FILE=${values_file:-default.yaml} ./scripts/network_test.sh ./src/spartan/smoke.test.ts + RUN NAMESPACE=smoke FRESH_INSTALL=true VALUES_FILE=${values_file:-default.yaml} ./scripts/network_test.sh ./src/spartan/smoke.test.ts network-transfer: ARG values_file LOCALLY - RUN NAMESPACE=transfer FRESH_INSTALL=true FORCE_BUILD=$force_build VALUES_FILE=${values_file:-default.yaml} ./scripts/network_test.sh ./src/spartan/transfer.test.ts + RUN NAMESPACE=transfer FRESH_INSTALL=true VALUES_FILE=${values_file:-default.yaml} ./scripts/network_test.sh ./src/spartan/transfer.test.ts diff --git a/yarn-project/end-to-end/scripts/network_test.sh b/yarn-project/end-to-end/scripts/network_test.sh index d757c45af80..00e58e54f4a 100755 --- a/yarn-project/end-to-end/scripts/network_test.sh +++ b/yarn-project/end-to-end/scripts/network_test.sh @@ -43,18 +43,45 @@ if [ "$FRESH_INSTALL" = "true" ]; then kubectl delete namespace "$NAMESPACE" --ignore-not-found=true --wait=true --now --timeout=10m fi +function show_status_until_pxe_ready() { + set +x # don't spam with our commands + sleep 15 # let helm upgrade start + for i in {1..100} ; do + if kubectl wait pod -l app==pxe --for=condition=Ready -n "transfer" --timeout=20s >/dev/null 2>/dev/null ; then + break # we are up, stop showing status + fi + # show startup status + kubectl get pods -n "$NAMESPACE" + done +} + +show_status_until_pxe_ready & + # Install the Helm chart -helm install spartan "$(git rev-parse --show-toplevel)/spartan/aztec-network/" \ +helm upgrade --install spartan "$(git rev-parse --show-toplevel)/spartan/aztec-network/" \ --namespace "$NAMESPACE" \ --create-namespace \ --values "$(git rev-parse --show-toplevel)/spartan/aztec-network/values/$VALUES_FILE" \ - --set images.test.image="aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG" \ --set images.aztec.image="aztecprotocol/aztec:$AZTEC_DOCKER_TAG" \ - --set test="$TEST" \ + --set ingress.enabled=true \ --wait \ --wait-for-jobs=true \ --timeout=30m kubectl wait pod -l app==pxe --for=condition=Ready -n "$NAMESPACE" --timeout=10m -helm test spartan --namespace "$NAMESPACE" --timeout 30m +function forward_pxe_k8s_port() { + # NOTE we fail silently, and work in the background + kubectl port-forward --namespace transfer svc/spartan-aztec-network-pxe 9082:8080 2>/dev/null >/dev/null || true +} +# tunnel in to get access directly to our PXE service in k8s +(kubectl port-forward --namespace transfer svc/spartan-aztec-network-pxe 9082:8080 2>/dev/null >/dev/null || true) & + +# run our test in the host network namespace (so we can access the above with localhost) +docker run --rm --network=host \ + -e SCENARIO=default \ + -e PXE_URL=http://localhost:9082 \ + -e DEBUG="aztec:*" \ + -e LOG_LEVEL=debug \ + -e LOG_JSON=1 \ + aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG $TEST