From 6e4b8c59b06828175b9a5050b9909aa39fd638aa Mon Sep 17 00:00:00 2001 From: mrekucci Date: Tue, 5 Nov 2024 00:45:42 +0700 Subject: [PATCH 1/5] refactor: distribute allocation from single address --- contracts/scripts/core/DeployCore.s.sol | 9 +++++++++ .../DeployStandardBridge.s.sol | 4 ++-- infrastructure/nomad/playbooks/deploy.yml | 2 +- .../templates/jobs/mev-commit-funder.nomad.j2 | 12 +++++++----- .../nomad/playbooks/variables/profiles.yml | 19 ------------------- 5 files changed, 19 insertions(+), 27 deletions(-) diff --git a/contracts/scripts/core/DeployCore.s.sol b/contracts/scripts/core/DeployCore.s.sol index 5d52a3c0b..08c36d451 100644 --- a/contracts/scripts/core/DeployCore.s.sol +++ b/contracts/scripts/core/DeployCore.s.sol @@ -15,6 +15,12 @@ import {BlockTracker} from "../../contracts/core/BlockTracker.sol"; import {console} from "forge-std/console.sol"; contract DeployTestnet is Script { + + // Amount of ETH required to fund the Oracle contract. + uint256 public constant ORACLE_FUNDING = 1000 ether; + + error FailedToSendETHToOracle(address addr); + function run() external { require(block.chainid == 17864, "chainID not 17864 (testnet env)"); vm.startBroadcast(); @@ -98,6 +104,9 @@ contract DeployTestnet is Script { preconfManager.updateOracleContract(address(oracle)); console.log("_PreconfManagerWithOracle:", address(oracle)); + (bool success, ) = payable(oracleKeystoreAddress).call{value: ORACLE_FUNDING}(""); + require(success, FailedToSendETHToOracle(oracleKeystoreAddress)); + vm.stopBroadcast(); } } diff --git a/contracts/scripts/standard-bridge/DeployStandardBridge.s.sol b/contracts/scripts/standard-bridge/DeployStandardBridge.s.sol index 8ee9769e7..9daffd2d0 100644 --- a/contracts/scripts/standard-bridge/DeployStandardBridge.s.sol +++ b/contracts/scripts/standard-bridge/DeployStandardBridge.s.sol @@ -14,7 +14,7 @@ import {console} from "forge-std/console.sol"; contract BridgeBase is Script { // Amount of ETH which must be allocated only to the contract deployer on mev-commit chain genesis. - uint256 public constant DEPLOYER_GENESIS_ALLOCATION = type(uint256).max - 10 ether; + uint256 public constant DEPLOYER_GENESIS_ALLOCATION = type(uint256).max - 2000 ether; // Amount of ETH to initially fund the relayer account on both chains. uint256 public constant RELAYER_INITIAL_FUNDING = 1 ether; @@ -23,7 +23,7 @@ contract BridgeBase is Script { // AND initially fund the relayer, all on mev-commit chain. // This amount of ETH must be initially locked in the L1 gateway contract to ensure a 1:1 peg // between mev-commit chain ETH and L1 ETH. - uint256 public constant MEV_COMMIT_CHAIN_SETUP_COST = 1 ether + RELAYER_INITIAL_FUNDING; + uint256 public constant MEV_COMMIT_CHAIN_SETUP_COST = 10000 ether + RELAYER_INITIAL_FUNDING; // Amount of ETH required on L1 to initialize the L1 gateway, make transfer calls, and initially fund the relayer on L1. uint256 public constant L1_SETUP_COST = 1 ether + RELAYER_INITIAL_FUNDING; diff --git a/infrastructure/nomad/playbooks/deploy.yml b/infrastructure/nomad/playbooks/deploy.yml index e6bb65388..0f8a227e8 100644 --- a/infrastructure/nomad/playbooks/deploy.yml +++ b/infrastructure/nomad/playbooks/deploy.yml @@ -495,7 +495,7 @@ echo "${ALLOC}" | jq --arg address "0x${ADDRESS}" ' . + { ($address): { - "balance": "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD4A51000FDA0FFFF" + "balance": "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" } } ' diff --git a/infrastructure/nomad/playbooks/templates/jobs/mev-commit-funder.nomad.j2 b/infrastructure/nomad/playbooks/templates/jobs/mev-commit-funder.nomad.j2 index a86b629bf..714162bff 100644 --- a/infrastructure/nomad/playbooks/templates/jobs/mev-commit-funder.nomad.j2 +++ b/infrastructure/nomad/playbooks/templates/jobs/mev-commit-funder.nomad.j2 @@ -37,8 +37,8 @@ job "{{ job.name }}" { {%- raw %} XDG_CONFIG_HOME="local/.config" KEYSTORE_PATH="/local/data-{{ env "NOMAD_ALLOC_INDEX" }}/keystore" - KEYSTORE_FILENAME="{{ with secret "secret/data/mev-commit" }}{{ .Data.data.{% endraw %}{{ job.target.artifacts | selectattr('keystores', 'defined') | map(attribute='keystores') | first | list | first }}{% raw %}_filename }}{{ end }}" - KEYSTORE_PASSWORD="{{ with secret "secret/data/mev-commit" }}{{ .Data.data.{% endraw %}{{ job.target.artifacts | selectattr('keystores', 'defined') | map(attribute='keystores') | first | list | first }}{% raw %}_password }}{{ end }}" + KEYSTORE_FILENAME="{{ with secret "secret/data/mev-commit" }}{{ .Data.data.contract_deployer_keystore_filename }}{{ end }}" + KEYSTORE_PASSWORD="{{ with secret "secret/data/mev-commit" }}{{ .Data.data.contract_deployer_keystore_password }}{{ end }}" {% endraw %} EOH destination = "secrets/.env" @@ -68,19 +68,21 @@ job "{{ job.name }}" { mkdir -p "${KEYSTORE_PATH}" > /dev/null 2>&1 {{- with secret "secret/data/mev-commit" }} KEYSTORE_FILE="${KEYSTORE_PATH}/${KEYSTORE_FILENAME}" - echo '{{ .Data.data.{% endraw %}{{ job.target.artifacts | selectattr('keystores', 'defined') | map(attribute='keystores') | first | list | first }}{% raw %} }}' > "${KEYSTORE_FILE}" + echo '{{ .Data.data.contract_deployer_keystore }}' > "${KEYSTORE_FILE}" {{ end }} {{- range nomadService "{% endraw %}{{ job.target.name }}{% raw %}" }} + {{- if contains "http" .Tags }} + ADDRESS=$(curl -sk https://{{ .Address }}:{{ .Port }}/v1/debug/topology | jq -r '.topology.self["Ethereum Address"]') + {{- end }} {{- range nomadService "mev-commit-geth-bootnode1" }} {{- if contains "http" .Tags }} - ADDRESS=$(cat "${KEYSTORE_FILE}" | jq -r '.address') cast send \ --keystore "${KEYSTORE_FILE}" \ --password "${KEYSTORE_PASSWORD}" \ --priority-gas-price 2000000000 \ --gas-price 5000000000 \ - --value 1000ether \ + --value 10ether \ --rpc-url http://{{ .Address }}:{{ .Port }} \ "${ADDRESS}" diff --git a/infrastructure/nomad/playbooks/variables/profiles.yml b/infrastructure/nomad/playbooks/variables/profiles.yml index a10270009..b930baf29 100644 --- a/infrastructure/nomad/playbooks/variables/profiles.yml +++ b/infrastructure/nomad/playbooks/variables/profiles.yml @@ -81,7 +81,6 @@ jobs: name: geth_signer_node1_nodekey - keystores: geth_signer1_keystore: - allocation: true count: 1 ports: - metrics: @@ -155,7 +154,6 @@ jobs: contract_deployer_keystore: allocation: true bridge_relayer_keystore: - allocation: true count: 1 ports: - http: @@ -186,7 +184,6 @@ jobs: - *p2p_artifact - keystores: bootnode1_keystore: - allocation: false count: 1 ports: - metrics: @@ -213,7 +210,6 @@ jobs: - *p2p_artifact - keystores: provider1_keystore: - allocation: true count: 1 ports: - metrics: @@ -240,7 +236,6 @@ jobs: - *p2p_artifact - keystores: provider2_keystore: - allocation: true count: 1 ports: - metrics: @@ -266,7 +261,6 @@ jobs: - *p2p_artifact - keystores: provider3_keystore: - allocation: true count: 1 ports: - metrics: @@ -342,7 +336,6 @@ jobs: - *p2p_artifact - keystores: bidder1_keystore: - allocation: true count: 1 ports: - metrics: @@ -368,7 +361,6 @@ jobs: - *p2p_artifact - keystores: bidder2_keystore: - allocation: true count: 1 ports: - metrics: @@ -393,7 +385,6 @@ jobs: - *p2p_artifact - keystores: bidder3_keystore: - allocation: true count: 1 ports: - metrics: @@ -418,7 +409,6 @@ jobs: - *p2p_artifact - keystores: bidder4_keystore: - allocation: true count: 1 ports: - metrics: @@ -443,7 +433,6 @@ jobs: - *p2p_artifact - keystores: bidder5_keystore: - allocation: true count: 1 ports: - metrics: @@ -533,7 +522,6 @@ jobs: name: oracle_register_provider_api_auth_token - keystores: oracle_keystore: - allocation: true dependencies: contracts_deployer: *contracts_deployer_job count: 1 @@ -571,7 +559,6 @@ jobs: artifacts: - keystores: faucet_keystore: - allocation: true count: 1 ports: - http: @@ -624,11 +611,8 @@ jobs: - *l1_transactor_artifact - keystores: l1_transactor_account1_keystore: - allocation: true l1_transactor_account2_keystore: - allocation: true l1_transactor_account3_keystore: - allocation: true dependencies: mock_l1: *mock_l1_job env: @@ -641,11 +625,8 @@ jobs: - *bridge_v1_artifact - keystores: bridge_emulator_account1_keystore: - allocation: true bridge_emulator_account2_keystore: - allocation: true bridge_emulator_account3_keystore: - allocation: true dependencies: contracts_deployer: *contracts_deployer_job count: 1 From 53b8d2817d6287f3221602993d889089cefc43e9 Mon Sep 17 00:00:00 2001 From: mrekucci Date: Tue, 5 Nov 2024 23:09:31 +0700 Subject: [PATCH 2/5] fix: found l1 transactor keystores --- .../templates/jobs/l1-transactor.nomad.j2 | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/infrastructure/nomad/playbooks/templates/jobs/l1-transactor.nomad.j2 b/infrastructure/nomad/playbooks/templates/jobs/l1-transactor.nomad.j2 index 2cc79edba..e8384a413 100644 --- a/infrastructure/nomad/playbooks/templates/jobs/l1-transactor.nomad.j2 +++ b/infrastructure/nomad/playbooks/templates/jobs/l1-transactor.nomad.j2 @@ -28,6 +28,11 @@ job "{{ job.name }}" { task "l1-transactor" { driver = "exec" + artifact { + source = "https://foundry.paradigm.xyz" + destination = "local/foundry.sh" + } + {% if env != 'devenv' %} artifact { source = "https://primev-infrastructure-artifacts.s3.us-west-2.amazonaws.com/l1-transactor_{{ version }}_Linux_{{ target_system_architecture }}.tar.gz" @@ -69,6 +74,10 @@ job "{{ job.name }}" { TRANSACTOR_L1_RPC_URL="ws://{{ .Address}}:{{ .Port }}" {{- end }} {{- end }} + XDG_CONFIG_HOME="local/.config" + CONTRACT_DEPLOYER_KEYSTORE_PATH="/local/data-{{ env "NOMAD_ALLOC_INDEX" }}/keystore" + CONTRACT_DEPLOYER_KEYSTORE_FILENAME="{{ with secret "secret/data/mev-commit" }}{{ .Data.data.contract_deployer_keystore_filename }}{{ end }}" + CONTRACT_DEPLOYER_KEYSTORE_PASSWORD="{{ with secret "secret/data/mev-commit" }}{{ .Data.data.contract_deployer_keystore_password }}{{ end }}" {% endraw %} EOH destination = "secrets/.env" @@ -85,8 +94,23 @@ job "{{ job.name }}" { exec > >(nc {{ .Address }} {{ .Port }}) 2>&1 {{ end }} {{- end }} + + mkdir -p "${CONTRACT_DEPLOYER_KEYSTORE_PATH}" > /dev/null 2>&1 + {{- with secret "secret/data/mev-commit" }} + CONTRACT_DEPLOYER_KEYSTORE_FILE="${CONTRACT_DEPLOYER_KEYSTORE_PATH}/${CONTRACT_DEPLOYER_KEYSTORE_FILENAME}" + echo '{{ .Data.data.contract_deployer_keystore }}' > "${CONTRACT_DEPLOYER_KEYSTORE_FILE}" + {{ end }} {% endraw %} + chmod +x local/foundry.sh && local/foundry.sh + chmod +x ${XDG_CONFIG_HOME}/.foundry/bin/foundryup + ${XDG_CONFIG_HOME}/.foundry/bin/foundryup 2>&1 + if [ $? -ne 0 ]; then + echo "Failed to install foundry tools" + exit 1 + fi + export PATH="${XDG_CONFIG_HOME}/.foundry/bin:$PATH" + {% if job.artifacts | selectattr('keystores', 'defined') | list | length > 0 %} mkdir -p "${TRANSACTOR_KEYSTORES_DIR}" > /dev/null 2>&1 {% macro ldelim() %}{{ '{{' }}{% endmacro %} @@ -99,8 +123,25 @@ job "{{ job.name }}" { {% for keystore_name in ns.keystore_path_passwd %} {{ ldelim() }} with secret "secret/data/mev-commit" {{ rdelim() }} mkdir -p "${TRANSACTOR_KEYSTORES_DIR}/{{ keystore_name }}" > /dev/null 2>&1 - echo '{{ ldelim() }} .Data.data.{{ keystore_name }} {{ rdelim() }}' > "${TRANSACTOR_KEYSTORES_DIR}/{{ keystore_name }}/{{ ldelim() }} .Data.data.{{ keystore_name }}_filename {{ rdelim() }}" + TRANSACTON_KEYSTORE_FILE="${TRANSACTOR_KEYSTORES_DIR}/{{ keystore_name }}/{{ ldelim() }} .Data.data.{{ keystore_name }}_filename {{ rdelim() }}" + echo '{{ ldelim() }} .Data.data.{{ keystore_name }} {{ rdelim() }}' > "${TRANSACTON_KEYSTORE_FILE}" {{ ldelim() }} end {{ rdelim() }} + + ADDRESS="$(cat "${TRANSACTON_KEYSTORE_FILE}" | jq -r '.address')" + cast send \ + --keystore "${CONTRACT_DEPLOYER_KEYSTORE_FILE}" \ + --password "${CONTRACT_DEPLOYER_KEYSTORE_PASSWORD}" \ + --priority-gas-price 2000000000 \ + --gas-price 5000000000 \ + --value 100ether \ + --rpc-url "${TRANSACTOR_L1_RPC_URL}" \ + "${ADDRESS}" + + if [ $? -eq 0 ]; then + echo "Funds successfully sent to: ${ADDRESS}" + else + echo "Failed to send funds to: ${ADDRESS}" + fi {% endfor %} {% endif %} From af05c531c1a900ca1201ec3c4060bf6ae3f66016 Mon Sep 17 00:00:00 2001 From: mrekucci Date: Wed, 6 Nov 2024 10:00:06 +0700 Subject: [PATCH 3/5] fix: comments --- contracts/scripts/core/DeployCore.s.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/scripts/core/DeployCore.s.sol b/contracts/scripts/core/DeployCore.s.sol index 08c36d451..abf51595d 100644 --- a/contracts/scripts/core/DeployCore.s.sol +++ b/contracts/scripts/core/DeployCore.s.sol @@ -16,7 +16,7 @@ import {console} from "forge-std/console.sol"; contract DeployTestnet is Script { - // Amount of ETH required to fund the Oracle contract. + // Amount of ETH required to fund the Oracle address. uint256 public constant ORACLE_FUNDING = 1000 ether; error FailedToSendETHToOracle(address addr); From 37445899634f44a254be7b6059eb79d25fede6ea Mon Sep 17 00:00:00 2001 From: mrekucci Date: Wed, 6 Nov 2024 21:00:29 +0700 Subject: [PATCH 4/5] refactor: lower initial funding amounts --- contracts/scripts/core/DeployCore.s.sol | 6 +++--- .../scripts/standard-bridge/DeployStandardBridge.s.sol | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/scripts/core/DeployCore.s.sol b/contracts/scripts/core/DeployCore.s.sol index abf51595d..1e2d2ec5a 100644 --- a/contracts/scripts/core/DeployCore.s.sol +++ b/contracts/scripts/core/DeployCore.s.sol @@ -16,8 +16,8 @@ import {console} from "forge-std/console.sol"; contract DeployTestnet is Script { - // Amount of ETH required to fund the Oracle address. - uint256 public constant ORACLE_FUNDING = 1000 ether; + // Amount of ETH to initially fund the oracle account on L1 chain. + uint256 public constant ORACLE_INITIAL_FUNDING = 1 ether; error FailedToSendETHToOracle(address addr); @@ -104,7 +104,7 @@ contract DeployTestnet is Script { preconfManager.updateOracleContract(address(oracle)); console.log("_PreconfManagerWithOracle:", address(oracle)); - (bool success, ) = payable(oracleKeystoreAddress).call{value: ORACLE_FUNDING}(""); + (bool success, ) = payable(oracleKeystoreAddress).call{value: ORACLE_INITIAL_FUNDING}(""); require(success, FailedToSendETHToOracle(oracleKeystoreAddress)); vm.stopBroadcast(); diff --git a/contracts/scripts/standard-bridge/DeployStandardBridge.s.sol b/contracts/scripts/standard-bridge/DeployStandardBridge.s.sol index 9daffd2d0..3cf3c6ac7 100644 --- a/contracts/scripts/standard-bridge/DeployStandardBridge.s.sol +++ b/contracts/scripts/standard-bridge/DeployStandardBridge.s.sol @@ -14,7 +14,7 @@ import {console} from "forge-std/console.sol"; contract BridgeBase is Script { // Amount of ETH which must be allocated only to the contract deployer on mev-commit chain genesis. - uint256 public constant DEPLOYER_GENESIS_ALLOCATION = type(uint256).max - 2000 ether; + uint256 public constant DEPLOYER_GENESIS_ALLOCATION = type(uint256).max - 500 ether; // Amount of ETH to initially fund the relayer account on both chains. uint256 public constant RELAYER_INITIAL_FUNDING = 1 ether; @@ -23,7 +23,7 @@ contract BridgeBase is Script { // AND initially fund the relayer, all on mev-commit chain. // This amount of ETH must be initially locked in the L1 gateway contract to ensure a 1:1 peg // between mev-commit chain ETH and L1 ETH. - uint256 public constant MEV_COMMIT_CHAIN_SETUP_COST = 10000 ether + RELAYER_INITIAL_FUNDING; + uint256 public constant MEV_COMMIT_CHAIN_SETUP_COST = 1 ether + RELAYER_INITIAL_FUNDING; // Amount of ETH required on L1 to initialize the L1 gateway, make transfer calls, and initially fund the relayer on L1. uint256 public constant L1_SETUP_COST = 1 ether + RELAYER_INITIAL_FUNDING; From a39cbf467672cbdd8ef0034ca2c111d6b09c6792 Mon Sep 17 00:00:00 2001 From: mrekucci Date: Thu, 7 Nov 2024 10:36:46 +0700 Subject: [PATCH 5/5] fix: address comments --- .../DeployStandardBridge.s.sol | 5 ++++- infrastructure/nomad/playbooks/deploy.yml | 19 +++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/contracts/scripts/standard-bridge/DeployStandardBridge.s.sol b/contracts/scripts/standard-bridge/DeployStandardBridge.s.sol index 3cf3c6ac7..1aa420f66 100644 --- a/contracts/scripts/standard-bridge/DeployStandardBridge.s.sol +++ b/contracts/scripts/standard-bridge/DeployStandardBridge.s.sol @@ -19,11 +19,14 @@ contract BridgeBase is Script { // Amount of ETH to initially fund the relayer account on both chains. uint256 public constant RELAYER_INITIAL_FUNDING = 1 ether; + // Amount of ETH to initially fund the oracle account on L1 chain. + uint256 public constant ORACLE_INITIAL_FUNDING = 1 ether; + // Amount of ETH required by the contract deployer to initialize all bridge and core contract state, // AND initially fund the relayer, all on mev-commit chain. // This amount of ETH must be initially locked in the L1 gateway contract to ensure a 1:1 peg // between mev-commit chain ETH and L1 ETH. - uint256 public constant MEV_COMMIT_CHAIN_SETUP_COST = 1 ether + RELAYER_INITIAL_FUNDING; + uint256 public constant MEV_COMMIT_CHAIN_SETUP_COST = 1 ether + RELAYER_INITIAL_FUNDING + ORACLE_INITIAL_FUNDING; // Amount of ETH required on L1 to initialize the L1 gateway, make transfer calls, and initially fund the relayer on L1. uint256 public constant L1_SETUP_COST = 1 ether + RELAYER_INITIAL_FUNDING; diff --git a/infrastructure/nomad/playbooks/deploy.yml b/infrastructure/nomad/playbooks/deploy.yml index 0f8a227e8..d34c37fb8 100644 --- a/infrastructure/nomad/playbooks/deploy.yml +++ b/infrastructure/nomad/playbooks/deploy.yml @@ -489,18 +489,13 @@ exit 1 fi - ALLOC=$(echo '{}' | jq '.') - for ADDRESS in ${ALLOCATIONS}; do - ALLOC=$( - echo "${ALLOC}" | jq --arg address "0x${ADDRESS}" ' - . + { - ($address): { - "balance": "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - } - } - ' - ) - done + ALLOC=$(jq -n --arg address "0x${ALLOCATIONS}" ' + { + ($address): { + "balance": "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + } + } + ') ADDRESS_COUNT=0 EXTRADATA="0x$(printf '0%.0s' {1..64})"