New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle block related op codes #75
Comments
This makes sense. I think that we should start by building a table (block_constants_table) of these constants in the verifier contract similar to here From there we have two choices
@DreamWuGit what do you think about the two proposal above ? Does my explanation of the earlier part match your understanding ? |
I think we would have built block hashes in layer1 contract for fast retrieval instead of calculating previous block hashes on the fly. Does it make sense to store previous 256 block hashes in layer1 contract @barryWhiteHat? Also In my WIP In normal case, such static data could be retrieve by copy constraint, but since there is So I try to put block context in |
storing multiple block info seems make sense to me, but I think new dependent table instead of combing with tx_lookup table seems semantical reasonable, I draft one spec here: https://hackmd.io/_odTfR3jTCWYE1NxhLjMVw?view |
This kind of came up in a similar discussion I had with Barry, but using an L2 contract seems an elegant solution to handle the block hashes. There's even an EIP for this that would make Ethereum itself work in the same way, so we can use this as a reference: https://github.com/ethereum/EIPs/blob/e2f2cc8790c2ac22e1079f48b623bdf200379749/EIPS/eip-2935.md So no need for special lookup tables for this, just a standard read from storage (no extra inputs necessary). This approach could perhaps be used for other data as well. |
Ah cool, |
Good idea! Making L2 contract to store block hashes requires L2 to develop a dedicated contract (sounds like precompile system contract ) and modify geth to pipe new block hash into it when new block generates, Do we have plan for this part work ? |
I think it would be good to wait on doing EIP2935 for now. I want to avoid adding more changes to geth if we can avoid them.
Yeah i think this should do for now.
I am not sure of the best table format maybe @han0110 has a better idea. Seems so far we have
2 and 3 are constructed in the l1 contract at the moment. Not sure if they should be together or seperate. |
I think the only thing that might need lookup is the So if |
Why don't we want to add more lookup tables ? for me that seems like the simplest approach for this. |
I thought that since |
I think the Probably still a bit trickier than the lookup approach though (but it should also make some other things easier), so just putting this potential idea out here for whenever we may want to follow that approach. |
I look at the #77 , agree with Non blockhash constant (number, coinbase, gaslimit .etc. ) wrapping into instruction and use directly without lookup, which seems easily constrains building , I am doing
interesting, one point if that when the L2 starts, the contract should be deployed at the beginning , otherwise |
I don't think the |
As However, with a revisit to use cases of these fields, most of them are read out and directly pushed onto the stack like:
Only some would also be used as raw value in other place:
However, if they exist as raw value in table, we need to do a "base conversion" from So it seems we inevitably need to do such "base conversion" once for |
I think this is relevant to how to construct account table( or anywhere,) associating to balance about raw value use, right? about |
Yes, from stack operation perspective, all needs random linear combination. The way I tried to propose to construct the read-write table (containing the account read/write) is to have less-bit keys as possible, because we need to verify that they are sorted. So I prefer to have |
sounds good , but if the work is still in early stage , I tend to keep them unchanged for now, can do it later and more time revisit & consideration |
Status list to track :
|
The missing piece (history_hashes) was done some time ago: https://github.com/privacy-scaling-explorations/zkevm-specs/blob/master/src/zkevm_specs/evm_circuit/execution/blockhash.py |
there is kind of op codes referring to block properties , i.e. Blockhash, Coinbase, gas limit, Difficulty, Timestamp etc. except
Blockhash
requires Keccak256 hash operation, others behave similarly:getting target property from block context and push to stack , also with some type conversion sometimes.
for
Blockhash
need separated handling regarding to Keccak256 circuit.for others , my intuitive approach is constructing block context (or called properties )table, which contains such above properties, and carefully deal with each data type in circuit , by looking up this table to constraint them. additional to add these properties into tests' block section for witness feeding.
appreciate to hear more ideas or comment here :)
The text was updated successfully, but these errors were encountered: