Skip to content

Commit

Permalink
Merge branch 'master' into md/e2e-p2p-snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 authored Oct 2, 2024
2 parents 01e8eca + 8031ef4 commit 295ef75
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -32,17 +32,6 @@ global HASH_SEPARATOR: u32 = 2;
// can actually use it here
impl<T, let INITIAL_DELAY: u32, Context> Storage<T> for SharedMutable<T, INITIAL_DELAY, Context> {}

fn concat_arrays<let N: u32, let M: u32>(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<T> stores a value of type T that is:
// - publicly known (i.e. unencrypted)
// - mutable in public
Expand Down Expand Up @@ -220,7 +209,7 @@ impl<T, let INITIAL_DELAY: u32> SharedMutable<T, INITIAL_DELAY, &mut PrivateCont
value_change: ScheduledValueChange<T>,
delay_change: ScheduledDelayChange<INITIAL_DELAY>
) -> 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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ pub fn array_length<T, let N: u32>(array: [T; N]) -> u32 where T: Empty + Eq {
length
}

pub fn array_concat<T, let N: u32, let M: u32, let S: u32>(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<T, let N: u32, let M: u32>(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];
}
Expand Down Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions scripts/run_on_tester
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@"
25 changes: 0 additions & 25 deletions spartan/aztec-network/templates/tests/run-tests.yaml

This file was deleted.

8 changes: 1 addition & 7 deletions spartan/aztec-network/values.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -182,4 +176,4 @@ metrics:
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
failureThreshold: 3
4 changes: 4 additions & 0 deletions spartan/scripts/forward_metrics_dashboard.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion spartan/scripts/setup_local_k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions spartan/scripts/setup_metrics_dashboard.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
35 changes: 31 additions & 4 deletions yarn-project/end-to-end/scripts/network_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 295ef75

Please sign in to comment.