Exemplo n.º 1
0
    def test_check_eta(self, mcd: DssDeployment, keeper: ChiefKeeper):
        print_out("test_check_eta")

        keeper.initial_query()

        etas = keeper.database.db.get(doc_id=3)['upcoming_etas']
        hat = mcd.ds_chief.get_hat()
        verify([hat.address], etas, 1)

        keeper.check_eta()

        # Confirm that the spell was casted and that the database was updated
        assert DSSSpell(mcd.web3, Address(hat)).done() == True
        etas = keeper.database.db.get(doc_id=3)['upcoming_etas']
        verify([], etas, 0)
Exemplo n.º 2
0
    def test_check_hat(self, mcd: DssDeployment, keeper: ChiefKeeper,
                       guy_address: Address):
        print_out("test_check_hat")

        # Confirm the hat with the most approval is unchanged
        oldHat = mcd.ds_chief.get_hat()
        keeper.check_hat()
        newHat = mcd.ds_chief.get_hat()
        assert oldHat.address == newHat.address

        # Move the 2000 MKR vote from the last spell in test_database.py to new spell
        self.spell = DSSSpell.deploy(mcd.web3, mcd.pause.address,
                                     mcd.vat.address)
        assert mcd.ds_chief.vote_yays([self.spell.address.address
                                       ]).transact(from_address=guy_address)

        keeper.check_hat()

        # Confirm that the hat has been lifted
        newerHat = mcd.ds_chief.get_hat()
        assert newerHat.address == self.spell.address.address

        # Confirm that the spell was scheduled
        assert self.spell.eta() != 0
Exemplo n.º 3
0
    def test_check_eta_receipt(self, mcd: DssDeployment, keeper: ChiefKeeper,
                               simpledb: SimpleDatabase, our_address: Address):
        print_out("test_check_eta_receipt")

        # clear out anything that came before
        keeper.check_hat()
        keeper.check_eta()

        # Give 1000 MKR to our_address
        amount = Wad.from_number(5000)
        mint_mkr(mcd.mkr, our_address, amount)
        assert mcd.mkr.balance_of(our_address) == amount

        # Lock MKR in DS-Chief
        assert mcd.mkr.approve(
            mcd.ds_chief.address).transact(from_address=our_address)
        assert mcd.ds_chief.lock(amount).transact(from_address=our_address)

        # Deploy spell
        spell = DSSBadSpell.deploy(mcd.web3)

        # Vote 5000 mkr on the spell
        assert mcd.ds_chief.vote_yays([spell.address.address
                                       ]).transact(from_address=our_address)

        keeper.check_hat()

        block = mcd.web3.eth.blockNumber
        simpledb.update_db_etas(block)

        hat = mcd.ds_chief.get_hat()

        etas = keeper.database.db.get(doc_id=3)['upcoming_etas']
        verify([hat.address], etas, 1)

        keeper.check_eta()

        # Confirm that the spell was casted and that the database was updated
        # For the DSSBadSpell, the cast() call in non-conformant.  Usually
        # cast() will flip done to true, but in this broken spell it's modified
        # to not set done to true so we can test this bug and prevent
        # regressions.
        assert DSSBadSpell(mcd.web3, Address(hat)).done() == False
        etas = keeper.database.db.get(doc_id=3)['upcoming_etas']
        verify([], etas, 0)
Exemplo n.º 4
0
 def test_check_deployment(self, mcd: DssDeployment, keeper: ChiefKeeper):
     print_out("test_check_deployment")
     keeper.check_deployment()
Exemplo n.º 5
0
    with open(key_file, "w") as file:
        file.write(json.dumps(encrypt_pk))
    with open(pass_file, "w") as file:
        file.write(password)

    ETH_KEY = f'key_file={key_file},pass_file={pass_file}'

    required_params = [
        ('--rpc-host', EnvParam(env_name="RPC_HOST", cast_type=str, required=True).value),
        ('--network', NETWORK),
        ('--eth-from', str(ETH_FROM)),
        ('--eth-key', str(ETH_KEY)),
        ('--dss-deployment-file', str(os.path.join(BASE_PATH, 'addresses', f'{NETWORK}-addresses.json'))),
    ]

    optional_params = [
        ('--rpc-timeout', EnvParam(env_name="RPC_TIMEOUT", cast_type=int, required=False).value),
        ('--chief-deployment-block', EnvParam(env_name="FROM_BLOCK", cast_type=int, required=False, default=10310344).value),

        ('--ethgasstation-api-key', EnvParam(env_name="ETHGASSTATION_API_KEY", cast_type=str, required=False).value),
        ('--fixed-gas-price', EnvParam(env_name="FIXED_GAS_PRICE", cast_type=float, required=False).value),

        ('--max-errors', EnvParam(env_name="MAX_ERRORS", cast_type=int, required=False).value),
        # ('--debug', True),
    ]

    keeper_args = generate_params_line(required_params) + generate_params_line(optional_params)
    keeper_args += generate_params_line(telegram_params)
    ChiefKeeper(keeper_args).main()
    print(f"ChiefKeeper {keeper_args}")
Exemplo n.º 6
0
from chief_keeper.chief_keeper import ChiefKeeper

RPC_HOST = "https://kovan.infura.io/v3/683836c8b9384898a9f99d483ae389bc"
NETWORK = "kovan"

ETH_FROM = "0xC0CCab7430aEc0C30E76e1dA596263C3bdD82932"
KEY_FILE = "/home/captain/development/dss-deploy-scripts/keystore.json"
PASS_FILE = "/home/captain/development/dss-deploy-scripts/p.pass"

ADDRESSES_FILE = "/home/captain/development/makerdao_python/chief-keeper/addresses/kovan-addresses.json"

if __name__ == '__main__':
    flip_args = [
        '--rpc-host',
        RPC_HOST,
        '--eth-from',
        ETH_FROM,
        '--network',
        NETWORK,
        '--eth-key',
        f'key_file={KEY_FILE},pass_file={PASS_FILE}',
        '--dss-deployment-file',
        ADDRESSES_FILE,
        '--chief-deployment-block',
        '17707858',
        # '--debug'
    ]
    ChiefKeeper(flip_args).main()
Exemplo n.º 7
0
def keeper(mcd: DssDeployment, keeper_address: Address) -> ChiefKeeper:
    keeper = ChiefKeeper(
        args=args(f"--eth-from {keeper_address} --network testnet"),
        web3=mcd.web3)
    assert isinstance(keeper, ChiefKeeper)
    return keeper
Exemplo n.º 8
0
    PASS_FILE = "/PATH/TO/PASS/FILE.pass"

    ADDRESSES_FILE = "PATH/TO/ADDRESS/FILE.json"

elif NETWORK.lower() == "mainnet":
    RPC_HOST = "https://mainnet.infura.io/v3/*******"
    ETH_FROM = "0x000000000000000000000000000"
    KEY_FILE = "/PATH/TO/KEY/FILE.json"
    PASS_FILE = "/PATH/TO/PASS/FILE.pass"

    ADDRESSES_FILE = "PATH/TO/ADDRESS/FILE.json"
else:
    raise Exception('NOT SUPPORTED NETWORK')

if __name__ == '__main__':
    start_args = [
        '--rpc-host',
        RPC_HOST,
        '--eth-from',
        ETH_FROM,
        '--network',
        NETWORK,
        '--eth-key',
        f'key_file={KEY_FILE},pass_file={PASS_FILE}',
        '--dss-deployment-file',
        ADDRESSES_FILE,
        # '--chief-deployment-block', '1',
        # '--debug'
    ]
    ChiefKeeper(start_args).main()