diff --git a/infrastructure/charts/mev-commit-erigon/Chart.yaml b/infrastructure/charts/mev-commit-erigon/Chart.yaml index d347fd51f..87ff4dc8d 100644 --- a/infrastructure/charts/mev-commit-erigon/Chart.yaml +++ b/infrastructure/charts/mev-commit-erigon/Chart.yaml @@ -4,4 +4,3 @@ description: A Helm chart for deploying MEV Commit chain with Erigon blockchain type: application version: 0.1.0 appVersion: "v3.0.7" - diff --git a/infrastructure/charts/mev-commit-erigon/scripts/create-genesis.sh b/infrastructure/charts/mev-commit-erigon/scripts/create-genesis.sh new file mode 100644 index 000000000..8aa9278ab --- /dev/null +++ b/infrastructure/charts/mev-commit-erigon/scripts/create-genesis.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +set -e + +echo "Creating genesis.json with generated accounts..." + +# Check if accounts were generated +ACCOUNTS_FILE="/shared/generated_accounts.txt" +if [ ! -f "$ACCOUNTS_FILE" ]; then + echo "Error: No generated accounts found at $ACCOUNTS_FILE" + exit 1 +fi + +# Read the genesis template +GENESIS_TEMPLATE="/genesis-template/genesis-template.json" +if [ ! -f "$GENESIS_TEMPLATE" ]; then + echo "Error: Genesis template not found at $GENESIS_TEMPLATE" + exit 1 +fi + +# Copy template to working location +cp "$GENESIS_TEMPLATE" /shared/genesis.json + +echo "Adding generated accounts to genesis..." + +# Install jq for JSON manipulation +apk add --no-cache jq + +# Read accounts and add them to genesis +while IFS= read -r address; do + if [ -n "$address" ]; then + echo "Adding account $address with balance $ACCOUNT_BALANCE" + + # Add account to alloc section + jq --arg addr "$address" --arg balance "$ACCOUNT_BALANCE" \ + '.alloc[$addr] = {"balance": $balance}' \ + /shared/genesis.json > /shared/genesis_temp.json && \ + mv /shared/genesis_temp.json /shared/genesis.json + fi +done < "$ACCOUNTS_FILE" + +echo "Genesis file created successfully!" +echo "Genesis file location: /shared/genesis.json" + +# Show the final genesis file (optional, for debugging) +echo "Final genesis.json alloc section:" +cat /shared/genesis.json | jq '.alloc' diff --git a/infrastructure/charts/mev-commit-erigon/scripts/download-genesis.sh b/infrastructure/charts/mev-commit-erigon/scripts/download-genesis.sh new file mode 100644 index 000000000..59d247c5a --- /dev/null +++ b/infrastructure/charts/mev-commit-erigon/scripts/download-genesis.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +set -e + +echo "Checking for existing genesis file..." + +# Check if genesis file already exists +if [ -f "/shared/genesis.json" ]; then + echo "Genesis file already exists at /shared/genesis.json" + + # Validate existing file + apk add --no-cache jq + if jq . /shared/genesis.json > /dev/null 2>&1; then + echo "Existing genesis file is valid JSON. Skipping download." + exit 0 + else + echo "Warning: Existing genesis file is invalid JSON. Re-downloading..." + rm -f /shared/genesis.json + fi +fi + +echo "Downloading genesis from URL..." + +# Check if genesis URL is provided +if [ -z "$GENESIS_URL" ]; then + echo "Error: GENESIS_URL environment variable not set" + exit 1 +fi + +echo "Downloading genesis from: $GENESIS_URL" + +# Install curl and jq +apk add --no-cache curl jq + +# Download genesis file +curl -L -o /shared/genesis.json "$GENESIS_URL" + +if [ ! -f "/shared/genesis.json" ]; then + echo "Error: Failed to download genesis file" + exit 1 +fi + +echo "Genesis file downloaded successfully!" +echo "Genesis file location: /shared/genesis.json" + +# Validate JSON format +if ! jq . /shared/genesis.json > /dev/null 2>&1; then + echo "Error: Downloaded file is not valid JSON" + exit 1 +fi + +echo "Genesis file validation passed!" diff --git a/infrastructure/charts/mev-commit-erigon/scripts/generate-account.sh b/infrastructure/charts/mev-commit-erigon/scripts/generate-account.sh new file mode 100644 index 000000000..df9560d2e --- /dev/null +++ b/infrastructure/charts/mev-commit-erigon/scripts/generate-account.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +set -e + +echo "Starting account generation..." + +# Create keystore directory if it doesn't exist +mkdir -p /keystore + +# Create accounts file to store generated addresses +ACCOUNTS_FILE="/shared/generated_accounts.txt" +> "$ACCOUNTS_FILE" # Clear the file + +echo "Generating $ACCOUNT_COUNT accounts..." + +for i in $(seq 1 $ACCOUNT_COUNT); do + echo "Generating account $i of $ACCOUNT_COUNT..." + + # Generate account using geth + ACCOUNT_OUTPUT=$(geth account new \ + --keystore /keystore \ + --password /password/password.txt 2>&1) + + # Extract address from output + # Geth outputs: "Your new account is locked with a password. Please give a password. Do not forget this password. + # Your new key was generated + # Public address of the key: 0x..." + ADDRESS=$(echo "$ACCOUNT_OUTPUT" | grep -i "Public address of the key:" | awk '{print $NF}' | tr -d '\n\r') + + if [ -z "$ADDRESS" ]; then + # Fallback: try to extract from different output format + ADDRESS=$(echo "$ACCOUNT_OUTPUT" | grep -o "0x[a-fA-F0-9]\{40\}" | head -1) + fi + + if [ -z "$ADDRESS" ]; then + echo "Error: Could not extract address from geth output" + echo "Geth output was: $ACCOUNT_OUTPUT" + exit 1 + fi + + echo "Generated account: $ADDRESS" + echo "$ADDRESS" >> "$ACCOUNTS_FILE" +done + +echo "Generated $ACCOUNT_COUNT accounts successfully!" +echo "Accounts stored in: $ACCOUNTS_FILE" + +# List generated keystore files +echo "Keystore files:" +ls -la /keystore/ + +# Show generated accounts +echo "Generated account addresses:" +cat "$ACCOUNTS_FILE" diff --git a/infrastructure/charts/mev-commit-erigon/scripts/init-erigon.sh b/infrastructure/charts/mev-commit-erigon/scripts/init-erigon.sh new file mode 100644 index 000000000..af73c2c54 --- /dev/null +++ b/infrastructure/charts/mev-commit-erigon/scripts/init-erigon.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +set -e + +echo "Initializing Erigon..." + +# Check if genesis file exists +if [ ! -f "/shared/genesis.json" ]; then + echo "Error: Genesis file not found at /shared/genesis.json" + exit 1 +fi + +echo "Found genesis file at /shared/genesis.json" + +# Check if Erigon data directory already exists and is initialized +if [ -d "${ERIGON_DATADIR}/chaindata" ]; then + echo "Erigon chaindata already exists at ${ERIGON_DATADIR}/chaindata" + echo "Skipping initialization to preserve existing data" + exit 0 +fi + +echo "Initializing Erigon with genesis file..." + +# Create data directory if it doesn't exist +mkdir -p "${ERIGON_DATADIR}" + +# Initialize Erigon with genesis +erigon init \ + --datadir="${ERIGON_DATADIR}" \ + /shared/genesis.json + +if [ $? -eq 0 ]; then + echo "Erigon initialization completed successfully!" +else + echo "Error: Erigon initialization failed" + exit 1 +fi + +# List contents to verify +echo "Erigon data directory contents:" +ls -la "${ERIGON_DATADIR}/" diff --git a/infrastructure/charts/mev-commit-erigon/templates/_helpers.tpl b/infrastructure/charts/mev-commit-erigon/templates/_helpers.tpl index 65a48a37f..2515da2a4 100644 --- a/infrastructure/charts/mev-commit-erigon/templates/_helpers.tpl +++ b/infrastructure/charts/mev-commit-erigon/templates/_helpers.tpl @@ -49,3 +49,52 @@ Selector labels app.kubernetes.io/name: {{ include "erigon-snode.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} + +{{/* +Validate genesis configuration - ensure mutual exclusivity +*/}} +{{- define "erigon-snode.validateGenesis" -}} +{{- $accountGenEnabled := .Values.genesis.accountGeneration.enabled | default false }} +{{- $genesisUrlSet := .Values.genesis.url | default "" }} +{{- if and $accountGenEnabled (ne $genesisUrlSet "") }} +{{- fail "ERROR: Cannot use both genesis.accountGeneration.enabled=true AND genesis.url. Choose one method only." }} +{{- end }} +{{- if and (not $accountGenEnabled) (eq $genesisUrlSet "") }} +{{- fail "ERROR: Must configure either genesis.accountGeneration.enabled=true OR set genesis.url. One genesis method is required." }} +{{- end }} +{{- end }} + +{{/* +Validate account generation configuration +*/}} +{{- define "erigon-snode.validateAccountGeneration" -}} +{{- if .Values.genesis.accountGeneration.enabled }} +{{- if not .Values.genesis.accountGeneration.count }} +{{- fail "ERROR: genesis.accountGeneration.count is required when account generation is enabled" }} +{{- end }} +{{- if lt (.Values.genesis.accountGeneration.count | int) 1 }} +{{- fail "ERROR: genesis.accountGeneration.count must be at least 1" }} +{{- end }} +{{- if not .Values.genesis.accountGeneration.password }} +{{- fail "ERROR: genesis.accountGeneration.password is required when account generation is enabled" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Validate JWT configuration +*/}} +{{- define "erigon-snode.validateJWT" -}} +{{- if not .Values.jwt.token }} +{{- fail "ERROR: jwt.token is required" }} +{{- end }} +{{- end }} + +{{/* +Run all validations +*/}} +{{- define "erigon-snode.validate" -}} +{{- include "erigon-snode.validateGenesis" . }} +{{- include "erigon-snode.validateAccountGeneration" . }} +{{- include "erigon-snode.validateJWT" . }} +{{- end }} diff --git a/infrastructure/charts/mev-commit-erigon/templates/configmap-genesis.yaml b/infrastructure/charts/mev-commit-erigon/templates/configmap-genesis.yaml new file mode 100644 index 000000000..f76575328 --- /dev/null +++ b/infrastructure/charts/mev-commit-erigon/templates/configmap-genesis.yaml @@ -0,0 +1,77 @@ +{{- if .Values.genesis.accountGeneration.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "erigon-snode.fullname" . }}-genesis-template + labels: + {{- include "erigon-snode.labels" . | nindent 4 }} +data: + genesis-template.json: | + { + "config": { + "chainId": {{ .Values.erigon.networkId }}, + "homesteadBlock": 0, + "daoForkSupport": true, + "eip150Block": 0, + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "muirGlacierBlock": 0, + "berlinBlock": 0, + "londonBlock": 0, + "arrowGlacierBlock": 0, + "grayGlacierBlock": 0, + "shanghaiTime": 0, + "cancunTime": 0, + "pragueTime": 0, + "depositContractAddress": "0x00000000219ab540356cbb839cbe05303d7705fa", + "blobSchedule": { + "cancun": { + "target": 3, + "max": 6, + "baseFeeUpdateFraction": 3338477 + }, + "prague": { + "target": 6, + "max": 9, + "baseFeeUpdateFraction": 5007716 + } + }, + "terminalTotalDifficulty": 0 + }, + "nonce": "0x0", + "timestamp": "{{ .Values.genesis.accountGeneration.timestamp }}", + "gasLimit": "0x197dea15ed8", + "difficulty": "0x1", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "alloc": { + "00000961Ef480Eb55e80D19ad83579A64c007002": { + "balance": "0x0", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460cb5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f457600182026001905f5b5f82111560685781019083028483029004916001019190604d565b909390049250505036603814608857366101f457346101f4575f5260205ff35b34106101f457600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160df575060105b5f5b8181146101835782810160030260040181604c02815460601b8152601401816001015481526020019060020154807fffffffffffffffffffffffffffffffff00000000000000000000000000000000168252906010019060401c908160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160e1565b910180921461019557906002556101a0565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101cd57505f5b6001546002828201116101e25750505f6101e8565b01600290035b5f555f600155604c025ff35b5f5ffd" + }, + "0000bbddc7ce488642fb579f8b00f3a590007251": { + "balance": "0x0", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460d35760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f82111560685781019083028483029004916001019190604d565b9093900492505050366060146088573661019a573461019a575f5260205ff35b341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060021160e7575060025b5f5b8181146101295782810160040260040181607402815460601b815260140181600101548152602001816002015481526020019060030154905260010160e9565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd" + }, + "0x0000F90827F1C53a10cb7A02335B175320002935": { + "balance": "0x0", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604657602036036042575f35600143038111604257611fff81430311604257611fff9006545f5260205ff35b5f5ffd5b5f35611fff60014303065500" + }, + "0x00000000219ab540356cbb839cbe05303d7705fa": { + "balance": "0x0", + "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a2646970667358221220dceca8706b29e917dacf25fceef95acac8d90d765ac926663ce4096195952b6164736f6c634300060b0033" + } + }, + "number": "0x0", + "gasUsed": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "withdrawalsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", + "baseFeePerGas": "0x7", + "excessBlobGas": "0x0", + "blobGasUsed": "0x0" + } +{{- end }} diff --git a/infrastructure/charts/mev-commit-erigon/templates/configmap-init.yaml b/infrastructure/charts/mev-commit-erigon/templates/configmap-init.yaml new file mode 100644 index 000000000..704225099 --- /dev/null +++ b/infrastructure/charts/mev-commit-erigon/templates/configmap-init.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "erigon-snode.fullname" . }}-scripts + labels: + {{- include "erigon-snode.labels" . | nindent 4 }} +data: + {{- if .Values.genesis.accountGeneration.enabled }} + generate-account.sh: |- + {{- .Files.Get "scripts/generate-account.sh" | nindent 4 }} + create-genesis.sh: |- + {{- .Files.Get "scripts/create-genesis.sh" | nindent 4 }} + {{- else }} + download-genesis.sh: |- + {{- .Files.Get "scripts/download-genesis.sh" | nindent 4 }} + {{- end }} + init-erigon.sh: |- + {{- .Files.Get "scripts/init-erigon.sh" | nindent 4 }} diff --git a/infrastructure/charts/mev-commit-erigon/templates/configmap.yaml b/infrastructure/charts/mev-commit-erigon/templates/configmap.yaml deleted file mode 100644 index e002edaf0..000000000 --- a/infrastructure/charts/mev-commit-erigon/templates/configmap.yaml +++ /dev/null @@ -1,43 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "erigon-snode.fullname" . }}-scripts - labels: - {{- include "erigon-snode.labels" . | nindent 4 }} -data: - create-jwt.sh: | - #!/bin/sh - set -e - if [ -f /shared/jwt ]; then - echo "[create-jwt] JWT already exists, skipping creation" - exit 0 - fi - echo "[create-jwt] copying JWT from secret to /shared/jwt" - cp /secrets/jwt /shared/jwt - chmod 600 /shared/jwt - download-genesis.sh: | - #!/bin/sh - set -e - echo "[download-genesis] ensuring /shared permissions" - mkdir -p /shared - chmod 777 /shared - - if [ -f /shared/genesis.json ]; then - echo "[download-genesis] genesis.json already exists, skipping download" - exit 0 - fi - - echo "[download-genesis] downloading genesis.json" - wget -O /shared/genesis.json {{ .Values.genesis.url }} - init-erigon.sh: | - #!/bin/sh - set -e - - # Check if erigon has already been initialized - if [ -f {{ .Values.erigon.datadir }}/chaindata/CURRENT ] || [ -f {{ .Values.erigon.datadir }}/chaindata/LOCK ]; then - echo "[init-erigon] Erigon already initialized, skipping init" - exit 0 - fi - - echo "[init-erigon] initializing erigon with genesis.json" - erigon --datadir {{ .Values.erigon.datadir }} init /shared/genesis.json diff --git a/infrastructure/charts/mev-commit-erigon/templates/password-secret.yaml b/infrastructure/charts/mev-commit-erigon/templates/password-secret.yaml new file mode 100644 index 000000000..3f2e0adc7 --- /dev/null +++ b/infrastructure/charts/mev-commit-erigon/templates/password-secret.yaml @@ -0,0 +1,11 @@ +{{- if .Values.genesis.accountGeneration.enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "erigon-snode.fullname" . }}-password + labels: + {{- include "erigon-snode.labels" . | nindent 4 }} +type: Opaque +data: + password.txt: {{ .Values.genesis.accountGeneration.password | b64enc }} +{{- end }} diff --git a/infrastructure/charts/mev-commit-erigon/templates/statefulset.yaml b/infrastructure/charts/mev-commit-erigon/templates/statefulset.yaml index 332ecef86..f665c524b 100644 --- a/infrastructure/charts/mev-commit-erigon/templates/statefulset.yaml +++ b/infrastructure/charts/mev-commit-erigon/templates/statefulset.yaml @@ -46,11 +46,19 @@ spec: - name: jwt-secret secret: secretName: {{ include "erigon-snode.fullname" . }}-jwt + {{- if .Values.genesis.accountGeneration.enabled }} + - name: genesis-template + configMap: + name: {{ include "erigon-snode.fullname" . }}-genesis-template + - name: password-file + secret: + secretName: {{ include "erigon-snode.fullname" . }}-password + {{- end }} initContainers: - name: create-jwt image: busybox:latest command: ["/bin/sh", "-c"] - args: ["/scripts/create-jwt.sh"] + args: ["cp /secrets/jwt /shared/jwt && chmod 600 /shared/jwt"] {{- with .Values.initContainerResources }} resources: {{- toYaml . | nindent 12 }} @@ -58,14 +66,65 @@ spec: securityContext: runAsUser: 0 runAsGroup: 0 + volumeMounts: + - name: jwt-secret + mountPath: /secrets + - name: erigon-volume + mountPath: /shared + subPath: shared + {{- if .Values.genesis.accountGeneration.enabled }} + - name: generate-accounts + image: "ethereum/client-go:latest" + command: ["/bin/sh", "-c"] + args: ["/scripts/generate-account.sh"] + {{- with .Values.initContainerResources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + securityContext: + runAsUser: 0 + runAsGroup: 0 + env: + - name: ACCOUNT_COUNT + value: "{{ .Values.genesis.accountGeneration.count }}" + - name: ACCOUNT_BALANCE + value: "{{ .Values.genesis.accountGeneration.balance | default "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD4A51000FDA0FFFF" }}" volumeMounts: - name: scripts-volume mountPath: /scripts - name: erigon-volume mountPath: /shared subPath: shared - - name: jwt-secret - mountPath: /secrets + - name: genesis-template + mountPath: /genesis-template + - name: password-file + mountPath: /password + - name: erigon-volume + mountPath: /keystore + subPath: keystore + - name: create-genesis + image: alpine:latest + command: ["/bin/sh", "-c"] + args: ["/scripts/create-genesis.sh"] + {{- with .Values.initContainerResources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + securityContext: + runAsUser: 0 + runAsGroup: 0 + env: + - name: ACCOUNT_BALANCE + value: "{{ .Values.genesis.accountGeneration.balance | default "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD4A51000FDA0FFFF" }}" + volumeMounts: + - name: scripts-volume + mountPath: /scripts + - name: erigon-volume + mountPath: /shared + subPath: shared + - name: genesis-template + mountPath: /genesis-template + {{- else }} - name: download-genesis image: alpine:latest command: ["/bin/sh", "-c"] @@ -77,12 +136,16 @@ spec: securityContext: runAsUser: 0 runAsGroup: 0 + env: + - name: GENESIS_URL + value: "{{ .Values.genesis.url }}" volumeMounts: - name: scripts-volume mountPath: /scripts - name: erigon-volume mountPath: /shared subPath: shared + {{- end }} - name: init-erigon image: "{{ .Values.image.erigon.repository }}:{{ .Values.image.erigon.tag }}" imagePullPolicy: {{ .Values.image.erigon.pullPolicy }} @@ -95,6 +158,9 @@ spec: securityContext: runAsUser: 0 runAsGroup: 0 + env: + - name: ERIGON_DATADIR + value: "{{ .Values.erigon.datadir }}" volumeMounts: - name: scripts-volume mountPath: /scripts @@ -118,6 +184,7 @@ spec: runAsGroup: 0 args: - --datadir={{ .Values.erigon.datadir }} + - --private.api.addr= - --authrpc.jwtsecret=/shared/jwt - --authrpc.addr=0.0.0.0 - --authrpc.port={{ .Values.erigon.ports.authrpc }} @@ -167,6 +234,11 @@ spec: - name: erigon-volume mountPath: /shared subPath: shared + {{- if .Values.genesis.accountGeneration.enabled }} + - name: erigon-volume + mountPath: /keystore + subPath: keystore + {{- end }} - name: snode image: "{{ .Values.image.snode.repository }}:{{ .Values.image.snode.tag }}" imagePullPolicy: {{ .Values.image.snode.pullPolicy }} diff --git a/infrastructure/charts/mev-commit-erigon/values.yaml b/infrastructure/charts/mev-commit-erigon/values.yaml index a614cab44..01f073ee2 100644 --- a/infrastructure/charts/mev-commit-erigon/values.yaml +++ b/infrastructure/charts/mev-commit-erigon/values.yaml @@ -1,6 +1,21 @@ +# Genesis Configuration - Choose ONE method only +# Method 1: Generate accounts and create genesis automatically. Genesis template is stored in the configmap +# Method 2: Download genesis from existing URL +# NOTE: Both methods cannot be used simultaneously - validation will fail if both are configured +genesis: + # Method 1: Account Generation (generates new accounts and creates genesis with them) + accountGeneration: + enabled: false # Set to true to enable automatic account generation + count: 5 # Number of accounts to generate and fund in genesis. These accounts will be added under alloc{} + password: "randompassword" # Password for generated account keystores + timestamp: 0x198c3a13dc8 # Timestamp for genesis block in milliseconds + + # Method 2: URL Download (downloads existing genesis file) + url: "http://example.com/genesis.json" # Set this to download genesis from URL + erigon: - networkId: 141414 + networkId: 10025 datadir: "/data/erigon" ports: http: 8545 @@ -23,12 +38,12 @@ erigon: enabled: true addr: "0.0.0.0" zeroFeeTxList: - - "0x00" # Orcale Keystore - - "0x00" # Contracts Deployer Keystore - - "0x00" # Bridge Relayer Keystore + - "0x0000000000000000000000000000000000000000" # Contracts Deployer Keystore + - "0x0000000000000000000000000000000000000000" # Orcale Keystore + #- "0x0000000000000000000000000000000000000000" # Bridge Relayer Keystore pruneMode: "archive" nodiscover: true - # Additional flags to pass to erigon + # Additional arguments to pass to erigon extraArgs: [] # Example: # extraArgs: @@ -37,7 +52,7 @@ erigon: snode: instanceId: "snode1" - priorityFeeRecipient: "0x00" + priorityFeeRecipient: "0x0000000000000000000000000000000000000000" ports: api: 9090 health: 8080 @@ -52,23 +67,20 @@ snode: jwt: token: "" -genesis: - url: "" - image: erigon: - repository: + repository: tag: pullPolicy: IfNotPresent snode: - repository: + repository: tag: pullPolicy: IfNotPresent storage: - size: 500Gi - storageClassName: + size: 100Gi + storageClassName: premium-rwo accessMode: ReadWriteOnce security: @@ -84,18 +96,18 @@ terminationGracePeriodSeconds: 60 resources: erigon: requests: - cpu: "48" - memory: "128Gi" + cpu: "1000m" + memory: "2Gi" limits: - cpu: "52" - memory: "152Gi" + cpu: "6000m" + memory: "16Gi" snode: requests: - cpu: "8" - memory: "48Gi" + cpu: "100m" + memory: "1Gi" limits: - cpu: "12" - memory: "64Gi" + cpu: "6000m" + memory: "16Gi" # Init container resources initContainerResources: @@ -108,7 +120,7 @@ initContainerResources: service: erigon: - type: ClusterIP + type: LoadBalancer ports: http: 8545 ws: 8546 @@ -132,62 +144,17 @@ service: # app: snode # component: consensus-layer -nodeSelector: - workload-type: erigon +#nodeSelector: +# workload-type: erigon tolerations: [] -# Example: -# tolerations: -# - key: "erigon-dedicated" -# operator: "Equal" -# value: "true" -# effect: "NoSchedule" -# - key: "node.kubernetes.io/disk-pressure" -# operator: "Exists" -# effect: "NoSchedule" + affinity: {} -# Example: -# affinity: -# nodeAffinity: -# requiredDuringSchedulingIgnoredDuringExecution: -# nodeSelectorTerms: -# - matchExpressions: -# - key: node-type -# operator: In -# values: -# - high-memory -# preferredDuringSchedulingIgnoredDuringExecution: -# - weight: 100 -# preference: -# matchExpressions: -# - key: zone -# operator: In -# values: -# - zone-1 -# podAntiAffinity: -# preferredDuringSchedulingIgnoredDuringExecution: -# - weight: 100 -# podAffinityTerm: -# labelSelector: -# matchExpressions: -# - key: app.kubernetes.io/name -# operator: In -# values: -# - erigon-snode -# topologyKey: kubernetes.io/hostname -topologySpreadConstraints: [] -# Example: -# topologySpreadConstraints: -# - maxSkew: 1 -# topologyKey: topology.kubernetes.io/zone -# whenUnsatisfiable: DoNotSchedule -# labelSelector: -# matchLabels: -# app.kubernetes.io/name: erigon-snode +topologySpreadConstraints: [] # Additional labels for StatefulSet additionalLabels: {} @@ -198,12 +165,12 @@ additionalLabels: {} # version: v1.0.0 ingress: - enabled: true - className: "" + enabled: false + className: "nginx" # RPC Configuration rpc: - host: + host: rpc.devnet.xyz path: / pathType: Prefix annotations: @@ -216,14 +183,14 @@ ingress: # WebSocket Configuration websocket: - host: + host: ws.devnet.xyz path: / pathType: Prefix annotations: nginx.ingress.kubernetes.io/backend-protocol: "HTTP" nginx.ingress.kubernetes.io/force-ssl-redirect: "true" nginx.ingress.kubernetes.io/proxy-body-size: "0" - nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" + nginx.ingress.kubernetes.io/proxy-read-timeout: "36h00" nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" nginx.ingress.kubernetes.io/ssl-redirect: "true" # WebSocket specific annotations @@ -232,7 +199,7 @@ ingress: Connection "upgrade" Upgrade $http_upgrade - + # TLS Configuration (shared) tls: - secretName: + secretName: devnet-tls # Should be pre-created if you using tls