Skip to content

Commit

Permalink
add qa for lt hash
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoranYi committed Feb 28, 2024
1 parent 307a4ea commit c9a6a7a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions accounts-db/src/accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,27 @@ pub struct AccountHash(pub Hash);
// This also ensures there are no padding bytes, which is required to safely implement Pod
const _: () = assert!(std::mem::size_of::<AccountHash>() == std::mem::size_of::<Hash>());

/// # Account Lattice Hash Q/A
///
/// ## What's account Lattice hash?
/// It is a new way to compute accounts hash based on the Algebra struct Lattice
/// defined on hash field. The field elements are 2048 bytes of hash of
/// individual accounts. This 2048 bytes of hash is computed from blake3 hash.
/// There are two operator defined on the field, add/sub, which are u16 x 1024
/// wrapping add and subtract.
///
/// ## How is the account Lattice hash used?
/// It is used to represent the account state for each slot. Each slot will
/// "add" in the new state of changed accounts and "sub" the old state of the
/// account. This way the accumulated hash of the slot is equal to sum all the
/// accounts state at that slot. The end goal is to replace the current merkle
/// tree hash.
///
/// ## How to handle account deletion and account creation?
/// That's where the identity element in the lattice play it role. All accounts
/// with zero lamport are treated to have the "identity" hash. add/sub such
/// element don't impact the accumulated hash.
///
/// Lattice hash
pub const LT_HASH_BYTES: usize = 2048;
pub const LT_HASH_ELEMENT: usize = 1024;
Expand Down

0 comments on commit c9a6a7a

Please sign in to comment.