From c5581321e6b35e2e646a806a260138319b03d671 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 25 Feb 2024 06:51:32 +0200 Subject: [PATCH] Add ethereum tasks. --- crawlers/deploy/deploy.bash | 33 +++++++++++++++++ crawlers/deploy/ethereum-metadata.service | 11 ++++++ crawlers/deploy/ethereum-metadata.timer | 9 +++++ crawlers/deploy/ethereum-state-clean.service | 11 ++++++ crawlers/deploy/ethereum-state-clean.timer | 9 +++++ crawlers/deploy/ethereum-state.service | 11 ++++++ crawlers/deploy/ethereum-state.timer | 9 +++++ .../state_crawler/jobs/ethereum-jobs.json | 35 +++++++++++++++++++ 8 files changed, 128 insertions(+) create mode 100644 crawlers/deploy/ethereum-metadata.service create mode 100644 crawlers/deploy/ethereum-metadata.timer create mode 100644 crawlers/deploy/ethereum-state-clean.service create mode 100644 crawlers/deploy/ethereum-state-clean.timer create mode 100644 crawlers/deploy/ethereum-state.service create mode 100644 crawlers/deploy/ethereum-state.timer create mode 100644 crawlers/mooncrawl/mooncrawl/state_crawler/jobs/ethereum-jobs.json diff --git a/crawlers/deploy/deploy.bash b/crawlers/deploy/deploy.bash index 138abc0cd..2ab07d374 100755 --- a/crawlers/deploy/deploy.bash +++ b/crawlers/deploy/deploy.bash @@ -36,6 +36,12 @@ ETHEREUM_TRENDING_TIMER_FILE="ethereum-trending.timer" ETHEREUM_MISSING_SERVICE_FILE="ethereum-missing.service" ETHEREUM_MISSING_TIMER_FILE="ethereum-missing.timer" ETHEREUM_MOONWORM_CRAWLER_SERVICE_FILE="ethereum-moonworm-crawler.service" +ETHEREUM_STATE_SERVICE_FILE="ethereum-state.service" +ETHEREUM_STATE_TIMER_FILE="ethereum-state.timer" +ETHEREUM_STATE_CLEAN_SERVICE_FILE="ethereum-state-clean.service" +ETHEREUM_STATE_CLEAN_TIMER_FILE="ethereum-state-clean.timer" +ETHEREUM_METADATA_SERVICE_FILE="ethereum-metadata.service" +ETHEREUM_METADATA_TIMER_FILE="ethereum-metadata.timer" ETHEREUM_ORANGE_DAO_REPORTS_TOKENONOMICS_SERVICE_FILE="ethereum-orange-dao-reports-tokenonomics.service" ETHEREUM_ORANGE_DAO_TOKENONOMICS_TIMER_FILE="ethereum-orange-dao-reports-tokenonomics.timer" ETHEREUM_HISTORICAL_CRAWL_TRANSACTIONS_SERVICE_FILE="ethereum-historical-crawl-transactions.service" @@ -221,6 +227,33 @@ cp "${SCRIPT_DIR}/${ETHEREUM_MOONWORM_CRAWLER_SERVICE_FILE}" "/home/ubuntu/.conf XDG_RUNTIME_DIR="/run/user/1000" systemctl --user daemon-reload XDG_RUNTIME_DIR="/run/user/1000" systemctl --user restart --no-block "${ETHEREUM_MOONWORM_CRAWLER_SERVICE_FILE}" +echo +echo +echo -e "${PREFIX_INFO} Replacing existing Ethereum state service and timer with: ${ETHEREUM_STATE_SERVICE_FILE}, ${ETHEREUM_STATE_TIMER_FILE}" +chmod 644 "${SCRIPT_DIR}/${ETHEREUM_STATE_SERVICE_FILE}" "${SCRIPT_DIR}/${ETHEREUM_STATE_TIMER_FILE}" +cp "${SCRIPT_DIR}/${ETHEREUM_STATE_SERVICE_FILE}" "/home/ubuntu/.config/systemd/user/${ETHEREUM_STATE_SERVICE_FILE}" +cp "${SCRIPT_DIR}/${ETHEREUM_STATE_TIMER_FILE}" "/home/ubuntu/.config/systemd/user/${ETHEREUM_STATE_TIMER_FILE}" +XDG_RUNTIME_DIR="/run/user/1000" systemctl --user daemon-reload +XDG_RUNTIME_DIR="/run/user/1000" systemctl --user restart --no-block "${ETHEREUM_STATE_TIMER_FILE}" + +echo +echo +echo -e "${PREFIX_INFO} Replacing existing Ethereum state clean service and timer with: ${ETHEREUM_STATE_CLEAN_SERVICE_FILE}, ${ETHEREUM_STATE_CLEAN_TIMER_FILE}" +chmod 644 "${SCRIPT_DIR}/${ETHEREUM_STATE_CLEAN_SERVICE_FILE}" "${SCRIPT_DIR}/${ETHEREUM_STATE_CLEAN_TIMER_FILE}" +cp "${SCRIPT_DIR}/${ETHEREUM_STATE_CLEAN_SERVICE_FILE}" "/home/ubuntu/.config/systemd/user/${ETHEREUM_STATE_CLEAN_SERVICE_FILE}" +cp "${SCRIPT_DIR}/${ETHEREUM_STATE_CLEAN_TIMER_FILE}" "/home/ubuntu/.config/systemd/user/${ETHEREUM_STATE_CLEAN_TIMER_FILE}" +XDG_RUNTIME_DIR="/run/user/1000" systemctl --user daemon-reload +XDG_RUNTIME_DIR="/run/user/1000" systemctl --user restart --no-block "${ETHEREUM_STATE_CLEAN_TIMER_FILE}" + +echo +echo +echo -e "${PREFIX_INFO} Replacing existing Ethereum metadata service and timer with: ${ETHEREUM_METADATA_SERVICE_FILE}, ${ETHEREUM_METADATA_TIMER_FILE}" +chmod 644 "${SCRIPT_DIR}/${ETHEREUM_METADATA_SERVICE_FILE}" "${SCRIPT_DIR}/${ETHEREUM_METADATA_TIMER_FILE}" +cp "${SCRIPT_DIR}/${ETHEREUM_METADATA_SERVICE_FILE}" "/home/ubuntu/.config/systemd/user/${ETHEREUM_METADATA_SERVICE_FILE}" +cp "${SCRIPT_DIR}/${ETHEREUM_METADATA_TIMER_FILE}" "/home/ubuntu/.config/systemd/user/${ETHEREUM_METADATA_TIMER_FILE}" +XDG_RUNTIME_DIR="/run/user/1000" systemctl --user daemon-reload +XDG_RUNTIME_DIR="/run/user/1000" systemctl --user restart --no-block "${ETHEREUM_METADATA_TIMER_FILE}" + echo echo echo -e "${PREFIX_INFO} Replacing existing Ethereum Orange DAO reports tokenonomics service and timer with: ${ETHEREUM_ORANGE_DAO_REPORTS_TOKENONOMICS_SERVICE_FILE}, ${ETHEREUM_ORANGE_DAO_TOKENONOMICS_TIMER_FILE}" diff --git a/crawlers/deploy/ethereum-metadata.service b/crawlers/deploy/ethereum-metadata.service new file mode 100644 index 000000000..f5e8fdd4e --- /dev/null +++ b/crawlers/deploy/ethereum-metadata.service @@ -0,0 +1,11 @@ +[Unit] +Description=Execute metadata crawler +After=network.target + +[Service] +Type=oneshot +WorkingDirectory=/home/ubuntu/moonstream/crawlers/mooncrawl +EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env +ExecStart=/home/ubuntu/moonstream-env/bin/python -m mooncrawl.metadata_crawler.cli crawl --blockchain ethereum +CPUWeight=60 +SyslogIdentifier=ethereum-metadata \ No newline at end of file diff --git a/crawlers/deploy/ethereum-metadata.timer b/crawlers/deploy/ethereum-metadata.timer new file mode 100644 index 000000000..e2217ae08 --- /dev/null +++ b/crawlers/deploy/ethereum-metadata.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Execute Ethereum metadata crawler each 10m + +[Timer] +OnBootSec=20s +OnUnitActiveSec=60m + +[Install] +WantedBy=timers.target diff --git a/crawlers/deploy/ethereum-state-clean.service b/crawlers/deploy/ethereum-state-clean.service new file mode 100644 index 000000000..6a7c179b6 --- /dev/null +++ b/crawlers/deploy/ethereum-state-clean.service @@ -0,0 +1,11 @@ +[Unit] +Description=Execute state clean labels crawler +After=network.target + +[Service] +Type=oneshot +WorkingDirectory=/home/ubuntu/moonstream/crawlers/mooncrawl +EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env +ExecStart=/home/ubuntu/moonstream-env/bin/python -m mooncrawl.state_crawler.cli --access-id "${NB_CONTROLLER_ACCESS_ID}" clean-state-labels --blockchain ethereum -N 10000 +CPUWeight=60 +SyslogIdentifier=ethereum-state-clean \ No newline at end of file diff --git a/crawlers/deploy/ethereum-state-clean.timer b/crawlers/deploy/ethereum-state-clean.timer new file mode 100644 index 000000000..dd00a0ebf --- /dev/null +++ b/crawlers/deploy/ethereum-state-clean.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Execute Ethereum state clean labels crawler each 25m + +[Timer] +OnBootSec=50s +OnUnitActiveSec=25m + +[Install] +WantedBy=timers.target diff --git a/crawlers/deploy/ethereum-state.service b/crawlers/deploy/ethereum-state.service new file mode 100644 index 000000000..6a68961ac --- /dev/null +++ b/crawlers/deploy/ethereum-state.service @@ -0,0 +1,11 @@ +[Unit] +Description=Execute state crawler +After=network.target + +[Service] +Type=oneshot +WorkingDirectory=/home/ubuntu/moonstream/crawlers/mooncrawl +EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env +ExecStart=/home/ubuntu/moonstream-env/bin/python -m mooncrawl.state_crawler.cli --access-id "${NB_CONTROLLER_ACCESS_ID}" crawl-jobs --moonstream-token "${MOONSTREAM_PUBLIC_QUERIES_DATA_ACCESS_TOKEN}" --blockchain ethereum --jobs-file /home/ubuntu/moonstream/crawlers/mooncrawl/mooncrawl/state_crawler/jobs/ethereum-jobs.json +CPUWeight=60 +SyslogIdentifier=ethereum-state \ No newline at end of file diff --git a/crawlers/deploy/ethereum-state.timer b/crawlers/deploy/ethereum-state.timer new file mode 100644 index 000000000..7db2aa54a --- /dev/null +++ b/crawlers/deploy/ethereum-state.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Execute Ethereum state crawler each 10m + +[Timer] +OnBootSec=15s +OnUnitActiveSec=10m + +[Install] +WantedBy=timers.target diff --git a/crawlers/mooncrawl/mooncrawl/state_crawler/jobs/ethereum-jobs.json b/crawlers/mooncrawl/mooncrawl/state_crawler/jobs/ethereum-jobs.json new file mode 100644 index 000000000..08e85f975 --- /dev/null +++ b/crawlers/mooncrawl/mooncrawl/state_crawler/jobs/ethereum-jobs.json @@ -0,0 +1,35 @@ +[ + { + "type": "function", + "stateMutability": "view", + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256", + "value": { + "type": "function", + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "address": "0xe1dC516B1486Aba548eecD2947A11273518434a4", + "inputs": [] + } + } + ], + "name": "tokenURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "address": "0xe1dC516B1486Aba548eecD2947A11273518434a4" + } +] \ No newline at end of file