Skip to content

Import constants directly instead of through procedures #2168

@PhilippGackstatter

Description

@PhilippGackstatter

After the upgrade to VM 0.20 (#2158), we can import constants (0xMiden/miden-vm#2067).

Ideally, we can get rid of all procedures in crates/miden-lib/asm/kernels/transaction/lib/constants.masm that just enable access to the constants.

For example, we have:
https://github.com/0xMiden/miden-base/blob/5433d1fdc8c10e82f13ca9283f4c6bbfe6282470/crates/miden-lib/asm/kernels/transaction/lib/constants.masm#L63-L65

We use it like this:
https://github.com/0xMiden/miden-base/blob/5433d1fdc8c10e82f13ca9283f4c6bbfe6282470/crates/miden-lib/asm/kernels/transaction/lib/memory.masm#L1920-L1921

Ideally, this can be rewritten as:

dup.1 lt.constants::MAX_ASSETS_PER_NOTE assert.err=ERR_NOTE_NUM_OF_ASSETS_EXCEED_LIMIT

I haven't checked if that syntax is allowed. If it isn't, then the next best thing would be:

dup.1 push.constants::MAX_ASSETS_PER_NOTE lt assert.err=ERR_NOTE_NUM_OF_ASSETS_EXCEED_LIMIT

I think we should do this for all constants in constants.masm, and also check beyond that file where we import constants through procedures.

We should also look for constants that are defined in multiple places, e.g. ACCOUNT_PROCEDURE_DATA_LENGTH (which was duplicated in #2162).

Metadata

Metadata

Labels

good first issueGood for newcomerskernelsRelated to transaction, batch, or block kernels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions