Near-One / rainbow-bridge

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

Near2EthProver #36

Closed MaksymZavershynskyi closed 4 years ago

MaksymZavershynskyi commented 4 years ago

We need to write a contract that verifies the merkle proofs towards certain transaction outcomes. The specific design of the proofs is discussed here: https://github.com/nearprotocol/nearcore/issues/2632

bowenwang1996 commented 4 years ago

Maybe I misunderstand what code you are talking about, but I don't think Misha wrote any of that code. It would be unfair to attribute potential suboptimalities to him.

MaksymZavershynskyi commented 4 years ago

@mikhailOK used to own nearcore/core/storage/state code between Autumn'19 and Spring'20. This code implements Merkle Patricia Trie and he is very familiar with it. NearProver would need to work with the paths in generated by that code.

bowenwang1996 commented 4 years ago

I see. But proofs for transaction outcomes is not stored in state. Maybe you mean something else.

MaksymZavershynskyi commented 4 years ago

I see. But proofs for transaction outcomes is not stored in state. Maybe you mean something else.

Correct. We have two different architectures for proving "events" in Near:

For the former we need someone who wrote or worked with merkelization code https://github.com/nearprotocol/nearcore/blob/4713f5f88a7a57d6b5a13ed1057289858d63f134/core/primitives/src/merkle.rs#L28 I guess it is you? So you might be right that @k06a would need to be asking your help instead of @mikhailOK 's.

k06a commented 4 years ago

Could we generate proofs by building Tree/Trie for all outcomes?

MaksymZavershynskyi commented 4 years ago

Could we generate proofs by building Tree/Trie for all outcomes?

I think that would be the best way to do it. Really easy, just read borsh-serialized transaction outcomes and merkelize them, the code is all there.

bowenwang1996 commented 4 years ago

@nearmax

Proving certain state.

I think we don't have this exposed properly. See https://github.com/nearprotocol/nearcore/issues/2076. It might require some effort.

MaksymZavershynskyi commented 4 years ago

Yup, we don't have it exposed. That's why we are going with the transaction outcome.