feat(scenarios): add reusable raw-layout overrides - #15
Conversation
| /// IDL for the account structure - defines all available fields and types. | ||
| /// | ||
| /// `None` for programs that publish no IDL and are written through `raw_layout` instead. Those | ||
| /// templates cannot use the IDL write path at all, so there is nothing to reconstruct here. | ||
| pub idl: Option<Idl>, |
There was a problem hiding this comment.
When a raw-layout template is returned with idl: null, Studio's action-selection handler rejects it as missing an IDL and returns before fetching the account or constructing the override. This makes raw-layout templates unusable in the coupled scenario editor, despite exposing them through the same template contract.
Knowledge Base Used: Shared data contracts
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/types/src/scenarios.rs
Line: 396-400
Comment:
**Optional IDL breaks Studio**
When a raw-layout template is returned with `idl: null`, Studio's action-selection handler rejects it as missing an IDL and returns before fetching the account or constructing the override. This makes raw-layout templates unusable in the coupled [scenario editor](https://github.com/limechain/surfpool-web-ui/blob/HEAD/apps/studio/src/components/svm/scenario-editor.tsx#L524-L533), despite exposing them through the same template contract.
**Knowledge Base Used:** [Shared data contracts](https://app.greptile.com/limechain/-/custom-context/knowledge-base/limechain/surfpool/-/docs/shared-data-contracts.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| /// For programs that publish no IDL. Their templates must carry a `raw_layout` and spell out | ||
| /// every property description, since there is no schema to fall back on. | ||
| pub fn load_raw_layout_overrides(&mut self, overrides_content: &str, protocol_name: &str) { | ||
| self.load_collection(None, overrides_content, protocol_name); |
There was a problem hiding this comment.
Raw-layout invariants remain unvalidated
load_raw_layout_overrides accepts collections without raw_layout and writable properties without both offset and encoding. These invalid templates are inserted successfully and fail only during scheduled materialization, leaving the account unchanged after emitting a warning; validate the required combinations while loading the collection.
Knowledge Base Used: Scenario execution
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/core/src/scenarios/registry.rs
Line: 195-198
Comment:
**Raw-layout invariants remain unvalidated**
`load_raw_layout_overrides` accepts collections without `raw_layout` and writable properties without both `offset` and `encoding`. These invalid templates are inserted successfully and fail only during scheduled materialization, leaving the account unchanged after emitting a warning; validate the required combinations while loading the collection.
**Knowledge Base Used:** [Scenario execution](https://app.greptile.com/limechain/-/custom-context/knowledge-base/limechain/surfpool/-/docs/scenario-execution.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Greptile Summary
The PR introduces optional IDL-free templates backed by guarded raw byte layouts, exact integer encodings, strided writes, and a new materialization path in the SVM.
Confidence Score: 4/5
The PR should not merge until the coupled Studio client can select and edit templates whose IDL is intentionally absent.
Raw-layout templates are emitted with
idl: null, while Studio’s current action-selection path rejects exactly that shape; loader validation is also deferred until materialization.Files Needing Attention: crates/types/src/scenarios.rs, crates/core/src/scenarios/registry.rs
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR Scenario[Scheduled override] --> Resolve[Resolve account] Resolve --> Layout{Template has raw layout?} Layout -->|Yes| Guard[Check size and magic] Guard --> Encode[Encode supplied values] Encode --> Write[Write offsets and strides] Write --> State[Update local account] Layout -->|No| IDL[Existing IDL materialization] IDL --> StatePrompt To Fix All With AI
Reviews (1): Last reviewed commit: "feat(scenarios): add reusable raw-layout..." | Re-trigger Greptile
Context used: