-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.ts
487 lines (443 loc) · 14.6 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
import * as pulumi from "@pulumi/pulumi"
import * as gcp from "@pulumi/gcp"
import * as k8s from "@pulumi/kubernetes"
import * as blake2b from "blake2b"
import * as bs58check from "bs58check"
import deployStatusPage from "./tezos/statusPage"
import deployMetricsPage from "./tezos/metricsPage"
import { TezosChain } from "./tezos/chain"
import { TezosNodes } from "./tezos/nodes"
import { TezosFaucet } from "./tezos/faucet"
import getPublicKeyFromPrivateKey from './tezos/keys'
const cfg = new pulumi.Config()
const faucetPrivateKey = cfg.requireSecret("faucet-private-key")
const faucetRecaptchaSiteKey = cfg.requireSecret("faucet-recaptcha-site-key")
const faucetRecaptchaSecretKey = cfg.requireSecret(
"faucet-recaptcha-secret-key"
)
const private_teztnets_baking_key = cfg.requireSecret(
"tf-teztnets-baking-key"
)
const stackname = cfg.require("infra_stack")
const stackRef = new pulumi.StackReference(stackname)
const kubeconfig = stackRef.requireOutput("kubeconfig")
const provider = new k8s.Provider("do-k8s-provider", {
kubeconfig,
})
const periodicCategory = "Periodic Teztnets"
const protocolCategory = "Protocol Teztnets"
const featureCategory = "Feature Teztnets"
const longCategory = "Long-running Teztnets"
// Create a GCP resource (Storage Bucket) for Bootstrap Smart Contracts
const activationBucket = new gcp.storage.Bucket("testnets-global-activation-bucket", {
location: "US", // You can choose the appropriate location
uniformBucketLevelAccess: true,
storageClass: "STANDARD",
});
// Set the bucket to be publicly readable
new gcp.storage.BucketIAMMember("publicRead", {
bucket: activationBucket.name,
role: "roles/storage.objectViewer",
member: "allUsers",
});
// Define another domain name and a suitable name for the managed zone
const domainNameCom = "teztnets.com";
const managedZoneNameCom = "teztnetscom-zone";
// Create a managed DNS zone
const dnsZoneCom = new gcp.dns.ManagedZone(managedZoneNameCom, {
name: managedZoneNameCom,
dnsName: domainNameCom + ".",
description: "Managed zone for " + domainNameCom,
});
// GitHub Pages IP addresses
// Create A records for each GitHub Pages IP
new gcp.dns.RecordSet("teztnetsComSiteRecord", {
name: domainNameCom + ".",
managedZone: dnsZoneCom.name,
type: "A",
ttl: 300,
rrdatas: [
"185.199.108.153",
"185.199.109.153",
"185.199.110.153",
"185.199.111.153",
]
});
// Weeklynet - restarts Wednesdays
//
const weeklynet_chain = new TezosChain(
{
category: periodicCategory,
humanName: "Weeklynet",
description:
"A testnet that restarts every Wednesday launched from tezos/tezos master branch. It runs Next for 4 cycles then upgrades to proto Alpha.",
schedule: "0 0 * * WED",
activationBucket: activationBucket,
bootstrapContracts: [
// "exchanger.json",
// "evm_bridge.json",
],
helmValuesFile: "networks/weeklynet/values.yaml",
bakingPrivateKey: private_teztnets_baking_key,
// chartPath: "networks/weeklynet/tezos-k8s", // point to a submodule, to run unreleased tezos-k8s code
chartRepoVersion: "7.1.2", // point to a release of tezos-k8s. This should be the default state.
bootstrapPeers: [],
},
provider
)
new TezosFaucet(
weeklynet_chain.name,
{
humanName: "Weeklynet",
namespace: weeklynet_chain.namespace,
helmValuesFile: "networks/weeklynet/faucet_values.yaml",
faucetPrivateKey: faucetPrivateKey,
faucetRecaptchaSiteKey: faucetRecaptchaSiteKey,
faucetRecaptchaSecretKey: faucetRecaptchaSecretKey,
chartRepoVersion: "7.1.2",
},
provider
)
// Ghostnet is different from the other testnets:
// * launched long time ago, launch code is not in the active code path
// * heavy usage on the RPC endpoint requires a more elaborate setup
// with archive/rolling nodes, NGINX path filtering and rate limiting.
// Consequently, we made a special class "TezosNodes" for the purpose.
const ghostnetRollingVersion = "octez-v20.3";
const ghostnetArchiveVersion = "octez-v20.3";
const ghostnet_chain = new TezosNodes(
"ghostnet-nodes",
{
chainName: "ghostnet",
rpcFqdn: `rpc.ghostnet.${domainNameCom}`,
p2pFqdn: `ghostnet.${domainNameCom}`,
octezRollingVersion: ghostnetRollingVersion,
octezArchiveVersion: ghostnetArchiveVersion,
chartRepoVersion: "7.0.9",
rollingPvcSize: "50Gi",
archivePvcSize: "1500Gi"
},
provider,
)
new TezosFaucet(
"ghostnet",
{
humanName: "Ghostnet",
namespace: ghostnet_chain.namespace,
helmValuesFile: "networks/ghostnet/faucet_values.yaml",
faucetPrivateKey: faucetPrivateKey,
faucetRecaptchaSiteKey: faucetRecaptchaSiteKey,
faucetRecaptchaSecretKey: faucetRecaptchaSecretKey,
chartRepoVersion: "7.0.9",
},
provider
)
// Qena
//
const qenanet_chain = new TezosChain(
{
category: protocolCategory,
humanName: "Qenanet",
description: "Test Chain for the Qena Protocol Proposal",
activationBucket: activationBucket,
helmValuesFile: "networks/qenanet/values.yaml",
bakingPrivateKey: private_teztnets_baking_key,
bootstrapPeers: [],
rpcUrls: [],
indexers: [],
chartRepoVersion: "7.2.0",
},
provider
)
new TezosFaucet(
qenanet_chain.name,
{
namespace: qenanet_chain.namespace,
humanName: "Qenanet",
helmValuesFile: "networks/qenanet/faucet_values.yaml",
faucetPrivateKey: faucetPrivateKey,
faucetRecaptchaSiteKey: faucetRecaptchaSiteKey,
faucetRecaptchaSecretKey: faucetRecaptchaSecretKey,
chartRepoVersion: "7.2.0",
},
provider
)
// End of Qena
// Quebecnet First Blood Part III
//
const quebecnet_chain = new TezosChain(
{
category: protocolCategory,
humanName: "Quebecnet",
description: "Test Chain for the Quebec Protocol Proposal 20241113",
activationBucket: activationBucket,
helmValuesFile: "networks/quebecnet2/values.yaml",
bakingPrivateKey: private_teztnets_baking_key,
bootstrapPeers: [ "quebecnet.tzinit.org" ],
rpcUrls: [],
indexers: [],
chartRepoVersion: "7.1.2",
},
provider
)
new TezosFaucet(
quebecnet_chain.name,
{
namespace: quebecnet_chain.namespace,
humanName: "Quebecnet",
helmValuesFile: "networks/quebecnet2/faucet_values.yaml",
faucetPrivateKey: faucetPrivateKey,
faucetRecaptchaSiteKey: faucetRecaptchaSiteKey,
faucetRecaptchaSecretKey: faucetRecaptchaSecretKey,
chartRepoVersion: "7.1.2",
},
provider
)
// Dal-test
const dqnet_chain = new TezosChain(
{
category: periodicCategory,
humanName: "DQnet-202410",
description: "Invitation only test chain for a pure DAL baking network. Please DM the Chief Baker.",
activationBucket: activationBucket,
helmValuesFile: "networks/dqnet/values.yaml",
bakingPrivateKey: private_teztnets_baking_key,
bootstrapPeers: [],
rpcUrls: [],
indexers: [],
chartRepoVersion: "7.0.9",
},
provider
)
// ParisC reboot test network
const pariscnet_chain = new TezosChain(
{
category: protocolCategory,
humanName: "ParisCnet",
snapOver: "parisnet",
description: "Test Chain for Paris replacement protocol",
activationBucket: activationBucket,
helmValuesFile: "networks/pariscnet/values.yaml",
bakingPrivateKey: private_teztnets_baking_key,
bootstrapPeers: [],
rpcUrls: [],
indexers: [],
chartRepoVersion: "7.1.2",
networkStakes: true,
},
provider
)
new TezosFaucet(
pariscnet_chain.name,
{
namespace: pariscnet_chain.namespace,
humanName: "Pariscnet",
helmValuesFile: "networks/pariscnet/faucet_values.yaml",
faucetPrivateKey: faucetPrivateKey,
faucetRecaptchaSiteKey: faucetRecaptchaSiteKey,
faucetRecaptchaSecretKey: faucetRecaptchaSecretKey,
chartRepoVersion: "7.1.2",
},
provider
)
function getNetworks(chains: TezosChain[]): object {
const networks: { [name: string]: object } = {}
chains.forEach(function(chain) {
const bootstrapPeers: string[] = Object.assign([], chain.params.bootstrapPeers) // clone
bootstrapPeers.splice(0, 0, `${chain.name}.${domainNameCom}`)
// genesis_pubkey is the public key associated with the $TEZOS_OXHEAD_BAKING_KEY private key in github secrets
let genesisPubkey = getPublicKeyFromPrivateKey(chain.params.bakingPrivateKey)
const network = Object.assign(
{},
chain.tezosHelmValues["node_config_network"]
) // clone
network["sandboxed_chain_name"] = "SANDBOXED_TEZOS"
network["default_bootstrap_peers"] = bootstrapPeers
network["genesis_parameters"] = {
values: {
genesis_pubkey: genesisPubkey,
},
}
if ("activation_account_name" in network) {
delete network["activation_account_name"]
}
if ("genesis" in network && "block" in network["genesis"] === false) {
// If block hash not passed, use tezos-k8s convention:
// deterministically derive it from chain name.
var input = Buffer.from(network["chain_name"])
var gbk = blake2b(32).update(input).digest("hex")
var bytes = Buffer.from("0134" + gbk, "hex")
network["genesis"]["block"] = bs58check.encode(bytes)
}
if ("dal_config" in network) {
network["dal_config"]["bootstrap_peers"] = [
`dal.${chain.name}.${domainNameCom}:11732`,
]
}
networks[chain.name] = network
})
return networks
}
function getTeztnets(chains: TezosChain[]): object {
const teztnets: { [name: string]: { [name: string]: Object } } = {}
chains.forEach(function(chain) {
let faucetUrl = `https://faucet.${chain.name}.${domainNameCom}`
teztnets[chain.name] = {
chain_name: chain.tezosHelmValues["node_config_network"]["chain_name"],
network_url: `https://${domainNameCom}/${chain.name}`,
human_name: chain.params.humanName,
description: chain.params.description,
docker_build: chain.getDockerBuild(),
git_ref: chain.getGitRef(),
last_baking_daemon: chain.getLastBakingDaemon(),
faucet_url: faucetUrl,
snapshot_url: `https://snapshots.tzinit.org/${chain.snap}/rolling`,
category: chain.params.category,
rpc_url: chain.getRpcUrl(),
rollup_urls: chain.getRollupUrls(),
evm_proxy_urls: chain.getEvmProxyUrls(),
rpc_urls: chain.getRpcUrls(),
masked_from_main_page: false,
indexers: chain.params.indexers || [],
network_stakes: chain.params.networkStakes || false
}
if (Object.keys(chain.dalNodes).length > 0) {
teztnets[chain.name].dal_nodes = chain.dalNodes;
}
})
return teztnets
}
// We do not host a ghostnet node here.
// Oxhead Alpha hosts a ghostnet RPC service and baker in the
// sensitive infra cluster.
// Instead, we hardcode the values to be displayed on the webpage.
const ghostnetNetwork = {
chain_name: "TEZOS_ITHACANET_2022-01-25T15:00:00Z",
default_bootstrap_peers: [
`ghostnet.${domainNameCom}`,
"ghostnet.boot.ecadinfra.com",
"ghostnet.stakenow.de:9733",
],
genesis: {
block: "BLockGenesisGenesisGenesisGenesisGenesis1db77eJNeJ9",
protocol: "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P",
timestamp: "2022-01-25T15:00:00Z",
},
genesis_parameters: {
values: {
genesis_pubkey: "edpkuYLienS3Xdt5c1vfRX1ibMxQuvfM67ByhJ9nmRYYKGAAoTq1UC",
},
},
sandboxed_chain_name: "SANDBOXED_TEZOS",
}
export const networks = {
...getNetworks([dqnet_chain, weeklynet_chain, pariscnet_chain]),
...getNetworks([quebecnet_chain]),
...getNetworks([qenanet_chain]),
...{ ghostnet: ghostnetNetwork },
}
// We hardcode the values to be displayed on the webpage.
const lastBakingDaemonMainnetGhostnet = "PsParisC"
const ghostnetTeztnet = {
category: "Long-running Teztnets",
chain_name: "TEZOS_ITHACANET_2022-01-25T15:00:00Z",
description: "Ghostnet is the long-running testnet for Tezos.",
docker_build: `tezos/tezos:${ghostnetRollingVersion}`,
faucet_url: `https://faucet.ghostnet.${domainNameCom}`,
snapshot_url: `https://snapshots.tzinit.org/ghostnet/rolling`,
git_ref: ghostnetRollingVersion,
human_name: "Ghostnet",
indexers: [
{
name: "TzKT",
url: "https://ghostnet.tzkt.io",
},
{
name: "TzStats",
url: "https://ghost.tzstats.com",
},
],
last_baking_daemon: lastBakingDaemonMainnetGhostnet,
masked_from_main_page: false,
network_url: `https://${domainNameCom}/ghostnet`,
rpc_url: `https://rpc.ghostnet.${domainNameCom}`,
rpc_urls: [
`https://rpc.ghostnet.${domainNameCom}`,
"https://ghostnet.ecadinfra.com",
],
}
// We also add mainnet to the teztnets metadata.
// Some systems rely on this to provide lists of third-party RPC services
// to their users. For example, umami wallet.
const mainnetMetadata = {
category: "Long-running Teztnets",
chain_name: "TEZOS_MAINNET",
description: "Tezos Mainnet",
docker_build: `tezos/tezos:${ghostnetRollingVersion}`,
git_ref: ghostnetRollingVersion,
human_name: "Mainnet",
indexers: [
{
name: "TzKT",
url: "https://tzkt.io",
},
{
name: "TzStats",
url: "https://tzstats.com",
},
],
last_baking_daemon: lastBakingDaemonMainnetGhostnet,
masked_from_main_page: true,
rpc_url: "https://mainnet.api.tez.ie",
rpc_urls: [
"https://mainnet.api.tez.ie",
],
}
export const teztnets = {
...getTeztnets([dqnet_chain, weeklynet_chain, pariscnet_chain]),
...getTeztnets([quebecnet_chain]),
...getTeztnets([qenanet_chain]),
...{ ghostnet: ghostnetTeztnet, mainnet: mainnetMetadata },
}
deployStatusPage(provider, {
networks: networks,
teztnets: teztnets,
statusPageFqdn: `status.${domainNameCom}`,
chartRepoVersion: "7.0.9"
});
deployMetricsPage(provider, {
metricsPageFqdn: `metrics.${domainNameCom}`,
});
// Redirects .xyz to .com
function createDomainRedirectIngress(srcDomain: string, destDomain: string): k8s.networking.v1.Ingress {
return new k8s.networking.v1.Ingress(`ingress-redirect-${srcDomain}`, {
metadata: {
annotations: {
"kubernetes.io/ingress.class": "nginx",
"cert-manager.io/cluster-issuer": "letsencrypt-prod",
"nginx.ingress.kubernetes.io/enable-cors": "true",
"nginx.ingress.kubernetes.io/cors-allow-origin": "*",
"nginx.ingress.kubernetes.io/server-snippet": `return 301 $scheme://${destDomain}$request_uri;`
},
},
spec: {
tls: [{
hosts: [srcDomain],
secretName: `${srcDomain}-secret`,
}],
rules: [{
host: srcDomain
}]
},
}, { provider });
}
// Define your domain name and a suitable name for the managed zone
const domainName = "teztnets.xyz";
const managedZoneName = "teztnets-zone";
// Create a managed DNS zone
const dnsZone = new gcp.dns.ManagedZone(managedZoneName, {
name: managedZoneName,
dnsName: domainName + ".",
description: "Managed zone for " + domainName,
});
createDomainRedirectIngress("teztnets.xyz", "teztnets.com");