-
Notifications
You must be signed in to change notification settings - Fork 40
ECIP-1046: Precompiled contract for verification of Merkle Inclusion Proofs #97
base: master
Are you sure you want to change the base?
Conversation
* assuming that the leafs should at least be memory addressable * no assumptions wrt blocksize to stay compatible with any future BTC/BCH changes
One issue that has been brought up is that this is solely compatible with BTC, but we may want to support other Merkle structures too. One idea is to add an extra argument to the contract call indicating the method with which the Merkle tree was built and having 0 indicate the BTC structure, 1 indicating the Merkle-Patricia try of ETC, and so on. However, perhaps this is overkill. I was wondering what the community thinks about this concern. |
|
@pyskell which chain do you have in mind with Merkle Tree hashes over 256 bits? AFAIK all the coins you mentioned use double SHA256, and Ethereum uses Keccak-256, which all produce exactly 256-bit, or |
I think @pyskell confused 32 bytes (= 256 bits) with 32 bits. PS it would be nice to use bits in the ECIP, for better readability. |
That I did @splix. Will edit my comment. |
as per the recommendation of @splix
@splix fixed to use bits instead, thanks for the feedback 😄 |
I would again like to point out that this ECIP even though pretty concrete is incomplete without a gas cost. I'd really appreciate some pointers for this. |
Heres my copy of gas prices sheet, the precompiles are set relative to their compute time vs internal operations. |
@realcodywburns thanks for the gas prices sheet, I'm not really sure how to utilise it though as SHA256 is not a primitive operation and it's not included there. I've had difficulty finding any resources on how to appropriately price precompiled contracts, so help would be much appreciated here. Is there a rationale behind pricing? Some invariant I should make sure not to violate? What I'm at currently thinking is that we're doing 2 sha256 operations per sibling, so we should charge less than |
@amiller Could you weight in on the gas costs and how to calculate it? |
I would like to reiterate that we'd like to also provide a meaningful metric about how much the implementation of this ECIP will improve the gas-performance of NIPoPoW verification, even though this may not need to be part of the ECIP itself. This is something we're working on currently. |
There are two kinds of costs here, one being the computation time for the SHA2 calls, the other is the cost of accessing the memory elements. The elements in memory are assumed to already be contiguous right? It seems like the amount of memory to read is variable. Are there any other instructions that get a discount for reading a chunk of memory? |
TODO: gas cost, would appreciate some pointers on how to calculate this