In Penumbra, ActionHandlers define the interface for handling transaction actions, and in particular, assert their validity via check_stateless and check_stateful. With respect to the DEX component, it would be helpful to enshrine the expectations set forth in both functions in unit-tests that would control for any accidental regression.
For example, the dex routing logic builds off a certain number of assumptions such as:
each position provisions at least some amount of either asset (i.e. wlog, $R_1 = 0 \implies R_2 \neq 0$)
trading function valuations are nonzero i.e $p, q \neq 0$
async fn check_stateless(&self, _context: Arc<Transaction>) -> Result<()> {
// Check:
// + reserves are at most 112 bits wide,
// + at least some assets are provisioned.
self.position.reserves.check_bounds()?;
// Check:
// + the trading function coefficients are at most 112 bits wide.
// + the trading function coefficients are non-zero,
// + the trading function doesn't specify a cyclic pair,
// + the fee is <=50%.
self.position.check_stateless()?;
It would make the codebase more robust to have tests that make sure that check_stateless, check_stateful always catch some positions that we craft to be invalid. This is a good first issue for prospective contributors, and I would be happy to help you ship this.
In Penumbra,
ActionHandler
s define the interface for handling transaction actions, and in particular, assert their validity viacheck_stateless
andcheck_stateful
. With respect to the DEX component, it would be helpful to enshrine the expectations set forth in both functions in unit-tests that would control for any accidental regression.For example, the dex routing logic builds off a certain number of assumptions such as:
It would make the codebase more robust to have tests that make sure that
check_stateless
,check_stateful
always catch some positions that we craft to be invalid. This is a good first issue for prospective contributors, and I would be happy to help you ship this.