Skip to content
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

feat: op-nethermind. chainId added to support many networks #441

Merged
merged 1 commit into from
Dec 5, 2023
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
143 changes: 143 additions & 0 deletions src/__tests__/node/mergeConfigOpNode.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import { NodePackageSpecification } from '../../common/nodeSpec';
import { mergePackageAndClientConfigValues } from '../../renderer/Presentational/AddNodeConfiguration/mergePackageAndClientConfigValues';

const nodePackageSpec = {
specId: 'optimism',
version: '1.0.0',
displayName: 'Optimism',
displayTagline: 'Ethereum L2 - Optimism',
execution: {
executionTypes: ['nodePackage'],
services: [
{
serviceId: 'executionClient',
name: 'Execution Client',
nodeOptions: ['op-geth', 'nethermind'],
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: 'eth-l2-op-stack',
systemRequirements: {
documentationUrl: 'https://geth.ethereum.org/docs/interface/hardware',
cpu: {
cores: 4,
},
memory: {
minSizeGBs: 16,
},
storage: {
minSizeGBs: 200,
ssdRequired: true,
},
internet: {
minDownloadSpeedMbps: 25,
minUploadSpeedMbps: 10,
},
},
configTranslation: {
network: {
displayName: 'Network',
defaultValue: 'Sepolia',
addNodeFlow: 'required',
uiControl: {
type: 'select/single',
controlTranslations: [
{
value: 'Sepolia',
config: 'unused in nodespec',
serviceConfigs: {
services: [
{
serviceId: 'executionClient',
configValues: {
genesisFile: 'sepolia-genesis-l2.json',
rollupSequencerHttpEndpoint:
'https://sepolia-sequencer.optimism.io/',
chainId: '11155420',
},
},
{
serviceId: 'consensusClient',
configValues: {
network: 'Sepolia',
},
},
],
},
},
{
value: 'Mainnet',
config: 'unused in nodespec',
serviceConfigs: {
services: [
{
serviceId: 'executionClient',
configValues: {
genesisFile: 'genesis-l2.json',
rollupSequencerHttpEndpoint:
'https://sequencer.optimism.io/',
chainId: '10',
},
},
{
serviceId: 'consensusClient',
configValues: {
network: 'Mainnet',
},
},
],
},
},
],
},
infoDescription: 'Mainnet support coming soon',
},
},
iconUrl: 'https://ethereum.png',
addNodeDescription:
'OP Mainnet is a fast, stable, and scalable L2 blockchain built by Ethereum developers, for Ethereum developers.',
description:
"Optimism 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: {
default: 'https://docs.optimism.org/guides/run-a-optimism-node/',
},
} as NodePackageSpecification;

const data = {
nodePackageSpec,
nodePackageConfigValues: {
network: 'Mainnet',
},
clientConfigValues: {},
serviceId: 'executionClient',
};

describe('Testing merge package and client config values', () => {
it('Successfully merges config with chainId by excluding network from the results', async () => {
const result1 = mergePackageAndClientConfigValues(data);

expect(result1).toEqual({
genesisFile: 'genesis-l2.json',
rollupSequencerHttpEndpoint: 'https://sequencer.optimism.io/',
chainId: '10',
});
});
});
12 changes: 8 additions & 4 deletions src/common/NodeSpecs/base/base-v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
"serviceId": "executionClient",
"name": "Execution Client",
"nodeOptions": ["op-geth"],
"nodeOptions": ["nethermind", "op-geth"],
"required": true,
"requiresCommonJwtSecret": true,
"requiresFiles": true
Expand All @@ -30,7 +30,7 @@
]
},
"category": "Ethereum/L2",
"rpcTranslation": "op-node",
"rpcTranslation": "eth-l2-op-stack",
"systemRequirements": {
"documentationUrl": "https://geth.ethereum.org/docs/interface/hardware",
"cpu": {
Expand Down Expand Up @@ -65,7 +65,9 @@
"serviceId": "executionClient",
"configValues": {
"genesisFile": "genesis-l2.json",
"rollupSequencerHttpEndpoint": "https://mainnet-sequencer.base.org"
"rollupSequencerHttpEndpoint": "https://mainnet-sequencer.base.org",
"chainId": "8453",
"enginePort": "8553"
}
},
{
Expand All @@ -86,7 +88,9 @@
"serviceId": "executionClient",
"configValues": {
"genesisFile": "sepolia-genesis-l2.json",
"rollupSequencerHttpEndpoint": "https://sepolia-sequencer.base.org/"
"rollupSequencerHttpEndpoint": "https://sepolia-sequencer.base.org/",
"chainId": "84532",
"enginePort": "8553"
}
},
{
Expand Down
30 changes: 30 additions & 0 deletions src/common/NodeSpecs/nethermind/nethermind-v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,36 @@
]
}
},
"chainId": {
"displayName": "Chain ID (Network)",
"cliConfigPrefix": "--config ",
"hideFromUserAfterStart": true,
"uiControl": {
"type": "select/single",
"controlTranslations": [
{
"value": "1",
"config": "mainnet"
},
{
"value": "17000",
"config": "holesky"
},
{
"value": "11155111",
"config": "sepolia"
},
{
"value": "10",
"config": "op-mainnet"
},
{
"value": "8453",
"config": "base-mainnet"
}
]
}
},
"http": {
"displayName": "RPC HTTP connections",
"category": "RPC APIs",
Expand Down
2 changes: 1 addition & 1 deletion src/common/NodeSpecs/op-geth/op-geth-v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"forcedRawNodeInput": "--http.addr 0.0.0.0 --authrpc.addr 0.0.0.0 --authrpc.jwtsecret /root/.ethereum/jwtsecret --ipcdisable"
}
},
"imageName": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:v1.101304.0"
"imageName": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:v1.101304.1"
},
"category": "L2/ExecutionClient",
"rpcTranslation": "eth-l2",
Expand Down
2 changes: 1 addition & 1 deletion src/common/NodeSpecs/op-node/op-node-v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"forcedRawNodeInput": "op-node --rpc.addr 0.0.0.0 --l2.jwt-secret /root/.ethereum/jwtsecret"
}
},
"imageName": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:v1.3.0"
"imageName": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:v1.3.1"
},
"category": "L2/ConsensusClient",
"rpcTranslation": "eth-l2-consensus",
Expand Down
50 changes: 28 additions & 22 deletions src/common/NodeSpecs/optimism/optimism-v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{
"serviceId": "executionClient",
"name": "Execution Client",
"nodeOptions": ["op-geth"],
"nodeOptions": ["nethermind", "op-geth"],
"required": true,
"requiresCommonJwtSecret": true,
"requiresFiles": true
Expand All @@ -31,7 +31,7 @@
]
},
"category": "Ethereum/L2",
"rpcTranslation": "op-node",
"rpcTranslation": "eth-l2-op-stack",
"systemRequirements": {
"documentationUrl": "https://geth.ethereum.org/docs/interface/hardware",
"cpu": {
Expand All @@ -52,50 +52,56 @@
"configTranslation": {
"network": {
"displayName": "Network",
"defaultValue": "Sepolia",
"defaultValue": "Mainnet",
"addNodeFlow": "required",
"uiControl": {
"type": "select/single",
"controlTranslations": [
{
"value": "Sepolia",
"value": "Mainnet",
"config": "unused in nodespec",
"serviceConfigs": {
"services": [
{
"serviceId": "executionClient",
"configValues": {
"genesisFile": "sepolia-genesis-l2.json",
"rollupSequencerHttpEndpoint": "https://sepolia-sequencer.optimism.io/"
"genesisFile": "genesis-l2.json",
"rollupSequencerHttpEndpoint": "https://sequencer.optimism.io/",
"chainId": "10",
"enginePort": "8553"
}
},
{
"serviceId": "consensusClient",
"configValues": {
"network": "Sepolia"
"network": "Mainnet"
}
}
]
}
},
{
"value": "Mainnet",
"value": "Sepolia",
"config": "unused in nodespec",
"serviceConfigs": [
{
"serviceId": "executionClient",
"configValues": {
"genesisFile": "genesis-l2.json",
"rollupSequencerHttpEndpoint": "https://sequencer.optimism.io/"
}
},
{
"serviceId": "consensusClient",
"configValues": {
"network": "Mainnet"
"serviceConfigs": {
"services": [
{
"serviceId": "executionClient",
"configValues": {
"genesisFile": "sepolia-genesis-l2.json",
"rollupSequencerHttpEndpoint": "https://sepolia-sequencer.optimism.io/",
"chainId": "11155420",
"enginePort": "8553"
}
},
{
"serviceId": "consensusClient",
"configValues": {
"network": "Sepolia"
}
}
}
]
]
}
}
]
},
Expand Down
1 change: 1 addition & 0 deletions src/common/rpcTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type RpcTranslation = {
export type NiceNodeRpcTranslation =
| 'eth-l1'
| 'eth-l1-beacon'
| 'eth-l2-op-stack'
| 'eth-l2-starknet'
| 'eth-l2-arbitrum'
| 'eth-l2-consensus'
Expand Down
14 changes: 14 additions & 0 deletions src/main/podman/podman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,20 @@ export const createRunCommand = (node: Node): string => {
},
);
}

// Special case: "chainId" takes priority over "network"
// chainId is disambiguous and allows a client like Nethermind) to
// easily work for many chains and testnets. network="mainnet" is very ambiguous.
// Only exclude node specification includes chainId
const excludeConfigKeys = ['dataDir', ...initCommandConfigKeys];
if (
node.config.configValuesMap.chainId &&
node.spec.configTranslation?.chainId
) {
console.log('EXCLUDING NETWORK!: ', node.spec.specId);
excludeConfigKeys.push('network');
}

const cliConfigInput = buildCliConfig({
configValuesMap: node.config.configValuesMap,
configTranslationMap: node.spec.configTranslation,
Expand Down
Loading