fix: advice inputs in TransactionInputs not being propagated#2094
fix: advice inputs in TransactionInputs not being propagated#2094PhilippGackstatter wants to merge 5 commits intomainfrom
TransactionInputs not being propagated#2094Conversation
| /// transaction with the specified transaction inputs. | ||
| pub fn new(tx_inputs: &TransactionInputs) -> Result<Self, TransactionAdviceMapMismatch> { | ||
| let mut inputs = TransactionAdviceInputs(tx_inputs.advice_inputs().clone()); | ||
| // Start with empty advice inputs so the advice stack is correctly build. |
There was a problem hiding this comment.
| // Start with empty advice inputs so the advice stack is correctly build. | |
| // Start with empty advice inputs so the advice stack is correctly built. |
igamigo
left a comment
There was a problem hiding this comment.
Looks great!
I think this chain of inputs and args is pretty hard to understand and we clearly missed it before and imo would be worth taking another look at.
Agreed
|
I've spent some time thinking about this, and I wonder if a slightly different approach would work better here. I like the conceptual separation between There is some overlap between the two: The main issue with the current approach is that Another approach is to add something like |
I think the main requirement would from our end would be that its difficult to "hold wrong" aka it should be obvious what is required via types/IDE. |
|
I'm not fully convinced it's much better than the current approach but it does sound more consistent with the conceptual separation between args and inputs, where the args are left untouched and inputs get modified throughout the execution. I took a look at the code to review a few questions I had and from the outside it may also still be a little confusing that the transaction "inputs" structure gets modified to hold important data (it also has a bunch of mutators which seem have some degree of overlap); aka it's not clear at first sight what is static and what gets mutated at what point necessarily.
This could probably be solved fairly easily if we name the method something like |
I agree with this. I think the main reason we didn't catch this is what @igamigo touched on, i.e. it's not clear what is being mutated vs left untouched. The The change in this PR was the quickest reasonable fix I could think of, so there may be a better overall structure for this. I also agree that the conceptual separation of the two advice inputs makes sense, but I'd probably try to work on this separately. |
| pub fn with_advice_inputs(mut self, advice_inputs: AdviceInputs) -> Self { | ||
| self.advice_inputs = advice_inputs; | ||
| self.tx_args.extend_advice_inputs(advice_inputs); |
There was a problem hiding this comment.
In the first iteration of the PR this overwrote the advice inputs. I now changed it to extend it, which makes the test_nested_fpi_cyclic_invocation test pass now (and I removed the ignore).
The test was failing during the LocalTransactionProver::prove call, because the custom advice stack inputs the test was setting on the advice inputs got overwritten after the tx execution by the call to with_advice_inputs in build_executed_transaction. So the custom advice stack inputs were no longer there at the time of proving. Thanks @Fumuran for the hint!
|
I opened an alternative approach in #2099 which is different from the alternative I proposed earlier, and conceptually is closer to this PR - though, it does modify fewer files. |
|
Superseded by #2099. |
Fixes advice inputs in
TransactionInputsnot being propagated through to transaction execution.When a transaction finishes execution, its final advice inputs, including generated signatures are set in the
TransactionInputs::advice_inputsfield:https://github.com/0xMiden/miden-base/blob/d52c65e85949b0b85b38fef04b2e86ab5cbe281a/crates/miden-tx/src/executor/mod.rs#L386-L390
However, the transaction execution API is:
and the advice inputs from the
TransactionInputsare not passed to this function (because there is no obvious way to do so).This PR removes the
advice_inputsfield in theTransactionInputsand instead uses the field inTransactionArgs, which can be provided to this API. For the same reason, this fails re-execution on the node, which doesn't use the actual advice inputs fromTransactionInputs: https://github.com/0xMiden/miden-node/blob/9bac0c11c32788e6dc1fd8376c5f5f55d9b45927/crates/rpc/src/server/validator.rs#L35-L40With this change, the usage in the node should automatically work, cc @Mirko-von-Leipzig.
An update to the
TransactionContextwas also required, to propagate the advice inputs from the transaction args through to the new transaction args we're building. I think this chain of inputs and args is pretty hard to understand and we clearly missed it before and imo would be worth taking another look at.There is one test I had to ignore because it uses custom advice stack input in some way that now fails, and I don't know exactly why. I believe this is only related to tests, and is unlikely to affect anything in practice, so I think it should be ok to look at this in another PR.
closes #2092