Skip to content

Commit

Permalink
Fix balance overflow and invalid messenger channel error code clash
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Jan 28, 2025
1 parent f8e7a10 commit e538e5d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions crates/sp-domains-fraud-proof/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ use subspace_core_primitives::U256;
use subspace_runtime_primitives::{Balance, Moment};

/// Custom invalid validity code for the extrinsics in pallet-domains.
// When updating these error codes, check for clashes between:
// <https://github.com/autonomys/subspace/blob/main/domains/primitives/runtime/src/lib.rs#L85-L88>
// <https://github.com/autonomys/subspace/blob/main/domains/pallets/messenger/src/lib.rs#L49-L53>
#[repr(u8)]
pub enum InvalidTransactionCode {
TransactionProof = 101,
Expand Down
6 changes: 5 additions & 1 deletion domains/pallets/messenger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ use sp_runtime::traits::{Extrinsic, Hash};
use sp_runtime::DispatchError;

pub(crate) mod verification_errors {
pub(crate) const INVALID_CHANNEL: u8 = 200;
// When updating these error codes, check for clashes between:
// <https://github.com/autonomys/subspace/blob/main/domains/primitives/runtime/src/lib.rs#L85-L88>
// <https://github.com/autonomys/subspace/blob/main/crates/sp-domains-fraud-proof/src/lib.rs#L49-L64>
pub(crate) const INVALID_NONCE: u8 = 201;
pub(crate) const NONCE_OVERFLOW: u8 = 202;
// This error code was previously 200, but that clashed with ERR_BALANCE_OVERFLOW.
pub(crate) const INVALID_CHANNEL: u8 = 203;
}

#[derive(Debug, Encode, Decode, Clone, Eq, PartialEq, TypeInfo, Copy)]
Expand Down
4 changes: 4 additions & 0 deletions domains/primitives/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ pub fn maximum_domain_block_weight() -> Weight {
weight.set_proof_size(consensus_maximum_normal_block_length)
}

// When updating these error codes, check for clashes between:
// <https://github.com/autonomys/subspace/blob/main/crates/sp-domains-fraud-proof/src/lib.rs#L49-L64>
// <https://github.com/autonomys/subspace/blob/main/domains/pallets/messenger/src/lib.rs#L49-L53>

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

0 comments on commit e538e5d

Please sign in to comment.