cosmos / ibc-rs

Rust implementation of the Inter-Blockchain Communication (IBC) protocol.
Apache License 2.0
182 stars 74 forks source link

FR: Allow customising HostFunctionsProvider in MerkleProof #1147

Closed mina86 closed 3 months ago

mina86 commented 3 months ago

Feature Summary

At the moment MerkleProof hard-codes ics23::HostFunctionsManager as generic argument to ics23::verify_membership and ics23::verify_non_membership functions. That manager implements all necessary methods using crates.

However, on platforms where syscalls are provided for calculating hashes this is wasteful and in fact may lead to program failure due execution time limits.

I’m specifically talking about Solana. We're hitting compute units limits when trying to verify proofs. Solana offers syscalls for hash functions which execute naively by the runtime and thus consume less compute units. But as described above there’s no way for us to use those syscalls in ibc-rs since it just assumes HostFunctionsManager.

Proposal

Make MerkleProof proof generic on the ics23::HostFunctionsProvider and expose that configuration to the users of deliver function. I don’t know what’s the best option of achieving that to be honest.