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: updated infra privacy to support privacy set up #56

Merged
merged 13 commits into from
May 15, 2024
56 changes: 28 additions & 28 deletions infrastructure/nomad/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@
profiles:
devnet:
job_names:
- 'datadog-agent-logs-collector'
- 'mev-commit-geth-bootnode1'
- 'mev-commit-geth-signer-node1'
- 'mev-commit-geth-member-node'
- 'deploy-contracts'
- 'mev-commit-bootnode1'
- 'mev-commit-provider-node1'
- 'mev-commit-provider-node1-funder'
- 'mev-commit-bidder-node1'
- 'mev-commit-bidder-node1-funder'
- 'mev-commit-provider-emulator-node1'
- 'mev-commit-bidder-emulator-node1'
- 'mev-commit-oracle'
- 'datadog-agent-metrics-collector'
- "datadog-agent-logs-collector"
- "mev-commit-geth-bootnode1"
- "mev-commit-geth-signer-node1"
- "mev-commit-geth-member-node"
- "deploy-contracts"
- "mev-commit-bootnode1"
- "mev-commit-provider-node1"
- "mev-commit-provider-node1-funder"
- "mev-commit-oracle"
- "mev-commit-bidder-node1"
- "mev-commit-bidder-node1-funder"
- "mev-commit-provider-emulator-node1"
- "mev-commit-bidder-emulator-node1"
- "datadog-agent-metrics-collector"
testnet:
job_names:
- 'datadog-agent-logs-collector'
- 'mev-commit-geth-bootnode1'
- 'mev-commit-geth-signer-node1'
- 'mev-commit-geth-member-node'
- 'deploy-contracts'
- 'mev-commit-bootnode1'
- 'mev-commit-provider-node1'
- 'mev-commit-provider-node1-funder'
- 'mev-commit-provider-emulator-node1'
- 'mev-commit-oracle'
- 'datadog-agent-metrics-collector'
- "datadog-agent-logs-collector"
- "mev-commit-geth-bootnode1"
- "mev-commit-geth-signer-node1"
- "mev-commit-geth-member-node"
- "deploy-contracts"
- "mev-commit-bootnode1"
- "mev-commit-provider-node1"
- "mev-commit-provider-node1-funder"
- "mev-commit-provider-emulator-node1"
- "mev-commit-oracle"
- "datadog-agent-metrics-collector"

vars_prompt:
- name: version
Expand Down Expand Up @@ -99,7 +99,7 @@
ansible.builtin.file:
path: "{{ ansible_env.HOME }}/{{ env }}"
state: directory
mode: '0744'
mode: "0744"
recurse: yes

- name: Build | Nomad artifacts
Expand All @@ -120,7 +120,7 @@
loop:
- infrastructure/tools/keystore-generator
- p2p/integrationtest/provider
- p2p/integrationtest/bidder
- p2p/integrationtest/real-bidder
- bridge/standard/bridge-v1
- external/geth
- contracts
Expand Down Expand Up @@ -174,7 +174,7 @@
- name: Deploy | Nomad jobs
ansible.builtin.shell: |
nomad run {{ ansible_env.HOME }}/{{ env }}/{{ job.name }}.nomad
[ "{{ job.name }}" = "deploy-contracts" ] && sleep 180 || true
[ "{{ job.name }}" = "deploy-contracts" ] && sleep 240 || true
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why this sleep time needed to be increased?

Copy link
Member Author

Choose a reason for hiding this comment

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

180s were not enough, but with 240s it's more reliable; contracts have enough time to be deployed with that timing.

args:
executable: bash
loop: "{{ jobs }}"
Expand Down
14 changes: 3 additions & 11 deletions infrastructure/nomad/templates/nomad/mev-commit-emulator.nomad.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ job "{{ job.name }}" {
mode = "bridge"

dns {
servers = {{ ansible_facts['dns']['nameservers'] | tojson }}
servers = {{ (ansible_facts['dns']['nameservers'] + ['1.1.1.1']) | tojson }}
}

{% for port_name, port_details in job.ports[0].items() %}
Expand Down Expand Up @@ -57,13 +57,7 @@ job "{{ job.name }}" {
{{- end }}
{% endraw %}
{% if job.target_type == 'bidder' %}
{%- raw %}
{{ range nomadService "mev-commit-geth-bootnode1" }}
{{- if contains "http" .Tags }}
EMULATOR_SETTLEMENT_RPC_ENDPOINT="http://{{ .Address }}:{{ .Port }}"
{{ end }}
{{ end }}
{% endraw %}
EMULATOR_L1_RPC_URL="{{ job.env['l1_rpc_url'] }}"
{% endif %}
EOH
destination = "secrets/.env"
Expand All @@ -86,10 +80,8 @@ job "{{ job.name }}" {
${EMULATOR_BINARY} \
-server-addr "${EMULATOR_IP_PORT}" \
{% if job.target_type == 'bidder' %}
-rpc-addr "${EMULATOR_SETTLEMENT_RPC_ENDPOINT}" \
Copy link
Contributor

Choose a reason for hiding this comment

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

So the emulator was previously (incorrectly) querying the mev-commit chain instead of L1?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we found out this with Alok

-rpc-addr "${EMULATOR_L1_RPC_URL}" \
{% endif %}
-log-tags "${EMULATOR_LOG_TAGS}" \
-log-fmt "${EMULATOR_LOG_FMT}"
EOH
destination = "local/run.sh"
perms = "0755"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ job "{{ job.name }}" {
local/cast send \
--rpc-url http://{{ .Address }}:{{ .Port }} \
--private-key 0x7c9bf0f015874594d321c1c01ada3166c3509bbd91f76f9e4d7380c2df269c55 ${ETHEREUM_ADDRESS} \
--value 100ether
--value 1000ether
{{- end }}
{{- end }}
{% endraw %}
Expand Down
27 changes: 24 additions & 3 deletions infrastructure/nomad/templates/nomad/mev-commit-oracle.nomad.j2
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,17 @@ job "{{ job.name }}" {
else 'service:' + job.name + '-{{ env "NOMAD_ALLOC_INDEX" }}'
}}"
MEV_ORACLE_LOG_LEVEL="{{ job.env.get('log-level', 'info') }}"
MEV_ORACLE_LAGGERD_MODE="{{ job.env.get('laggerd-mode', '64') }}"
MEV_ORACLE_PRECONF_CONTRACT_ADDR="{{ job.env['preconf_contract_address'] }}"
MEV_ORACLE_BLOCKTRACKER_CONTRACT_ADDR="{{ job.env['blocktracker_contract_address'] }}"
MEV_ORACLE_ORACLE_CONTRACT_ADDR="{{ job.env['oracle_contract_address'] }}"
MEV_ORACLE_BIDDERREGISTRY_CONTRACT_ADDR="{{ job.env['bidder_registry_contract_address'] }}"
MEV_ORACLE_PROVIDERREGISTRY_CONTRACT_ADDR="{{ job.env['provider_registry_contract_address'] }}"
MEV_ORACLE_LAGGERD_MODE="{{ job.env.get('laggerd-mode', '20') }}"
MEV_ORACLE_L1_RPC_URL="{{ job.env['l1_rpc_url'] }}"
{%- raw %}
MEV_ORACLE_KEYSTORE_PATH="/local/data-{{env "NOMAD_ALLOC_INDEX"}}/keystore"
MEV_ORACLE_KEYSTORE_PASSWORD="{{ with secret "secret/data/mev-commit" }}{{ .Data.data.oracle_keystore_password }}{{ end }}"
# MEV_ORACLE_KEYSTORE_PATH="/local/data-{{env "NOMAD_ALLOC_INDEX"}}/keystore"
# MEV_ORACLE_KEYSTORE_PASSWORD="{{ with secret "secret/data/mev-commit" }}{{ .Data.data.oracle_keystore_password }}{{ end }}"
MEV_ORACLE_PRIV_KEY_FILE = "/local/data-{{env "NOMAD_ALLOC_INDEX"}}/priv-key"
{{- range nomadService "mev-commit-oracle" }}
{{- if contains "http" .Tags }}
MEV_ORACLE_HTTP_PORT="{{ .Port }}"
Expand All @@ -148,6 +154,9 @@ job "{{ job.name }}" {
{{- if contains "http" .Tags }}
MEV_ORACLE_SETTLEMENT_RPC_URL="http://{{ .Address }}:{{ .Port }}"
{{- end }}
{{- if contains "ws" .Tags }}
MEV_ORACLE_SETTLEMENT_WS_RPC_ENDPOINT="ws://{{ .Address}}:{{ .Port }}"
{{- end }}
{{- end }}
{{- range nomadService "{% endraw %}{{ job.name }}{% raw %}" }}
{{- if contains "db" .Tags }}
Expand All @@ -167,6 +176,15 @@ job "{{ job.name }}" {
template {
data = <<-EOH
#!/usr/bin/env bash
{%- raw %}
{{- range nomadService "mev-commit-provider-node1" }}
{{ if contains "http" .Tags }}
TOPOLOGY=$(curl https://{{ .Address}}:{{ .Port }}/topology)
PROVIDER_ETHEREUM_ADDRESS=$(echo ${TOPOLOGY} | jq -r '.self["Ethereum Address"]')
export MEV_ORACLE_OVERRIDE_WINNERS=${PROVIDER_ETHEREUM_ADDRESS}
{{ end }}
{{- end }}
{% endraw %}

{%- raw %}
{{- range nomadService "datadog-agent-logs-collector" }}
Expand All @@ -185,6 +203,9 @@ job "{{ job.name }}" {
fi

mkdir -p $(dirname "${MEV_ORACLE_PRIV_KEY_FILE}") > /dev/null 2>&1
{%- raw %}
echo {{ with secret "secret/data/mev-commit" }}{{ .Data.data.oracle_private_key }}{{ end }} > ${MEV_ORACLE_PRIV_KEY_FILE}
{% endraw %}
chmod +x local/mev-commit-oracle
local/mev-commit-oracle start
EOH
Expand Down
7 changes: 7 additions & 0 deletions infrastructure/nomad/templates/nomad/mev-commit.nomad.j2
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ job "{{ job.name }}" {
{{- if contains "http" .Tags }}
MEV_COMMIT_SETTLEMENT_RPC_ENDPOINT="http://{{ .Address }}:{{ .Port }}"
{{- end }}
{{- if contains "ws" .Tags }}
MEV_COMMIT_SETTLEMENT_WS_RPC_ENDPOINT="ws://{{ .Address}}:{{ .Port }}"
{{- end }}
{{- end }}
{% endraw %}
MEV_COMMIT_PEER_TYPE="{{ job.env['type'] }}"
Expand All @@ -73,6 +76,10 @@ job "{{ job.name }}" {
MEV_COMMIT_P2P_ADDR="{{ job.env.get('p2p-address', '0.0.0.0') }}"
MEV_COMMIT_SERVER_TLS_CERTIFICATE="{{ job.env['tls_crt_file'] }}"
MEV_COMMIT_SERVER_TLS_PRIVATE_KEY="{{ job.env['tls_key_file'] }}"
MEV_COMMIT_PROVIDER_REGISTRY_ADDR="{{ job.env.get('provider_registry_contract_address') }}"
MEV_COMMIT_BIDDER_REGISTRY_ADDR="{{ job.env.get('bidder_registry_contract_address') }}"
MEV_COMMIT_PRECONF_ADDR="{{ job.env.get('preconf_contract_address') }}"
MEV_COMMIT_BLOCK_TRACKER_ADDR="{{ job.env.get('blocktracker_contract_address') }}"
{% if job.env['type'] == 'provider' %}
MEV_COMMIT_NAT_ADDR="{{ job.env['nat_address'] }}"
{%- raw %}
Expand Down
65 changes: 39 additions & 26 deletions infrastructure/nomad/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ server_common_name: "mev-commit_{{ env }}.mev-commit.primev.xyz"
tls_crt_file: "{{ certificates_dir }}/{{ server_common_name }}.crt"
tls_key_file: "{{ private_keys_dir }}/{{ server_common_name }}.key"
tls_ca_crt_file: "{{ ca_certificates_dir }}/ca-{{ server_common_name }}.crt"
preconf_contract_address: "0x2Aff805aBdF1Fe79AfcF8B3a9B4B45ECcD6b6D6e"
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid introducing another place that these addresses are hardcoded, and use one or the other. See https://github.com/primevprotocol/monorepo/blob/main/contracts-abi/config/testnet.go

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with @shaspitz

We should not hard-code the contract addresses for the testnet setup. We should have this mechanism for the devnet setup as we may deploy new set of contracts and they have to be tested. Not sure how to manage this with nomad though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Got rid of hard-code addresses in nomad script

blocktracker_contract_address: "0x042744D8cF66d8455350D43F9e09CA73b5C0CB94"
oracle_contract_address: "0x77A4FE615de28fdf0bF68D9B9ba773A32b5C7630"
bidder_registry_contract_address: "0x1E218818D409E0f00dfeBE8A960F7585d4fDff70"
provider_registry_contract_address: "0x0332388390d9df01cA3d26269f2B1Fc314deD9c0"

jobs:
- name: datadog-agent-logs-collector
Expand All @@ -26,6 +31,9 @@ jobs:
http:
static: 8545
to: 8545
ws:
static: 8546
to: 8546
p2p:
to: 30301
env:
Expand All @@ -49,21 +57,6 @@ jobs:
sync_mode: snap
block_address: "0xd9cd8E5DE6d55f796D980B818D350C0746C25b97"

- name: mev-commit-geth-signer-node2
template: mev-commit-geth.nomad.j2
count: 1
ports:
- metrics:
to: 6060
p2p:
to: 30311
env:
ip: 0.0.0.0
net_restrict: 0.0.0.0/0
type: signer
sync_mode: snap
block_address: "0x788EBABe5c3dD422Ef92Ca6714A69e2eabcE1Ee4"

- name: mev-commit-geth-member-node
template: mev-commit-geth.nomad.j2
count: 1
Expand Down Expand Up @@ -108,6 +101,10 @@ jobs:
type: bootnode
tls_crt_file: "{{ tls_crt_file }}"
tls_key_file: "{{ tls_key_file }}"
preconf_contract_address: "{{ preconf_contract_address }}"
blocktracker_contract_address: "{{ blocktracker_contract_address }}"
bidder_registry_contract_address: "{{ bidder_registry_contract_address }}"
provider_registry_contract_address: "{{ provider_registry_contract_address }}"

- name: mev-commit-provider-node1
template: mev-commit.nomad.j2
Expand All @@ -130,13 +127,35 @@ jobs:
nat_address: "{{ ansible_facts['default_ipv4']['address'] }}"
tls_crt_file: "{{ tls_crt_file }}"
tls_key_file: "{{ tls_key_file }}"
preconf_contract_address: "{{ preconf_contract_address }}"
blocktracker_contract_address: "{{ blocktracker_contract_address }}"
bidder_registry_contract_address: "{{ bidder_registry_contract_address }}"
provider_registry_contract_address: "{{ provider_registry_contract_address }}"

- name: mev-commit-provider-node1-funder
template: mev-commit-funder.nomad.j2
count: 1
target_type: provider
target_name: mev-commit-provider-node1

- name: mev-commit-oracle
template: mev-commit-oracle.nomad.j2
count: 1
ports:
- db:
static: 5432
to: 5432
http:
static: 8080
to: 8080
env:
l1_rpc_url: https://ethereum-holesky-rpc.publicnode.com
preconf_contract_address: "{{ preconf_contract_address }}"
blocktracker_contract_address: "{{ blocktracker_contract_address }}"
bidder_registry_contract_address: "{{ bidder_registry_contract_address }}"
provider_registry_contract_address: "{{ provider_registry_contract_address }}"
oracle_contract_address: "{{ oracle_contract_address }}"

- name: mev-commit-bidder-node1
template: mev-commit.nomad.j2
count: 1
Expand All @@ -157,6 +176,10 @@ jobs:
type: bidder
tls_crt_file: "{{ tls_crt_file }}"
tls_key_file: "{{ tls_key_file }}"
preconf_contract_address: "{{ preconf_contract_address }}"
blocktracker_contract_address: "{{ blocktracker_contract_address }}"
bidder_registry_contract_address: "{{ bidder_registry_contract_address }}"
provider_registry_contract_address: "{{ provider_registry_contract_address }}"

- name: mev-commit-bidder-node1-funder
template: mev-commit-funder.nomad.j2
Expand All @@ -181,18 +204,8 @@ jobs:
ports:
- metrics:
to: 8080

- name: mev-commit-oracle
template: mev-commit-oracle.nomad.j2
count: 1
ports:
- db:
static: 5432
to: 5432
http:
to: 8080
env:
l1_rpc_url: https://rpc.sepolia.org
l1_rpc_url: https://ethereum-holesky-rpc.publicnode.com

- name: mev-commit-bridge
template: mev-commit-bridge.nomad.j2
Expand Down
Loading