Skip to content

Commit

Permalink
feat: node package level config (#300)
Browse files Browse the repository at this point in the history
* check-in: node package level settings for add node flow. merge config method with tests
* feat: hide node settings from users hideFromUserAfterStart
* feat: use node package settings from add node flow in init command. fix nodes network configs
  • Loading branch information
jgresham authored Oct 4, 2023
1 parent dad6b6f commit 82a3169
Show file tree
Hide file tree
Showing 40 changed files with 15,695 additions and 218 deletions.
213 changes: 213 additions & 0 deletions src/__tests__/node/mergeConfig.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
import { NodePackageSpecification } from '../../common/nodeSpec';
import { mergePackageAndClientConfigValues } from '../../renderer/Presentational/AddNodeConfiguration/mergePackageAndClientConfigValues';

const nodePackageSpec = {
specId: 'ethereum',
version: '1.0.0',
displayName: 'Ethereum',
displayTagline: 'Non-Validating Node - Ethereum',
execution: {
executionTypes: ['nodePackage'],
defaultExecutionType: 'nodePackage',
services: [
{
serviceId: 'executionClient',
name: 'Execution Client',
nodeOptions: ['nethermind', 'besu', 'geth', 'reth'],
required: true,
requiresCommonJwtSecret: true,
},
{
serviceId: 'consensusClient',
name: 'Consensus Client',
nodeOptions: [
'lodestar-beacon',
'teku-beacon',
'prysm-beacon',
'lighthouse-beacon',
'nimbus-beacon',
],
required: true,
requiresCommonJwtSecret: true,
},
],
},
category: 'L1',
rpcTranslation: 'eth-l1',
systemRequirements: {
documentationUrl: 'https://geth.ethereum.org/docs/interface/hardware',
cpu: {
cores: 4,
},
memory: {
minSizeGBs: 16,
},
storage: {
minSizeGBs: 1600,
ssdRequired: true,
},
internet: {
minDownloadSpeedMbps: 25,
minUploadSpeedMbps: 10,
},
docker: {
required: true,
},
},
configTranslation: {
dataDir: {
displayName: 'Node data is stored in this folder',
cliConfigPrefix: '--datadir ',
defaultValue: '~/.ethereum',
uiControl: {
type: 'filePath',
serviceConfigs: {
services: [
{
serviceId: 'executionClient',
configKey: 'dataDir',
},
{
serviceId: 'consensusClient',
configKey: 'dataDir',
},
],
},
},
infoDescription:
'Data directory for the databases and keystore (default: "~/.ethereum")',
},
network: {
displayName: 'Network (Ethereum node)',
addNodeFlow: 'required',
defaultValue: 'Mainnet',
hideFromUserAfterStart: true,
uiControl: {
type: 'select/single',
controlTranslations: [
{
value: 'Mainnet',
config: 'unused in nodespec',
serviceConfigs: {
services: [
{
serviceId: 'executionClient',
configValues: {
network: 'Mainnet',
},
},
{
serviceId: 'consensusClient',
configValues: {
network: 'Mainnet',
},
},
],
},
},
{
value: 'Sepolia',
config: 'unused in nodespec',
serviceConfigs: {
services: [
{
serviceId: 'executionClient',
configValues: {
network: 'Sepolia',
},
},
{
serviceId: 'consensusClient',
configValues: {
network: 'Sepolia',
},
},
],
},
},
],
},
documentation:
'https://ethereum.org/en/developers/docs/networks/#public-networks',
},
},
iconUrl: 'https://ethereum.png',
addNodeDescription:
'Running a full etherum node is a two part story. Choosing minority clients are important for the health of the network.',
description:
"An Ethereum node holds a copy of the Ethereum blockchain and verifies the validity of every block, keeps it up-to-date with new blocks and thelps others to download and update their own copies of the chain. In the case of Ethereum a node consists of two parts: the execution client and the consensus client. These two clients work together to verify Ethereum's state. The execution client listens to new transactions broadcasted in the network, executes them in EVM, and holds the latest state and database of all current Ethereum data. The consensus client runs the Proof-of-Stake consensus algorithm, which enables the network to achieve agreement based on validated data from the execution client. A non-validating node does not get financial rewards but there are many benefits of running a node for any Ethereum user to consider, including privacy, security, reduced reliance on third-party servers, censorship resistance and improved health and decentralization of the network.",
} as NodePackageSpecification;
const data = {
nodePackageSpec,
nodePackageConfigValues: {
network: 'Sepolia',
},
clientConfigValues: {},
serviceId: 'executionClient',
};

describe('Testing merge package and client config values', () => {
it('Successfully merges a single network select value with no client values', async () => {
const result1 = mergePackageAndClientConfigValues(data);

expect(result1).toEqual({ network: 'Sepolia' });
});
it('Successfully merges a single text value with no client values', async () => {
const result1 = mergePackageAndClientConfigValues({
...data,
nodePackageConfigValues: {
dataDir: '/test/dir',
},
});

expect(result1).toEqual({ dataDir: '/test/dir' });
});

it('Successfully merges a single network select value with other client values', async () => {
const result1 = mergePackageAndClientConfigValues({
...data,
clientConfigValues: { someotherthing: 'thin1' },
});

expect(result1).toEqual({ network: 'Sepolia', someotherthing: 'thin1' });
});
it('Successfully merges a single text value with other client values', async () => {
const result1 = mergePackageAndClientConfigValues({
...data,
nodePackageConfigValues: {
dataDir: '/test/dir',
},
clientConfigValues: {
someotherthing: 'thin1',
},
});

expect(result1).toEqual({ dataDir: '/test/dir', someotherthing: 'thin1' });
});

it('Successfully merges a single network select value that overrides a client value', async () => {
const result1 = mergePackageAndClientConfigValues({
...data,
clientConfigValues: {
network: 'clientNetworkHowdThisHappen',
someotherthing: 'thin1',
},
});

expect(result1).toEqual({ network: 'Sepolia', someotherthing: 'thin1' });
});
it('Successfully merges a single text value that overrides a client value', async () => {
const result1 = mergePackageAndClientConfigValues({
...data,
nodePackageConfigValues: {
dataDir: '/test/dir',
},
clientConfigValues: {
dataDir: '/other/client/dir/howd/this/happen',
someotherthing: 'thin1',
},
});

expect(result1).toEqual({ dataDir: '/test/dir', someotherthing: 'thin1' });
});
});
20 changes: 9 additions & 11 deletions src/common/NodeSpecs/arbitrum/arbitrum-v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"execution": {
"executionTypes": ["nodePackage"],
"defaultExecutionType": "nodePackage",
"services" : [{
"serviceId": "executionClient",
"name" : "Execution Client",
"nodeOptions": ["nitro"],
"required": true
}]
"services": [
{
"serviceId": "executionClient",
"name": "Execution Client",
"nodeOptions": ["nitro"],
"required": true
}
]
},
"category": "Ethereum/L2",
"rpcTranslation": "eth-l1",
Expand Down Expand Up @@ -46,17 +48,13 @@
"infoDescription": "Data directory for the databases and keystore (default: \"~/.ethereum\")"
},
"network": {
"displayName": "mainnet or a testnet",
"displayName": "Network",
"uiControl": {
"type": "select/single",
"controlTranslations": [
{
"value": "Mainnet",
"config": "--network mainnet"
},
{
"value": "Testnet",
"config": "--network testnet"
}
]
},
Expand Down
94 changes: 67 additions & 27 deletions src/common/NodeSpecs/base/base-v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,30 @@
"displayName": "Base",
"execution": {
"executionTypes": ["nodePackage"],
"services" : [{
"serviceId": "executionClient",
"name" : "Execution Client",
"nodeOptions": ["op-geth"],
"required": true,
"requiresCommonJwtSecret": true,
"requiresFiles" : true
}, {
"serviceId": "consensusClient",
"name" : "Consensus Client",
"nodeOptions": ["op-node"],
"required": true,
"requiresCommonJwtSecret": true,
"requiresFiles" : true
}],
"dependencies": [{
"name" : "Ethereum node",
"specId": "ethereum"
}]
"services": [
{
"serviceId": "executionClient",
"name": "Execution Client",
"nodeOptions": ["op-geth"],
"required": true,
"requiresCommonJwtSecret": true,
"requiresFiles": true
},
{
"serviceId": "consensusClient",
"name": "Consensus Client",
"nodeOptions": ["op-node"],
"required": true,
"requiresCommonJwtSecret": true,
"requiresFiles": true
}
],
"dependencies": [
{
"name": "Ethereum node",
"specId": "ethereum"
}
]
},
"category": "Ethereum/L2",
"rpcTranslation": "op-node",
Expand All @@ -45,28 +50,63 @@
},
"configTranslation": {
"network": {
"displayName": "mainnet or a testnet",
"displayName": "Network",
"defaultValue": "Mainnet",
"addNodeFlow": "required",
"uiControl": {
"type": "select/single",
"controlTranslations": [
{
"value": "Mainnet",
"config": "--network mainnet"
"config": "unused in nodespec",
"serviceConfigs": {
"services": [
{
"serviceId": "executionClient",
"configValues": {
"genesisFile": "genesis-l2.json",
"rollupSequencerHttpEndpoint": "https://mainnet-sequencer.base.org"
}
},
{
"serviceId": "consensusClient",
"configValues": {
"rollupConfigFile": "rollup.json"
}
}
]
}
},
{
"value": "Testnet",
"config": "--network testnet"
"value": "Sepolia",
"config": "unused in nodespec",
"serviceConfigs": {
"services": [
{
"serviceId": "executionClient",
"configValues": {
"rollupConfigFile": "sepolia-genesis-l2.json",
"rollupSequencerHttpEndpoint": "https://sepolia-sequencer.base.org/"
}
},
{
"serviceId": "consensusClient",
"configValues": {
"rollupConfigFile": "sepolia-rollup.json"
}
}
]
}
}
]
},
"defaultValue": "Disabled",
"documentation": "https://geth.ethereum.org/docs/rpc/server"
"documentation": "https://docs.base.org/network-information/"
}
},
"iconUrl": "https://ethereum.png",
"addNodeDescription" : "Decentralization and collaboration are critical for the longer-term success of Base and scaling Ethereum. That’s why we are working with OP Labs and the Optimism Collective on a plan to scale Ethereum in a decentralized way.",
"addNodeDescription": "Decentralization and collaboration are critical for the longer-term success of Base and scaling Ethereum. That’s why we are working with OP Labs and the Optimism Collective on a plan to scale Ethereum in a decentralized way.",
"description": "Base is a secure, low-cost, developer-friendly Ethereum L2 built to bring the next billion users onchain. It's built on Optimism’s open-source OP Stack.",
"documentation" : {
"documentation": {
"default": "https://docs.base.org/guides/run-a-base-node/"
}
}
6 changes: 3 additions & 3 deletions src/common/NodeSpecs/besu/besu-v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@
"documentation": "https://besu.hyperledger.org/public-networks/reference/cli/options#data-path"
},
"network": {
"displayName": "Network (Besu)",
"displayName": "Network",
"cliConfigPrefix": "--network=",
"defaultValue": "Mainnet",
"hideFromUserAfterStart": true,
"uiControl": {
"type": "select/single",
"controlTranslations": [
Expand All @@ -79,8 +80,7 @@
"config": "sepolia"
}
]
},
"addNodeFlow": "advanced"
}
},
"syncMode": {
"displayName": "Node synchronization mode",
Expand Down
Loading

0 comments on commit 82a3169

Please sign in to comment.