Add rollup_getVirtualZkEVMStateMerkleProofV0#135
Add rollup_getVirtualZkEVMStateMerkleProofV0#135garyschulte wants to merge 20 commits intoConsensys:mainfrom
Conversation
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
core/src/main/java/net/consensys/shomei/storage/ZkWorldStateArchive.java
Outdated
Show resolved
Hide resolved
core/src/main/java/net/consensys/shomei/storage/ZkWorldStateArchive.java
Outdated
Show resolved
Hide resolved
...ain/java/net/consensys/shomei/rpc/server/method/RollupGetVirtualZkEVMStateMerkleProofV0.java
Outdated
Show resolved
Hide resolved
core/src/main/java/net/consensys/shomei/storage/ZkWorldStateArchive.java
Show resolved
Hide resolved
services/rpc/client/src/main/java/net/consensys/shomei/rpc/client/model/SimulateV1Response.java
Show resolved
Hide resolved
core/src/main/java/net/consensys/shomei/storage/ZkWorldStateArchive.java
Outdated
Show resolved
Hide resolved
… not head Signed-off-by: garyschulte <garyschulte@gmail.com>
…_getVirtualZkEVMStateMerkleProofV0 Signed-off-by: garyschulte <garyschulte@gmail.com>
...ain/java/net/consensys/shomei/rpc/server/method/RollupGetVirtualZkEVMStateMerkleProofV0.java
Outdated
Show resolved
Hide resolved
services/rpc/client/src/main/java/net/consensys/shomei/rpc/client/model/SimulateV1Request.java
Show resolved
Hide resolved
services/rpc/client/src/main/java/net/consensys/shomei/rpc/client/BesuSimulateClient.java
Show resolved
Hide resolved
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
…might potentially be a snapshot Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
...ain/java/net/consensys/shomei/rpc/server/method/RollupGetVirtualZkEVMStateMerkleProofV0.java
Show resolved
Hide resolved
core/src/main/java/net/consensys/shomei/storage/worldstate/LayeredWorldStateStorage.java
Show resolved
Hide resolved
...java/net/consensys/shomei/rpc/server/method/RollupGetVirtualZkEVMStateMerkleProofV0Test.java
Outdated
Show resolved
Hide resolved
core/src/main/java/net/consensys/shomei/storage/worldstate/LayeredWorldStateStorage.java
Show resolved
Hide resolved
...a/net/consensys/shomei/rpc/server/model/RollupGetVirtualZkEVMStateMerkleProofV0Response.java
Show resolved
Hide resolved
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
b680ab4 to
6a04fea
Compare
core/src/main/java/net/consensys/shomei/storage/worldstate/LayeredWorldStateStorage.java
Show resolved
Hide resolved
Signed-off-by: garyschulte <garyschulte@gmail.com>
...ain/java/net/consensys/shomei/rpc/server/method/RollupGetVirtualZkEVMStateMerkleProofV0.java
Outdated
Show resolved
Hide resolved
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
…onor interrupted exception Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
|
when testing, I found these resources to be useful: and this curl to simulate a block 34 on top of the chain of 33: |
| final TrieStorage.Range parentRange = parentStorage.getNearestKeys(hkey); | ||
|
|
||
| // Check for exact match (center node) in overlay first, then parent (if not deleted) | ||
| Optional<Map.Entry<Bytes, FlattenedLeaf>> centerNode = overlayRange.getCenterNode(); |
There was a problem hiding this comment.
do we need also to use getValidParentNode in this case ?
because it seems we are not checking if the key returned by the overlay is deleted
final TrieStorage.Range overlayRange = overlayStorage.getNearestKeys(hkey);
There was a problem hiding this comment.
We shouldn't need getValidParentNode in that case because we only exact match for center nodes. Line 120 we filter parent range center node by deleted keys.
|
|
||
| private final WorldStateStorage parentStorage; | ||
| private final InMemoryWorldStateStorage overlayStorage; | ||
| private final Set<Bytes> deletedKeys = ConcurrentHashMap.newKeySet(); |
There was a problem hiding this comment.
why not managing the delete in the InMemoryWorldStateStorage ?
There was a problem hiding this comment.
I was reluctant to change InMemoryWorldStateStorage - if you want to change this to use the Besu approach that sounds reasonable. I think the complexity is the same either way since we still have to defer to the parent for getNearest - that is where the complexity is. The unit tests assert correct behavior (on toy state), so we should have good coverage for a refactor
| * This is useful for virtual/simulated blocks where we want to apply changes temporarily | ||
| * without modifying the cached parent state or persist the state permanently. | ||
| */ | ||
| public class LayeredWorldStateStorage implements WorldStateStorage { |
There was a problem hiding this comment.
why not doing something similar to the LayeredKeyValueStorage besu implementation. this way to have InMemoryWorldStateStorage as a field seems to add a lot of complexity in the code
in Besu LayeredKeyValueStorage extend directly a InMemoryWorldStateStorage version that track deletion and we only have the parent
PR Description
Adds an rpc endpoint to encapsulate the eth_simulateV1 call for a single transaction, and returns a proof of a 'virtual' block on top of the specified parent, akin to
rollup_getZkEVMStateMerkleProofV0.Fixed Issue(s)
relates to Consensys/besu-shomei-plugin#70
Documentation
doc-change-requiredlabel to this PR if updates are required.Changelog
Note
Medium Risk
Adds a new RPC path that drives worldstate simulation and trace generation on cached snapshots, plus updates trielog decoding for a new Besu format; correctness and cache/overlay edge cases could affect proof outputs or runtime behavior.
Overview
Adds a new JSON-RPC method
rollup_getVirtualZkEVMStateMerkleProofV0that simulates a single transaction on top of a specified parent block (via Besueth_simulateV1), then returns the parent/end zk state root hashes plus the generated zk state merkle proof.To support non-persistent simulation, introduces
LayeredWorldStateStorage(in-memory overlay with delete tracking) andZkWorldStateArchive.generateVirtualTrace(...)which applies a decoded trielog against a cached parent snapshot using an ephemeral trace store. Also updates trielog decoding for forward compatibility with Besu metadata, improves JSON-RPC client error handling/modeling, bumpsbesuVersion, and adjusts sync queue waiting logic to poll with timeouts/backoff for cleaner shutdown behavior.Written by Cursor Bugbot for commit 8ff6eac. This will update automatically on new commits. Configure here.