agent0.core.hyperdrive.crash_report
Utilities for executing agents on Hyperdrive devnet.
Submodules
Functions
Build the trade result object when a crash happens. |
|
|
Helper function for getting anvil dump state. |
|
Log a crash report for a hyperdrive transaction. |
Create a new logging file handler with CRITICAL log level for hyperdrive crash reporting. |
|
Runs known error checks and adds information to trade result. |
Package Contents
- agent0.core.hyperdrive.crash_report.build_crash_trade_result(exception: Exception, interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, account: eth_account.signers.local.LocalAccount | None = None, wallet: agent0.core.hyperdrive.HyperdriveWallet | None = None, policy: agent0.core.hyperdrive.policies.HyperdriveBasePolicy | None = None, trade_object: agent0.core.base.Trade[agent0.core.hyperdrive.HyperdriveMarketAction] | None = None, additional_info: dict[str, Any] | None = None, pool_state: agent0.ethpy.hyperdrive.state.PoolState | None = None) agent0.core.hyperdrive.agent.TradeResult
Build the trade result object when a crash happens.
- Parameters:
exception (Exception) – The exception that was thrown
interface (HyperdriveReadInterface) – An interface for Hyperdrive with contracts deployed on any chain with an RPC url.
account (LocalAccount | None, optional.) – The LocalAccount object that made the trade. If None, won’t report the agent.
wallet (HyperdriveWallet | None, optional) – The agent’s wallet. If None, won’t report the wallet.
policy (HyperdriveBasePolicy | None, optional) – The agent’s policy. If None, won’t report the policy.
trade_object (Trade[HyperdriveMarketAction] | None, optional) – A trade provided by the LocalAccount. If None, won’t report the trade object.
additional_info (dict[str, Any] | None, optional) – Additional information used for crash reporting, optional
pool_state (PoolState | None, optional) – The pool state for crash reporting. If none, will get the current pool state from the interface.
- Returns:
The trade result object.
- Return type:
- agent0.core.hyperdrive.crash_report.get_anvil_state_dump(web3: web3.Web3) str | None
Helper function for getting anvil dump state.
- Parameters:
web3 (Web3) – Web3 provider object.
- Returns:
Returns the anvil state as a string, or None if it failed.
- Return type:
str | None
- agent0.core.hyperdrive.crash_report.log_hyperdrive_crash_report(trade_result: agent0.core.hyperdrive.agent.TradeResult, log_level: int | None = None, crash_report_stdout_summary: bool = True, crash_report_to_file: bool = True, crash_report_file_prefix: str | None = None, log_to_rollbar: bool = False, rollbar_log_level_threshold: int | None = None, rollbar_log_prefix: str | None = None, rollbar_data: dict | None = None, rollbar_log_filter_func: Callable[[Exception], bool] | None = None, additional_info: dict | None = None) None
Log a crash report for a hyperdrive transaction.
- Parameters:
trade_result (TradeResult) – The trade result object that stores all crash information.
log_level (int | None, optional) – The logging level for this crash report. Defaults to critical.
crash_report_stdout_summary (bool, optional) – Whether to print a summary of the crash report to stdout (if True), or print out the full report (if False). Defaults to True.
crash_report_to_file (bool, optional) – Whether or not to save the crash report to a file. Defaults to True.
crash_report_file_prefix (str | None, optional) – Optional prefix to append a string to the crash report filename. The filename defaults to the timestamp of the report.
log_to_rollbar (bool, optional) – If enabled, logs errors to the rollbar service. Defaults to False.
rollbar_log_level_threshold (int | None, optional) – Threshold for logging to rollbar. Defaults to DEBUG.
rollbar_log_prefix (str | None, optional) – The prefix to prepend to rollbar exception messages
rollbar_data (dict | None, optional) – Optional dictionary of data to use for the the rollbar report. If not provided, will default to logging all of the crash report to rollbar.
rollbar_log_filter_func (Callable[[Exception], bool] | None, optional) – A function that filters exceptions to log to rollbar. The function should return True for exceptions that should be filtered from rollbar logging. Defaults to logging all exceptions.
additional_info (dict | None, optional) – Optional dictionary of additional data to include in the crash report.
- agent0.core.hyperdrive.crash_report.setup_hyperdrive_crash_report_logging(log_format_string: str | None = None) None
Create a new logging file handler with CRITICAL log level for hyperdrive crash reporting.
In the future, a custom log level could be used specific to crash reporting.
- Parameters:
log_format_string (str, optional) – Logging format described in string format.
- agent0.core.hyperdrive.crash_report.check_for_known_errors(trade_result: agent0.core.hyperdrive.TradeResult, interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface) agent0.core.hyperdrive.TradeResult
Runs known error checks and adds information to trade result.
- Parameters:
trade_result (TradeResult) – The trade result object from trading.
interface (HyperdriveReadInterface) – The hyperdrive read interface to compute expected balances for trades.
- Returns:
A modified trade_result that has a custom exception argument message prepended
- Return type: