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

refactor: redistribute funds from single genesis address #465

Merged
merged 5 commits into from
Nov 7, 2024
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
9 changes: 9 additions & 0 deletions contracts/scripts/core/DeployCore.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 to initially fund the oracle account on L1 chain.
uint256 public constant ORACLE_INITIAL_FUNDING = 1 ether;
shaspitz marked this conversation as resolved.
Show resolved Hide resolved

error FailedToSendETHToOracle(address addr);

function run() external {
require(block.chainid == 17864, "chainID not 17864 (testnet env)");
vm.startBroadcast();
Expand Down Expand Up @@ -98,6 +104,9 @@ contract DeployTestnet is Script {
preconfManager.updateOracleContract(address(oracle));
console.log("_PreconfManagerWithOracle:", address(oracle));

(bool success, ) = payable(oracleKeystoreAddress).call{value: ORACLE_INITIAL_FUNDING}("");
require(success, FailedToSendETHToOracle(oracleKeystoreAddress));

vm.stopBroadcast();
}
}
7 changes: 5 additions & 2 deletions contracts/scripts/standard-bridge/DeployStandardBridge.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ 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 - 500 ether;

// 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;
Expand Down
19 changes: 7 additions & 12 deletions infrastructure/nomad/playbooks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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": "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD4A51000FDA0FFFF"
}
}
'
)
done
ALLOC=$(jq -n --arg address "0x${ALLOCATIONS}" '
{
($address): {
"balance": "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
}
}
')

ADDRESS_COUNT=0
EXTRADATA="0x$(printf '0%.0s' {1..64})"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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 %}
Expand All @@ -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')"
shaspitz marked this conversation as resolved.
Show resolved Hide resolved
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 %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mev-commit contract deployer can no longer send unaccounted for ether to various accounts. All usable eth on the mev-commit chain (excluding balance given to allocator contract) must have an equivalent amount locked in the L1 gateway contract

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funders are only used in testnet/devnet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can keep the current code to move quickly, but ideally we eventually have constant config and test bidders/providers bridge their eth from mock l1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This 10 eth is being bridged from the mock L1 ? What code does that happen from?

--rpc-url http://{{ .Address }}:{{ .Port }} \
"${ADDRESS}"

Expand Down
19 changes: 0 additions & 19 deletions infrastructure/nomad/playbooks/variables/profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ jobs:
name: geth_signer_node1_nodekey
- keystores:
geth_signer1_keystore:
allocation: true
count: 1
ports:
- metrics:
Expand Down Expand Up @@ -155,7 +154,6 @@ jobs:
contract_deployer_keystore:
allocation: true
bridge_relayer_keystore:
allocation: true
count: 1
ports:
- http:
Expand Down Expand Up @@ -186,7 +184,6 @@ jobs:
- *p2p_artifact
- keystores:
bootnode1_keystore:
allocation: false
count: 1
ports:
- metrics:
Expand All @@ -213,7 +210,6 @@ jobs:
- *p2p_artifact
- keystores:
provider1_keystore:
allocation: true
count: 1
ports:
- metrics:
Expand All @@ -240,7 +236,6 @@ jobs:
- *p2p_artifact
- keystores:
provider2_keystore:
allocation: true
count: 1
ports:
- metrics:
Expand All @@ -266,7 +261,6 @@ jobs:
- *p2p_artifact
- keystores:
provider3_keystore:
allocation: true
count: 1
ports:
- metrics:
Expand Down Expand Up @@ -342,7 +336,6 @@ jobs:
- *p2p_artifact
- keystores:
bidder1_keystore:
allocation: true
count: 1
ports:
- metrics:
Expand All @@ -368,7 +361,6 @@ jobs:
- *p2p_artifact
- keystores:
bidder2_keystore:
allocation: true
count: 1
ports:
- metrics:
Expand All @@ -393,7 +385,6 @@ jobs:
- *p2p_artifact
- keystores:
bidder3_keystore:
allocation: true
count: 1
ports:
- metrics:
Expand All @@ -418,7 +409,6 @@ jobs:
- *p2p_artifact
- keystores:
bidder4_keystore:
allocation: true
count: 1
ports:
- metrics:
Expand All @@ -443,7 +433,6 @@ jobs:
- *p2p_artifact
- keystores:
bidder5_keystore:
allocation: true
count: 1
ports:
- metrics:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -571,7 +559,6 @@ jobs:
artifacts:
- keystores:
faucet_keystore:
allocation: true
count: 1
ports:
- http:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
Loading