refactor: add miden::protocol::auth module with public auth event constants#2377
Conversation
|
The So even if we define @bobbinth is there a way to import a pub const and use it with |
|
That's probably a question for @bitwalker. |
Importing constants via However, a workaround is to do the following instead: As I mentioned above though, this shouldn't be necessary, i.e. |
01901f7 to
137cafa
Compare
…stants This adds a new auth.masm module under miden::protocol that exports public constants for authentication events: - AUTH_REQUEST_EVENT: emitted when requesting an authentication signature - AUTH_UNAUTHORIZED_EVENT: emitted when authentication is unauthorized The constants are defined using the event() function and can be imported by other modules. Note: Due to a linker bug in miden-assembly, direct imports like `use miden::protocol::auth::AUTH_REQUEST_EVENT` don't work yet. As a workaround, modules define local constants that reference the full path: `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT` Closes 0xMiden#2370
137cafa to
3315a8d
Compare
In the course of looking into an issue described [here](0xMiden/protocol#2377 (comment)), I discovered that a lot of the symbol resolver complexity was due to handling edge cases at the wrong level. Not only did this result in a lot of excess complexity, but it also failed to account for issues such as the one identified in the linked comment above. This commit rewrites the core `resolve_path` implementation to work in terms of "expanding" a path into its absolute form, and then resolving the absolute path. This is much more efficient, since we can take a couple of shortcuts based on a few rules, and results in much more intuitive behavior, and a considerably simpler implementation. Two new tests were added to catch a few edge cases that were not well represented by our existing test suite, and can be used to prevent future regressions as well. This is a non-breaking change in the public interface of the assembler.
In the course of looking into an issue described [here](0xMiden/protocol#2377 (comment)), I discovered that a lot of the symbol resolver complexity was due to handling edge cases at the wrong level. Not only did this result in a lot of excess complexity, but it also failed to account for issues such as the one identified in the linked comment above. This commit rewrites the core `resolve_path` implementation to work in terms of "expanding" a path into its absolute form, and then resolving the absolute path. This is much more efficient, since we can take a couple of shortcuts based on a few rules, and results in much more intuitive behavior, and a considerably simpler implementation. Two new tests were added to catch a few edge cases that were not well represented by our existing test suite, and can be used to prevent future regressions as well. This is a non-breaking change in the public interface of the assembler.
PhilippGackstatter
left a comment
There was a problem hiding this comment.
Looks good to me!
Resolve merge conflicts with recent changes: - 0xMiden#2369: Updated offset numbers for new get_asset API - 0xMiden#2377: Keep pub const prefix for all offset constants
) * refactor(assembly): improve link-time symbol resolution internals In the course of looking into an issue described [here](0xMiden/protocol#2377 (comment)), I discovered that a lot of the symbol resolver complexity was due to handling edge cases at the wrong level. Not only did this result in a lot of excess complexity, but it also failed to account for issues such as the one identified in the linked comment above. This commit rewrites the core `resolve_path` implementation to work in terms of "expanding" a path into its absolute form, and then resolving the absolute path. This is much more efficient, since we can take a couple of shortcuts based on a few rules, and results in much more intuitive behavior, and a considerably simpler implementation. Two new tests were added to catch a few edge cases that were not well represented by our existing test suite, and can be used to prevent future regressions as well. This is a non-breaking change in the public interface of the assembler.
Replace the temporary workaround constants introduced in PR 0xMiden#2377 with direct imports from `miden::protocol::auth`. The linker bug that required the workaround has been fixed in miden-vm#2637. Changes: - Replace `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT` with `use miden::protocol::auth::AUTH_REQUEST_EVENT` - Replace `const AUTH_UNAUTHORIZED_EVENT = ::miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT` with `use miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT` Closes 0xMiden#2392
Replace the temporary workaround constants introduced in PR 0xMiden#2377 with direct imports from `miden::protocol::auth`. The linker bug that required the workaround has been fixed in miden-vm#2637. Changes: - Replace `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT` with `use miden::protocol::auth::AUTH_REQUEST_EVENT` - Replace `const AUTH_UNAUTHORIZED_EVENT = ::miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT` with `use miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT` Closes 0xMiden#2392
Replace the temporary workaround constants introduced in PR 0xMiden#2377 with direct imports from `miden::protocol::auth`. The linker bug that required the workaround has been fixed in miden-vm#2637. Changes: - Replace `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT` with `use miden::protocol::auth::AUTH_REQUEST_EVENT` - Replace `const AUTH_UNAUTHORIZED_EVENT = ::miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT` with `use miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT` Closes 0xMiden#2392
…#2404) * refactor: replace auth event constant workarounds with direct imports Replace the temporary workaround constants introduced in PR #2377 with direct imports from `miden::protocol::auth`. The linker bug that required the workaround has been fixed in miden-vm#2637. Changes: - Replace `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT` with `use miden::protocol::auth::AUTH_REQUEST_EVENT` - Replace `const AUTH_UNAUTHORIZED_EVENT = ::miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT` with `use miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT` Closes #2392 * chore: update miden-assembly to v0.20.6 for constant import support --------- Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
…stants (0xMiden#2377) This adds a new auth.masm module under miden::protocol that exports public constants for authentication events: - AUTH_REQUEST_EVENT: emitted when requesting an authentication signature - AUTH_UNAUTHORIZED_EVENT: emitted when authentication is unauthorized The constants are defined using the event() function and can be imported by other modules. Note: Due to a linker bug in miden-assembly, direct imports like `use miden::protocol::auth::AUTH_REQUEST_EVENT` don't work yet. As a workaround, modules define local constants that reference the full path: `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT` Closes 0xMiden#2370
…0xMiden#2404) * refactor: replace auth event constant workarounds with direct imports Replace the temporary workaround constants introduced in PR 0xMiden#2377 with direct imports from `miden::protocol::auth`. The linker bug that required the workaround has been fixed in miden-vm#2637. Changes: - Replace `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT` with `use miden::protocol::auth::AUTH_REQUEST_EVENT` - Replace `const AUTH_UNAUTHORIZED_EVENT = ::miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT` with `use miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT` Closes 0xMiden#2392 * chore: update miden-assembly to v0.20.6 for constant import support --------- Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
Summary
crates/miden-protocol/asm/protocol/auth.masmwith public constants:AUTH_REQUEST_EVENTAUTH_UNAUTHORIZED_EVENTbuild.rssince events are now defined in the protocol moduleCloses #2370