Пример #1
0
    def main(self):
        self.startup()

        pending_txes = get_pending_transactions(web3)
        pprint(
            list(
                map(lambda t: f"{t.name()} with gas {t.current_gas}",
                    pending_txes)))

        if len(pending_txes) > 0:
            while len(pending_txes) > 0:
                pending_txes[0].cancel(gas_price=increasing_gas)
                # After the synchronous cancel, wait to see if subsequent transactions get mined
                time.sleep(15)
                pending_txes = get_pending_transactions(web3)
        else:
            logging.info(
                f"No pending transactions were found; submitting {stuck_txes_to_submit}"
            )
            for i in range(1, stuck_txes_to_submit + 1):
                self._run_future(
                    weth.deposit(Wad(i)).transact_async(
                        gas_price=FixedGasPrice(int(0.4 * i * GWEI))))
            time.sleep(2)

        self.shutdown()
Пример #2
0
 def plunge(self):
     pending_txes = get_pending_transactions(self.web3)
     if len(pending_txes) > 0:
         while len(pending_txes) > 0:
             logging.warning(f"Cancelling first of {len(pending_txes)} pending transactions")
             pending_txes[0].cancel(gas_price=self.gas_price)
             # After the synchronous cancel, wait to see if subsequent transactions get mined
             time.sleep(28)
             pending_txes = get_pending_transactions(self.web3)
Пример #3
0
    async def test_recover_pending_tx(self, other_address):
        # given
        low_gas = FixedGasPrice(1)
        await self.token.transfer(other_address,
                                  Wad(5)).transact_async(gas_price=low_gas)
        await asyncio.sleep(0.5)

        # when
        pending = get_pending_transactions(self.web3)

        # and
        assert len(pending) == 1
        recovered: RecoveredTransact = pending[0]
        high_gas = FixedGasPrice(int(1 * FixedGasPrice.GWEI))
        recovered.cancel(high_gas)

        # then
        assert get_pending_transactions(self.web3) == []
Пример #4
0
 def plunge(self):
     """
     Method to automatically plunge any pending transactions on keeper startup
     """
     pending_txes = get_pending_transactions(self.web3, self.our_address)
     logging.info(f"There are {len(pending_txes)} pending transactions in the queue")
     if len(pending_txes) > 0:
         for index, tx in enumerate(pending_txes):
             logging.warning(f"Cancelling {index+1} of {len(pending_txes)} pending transactions")
             # Note this can raise a "Transaction nonce is too low" error, stopping the service.
             # This means one of the pending TXes was mined, and the service can be restarted to either resume
             # plunging or normal operation.
             tx.cancel(gas_price=self.gas_price)
Пример #5
0
    def test_nothing_pending(self):
        # given no pending transactions created by prior tests

        # then
        assert get_pending_transactions(self.web3) == []