From 422cb163baf03998dee18306de7bd2da82fec703 Mon Sep 17 00:00:00 2001 From: Jeannette Date: Tue, 7 Nov 2023 14:38:00 -0600 Subject: [PATCH] Remove virtualenv --- Dockerfile | 24 ++++-- chief_keeper/database/db_mainnet.json | 2 +- run-chief-keeper.sh | 101 +++++++++++++++++++------- 3 files changed, 94 insertions(+), 33 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0fd1a1c..df37a10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,26 @@ +# Use an official Python runtime as a parent image FROM python:3.8-buster +# Add user and group for running the application RUN groupadd -r keeper && useradd -d /home/keeper -m --no-log-init -r -g keeper keeper && \ - apt-get -y update && \ - apt-get -y install python3-pip jshon jq virtualenv pkg-config openssl libssl-dev autoconf libtool libsecp256k1-dev && \ + apt-get update -y && \ + apt-get install -y jshon jq pkg-config openssl libssl-dev autoconf libtool libsecp256k1-dev && \ apt-get clean && rm -rf /var/lib/apt/lists/* -COPY . /opt/keeper/chief-keeper - +# Set the working directory in the container to /opt/keeper/chief-keeper WORKDIR /opt/keeper/chief-keeper -RUN git submodule update --init --recursive && \ - pip3 install virtualenv && \ - bash /opt/keeper/chief-keeper/install.sh +# Copy the rest of the application's code into the container +COPY . . + +# Install submodules +RUN git submodule update --init --recursive +# Install any needed packages specified in requirements.txt +# First copy only the requirements.txt to leverage Docker cache +COPY requirements.txt ./ +RUN pip3 install --no-cache-dir -r requirements.txt + +# Run run-chief-keeper.sh when the container launches CMD ["./run-chief-keeper.sh"] + diff --git a/chief_keeper/database/db_mainnet.json b/chief_keeper/database/db_mainnet.json index d6870e6..dbc8aeb 100644 --- a/chief_keeper/database/db_mainnet.json +++ b/chief_keeper/database/db_mainnet.json @@ -1 +1 @@ -{"_default": {"1": {"last_block_checked_for_yays": 18472117}, "2": {"yays": ["0x2A8E8588ae9d420656c49C910C2c820450a01F95", "0xFc5154dc5F980A3377374864fbE7a25AFc9Fe5ED", "0xD8CAe22CDC75ab61Ec7663a355D043De4277dC1E", "0xa3F971B97E1e8d98061e58809748d525D8AE295F", "0x77bdCbD18A064B97a71F3982D6ae981EF32e72D8", "0x2EaCCAC62E9D9a55417c35df3491Ec6F6343e311", "0xd79E320fDF9a738E9ADa8C6644563c3E1923B33d", "0xcf50ef07DebcB608b8b1133A13bF5AC823E47D9D", "0xE3d9458cf864C9028363464c7D45C66078F54240", "0xAa0087F0AB8ffD4A8F72Bb1bb09EE7b046566412", "0x0aF27f917864a4f05D18CeeF22F0d23CD73C10aD", "0x74c63Bb8610C7a7538733ECf915Fa217605C01a5", "0xf282371EA8eFDE8e47D78131c3Af70a6e2A28617", "0xe9a7e8AB8e2b8118eC1f108a370b7151635D06B7", "0xeDc016ACE4618284F289696545760AC0dB5bc79B", "0x22E9B678daF00B41f2127837A521F92f18802674", "0x46e5E4502f99867405fC239Ca695f1569ef4d3e6", "0x3FfE82e0Ea5ABC48c3C4cA9ceF2F9C81515e800b", "0x899E41f14eE23BF3Dca12bDe066F35994DC4e7bc", "0x3Ef533927c4FE49B3dA53aC3241322eB98F9717d", "0xae220fa15DEd4e6e63310D2f6C8d3DFAaF4F8A1b", "0x6fBe6d79BD2aeEfA4B6929bD47babf236023902e", "0x15732a23db6A0D54E3240F72913950c8c9a64c20", "0xB81ddbFF61420A181bB725D5F06cA99486Bb4e6a", "0xD665104a2800FaDFd232961d718E2108e8ec6BDD", "0x3920f14096E89b1bc2f4Ebf3A847c913170a1F92", "0xeC17e6122578A6E5B92e904aD46b03Fe07568359", "0x28498dDD408001A7011DA2edE4136104e035f2F4", "0xBd144df1031f1718d50715e0ade8856C7b06AaE1", "0xB6b375aCebC0068F7414Cc6c81f4392d0760c845", "0x6fC17C824f3E39dF6D21b2740B676755E71466d6", "0xf8587266d56F3e3480F693a0AD2e36E6E2c12cDA", "0x5a53768b01AEb799572998819638C63c8EEEea52", "0xC1136F15C605222793F60E328FE3F01Ec2c3F264", "0xca988c4D38d562DDeDEbFb7a44ec5a72a6698f5c", "0xbD01665f3768D793DA1Ffc4DCD70114B31A3954C", "0x784e85ef0f6e05Ff5252629c2e2649c89bdC88Da", "0xE460E2588d8cb9c460F63Bd2f746724bD0e55Aa0", "0x25222057EF01A3BDe7F59d10695da6dAe42C531A", "0x74eD57e3c12Ee6Eec8E583BFFF77Ea9D33A602e2", "0x20B4a73B34Fb2893D60D24c1b3996cbC2664F7cC", "0xE75A8Ae8075425b4D2F8f53B55996afb9157D980", "0xaE071879962A36d338ed89Bb0fF61D0A5b8C6201", "0x31a5577D98251c6C08CAcfEE6faE2e2D7A040b50", "0x2bd13D445aD7a40c393FAA93b43b24AA35DcD973", "0xBA57238e70116fB61fdE07387c6dD79AebF92E5E", "0xA453B4C7BA03FBea2a1ddAD12Bb3Bc5dC41cEee8", "0x58339aB7f27e66768713aF28E8e539Ca56432423", "0x87471BEd520edf4B54E0091Ff754E3E69666A9D6", "0xceafE30A12d00D35beCdE807c5e360ce5124A750", "0xB5010b4bC4e506B933C2f0aca7B8214089167e33", "0x3d6F4c40A2C53964ddB4D63fBB50FA854e048499", "0x5abf3e4C8d144DB9d3603A76e524671040Aa4859", "0x38e13DaF8024f682deA2022c849152BbD9b071DF", "0x7a87C5dd42Fed47b85e23C3F5C02b735FD69A38F", "0xFd27AE89d4976Bb11d4FB7e0e215Eced997F13a6", "0xcD0E28B9DFCc1ee71d9D6834EF66C1E103E94B27", "0xa5e85cAC3Fb448E16699C97DA86124bD288017d6", "0x606395F1B167AA73134b8A2B34C25Bb7D0564920", "0xCa9f54957c61b58843628051561896d0557D42c3", "0x7aB726CdF93443302CC4c90e83cb7ce4210bb724", "0xf00Ad3314E08e0E8E713D8155E3c867580cD811b", "0x6571e4B3432e856CdA8fae95dB3e23B573019e8B", "0x3DcD037bB1D3A898f6CbbE136ae2e1959FF74e3c", "0x6E2850E425d89836F1B10256C2C9E23415dc47F2", "0x9F978435542Ee71e8b2E8f1f51bB808dCF307D41", "0x8794E3EAeBeEbdFD9d0C601753f7Cd377aC69280", "0xa3104Af92F7C996f7FD73F6b87F16bE420d76c71", "0x17bcD46C9f85888E6169C54336fe3E91c604F1D5", "0xe01F7E3Ac096904EaC6Ac4497Ad2ab96f647bA87", "0xeb1F2F9dA1E1f932Ab11bc00F70A5Cd3607ef628", "0xc0F05F0E3DA5ff76fEC6C3Def889103a3709bfbF", "0xde4000CB884B237eFBd6f793584701230E1c45B3", "0x73b474fE6ff6844222471bC4CFD4Bd7A518B16C4", "0x81A64CE48C01d252B90E3d5531D448e446Bf3e42", "0x45e33477CD5aB5CeFA708cd977c1e398061D61cD", "0x30899738762d84343f615DE62c8D1283Cc3364da", "0x79Ba240EDc34f81DD56Ff153470e2be3DA91e88a", "0x4C3c8aCA2758799D697Ce83e63fdcCe0D52b3cd9", "0x483574D869BC34D2131032e65a3114A901928E91", "0xe7BbC8Fea57A92fC307D650D78e5481B25ccedff", "0x1EAD8a37d189a67B1736020131d4890833cF9103", "0x414c6e043c8580cA077250045a1C04b4745ac236", "0x4436A797F8E1cD87F3c674865Bc3eA1474C3B0B2", "0x043c52c8ff76C088646c8d2630eDdF1A8e33bA4C", "0x168Da8AFc9D925456c087999ED0f8041a2b7DeFA", "0xFA635D9093C2dd637CF19d48Df6EA1DBde56DDB1", "0xF44113760c4f70aFeEb412C63bC713B13E6e202E", "0xF3aB5E963E7c09E205927b9ba498Bb09afe3BC22", "0x902f009d4dE4a7828284B04b364dD43F00E51A02", "0xF267EFDDA842539a2cAff990259395188a86b813", "0xDD4Aa99077C5e976AFc22060EEafBBd1ba34eae9", "0x94c19E029F5A1A115F3B99aD87da24D33E60A0E1", "0x333c0501182170c5002219380ded6b12C338E272", "0x7A87aCB1f92c50297239EF9B0Ef9387105Bd4Fc5", "0x0000000000000000000000000000000000000000", "0x58401b64CA6b91E346c87B057254F040990c4F98", "0x6b8b3993cFB253968894C8EcB430CaF2455b51Aa", "0x437F5aAF195C97a01f85e672bb8e371484D96C57", "0x3ee0C26aE7aa8cCc759e4Ee4f1E6F2C16220e5f6", "0xD3F96B8Ffbf21033F5A6210C6349598AAdBd1152", "0x2f34BB0FE10BCb5652390FD0bA3Af7879BcA4b62", "0xb242159a9182e7FE0b72Fc035b336cFE060381B3"]}, "3": {"upcoming_etas": {}}}} \ No newline at end of file +{"_default": {"1": {"last_block_checked_for_yays": 18522491}, "2": {"yays": ["0x2A8E8588ae9d420656c49C910C2c820450a01F95", "0xFc5154dc5F980A3377374864fbE7a25AFc9Fe5ED", "0xD8CAe22CDC75ab61Ec7663a355D043De4277dC1E", "0xa3F971B97E1e8d98061e58809748d525D8AE295F", "0x77bdCbD18A064B97a71F3982D6ae981EF32e72D8", "0x2EaCCAC62E9D9a55417c35df3491Ec6F6343e311", "0xd79E320fDF9a738E9ADa8C6644563c3E1923B33d", "0xcf50ef07DebcB608b8b1133A13bF5AC823E47D9D", "0xE3d9458cf864C9028363464c7D45C66078F54240", "0xAa0087F0AB8ffD4A8F72Bb1bb09EE7b046566412", "0x0aF27f917864a4f05D18CeeF22F0d23CD73C10aD", "0x74c63Bb8610C7a7538733ECf915Fa217605C01a5", "0xf282371EA8eFDE8e47D78131c3Af70a6e2A28617", "0xe9a7e8AB8e2b8118eC1f108a370b7151635D06B7", "0xeDc016ACE4618284F289696545760AC0dB5bc79B", "0x22E9B678daF00B41f2127837A521F92f18802674", "0x46e5E4502f99867405fC239Ca695f1569ef4d3e6", "0x3FfE82e0Ea5ABC48c3C4cA9ceF2F9C81515e800b", "0x899E41f14eE23BF3Dca12bDe066F35994DC4e7bc", "0x3Ef533927c4FE49B3dA53aC3241322eB98F9717d", "0xae220fa15DEd4e6e63310D2f6C8d3DFAaF4F8A1b", "0x6fBe6d79BD2aeEfA4B6929bD47babf236023902e", "0x15732a23db6A0D54E3240F72913950c8c9a64c20", "0xB81ddbFF61420A181bB725D5F06cA99486Bb4e6a", "0xD665104a2800FaDFd232961d718E2108e8ec6BDD", "0x3920f14096E89b1bc2f4Ebf3A847c913170a1F92", "0xeC17e6122578A6E5B92e904aD46b03Fe07568359", "0x28498dDD408001A7011DA2edE4136104e035f2F4", "0xBd144df1031f1718d50715e0ade8856C7b06AaE1", "0xB6b375aCebC0068F7414Cc6c81f4392d0760c845", "0x6fC17C824f3E39dF6D21b2740B676755E71466d6", "0xf8587266d56F3e3480F693a0AD2e36E6E2c12cDA", "0x5a53768b01AEb799572998819638C63c8EEEea52", "0xC1136F15C605222793F60E328FE3F01Ec2c3F264", "0xca988c4D38d562DDeDEbFb7a44ec5a72a6698f5c", "0xbD01665f3768D793DA1Ffc4DCD70114B31A3954C", "0x784e85ef0f6e05Ff5252629c2e2649c89bdC88Da", "0xE460E2588d8cb9c460F63Bd2f746724bD0e55Aa0", "0x25222057EF01A3BDe7F59d10695da6dAe42C531A", "0x74eD57e3c12Ee6Eec8E583BFFF77Ea9D33A602e2", "0x20B4a73B34Fb2893D60D24c1b3996cbC2664F7cC", "0xE75A8Ae8075425b4D2F8f53B55996afb9157D980", "0xaE071879962A36d338ed89Bb0fF61D0A5b8C6201", "0x31a5577D98251c6C08CAcfEE6faE2e2D7A040b50", "0x2bd13D445aD7a40c393FAA93b43b24AA35DcD973", "0xBA57238e70116fB61fdE07387c6dD79AebF92E5E", "0xA453B4C7BA03FBea2a1ddAD12Bb3Bc5dC41cEee8", "0x58339aB7f27e66768713aF28E8e539Ca56432423", "0x87471BEd520edf4B54E0091Ff754E3E69666A9D6", "0xceafE30A12d00D35beCdE807c5e360ce5124A750", "0xB5010b4bC4e506B933C2f0aca7B8214089167e33", "0x3d6F4c40A2C53964ddB4D63fBB50FA854e048499", "0x5abf3e4C8d144DB9d3603A76e524671040Aa4859", "0x38e13DaF8024f682deA2022c849152BbD9b071DF", "0x7a87C5dd42Fed47b85e23C3F5C02b735FD69A38F", "0xFd27AE89d4976Bb11d4FB7e0e215Eced997F13a6", "0xcD0E28B9DFCc1ee71d9D6834EF66C1E103E94B27", "0xa5e85cAC3Fb448E16699C97DA86124bD288017d6", "0x606395F1B167AA73134b8A2B34C25Bb7D0564920", "0xCa9f54957c61b58843628051561896d0557D42c3", "0x7aB726CdF93443302CC4c90e83cb7ce4210bb724", "0xf00Ad3314E08e0E8E713D8155E3c867580cD811b", "0x6571e4B3432e856CdA8fae95dB3e23B573019e8B", "0x3DcD037bB1D3A898f6CbbE136ae2e1959FF74e3c", "0x6E2850E425d89836F1B10256C2C9E23415dc47F2", "0x9F978435542Ee71e8b2E8f1f51bB808dCF307D41", "0x8794E3EAeBeEbdFD9d0C601753f7Cd377aC69280", "0xa3104Af92F7C996f7FD73F6b87F16bE420d76c71", "0x17bcD46C9f85888E6169C54336fe3E91c604F1D5", "0xe01F7E3Ac096904EaC6Ac4497Ad2ab96f647bA87", "0xeb1F2F9dA1E1f932Ab11bc00F70A5Cd3607ef628", "0xc0F05F0E3DA5ff76fEC6C3Def889103a3709bfbF", "0xde4000CB884B237eFBd6f793584701230E1c45B3", "0x73b474fE6ff6844222471bC4CFD4Bd7A518B16C4", "0x81A64CE48C01d252B90E3d5531D448e446Bf3e42", "0x45e33477CD5aB5CeFA708cd977c1e398061D61cD", "0x30899738762d84343f615DE62c8D1283Cc3364da", "0x79Ba240EDc34f81DD56Ff153470e2be3DA91e88a", "0x4C3c8aCA2758799D697Ce83e63fdcCe0D52b3cd9", "0x483574D869BC34D2131032e65a3114A901928E91", "0xe7BbC8Fea57A92fC307D650D78e5481B25ccedff", "0x1EAD8a37d189a67B1736020131d4890833cF9103", "0x414c6e043c8580cA077250045a1C04b4745ac236", "0x4436A797F8E1cD87F3c674865Bc3eA1474C3B0B2", "0x043c52c8ff76C088646c8d2630eDdF1A8e33bA4C", "0x168Da8AFc9D925456c087999ED0f8041a2b7DeFA", "0xFA635D9093C2dd637CF19d48Df6EA1DBde56DDB1", "0xF44113760c4f70aFeEb412C63bC713B13E6e202E", "0xF3aB5E963E7c09E205927b9ba498Bb09afe3BC22", "0x902f009d4dE4a7828284B04b364dD43F00E51A02", "0xF267EFDDA842539a2cAff990259395188a86b813", "0xDD4Aa99077C5e976AFc22060EEafBBd1ba34eae9", "0x94c19E029F5A1A115F3B99aD87da24D33E60A0E1", "0x333c0501182170c5002219380ded6b12C338E272", "0x7A87aCB1f92c50297239EF9B0Ef9387105Bd4Fc5", "0x0000000000000000000000000000000000000000", "0x58401b64CA6b91E346c87B057254F040990c4F98", "0x6b8b3993cFB253968894C8EcB430CaF2455b51Aa", "0x437F5aAF195C97a01f85e672bb8e371484D96C57", "0x3ee0C26aE7aa8cCc759e4Ee4f1E6F2C16220e5f6", "0xD3F96B8Ffbf21033F5A6210C6349598AAdBd1152", "0x2f34BB0FE10BCb5652390FD0bA3Af7879BcA4b62", "0xb242159a9182e7FE0b72Fc035b336cFE060381B3", "0xA6dFB3E92BBD3Ae9098fda9AE3DDE4c727ec618a", "0x77583dc3D6192D55eF642060e82Af1D7A34BC142"]}, "3": {"upcoming_etas": {}}}} \ No newline at end of file diff --git a/run-chief-keeper.sh b/run-chief-keeper.sh index 6dde961..e9d708d 100755 --- a/run-chief-keeper.sh +++ b/run-chief-keeper.sh @@ -1,46 +1,44 @@ #!/bin/bash -dir=`pwd` +#!/bin/bash + +# Set the current working directory to the location of this script +dir=$(dirname "$(readlink -f "$0")") -secret_paths=(${ETH_ACCOUNT_KEY//,/ }) +# Split ETH_ACCOUNT_KEY into an array based on comma separator +IFS=',' read -ra secret_paths <<< "${ETH_ACCOUNT_KEY}" -if [[ ! -f "$(echo ${secret_paths[0]} | awk -F'[=]' '{print $2}')" ]] && [[ ! -f "$(echo ${secret_paths[1]} | awk -F'[=]' '{print $2}')" ]] -then +# Check if the keystore files exist +if [[ ! -f "${secret_paths[0]}" ]] && [[ ! -f "${secret_paths[1]}" ]]; then echo "No keystore files found. Running this container locally requires keys and a secrets volume mapping, see DOCKER.md." - # get expected secret key paths - for secret in ${secret_paths[@]} - do + + # Get the expected secret key paths + for secret in "${secret_paths[@]}"; do if [[ $secret == *"key_file"* ]]; then - key_file_location=$(echo $secret | awk -F'[=]' '{print $2}') - fi - if [[ $secret == *"pass_file"* ]]; then - pass_file_location=$(echo $secret | awk -F'[=]' '{print $2}') + key_file_location=$(echo $secret | cut -d'=' -f2) + elif [[ $secret == *"pass_file"* ]]; then + pass_file_location=$(echo $secret | cut -d'=' -f2) fi done + # Write the secret key to file if provided if [[ -n "${SECRET_KEY}" ]]; then - touch ${key_file_location} - echo $SECRET_KEY | sed 's/\\"/\"/g' >> ${key_file_location} - else - echo "No secret key to write to file." + echo -n "${SECRET_KEY}" > "${key_file_location}" fi + + # Write the secret pass to file if provided if [[ -n "${SECRET_PASS}" ]]; then - touch pass_file_location - echo $SECRET_PASS >> ${pass_file_location} - else - echo "No secret pass to write to file." + echo -n "${SECRET_PASS}" > "${pass_file_location}" fi fi -if [[ -n "${RPC_HOST_TIMEOUT}" ]]; then - RPC_HOST_TIMEOUT=${RPC_HOST_TIMEOUT} -else - RPC_HOST_TIMEOUT=10 -fi +# Set a default RPC_HOST_TIMEOUT if not set +RPC_HOST_TIMEOUT="${RPC_HOST_TIMEOUT:-10}" -exec $dir/bin/chief-keeper \ +# Run the chief-keeper application +exec "${dir}/bin/chief-keeper" \ --rpc-host "${SERVER_ETH_RPC_HOST}" \ --rpc-timeout "${RPC_HOST_TIMEOUT}" \ --network "${BLOCKCHAIN_NETWORK}" \ @@ -48,3 +46,56 @@ exec $dir/bin/chief-keeper \ --eth-key "${ETH_ACCOUNT_KEY}" \ --chief-deployment-block "${CHIEF_DEPLOYMENT_BLOCK}" \ --blocknative-api-key "${BLOCKNATIVE_API_KEY}" + + + + + +# dir=`pwd` + +# secret_paths=(${ETH_ACCOUNT_KEY//,/ }) + +# if [[ ! -f "$(echo ${secret_paths[0]} | awk -F'[=]' '{print $2}')" ]] && [[ ! -f "$(echo ${secret_paths[1]} | awk -F'[=]' '{print $2}')" ]] +# then +# echo "No keystore files found. Running this container locally requires keys and a secrets volume mapping, see DOCKER.md." + +# # get expected secret key paths +# for secret in ${secret_paths[@]} +# do +# if [[ $secret == *"key_file"* ]]; then +# key_file_location=$(echo $secret | awk -F'[=]' '{print $2}') +# fi +# if [[ $secret == *"pass_file"* ]]; then +# pass_file_location=$(echo $secret | awk -F'[=]' '{print $2}') +# fi +# done + +# if [[ -n "${SECRET_KEY}" ]]; then +# touch ${key_file_location} +# echo $SECRET_KEY | sed 's/\\"/\"/g' >> ${key_file_location} +# else +# echo "No secret key to write to file." +# fi +# if [[ -n "${SECRET_PASS}" ]]; then +# touch pass_file_location +# echo $SECRET_PASS >> ${pass_file_location} +# else +# echo "No secret pass to write to file." +# fi + +# fi + +# if [[ -n "${RPC_HOST_TIMEOUT}" ]]; then +# RPC_HOST_TIMEOUT=${RPC_HOST_TIMEOUT} +# else +# RPC_HOST_TIMEOUT=10 +# fi + +# exec $dir/bin/chief-keeper \ +# --rpc-host "${SERVER_ETH_RPC_HOST}" \ +# --rpc-timeout "${RPC_HOST_TIMEOUT}" \ +# --network "${BLOCKCHAIN_NETWORK}" \ +# --eth-from "${ETH_FROM_ADDRESS}" \ +# --eth-key "${ETH_ACCOUNT_KEY}" \ +# --chief-deployment-block "${CHIEF_DEPLOYMENT_BLOCK}" \ +# --blocknative-api-key "${BLOCKNATIVE_API_KEY}"