Repository navigation
Conversation
8fb7e01 to
e2f8cb8
Compare
PR SummaryHigh Risk Overview The VM tracks those contracts in Behavior is always on in this version (no consensus flag). Changelog and tests cover validity and VM paths. Reviewed by Cursor Bugbot for commit 6f91dfa. Bugbot is set up for automated code reviews on this repo. Configure here. |
Relax transaction validity so a contract input without the corresponding contract output is valid, denoting a READ-ONLY contract access. This is automatic on this version and is NOT gated behind a consensus parameter: every transaction on the new version supports it. Such an input lets the VM execute the contract's code and read its state and balances, but panics with the new PanicReason::ContractIsReadOnly on any mutation (storage writes and clears, non-zero MINT/BURN, TR/TRO debits or credits, SMO with coins, CALL with forwarded coins). Because a read-only contract's state root and balance root cannot change, no output slot is needed to commit new roots, so block executors can schedule transactions that only read a shared contract concurrently. - fuel-tx: a contract input may now have zero or one associated contract output (more than one is still InputContractAssociatedOutputContract). Input::check/check_without_signature and the TypeScript check_input binding keep their original signatures (no consensus-parameter plumbing). - fuel-asm: new PanicReason::ContractIsReadOnly = 0x43. - fuel-vm: interpreter tracks read_only_contracts (contract inputs without an output slot) and guards every state/balance mutation path; GTF InputContractOutputIndex panics with InputNotFound for read-only inputs (no mapping exists). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
e2f8cb8 to
6f91dfa
Compare
Groundwork for concurrent execution of read-heavy contract transactions (fuel-core's lane-scheduler txpool integration derives
Readaccess for contract inputs without a matching output).Description
Relaxes transaction validity so that a contract input without the corresponding contract output is valid and denotes a read-only contract access. The contract's code can be executed and its state and balances read, but any modification panics. Since a read-only contract's state root and balance root cannot change, no output slot is needed to commit new roots — which lets block producers/schedulers run transactions that only read a shared contract (oracles, config registries) concurrently. Simulation on read-heavy traffic measured up to ~7x throughput once such inputs exist.
This is automatic on the new version — it is not gated behind a consensus parameter. Every transaction on a node running this version supports read-only contract inputs; activation is coordinated by node/VM version, not by an on-chain flag.
fuel-tx
InputContractAssociatedOutputContract).OutputContractInputIndex) is unchanged: a contract output must still point at a contract input.Input::check/Input::check_without_signatureand the TypeScriptcheck_inputbinding keep their original signatures — no consensus-parameter plumbing.fuel-vm
read_only_contractsat init: contract inputs with no entry in the input→output index map.PanicReason::ContractIsReadOnly = 0x43when targeting such a contract:SWW,SWWQ,SWRD/SWRI,SUPD/SUPI,SCWQ) — guarded at the two central chokepointsstorage_write_slot/storage_clear_slot_range;MINT/BURNwith a non-zero amount (zero-amount is a storage no-op and stays allowed);TR/TROdebits and credits;SMOwith coins;CALLwith forwarded coins (coin-less calls work, so read-only contracts remain fully executable).GTF InputContractOutputIndexpanics withInputNotFoundfor a read-only input (no mapping exists), as the map-based lookup already did.Audit notes
The VM does not otherwise rely on every contract input having an output: the input→output index map is consumed only by the GTF opcode above, and all
ContractsState/ContractsAssetswriters route through the guarded paths (the only unguarded writers are Create-tx deployment of the newly created contract and test/diff-revert helpers).Breaking changes
InputContractAssociatedOutputContract). Active for every transaction on this version — not gated behind a consensus parameter.PanicReasonvariantContractIsReadOnly = 0x43(PanicReasonis#[non_exhaustive]).Checklist
Before requesting review
After merging, notify other teams
🤖 Generated with Claude Code