Near-One / rainbow-bridge

🌈🌈🌈 NEAR <> Ethereum Decentralized Bridge
GNU General Public License v3.0
327 stars 100 forks source link

Add eth proof generation utilities #928

Closed kiseln closed 8 months ago

kiseln commented 8 months ago

Replacement for https://github.com/aurora-is-near/rainbow-bridge/blob/master/eth2near/eth2near-block-relay/eth-proof-extractor.js#L86 written in Rust.

Javascript version is used here https://github.com/aurora-is-near/fast-bridge-service/blob/8ed92f1b9c051d49083726803d112aeaa5e51d52/src/ethereum/proof.rs#L40

Supporting older blocks I tested this on post merge and post-4844 blocks. Older blocks may not work (for example because of different handling of difficulty field). If needed I'll test and add support for pre-merge.

Tests I intended to mock RPC requests and add a few tests for the client as well ass more general test cases for proof generation. Would that be the correct approach?

Error handling As one can see it's Box almost everywhere. I can put some work towards friendlier error types.

Types I chose not to expose the types I added publicly. They are quite specifically designed for deserialization and support only required fields. In the future they can be improved and exposed to other components if that is deemed useful

kiseln commented 8 months ago

Also, I think the utilities better rename into eth_proof_extractor or something like this.

Depends whether proof generation is the only thing we are going to expose from this crate. If we, say, also want to expose the new ETH client then 'utilities' would work better