matter-labs / zksync

zkSync: trustless scaling and privacy engine for Ethereum
https://zksync.io
Apache License 2.0
4.89k stars 2.68k forks source link

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

Open Boqian-Ma opened 1 year ago

Boqian-Ma commented 1 year ago

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 commented 1 year ago

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?

ssutingh commented 1 year ago

Great!