Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling transaction fails with multiple notes #443

Closed
igamigo opened this issue Jan 27, 2024 · 17 comments
Closed

Compiling transaction fails with multiple notes #443

igamigo opened this issue Jan 27, 2024 · 17 comments
Labels
bug Something isn't working
Milestone

Comments

@igamigo
Copy link
Collaborator

igamigo commented Jan 27, 2024

When testing consuming multiple notes from the client, I'm getting this error:

transaction executor error: CompileTransactionFiled(CompileNoteScriptFailed(DuplicateProcName("add_note_assets_to_account", "#exec"))) 

The same code works for consuming one single note each time, the issue occurs only when having more than one. I'm not sure if this is a bug or a problem with the client code (I couldn't find examples of transactions having multiple input notes), but @bobbinth suggested opening an issue here.

@bobbinth
Copy link
Contributor

bobbinth commented Jan 28, 2024

This is likely due to a collision in the Assembler's cache when we try to compile two executable programs in the same context. So, it is likely that the bug is in Miden VM rather than miden base. @Overcastan may be able to help with this.

@Fumuran
Copy link
Contributor

Fumuran commented Jan 28, 2024

@igamigo Could you please provide the code of the failing test?

@igamigo
Copy link
Collaborator Author

igamigo commented Jan 29, 2024

Here's the function that creates the transaction that compiles the script and attempts to consume multiple notes. Notice lines 256-264, where it is decided to use either one or multiple notes; first branch works correctly but the else clause does not. Unfortunately it's not very simple to test right now but I will try to provide instructions or a test that runs this code and repros the issue tomorrow.

@igamigo
Copy link
Collaborator Author

igamigo commented Jan 31, 2024

Having some trouble creating a unit test for this, I'm getting a PhantomCallsNotAllowed error for the test I was writing. Guessing I'm mocking some inputs incorrectly.

@Fumuran
Copy link
Contributor

Fumuran commented Feb 1, 2024

@igamigo I think I understood what's happening, there is no need for the example test. Bobbin is right, the problem occurs when we try to compile two programs in the same context.
During the nodes consumption you're compiling the transactions, which internally contains the compilation of the note scripts (P2ID or P2IDR, I guess). Both of these scripts contain the add_note_assets_to_account procedure, and that's exactly what causes the error: we don't allow usage of functions with the same names in one context now. If I remove this check the local procedures should still run without problems, but I'm not sure about exported and reexported — let me check this.
Anyway now I see that this check should be reworked, at least we need to print a warning if we compile two procedures with the same names. That shouldn't be a complex issue to fix, I hope I will open a related PR tomorrow

@bobbinth bobbinth added this to the v0.2 milestone Feb 13, 2024
@Dominik1999
Copy link
Collaborator

@Overcastan are you still on this topic?

@Fumuran
Copy link
Contributor

Fumuran commented Feb 16, 2024

Yes, problem is in the VM, I hope I'll create a PR on the weekend.

@Fumuran
Copy link
Contributor

Fumuran commented Feb 21, 2024

@igamigo I checked the VM and came to the conclusion that just a plane change from error to log message should be fine. Although I didn't manage to create a proper test for the case with two programs compiled in one context. Could you check your test with my VM dev branch andrew-duplicate-proc-fix as a dependency? Instead of error now it should print a warning: duplicate proc name '{}' in module {}.

@igamigo
Copy link
Collaborator Author

igamigo commented Feb 21, 2024

Will test and report back, thanks

@igamigo
Copy link
Collaborator Author

igamigo commented Feb 21, 2024

Yes, this works well (took a a bit to test due to the dependency chain of client -> base- > VM). Thanks!

@Fumuran
Copy link
Contributor

Fumuran commented Feb 21, 2024

Sorry, changing dependencies is troublesome indeed, I felt this when I was updating the repositories to work with new version of Winterfell. I'll create a PR with this change today

@Dominik1999
Copy link
Collaborator

@Overcastan are you still working on this issue?

@Fumuran
Copy link
Contributor

Fumuran commented Mar 5, 2024

@Dominik1999 Probably we should put this issue on hold, since it should become a non-issue when @bitwalker merge the changes in assembler.

@Dominik1999
Copy link
Collaborator

@Overcastan are the changes in the assembler done here 0xPolygonMiden/miden-vm#1277 enough? Or is another PR outstanding?

@Fumuran
Copy link
Contributor

Fumuran commented Jun 3, 2024

@igamigo Can you please check is this error still occurring with a new version of assembler?

@Dominik1999
Copy link
Collaborator

It is still blocked

@bobbinth bobbinth modified the milestones: v0.4, v0.5 Jun 24, 2024
@bobbinth
Copy link
Contributor

Closed by #837.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

4 participants