ethers-io / ethers.js

Complete Ethereum library and wallet implementation in JavaScript.
https://ethers.org/
MIT License
7.89k stars 1.83k forks source link

Different Hashing Mechanism Causes Comparison Error in Ether.js #4233

Open danilowhk opened 1 year ago

danilowhk commented 1 year ago

Describe the Feature

Problem

In Kakarot ZkEVM, we are not using the same hashing mechanism(keecak) as Ethers.js for our transactions. Currently, when deploying a contract, Ethers.js precomputes the hash of a transaction and then compares it with the returned transaction hash. Due to our different hashing mechanisms, the returned hash is different causing a comparison error.

I believe the assertation is being done in this line:

https://github.com/ethers-io/ethers.js/blob/1dd542721d3a9e74d10a92847200f4b2aa5da618/dist/ethers.js#L9386

For more info, currently Kakarot is using the tx_hashes calculated by starknet:

https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/

Impact

This discrepancy between hashing mechanisms prevents us from effectively using Ethers.js for deploying our contracts. It throws a comparison error that stops the process.

Proposal

We had some ideas of what we could do from our side but first wanted to check with the ethers.js team what are your thoughts and suggestions on how to solve this.

Thank you for your attention to this matter.

Code Example

No response

ClementWalter commented 1 year ago

What are the benefit of precomputing the tx hash and not using the one returned?