Skip to content

Commit 38e94f9

Browse files
authored
Merge pull request #6 from unifralabs/unifra/euclid-upgrade
Shu fix bugs (#7)
2 parents 0b0dec3 + 10531b6 commit 38e94f9

File tree

7 files changed

+281
-80
lines changed

7 files changed

+281
-80
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@scroll-tech/scroll-sdk-cli",
3-
"description": "A tool for managing and testing Scroll SDK deployments",
4-
"version": "0.1.2",
3+
"description": "A tool for managing and testing Scroll SDK(Dogeos) deployments",
4+
"version": "0.1.3",
55
"author": "Daniel Helm",
66
"bin": {
77
"scrollsdk": "bin/run.js"
@@ -48,7 +48,7 @@
4848
"eslint-config-prettier": "^9",
4949
"mocha": "^10",
5050
"oclif": "^4",
51-
"shx": "^0.3.3",
51+
"shx": "^0.4.0",
5252
"sinon": "^18.0.0",
5353
"ts-node": "^10",
5454
"typescript": "^5"

src/commands/setup/configs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class SetupConfigs extends Command {
1414

1515
static override examples = [
1616
'<%= config.bin %> <%= command.id %>',
17-
'<%= config.bin %> <%= command.id %> --image-tag gen-configs-9b29d9b6dcea6828118c0ee63d208095265f3a03',
17+
'<%= config.bin %> <%= command.id %> --image-tag gen-configs-f961bf3e75c7c3fec63250062e751b0aaf47fefd',
1818
'<%= config.bin %> <%= command.id %> --configs-dir custom-configs',
1919
]
2020

@@ -465,7 +465,7 @@ export default class SetupConfigs extends Command {
465465
}
466466

467467
private async getDockerImageTag(providedTag: string | undefined): Promise<string> {
468-
const defaultTag = 'gen-configs-9b29d9b6dcea6828118c0ee63d208095265f3a03'
468+
const defaultTag = 'gen-configs-f961bf3e75c7c3fec63250062e751b0aaf47fefd'
469469

470470
if (!providedTag) {
471471
return defaultTag

src/commands/setup/db-init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ export default class SetupDbInit extends Command {
377377
this.log(chalk.blue('First, provide connection information for the database instance. This will only be used for creating users and databases. This information will not be persisted in your configuration repo.'));
378378
const publicHost = await input({ message: 'Enter public PostgreSQL host:', default: 'localhost' })
379379
const publicPort = await input({ message: 'Enter public PostgreSQL port:', default: '5432' })
380-
const pgUser = await input({ message: 'Enter PostgreSQL admin username:', default: 'admin' })
380+
const pgUser = await input({ message: 'Enter PostgreSQL admin username:', default: 'scrolladmin' })
381381
const pgPassword = await password({ message: 'Enter PostgreSQL admin password:' })
382382
const pgDatabase = await input({ message: 'Enter PostgreSQL database name:', default: 'postgres' })
383383

src/commands/setup/domains.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,23 @@ export default class SetupDomains extends Command {
457457
delete existingConfig.ingress.L1_EXPLORER_HOST
458458
}
459459

460+
/*
461+
[contracts.verification]
462+
VERIFIER_TYPE_L1 = "blockscout"
463+
VERIFIER_TYPE_L2 = "blockscout"
464+
EXPLORER_URI_L1 = "http://l1-explorer.scrollsdk"
465+
EXPLORER_URI_L2 = "http://blockscout.scrollsdk"
466+
RPC_URI_L1 = "http://l1-devnet.scrollsdk"
467+
RPC_URI_L2 = "http://l2-rpc.scrollsdk"
468+
EXPLORER_API_KEY_L1 = ""
469+
EXPLORER_API_KEY_L2 = ""
470+
*/
471+
existingConfig.contracts.verification.EXPLORER_URI_L1 = domainConfig.EXTERNAL_EXPLORER_URI_L1;
472+
existingConfig.contracts.verification.EXPLORER_URI_L2 = domainConfig.EXTERNAL_EXPLORER_URI_L2;
473+
existingConfig.contracts.verification.RPC_URI_L1 = domainConfig.EXTERNAL_RPC_URI_L1;
474+
existingConfig.contracts.verification.RPC_URI_L2 = domainConfig.EXTERNAL_RPC_URI_L2;
475+
476+
460477
// Convert the updated config back to TOML string
461478
const updatedContent = toml.stringify(existingConfig)
462479

src/commands/setup/prep-charts.ts

Lines changed: 147 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ export default class SetupPrepCharts extends Command {
113113
}
114114

115115
private async processProductionYaml(valuesDir: string): Promise<{ updated: number; skipped: number }> {
116+
117+
116118
const productionFiles = fs.readdirSync(valuesDir)
117119
.filter(file => file.endsWith('-production.yaml') || file.match(/-production-\d+\.yaml$/))
118120

@@ -141,36 +143,35 @@ export default class SetupPrepCharts extends Command {
141143
// if (value === '' || value === '[""]' || value === '[]' ||
142144
// (Array.isArray(value) && (value.length === 0 || (value.length === 1 && value[0] === ''))) ||
143145
// value === null || value === undefined) {
144-
const configMapping = this.configMapping[key]
145-
if (configMapping) {
146-
let configKey: string
147-
if (typeof configMapping === 'function') {
148-
configKey = configMapping(chartName, productionNumber)
149-
} else {
150-
configKey = configMapping
151-
}
152-
const configValue = this.getConfigValue(configKey)
153-
if (configValue !== undefined && configValue !== null) {
154-
let newValue: string | string[]
155-
if (Array.isArray(configValue)) {
156-
newValue = JSON.stringify(configValue)
157-
} else {
158-
newValue = String(configValue)
159-
}
146+
const configMapping = this.configMapping[key]
147+
if (configMapping) {
148+
let configKey: string
149+
if (typeof configMapping === 'function') {
150+
configKey = configMapping(chartName, productionNumber)
151+
} else {
152+
configKey = configMapping
153+
}
154+
if (chartName === "l1-devnet" && key === "CHAIN_ID") {
155+
configKey = "general.CHAIN_ID_L1";
156+
}
160157

161-
if(chartName === "l1-devnet" && key === "CHAIN_ID"){
162-
continue;
163-
}
164-
if (newValue != value) {
165-
changes.push({ key, oldValue: JSON.stringify(value), newValue: newValue })
166-
envData[key] = newValue
167-
updated = true
168-
}
158+
const configValue = this.getConfigValue(configKey)
159+
if (configValue !== undefined && configValue !== null) {
160+
let newValue: string | string[]
161+
if (Array.isArray(configValue)) {
162+
newValue = JSON.stringify(configValue)
169163
} else {
170-
this.log(chalk.yellow(`${chartName}: No value found for ${configKey}`))
164+
newValue = String(configValue)
171165
}
166+
if (newValue != value) {
167+
changes.push({ key, oldValue: JSON.stringify(value), newValue: newValue })
168+
envData[key] = newValue
169+
updated = true
170+
}
171+
} else {
172+
this.log(chalk.yellow(`${chartName}: No value found for ${configKey}`))
172173
}
173-
//}
174+
}
174175
}
175176
}
176177
}
@@ -243,6 +244,126 @@ export default class SetupPrepCharts extends Command {
243244
}
244245
}
245246
}
247+
/*
248+
blockscout-stack.blockscout.ingress.annotations.nginx.ingress.kubernetes.io/cors-allow-origin:https://blockscout.scrollsdk
249+
blockscout-stack.blockscout.ingress.hostname:blockscout.scrollsdk
250+
blockscout-stack.frontend.env.NEXT_PUBLIC_API_HOST:blockscout.scrollsdk
251+
blockscout-stack.frontend.ingress.annotations.nginx.ingress.kubernetes.io/cors-allow-origin: "https://blockscout.scrollsdk"
252+
blockscout-stack.frontend.ingress.hostname: "blockscout.scrollsdk"
253+
*/
254+
if (productionYaml["blockscout-stack"]) {
255+
let ingressUpdated = false;
256+
const blockscout = productionYaml["blockscout-stack"].blockscout;
257+
const frontend = productionYaml["blockscout-stack"].frontend;
258+
let blockscout_host = this.getConfigValue("ingress.BLOCKSCOUT_HOST");
259+
let blockscout_url = this.getConfigValue("frontend.EXTERNAL_EXPLORER_URI_L2");
260+
261+
if (blockscout?.ingress?.annotations?.["nginx.ingress.kubernetes.io/cors-allow-origin"]) {
262+
changes.push({ key: `ingress.blockscout.annotations["nginx.ingress.kubernetes.io/cors-allow-origin"]`, oldValue: blockscout.ingress.annotations["nginx.ingress.kubernetes.io/cors-allow-origin"], newValue: blockscout_url });
263+
blockscout.ingress.annotations["nginx.ingress.kubernetes.io/cors-allow-origin"] = blockscout_url;
264+
ingressUpdated = true;
265+
}
266+
267+
if (blockscout?.ingress?.hostname) {
268+
changes.push({ key: `ingress.blockscout.hostname`, oldValue: blockscout.ingress.hostname, newValue: blockscout_host });
269+
blockscout.ingress.hostname = blockscout_host;
270+
ingressUpdated = true;
271+
}
272+
if (frontend?.env?.NEXT_PUBLIC_API_HOST) {
273+
changes.push({ key: `frontend.env.NEXT_PUBLIC_API_HOST`, oldValue: frontend.env.NEXT_PUBLIC_API_HOST, newValue: blockscout_host });
274+
frontend.env.NEXT_PUBLIC_API_HOST = blockscout_host;
275+
ingressUpdated = true;
276+
}
277+
if (frontend?.ingress?.annotations?.["nginx.ingress.kubernetes.io/cors-allow-origin"]) {
278+
changes.push({ key: `frontend.ingress.annotations["nginx.ingress.kubernetes.io/cors-allow-origin"]`, oldValue: frontend.ingress.annotations["nginx.ingress.kubernetes.io/cors-allow-origin"], newValue: blockscout_url });
279+
frontend.ingress.annotations["nginx.ingress.kubernetes.io/cors-allow-origin"] = blockscout_url;
280+
ingressUpdated = true;
281+
}
282+
if (frontend?.ingress?.hostname) {
283+
changes.push({ key: `frontend.ingress.hostname`, oldValue: frontend.ingress.hostname, newValue: blockscout_host });
284+
frontend.ingress.hostname = blockscout_host;
285+
ingressUpdated = true;
286+
}
287+
/*
288+
INDEXER_SCROLL_L1_CHAIN_CONTRACT: ""
289+
INDEXER_SCROLL_L1_BATCH_START_BLOCK: ""
290+
INDEXER_SCROLL_L1_MESSENGER_CONTRACT: ""
291+
INDEXER_SCROLL_L1_MESSENGER_START_BLOCK: ""
292+
INDEXER_SCROLL_L2_MESSENGER_CONTRACT: ""
293+
INDEXER_SCROLL_L2_GAS_ORACLE_CONTRACT: ""
294+
INDEXER_SCROLL_L1_RPC: ""
295+
INDEXER_SCROLL_L2_MESSENGER_START_BLOCK: 0
296+
INDEXER_SCROLL_L1_ETH_GET_LOGS_RANGE_SIZE: 500
297+
INDEXER_SCROLL_L2_ETH_GET_LOGS_RANGE_SIZE: 500
298+
*/
299+
interface BlockscoutEnvMapping {
300+
key: string;
301+
configKey: string;
302+
defaultValue?: string;
303+
}
304+
305+
const BLOCKSCOUT_ENV_MAPPINGS: BlockscoutEnvMapping[] = [
306+
{
307+
key: 'INDEXER_SCROLL_L1_BATCH_START_BLOCK',
308+
configKey: '',
309+
defaultValue: '0'
310+
},
311+
{
312+
key: 'INDEXER_SCROLL_L1_MESSENGER_START_BLOCK',
313+
configKey: '',
314+
defaultValue: '0'
315+
},
316+
{
317+
key: 'INDEXER_SCROLL_L1_CHAIN_CONTRACT',
318+
configKey: 'contractsFile.L1_SCROLL_CHAIN_PROXY_ADDR'
319+
},
320+
{
321+
key: 'INDEXER_SCROLL_L1_MESSENGER_CONTRACT',
322+
configKey: 'L1_SCROLL_MESSENGER_PROXY_ADDR'
323+
},
324+
{
325+
key: 'INDEXER_SCROLL_L2_MESSENGER_CONTRACT',
326+
configKey: 'L2_SCROLL_MESSENGER_PROXY_ADDR'
327+
},
328+
{
329+
key: 'INDEXER_SCROLL_L2_GAS_ORACLE_CONTRACT',
330+
configKey: 'L1_GAS_PRICE_ORACLE_ADDR'
331+
},
332+
{
333+
key: 'INDEXER_SCROLL_L1_RPC',
334+
configKey: 'general.L1_RPC_ENDPOINT'
335+
}
336+
337+
338+
];
339+
const benv = productionYaml["blockscout-stack"].blockscout.env;
340+
341+
BLOCKSCOUT_ENV_MAPPINGS.forEach(mapping => {
342+
const { key, configKey, defaultValue } = mapping;
343+
344+
let newValue = this.getConfigValue(configKey);
345+
if (!newValue) {
346+
newValue = configKey ? this.contractsConfig[configKey] : defaultValue;
347+
}
348+
349+
if (newValue !== undefined) {
350+
changes.push({
351+
key: `blockscout.env.${key}`,
352+
oldValue: benv[key],
353+
newValue: newValue
354+
});
355+
benv[key] = newValue;
356+
} else {
357+
this.log(chalk.yellow(`No value found for ${key}`));
358+
}
359+
});
360+
361+
updated = true;
362+
363+
if (ingressUpdated) {
364+
updated = true;
365+
}
366+
}
246367

247368
if (productionYaml.grafana) {
248369
let ingressUpdated = false;

0 commit comments

Comments
 (0)