degenbot.provider.alloy_errors¶
Translate Alloy (Rust) provider errors into degenbot-owned exceptions.
The Rust AlloyProvider flattens every non-timeout, non-connection RPC
error into a RuntimeError("Provider error: ...") — see the
ProviderError → PyErr conversion in rust/src/errors.rs, which loses
the structured JSON-RPC error data and keeps only code + a formatted
string. An alloy eth_call revert is therefore surfaced as a bare
RuntimeError.
That asymmetry is a real bug: probing code throughout the codebase
(degenbot.builders.type_resolution,
degenbot.aave.analysis) catches the provider-layer revert type to mean
“this method is not implemented by the contract.” Under the alloy backend a
reverted probe (e.g. factory() on a Curve pool, which has no such method)
propagated the bare RuntimeError and broke pool construction before the
Curve fallback in Bot.build_pool() could trigger.
This module restores parity at the adapter seam: an alloy eth_call revert
is re-raised as the degenbot-owned ContractLogicError
(an RpcError subclass) so probe sites that catch
RpcError behave identically across the Alloy and web3 backends. The web3
adapter performs the symmetric conversion at its own call/call_raw
seam (catching web3’s ContractLogicError and re-raising the degenbot type).
Note
Revert detection here is message-based because the Rust layer discards the
structured JSON-RPC error data before it crosses the FFI boundary. A
future Rust-side ProviderError::ExecutionReverted variant that
preserves error.data (the 0x08c379a0 / 0x4e487b71 revert
selectors, or the raw revert reason) would let this classification be
structural rather than string-based.
Module Contents¶
- degenbot.provider.alloy_errors.is_alloy_revert(exc: BaseException) bool¶
Return whether a Rust Alloy
RuntimeErrorrepresents an EVM revert.- Returns:
Trueonly ifexcis aRuntimeErrorwhose message carries a recognized revert marker;Falseotherwise (so genuine transport / server errors propagate unchanged).
- degenbot.provider.alloy_errors.alloy_revert_error(exc: RuntimeError, *, to: degenbot.types.chain.Address | str) degenbot.exceptions.ContractLogicError¶
Build a degenbot
ContractLogicErrormirroring an Alloy revert.Raises the degenbot-owned
ContractLogicError(anRpcErrorsubclass) so the existing probe sites — which now catchRpcErrorrather thanWeb3Exception— behave identically across the Alloy and web3 backends. The web3 adapter performs the symmetric conversion at its owncall/call_rawseam.- Returns:
A
ContractLogicErrorwhose message embeds the original alloy revert text, suitable for raising at the adapter seam.