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

Rework error names #712

Closed
wants to merge 2 commits into from
Closed

Rework error names #712

wants to merge 2 commits into from

Conversation

Fumuran
Copy link
Contributor

@Fumuran Fumuran commented May 28, 2024

This PR updates kernel assertion error names and descriptions so that the essence of the error is clear only by name.

Related issue: #671

@Fumuran Fumuran linked an issue May 28, 2024 that may be closed by this pull request
@Fumuran Fumuran force-pushed the andrew-rework-error-naming branch from 7580f7b to 7593fa0 Compare June 1, 2024 11:00
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Looks good! Not a full review yet - but I left some comments inline.

Comment on lines 233 to 244
// --- P2ID ERRORS --------------------------------------------------------------------------------
const ERR_P2ID_EXPECTS_EXACTLY_1_NOTE_INPUT: u32 = 131074; // 131074 0x00020002
const ERR_P2ID_MISMATCH_OF_TARGET_ACCOUNT_ADDR_AND_TRANSACTION_ADDR: u32 = 131075; // 131075 0x00020003

// --- P2IDR ERRORS -------------------------------------------------------------------------------
const ERR_P2IDR_CAN_BE_RECLAIMED_ONLY_BY_SENDER: u32 = 131077; // 131077 0x00020005
const ERR_P2IDR_EXPECTS_EXACTLY_2_NOTE_INPUTS: u32 = 131076; // 131076 0x00020004
const ERR_P2IDR_RECLAIM_BLOCK_HEIGHT_NOT_REACHED: u32 = 131078; // 131078 0x00020006

// --- SWAP ERRORS --------------------------------------------------------------------------------
const ERR_SWAP_EXPECTS_EXACTLY_9_NOTE_INPUTS: u32 = 131079; // 131079 0x00020007
const ERR_SWAP_REQUIRES_EXACTLY_1_NOTE_ASSET: u32 = 131080; // 131080 0x00020008
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are technically not part of the kernel. I think we should break them up into a different category (and maybe use 0x0003 prefix for them).

const ERR_NOTE_INVALID_TAG_PREFIX_FOR_TYPE: u32 = 131141;
const ERR_NOTE_TAG_MUST_BE_U32: u32 = 131142;
// --- ACCOUNT ERRORS -----------------------------------------------------------------------------
const ERR_ACCOUNT_CODE_MUST_BE_UPDATABLE: u32 = 131133; // 131133 0x0002003D 131072 0x00020000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there two separate codes here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm preparing to change codes to be in in ascending order (as soon as constants get their final names and hence correct alphabetical order). And not to mess everything up and confuse the old and new values when I will update the actual constants in masm code I wrote the old values for every constant and a starting point for a new values.

miden-tx/src/error.rs Outdated Show resolved Hide resolved
// --- ACCOUNT ERRORS -----------------------------------------------------------------------------
const ERR_ACCOUNT_CODE_MUST_BE_UPDATABLE: u32 = 131133; // 131133 0x0002003D 131072 0x00020000
const ERR_ACCOUNT_ID_INVALID_INSUFFICIENT_NUMBER_OF_ONES: u32 = 131132; // 131132 0x0002003C
const ERR_ACCOUNT_MUST_BE_A_FAUCET_TO_CALL_PROCEDURE: u32 = 131073; // 131073 0x00020001
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does this error happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use it here in the api.masm to make sure that this get_fungible_faucet_total_issuance procedure is called by a fungible faucet. But now name of the constant looks a bit odd for me. Perhaps something like ERR_ACCOUNT_MUST_BE_A_FUNGIBLE_FAUCET would be better.

const ERR_ACCOUNT_SEED_DIGEST_MISMATCH: u32 = 131134; // 131134 0x0002003E

// --- NONCE ERROR --------------------------------------------------------------------------------
const ERR_NONCE_DID_NOT_INCREASE_AFTER_STATE_CHANGED: u32 = 131081; // 131081 0x00020009
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably should go into the "account errors" category as well.

Also, do we have the opposite error: "account nonce increased without state change"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do we have the opposite error: "account nonce increased without state change"?

For now we don't have this error and as far as I can see we don't check for this anywhere. Should I create a constant for this error?


// --- VAULT ERRORS -------------------------------------------------------------------------------
const ERR_VAULT_ADDING_FUNGIBLE_ASSET_WOULD_EXCEED_MAX_AMOUNT_OF_9223372036854775807: u32 = 131117; // 131117 0x0002002D
const ERR_VAULT_ADD_FUNGIBLE_ASSET_TO_ACCOUNT_FAILED_INITIAL_VALUE_INVALID: u32 = 131118; // 131118 0x0002002E
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When odes this error happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use it here in the asset_vault.masm to make sure that old vault value is correct.

const ERR_ASSET_EXCEED_MAX_AMOUNT_OF_9223372036854775807: u32 = 131138; // 131138 0x00020042

// --- FUNGIBLE ASSET ERRORS ----------------------------------------------------------------------
const ERR_FUNGIBLE_ASSET_DISTRIBUTE_WOULD_CAUSE_MAX_SUPPLY_TO_BE_EXCEEDED: u32 = 131105; // 131105 0x00020021
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this also might not really be a part of the kernel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure where to place this error (and also the ERR_ASSET_EXCEED_MAX_AMOUNT_OF_9223372036854775807 above it). They could be described as "faucet" and "asset" errors respectively, but creating a new section with a new prefix just for one error looks like an overkill for me.

@Fumuran Fumuran force-pushed the andrew-rework-error-naming branch from 7593fa0 to 3c3df98 Compare June 5, 2024 20:59
@bobbinth
Copy link
Contributor

@Overcastan could you rebase this from the latest next?

@Fumuran Fumuran force-pushed the andrew-rework-error-naming branch from 3c3df98 to 63682a7 Compare June 28, 2024 22:11
@Fumuran
Copy link
Contributor Author

Fumuran commented Jul 1, 2024

My initial thought was to update the error values to make them go in ascending order, but now I think that it doesn't make a lot of sense: probably new errors will be added to the groups, so this order will be broken anyway.

@Fumuran Fumuran requested a review from bobbinth July 1, 2024 14:35
@Fumuran Fumuran marked this pull request as ready for review July 2, 2024 17:50
@Fumuran Fumuran force-pushed the andrew-rework-error-naming branch from 2c79cc5 to b76f68b Compare July 4, 2024 16:44
@Fumuran
Copy link
Contributor Author

Fumuran commented Jul 4, 2024

This rebase was large and nasty, so commit history now looks odd, but at least this PR now have only right changes.

@Fumuran Fumuran mentioned this pull request Sep 13, 2024
2 tasks
@Fumuran Fumuran removed the request for review from hackaugusto September 23, 2024 10:14
@Fumuran
Copy link
Contributor Author

Fumuran commented Oct 7, 2024

Superseded by #906.

@Fumuran Fumuran closed this Oct 7, 2024
@bobbinth bobbinth deleted the andrew-rework-error-naming branch November 6, 2024 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rework error naming
3 participants