zksync icon indicating copy to clipboard operation
zksync copied to clipboard

Is the balance tree in CircuitAccount a binary sparse merkle tree?

Open Boqian-Ma opened this issue 2 years ago • 2 comments

From the implementation, it seems like the balance tree uses the same sparse merkle tree data structure as the circuit account tree.

pub struct CircuitAccount<E: RescueEngine> {
    pub subtree: SparseMerkleTree<Balance<E>, E::Fr, RescueHasher<E>>,
    pub nonce: E::Fr,
    pub pub_key_hash: E::Fr,
    pub address: E::Fr,
}

However, as noted in the illustration in protocol.md, the balance tree is none binary.

What is the correct interpretation?

Boqian-Ma avatar Jun 15 '23 07:06 Boqian-Ma

Follow up questions:

  1. why does CircuitAccountTree have a sub tree, but not AccountTree?
  2. Do both reside in the "server"?
  3. Why are there two trees?

Boqian-Ma avatar Jun 15 '23 07:06 Boqian-Ma

Great!

ssutingh avatar Jul 03 '23 02:07 ssutingh