Closed kkovaacs closed 2 weeks ago
The following needs to be changed:
Currently, we calculate state diff commitments as a Poseidon hash over the following:
Note that all of the lists are ordered (lists of pairs are ordered by the first element of the pair), which is why our code uses BTreeMap
and BTreeHash
.
In v0.13.2, the structure gets more flat, i.e. there is no nested hashing, and the first element is a string instead of a single 0. The state diff commitment should be a Poseidon hash over the following:
[x] Update the transaction commitment calculation algorithm. Currently we calculate the transaction commitment as a Merkle tree hash where the leaves are Pedersen(transaction hash, signature hash). For 13.0.2, the leaves should be Poseidon(transaction hash, signature elem 0, signature elem 1, ...), i.e., a hash over the transaction hash and the signature elements, where the signature does not get hashed separately. Note that the hashing algorithm has changed from Pedersen to Poseidon.
[x] Update the event commitment calculation algorithm. Currently we calculate the event commitment as a Merkle tree hash where the leaves are Pedersen(from address, Pedersen(key 0, key 1, ...), Pedersen(content 0, content 1, ...)). For 13.0.2, the leaves should be Poseidon(from address, transaction hash, num keys, key 0, key 1, ..., num contents, content0, content1, ...), i.e. Poseidon is used instead of Pedersen, there is no nested hashing, and the transaction hash, the number of keys and the number contents in the event are also included in the hash.
[x] Implement the newly added receipt commitment algorithm.
The receipt commitment is a Merkle tree hash where the leaves are Poseidon hashes over the following:
The block hash should be a Poseidon hash (currently it's Pedersen!) over the following:
0b10000000
otherwise.
The new algorithm is already implemented in the
starknet-api
crate.More info: https://community.starknet.io/t/starknet-v0-13-2-pre-release-notes/114223#new-block-hash-definition-4