Skip to content

Commit

Permalink
chore: offsite network stuff (#9231)
Browse files Browse the repository at this point in the history
- turn down transaction bot
- add ability to remove l1 validator from CLI
- add ability to prune l1 rollup from CLI
- add some helpful logging
- touch up readme for oitavos net.
- allow a config on the boot node to skip contract deployments to L1.
- remove the persistence from the boot node yaml because it was
improperly configured
  • Loading branch information
just-mitch authored Oct 14, 2024
1 parent 4bfeb83 commit 155b40b
Show file tree
Hide file tree
Showing 16 changed files with 266 additions and 57 deletions.
50 changes: 38 additions & 12 deletions spartan/aztec-network/templates/boot-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ spec:
done
echo "OpenTelemetry collector is ready!"
{{- end }}
{{- if .Values.bootNode.deployContracts }}
- name: deploy-contracts
image: {{ .Values.images.aztec.image }}
command:
Expand All @@ -48,7 +49,7 @@ spec:
"cp /scripts/deploy-contracts.sh /tmp/deploy-contracts.sh && chmod +x /tmp/deploy-contracts.sh && /tmp/deploy-contracts.sh \"{{ join "," .Values.validator.validatorAddresses }}\""
]
volumeMounts:
- name: shared-volume
- name: scripts-output
mountPath: /shared
- name: scripts
mountPath: /scripts
Expand All @@ -57,6 +58,7 @@ spec:
value: {{ include "aztec-network.ethereumHost" . | quote }}
- name: INIT_VALIDATORS
value: {{ not .Values.validator.external | quote }}
{{- end }}
containers:
- name: boot-node
image: {{ .Values.images.aztec.image }}
Expand All @@ -78,8 +80,14 @@ spec:
timeoutSeconds: 30
failureThreshold: 3
volumeMounts:
- name: shared-volume
{{- if .Values.bootNode.deployContracts }}
- name: scripts-output
mountPath: /shared
{{- else }}
- name: contracts-env
mountPath: /shared/contracts.env
subPath: contracts.env
{{- end }}
env:
- name: POD_NAME
valueFrom:
Expand All @@ -103,6 +111,8 @@ spec:
value: {{ include "aztec-network.ethereumHost" . | quote }}
- name: P2P_ENABLED
value: "{{ .Values.bootNode.p2p.enabled }}"
- name: COINBASE
value: "{{ .Values.bootNode.coinbaseAddress }}"
- name: VALIDATOR_DISABLED
value: "{{ .Values.bootNode.validator.disabled }}"
- name: SEQ_MAX_SECONDS_BETWEEN_BLOCKS
Expand Down Expand Up @@ -138,19 +148,18 @@ spec:
resources:
{{- toYaml .Values.bootNode.resources | nindent 12 }}
volumes:
{{- if .Values.bootNode.deployContracts }}
- name: scripts
configMap:
name: {{ include "aztec-network.fullname" . }}-deploy-contracts-script
volumeClaimTemplates:
- metadata:
name: shared-volume
labels:
{{- include "aztec-network.labels" . | nindent 8 }}
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.bootNode.storage }}
- name: scripts-output
emptyDir: {}
{{- else }}
- name: contracts-env
configMap:
name: {{ include "aztec-network.fullname" . }}-contracts-env
{{- end }}
{{- if .Values.bootNode.deployContracts }}
---
apiVersion: v1
kind: ConfigMap
Expand All @@ -161,6 +170,23 @@ metadata:
data:
deploy-contracts.sh: |
{{ .Files.Get "files/config/deploy-l1-contracts.sh" | nindent 4 }}
{{- else }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "aztec-network.fullname" . }}-contracts-env
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
data:
contracts.env: |
export ROLLUP_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.rollupAddress }}
export REGISTRY_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.registryAddress }}
export INBOX_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.inboxAddress }}
export OUTBOX_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.outboxAddress }}
export FEE_JUICE_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.feeJuiceAddress }}
export FEE_JUICE_PORTAL_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.feeJuicePortalAddress }}
{{- end }}
---
apiVersion: v1
kind: Service
Expand Down
11 changes: 10 additions & 1 deletion spartan/aztec-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bootNode:
nodePort: 8080
logLevel: "debug"
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*"
coinbaseAddress: "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
sequencer:
maxSecondsBetweenBlocks: 0
minTxsPerBlock: 1
Expand All @@ -42,6 +43,14 @@ bootNode:
requests:
memory: "2Gi"
cpu: "200m"
deployContracts: true # Set to false to use manual contract addresses
contracts:
rollupAddress: ""
registryAddress: ""
inboxAddress: ""
outboxAddress: ""
feeJuiceAddress: ""
feeJuicePortalAddress: ""
storage: "8Gi"

validator:
Expand Down Expand Up @@ -115,7 +124,7 @@ bot:
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*"
replicas: 1
botPrivateKey: "0xcafe"
txIntervalSeconds: 5
txIntervalSeconds: 24
privateTransfersPerTx: 1
publicTransfersPerTx: 0
# Do not wait for transactions
Expand Down
3 changes: 2 additions & 1 deletion spartan/aztec-network/values/3-validators-with-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ telemetry:
otelCollectorEndpoint: http://metrics-opentelemetry-collector.metrics:4318

validator:
debug: "aztec:*,-aztec:avm_simulator:*,-aztec:libp2p_service,-aztec:world-state:database"
debug: "aztec:*,-aztec:avm_simulator:*,-aztec:world-state:database,discv5:*,-JsonProxy:*"
replicas: 3
validatorKeys:
- 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Expand All @@ -23,5 +23,6 @@ validator:
disabled: false

bootNode:
debug: "aztec:*,-aztec:avm_simulator:*,-aztec:world-state:database,discv5:*,-JsonProxy:*"
validator:
disabled: true
4 changes: 4 additions & 0 deletions spartan/metrics/install-prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -eu

helm upgrade metrics . -n metrics --values "./values/prod.yaml" --install --create-namespace --atomic
9 changes: 3 additions & 6 deletions spartan/metrics/values/prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
grafana:
service:
type: LoadBalancer
port: 443
annotations:
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:acm:us-east-1:278380418400:certificate/39e70177-9fb5-40e3-a73c-5d963bb6d50c"
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "http"
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"
service.beta.kubernetes.io/aws-load-balancer-ssl-negotiation-policy: "ELBSecurityPolicy-TLS-1-2-2017-01"
persistence:
type: pvc
enabled: true
size: "10Gi"

opentelemetry-collector:
ports:
jaeger-compact:
enabled: false
service:
enabled: true
type: LoadBalancer
53 changes: 46 additions & 7 deletions spartan/oitavos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

## Install docker


## Setup your environment

On your local machine, copy the `deploy-oitavos-team.sh` script to the remote machine:
```sh
PEM=given
FILE=/path/to/your/checkout/spartan/oitavos/deploy-oitavos-team.sh
REMOTE=given

scp -i $PEM $FILE ubuntu@$REMOTE:~/deploy.sh
```

Log into the remote machine:
```
ssh -i $PEM ubuntu@$REMOTE
```

Setup docker:

```sh
sudo apt update
sudo apt install docker.io
Expand All @@ -11,26 +30,46 @@ sudo usermod -aG docker $USER
newgrp docker
```

## Setup your environment

Now export some stuff that will remain constant:

```sh
export AZTEC_IMAGE=given
export ETHEREUM_HOST=given
export BOOT_NODE_URL=given
export PUBLIC_IP=given
export PUBLIC_IP=given, same as the one you used to ssh
```

## When you win a validator
Now, whenever you win a validator, you are going to launch a container.
They need to use different ports, and that script will be reading/writing from your `pwd`,
so you want a different dir for each validator.

So when you win validator 1, you can run:

```sh
VALIDATOR_PRIVATE_KEY=given \
VALIDATOR_ADDRESS=given \
mkdir val1
cd val1
VALIDATOR_PRIVATE_KEY=0x4c9f2ddf5a2436ba5bb481149e4a7e6c43827d1999b82ae7c66138a768c128cc \
VALIDATOR_ADDRESS=0xaaff72f778ae11740eaf84eafcef3e8bc7446aac \
NODE_PORT=8080 \
P2P_TCP_PORT=40400 \
P2P_UDP_PORT=40500 \
./deploy-oitavos-team.sh
../deploy.sh
```

Note, it doesn't log from the running container.

When you win another validator, you can open a new tab and

```sh
# export the same static vars above
mkdir val2
cd val2
VALIDATOR_PRIVATE_KEY=given \
VALIDATOR_ADDRESS=given \
NODE_PORT=8081 \
P2P_TCP_PORT=40401 \
P2P_UDP_PORT=40501 \
../deploy.sh
```

# For operators
Expand Down
47 changes: 25 additions & 22 deletions spartan/oitavos/deploy-oitavos-team.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
#!/bin/bash
set -eu

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# These need to be set in the environment
# AZTEC_IMAGE=$1
# ETHEREUM_HOST=$2
# BOOT_NODE_URL=$3
# VALIDATOR_PRIVATE_KEY=$4
# VALIDATOR_ADDRESS=$5
# PUBLIC_IP=$6
# NODE_PORT=$7
# P2P_TCP_PORT=$8
# P2P_UDP_PORT=$9
# These need to be set in the environment.
# We'll echo them out now to make sure they're set:
echo "AZTEC_IMAGE: $AZTEC_IMAGE"
echo "ETHEREUM_HOST: $ETHEREUM_HOST"
echo "BOOT_NODE_URL: $BOOT_NODE_URL"
echo "PUBLIC_IP: $PUBLIC_IP"
echo "VALIDATOR_PRIVATE_KEY: $VALIDATOR_PRIVATE_KEY"
echo "VALIDATOR_ADDRESS: $VALIDATOR_ADDRESS"
echo "NODE_PORT: $NODE_PORT"
echo "P2P_TCP_PORT: $P2P_TCP_PORT"
echo "P2P_UDP_PORT: $P2P_UDP_PORT"

docker run $AZTEC_IMAGE get-node-info -u $BOOT_NODE_URL | tee $SCRIPT_DIR/node_info.txt

boot_node_enr=$(cat $SCRIPT_DIR/node_info.txt | grep -oP 'Node ENR: \Kenr:[a-zA-Z0-9\-\_\.]+')
rollup_address=$(cat $SCRIPT_DIR/node_info.txt | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}')
registry_address=$(cat $SCRIPT_DIR/node_info.txt | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}')
inbox_address=$(cat $SCRIPT_DIR/node_info.txt | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}')
outbox_address=$(cat $SCRIPT_DIR/node_info.txt | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
fee_juice_address=$(cat $SCRIPT_DIR/node_info.txt | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
fee_juice_portal_address=$(cat $SCRIPT_DIR/node_info.txt | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')

docker run $AZTEC_IMAGE get-node-info -u $BOOT_NODE_URL | tee ./node_info.txt

boot_node_enr=$(cat ./node_info.txt | grep -oP 'Node ENR: \Kenr:[a-zA-Z0-9\-\_\.]+')
rollup_address=$(cat ./node_info.txt | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}')
registry_address=$(cat ./node_info.txt | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}')
inbox_address=$(cat ./node_info.txt | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}')
outbox_address=$(cat ./node_info.txt | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
fee_juice_address=$(cat ./node_info.txt | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
fee_juice_portal_address=$(cat ./node_info.txt | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')


# Write the addresses to a file in the shared volume
cat <<EOF > $SCRIPT_DIR/validator.env
cat <<EOF > ./validator.env
BOOTSTRAP_NODES=$boot_node_enr
ROLLUP_CONTRACT_ADDRESS=$rollup_address
REGISTRY_CONTRACT_ADDRESS=$registry_address
Expand All @@ -49,13 +51,14 @@ P2P_TCP_ANNOUNCE_ADDR=$PUBLIC_IP:$P2P_TCP_PORT
P2P_UDP_ANNOUNCE_ADDR=$PUBLIC_IP:$P2P_UDP_PORT
P2P_TCP_LISTEN_ADDR=0.0.0.0:$P2P_TCP_PORT
P2P_UDP_LISTEN_ADDR=0.0.0.0:$P2P_UDP_PORT
COINBASE=$VALIDATOR_ADDRESS
EOF

cat $SCRIPT_DIR/validator.env
cat ./validator.env

docker run $AZTEC_IMAGE add-l1-validator -u $ETHEREUM_HOST --validator $VALIDATOR_ADDRESS --rollup $rollup_address
docker run --rm \
--env-file $SCRIPT_DIR/validator.env \
--env-file ./validator.env \
-p $NODE_PORT:$NODE_PORT \
-p $P2P_TCP_PORT:$P2P_TCP_PORT \
-p $P2P_UDP_PORT:$P2P_UDP_PORT/udp \
Expand Down
6 changes: 3 additions & 3 deletions spartan/oitavos/oitavos-spartan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ telemetry:
otelCollectorEndpoint: http://metrics-opentelemetry-collector.metrics:4318

bootNode:
debug: "aztec:*,-aztec:avm_simulator*,-aztec:circuits:artifact_hash,-json-rpc*"
externalTcpHost: a32232476dd1841b58f3a72a5cc5007b-171632666.us-east-1.elb.amazonaws.com
externalUdpHost: a63a7f4819ca44eb58e9dc42c1e4b11e-a3423b2c54b3ab38.elb.us-east-1.amazonaws.com
debug: "aztec:*,-aztec:avm_simulator*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:*,-aztec:l2_block_stream,-aztec:libp2p_service"
externalTcpHost: a1a4d181c572d4b919797b16a6c9fa23-446041891.us-east-1.elb.amazonaws.com
externalUdpHost: aaa28cdcabbf6435c824cf6335f3953b-1b1df1304f79fbf2.elb.us-east-1.amazonaws.com
validator:
disabled: true

Expand Down
9 changes: 4 additions & 5 deletions yarn-project/archiver/src/archiver/archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,10 @@ export class Archiver implements ArchiveSource {

const lastProcessedL1BlockNumber = retrievedBlocks[retrievedBlocks.length - 1].l1.blockNumber;

this.log.debug(
`Processing retrieved blocks ${retrievedBlocks
.map(b => b.data.number)
.join(',')} with last processed L1 block ${lastProcessedL1BlockNumber}`,
);
this.log.debug(`last processed L1 block: [${lastProcessedL1BlockNumber}]`);
for (const block of retrievedBlocks) {
this.log.debug(`ingesting new L2 block`, block.data.header.globalVariables.toFriendlyJSON());
}

const timer = new Timer();
await this.store.addBlocks(retrievedBlocks);
Expand Down
14 changes: 14 additions & 0 deletions yarn-project/circuits.js/src/structs/global_variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ export class GlobalVariables {
};
}

/**
* A trimmed version of the JSON representation of the global variables,
* tailored for human consumption.
*/
toFriendlyJSON() {
return {
blockNumber: this.blockNumber.toNumber(),
slotNumber: this.slotNumber.toNumber(),
timestamp: this.timestamp.toString(),
coinbase: this.coinbase.toString(),
gasFees: this.gasFees.toJSON(),
};
}

clone(): GlobalVariables {
return GlobalVariables.fromBuffer(this.toBuffer());
}
Expand Down
Loading

0 comments on commit 155b40b

Please sign in to comment.