Skip to content

Commit 7188c46

Browse files
authored
chore: deploy staging bots (#16935)
Deploys a configurable set of bots (both transfers and amm swaps) as part of deploy-aztec-infra Fix TMNT-323
2 parents e162028 + 81d28a4 commit 7188c46

File tree

8 files changed

+211
-1
lines changed

8 files changed

+211
-1
lines changed

.github/workflows/deploy-staging-networks.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ jobs:
115115
ETHERSCAN_API_KEY=${{ secrets.ETHERSCAN_API_KEY }}
116116
DEPLOY_INTERNAL_BOOTNODE=false
117117
STORE_SNAPSHOT_URL="${{ secrets.GCS_TESTNET_SNAPSHOT_URL }}/staging-public/"
118+
BOT_TRANSFERS_REPLICAS=1
119+
BOT_SWAPS_REPLICAS=1
118120
EOF
119121
echo "NAMESPACE=$NAMESPACE" >> $GITHUB_ENV
120122
@@ -168,6 +170,8 @@ jobs:
168170
169171
STORE_SNAPSHOT_URL="${{ secrets.GCS_TESTNET_SNAPSHOT_URL }}/staging-ignition/"
170172
DEPLOY_INTERNAL_BOOTNODE=false
173+
BOT_TRANSFERS_REPLICAS=0
174+
BOT_SWAPS_REPLICAS=0
171175
EOF
172176
echo "NAMESPACE=$NAMESPACE" >> $GITHUB_ENV
173177
@@ -220,6 +224,8 @@ jobs:
220224
221225
STORE_SNAPSHOT_URL="${{ secrets.GCS_TESTNET_SNAPSHOT_URL }}/testnet/"
222226
DEPLOY_INTERNAL_BOOTNODE=false
227+
BOT_TRANSFERS_REPLICAS=0
228+
BOT_SWAPS_REPLICAS=0
223229
EOF
224230
echo "NAMESPACE=$NAMESPACE" >> $GITHUB_ENV
225231

spartan/scripts/deploy_network.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ STORE_SNAPSHOT_URL=${STORE_SNAPSHOT_URL:-null}
6767
OTEL_COLLECTOR_ENDPOINT=${OTEL_COLLECTOR_ENDPOINT:-}
6868
DEPLOY_INTERNAL_BOOTNODE=${DEPLOY_INTERNAL_BOOTNODE:-}
6969

70+
BOT_RESOURCE_PROFILE=${BOT_RESOURCE_PROFILE:-${RESOURCE_PROFILE}}
71+
BOT_TRANSFERS_REPLICAS=${BOT_TRANSFERS_REPLICAS:-0}
72+
BOT_SWAPS_REPLICAS=${BOT_SWAPS_REPLICAS:-0}
73+
BOT_TRANSFERS_TX_INTERVAL_SECONDS=${BOT_TRANSFERS_TX_INTERVAL_SECONDS:-60}
74+
BOT_SWAPS_TX_INTERVAL_SECONDS=${BOT_SWAPS_TX_INTERVAL_SECONDS:-60}
75+
BOT_TRANSFERS_FOLLOW_CHAIN=${BOT_TRANSFERS_FOLLOW_CHAIN:-NONE}
76+
BOT_SWAPS_FOLLOW_CHAIN=${BOT_SWAPS_FOLLOW_CHAIN:-NONE}
77+
7078
########################
7179
# CHAOS MESH VARIABLES
7280
########################
@@ -277,6 +285,17 @@ PROVER_REAL_PROOFS = ${PROVER_REAL_PROOFS}
277285
TRANSACTIONS_DISABLED = ${TRANSACTIONS_DISABLED:-null}
278286
NETWORK = "${NETWORK:-null}"
279287
STORE_SNAPSHOT_URL = "${STORE_SNAPSHOT_URL}"
288+
289+
# Bot settings
290+
BOT_RESOURCE_PROFILE = "${BOT_RESOURCE_PROFILE}"
291+
BOT_TRANSFERS_REPLICAS = ${BOT_TRANSFERS_REPLICAS}
292+
BOT_TRANSFERS_TX_INTERVAL_SECONDS = ${BOT_TRANSFERS_TX_INTERVAL_SECONDS}
293+
BOT_TRANSFERS_FOLLOW_CHAIN = "${BOT_TRANSFERS_FOLLOW_CHAIN}"
294+
BOT_SWAPS_REPLICAS = ${BOT_SWAPS_REPLICAS}
295+
BOT_SWAPS_TX_INTERVAL_SECONDS = ${BOT_SWAPS_TX_INTERVAL_SECONDS}
296+
BOT_SWAPS_FOLLOW_CHAIN = "${BOT_SWAPS_FOLLOW_CHAIN}"
297+
BOT_TRANSFERS_PRIVATE_KEY = "${BOT_TRANSFERS_PRIVATE_KEY:-0xcafe01}"
298+
BOT_SWAPS_PRIVATE_KEY = "${BOT_SWAPS_PRIVATE_KEY:-0xcafe02}"
280299
EOF
281300

282301
tf_run "${DEPLOY_AZTEC_INFRA_DIR}" "${DESTROY_AZTEC_INFRA}" "${CREATE_AZTEC_INFRA}"

spartan/terraform/deploy-aztec-infra/main.tf

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ locals {
4343

4444
internal_boot_node_url = var.DEPLOY_INTERNAL_BOOTNODE ? "http://${var.RELEASE_PREFIX}-p2p-bootstrap-node.${var.NAMESPACE}.svc.cluster.local:8080" : ""
4545

46+
internal_rpc_url = "http://${var.RELEASE_PREFIX}-rpc-aztec-node-admin.${var.NAMESPACE}.svc.cluster.local:8080"
4647
internal_rpc_admin_url = "http://${var.RELEASE_PREFIX}-rpc-aztec-node-admin.${var.NAMESPACE}.svc.cluster.local:8880"
4748

4849
# Common settings for all releases
@@ -165,6 +166,46 @@ locals {
165166
boot_node_host_path = "node.env.BOOT_NODE_HOST"
166167
bootstrap_nodes_path = "node.env.BOOTSTRAP_NODES"
167168
}
169+
170+
# Optional: transfer bots
171+
bot_transfers = var.BOT_TRANSFERS_REPLICAS > 0 ? {
172+
name = "${var.RELEASE_PREFIX}-bot-transfers"
173+
chart = "aztec-bot"
174+
values = [
175+
"common.yaml",
176+
"bot-token-transfer.yaml",
177+
"bot-resources-${var.BOT_RESOURCE_PROFILE}.yaml",
178+
]
179+
custom_settings = {
180+
"bot.replicaCount" = var.BOT_TRANSFERS_REPLICAS
181+
"bot.txIntervalSeconds" = var.BOT_TRANSFERS_TX_INTERVAL_SECONDS
182+
"bot.followChain" = var.BOT_TRANSFERS_FOLLOW_CHAIN
183+
"bot.botPrivateKey" = var.BOT_TRANSFERS_PRIVATE_KEY
184+
"bot.nodeUrl" = local.internal_rpc_url
185+
}
186+
boot_node_host_path = ""
187+
bootstrap_nodes_path = ""
188+
} : null
189+
190+
# Optional: AMM swap bots
191+
bot_swaps = var.BOT_SWAPS_REPLICAS > 0 ? {
192+
name = "${var.RELEASE_PREFIX}-bot-swaps"
193+
chart = "aztec-bot"
194+
values = [
195+
"common.yaml",
196+
"bot-amm-swaps.yaml",
197+
"bot-resources-${var.BOT_RESOURCE_PROFILE}.yaml",
198+
]
199+
custom_settings = {
200+
"bot.replicaCount" = var.BOT_SWAPS_REPLICAS
201+
"bot.txIntervalSeconds" = var.BOT_SWAPS_TX_INTERVAL_SECONDS
202+
"bot.followChain" = var.BOT_SWAPS_FOLLOW_CHAIN
203+
"bot.botPrivateKey" = var.BOT_SWAPS_PRIVATE_KEY
204+
"bot.nodeUrl" = local.internal_rpc_url
205+
}
206+
boot_node_host_path = ""
207+
bootstrap_nodes_path = ""
208+
} : null
168209
}
169210
}
170211

@@ -216,4 +257,3 @@ resource "helm_release" "releases" {
216257
}
217258
}
218259
}
219-
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
bot:
2+
replicaCount: 1
3+
txIntervalSeconds: 10
4+
ammTxs: true
5+
followChain: "PENDING"
6+
feePaymentMethod: "fee_juice"
7+
maxErrors: 3
8+
stopIfUnhealthy: true
9+
botPrivateKey: "0xcafe02"
10+
11+
persistence:
12+
enabled: true
13+
statefulSet:
14+
volumeClaimTemplates:
15+
- metadata:
16+
name: data
17+
spec:
18+
accessModes: [ReadWriteOnce]
19+
resources:
20+
requests:
21+
storage: 2Gi
22+
23+
service:
24+
headless:
25+
enabled: true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
bot:
2+
node:
3+
resources:
4+
requests:
5+
cpu: "0.5"
6+
memory: "1Gi"
7+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
bot:
2+
nodeSelector:
3+
local-ssd: "false"
4+
node-type: "network"
5+
cores: "8"
6+
7+
affinity:
8+
nodeAffinity:
9+
requiredDuringSchedulingIgnoredDuringExecution:
10+
nodeSelectorTerms:
11+
- matchExpressions:
12+
- key: cloud.google.com/gke-spot
13+
operator: Exists
14+
15+
tolerations:
16+
- key: "cloud.google.com/gke-spot"
17+
operator: "Equal"
18+
value: "true"
19+
effect: "NoSchedule"
20+
21+
node:
22+
resources:
23+
requests:
24+
cpu: "7"
25+
memory: "16Gi"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
bot:
2+
replicaCount: 1
3+
ammTxs: false
4+
txIntervalSeconds: 10
5+
privateTransfersPerTx: 0
6+
publicTransfersPerTx: 1
7+
followChain: "NONE"
8+
feePaymentMethod: "fee_juice"
9+
maxErrors: 3
10+
stopIfUnhealthy: true
11+
botPrivateKey: "0xcafe01"
12+
13+
persistence:
14+
enabled: true
15+
statefulSet:
16+
volumeClaimTemplates:
17+
- metadata:
18+
name: data
19+
spec:
20+
accessModes: [ReadWriteOnce]
21+
resources:
22+
requests:
23+
storage: 2Gi
24+
25+
service:
26+
headless:
27+
enabled: false

spartan/terraform/deploy-aztec-infra/variables.tf

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ variable "RPC_RESOURCE_PROFILE" {
4949
}
5050
}
5151

52+
variable "BOT_RESOURCE_PROFILE" {
53+
description = "Resource profile to use for the bots (dev or prod)"
54+
type = string
55+
default = "prod"
56+
validation {
57+
condition = contains(["dev", "prod"], var.BOT_RESOURCE_PROFILE)
58+
error_message = "BOT_RESOURCE_PROFILE must be either 'dev' or 'prod'."
59+
}
60+
}
61+
5262
variable "K8S_CLUSTER_CONTEXT" {
5363
description = "GKE cluster context"
5464
type = string
@@ -297,3 +307,54 @@ variable "SNAPSHOT_CRON" {
297307
type = string
298308
default = "0 */12 * * *"
299309
}
310+
311+
# Bot configuration
312+
variable "BOT_TRANSFERS_REPLICAS" {
313+
description = "Number of transfer bot replicas to deploy (0 to disable)"
314+
type = number
315+
default = 0
316+
}
317+
318+
variable "BOT_TRANSFERS_TX_INTERVAL_SECONDS" {
319+
description = "Interval in seconds between transfer bot transactions"
320+
type = number
321+
default = 10
322+
}
323+
324+
variable "BOT_TRANSFERS_FOLLOW_CHAIN" {
325+
description = "Transfers bot follow-chain mode (e.g., NONE)"
326+
type = string
327+
default = "NONE"
328+
}
329+
330+
variable "BOT_SWAPS_REPLICAS" {
331+
description = "Number of AMM swap bot replicas to deploy (0 to disable)"
332+
type = number
333+
default = 0
334+
}
335+
336+
variable "BOT_SWAPS_TX_INTERVAL_SECONDS" {
337+
description = "Interval in seconds between AMM swap bot transactions"
338+
type = number
339+
default = 10
340+
}
341+
342+
variable "BOT_SWAPS_FOLLOW_CHAIN" {
343+
description = "AMM swaps bot follow-chain mode (e.g., NONE)"
344+
type = string
345+
default = "PENDING"
346+
}
347+
348+
variable "BOT_TRANSFERS_PRIVATE_KEY" {
349+
description = "Private key for the transfers bot (hex string starting with 0x)"
350+
type = string
351+
default = null
352+
nullable = true
353+
}
354+
355+
variable "BOT_SWAPS_PRIVATE_KEY" {
356+
description = "Private key for the AMM swaps bot (hex string starting with 0x)"
357+
type = string
358+
default = null
359+
nullable = true
360+
}

0 commit comments

Comments
 (0)