diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 8660d2f..8ed961d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -22,8 +22,8 @@ jobs: run: | sudo apt-get update sudo apt-get -y install python3-pip jshon jq virtualenv pkg-config openssl libssl-dev autoconf libtool libsecp256k1-dev - pip install $(cat requirements.txt $(find lib -name requirements.txt | sort) | sort | uniq | sed 's/ *== */==/g') - pip install -r requirements-dev.txt + pip3 install -r requirements.txt + pip3 install -r requirements-dev.txt - name: Run tests run: ./test.sh diff --git a/.gitmodules b/.gitmodules index 760c089..3d546e3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,4 @@ [submodule "lib/pymaker"] path = lib/pymaker - url = https://github.com/makerdao/pymaker.git -[submodule "lib/pygasprice-client"] - path = lib/pygasprice-client - url = https://github.com/makerdao/pygasprice-client.git -[submodule "lib/auction-keeper"] - path = lib/auction-keeper - url = https://github.com/makerdao/auction-keeper.git + url = https://github.com/makerdao/pymaker + branch = EIP-1559 diff --git a/bin/chief-keeper b/bin/chief-keeper index 3ce59bc..417aad8 100755 --- a/bin/chief-keeper +++ b/bin/chief-keeper @@ -4,6 +4,6 @@ dir="$(dirname "$0")"/.. . $dir/_virtualenv/bin/activate || exit -export PYTHONPATH=$PYTHONPATH:$dir:$dir/lib/pymaker:$dir/lib/auction-keeper:$dir/lib/pygasprice-client +export PYTHONPATH=$PYTHONPATH:$dir:$dir/lib/pymaker exec python3 -m chief_keeper.chief_keeper $@ diff --git a/chief_keeper/chief_keeper.py b/chief_keeper/chief_keeper.py index 3d76c15..6f6dd75 100644 --- a/chief_keeper/chief_keeper.py +++ b/chief_keeper/chief_keeper.py @@ -18,6 +18,7 @@ import argparse import logging import sys +import requests import time import types @@ -28,13 +29,11 @@ from pymaker import Address, web3_via_http from pymaker.util import is_contract_at -from pymaker.gas import DefaultGasPrice +from pymaker.gas import GeometricGasPrice from pymaker.keys import register_keys from pymaker.lifecycle import Lifecycle from pymaker.deployment import DssDeployment -from auction_keeper.gas import DynamicGasPrice - HEALTHCHECK_FILE_PATH = "/tmp/health.log" @@ -54,6 +53,7 @@ class ChiefKeeper: logger = logging.getLogger("chief-keeper") + def __init__(self, args: list, **kwargs): """Pass in arguements assign necessary variables/objects and instantiate other Classes""" @@ -62,15 +62,15 @@ def __init__(self, args: list, **kwargs): parser.add_argument( "--rpc-host", type=str, - default="https://localhost:8545", - help="JSON-RPC host:port (default: 'localhost:8545')", + required=True, + help="JSON-RPC host url", ) parser.add_argument( "--rpc-timeout", type=int, - default=10, - help="JSON-RPC timeout (in seconds, default: 10)", + default=60, + help="JSON-RPC timeout (in seconds, default: 60)", ) parser.add_argument( @@ -121,16 +121,17 @@ def __init__(self, args: list, **kwargs): ) parser.add_argument( - "--ethgasstation-api-key", + "--blocknative-api-key", type=str, default=None, - help="ethgasstation API key", + help="Blocknative API key", ) + parser.add_argument( "--gas-initial-multiplier", type=str, default=1.0, - help="ethgasstation API key", + help="gas multiplier", ) parser.add_argument( "--gas-reactive-multiplier", @@ -145,20 +146,16 @@ def __init__(self, args: list, **kwargs): parser.set_defaults(cageFacilitated=False) self.arguments = parser.parse_args(args) - self.web3: Web3 = ( - kwargs["web3"] - if "web3" in kwargs - else web3_via_http( - endpoint_uri=self.arguments.rpc_host, - timeout=self.arguments.rpc_timeout, - http_pool_size=100, - ) - ) + self.web3 = kwargs['web3'] if 'web3' in kwargs else Web3(HTTPProvider(endpoint_uri=self.arguments.rpc_host, + request_kwargs={"timeout": self.arguments.rpc_timeout})) self.web3.eth.defaultAccount = self.arguments.eth_from register_keys(self.web3, self.arguments.eth_key) self.our_address = Address(self.arguments.eth_from) + isConnected = self.web3.isConnected() + self.logger.info(f'web3 isConntected is: {isConnected}') + if self.arguments.dss_deployment_file: self.dss = DssDeployment.from_json( web3=self.web3, @@ -168,7 +165,7 @@ def __init__(self, args: list, **kwargs): self.dss = DssDeployment.from_network( web3=self.web3, network=self.arguments.network ) - + self.logger.info(f"DS-Chief: {self.dss.ds_chief.address}") self.deployment_block = self.arguments.chief_deployment_block self.max_errors = self.arguments.max_errors @@ -176,17 +173,12 @@ def __init__(self, args: list, **kwargs): self.confirmations = 0 - # Create dynamic gas strategy - if self.arguments.ethgasstation_api_key: - self.gas_price = DynamicGasPrice(self.arguments, self.web3) - else: - self.gas_price = DefaultGasPrice() - logging.basicConfig( format="%(asctime)-15s %(levelname)-8s %(message)s", level=(logging.DEBUG if self.arguments.debug else logging.INFO), ) + def main(self): """Initialize the lifecycle and enter into the Keeper Lifecycle controller. @@ -227,11 +219,34 @@ def initial_query(self): self.logger.info(result) + def get_initial_tip(self, arguments) -> int: + try: + result = requests.get( + url='https://api.blocknative.com/gasprices/blockprices', + headers={ + 'Authorization': arguments.blocknative_api_key + }, + timeout=15 + ) + if result.ok and result.content: + confidence_80_tip = result.json().get('blockPrices')[0]['estimatedPrices'][3]['maxPriorityFeePerGas'] + self.logger.info(f"Using Blocknative 80% confidence tip {confidence_80_tip}") + self.logger.info(int(confidence_80_tip * GeometricGasPrice.GWEI)) + return int(confidence_80_tip * GeometricGasPrice.GWEI) + except Exception as e: + logging.error(str(e)) + + return int(1.5 * GeometricGasPrice.GWEI) + + @healthy def process_block(self): """Callback called on each new block. If too many errors, terminate the keeper. This is the entrypoint to the Keeper's monitoring logic """ + isConnected = self.web3.isConnected() + self.logger.info(f'web3 isConntected is: {isConnected}') + if self.errors >= self.max_errors: self.lifecycle.terminate() else: @@ -258,6 +273,13 @@ def check_hat(self): contender, highestApprovals = hat, hatApprovals + gas_strategy = GeometricGasPrice( + web3=self.web3, + initial_price=None, + initial_tip=self.get_initial_tip(self.arguments), + every_secs=180 + ) + for yay in yays: contenderApprovals = self.dss.ds_chief.get_approvals(yay) if contenderApprovals > highestApprovals: @@ -269,7 +291,7 @@ def check_hat(self): self.logger.info(f"Old hat ({hat}) with Approvals {hatApprovals}") self.logger.info(f"New hat ({contender}) with Approvals {highestApprovals}") self.dss.ds_chief.lift(Address(contender)).transact( - gas_price=self.gas_price + gas_strategy=gas_strategy ) else: self.logger.info(f"Current hat ({hat}) with Approvals {hatApprovals}") @@ -290,7 +312,7 @@ def check_hat(self): # Functional with DSSSpells but not DSSpells (not compatiable with DSPause) if spell.done() == False and self.database.get_eta_inUnix(spell) == 0: self.logger.info(f"Scheduling spell ({yay})") - spell.schedule().transact(gas_price=self.gas_price) + spell.schedule().transact(gas_strategy=gas_strategy) else: self.logger.warning( f"Spell is an EOA or 0x0, so keeper will not attempt to call schedule()" @@ -321,9 +343,15 @@ def check_eta(self): ) if spell is not None: + gas_strategy = GeometricGasPrice( + web3=self.web3, + initial_price=None, + initial_tip=self.get_initial_tip(self.arguments), + every_secs=180 + ) if spell.done() == False: self.logger.info(f"Casting spell ({spell.address.address})") - receipt = spell.cast().transact(gas_price=self.gas_price) + receipt = spell.cast().transact(gas_strategy=gas_strategy) if receipt is None or receipt.successful == True: del etas[yay] diff --git a/chief_keeper/database/db_mainnet.json b/chief_keeper/database/db_mainnet.json index fa9785c..a031eec 100644 --- a/chief_keeper/database/db_mainnet.json +++ b/chief_keeper/database/db_mainnet.json @@ -1 +1 @@ -{"_default": {"1": {"last_block_checked_for_yays": 11641950}, "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"]}, "3": {"upcoming_etas": {}}}} \ No newline at end of file +{"_default": {"1": {"last_block_checked_for_yays": 18428527}, "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 diff --git a/chief_keeper/database/db_testnet.json b/chief_keeper/database/db_testnet.json index d5fd254..5c53a6a 100644 --- a/chief_keeper/database/db_testnet.json +++ b/chief_keeper/database/db_testnet.json @@ -1 +1 @@ -{"_default": {"1": {"last_block_checked_for_yays": 296}, "2": {"yays": ["0x0000000000000000000000000000000000000000", "0x50FF810797f75f6bfbf2227442e0c961a8562F4C", "0x57Da1B8F38A5eCF91E9FEe8a047DF0F0A88716A1", "0x976e4aE9c4BeECe1BA2C6bA354D6775A7a80E506", "0x8DebBDdc6909c62F16aA59F55b6D3c04162aFcfA", "0x72c740550e51bd3F4F8eBe4Ec300269608618abE"]}, "3": {"upcoming_etas": {}}}} \ No newline at end of file +{"_default": {"1": {"last_block_checked_for_yays": 303}, "2": {"yays": ["0x0000000000000000000000000000000000000000", "0x50FF810797f75f6bfbf2227442e0c961a8562F4C", "0x57Da1B8F38A5eCF91E9FEe8a047DF0F0A88716A1", "0x976e4aE9c4BeECe1BA2C6bA354D6775A7a80E506", "0x8DebBDdc6909c62F16aA59F55b6D3c04162aFcfA", "0x72c740550e51bd3F4F8eBe4Ec300269608618abE"]}, "3": {"upcoming_etas": {}}}} \ No newline at end of file diff --git a/deploy/production/chief-keeper.yaml b/deploy/production/chief-keeper.yaml index 9532889..aede278 100644 --- a/deploy/production/chief-keeper.yaml +++ b/deploy/production/chief-keeper.yaml @@ -67,6 +67,10 @@ env: type: parameterStore name: secret-pass-mainnet parameter_name: /eks/maker-prod/chief-keeper/secret-pass-mainnet + BLOCKNATIVE_API_KEY: + type: parameterStore + name: blocknative-api-key + parameter_name: /eks/maker-prod/chief-keeper/blocknative-api-key externalSecrets: clusterSecretStoreName: maker-prod livenessProbe: diff --git a/install-dev.sh b/install-dev.sh index 6f57a25..f7e0a3c 100755 --- a/install-dev.sh +++ b/install-dev.sh @@ -1,15 +1,31 @@ -#!/usr/bin/env bash +#!/bin/bash -cd "$(dirname "$0")" +if [[ "$0" = "$BASH_SOURCE" ]]; then + echo "Needs to be run using source: . install-dev.sh" -set -e +else + rm -rf _virtualenv + virtualenv _virtualenv -p /usr/local/bin/python3.8 + VENVPATH="_virtualenv/bin/activate" + if [[ $# -eq 1 ]]; then + if [ -d $1 ]; then + VENVPATH="$1/bin/activate" + else + echo "Virtual environment $1 not found" + return + fi -rm -rf _virtualenv -virtualenv --python=`which python3` _virtualenv -. _virtualenv/bin/activate + elif [ -d "_virtualenv" ]; then + VENVPATH="_virtualenv/bin/activate" -# The advantage of using this method, in contrary to just calling `pip3 install -r requirements.txt` several times, -# is that it can detect different versions of the same dependency and fail with a "Double requirement given" -# error message. -pip install $(cat requirements.txt $(find lib -name requirements.txt | sort) | sort | uniq | sed 's/ *== */==/g') -pip install $(cat lib/pymaker/requirements-dev.txt $(find lib -name lib/pymaker/requirements-dev.txt | sort) | sort | uniq | sed 's/ *== */==/g') + elif [-d "env"]; then + VENVPATH="env/bin/activate" + fi + + echo "Activating virtual environment $VENVPATH" + source "$VENVPATH" +fi + +python --version +pip3 install -r requirements.txt +pip3 install -r requirements-dev.txt diff --git a/install.sh b/install.sh index 0d4ec43..abdba3b 100755 --- a/install.sh +++ b/install.sh @@ -1,14 +1,31 @@ -#!/usr/bin/env bash +#!/bin/bash -cd "$(dirname "$0")" -set -e +if [[ "$0" = "$BASH_SOURCE" ]]; then + echo "Needs to be run using source: . install.sh" -rm -rf _virtualenv -virtualenv --python=`which python3` _virtualenv -. _virtualenv/bin/activate +else + rm -rf _virtualenv + virtualenv _virtualenv -p /usr/local/bin/python3.8 + VENVPATH="_virtualenv/bin/activate" + if [[ $# -eq 1 ]]; then + if [ -d $1 ]; then + VENVPATH="$1/bin/activate" + else + echo "Virtual environment $1 not found" + return + fi -# The advantage of using this method, in contrary to just calling `pip3 install -r requirements.txt` several times, -# is that it can detect different versions of the same dependency and fail with a "Double requirement given" -# error message. -pip install $(cat requirements.txt $(find lib -name requirements.txt | sort) | sort | uniq | sed 's/ *== */==/g') + elif [ -d "_virtualenv" ]; then + VENVPATH="_virtualenv/bin/activate" + + elif [-d "env"]; then + VENVPATH="env/bin/activate" + fi + + echo "Activating virtual environment $VENVPATH" + source "$VENVPATH" +fi + +python --version +pip3 install -r requirements.txt diff --git a/lib/auction-keeper b/lib/auction-keeper deleted file mode 160000 index c6424e5..0000000 --- a/lib/auction-keeper +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c6424e54aac55d94001c622b10e211b0492607fb diff --git a/lib/pygasprice-client b/lib/pygasprice-client deleted file mode 160000 index 864ab10..0000000 --- a/lib/pygasprice-client +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 864ab101b2889e38fe552adaca7b860637583e7b diff --git a/lib/pymaker b/lib/pymaker index 79d90f1..e076ef3 160000 --- a/lib/pymaker +++ b/lib/pymaker @@ -1 +1 @@ -Subproject commit 79d90f1db276eed64f0d9d112e7699014eeb8583 +Subproject commit e076ef37de796ef3d7f24bb2ae84ae3350f4e9d2 diff --git a/requirements-dev.txt b/requirements-dev.txt index 205960d..1f32a27 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,3 +7,4 @@ pytest-mock == 1.6.3 pytest-timeout == 1.2.1 asynctest == 0.13.0 Sphinx == 1.6.2 +codecov == 2.1.13 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 8af937d..722b516 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,9 @@ -web3 == 5.12.0 +jsonnet == 0.9.5 +requests == 2.22.0 +web3 == 5.23.0 eth-abi == 2.1.1 -eth-utils == 1.9.0 +eth-utils<2.0.0,>=1.9.5 eth-testrpc == 1.3.0 rlp == 1.2.0 tinydb == 3.15.2 +pytz == 2017.3 \ No newline at end of file diff --git a/run-chief-keeper.sh b/run-chief-keeper.sh index 6933bc8..6dde961 100755 --- a/run-chief-keeper.sh +++ b/run-chief-keeper.sh @@ -46,4 +46,5 @@ exec $dir/bin/chief-keeper \ --network "${BLOCKCHAIN_NETWORK}" \ --eth-from "${ETH_FROM_ADDRESS}" \ --eth-key "${ETH_ACCOUNT_KEY}" \ - --chief-deployment-block "${CHIEF_DEPLOYMENT_BLOCK}" + --chief-deployment-block "${CHIEF_DEPLOYMENT_BLOCK}" \ + --blocknative-api-key "${BLOCKNATIVE_API_KEY}" diff --git a/test.sh b/test.sh index dfc5670..5bd8831 100755 --- a/test.sh +++ b/test.sh @@ -15,7 +15,7 @@ popd virtualenv --python=`which python3` _virtualenv . _virtualenv/bin/activate -PYTHONPATH=$PYTHONPATH:./lib/pymaker:./lib/auction-keeper:./lib/pygasprice-client py.test \ +PYTHONPATH=$PYTHONPATH:./lib/pymaker py.test \ -s \ --cov=chief_keeper \ --cov-report=term \ diff --git a/tests/conftest.py b/tests/conftest.py index 95feced..bbf7946 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -96,7 +96,7 @@ def mcd(web3) -> DssDeployment: @pytest.fixture(scope="session") def keeper(mcd: DssDeployment, keeper_address: Address) -> ChiefKeeper: - keeper = ChiefKeeper(args=args(f"--eth-from {keeper_address} --network testnet"), web3=mcd.web3) + keeper = ChiefKeeper(args=args(f"--eth-from {keeper_address} --network testnet --rpc-host https://localhost:8545"), web3=mcd.web3) assert isinstance(keeper, ChiefKeeper) return keeper