Skip to content

Commit 0e9cb33

Browse files
authored
Merge pull request #361 from genlayerlabs/feat/multi-network-support
feat: add support for Asimov and Bradbury network configurations in setup guide and action files
2 parents 4e26871 + 4e4cb36 commit 0e9cb33

File tree

7 files changed

+120
-59
lines changed

7 files changed

+120
-59
lines changed

.github/actions/sync-files/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ runs:
3838
using: 'composite'
3939
steps:
4040
- name: Prepare config file
41-
if: inputs.type == 'config'
41+
if: inputs.type == 'config' || inputs.type == 'config_asimov' || inputs.type == 'config_bradbury'
4242
shell: bash
4343
run: |
4444
# For config type, handle special case:
@@ -92,7 +92,7 @@ runs:
9292
shell: bash
9393
run: |
9494
# Use prepared source for config/docker_compose types, otherwise use original source
95-
if [[ "${{ inputs.type }}" == "config" ]] && [[ -n "$CONFIG_SOURCE" ]]; then
95+
if [[ "${{ inputs.type }}" == "config" || "${{ inputs.type }}" == "config_asimov" || "${{ inputs.type }}" == "config_bradbury" ]] && [[ -n "$CONFIG_SOURCE" ]]; then
9696
SOURCE_PATH="$CONFIG_SOURCE"
9797
elif [[ "${{ inputs.type }}" == "docker_compose" ]] && [[ -n "$DOCKER_COMPOSE_SOURCE" ]]; then
9898
SOURCE_PATH="$DOCKER_COMPOSE_SOURCE"
@@ -109,7 +109,7 @@ runs:
109109
"${{ inputs.exclude_files }}"
110110
111111
- name: Cleanup config temp directory
112-
if: inputs.type == 'config' && always()
112+
if: (inputs.type == 'config' || inputs.type == 'config_asimov' || inputs.type == 'config_bradbury') && always()
113113
shell: bash
114114
run: |
115115
if [[ -n "$TEMP_CONFIG_DIR" ]] && [[ -d "$TEMP_CONFIG_DIR" ]]; then

.github/workflows/sync-docs-from-node.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
needs: prepare
9393
strategy:
9494
matrix:
95-
sync_type: [changelog, config, docker_compose, api_gen, api_debug, api_ops]
95+
sync_type: [changelog, config, config_asimov, config_bradbury, docker_compose, api_gen, api_debug, api_ops]
9696
fail-fast: false
9797
steps:
9898
- name: Checkout documentation repository
@@ -101,7 +101,7 @@ jobs:
101101
token: ${{ secrets.GITHUB_TOKEN }}
102102

103103
- name: Install yq for YAML sanitization
104-
if: matrix.sync_type == 'config' || matrix.sync_type == 'docker_compose'
104+
if: matrix.sync_type == 'config' || matrix.sync_type == 'config_asimov' || matrix.sync_type == 'config_bradbury' || matrix.sync_type == 'docker_compose'
105105
run: |
106106
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
107107
sudo chmod +x /usr/local/bin/yq
@@ -115,6 +115,8 @@ jobs:
115115
sparse-checkout: |
116116
docs
117117
configs/node/config.yaml.example
118+
configs/node/asimov.yaml.example
119+
configs/node/bradbury.yaml.example
118120
release/docker-compose.yaml
119121
sparse-checkout-cone-mode: true
120122
path: source-repo
@@ -136,6 +138,18 @@ jobs:
136138
echo "target_path=content/validators/config.yaml" >> $GITHUB_OUTPUT
137139
echo "filter_pattern=.*" >> $GITHUB_OUTPUT
138140
;;
141+
"config_asimov")
142+
echo "title=Config File (Asimov)" >> $GITHUB_OUTPUT
143+
echo "source_path=source-repo/configs/node/asimov.yaml.example" >> $GITHUB_OUTPUT
144+
echo "target_path=content/validators/asimov.yaml" >> $GITHUB_OUTPUT
145+
echo "filter_pattern=.*" >> $GITHUB_OUTPUT
146+
;;
147+
"config_bradbury")
148+
echo "title=Config File (Bradbury)" >> $GITHUB_OUTPUT
149+
echo "source_path=source-repo/configs/node/bradbury.yaml.example" >> $GITHUB_OUTPUT
150+
echo "target_path=content/validators/bradbury.yaml" >> $GITHUB_OUTPUT
151+
echo "filter_pattern=.*" >> $GITHUB_OUTPUT
152+
;;
139153
"docker_compose")
140154
echo "title=Docker Compose File" >> $GITHUB_OUTPUT
141155
echo "source_path=source-repo/release/docker-compose.yaml" >> $GITHUB_OUTPUT
@@ -474,11 +488,13 @@ jobs:
474488
echo "" >> $GITHUB_STEP_SUMMARY
475489
476490
# Process each sync type report
477-
for sync_type in changelog config docker_compose api_gen api_debug api_ops; do
491+
for sync_type in changelog config config_asimov config_bradbury docker_compose api_gen api_debug api_ops; do
478492
# Get proper title
479493
case "$sync_type" in
480494
"changelog") title="📝 Changelog Sync" ;;
481495
"config") title="⚙️ Config File Sync" ;;
496+
"config_asimov") title="⚙️ Config File Sync (Asimov)" ;;
497+
"config_bradbury") title="⚙️ Config File Sync (Bradbury)" ;;
482498
"docker_compose") title="🐳 Docker Compose Sync" ;;
483499
"api_gen") title="🔧 API Gen Methods Sync" ;;
484500
"api_debug") title="🐛 API Debug Methods Sync" ;;

content/validators/asimov.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Asimov Phase 5 network consensus configuration
2+
consensus:
3+
consensusaddress: "0xe66B434bc83805f380509642429eC8e43AE9874a"
4+
genesis: 17326

content/validators/bradbury.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Bradbury Phase 1 network consensus configuration
2+
consensus:
3+
consensusaddress: "0x8aCE036C8C3C5D603dB546b031302FCf149648E8"
4+
genesis: 501711

pages/validators/monitoring.mdx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ CENTRAL_LOKI_PASSWORD=your-logs-password
117117
# Node identification
118118
NODE_ID=validator-001
119119
VALIDATOR_NAME=MyValidator
120+
NETWORK_NAME=asimov-phase5
120121
121122
# Usually defaults are fine
122123
NODE_METRICS_ENDPOINT=host.docker.internal:9153
@@ -165,6 +166,7 @@ alloy:
165166
# Single node configuration
166167
- NODE_ID=${NODE_ID:-local}
167168
- VALIDATOR_NAME=${VALIDATOR_NAME:-default}
169+
- NETWORK_NAME=${NETWORK_NAME:-asimov-phase5}
168170
- NODE_METRICS_ENDPOINT=${NODE_METRICS_ENDPOINT:-host.docker.internal:9153}
169171

170172
# Multi-node configuration
@@ -237,6 +239,12 @@ discovery.relabel "add_labels" {
237239
replacement = "alloy"
238240
}
239241

242+
// Add network label from environment variable
243+
rule {
244+
target_label = "network"
245+
replacement = coalesce(sys.env("NETWORK_NAME"), "asimov-phase5")
246+
}
247+
240248
// Add job label
241249
rule {
242250
target_label = "job"
@@ -278,16 +286,16 @@ loki.write "central" {
278286
// Supports both single node and multi-node configurations
279287
//
280288
// Single Node Mode:
281-
// Set NODE_METRICS_ENDPOINT, NODE_ID, VALIDATOR_NAME
289+
// Set NODE_METRICS_ENDPOINT, NODE_ID, VALIDATOR_NAME, NETWORK_NAME
282290
//
283291
// Multi-Node Mode:
284292
// Set SCRAPE_TARGETS_JSON with JSON array of target objects
285-
// Example: [{"__address__":"host.docker.internal:9250","instance":"0x...","validator_name":"node-1"}]
293+
// Example: [{"__address__":"host.docker.internal:9250","instance":"0x...","validator_name":"node-1","network":"testnet-asimov"}]
286294
prometheus.scrape "genlayer_node" {
287295
// Dynamic targets based on environment variable
288296
// If SCRAPE_TARGETS_JSON is set, use it (multi-node mode)
289297
// Otherwise, build single target from individual env vars (single node mode)
290-
targets = encoding.from_json(coalesce(sys.env("SCRAPE_TARGETS_JSON"), string.format("[{\"__address__\":\"%s\",\"instance\":\"%s\",\"validator_name\":\"%s\"}]", coalesce(sys.env("NODE_METRICS_ENDPOINT"), "host.docker.internal:9153"), coalesce(sys.env("NODE_ID"), "local"), coalesce(sys.env("VALIDATOR_NAME"), "default"))))
298+
targets = encoding.from_json(coalesce(sys.env("SCRAPE_TARGETS_JSON"), string.format("[{\"__address__\":\"%s\",\"instance\":\"%s\",\"validator_name\":\"%s\",\"network\":\"%s\"}]", coalesce(sys.env("NODE_METRICS_ENDPOINT"), "host.docker.internal:9153"), coalesce(sys.env("NODE_ID"), "local"), coalesce(sys.env("VALIDATOR_NAME"), "default"), coalesce(sys.env("NETWORK_NAME"), "asimov-phase5"))))
291299

292300
forward_to = [prometheus.relabel.metrics.receiver]
293301

pages/validators/setup-guide.mdx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ This is the main configuration file of your node. Without it, your node won't st
255255

256256
The file needs to be located at `configs/node/config.yaml`
257257

258-
You can use the following example configuration. **Note:** For most users, you will only need to modify the `genlayerchainrpcurl` and `genlayerchainwebsocketurl` values below.
258+
You can use the following example configuration. **Note:** For most users, you will only need to modify the `genlayerchainrpcurl`, `genlayerchainwebsocketurl`, and the `consensus` section for your target network (see [Network-Specific Consensus Configuration](#network-specific-consensus-configuration) below).
259259

260260
```yaml copy
261261
# rollup configuration
@@ -366,6 +366,30 @@ metrics:
366366

367367
```
368368

369+
#### Network-Specific Consensus Configuration
370+
371+
Set the `consensus` section in your `config.yaml` according to the network you want to join:
372+
373+
##### Testnet Asimov
374+
375+
```yaml copy
376+
# Asimov Phase 5 network consensus configuration
377+
consensus:
378+
consensusaddress: "0xe66B434bc83805f380509642429eC8e43AE9874a"
379+
genesis: 17326
380+
381+
```
382+
383+
##### Testnet Bradbury
384+
385+
```yaml copy
386+
# Bradbury Phase 1 network consensus configuration
387+
consensus:
388+
consensusaddress: "0x8aCE036C8C3C5D603dB546b031302FCf149648E8"
389+
genesis: 501711
390+
391+
```
392+
369393
#### Overriding Configuration with Environment Variables
370394

371395
Any configuration value in `config.yaml` can be overridden using environment variables with the prefix `GENLAYERNODE_`.

scripts/update-config-in-setup-guide.js

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,71 +5,76 @@ const path = require('path');
55

66
/**
77
* Update the setup guide with the latest config from content/validators/config.yaml
8+
* and network-specific consensus configs from content/validators/asimov.yaml and bradbury.yaml
89
*/
910
function updateConfigInSetupGuide() {
1011
const configPath = path.join(process.cwd(), 'content/validators/config.yaml');
12+
const asimovPath = path.join(process.cwd(), 'content/validators/asimov.yaml');
13+
const bradburyPath = path.join(process.cwd(), 'content/validators/bradbury.yaml');
1114
const setupGuidePath = path.join(process.cwd(), 'pages/validators/setup-guide.mdx');
12-
13-
if (!fs.existsSync(configPath)) {
14-
console.error(`Config file ${configPath} does not exist`);
15-
return;
16-
}
17-
15+
1816
if (!fs.existsSync(setupGuidePath)) {
1917
console.error(`Setup guide file ${setupGuidePath} does not exist`);
2018
return;
2119
}
22-
23-
// Read the config.yaml content
24-
const configContent = fs.readFileSync(configPath, 'utf8');
25-
26-
// Read the setup guide
20+
2721
let setupGuideContent = fs.readFileSync(setupGuidePath, 'utf8');
28-
29-
// Pattern to match the YAML config block
30-
// Looks for the text before the yaml block, the yaml block itself, and the text after
31-
// Note: The yaml block may have additional attributes like "copy" (```yaml copy)
32-
// Uses [\s\S]*? to match any characters (including backticks in inline code) until the yaml block
33-
const configPattern = /(You can use the following example configuration[\s\S]*?```yaml[^\n]*\n)([\s\S]*?)(\n```)/;
34-
35-
if (configPattern.test(setupGuideContent)) {
36-
// Replace the config content while preserving the surrounding text
37-
setupGuideContent = setupGuideContent.replace(
38-
configPattern,
39-
`$1${configContent}$3`
40-
);
41-
42-
// Write the updated content back
43-
fs.writeFileSync(setupGuidePath, setupGuideContent);
44-
console.log(`Updated setup guide config at ${new Date().toISOString()}`);
45-
} else {
46-
console.error('Could not find config pattern in setup guide');
47-
48-
// Try a more general pattern as fallback
49-
const fallbackPattern = /(```yaml\n)([\s\S]*?)(\n```)/;
50-
const matches = setupGuideContent.match(fallbackPattern);
51-
52-
if (matches) {
53-
// Check if this looks like the config block by looking for consensus addresses
54-
if (matches[2].includes('contractmanageraddress') || matches[2].includes('consensus:')) {
55-
setupGuideContent = setupGuideContent.replace(
56-
fallbackPattern,
57-
`$1${configContent}$3`
58-
);
59-
fs.writeFileSync(setupGuidePath, setupGuideContent);
60-
console.log(`Updated setup guide config using fallback pattern at ${new Date().toISOString()}`);
61-
} else {
62-
console.error('Found YAML block but it does not appear to be the config block');
63-
}
22+
23+
// Update main config block from config.yaml
24+
if (fs.existsSync(configPath)) {
25+
const configContent = fs.readFileSync(configPath, 'utf8');
26+
const configPattern = /(You can use the following example configuration[\s\S]*?```yaml[^\n]*\n)([\s\S]*?)(\n```)/;
27+
28+
if (configPattern.test(setupGuideContent)) {
29+
setupGuideContent = setupGuideContent.replace(
30+
configPattern,
31+
`$1${configContent}$3`
32+
);
33+
console.log(`Updated main config block at ${new Date().toISOString()}`);
6434
} else {
65-
console.error('Could not find any YAML block in setup guide');
35+
console.error('Could not find main config pattern in setup guide');
6636
}
6737
}
38+
39+
// Update Asimov consensus config
40+
if (fs.existsSync(asimovPath)) {
41+
const asimovContent = fs.readFileSync(asimovPath, 'utf8');
42+
const asimovPattern = /(##### Testnet Asimov\s*```yaml[^\n]*\n)([\s\S]*?)(\n```)/;
43+
44+
if (asimovPattern.test(setupGuideContent)) {
45+
setupGuideContent = setupGuideContent.replace(
46+
asimovPattern,
47+
`$1${asimovContent}$3`
48+
);
49+
console.log(`Updated Asimov config block at ${new Date().toISOString()}`);
50+
} else {
51+
console.error('Could not find Asimov config pattern in setup guide');
52+
}
53+
}
54+
55+
// Update Bradbury consensus config
56+
if (fs.existsSync(bradburyPath)) {
57+
const bradburyContent = fs.readFileSync(bradburyPath, 'utf8');
58+
const bradburyPattern = /(##### Testnet Bradbury\s*```yaml[^\n]*\n)([\s\S]*?)(\n```)/;
59+
60+
if (bradburyPattern.test(setupGuideContent)) {
61+
setupGuideContent = setupGuideContent.replace(
62+
bradburyPattern,
63+
`$1${bradburyContent}$3`
64+
);
65+
console.log(`Updated Bradbury config block at ${new Date().toISOString()}`);
66+
} else {
67+
console.error('Could not find Bradbury config pattern in setup guide');
68+
}
69+
}
70+
71+
// Write the updated content back
72+
fs.writeFileSync(setupGuidePath, setupGuideContent);
6873
}
6974

7075
// Run the script
7176
if (require.main === module) {
7277
updateConfigInSetupGuide();
7378
}
7479

75-
module.exports = { updateConfigInSetupGuide };
80+
module.exports = { updateConfigInSetupGuide };

0 commit comments

Comments
 (0)