Expand description
Core utilities for MultiversX Rust services.
This crate provides shared functionality used across mx-relayer, mx-stress, and mx-notifier:
- Protocol constants (shard IDs, transaction options)
- Mnemonic normalization
- Shard computation (matching mx-chain-go algorithm)
- Bech32 address encoding/decoding
- Go
BigIntCasterencode/decode helpers and unsigned amount parsing - Base64/hex encoding utilities
- Wallet derivation (Ed25519 signing keys and addresses from BIP39 mnemonics)
Re-exports§
pub use leader::ConsensusMsgType;pub use leader::ConsensusSignal;pub use leader::EligibleValidator;pub use leader::decode_consensus_signal;pub use leader::epoch_shuffle;pub use leader::select_consensus_group;pub use leader::select_leader;
Modules§
- leader
- resilience
- Resilience patterns: circuit breaker, backoff, and retry.
- ws_
protocol - Shared WebSocket wire-format types for relayer ↔ stress communication.
Structs§
- Topic
Info - Parsed information for a concrete gossip topic.
Enums§
- Base
Topic - Enumeration of all gossip topic families used by
MultiversXnodes. - Core
Error - Errors returned by mx-core public functions.
- Topic
Routing - Represents how a topic is routed across shards.
- Topic
Shard - A shard token extracted from a topic suffix.
Constants§
- ALL_
SHARD_ ID - Shard ID representing all shards in P2P topics.
- METACHAIN_
SHARD_ ID - Alias for metachain shard ID used in P2P topics.
- META_
SHARD_ ID Deprecated - Special shard ID for metachain (0xFFFFFFFF).
- TRANSACTIONS_
BASE_ TOPIC - Base topic used when broadcasting regular transactions.
- TX_
OPTION_ GUARDED - Transaction option flag for guarded transactions.
- TX_
OPTION_ HASH_ SIGN - Transaction option flag for hash signing (keccak256 hash instead of raw JSON).
Functions§
- all_
topics_ for_ shards - Generates every known topic (including control channels) for the provided shard set.
- broadcast_
topic - Builds a gossipsub topic name for a shard pair (e.g., “
transactions_0_1”). Shards are automatically sorted to ensure canonical ordering perMultiversXprotocol. - communication_
identifier_ between_ shards - Mirrors Go’s
CommunicationIdentifierBetweenShards. - decode_
base64 - Decodes a base64-encoded string, trying standard encoding first.
- decode_
base64_ bytes - Decodes a base64-encoded string to Bytes.
- decode_
base64_ or_ hex - Decodes data that may be either base64 or hex encoded. Tries base64 first, then falls back to hex.
- decode_
bech32 - Decodes a bech32-encoded address into raw bytes.
- decode_
big_ int_ caster - Decodes bytes encoded with Go’s
BigIntCasterformat. - decode_
embedded_ receiver - Extracts the embedded receiver address from ESDT/NFT transfer data payloads.
- decode_
hex - Decodes a hex-encoded string.
- decode_
optional_ base64 - Decodes an optional base64-encoded string.
- decode_
optional_ bech32 - Decodes an optional bech32 address, returning empty Bytes if None or empty.
- decode_
optional_ hex - Decodes an optional hex-encoded string.
- derive_
address - Derives a bech32-encoded address from a BIP39 mnemonic at the given account and index.
- derive_
signing_ key - Derives an Ed25519 signing key from a BIP39 mnemonic at the given account and index.
- encode_
bech32 - Encodes raw bytes as a bech32 address with the given HRP.
- encode_
big_ int_ caster - Encodes a
BigIntusing Go’sBigIntCasterformat. - filter_
username - Filters and trims a username field.
- normalize_
mnemonic - Normalizes a mnemonic string by replacing commas or multiple whitespace with single spaces.
- parse_
big_ uint - Parses an unsigned integer string into the Go
BigIntCasterwire format. - select_
shard - Computes the shard ID from the last byte of an address.
- shard_
of - Determines the shard ID for a given bech32 address.
- shard_
of_ address_ bytes - Determines shard ID from raw public key bytes (no bech32 decoding).
- shard_
of_ bytes - Determines the shard ID from raw address bytes (simpler version).
- transaction_
topics_ from_ shards - Convenience wrapper generating all transaction topics for the provided shard set.