serialization.rs
Overview
This file defines a set of data structures designed to encapsulate serialization-related data for blockchain entities, including accounts, blocks, messages, and transactions. The primary purpose of these structures is to bundle together the core entity data with supplementary metadata such as serialization output (BOC - Bag of Cells), cryptographic proofs, processing statuses, and identifiers. These bundles facilitate consistent handling, transmission, and storage of serialized blockchain objects within the system.
Data Structures
AccountSerializationSet
Represents a serialized account along with associated metadata necessary for blockchain operations and verification.
Fields
account: Account
The core account data imported from thetvm_blockmodule.prev_code_hash: Option<UInt256>
An optional cryptographic hash representing the previous smart contract code associated with the account, useful for code version tracking.boc: Vec<u8>
Binary serialized representation of the account in Bag of Cells (BOC) format.boc1: Option<Vec<u8>>
An optional alternative BOC serialization, possibly for a different serialization variant or version.proof: Option<Vec<u8>>
Optional cryptographic proof data confirming the validity or state of the account.dapp_id: Option<UInt256>
Optional identifier linking the account to a decentralized application (DApp).
Usage Example
let serialized_account = AccountSerializationSet {
account,
prev_code_hash: Some(prev_hash),
boc: account_boc,
boc1: None,
proof: Some(proof_data),
dapp_id: Some(dapp_identifier),
};
BlockSerializationSetFH
Encapsulates a block's serialized data, its identity, and processing status.
Fields
block: Block
The block object from thetvm_blockmodule.id: BlockId
Unique identifier for the block.status: BlockProcessingStatus
Enum indicating the current processing status of the block (e.g., pending, processed, failed).boc: Vec<u8>
Serialized block data in BOC format.file_hash: Option<UInt256>
Optional hash of the file containing the block data, aiding integrity verification.
Usage Example
let block_set = BlockSerializationSetFH {
block,
id,
status: BlockProcessingStatus::Processed,
boc: block_boc,
file_hash: Some(file_hash),
};
DeletedAccountSerializationSet
Represents metadata for an account that has been deleted from the blockchain state.
Fields
account_id: AccountId
Identifier of the deleted account.prev_code_hash: Option<UInt256>
Optional hash of the smart contract code that was associated with the account prior to deletion.workchain_id: i32
Identifier of the workchain to which the account belonged.
Usage Example
let deleted_account = DeletedAccountSerializationSet {
account_id,
prev_code_hash: None,
workchain_id: -1,
};
MessageSerializationSet
Bundles a message's serialization, identifiers, state, and proof information.
Fields
message: Message
The message object from thetvm_blockmodule.id: MessageId
Unique identifier for the message.block_id: Option<UInt256>
Optional identifier of the block containing this message.transaction_id: Option<UInt256>
Optional identifier of the transaction related to this message.transaction_now: Option<u32>
Optional timestamp or sequence number relevant to the transaction.status: MessageProcessingStatus
Enum representing the current processing status of the message.boc: Vec<u8>
Serialized message in BOC format.proof: Option<Vec<u8>>
Optional cryptographic proof related to the message.
Usage Example
let message_set = MessageSerializationSet {
message,
id,
block_id: Some(block_id),
transaction_id: None,
transaction_now: None,
status: MessageProcessingStatus::Pending,
boc: message_boc,
proof: None,
};
TransactionSerializationSet
Encapsulates serialized transaction data along with its identifiers and processing details.
Fields
transaction: Transaction
Transaction object from thetvm_blockmodule.id: TransactionId
Unique identifier for the transaction.status: TransactionProcessingStatus
Enum indicating the transaction processing state.block_id: Option<BlockId>
Optional identifier of the block containing this transaction.workchain_id: i32
Identifier of the workchain related to this transaction.boc: Vec<u8>
Serialized transaction in BOC format.proof: Option<Vec<u8>>
Optional cryptographic proof confirming the transaction's validity.
Usage Example
let transaction_set = TransactionSerializationSet {
transaction,
id,
status: TransactionProcessingStatus::Confirmed,
block_id: Some(block_id),
workchain_id: 0,
boc: transaction_boc,
proof: Some(proof_data),
};
Implementation Details
The serialization sets primarily act as containers combining the core blockchain entities with their serialized BOC representations and optional cryptographic proofs.
The use of
Option<T>types for several fields enables flexible inclusion of metadata when available, accommodating different serialization and proof scenarios.The structures use types from external modules such as
tvm_blockandtvm_typesto represent blockchain-specific data primitives and identifiers.The design supports varied blockchain entities (accounts, blocks, messages, transactions) in a consistent serialization framework facilitating storage, transmission, and processing workflows.
Interaction With Other System Components
These serialization sets interface with the
tvm_blockmodule types (Account,Block,Message,Transaction, etc.), which define the core blockchain entities.The serialization sets are likely used in modules responsible for:
Persisting blockchain data to storage or databases.
Communicating serialized data over the network.
Verifying blockchain entity states via cryptographic proofs.
Processing blockchain events and tracking processing statuses.
By bundling data with serialization and proof information, these structures support consistent state transitions and validation processes elsewhere in the system.
Structure Diagram
classDiagram
class AccountSerializationSet {
+account: Account
+prev_code_hash: Option<UInt256>
+boc: Vec<u8>
+boc1: Option<Vec<u8>>
+proof: Option<Vec<u8>>
+dapp_id: Option<UInt256>
}
class BlockSerializationSetFH {
+block: Block
+id: BlockId
+status: BlockProcessingStatus
+boc: Vec<u8>
+file_hash: Option<UInt256>
}
class DeletedAccountSerializationSet {
+account_id: AccountId
+prev_code_hash: Option<UInt256>
+workchain_id: i32
}
class MessageSerializationSet {
+message: Message
+id: MessageId
+block_id: Option<UInt256>
+transaction_id: Option<UInt256>
+transaction_now: Option<u32>
+status: MessageProcessingStatus
+boc: Vec<u8>
+proof: Option<Vec<u8>>
}
class TransactionSerializationSet {
+transaction: Transaction
+id: TransactionId
+status: TransactionProcessingStatus
+block_id: Option<BlockId>
+workchain_id: i32
+boc: Vec<u8>
+proof: Option<Vec<u8>>
}