0xMiden / 0xMiden/protocol

Test stack padding and truncation in kernel procedure wrappers

Abierto
#2,881 1 comentario 0 reacciones 1 asignado Reclamado por @partylikeits1983 Ver en GitHub
kernels
Lenguaje dominante
Rust
Estrellas
132
Forks
167
Merge medio
1 d 23 h
PR fusionados (30 d)
110

Descripción

We should consider implementing one or more tests that checks that all wrappers around kernel procedures pad and truncate the stack correctly. Stack padding/truncation is done manually in every one of these procedures and is easy to get wrong, in a few cases _without_ breaking the functionality of the procedure itself. This means tests that check the functionality in isolation don't always catch these issues.

A real example was fixed in https://github.com/0xMiden/protocol/pull/2871, where `add_attachment` was internally padded with `push.0 movdn.8` instead of `push.0 movdn.7`. This resulted in one of the existing stack elements to be used as the note idx, which happened to be 0. Since 0 is often the target note idx in tests anyway, this didn't break tests. The error surface when the procedure was called in a loop.

The goal of these tests is to make sure that the stack effect of these procedures is neutral, no stray elements are left behind, and no existing elements are unintentionally dropped, according to the procedure's signature.

We'd need to execute a valid invocation of each procedure, so parameters will likely need to be customized. One test per module (`output_note`, `input_note`, ...) might be useful and `rstest` might be handy to parameterize over all procedures. But if we can automate more of this away, that'd be even better.

Since this is critical for correctness, it would be good to do before mainnet.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.