PR: #41 (feat/executor: transaction builder + eth_call simulator)
File: crates/charon-executor/src/builder.rs, crates/charon-executor/src/simulation.rs
Refs #41
Problem
Every public method in charon-executor returns anyhow::Result:
- encode_calldata -> Result
- build_tx -> Result
- sign -> Result
- simulate -> Result<()>
The executor pipeline must distinguish:
- Drop this opportunity, try next: simulation revert (position no longer liquidatable), transient nonce race.
- Abort the pipeline: signer failure, chain ID mismatch, provider disconnected.
Without typed errors, callers must either treat all errors as fatal (abort on transient nonce race) or all as recoverable (swallow signer failures silently). Neither is correct.
Repo convention
PR #28 (lending trait), PR #39 (flashloan router): library crates expose thiserror enums. anyhow is for application-layer main functions, not library API boundaries.
Fix
Add thiserror to workspace dependencies and charon-executor/Cargo.toml. Define typed error enums:
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum BuilderError {
#[error("nonce fetch failed: {0}")]
NonceFetch(#[source] alloy::transports::TransportError),
#[error("signing failed: {0}")]
Signing(#[source] alloy::signers::Error),
#[error("fee invariant violated: priority {0} > max {1}")]
InvalidFees(u128, u128),
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum SimulationError {
#[error("simulation reverted: {0}")]
Reverted(String),
#[error("provider error: {0}")]
Provider(#[source] alloy::transports::TransportError),
}
PR: #41 (feat/executor: transaction builder + eth_call simulator)
File: crates/charon-executor/src/builder.rs, crates/charon-executor/src/simulation.rs
Refs #41
Problem
Every public method in charon-executor returns anyhow::Result:
The executor pipeline must distinguish:
Without typed errors, callers must either treat all errors as fatal (abort on transient nonce race) or all as recoverable (swallow signer failures silently). Neither is correct.
Repo convention
PR #28 (lending trait), PR #39 (flashloan router): library crates expose thiserror enums. anyhow is for application-layer main functions, not library API boundaries.
Fix
Add thiserror to workspace dependencies and charon-executor/Cargo.toml. Define typed error enums: