Skip to content

feat: add admin system #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 18, 2024
1 change: 1 addition & 0 deletions docker/Dockerfile.gen-configs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ COPY ./docker/templates/coordinator-config.json /contracts/docker/templates/coor
COPY ./docker/templates/genesis.json /contracts/docker/templates/genesis.json
COPY ./docker/templates/rollup-config.json /contracts/docker/templates/rollup-config.json
COPY ./docker/templates/rollup-explorer-backend-config.json /contracts/docker/templates/rollup-explorer-backend-config.json
COPY ./docker/templates/admin-system-backend-config.json /contracts/docker/templates/admin-system-backend-config.json

COPY ./docker/scripts/gen-configs.sh /contracts/docker/scripts/gen-configs.sh

Expand Down
1 change: 1 addition & 0 deletions docker/config-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ L2_GAS_ORACLE_SENDER_ADDR = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"

[db]

ADMIN_SYSTEM_BACKEND_DB_CONNECTION_STRING = "postgresql://postgres:qwerty12345@postgresql:5432/scroll_admin_system?sslmode=disable"
BLOCKSCOUT_DB_CONNECTION_STRING = "postgres://postgres:qwerty12345@postgresql:5432/blockscout"
BRIDGE_HISTORY_DB_CONNECTION_STRING = "postgres://postgres:qwerty12345@postgresql:5432/scroll?sslmode=disable"
CHAIN_MONITOR_DB_CONNECTION_STRING = "postgres://postgres:qwerty12345@postgresql:5432/scroll?sslmode=disable"
Expand Down
4 changes: 4 additions & 0 deletions docker/scripts/gen-configs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ forge script scripts/deterministic/GenerateConfigs.s.sol:GenerateFrontendConfig
echo ""
echo "generating rollup-explorer-backend-config.json"
forge script scripts/deterministic/GenerateConfigs.s.sol:GenerateRollupExplorerBackendConfig || exit 1

echo ""
echo "generating admin-system-backend-config.json"
forge script scripts/deterministic/GenerateConfigs.s.sol:GenerateAdminSystemBackendConfig || exit 1
59 changes: 59 additions & 0 deletions docker/templates/admin-system-backend-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"db_config": {
"driver_name": "postgres",
"dsn": "",
"max_open_connections": 200,
"max_idel_connections": 20
},
"read_only_db_config": {
"driver_name": "postgres",
"dsn": "",
"max_open_connections": 200,
"max_idel_connections": 20
},
"db_mappings": {
"default": "read_only",
"batch_chunk": "read_only",
"prover_block_list": "read_write"
},
"auth_db_config": {
"driver_name": "postgres",
"dsn": "",
"max_open_connections": 200,
"max_idel_connections": 20
},
"authentication": {
"mode": "skip",
"jwt": {
"secret": "scroll admin system secret key",
"token_expire_seconds": 3600
},
"ldap": {
"endpoint": "ldap://xxx.xxx.com:389",
"bind_dn": "",
"bind_password": "",
"search_base_dn_list": [""],
"search_filter": "(mail=%s)"
},
"otp": {
"issuer": "ScrollAdmin(Dev)",
"enabled": true,
"admin_only": true
}
},
"authorization": {
"casbin": {
"model_path": "conf/model.conf",
"policy_path": "conf/policy.csv"
}
},
"prometheus": {
"endpoint": "https://xxx.xxx.com/prometheus",
"user": "",
"password": ""
},
"admin": {
"prover_becomes_offline_since_last_get_task_seconds": 3600,
"prover_becomes_idle_since_last_task_assigned_seconds": 1800
}
}
4 changes: 3 additions & 1 deletion scripts/deterministic/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ string constant CHAIN_MONITOR_CONFIG_TEMPLATE_PATH = "./docker/templates/chain-m
string constant BRIDGE_HISTORY_CONFIG_TEMPLATE_PATH = "./docker/templates/bridge-history-config.json";
string constant BALANCE_CHECKER_CONFIG_TEMPLATE_PATH = "./docker/templates/balance-checker-config.json";
string constant ROLLUP_EXPLORER_BACKEND_CONFIG_TEMPLATE_PATH = "./docker/templates/rollup-explorer-backend-config.json";
string constant ADMIN_SYSTEM_BACKEND_CONFIG_TEMPLATE_PATH = "./docker/templates/admin-system-backend-config.json";

// input files
string constant CONFIG_PATH = "./volume/config.toml";
Expand All @@ -35,6 +36,7 @@ string constant BRIDGE_HISTORY_CONFIG_PATH = "./volume/bridge-history-config.jso
string constant BALANCE_CHECKER_CONFIG_PATH = "./volume/balance-checker-config.json";
string constant FRONTEND_ENV_PATH = "./volume/frontend-config";
string constant ROLLUP_EXPLORER_BACKEND_CONFIG_PATH = "./volume/rollup-explorer-backend-config.json";
string constant ADMIN_SYSTEM_BACKEND_CONFIG_PATH = "./volume/admin-system-backend-config.json";

// plonk verifier configs
bytes32 constant V4_VERIFIER_DIGEST = 0x0a1904dbfff4614fb090b4b3864af4874f12680c32f07889e9ede8665097e5ec;
bytes32 constant V4_VERIFIER_DIGEST = 0x0a1904dbfff4614fb090b4b3864af4874f12680c32f07889e9ede8665097e5ec;
30 changes: 29 additions & 1 deletion scripts/deterministic/GenerateConfigs.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.8.24;

import {BALANCE_CHECKER_CONFIG_PATH, BALANCE_CHECKER_CONFIG_TEMPLATE_PATH, BRIDGE_HISTORY_CONFIG_PATH, BRIDGE_HISTORY_CONFIG_TEMPLATE_PATH, CHAIN_MONITOR_CONFIG_PATH, CHAIN_MONITOR_CONFIG_TEMPLATE_PATH, COORDINATOR_CONFIG_PATH, COORDINATOR_CONFIG_TEMPLATE_PATH, FRONTEND_ENV_PATH, ROLLUP_CONFIG_PATH, ROLLUP_CONFIG_TEMPLATE_PATH, ROLLUP_EXPLORER_BACKEND_CONFIG_PATH, ROLLUP_EXPLORER_BACKEND_CONFIG_TEMPLATE_PATH} from "./Constants.sol";
import {ADMIN_SYSTEM_BACKEND_CONFIG_PATH, ADMIN_SYSTEM_BACKEND_CONFIG_TEMPLATE_PATH, BALANCE_CHECKER_CONFIG_PATH, BALANCE_CHECKER_CONFIG_TEMPLATE_PATH, BRIDGE_HISTORY_CONFIG_PATH, BRIDGE_HISTORY_CONFIG_TEMPLATE_PATH, CHAIN_MONITOR_CONFIG_PATH, CHAIN_MONITOR_CONFIG_TEMPLATE_PATH, COORDINATOR_CONFIG_PATH, COORDINATOR_CONFIG_TEMPLATE_PATH, FRONTEND_ENV_PATH, ROLLUP_CONFIG_PATH, ROLLUP_CONFIG_TEMPLATE_PATH, ROLLUP_EXPLORER_BACKEND_CONFIG_PATH, ROLLUP_EXPLORER_BACKEND_CONFIG_TEMPLATE_PATH} from "./Constants.sol";
import {DeployScroll} from "./DeployScroll.s.sol";
import {DeterministicDeployment} from "./DeterministicDeployment.sol";

Expand Down Expand Up @@ -353,3 +353,31 @@ contract GenerateRollupExplorerBackendConfig is DeployScroll {
vm.writeJson(ROLLUP_EXPLORER_BACKEND_DB_CONNECTION_STRING, ROLLUP_EXPLORER_BACKEND_CONFIG_PATH, ".db_url");
}
}

contract GenerateAdminSystemBackendConfig is DeployScroll {
/***************
* Entry point *
***************/

function run() public {
DeterministicDeployment.initialize(ScriptMode.VerifyConfig);
predictAllContracts();

generateAdminSystemBackendConfig();
}

/*********************
* Private functions *
*********************/

// prettier-ignore
function generateAdminSystemBackendConfig() private {
// initialize template file
if (vm.exists(ADMIN_SYSTEM_BACKEND_CONFIG_PATH)) {
vm.removeFile(ADMIN_SYSTEM_BACKEND_CONFIG_PATH);
}

string memory template = vm.readFile(ADMIN_SYSTEM_BACKEND_CONFIG_TEMPLATE_PATH);
vm.writeFile(ADMIN_SYSTEM_BACKEND_CONFIG_PATH, template);
}
}
Loading