<aside> 💡 Merkle Tree、Merkle Patricia Tree、Rollup State Tree、Verkle Tree和在Airdrop中的使用
</aside>
对不同的数据结构求Hash
https://learnmeabitcoin.com/technical/merkle-root
对Struct求Hash,数据拼接
BlockHash = hash(BlockHeader) = hash(Version+PrevBlock+Time+…)
TxHash = hash(Tx) = hash(To+Value+Sig+…)
对Array求Hash?
hash([TxHash0, TxHash1, TxHash2,…])
?对Map求Hash?
hash({Address0: State0, Address1: State1, …})
?对Array/Map的进行数据拼接
Proof of Inclusion(PoI)
需求:对Array/Map求Hash,且PoI复杂度低
Merkle Tree是一种对Array求Hash的方法,且提供简洁的PoI
https://bitcoin.org/bitcoin.pdf
Hash01 = hash(TxHash0+TxHash1)
Patricia Tree,也叫Radix Tree、Trie
https://en.wikipedia.org/wiki/Radix_tree
可理解为把Merkle Tree从2叉树变成16叉树,再加个value字段
https://medium.com/@chiqing/merkle-patricia-trie-explained-ae3ac6a7e123
把所有的node存到key-value DB里,以hash(node)作为key
node里面叶子的指针替换为叶子的hash(node)
https://ethereum.stackexchange.com/questions/268/ethereum-block-architecture
Merkle Patricia Tree的问题:同时负责了Map的PoI和索引,互相制约性能
Rollup的State Tree对性能要求高:需要在合约验证PoI
对Map的key-value pairs排序后建立Merkle Tree
{Address0: State0, Address1: State1, …}
→
{Address0: Index0, Address1: Index1, ...}
+[(Address0, State0), (Address1, State1), ...]
举例:{Alice: 0, Bob: 6, Charlie: 12, ...}
+
分析
需求:Stateless Client
回顾Data Availability里的KZG commitment
https://docs.google.com/presentation/d/1-pe9TMF1ld185GL-5HSWMAsaZLbEqgfU1sYsHGdD0Vw
https://dankradfeist.de/ethereum/2021/06/18/verkle-trie-for-eth1.html
空间复杂度从Merkle Patricia Tree的$O(16·log_{16}N)$、Merkle Tree的O(logN), 提升为 $O(log_{16}N)$