Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit Requeues/Retries #26

Merged
52 commits merged into from
Mar 11, 2024
Merged
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
73e3e0e
AsyncTxStrategy should do one of the following during execute: raise …
derekpierre Mar 1, 2024
013279c
Adjust strategies to accomodate latest paradigm for execute i.e. retu…
derekpierre Mar 1, 2024
9c2ec6e
Adjust existing strategy tests since None can now be returned from ex…
derekpierre Mar 1, 2024
39b4b36
Update timeout strategy logging.
derekpierre Mar 3, 2024
cf88810
Update speedup strategy calcs to use math.ceil instead of round
derekpierre Mar 3, 2024
1c01980
Move from a fixed max tip to a max tip factor based on the current su…
derekpierre Mar 4, 2024
352f74a
Simplify legacy transaction speedup logic.
derekpierre Mar 4, 2024
0be4f52
Add tests for constructor parameters and legacy tx speed up functiona…
derekpierre Mar 4, 2024
c023dea
Update logging of gas conditions.
derekpierre Mar 4, 2024
979f3f9
Better annotations about what the strategy is doing.
derekpierre Mar 4, 2024
9589151
Don't modify tx nonce as part of strategy.
derekpierre Mar 4, 2024
b66f5af
Fix outdated comment about value of warn factor.
derekpierre Mar 4, 2024
bf13194
Clean up logging logic since old_tip, old_max_fee may or may not be p…
derekpierre Mar 4, 2024
f7bd316
Add tests for eip1559 transaction speedup.
derekpierre Mar 4, 2024
699d38f
Rename speed up strategy; while the rate value is fixed the updates a…
derekpierre Mar 4, 2024
3755667
Use constant instead of "maxPriorityFeePerGas".
derekpierre Mar 4, 2024
16c2ed3
Use constant for minimum required speedup increase percentage.
derekpierre Mar 4, 2024
1c67055
Use a max between a low default value and warn factor calc in case ti…
derekpierre Mar 4, 2024
f8cf36b
Add todo about best way of setting a cap on the speedup strategy.
derekpierre Mar 4, 2024
1f1fb28
Use reactor to determine when hook is called instead of repeatedly ca…
derekpierre Mar 4, 2024
abb8555
Add TODO to determine whether strategies can be overriden.
derekpierre Mar 4, 2024
5491a6e
Update logging category for monitor when no longer tracking tx.
derekpierre Mar 5, 2024
2a9c0b5
Use enable/disabling of auto mining for better testing.
derekpierre Mar 5, 2024
436ce64
Fix nonce logging message for strategies.
derekpierre Mar 5, 2024
c7851ae
Add the ability to update the tracker's active pending tx after a retry.
derekpierre Mar 5, 2024
7e647c0
Ensure that "from" value in tx params matches/equals signer.
derekpierre Mar 5, 2024
283ba70
Make __fire reusable by both broadcast and strategize - it is now lim…
derekpierre Mar 5, 2024
bd27cbf
Add tests to ensure that strategies are employed when a tx hasn't alr…
derekpierre Mar 5, 2024
25ad0b5
Add testing for "from" tx parameter handling when a tx is being queued.
derekpierre Mar 6, 2024
adac77d
Add test for strategies which do not make updates to parameters.
derekpierre Mar 6, 2024
dc6cda3
Add testing statements to ensure that the broadcast hook is also call…
derekpierre Mar 6, 2024
28f67f4
txhash is not optionally returned from __fire - either it is or an ex…
derekpierre Mar 6, 2024
a7eff18
Potential specialized handling of error cases when firing a tx; this …
derekpierre Mar 6, 2024
9ea695c
Commonize check for recoverable type of error after calling sendRawTr…
derekpierre Mar 6, 2024
f42264d
Insufficient funds is really a special case and its own exception, no…
derekpierre Mar 6, 2024
9013c0d
Fix firing of hook with only ordered args.
derekpierre Mar 6, 2024
f5ecc5a
Add test for unrecoverable errors encoutered when trying to broadcast…
derekpierre Mar 6, 2024
4905e07
Add test for recoverable errors encoutered when trying to broadcast a…
derekpierre Mar 7, 2024
d695078
Add test for unrecoverable errors encoutered when trying to retry a tx.
derekpierre Mar 7, 2024
e000b64
Retry failures should be treated differently than broadcast failures.…
derekpierre Mar 7, 2024
b744a93
Make methods on TxTracker public instead of protected.
derekpierre Mar 7, 2024
431462e
Use a counter for tracking number of requeue attempts for failed txs …
derekpierre Mar 7, 2024
290fd65
Use a counter for tracking number of failed retry attempts when using…
derekpierre Mar 7, 2024
5c42f80
Update existing tests given limits on requeue/retry (redo) attempts.
derekpierre Mar 7, 2024
189b2dd
Add test for exceeding retries when encountering a broadcast error.
derekpierre Mar 7, 2024
f4670ac
Add additional assertions for the requeue counter in existing tests.
derekpierre Mar 7, 2024
c370dea
Existing retry test cleanup.
derekpierre Mar 7, 2024
f59aa74
Add test for exceeding retries when encountering retry errors.
derekpierre Mar 7, 2024
86734c3
Ensure that retry_failure_counter is cleared for all exit cases fault…
derekpierre Mar 7, 2024
190ed94
Rename constant to _MAX_REDO_ATTEMPTS.
derekpierre Mar 7, 2024
f820474
Add TODO.
derekpierre Mar 7, 2024
a2ea01c
Track num requeues and num retries directly on FutureTx and PendingTx…
derekpierre Mar 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Insufficient funds is really a special case and its own exception, no…
…t a subclass.

It is also not needed as a extra strategy (at least for now), since it is encountered during firing to txs.
It may/may not be considered a fault so left the Fault.INSUFFICIENT_FUNDS enum for now.
More to be explored in a future issue/PR.
derekpierre committed Mar 6, 2024

Verified

This commit was signed with the committer’s verified signature.
derekpierre Derek Pierre
commit f42264d8efa76680ee7f1d6e85eed15cd47b9339
7 changes: 2 additions & 5 deletions atxm/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from enum import Enum

from web3.types import PendingTx, RPCError, TxReceipt
from web3.types import PendingTx, TxReceipt


class Fault(Enum):
@@ -13,9 +13,6 @@ class Fault(Enum):
# Strategy has been running for too long
TIMEOUT = "timeout"

# Transaction has been capped and subsequently timed out
PAUSE = "pause"

# Transaction reverted
REVERT = "revert"

@@ -26,7 +23,7 @@ class Fault(Enum):
INSUFFICIENT_FUNDS = "insufficient_funds"


class InsufficientFunds(RPCError):
class InsufficientFunds(Exception):
"""raised when a transaction exceeds the spending cap"""


2 changes: 0 additions & 2 deletions atxm/machine.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@
from atxm.strategies import (
AsyncTxStrategy,
ExponentialSpeedupStrategy,
InsufficientFundsPause,
TimeoutStrategy,
)
from atxm.tracker import _TxTracker
@@ -97,7 +96,6 @@ class _Machine(StateMachine):
_BLOCK_SAMPLE_SIZE = 10_000 # blocks

STRATEGIES: List[Type[AsyncTxStrategy]] = [
InsufficientFundsPause,
TimeoutStrategy,
ExponentialSpeedupStrategy,
]
20 changes: 0 additions & 20 deletions atxm/strategies.py
Original file line number Diff line number Diff line change
@@ -64,26 +64,6 @@ def execute(self, pending: PendingTx) -> Optional[TxParams]:
raise NotImplementedError


class InsufficientFundsPause(AsyncTxStrategy):
"""Pause strategy for pending transactions."""

_NAME = "insufficient-funds"

def execute(self, pending: PendingTx) -> Optional[TxParams]:
balance = self.w3.eth.get_balance(pending.params["from"])
if balance == 0:
self.log.warn(
f"Insufficient funds for transaction #{pending.params['nonce']}"
)
raise TransactionFaulted(
tx=pending,
fault=Fault.INSUFFICIENT_FUNDS,
message="Insufficient funds",
)
# log.warn(f"Insufficient funds for transaction #{pending.params['nonce']}")
return None


class TimeoutStrategy(AsyncTxStrategy):
"""Timeout strategy for pending transactions."""