core, consensus: handle statedb interface conversion for hooked state db#1623
core, consensus: handle statedb interface conversion for hooked state db#1623
Conversation
|
@manav2401
Review Let me double check my claim, as you passed a hooked stateDB at least in After review, there is still some places where the But everything should work properly, we can update our own PR on top of yours just to adjust the changes related to |
|
Hi @maoueh, thanks for your inputs. I initially thought the remaining functions like I think your PR might also work but there are some extra interface methods you've added which may not be needed. |
|
Okay, I found a few minor issues around using state db correctly which I've fixed. I've also updated the PR to pass around |
|
@manav2401 yeah with the remaining passing around of
Yeah we have follow up PRs to wrap more nicely the tracing around those part too. |
… db (0xPolygon#1623) Pass around a wrapper `vm.StateDB` instance and expose public methods for accessing underlying state db which can be different for normal v/s tracing mode.
Description
Fixes #1577
Earlier in bor consensus, we just used to extract the underlying db by type conversion (as it's just wrapped by the
vm.StateDBinterface) like this:This may panic (as the issue suggests) when the underlying db is not simple
*state.StateDBbut a hooked state db if tracing is enabled. It's a wrapper over*state.StateDBbut handles tracing hooks for abstraction. Moreover, it won't allow live tracing as we're directly using the state db instance.This PR passes the wrapped state db (interface) to consensus methods (using state for committing spans and bridge events).
Moreover, it also adds 2 additional interface methods
SetBalance: For setting balance which is used by bor consensus when there's a hard fork (the new interface doesn't support it so need to add it for tracing)Inner: Returns the inner state db instance (for hooked as well as normal state db)We could have handled the interface conversion for hooked state db as well to solve this simply but the
SetBalancecall wouldn't be tracked if tracing is enabled.Changes
Breaking changes
Please complete this section if any breaking changes have been made, otherwise delete it
Nodes audience
In case this PR includes changes that must be applied only to a subset of nodes, please specify how you handled it (e.g. by adding a flag with a default value...)
Checklist
Cross repository changes
Testing
Manual tests
Please complete this section with the steps you performed if you ran manual tests for this functionality, otherwise delete it
Additional comments
Please post additional comments in this section if you have them, otherwise delete it