Conversation
Rule Review: No warnings found; one minor noteRules checked: WarningsNone. Info
Overall: The fix is sound. Rule review against |
d870416 to
5ea36c8
Compare
…code Previously, return_contract_code controlled both the network request (whether peers include WASM in response) and the client response. When false, the node never received the WASM from the network, preventing it from caching, validating updates, or accepting SUBSCRIBE requests. Now the node always requests contract code from the network (internal fetch_contract=true) and only strips it from the client response when return_contract_code=false. This separates the client bandwidth optimization from the node's internal caching needs. Closes #3757 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Problem
When a client sends a GET with
return_contract_code: false, the node does not cache the contract WASM locally. This causes:The workaround (always setting
return_contract_code: true) wastes bandwidth sending WASM to clients that already have it.Approach
Separate the two concerns that
return_contract_codewas conflating:fetch_contract: trueinternally) so the node can cache WASM for validation, subscription, and hostingreturn_contract_code: false(bandwidth optimization)Added a
client_return_codefield toGetOpthat tracks the client's original preference. The node always fetches WASM from the network, butto_host_result()respects the client preference when building the response.Testing
get_op_to_host_result_strips_contract_when_client_return_code_false- Verifies contract is included/excluded in client response based onclient_return_codestart_op_always_fetches_contract_code- Verifiesfetch_contractis alwaystrueinternally even when client passesfalsecargo test -p freenetpassCloses #3757
[AI-assisted - Claude]