Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
Mantis takes #networkConfig instead of #network
Browse files Browse the repository at this point in the history
Counts are explicit now as well.
  • Loading branch information
nrdxp committed Apr 6, 2021
1 parent 810eb38 commit fa82a9f
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 83 deletions.
51 changes: 39 additions & 12 deletions deploy.cue
Expand Up @@ -16,7 +16,6 @@ _Namespace: [Name=_]: {
let datacenter = "eu-central-1" | "us-east-2" | "eu-west-1"
datacenters: list.MinItems(1) | [...datacenter] | *["eu-central-1", "us-east-2"]
#fqdn: "mantis.ws"
#network: string
}
jobs: [string]: types.#stanza.job
}
Expand All @@ -38,52 +37,80 @@ _Namespace: [Name=_]: {
}

#miner: jobDef.#Mantis & {
#count: uint | *1
#role: "miner"
#mantisRev: #defaults.mantisRev
}

#passive: jobDef.#Mantis & {
#count: uint | *1
#role: "passive"
#mantisRev: #defaults.mantisRev
}

#morpho: jobDef.#Morpho & {
#count: uint | *5
#morphoRev: #defaults.morphoRev
#mantisRev: #defaults.mantisRev
}

#namespaces: {
"mantis-unstable": {
vars: #network: "sagano"
vars: {
#networkConfig: """
mantis.blockchains.testnet-internal-nomad.bootstrap-nodes = [
"enode://f92aa66337ab1993cc7269d4295d296aefe6199b34e900eac08c514c947ec7340d46a5648ffc2da10325dbaba16bdf92aa9c0b5e51d97a7818c3f495d478ddad@mantis-testnet-0.mantis.ws:9001?discport=9501",
"enode://d8a010f019db37dcaf2e1fb98d4fcbf1f57dbd7e2a7f065e92fbe77dca8b9120d6e79f1617e98fa6134e6af8858ac8f3735b1e70a5708eb14f228080356eb0a7@mantis-testnet-1.mantis.ws:9002?discport=9502",
"enode://442e2bd50eece65f90dee0d5c6075da4e1b4bc62e36b261a52e7f393dae6a68241e4dbad868c7ecc14fed277ed72e99a289a811b6172f35fb18bdca0b7a5602c@mantis-testnet-2.mantis.ws:9003?discport=9503",
"enode://ff86741b7b35087b2b53f44a612b233336490d5fae10b1434619b7714fe2d5346c71427a5e126cd27b9422a4d4376c1534ef66e88c5e62d6441d2541f63de0cf@mantis-testnet-3.mantis.ws:9004?discport=9504",
"enode://af97643f364b805d5b0e32b5356578a16afcc4fb9d1b6622998e9441eeb7795e8daf8e6b0ff3330da9879034112be56954f9269164513ece0f7394b805be3633@mantis-testnet-4.mantis.ws:9005?discport=9505",
]
"""
}
jobs: {
explorer: #explorer
faucet: #faucet
miner: #miner
passive: #passive
morpho: #morpho
miner: #miner & {#count: 5}
passive: #passive & {#count: 5}
morpho: #morpho & {#count: 5}
}
}
"mantis-testnet": {
vars: #network: "sagano"
vars: {
#networkConfig: """
mantis.blockchains.testnet-internal-nomad.bootstrap-nodes = [
"enode://f92aa66337ab1993cc7269d4295d296aefe6199b34e900eac08c514c947ec7340d46a5648ffc2da10325dbaba16bdf92aa9c0b5e51d97a7818c3f495d478ddad@mantis-testnet-0.mantis.ws:9001?discport=9501",
"enode://d8a010f019db37dcaf2e1fb98d4fcbf1f57dbd7e2a7f065e92fbe77dca8b9120d6e79f1617e98fa6134e6af8858ac8f3735b1e70a5708eb14f228080356eb0a7@mantis-testnet-1.mantis.ws:9002?discport=9502",
"enode://442e2bd50eece65f90dee0d5c6075da4e1b4bc62e36b261a52e7f393dae6a68241e4dbad868c7ecc14fed277ed72e99a289a811b6172f35fb18bdca0b7a5602c@mantis-testnet-2.mantis.ws:9003?discport=9503",
"enode://ff86741b7b35087b2b53f44a612b233336490d5fae10b1434619b7714fe2d5346c71427a5e126cd27b9422a4d4376c1534ef66e88c5e62d6441d2541f63de0cf@mantis-testnet-3.mantis.ws:9004?discport=9504",
"enode://af97643f364b805d5b0e32b5356578a16afcc4fb9d1b6622998e9441eeb7795e8daf8e6b0ff3330da9879034112be56954f9269164513ece0f7394b805be3633@mantis-testnet-4.mantis.ws:9005?discport=9505",
]
"""
}

jobs: {
explorer: #explorer
faucet: #faucet
miner: #miner & {#count: 5}
passive: #passive & {#count: 5}
morpho: #morpho
morpho: #morpho & {#count: 5}
}
}
"mantis-staging": {
vars: #network: "testnet-internal-nomad"
vars: {
#networkConfig: """
mantis.blockchains.testnet-internal-nomad.bootstrap-nodes = [
"enode://cbd80c7f72a889101b7f23d51be2de7e3f1f46ad3b25c438e959e24e08f03bd9fe833460e84b60174d4eb120af3b127389c4606f81c842943c4922cab384a234@mantis-staging-0.mantis.ws:33000?discport=33500",
"enode://0e63642be49c5a092569aa01663fcda1505362cd0ac41e24ff9296ab80c97af135fb6fb247273631a3a11257774f39ed882d72a20fd45131e53e9015adf6b9e5@mantis-staging-1.mantis.ws:33001?discport=33501",
"enode://3ee3641a25cfc611ba54a898260af7768ecf0643f06aefedf853864ed433d5ad6265eeb24abcc4d6f6ee90a1eac6c1fbf157fc05fd8e28e194dfc864cb56058e@mantis-staging-2.mantis.ws:33002?discport=33502",
"enode://907842e336fc757bbfde70368aef329714aa627e72e5da687f31b097fa71a59f36404aebbc83885c9b515270042e025a6788b700c314ee8bc68099dcff32afcd@mantis-staging-3.mantis.ws:33003?discport=33503",
"enode://92958d370442cfbf3efc46b37a0a1608298d8118013bf86868aaa49305a58991e006857552a88ac3349c5da43b00df44e685b39982f61c2fdeb3582daecac476@mantis-staging-4.mantis.ws:33004?discport=33504",
]
"""
}
jobs: {
explorer: #explorer
faucet: #faucet
miner: #miner & {#count: 5}
passive: #passive & {#count: 5}
morpho: #morpho
morpho: #morpho & {#count: 5}
}
}
// "mantis-iele": jobs: #defaultJobs
Expand Down
6 changes: 3 additions & 3 deletions jobs/mantis.cue
Expand Up @@ -10,9 +10,9 @@ import (
#role: "passive" | "miner" | "backup"
#mantisRev: string
#fqdn: string
#network: string
#networkConfig: string

let ref = {network: #network, mantisRev: #mantisRev, role: #role}
let ref = {networkConfig: #networkConfig, mantisRev: #mantisRev, role: #role}

namespace: string
type: "service"
Expand Down Expand Up @@ -62,7 +62,7 @@ import (
#namespace: namespace
#mantisRev: ref.mantisRev
#role: ref.role
#network: ref.network
#networkConfig: ref.networkConfig
}

task: promtail: tasks.#Promtail
Expand Down
25 changes: 12 additions & 13 deletions jobs/morpho.cue
Expand Up @@ -6,17 +6,17 @@ import (
)

#Morpho: types.#stanza.job & {
#index: uint
#count: uint
#mantisRev: string
#morphoRev: string
#fqdn: string
#network: string
#index: uint
#count: uint
#mantisRev: string
#morphoRev: string
#fqdn: string
#networkConfig: string

#name: "morpho-\(#index)"
#id: "\(namespace)-\(#name)"

let ref = {morphoRev: #morphoRev, network: #network, mantisRev: #mantisRev}
let ref = {morphoRev: #morphoRev, networkConfig: #networkConfig, mantisRev: #mantisRev}

namespace: string
type: "service"
Expand Down Expand Up @@ -52,10 +52,9 @@ import (
sticky: true
}


network: {
mode: "host"
// From https://github.com/input-output-hk/bitte/blob/33cb20fa1cd7c6e4d3bc75253fc166bf048b500c/profiles/docker.nix#L16
dns: servers: [ "172.17.0.1"]
port: {
discovery: {}
metrics: {}
Expand Down Expand Up @@ -83,10 +82,10 @@ import (
}

task: mantis: tasks.#Mantis & {
#namespace: namespace
#mantisRev: ref.mantisRev
#role: "passive"
#network: ref.network
#namespace: namespace
#mantisRev: ref.mantisRev
#role: "passive"
#networkConfig: ref.networkConfig
}
}
}
62 changes: 11 additions & 51 deletions jobs/tasks/mantis.cue
Expand Up @@ -7,10 +7,10 @@ import (
)

#Mantis: types.#stanza.task & {
#namespace: string
#role: "passive" | "miner" | "backup"
#mantisRev: string
#network: string
#namespace: string
#role: "passive" | "miner" | "backup"
#mantisRev: string
#networkConfig: string
#miners: []
#amountOfMorphoNodes: 5
#requiredPeerCount: len(#miners)
Expand Down Expand Up @@ -111,61 +111,20 @@ import (
"""
}

#saganoConf: string

if #network != "sagano" && #network != "testnet-internal-nomad" {
#saganoConf: ""
}

if #network == "sagano" {
#saganoConf: """
blockchains.testnet-internal-nomad = {
custom-genesis-file = "/local/genesis.json"
allowed-miners = []
bootstrap-nodes = [
"enode://f92aa66337ab1993cc7269d4295d296aefe6199b34e900eac08c514c947ec7340d46a5648ffc2da10325dbaba16bdf92aa9c0b5e51d97a7818c3f495d478ddad@mantis-testnet-0.mantis.ws:9001?discport=9501",
"enode://d8a010f019db37dcaf2e1fb98d4fcbf1f57dbd7e2a7f065e92fbe77dca8b9120d6e79f1617e98fa6134e6af8858ac8f3735b1e70a5708eb14f228080356eb0a7@mantis-testnet-1.mantis.ws:9002?discport=9502",
"enode://442e2bd50eece65f90dee0d5c6075da4e1b4bc62e36b261a52e7f393dae6a68241e4dbad868c7ecc14fed277ed72e99a289a811b6172f35fb18bdca0b7a5602c@mantis-testnet-2.mantis.ws:9003?discport=9503",
"enode://ff86741b7b35087b2b53f44a612b233336490d5fae10b1434619b7714fe2d5346c71427a5e126cd27b9422a4d4376c1534ef66e88c5e62d6441d2541f63de0cf@mantis-testnet-3.mantis.ws:9004?discport=9504",
"enode://af97643f364b805d5b0e32b5356578a16afcc4fb9d1b6622998e9441eeb7795e8daf8e6b0ff3330da9879034112be56954f9269164513ece0f7394b805be3633@mantis-testnet-4.mantis.ws:9005?discport=9505",
]
checkpoint-public-keys = [
\(#checkPointKeysString)
]
}
"""
}
change_mode: "noop"
splay: "1h"
data: """
logging.json-output = false
logging.logs-file = "logs"
if #network == "testnet-internal-nomad" {
#saganoConf: """
mantis = {
blockchains.testnet-internal-nomad = {
custom-genesis-file = "/local/genesis.json"
allowed-miners = []
bootstrap-nodes = [
"enode://cbd80c7f72a889101b7f23d51be2de7e3f1f46ad3b25c438e959e24e08f03bd9fe833460e84b60174d4eb120af3b127389c4606f81c842943c4922cab384a234@mantis-staging-0.mantis.ws:33000?discport=33500",
"enode://0e63642be49c5a092569aa01663fcda1505362cd0ac41e24ff9296ab80c97af135fb6fb247273631a3a11257774f39ed882d72a20fd45131e53e9015adf6b9e5@mantis-staging-1.mantis.ws:33001?discport=33501",
"enode://3ee3641a25cfc611ba54a898260af7768ecf0643f06aefedf853864ed433d5ad6265eeb24abcc4d6f6ee90a1eac6c1fbf157fc05fd8e28e194dfc864cb56058e@mantis-staging-2.mantis.ws:33002?discport=33502",
"enode://907842e336fc757bbfde70368aef329714aa627e72e5da687f31b097fa71a59f36404aebbc83885c9b515270042e025a6788b700c314ee8bc68099dcff32afcd@mantis-staging-3.mantis.ws:33003?discport=33503",
"enode://92958d370442cfbf3efc46b37a0a1608298d8118013bf86868aaa49305a58991e006857552a88ac3349c5da43b00df44e685b39982f61c2fdeb3582daecac476@mantis-staging-4.mantis.ws:33004?discport=33504",
]
checkpoint-public-keys = [
\(#checkPointKeysString)
]
}
"""
}

change_mode: "noop"
splay: "1h"
data: """
include "/conf/base.conf"
include "/conf/\(#network).conf"
logging.json-output = false
logging.logs-file = "logs"
mantis = {
\(#saganoConf)
client-id = "mantis-\(#role)-{{env "NOMAD_ALLOC_INDEX"}}"
datadir = "/local/mantis"
Expand All @@ -188,6 +147,7 @@ import (
}
\(#extraConfig)
\(#networkConfig)
"""
}

Expand Down
5 changes: 1 addition & 4 deletions schemas/nomad/types.cue
Expand Up @@ -98,7 +98,7 @@ import (
TaskGroup: {
Affinities: [...Affinity]
Constraints: [...Constraint]
Count: int & >0 | *1
Count: int & >0
Meta: [string]: string
Name: string
RestartPolicy: *null | #json.RestartPolicy
Expand Down Expand Up @@ -550,9 +550,6 @@ let durationType = string & =~"^[1-9]\\d*[hms]$"

network: {
mode: "host" | "bridge"
dns: *null | {
servers: [...string]
}
port: [string]: {
static: *null | uint
to: *null | uint
Expand Down

0 comments on commit fa82a9f

Please sign in to comment.