Update BonsaiLayeredWorldState implementation#1999
Conversation
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
| public Optional<MutableWorldState> getWorldState(final Hash rootHash, final Hash blockHash) { | ||
| if (layeredWorldStates.containsKey(blockHash)) { | ||
| return Optional.of(layeredWorldStates.get(blockHash)); | ||
| } else { |
There was a problem hiding this comment.
If we don't load TrieLog layered world states from disk how do we then do traces beyond near chain head? We won't be able to do eth_call 1MM blocks back but we should be able to do trace_* from 1MM blocks back if we have the TrieLogs.
There was a problem hiding this comment.
Indeed I just put back the loading of the layer from the disk but in this case I put the nextLayer (=parent) to empty and I load it on demand (call getNextWorldView : https://github.com/hyperledger/besu/pull/1999/files#diff-b24e30196f7e0d254b3a27e89926831bb450c356a094f435e6a6daa80b10b09dR64)
so as not to load all layers for maybe nothing when we call getMutable
I tried it's work
| } | ||
| final MutableWorldState mutableWorldState = | ||
| worldStateArchive.getMutable(previous.getStateRoot(), previous.getHash()).orElse(null); | ||
| worldStateArchive.getWorldState(previous.getStateRoot(), previous.getHash()).orElse(null); |
There was a problem hiding this comment.
Looks like there is a lingering type/name issue. If the return type is a MutableWorldState then the method name should be getMutable or getMutableWorldState. This should either go to just a WorldState or the method name should be getMutable
There was a problem hiding this comment.
Done renamed to getMutable
| currentLayer.trieLog.getStorageBySlotHash(address, slotHash); | ||
| if (maybeValue.isPresent()) { | ||
| final Optional<UInt256> maybeOriginalValue = | ||
| currentLayer.trieLog.getOriginalStorageBySlotHash(address, slotHash); |
There was a problem hiding this comment.
I don't think this is a good place for getOriginalStorageBySlotHash. Original in the sense of EIP-2200 gas costing. I think we need to go to renaming BonsaiValue getOriginal as getPrior to remove that confusion.
There was a problem hiding this comment.
indeed I wanted to rename it in another PR but why not do it now
|
|
||
| private final BonsaiWorldStateArchive worldStateArchive; | ||
| private final BonsaiWorldView parent; | ||
| private Optional<BonsaiWorldView> parent; |
There was a problem hiding this comment.
So we can have a layer or a persistate Worldstate so I renamed it to nextWorldView because those are both BonsaiWorldView.
Layer9 (parent = = Layer10), Layer10 (parent= = Layer11), Layer11 (parent==PersistedWorldState)
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
|
@shemnon Do you have any other remarks before its merge into master ? |
Update BonsaiLayeredWorldState implementation to find valid code, storage and account corresponding to a block with Bonsai trie storage mode Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Richard Hart <richardhart92@gmail.com>
Update BonsaiLayeredWorldState implementation to find valid code, storage and account corresponding to a block with Bonsai trie storage mode Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM t2am.karim@gmail.com
PR description
Update BonsaiLayeredWorldState implementation to find valid code, storage and account corresponding to a block
Test performed
Fixed Issue(s)
Changelog