diff --git a/.envrc b/.envrc index ab7eee4..bc74660 100644 --- a/.envrc +++ b/.envrc @@ -9,20 +9,23 @@ export HOST_UID HOST_GID export DOCKER_CONFIGS=${PRJ_ROOT}/docker/configs export DOCKER_LOCAL_DATA=${PRJ_ROOT}/.local/docker/data -# used by geth setup in docker-compose +# used by procfile +export LOCAL_CONFIGS=${PRJ_ROOT}/procfile/configs +export LOCAL_DATA=${PRJ_ROOT}/.local + +# geth export GETH_NETWORK_ID=1214 export GETH_ACCOUNT_PASSWORD=!Pa55word - -# erigon -export ERIGON_DATA=${DOCKER_LOCAL_DATA}/erigon +export GETH_DATA=${LOCAL_DATA}/geth +export GETH_IPC=${GETH_DATA}/geth.ipc # prysm -export PRYSM_CHECKPOINT=${DOCKER_CONFIGS}/prysm/checkpoints +export PRYSM_CHECKPOINT_URL="https://sepolia.checkpoint-sync.ethdevops.io" +export PRYSM_CHECKPOINT=${LOCAL_CONFIGS}/genesis.ssz export PRYSM_DATA=${DOCKER_LOCAL_DATA}/prysm +# nats +export NATS_DATA=${LOCAL_DATA}/nats-server + # allow local .envrc overrides [[ -f .envrc.local ]] && source_env .envrc.local - -# ensure local data directories exist -mkdir -p ${PRYSM_DATA} -mkdir -p ${ERIGON_DATA} \ No newline at end of file diff --git a/.gitignore b/.gitignore index f7c3408..5f06706 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,6 @@ node_modules/ /out ############################## -## Docker +## Docker & Procfile ############################## /.local/ diff --git a/Justfile b/Justfile index fa3d488..8dd3110 100644 --- a/Justfile +++ b/Justfile @@ -55,12 +55,3 @@ nix-check: clean: rm -rf ./result* alias c := clean - -# Alias docker-compose up -up: - mkdir -p $PRYSM_DATA $ERIGON_DATA - docker-compose up -d - -# Alias for docker-compose down -down: - docker-compose down --remove-orphans -v \ No newline at end of file diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..a726800 --- /dev/null +++ b/Procfile @@ -0,0 +1,10 @@ +# Procfile - https://devcenter.heroku.com/articles/procfile + +# Prysm / Sepolia / https://docs.prylabs.network/docs/install/install-with-script +prysm: beacon-chain --accept-terms-of-use --sepolia --datadir="${PRYSM_DATA}" --rpc-host="0.0.0.0" --execution-endpoint="${GETH_IPC}" --monitoring-host="0.0.0.0" --grpc-gateway-host="0.0.0.0" --grpc-gateway-corsdomain="*" --checkpoint-sync-url="${PRYSM_CHECKPOINT_URL}" --genesis-beacon-api-url="${PRYSM_CHECKPOINT_URL}" --genesis-state="${PRYSM_CHECKPOINT}" + +# Geth / Sepolia +geth: geth --sepolia --datadir="${GETH_DATA}" --http --http.api eth,net,engine,admin --ws --override.terminaltotaldifficulty 17000000000000000 + +# NATS / Server / https://docs.nats.io/running-a-nats-service/introduction/running +nats: nats-server --addr="0.0.0.0" --port=4222 --http_port=8222 --jetstream --store_dir="${NATS_DATA}" \ No newline at end of file diff --git a/docker-compose.eth1.yaml b/docker-compose.eth1.yaml deleted file mode 100644 index 609a0b1..0000000 --- a/docker-compose.eth1.yaml +++ /dev/null @@ -1,188 +0,0 @@ -version: "3.8" - -networks: - tethys: - name: tethys - driver: bridge - ipam: - config: - - subnet: 172.16.254.0/28 - -services: - nats: - container_name: nats - build: - context: docker/images/nats - ports: - - "4222:4222" # client connections - - "6222:6222" # routing port for clustering - - "8222:8222" # http management port for information reporting - networks: - - tethys - - geth-bootnode: - container_name: geth-bootnode - build: - context: docker/images/geth - args: - - ACCOUNT_PASSWORD=${GETH_ACCOUNT_PASSWORD} - command: - --nodekeyhex="b0ac22adcad37213c7c565810a50f1772291e7b0ce53fb73e7ec2a3c75bc13b5" - --nodiscover - --ipcdisable - --networkid=${GETH_NETWORK_ID} - --netrestrict="172.16.254.0/28" - networks: - - tethys - - geth-miner: - container_name: geth-miner - build: - context: docker/images/geth - depends_on: - - geth-bootnode - command: - --bootnodes="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13786620d5953738762afa13711d4ffb3b19aa5de772d8af72f851f7e9c5b164a@geth-bootnode:30303" - --mine - --miner.threads=1 - --networkid=${GETH_NETWORK_ID} - --netrestrict="172.16.254.0/28" - networks: - tethys: - - geth-rpc-1: - container_name: geth-rpc-1 - build: - context: docker/images/geth - depends_on: - - geth-bootnode - command: - --bootnodes="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13786620d5953738762afa13711d4ffb3b19aa5de772d8af72f851f7e9c5b164a@geth-bootnode:30303" - --http - --http.vhosts="*" - --http.addr="0.0.0.0" - --http.api="eth,net,web3,debug,txpool,personal,admin" - --http.corsdomain="*" - --http.rpcprefix="/" - --ws - --ws.addr="0.0.0.0" - --ws.api="eth,net,web3,debug,txpool,personal,admin" - --ws.rpcprefix="/" - --networkid=${GETH_NETWORK_ID} - --netrestrict="172.16.254.0/28" - ports: - - "8545:8545" - - "8546:8546" - networks: - - tethys - - geth-rpc-1-sidecar: - container_name: geth-rpc-1-sidecar - image: 41north/tethys-sidecar:dev - depends_on: - - nats - - geth-rpc-1 - networks: - - tethys - restart: on-failure - command: - - eth - environment: - NATS_URL: ns://nats:4222 - WEB3_URL: ws://geth-rpc-1:8546 - - geth-rpc-2: - container_name: geth-rpc-2 - build: - context: docker/images/geth - depends_on: - - geth-bootnode - command: - --bootnodes="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13786620d5953738762afa13711d4ffb3b19aa5de772d8af72f851f7e9c5b164a@geth-bootnode:30303" - --http - --http.vhosts="*" - --http.addr="0.0.0.0" - --http.api="eth,net,web3,debug,txpool,personal,admin" - --http.corsdomain="*" - --http.rpcprefix="/" - --ws - --ws.addr="0.0.0.0" - --ws.api="eth,net,web3,debug,txpool,personal,admin" - --ws.rpcprefix="/" - --networkid=${GETH_NETWORK_ID} - --netrestrict="172.16.254.0/28" - networks: - - tethys - - geth-rpc-2-sidecar: - container_name: geth-rpc-2-sidecar - image: 41north/tethys-sidecar:dev - depends_on: - - nats - - geth-rpc-2 - networks: - - tethys - restart: on-failure - command: - - eth - environment: - NATS_URL: ns://nats:4222 - WEB3_URL: ws://geth-rpc-2:8546 - - geth-rpc-3: - container_name: geth-rpc-3 - build: - context: docker/images/geth - depends_on: - - geth-bootnode - command: - --bootnodes="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13786620d5953738762afa13711d4ffb3b19aa5de772d8af72f851f7e9c5b164a@geth-bootnode:30303" - --http - --http.vhosts="*" - --http.addr="0.0.0.0" - --http.api="eth,net,web3,debug,txpool,personal,admin" - --http.corsdomain="*" - --http.rpcprefix="/" - --ws - --ws.addr="0.0.0.0" - --ws.api="eth,net,web3,debug,txpool,personal,admin" - --ws.rpcprefix="/" - --networkid=${GETH_NETWORK_ID} - --netrestrict="172.16.254.0/28" - networks: - - tethys - - geth-rpc-3-sidecar: - container_name: geth-rpc-3-sidecar - image: 41north/tethys-sidecar:dev - depends_on: - - nats - - geth-rpc-3 - networks: - - tethys - restart: on-failure - command: - - eth - environment: - NATS_URL: ns://nats:4222 - WEB3_URL: ws://geth-rpc-3:8546 - WEB3_CONNECTION_TYPE: ConnectionTypeManaged - WEB3_CLIENT_ID: alchemy - - proxy: - container_name: proxy - image: 41north/tethys-proxy:dev - depends_on: - - nats - networks: - - tethys - ports: - - "8080:8080" - restart: on-failure - command: - - eth - - --log-level=debug - environment: - NATS_URL: ns://nats:4222 - ETH_NETWORK_ID: 1214 - ETH_CHAIN_ID: 1214 diff --git a/docker-compose.yaml b/docker-compose.yaml index 2f951fa..609a0b1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,9 +1,5 @@ version: "3.8" -configs: - genesis.ssz: - file: ${PRYSM_CHECKPOINT}/genesis.ssz - networks: tethys: name: tethys @@ -13,104 +9,180 @@ networks: - subnet: 172.16.254.0/28 services: - prysm: - image: gcr.io/prysmaticlabs/prysm/beacon-chain:v3.0.0 - restart: unless-stopped - user: "${HOST_UID}:${HOST_GID}" - command: --datadir=/data/sepolia - --rpc-host=0.0.0.0 - --monitoring-host=0.0.0.0 - --execution-endpoint=http://erigon:8551 - --sepolia - --jwt-secret=/erigon-data/sepolia/jwt.hex - --accept-terms-of-use - --genesis-state=/genesis.ssz - --grpc-gateway-host="0.0.0.0" - --grpc-gateway-corsdomain='*' - --checkpoint-sync-url=https://sepolia.checkpoint-sync.ethdevops.io - --genesis-beacon-api-url=https://sepolia.checkpoint-sync.ethdevops.io + nats: + container_name: nats + build: + context: docker/images/nats + ports: + - "4222:4222" # client connections + - "6222:6222" # routing port for clustering + - "8222:8222" # http management port for information reporting networks: - tethys - ports: - - "3500:3500" - - "13000:13000" - - "12000:12000/udp" - volumes: - - type: bind - source: "${ERIGON_DATA}" - target: /erigon-data - - type: bind - source: "${PRYSM_DATA}" - target: /data - depends_on: - - "erigon" - mem_swappiness: 0 - configs: - - genesis.ssz - erigon: - image: otterscan/erigon:v2022.08.03-otterscan - restart: unless-stopped - user: "${HOST_UID}:${HOST_GID}" - command: erigon - --chain=sepolia - --datadir=/erigon-data/sepolia - --torrent.download.slots=7 - --http.api="eth,web3,net,erigon,ots" - --ws - --http.corsdomain="*" - --http.addr="0.0.0.0" - --http.vhosts='*' - --authrpc.addr="erigon" - --authrpc.vhosts="erigon" + geth-bootnode: + container_name: geth-bootnode + build: + context: docker/images/geth + args: + - ACCOUNT_PASSWORD=${GETH_ACCOUNT_PASSWORD} + command: + --nodekeyhex="b0ac22adcad37213c7c565810a50f1772291e7b0ce53fb73e7ec2a3c75bc13b5" + --nodiscover + --ipcdisable + --networkid=${GETH_NETWORK_ID} + --netrestrict="172.16.254.0/28" networks: - tethys + + geth-miner: + container_name: geth-miner + build: + context: docker/images/geth + depends_on: + - geth-bootnode + command: + --bootnodes="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13786620d5953738762afa13711d4ffb3b19aa5de772d8af72f851f7e9c5b164a@geth-bootnode:30303" + --mine + --miner.threads=1 + --networkid=${GETH_NETWORK_ID} + --netrestrict="172.16.254.0/28" + networks: + tethys: + + geth-rpc-1: + container_name: geth-rpc-1 + build: + context: docker/images/geth + depends_on: + - geth-bootnode + command: + --bootnodes="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13786620d5953738762afa13711d4ffb3b19aa5de772d8af72f851f7e9c5b164a@geth-bootnode:30303" + --http + --http.vhosts="*" + --http.addr="0.0.0.0" + --http.api="eth,net,web3,debug,txpool,personal,admin" + --http.corsdomain="*" + --http.rpcprefix="/" + --ws + --ws.addr="0.0.0.0" + --ws.api="eth,net,web3,debug,txpool,personal,admin" + --ws.rpcprefix="/" + --networkid=${GETH_NETWORK_ID} + --netrestrict="172.16.254.0/28" ports: - "8545:8545" - - "30303:30303/tcp" - - "30303:30303/udp" - - "42069:42069/tcp" - - "42069:42069/udp" - volumes: - - type: bind - source: "${ERIGON_DATA}" - target: /erigon-data - mem_swappiness: 0 + - "8546:8546" + networks: + - tethys - otterscan: - image: otterscan/otterscan:v2022.04.01-otterscan - restart: unless-stopped + geth-rpc-1-sidecar: + container_name: geth-rpc-1-sidecar + image: 41north/tethys-sidecar:dev + depends_on: + - nats + - geth-rpc-1 networks: - tethys - ports: - - "3000:80" + restart: on-failure + command: + - eth + environment: + NATS_URL: ns://nats:4222 + WEB3_URL: ws://geth-rpc-1:8546 + + geth-rpc-2: + container_name: geth-rpc-2 + build: + context: docker/images/geth depends_on: - - "prysm" - - "erigon" + - geth-bootnode + command: + --bootnodes="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13786620d5953738762afa13711d4ffb3b19aa5de772d8af72f851f7e9c5b164a@geth-bootnode:30303" + --http + --http.vhosts="*" + --http.addr="0.0.0.0" + --http.api="eth,net,web3,debug,txpool,personal,admin" + --http.corsdomain="*" + --http.rpcprefix="/" + --ws + --ws.addr="0.0.0.0" + --ws.api="eth,net,web3,debug,txpool,personal,admin" + --ws.rpcprefix="/" + --networkid=${GETH_NETWORK_ID} + --netrestrict="172.16.254.0/28" + networks: + - tethys - nats: + geth-rpc-2-sidecar: + container_name: geth-rpc-2-sidecar + image: 41north/tethys-sidecar:dev + depends_on: + - nats + - geth-rpc-2 + networks: + - tethys + restart: on-failure + command: + - eth + environment: + NATS_URL: ns://nats:4222 + WEB3_URL: ws://geth-rpc-2:8546 + + geth-rpc-3: + container_name: geth-rpc-3 build: - context: docker/images/nats - ports: - - "4222:4222" # client connections - - "6222:6222" # routing port for clustering - - "8222:8222" # http management port for information reporting + context: docker/images/geth + depends_on: + - geth-bootnode + command: + --bootnodes="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13786620d5953738762afa13711d4ffb3b19aa5de772d8af72f851f7e9c5b164a@geth-bootnode:30303" + --http + --http.vhosts="*" + --http.addr="0.0.0.0" + --http.api="eth,net,web3,debug,txpool,personal,admin" + --http.corsdomain="*" + --http.rpcprefix="/" + --ws + --ws.addr="0.0.0.0" + --ws.api="eth,net,web3,debug,txpool,personal,admin" + --ws.rpcprefix="/" + --networkid=${GETH_NETWORK_ID} + --netrestrict="172.16.254.0/28" networks: - tethys + geth-rpc-3-sidecar: + container_name: geth-rpc-3-sidecar + image: 41north/tethys-sidecar:dev + depends_on: + - nats + - geth-rpc-3 + networks: + - tethys + restart: on-failure + command: + - eth + environment: + NATS_URL: ns://nats:4222 + WEB3_URL: ws://geth-rpc-3:8546 + WEB3_CONNECTION_TYPE: ConnectionTypeManaged + WEB3_CLIENT_ID: alchemy + proxy: + container_name: proxy image: 41north/tethys-proxy:dev - restart: unless-stopped depends_on: - nats networks: - tethys ports: - "8080:8080" + restart: on-failure command: - eth - --log-level=debug environment: NATS_URL: ns://nats:4222 - ETH_NETWORK_ID: 11155111 # sepolia - ETH_CHAIN_ID: 11155111 + ETH_NETWORK_ID: 1214 + ETH_CHAIN_ID: 1214 diff --git a/flake.lock b/flake.lock index e9d2088..59da12a 100644 --- a/flake.lock +++ b/flake.lock @@ -23,6 +23,71 @@ "type": "github" } }, + "devshell_2": { + "inputs": { + "flake-utils": [ + "ethereum-nix", + "fu" + ], + "nixpkgs": [ + "ethereum-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660811669, + "narHash": "sha256-V6lmsaLNFz41myppL0yxglta92ijkSvpZ+XVygAh+bU=", + "owner": "numtide", + "repo": "devshell", + "rev": "c2feacb46ee69949124c835419861143c4016fb5", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "ethereum-nix": { + "inputs": { + "devshell": "devshell_2", + "flake-compat": "flake-compat", + "fu": "fu", + "fup": "fup", + "nixlib": "nixlib", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1662562629, + "narHash": "sha256-GhX78DQergDxcu/0dfzyui2FxfYUzEJOU7HAyTMSvxM=", + "owner": "41north", + "repo": "ethereum.nix", + "rev": "3e9cda89270bd4552c7344b9ed0d18e49853108c", + "type": "github" + }, + "original": { + "owner": "41north", + "repo": "ethereum.nix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1659877975, @@ -38,13 +103,64 @@ "type": "github" } }, + "fu": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "fup": { + "inputs": { + "flake-utils": [ + "ethereum-nix", + "fu" + ] + }, + "locked": { + "lastModified": 1657226504, + "narHash": "sha256-GIYNjuq4mJlFgqKsZ+YrgzWm0IpA4axA3MCrdKYj7gs=", + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "2bf0f91643c2e5ae38c1b26893ac2927ac9bd82a", + "type": "github" + }, + "original": { + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "type": "github" + } + }, + "nixlib": { + "locked": { + "lastModified": 1661648408, + "narHash": "sha256-EYTUe3i0qJB02yV87ohQjSL0VXIGEyFjfYqtJX09KWo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "d199f9f8cab305f23fa3928aea84d37c53fd675a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1661336769, - "narHash": "sha256-5Sf9tMd1Jdm+lTBGspbQ4kEoYCDKpUhEVAZHRcm6mGU=", + "lastModified": 1661353537, + "narHash": "sha256-1E2IGPajOsrkR49mM5h55OtYnU0dGyre6gl60NXKITE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "03428dbaaa23d6bf458770907b0927b377c873a8", + "rev": "0e304ff0d9db453a4b230e9386418fd974d5804a", "type": "github" }, "original": { @@ -55,6 +171,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1662096612, + "narHash": "sha256-R+Q8l5JuyJryRPdiIaYpO5O3A55rT+/pItBrKcy7LM4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "21de2b973f9fee595a7a1ac4693efff791245c34", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1645655918, "narHash": "sha256-ZfbEFRW7o237+A1P7eTKhXje435FCAoe0blj2n20Was=", @@ -69,11 +201,36 @@ } }, "pre-commit-hooks": { + "inputs": { + "flake-utils": [ + "ethereum-nix", + "fu" + ], + "nixpkgs": [ + "ethereum-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660830093, + "narHash": "sha256-HUhx3a82C7bgp2REdGFeHJdhEAzMGCk3V8xIvfBqg1I=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "8cb8ea5f1c7bc2984f460587fddd5f2e558f6eb8", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "pre-commit-hooks_2": { "inputs": { "flake-utils": [ "flake-utils" ], - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 1660830093, @@ -92,9 +249,10 @@ "root": { "inputs": { "devshell": "devshell", + "ethereum-nix": "ethereum-nix", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "pre-commit-hooks": "pre-commit-hooks" + "nixpkgs": "nixpkgs_2", + "pre-commit-hooks": "pre-commit-hooks_2" } } }, diff --git a/flake.nix b/flake.nix index 83b7f26..6203e05 100644 --- a/flake.nix +++ b/flake.nix @@ -5,21 +5,29 @@ substituters = [ "https://cache.nixos.org" "https://nix-community.cachix.org" + "https://pre-commit-hooks.cachix.org" + "https://ethereum-nix.cachix.org" ]; trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc=" + "ethereum-nix.cachix.org-1:mpmQuO1myAs3CXDBLh8uQy4QDFtemaDKLD4UKmVjByE=" ]; }; inputs = { + # sources + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + ethereum-nix.url = "github:41north/ethereum.nix"; + + # utilities devshell = { url = "github:numtide/devshell"; inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; flake-utils.url = "github:numtide/flake-utils"; - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; pre-commit-hooks = { url = "github:cachix/pre-commit-hooks.nix"; inputs.flake-utils.follows = "flake-utils"; @@ -30,6 +38,7 @@ self, devshell, nixpkgs, + ethereum-nix, flake-utils, pre-commit-hooks, ... @@ -42,10 +51,11 @@ inherit system; overlays = [ devshell.overlay + ethereum-nix.overlays.default (import ./nix/overlays) - (import ./nix/pkgs) ]; }; + ethereumPkgs = ethereum-nix.packages.${system}; inherit (pkgs) dockerTools buildGoModule; inherit (pkgs.stdenv) isLinux; @@ -66,24 +76,11 @@ formatter = pkgWithCategory "formatters"; util = pkgWithCategory "utils"; in { - checks = { - format = - pkgs.runCommandNoCC "treefmt" { - nativeBuildInputs = linters; - } '' - # keep timestamps so that treefmt is able to detect mtime changes - cp --no-preserve=mode --preserve=timestamps -r ${self} source - cd source - HOME=$TMPDIR treefmt --fail-on-change - touch $out - ''; - }; - # nix build .# packages = let vendorSha256 = "sha256-JEBEjjiDRwyNb9woG0QEqbpBXQf0TPeSLrt57trIxXQ="; in - flattenTree rec { + rec { tethys-proxy = buildGoApp { inherit vendorSha256; name = "tethys-proxy"; @@ -112,16 +109,19 @@ }; }; + # nix develop devShells.default = mkShell { # TODO: Not recognized properly, research why # inherit (self.checks.${system}.pre-commit-check) shellHook; packages = with pkgs; [ + (lib.hiPrio ethereumPkgs.prysm) # https://github.com/prysmaticlabs/prysm delve # https://github.com/go-delve/delve go_1_19 # https://go.dev/ go-ethereum # https://geth.ethereum.org/ gotools # https://go.googlesource.com/tools + hivemind # https://github.com/DarthSim/hivemind jq # https://stedolan.github.io/jq/ just # https://github.com/casey/just nats-server # https://github.com/nats-io/nats-server @@ -172,5 +172,19 @@ drv = self.packages.tethys-sidecar; }; }; + + # nix flake check + checks = { + format = + pkgs.runCommandNoCC "treefmt" { + nativeBuildInputs = linters; + } '' + # keep timestamps so that treefmt is able to detect mtime changes + cp --no-preserve=mode --preserve=timestamps -r ${self} source + cd source + HOME=$TMPDIR treefmt --fail-on-change + touch $out + ''; + }; }); } diff --git a/nix/pkgs/avalanche-cli/default.nix b/nix/pkgs/avalanche-cli/default.nix deleted file mode 100644 index 4b8c861..0000000 --- a/nix/pkgs/avalanche-cli/default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ - lib, - buildGoModule, - fetchFromGitHub, -}: -buildGoModule rec { - pname = "avalanche-cli"; - version = "0.1.3"; - - src = fetchFromGitHub { - owner = "ava-labs"; - repo = pname; - rev = "v${version}"; - sha256 = "sha256-duqAq8TooAqKt24gyurwva8y7YPZ7/58DzjZRGgy598="; - }; - - vendorSha256 = "sha256-6bVpPDZ1Eilc8nDnPbvmdqzxACij67a7+FxUz8M+ctk="; - - doCheck = true; - - ldflags = ["-s" "-w"]; - - meta = with lib; { - homepage = "https://github.com/ava-labs/avalanche-cli"; - description = "Avalanche CLI is a command line tool that gives developers access to everything Avalanche"; - license = licenses.bsd3; - maintainers = with maintainers; [aldoborrero]; - }; -} diff --git a/nix/pkgs/avalanche-network-runner/default.nix b/nix/pkgs/avalanche-network-runner/default.nix deleted file mode 100644 index 89824aa..0000000 --- a/nix/pkgs/avalanche-network-runner/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - lib, - buildGoModule, - fetchFromGitHub, -}: -buildGoModule rec { - pname = "avalanche-network-runner"; - version = "1.1.0"; - - src = fetchFromGitHub { - owner = "ava-labs"; - repo = pname; - rev = "v${version}"; - sha256 = "sha256-ZSjEn4qQk9kl+pcMwVxj23SPU5ncpxBqrkCYC15bl2I="; - }; - - vendorSha256 = "sha256-nEGd40WIPakt0pWGppXVCffl9k1r80xA0Yr64KzxTjM="; - - doCheck = true; - - ldflags = ["-s" "-w"]; - - subPackages = ["cmd/avalanche-network-runner"]; - - meta = with lib; { - homepage = "https://github.com/ava-labs/avalanche-network-runner"; - description = "Tool to run and interact with an Avalanche network locally"; - license = licenses.bsd3; - maintainers = with maintainers; [aldoborrero]; - }; -} diff --git a/nix/pkgs/avalanche-subnet-cli/default.nix b/nix/pkgs/avalanche-subnet-cli/default.nix deleted file mode 100644 index 03e7c77..0000000 --- a/nix/pkgs/avalanche-subnet-cli/default.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ - lib, - buildGoModule, - fetchFromGitHub, - libusb1, -}: -# TODO: Solve compilation issue related to Zondax HID. See the following: -# - https://gitlab.com/thorchain/thornode/-/issues/1250 -# - https://github.com/karalabe/hid/issues/27 -# -# Alternative approach would be to use this forked version: -# - https://github.com/dolmen-go/hid/commit/ae6e6ef1b126c15a70fcededd7d39499b17864f5 -# -# But that implies updating several tooling related to Avalanche: -# $ go mod why -m github.com/zondax/hid -# # github.com/zondax/hid -# github.com/ava-labs/subnet-cli/internal/key -# github.com/ava-labs/avalanche-ledger-go -# github.com/zondax/ledger-go -# github.com/zondax/hid -# -buildGoModule rec { - pname = "subnet-cli"; - # version = "0.0.2"; - version = "206ed3a24a3db06a223ef0e6e064c0852a5789ca"; - - src = fetchFromGitHub { - # owner = "ava-labs"; - owner = "aldoborrero"; - repo = pname; - rev = "${version}"; - # sha256 = "sha256-fBmHy4KHHM9KPkffc/2JvuPZ9QpIjx7xAWhAjTWdwRg="; - sha256 = "sha256-XBWjcD68OXEaobEuodD/FxDMxUzmsU84r4Tr4eB+7Q0="; - }; - - # vendorSha256 = "sha256-3wQaUOBrfjsp8Bcih8wCqNzGcI3F9bbxU0O0CuQdCGc="; - vendorSha256 = "sha256-ykgWHP/G0+MX6xguEhbN7BGxaZd2XSh0Srt7B3aYN3c="; - - # E2E tests fails - doCheck = false; - - buildInputs = [libusb1]; - - ldflags = ["-s" "-w"]; - - meta = with lib; { - homepage = "https://github.com/ava-labs/subnet-cli"; - description = "A command-line interface to manage Avalanche Subnets"; - license = licenses.bsd3; - maintainers = with maintainers; [aldoborrero]; - platforms = platforms.linux; - }; -} diff --git a/nix/pkgs/avalanchego/default.nix b/nix/pkgs/avalanchego/default.nix deleted file mode 100644 index 8802369..0000000 --- a/nix/pkgs/avalanchego/default.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ - lib, - buildGoModule, - fetchFromGitHub, -}: -buildGoModule rec { - pname = "avalanchego"; - version = "1.7.13"; - - src = fetchFromGitHub { - owner = "ava-labs"; - repo = pname; - rev = "v${version}"; - sha256 = "sha256-Rjg+dHd6MxHy+ZQcPIx18VCzIvxqP3crvU9nF6DG8rs="; - }; - - vendorSha256 = "sha256-aaWCj3bucb81P3GjspOiFgUOoL2bygy2lmwmnG/W2a8="; - - doCheck = true; - - ldflags = [ - "-s" - "-w" - "-X github.com/ava-labs/avalanchego/version.GitCommit=${src.rev}" - ]; - - postInstall = '' - # Build directory should have this structure: - # See: https://github.com/ava-labs/avalanchego/blob/acd07505cd701dbd3832ca7aa301865fc0737839/config/config.go#L84 - # - # build - # ├── avalanchego (the binary from compiling the app directory) - # └── plugins - # └── evm - mkdir -p $out/build/plugins - - # Store bin inside build/ folder - mv $out/bin/main $out/build/${pname} - - # For now, we symlink, but the idea is to give support to different plugins - ln -s $out/build/${pname} $out/bin/${pname} - ''; - - subPackages = ["main/main.go"]; - - meta = with lib; { - homepage = "https://www.avax.network/"; - description = "Go implementation of an Avalanche node"; - license = licenses.bsd3; - maintainers = with maintainers; [aldoborrero]; - }; -} diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix deleted file mode 100644 index f5ba24b..0000000 --- a/nix/pkgs/default.nix +++ /dev/null @@ -1,15 +0,0 @@ -self: super: let - inherit (self.pkgs) callPackage; -in { - # https://github.com/ava-labs/avalanchego/ - avalanchego = callPackage ./avalanchego {}; - - # https://github.com/ava-labs/avalanche-cli - avalanche-cli = callPackage ./avalanche-cli {}; - - # https://github.com/ava-labs/avalanche-network-runner - avalanche-network-runner = callPackage ./avalanche-network-runner {}; - - # https://github.com/ava-labs/subnet-cli - avalanche-subnet-cli = callPackage ./avalanche-subnet-cli {}; -} diff --git a/nix/pkgs/prysm/default.nix b/nix/pkgs/prysm/default.nix deleted file mode 100644 index 2c71294..0000000 --- a/nix/pkgs/prysm/default.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ - lib, - buildGoModule, - fetchFromGitHub, -}: -buildGoModule rec { - pname = "prysm"; - version = "3.0.0"; - - src = fetchFromGitHub { - owner = "prysmaticlabs"; - repo = pname; - rev = "v${version}"; - sha256 = "sha256-Rjg+dHd6MxHy+ZQcPIx18VCzIvxqP3crvU9nF6DG8rs="; - }; - - vendorSha256 = "sha256-aaWCj3bucb81P3GjspOiFgUOoL2bygy2lmwmnG/W2a8="; - - doCheck = false; - - ldflags = [ - "-s" - "-w" - "-X github.com/ava-labs/avalanchego/version.GitCommit=${src.rev}" - ]; - - postInstall = '' - # Build directory should have this structure: - # See: https://github.com/ava-labs/avalanchego/blob/acd07505cd701dbd3832ca7aa301865fc0737839/config/config.go#L84 - # - # build - # ├── avalanchego (the binary from compiling the app directory) - # └── plugins - # └── evm - mkdir -p $out/build/plugins - - # Store bin inside build/ folder - mv $out/bin/main $out/build/${pname} - - # For now, we symlink, but the idea is to give support to different plugins - ln -s $out/build/${pname} $out/bin/${pname} - ''; - - subPackages = ["main/main.go"]; - - meta = with lib; { - homepage = "https://www.avax.network/"; - description = "Go implementation of an Avalanche node"; - license = licenses.bsd3; - maintainers = with maintainers; [aldoborrero]; - }; -} diff --git a/procfile/configs/prysm/genesis.ssz b/procfile/configs/prysm/genesis.ssz new file mode 100644 index 0000000..3edfc0a Binary files /dev/null and b/procfile/configs/prysm/genesis.ssz differ