Skip to content

Commit 8f5b8ba

Browse files
committed
Fixed network switching
1 parent 0743bad commit 8f5b8ba

7 files changed

Lines changed: 79 additions & 27 deletions

File tree

controls/roles/manage-service/tasks/main.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,23 @@
7474
with_items: "{{ stereum_service_configuration.ports }}"
7575
when: stereum.manage_service.state != "restarted" and stereum_service_configuration.ports is defined
7676

77+
- name: Get engine.jwt stat
78+
stat:
79+
path: "{{ stereum_service_configuration.volumes | select('search', ':/engine.jwt') | first | split(':') | first }}"
80+
become: yes
81+
register: jwt_file
82+
when:
83+
- stereum.manage_service.state == "started" or stereum.manage_service.state == "restarted"
84+
- stereum_service_configuration.service in ['GethService', 'PrysmBeaconService']
85+
- stereum_service_configuration.volumes | select('search', ':/engine.jwt') | length > 0
86+
87+
- name: Delete engine.jwt directory
88+
file:
89+
path: "{{ jwt_file.stat.path }}"
90+
state: absent
91+
become: yes
92+
when: jwt_file.stat.isdir is defined and jwt_file.stat.isdir
93+
7794
- name: Generate JWT (execution client only)
7895
copy:
7996
content: "ff{{ query('community.general.random_string', override_all=hex_chars, length=62) | first }}"

launcher/src/backend/ServiceManager.js

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { CharonService } from "./ethereum-services/CharonService";
55
import { PrometheusService } from "./ethereum-services/PrometheusService";
66
import { PrometheusNodeExporterService } from "./ethereum-services/PrometheusNodeExporterService";
77
import { GrafanaService } from "./ethereum-services/GrafanaService";
8-
import { PrysmBeaconService } from "./ethereum-services/PrysmBeaconService";
8+
import { PrysmBeaconService, checkpointSyncUrls } from "./ethereum-services/PrysmBeaconService";
99
import { PrysmValidatorService } from "./ethereum-services/PrysmValidatorService";
1010
import { FlashbotsMevBoostService } from "./ethereum-services/FlashbotsMevBoostService";
1111
import { ServicePort, servicePortProtocol, changeablePorts } from "./ethereum-services/ServicePort";
@@ -16,7 +16,7 @@ import { MetricsExporterService } from "./ethereum-services/MetricsExporterServi
1616
import { ExternalConsensusService } from "./ethereum-services/ExternalConsensusService";
1717
import { ExternalExecutionService } from "./ethereum-services/ExternalExecutionService";
1818
import { CustomService } from "./ethereum-services/CustomService";
19-
import { LssEjectorService } from "./ethereum-services/LssEjectorService";
19+
import { LssEjectorService, stakingContractAddresses } from "./ethereum-services/LssEjectorService";
2020
import { ConfigManager } from "./ConfigManager";
2121
import YAML from "yaml";
2222
// import { file } from "jszip";
@@ -1300,22 +1300,37 @@ export class ServiceManager {
13001300
isString = true;
13011301
command = command.replaceAll(/\n/gm, "").replaceAll(/\s\s+/gm, " ").split(" ");
13021302
}
1303+
if (newNetwork === 'stratis') {
1304+
newNetwork = 'mainnet'
1305+
}
13031306
if (service.service === "FlashbotsMevBoostService") {
13041307
command = service.entrypoint;
1305-
let index = command.findIndex((c) => /^-(stratis|auroria$)/.test(c));
1308+
let index = command.findIndex((c) => /^-(mainnet|stratis|auroria$)/.test(c));
13061309
command[index] = "-" + newNetwork;
13071310
index = command.findIndex((c) => c === "-relays") + 1;
13081311
command[index] = '""';
13091312
} else if (service.service === "PrysmBeaconService") {
1310-
let index = command.findIndex((c) => /--(stratis|auroria)/.test(c));
1311-
command[index] = "--" + newNetwork;
1313+
let networkIndex = command.findIndex((c) => /--(mainnet|stratis|auroria)/.test(c));
1314+
if (networkIndex !== -1) {
1315+
command[networkIndex] = "--" + newNetwork;
1316+
} else {
1317+
command.push(`--${newNetwork}`)
1318+
}
1319+
1320+
const checkpointSyncIndex = command.findIndex(c => /--checkpoint-sync-url/.test(c))
1321+
if (checkpointSyncIndex !== -1) {
1322+
command[checkpointSyncIndex] = `--checkpoint-sync-url=${checkpointSyncUrls[newNetwork === 'mainnet' ? 'stratis' : newNetwork]}`
1323+
}
1324+
} else if (service.service === 'LssEjectorService') {
1325+
const index = command.findIndex(c => /--staking_address/.test(c))
1326+
command[index] = `--staking_address=${stakingContractAddresses[newNetwork === 'mainnet' ? 'stratis' : newNetwork]}`
13121327
} else {
1313-
command = command.map((c) => {
1314-
if (/stratis|auroria/.test(c)) {
1315-
c = c.replace(/stratis|auroria/, newNetwork);
1316-
}
1317-
return c;
1318-
});
1328+
let networkIndex = command.findIndex((c) => /--(mainnet|stratis|auroria)/.test(c));
1329+
if (networkIndex !== -1) {
1330+
command[networkIndex] = "--" + newNetwork;
1331+
} else {
1332+
command.push(`--${newNetwork}`)
1333+
}
13191334
}
13201335
if (isString) return command.join(" ").trim();
13211336
return command;
@@ -1332,6 +1347,15 @@ export class ServiceManager {
13321347
service.network = newNetwork;
13331348
}
13341349
await this.createKeystores(services);
1350+
services.sort((a, b) => {
1351+
if (a.service === 'GethService' || b.service === 'LssEjectorService') {
1352+
return -1
1353+
} else if (b.service === 'GethService' || a.service === 'LssEjectorService') {
1354+
return 1
1355+
}
1356+
1357+
return 0
1358+
})
13351359
await Promise.all(
13361360
services.map(async (service) => {
13371361
await this.nodeConnection.writeServiceConfiguration(service.buildConfiguration());

launcher/src/backend/ValidatorAccountManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class ValidatorAccountManager {
107107
await this.nodeConnection.sshService.exec(`chown 2000:2000 ${passwords_path}/wallet-password`);
108108
//Prysm - Create wallet for account(s)
109109
await this.nodeConnection.sshService.exec(
110-
`docker exec stereum-${client.id} /app/cmd/validator/validator wallet create --wallet-dir=/opt/app/data/wallets --wallet-password-file=/opt/app/data/passwords/wallet-password --accept-terms-of-use --keymanager-kind=direct --auroria`
110+
`docker exec stereum-${client.id} /app/cmd/validator/validator wallet create --wallet-dir=/opt/app/data/wallets --wallet-password-file=/opt/app/data/passwords/wallet-password --accept-terms-of-use --keymanager-kind=direct`
111111
);
112112

113113
await this.nodeConnection.sshService.exec(`chown -R 2000:2000 ${wallet_path}`);

launcher/src/backend/ethereum-services/GethService.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export class GethService extends NodeService {
3535
"--syncmode=full",
3636
]
3737

38-
if (network !== 'stratis') {
38+
if (network == 'stratis') {
39+
command.unshift('--mainnet')
40+
} else {
3941
command.unshift(`--${network}`)
4042
}
4143

launcher/src/backend/ethereum-services/LssEjectorService.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { NodeService } from "./NodeService";
22
import { ServiceVolume } from "./ServiceVolume";
33

4+
export const stakingContractAddresses = {
5+
stratis: '0x16CFc478175C222a1eC558baAE290593f175514F',
6+
auroria: '0x0504D06711d02E6275e1724529a801441088f9f4',
7+
}
8+
49
export class LssEjectorService extends NodeService {
510
static buildByUserInput(network, executionClients, consensusClients, otherServices) {
611
const service = new LssEjectorService();
@@ -16,8 +21,8 @@ export class LssEjectorService extends NodeService {
1621
})
1722
.join();
1823

19-
const allAccountsKeystoreDir = '/config/all-accounts.keystore.json'
20-
const walletPasswordDir = '/config/wallet-password'
24+
const allAccountsKeystoreDir = '/config/wallets'
25+
const walletPasswordDir = '/config/passwords'
2126

2227
const validatorService = otherServices.find(s => s.service.includes('PrysmValidator'))
2328

@@ -29,15 +34,10 @@ export class LssEjectorService extends NodeService {
2934
).destinationPath
3035

3136
const volumes = [
32-
new ServiceVolume(`${walletsDir}/direct/accounts/all-accounts.keystore.json`, allAccountsKeystoreDir, 'ro'),
33-
new ServiceVolume(`${passwordsDir}/wallet-password`, walletPasswordDir, 'ro'),
37+
new ServiceVolume(walletsDir, allAccountsKeystoreDir, 'ro'),
38+
new ServiceVolume(passwordsDir, walletPasswordDir, 'ro'),
3439
]
3540

36-
let stakingContractAddress = '0x16CFc478175C222a1eC558baAE290593f175514F'
37-
if (network === 'auroria') {
38-
stakingContractAddress = '0x0504D06711d02E6275e1724529a801441088f9f4'
39-
}
40-
4141
service.init(
4242
"LssEjectorService", //service
4343
service.id, // id
@@ -49,9 +49,9 @@ export class LssEjectorService extends NodeService {
4949
'--all_accounts_file',
5050
`--consensus_endpoint=${consensusEndpoint}`,
5151
`--execution_endpoint=${executionEndpoint}`,
52-
`--keys_dir=${allAccountsKeystoreDir}`,
53-
`--keystore_password_file=${walletPasswordDir}`,
54-
`--staking_address=${stakingContractAddress}`
52+
`--keys_dir=${allAccountsKeystoreDir}/direct/accounts/all-accounts.keystore.json`,
53+
`--keystore_password_file=${walletPasswordDir}/wallet-password`,
54+
`--staking_address=${stakingContractAddresses[network]}`
5555
], // command
5656
["lss-ejector"], // entrypoint
5757
null, // env

launcher/src/backend/ethereum-services/PrysmBeaconService.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { NodeService } from "./NodeService.js";
22
import { ServicePortDefinition } from "./SerivcePortDefinition.js";
33
import { ServiceVolume } from "./ServiceVolume.js";
44

5+
export const checkpointSyncUrls = {
6+
stratis: 'https://checkpoint.stratisevm.com/',
7+
auroria: 'https://auroria.checkpoint.stratisevm.com/',
8+
}
9+
510
export class PrysmBeaconService extends NodeService {
611
static buildByUserInput(network, ports, dir, executionClients, mevboost, checkpointURL) {
712
const service = new PrysmBeaconService();
@@ -68,7 +73,9 @@ export class PrysmBeaconService extends NodeService {
6873
mevboost //mevboost
6974
);
7075

71-
if (network !== 'stratis') {
76+
if (network === 'stratis') {
77+
service.command.push(`--mainnet`)
78+
} else {
7279
service.command.push(`--${network}`)
7380
}
7481

launcher/src/backend/ethereum-services/PrysmValidatorService.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ export class PrysmValidatorService extends NodeService {
6969
consensusClients //consensusClients
7070
);
7171

72-
if (network !== 'stratis') {
72+
if (network === 'stratis') {
73+
service.command.push(`--mainnet`)
74+
} else {
7375
service.command.push(`--${network}`)
7476
}
7577

0 commit comments

Comments
 (0)