fix(vm): make initAllow setters drop leftover local snapshot - #19
Open
vividctrlalt wants to merge 1 commit into
Open
fix(vm): make initAllow setters drop leftover local snapshot#19vividctrlalt wants to merge 1 commit into
vividctrlalt wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
VMConfig.initAllow*(),initDynamicEnergy*(), andinitDisableJavaLangMath()writeglobalSnapshotwhile getters readcurrent()(the thread-local snapshot if one is present). After tronprotocol#6857, a leftover local snapshot from a prior constant call hides those writes, so callers ofinit*do not observe the flags they just set.Why
tronprotocol#6857 split VM config into a process-global snapshot (block processing) and a thread-local snapshot (constant calls). That dual-write is the correct production isolation:
current()must keep preferring the local view so a solidity/PBFT constant call cannot pollute HEAD flags.The test-only
init*API (25 test files; production load usessetGlobalSnapshot) was left as "write global, read local". That is a contract bug in the setters themselves. Patching call sites —clearLocalSnapshot()wrappers aroundinit*, clearing the local view fromConfigLoaderwhendisableis set, or BaseTest@Aftercleanup — treats the symptom and misses any test that still calls plaininit*. The one-place fix is: everyinit*setter that mutatesglobalSnapshotfirst drops the leftover local snapshot, then writes the global one.current()is unchanged.Changes
forInit()removes the thread-local snapshot and returnsglobalSnapshot. EveryinitAllow*/initDynamicEnergy*/initDisableJavaLangMathsetter is a single assignment through that helper.VMConfigIsolationTest.testInitIsVisibleWhenLocalSnapshotExistsasserts thatinitAllowTvmLondon(1)is visible even when a stale local snapshot exists.@Afterstill restores the global snapshot.TransactionsMsgHandlerTest: every case that stubs a peer uses a brand-new mock anddoReturn. A shared mock pluswhen(mock.foo())raceshandleTransactioncallingisBadPeer()on the same mock. Boolean mocks default tofalse, so anisBadPeer()stub is not added.Related
tronprotocol#6857
Test plan
./gradlew :framework:test --tests org.tron.common.runtime.vm.VMConfigIsolationTest --tests org.tron.core.net.messagehandler.TransactionsMsgHandlerTest --tests org.tron.common.runtime.vm.AllowTvmLondonTest --tests org.tron.common.runtime.vm.ValidateMultiSignContractTest