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

Unify Custom transaction error codes #3353

Open
teor2345 opened this issue Jan 20, 2025 · 0 comments
Open

Unify Custom transaction error codes #3353

teor2345 opened this issue Jan 20, 2025 · 0 comments
Labels
bug Something isn't working execution Subspace execution fraud-proof refactor

Comments

@teor2345
Copy link
Member

Currently, subspace has Custom error codes in 3 different locations, which has led to clashes multiple times: (including 200 here)

/// Custom error when nonce overflow occurs.
pub const ERR_NONCE_OVERFLOW: u8 = 100;
/// Custom error when balance overflow occurs.
pub const ERR_BALANCE_OVERFLOW: u8 = 200;

/// Custom invalid validity code for the extrinsics in pallet-domains.
#[repr(u8)]
pub enum InvalidTransactionCode {
TransactionProof = 101,
ExecutionReceipt = 102,
Bundle = 103,
FraudProof = 104,
BundleStorageFeePayment = 105,
}
impl From<InvalidTransactionCode> for InvalidTransaction {
#[inline]
fn from(invalid_code: InvalidTransactionCode) -> Self {
InvalidTransaction::Custom(invalid_code as u8)
}
}

pub(crate) mod verification_errors {
pub(crate) const INVALID_CHANNEL: u8 = 200;
pub(crate) const INVALID_NONCE: u8 = 201;
pub(crate) const NONCE_OVERFLOW: u8 = 202;
}

This potentially causes bugs if we match on the error code in production or test code. It also makes logs harder to read.

We should move all these codes next to each other, in the same file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working execution Subspace execution fraud-proof refactor
Projects
None yet
Development

No branches or pull requests

1 participant