Repository navigation
Conversation
added 2 commits
October 25, 2026 00:05
App shaders that read contract vars through a dependent context got confirmed state, while tx validation on that context applies its pending txs first. A contract call quoted this way signs for funds the contract no longer moves, and the kernel fails CheckSigs. We hit it with an AMM trade built on top of someone else's pending trade in the same pool. Cause: ContractVarsEnum runs its worker inside ExecInDependentContext, but the worker reads NodeDB. DependentContextSwitch applies the pending txs with m_Temporary set, so their var changes stay in BlockInterpretCtx::Storage::m_Vars and never reach the DB. Fix: NodeProcessor::EnumContractVars. Inside ExecInDependentContext it walks the temporary storage with Storage::FindVarEx, the same DB plus m_Vars lookup contract execution uses. Outside it reads the DB as before. ContractVarsEnum calls it. Test: TestDependentTxs reads the vault account while the deposit is still pending and expects the deposited amount.
Same bug for logs: ContractLogsEnum runs inside ExecInDependentContext but reads NodeDB only. Here the pending txs' logs aren't kept anywhere, not even in memory: Storage::OnLog writes to NodeDB only when !m_Temporary. Fix: ExecInDependentContext sets BlockInterpretCtx::m_KeepTempLogs, so OnLog keeps temporary logs in m_vTempLogs and the Log undo pops them. NodeProcessor::EnumContractLogs merges them into the DB walk in the DB's order: by position, or by key then position. They all sit at the next height, so they follow DB logs of the same key. ContractLogsEnum calls it. Test: TestDependentTxs reads the vault logs while the deposit is still pending and expects the deposited amount.
profinch
force-pushed
the
dependent-context-pending-txs
branch
from
October 24, 2026 23:05
7eec8fa to
dd41921
Compare
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.
App shaders that read contract vars or logs through a dependent context got confirmed state only, while tx validation on that context applies its pending txs first. A contract call quoted this way signs for funds the contract no longer moves, and the kernel fails CheckSigs. Hit with an AMM trade built on top of someone else's pending trade in the same pool.
Vars (commit 1):
ContractVarsEnumruns insideExecInDependentContextbut reads NodeDB, while the pending txs' var changes live only inBlockInterpretCtx::Storage::m_Vars(applied withm_Temporary). NewNodeProcessor::EnumContractVarswalks the temporary storage withStorage::FindVarExinside a dependent context and the DB otherwise.Logs (commit 2): same for
ContractLogsEnum; temporary logs were not kept anywhere.ExecInDependentContextnow setsm_KeepTempLogs,OnLogkeeps them inm_vTempLogs(popped on undo), and the newNodeProcessor::EnumContractLogsmerges them into the DB walk in DB order.Tests:
TestDependentTxsreads the vault account and the vault logs while the deposit is still pending and expects the deposited amount.Patches authored by @Maxnflaxl, opened on their behalf (account suspended).
🤖 Generated with Claude Code