Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/setup/db-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ export default class SetupDbInit extends Command {
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.'));
const publicHost = await input({ message: 'Enter public PostgreSQL host:', default: 'localhost' })
const publicPort = await input({ message: 'Enter public PostgreSQL port:', default: '5432' })
const pgUser = await input({ message: 'Enter PostgreSQL admin username:', default: 'admin' })
const pgUser = await input({ message: 'Enter PostgreSQL admin username:', default: 'scrolladmin' })
const pgPassword = await password({ message: 'Enter PostgreSQL admin password:' })
const pgDatabase = await input({ message: 'Enter PostgreSQL database name:', default: 'postgres' })

Expand Down
17 changes: 17 additions & 0 deletions src/commands/setup/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,23 @@ export default class SetupDomains extends Command {
delete existingConfig.ingress.L1_EXPLORER_HOST
}

/*
[contracts.verification]
VERIFIER_TYPE_L1 = "blockscout"
VERIFIER_TYPE_L2 = "blockscout"
EXPLORER_URI_L1 = "http://l1-explorer.scrollsdk"
EXPLORER_URI_L2 = "http://blockscout.scrollsdk"
RPC_URI_L1 = "http://l1-devnet.scrollsdk"
RPC_URI_L2 = "http://l2-rpc.scrollsdk"
EXPLORER_API_KEY_L1 = ""
EXPLORER_API_KEY_L2 = ""
*/
existingConfig.contracts.verification.EXPLORER_URI_L1 = domainConfig.EXTERNAL_EXPLORER_URI_L1;
existingConfig.contracts.verification.EXPLORER_URI_L2 = domainConfig.EXTERNAL_EXPLORER_URI_L2;
existingConfig.contracts.verification.RPC_URI_L1 = domainConfig.EXTERNAL_RPC_URI_L1;
existingConfig.contracts.verification.RPC_URI_L2 = domainConfig.EXTERNAL_RPC_URI_L2;


// Convert the updated config back to TOML string
const updatedContent = toml.stringify(existingConfig)

Expand Down
9 changes: 8 additions & 1 deletion src/commands/setup/gen-keystore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ export default class SetupGenKeystore extends Command {
}

private async generateSequencerKeystore(index: number): Promise<SequencerData> {
const password = await input({ message: `Enter a password for sequencer-${index} keystore:` })
let password = ''
while (!password) {
password = await input({ message: `Enter a password for sequencer-${index} keystore:` })
if (!password) {
console.log('Password cannot be empty. Please try again.')
}
}

const wallet = Wallet.createRandom()
const encryptedJson = await wallet.encrypt(password)
return {
Expand Down
166 changes: 147 additions & 19 deletions src/commands/setup/prep-charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export default class SetupPrepCharts extends Command {
}

private async processProductionYaml(valuesDir: string): Promise<{ updated: number; skipped: number }> {


const productionFiles = fs.readdirSync(valuesDir)
.filter(file => file.endsWith('-production.yaml') || file.match(/-production-\d+\.yaml$/))

Expand All @@ -138,33 +140,39 @@ export default class SetupPrepCharts extends Command {
if (configMapData && typeof configMapData === 'object' && 'data' in configMapData) {
const envData = (configMapData as any).data
for (const [key, value] of Object.entries(envData)) {
if (value === '' || value === '[""]' || value === '[]' ||
(Array.isArray(value) && (value.length === 0 || (value.length === 1 && value[0] === ''))) ||
value === null || value === undefined) {
const configMapping = this.configMapping[key]
if (configMapping) {
let configKey: string
if (typeof configMapping === 'function') {
configKey = configMapping(chartName, productionNumber)
// if (value === '' || value === '[""]' || value === '[]' ||
// (Array.isArray(value) && (value.length === 0 || (value.length === 1 && value[0] === ''))) ||
// value === null || value === undefined) {
const configMapping = this.configMapping[key]
if (configMapping) {
let configKey: string
if (typeof configMapping === 'function') {
configKey = configMapping(chartName, productionNumber)
} else {
configKey = configMapping
}
if (chartName === "l1-devnet" && key === "CHAIN_ID") {
configKey = "general.CHAIN_ID_L1";
}

const configValue = this.getConfigValue(configKey)
if (configValue !== undefined && configValue !== null) {
let newValue: string | string[]
if (Array.isArray(configValue)) {
newValue = JSON.stringify(configValue)
} else {
configKey = configMapping
newValue = String(configValue)
}
const configValue = this.getConfigValue(configKey)
if (configValue !== undefined && configValue !== null) {
let newValue: string | string[]
if (Array.isArray(configValue)) {
newValue = JSON.stringify(configValue)
} else {
newValue = String(configValue)
}
if (newValue != value) {
changes.push({ key, oldValue: JSON.stringify(value), newValue: newValue })
envData[key] = newValue
updated = true
} else {
this.log(chalk.yellow(`${chartName}: No value found for ${configKey}`))
}
} else {
this.log(chalk.yellow(`${chartName}: No value found for ${configKey}`))
}
}
//}
}
}
}
Expand Down Expand Up @@ -237,6 +245,126 @@ export default class SetupPrepCharts extends Command {
}
}
}
/*
blockscout-stack.blockscout.ingress.annotations.nginx.ingress.kubernetes.io/cors-allow-origin:https://blockscout.scrollsdk
blockscout-stack.blockscout.ingress.hostname:blockscout.scrollsdk
blockscout-stack.frontend.env.NEXT_PUBLIC_API_HOST:blockscout.scrollsdk
blockscout-stack.frontend.ingress.annotations.nginx.ingress.kubernetes.io/cors-allow-origin: "https://blockscout.scrollsdk"
blockscout-stack.frontend.ingress.hostname: "blockscout.scrollsdk"
*/
if (productionYaml["blockscout-stack"]) {
let ingressUpdated = false;
const blockscout = productionYaml["blockscout-stack"].blockscout;
const frontend = productionYaml["blockscout-stack"].frontend;
let blockscout_host = this.getConfigValue("ingress.BLOCKSCOUT_HOST");
let blockscout_url = this.getConfigValue("frontend.EXTERNAL_EXPLORER_URI_L2");

if (blockscout?.ingress?.annotations?.["nginx.ingress.kubernetes.io/cors-allow-origin"]) {
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 });
blockscout.ingress.annotations["nginx.ingress.kubernetes.io/cors-allow-origin"] = blockscout_url;
ingressUpdated = true;
}

if (blockscout?.ingress?.hostname) {
changes.push({ key: `ingress.blockscout.hostname`, oldValue: blockscout.ingress.hostname, newValue: blockscout_host });
blockscout.ingress.hostname = blockscout_host;
ingressUpdated = true;
}
if (frontend?.env?.NEXT_PUBLIC_API_HOST) {
changes.push({ key: `frontend.env.NEXT_PUBLIC_API_HOST`, oldValue: frontend.env.NEXT_PUBLIC_API_HOST, newValue: blockscout_host });
frontend.env.NEXT_PUBLIC_API_HOST = blockscout_host;
ingressUpdated = true;
}
if (frontend?.ingress?.annotations?.["nginx.ingress.kubernetes.io/cors-allow-origin"]) {
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 });
frontend.ingress.annotations["nginx.ingress.kubernetes.io/cors-allow-origin"] = blockscout_url;
ingressUpdated = true;
}
if (frontend?.ingress?.hostname) {
changes.push({ key: `frontend.ingress.hostname`, oldValue: frontend.ingress.hostname, newValue: blockscout_host });
frontend.ingress.hostname = blockscout_host;
ingressUpdated = true;
}
/*
INDEXER_SCROLL_L1_CHAIN_CONTRACT: ""
INDEXER_SCROLL_L1_BATCH_START_BLOCK: ""
INDEXER_SCROLL_L1_MESSENGER_CONTRACT: ""
INDEXER_SCROLL_L1_MESSENGER_START_BLOCK: ""
INDEXER_SCROLL_L2_MESSENGER_CONTRACT: ""
INDEXER_SCROLL_L2_GAS_ORACLE_CONTRACT: ""
INDEXER_SCROLL_L1_RPC: ""
INDEXER_SCROLL_L2_MESSENGER_START_BLOCK: 0
INDEXER_SCROLL_L1_ETH_GET_LOGS_RANGE_SIZE: 500
INDEXER_SCROLL_L2_ETH_GET_LOGS_RANGE_SIZE: 500
*/
interface BlockscoutEnvMapping {
key: string;
configKey: string;
defaultValue?: string;
}

const BLOCKSCOUT_ENV_MAPPINGS: BlockscoutEnvMapping[] = [
{
key: 'INDEXER_SCROLL_L1_BATCH_START_BLOCK',
configKey: '',
defaultValue: '0'
},
{
key: 'INDEXER_SCROLL_L1_MESSENGER_START_BLOCK',
configKey: '',
defaultValue: '0'
},
{
key: 'INDEXER_SCROLL_L1_CHAIN_CONTRACT',
configKey: 'contractsFile.L1_SCROLL_CHAIN_PROXY_ADDR'
},
{
key: 'INDEXER_SCROLL_L1_MESSENGER_CONTRACT',
configKey: 'L1_SCROLL_MESSENGER_PROXY_ADDR'
},
{
key: 'INDEXER_SCROLL_L2_MESSENGER_CONTRACT',
configKey: 'L2_SCROLL_MESSENGER_PROXY_ADDR'
},
{
key: 'INDEXER_SCROLL_L2_GAS_ORACLE_CONTRACT',
configKey: 'L1_GAS_PRICE_ORACLE_ADDR'
},
{
key: 'INDEXER_SCROLL_L1_RPC',
configKey: 'general.L1_RPC_ENDPOINT'
}


];
const benv = productionYaml["blockscout-stack"].blockscout.env;

BLOCKSCOUT_ENV_MAPPINGS.forEach(mapping => {
const { key, configKey, defaultValue } = mapping;

let newValue = this.getConfigValue(configKey);
if (!newValue) {
newValue = configKey ? this.contractsConfig[configKey] : defaultValue;
}

if (newValue !== undefined) {
changes.push({
key: `blockscout.env.${key}`,
oldValue: benv[key],
newValue: newValue
});
benv[key] = newValue;
} else {
this.log(chalk.yellow(`No value found for ${key}`));
}
});

updated = true;

if (ingressUpdated) {
updated = true;
}
}

if (productionYaml.grafana) {
let ingressUpdated = false;
Expand Down
Loading
Loading