feat(dvm): C6 call_sc + incoming-value forward (fixes #118) - #119
Open
liqdmetal wants to merge 2 commits into
Open
feat(dvm): C6 call_sc + incoming-value forward (fixes #118)#119liqdmetal wants to merge 2 commits into
liqdmetal wants to merge 2 commits into
Conversation
liqdmetal
force-pushed
the
feature/dvm-c6-callsc
branch
from
August 25, 2026 01:45
2f7e01d to
ccc7453
Compare
…ntrinsic dep) call_sc(scid, entrypoint, name1, val1, ...) -> 0/1: nested DVM invocation sharing the same tx (one gas budget, one commit point). Snapshot/rollback on callee failure, recursion cap at 8, SCIDSELF + Chain_inputs.SCID switched for the nested run so LOAD/STORE hit the target's tree. Effect: separate audited contracts can call each other (composability). Self-contained — no dependency on the intrinsics package.
liqdmetal
force-pushed
the
feature/dvm-c6-callsc
branch
from
August 25, 2026 02:06
ccc7453 to
6c0bd12
Compare
Reserved args value/assetvalue/asset move the caller incoming pot into the callee for the nested run. Insufficient funds returns 2 and rolls back. TestC6_ValueForward covers credit + over-forward.
Author
|
Folded local maturity: call_sc now forwards incoming DERO/asset via reserved args value/assetvalue/asset. Callee sees DEROVALUE()==forwarded amount; insufficient funds returns 2 and rolls back. TestC6_ValueForward. Branch is flat on community-dev (no intrinsic dep). |
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.
Summary
C6 from the improvement agenda — cross-contract calls:
call_sc.The single biggest DeFi gap in DERO's DVM is closed: a contract can now
call another contract. No more monolithic dApps.
The primitive
call_sc(scid_hex String, entrypoint String, name1, val1, name2, val2, ...) -> Uint64entrypointin a nested DVM invocation sharing thesame tx: one gas budget, one commit point, deferred transfers intact
Execution semantics (the safe minimal version)
SCIDSELF+Chain_inputs.SCIDto the target and resolves/executes against the target's own treeMonitor_recursioncap of 8 (the codebase's own comment says 64 is already excessive); exceeding it fails the call cleanly, never panics the parentverify_sig(K0 Fix C) — never trusts "who called me"call_scbase cost 10,000 + the callee's execution on the shared budgetDeliberately NOT in v1
Changes
dvm/dvm_functions.go—dvm_call_schandler + func_table entry (>= 10.0.0)dvm/dvm.go—Shared_StategainsTreeCache+Snapshot(to reach any SC's tree)dvm/sc.go—Execute_sc_functioncarries the tree cache/snapshot throughdvm/simulator.go,blockchain/transaction_execute.go— wire the tree cache/snapshotTests (
dvm/call_sc_test.go)TestC6_NestedSuccessInc(7)→ count persisted = 7TestC6_FailureRollbackpoison) discardedTestC6_RecursionCapFull dvm suite green; whole tree builds.
Why this matters
Router, escrow, and token can now be separate audited contracts calling
each other instead of one giant contract where a bug in any piece
compromises all of it. Standard interfaces become possible. Upgrade
layering (swap an oracle behind a stable interface) becomes possible.
This is the composability primitive that a settlement rail — atomic swaps,
DEX, confidential AMM, perpDEX — is built on.
Relationship
research-docs/cross-contract-calls.md(issue Cross-contract calls (CALL_SC) — design proposal #87)Branch:
feature/dvm-c6-callscin the forkliqdmetal/derohe-improvements-by-liqdmetal(stacked onfeature/dvm-v9-intrinsics).