Labels: medium-difficulty, yul, assembly, gasguard
Difficulty: Medium
Module: contracts/utils/
π§ Concept
Build an assembly helper function MappingResolver.sol that computes nested mapping storage keys directly in scratch memory (0x00β0x40).
β οΈ Problem
High-level Solidity nested mapping lookups (mapping(address => mapping(uint256 => Struct))) generate repetitive memory allocation and keccak256 hashing instructions.
π Implementation Scope
contracts/utils/MappingResolver.sol
test/utils/MappingResolver.test.ts
π οΈ Requirements
- Use inline assembly
mstore to write key and slot index directly to scratch space (0x00).
- Compute target storage slot via single
keccak256(0x00, 0x40) opcode execution.
- Fetch data using low-level
sload(slot).
π― Acceptance Criteria
Labels:
medium-difficulty,yul,assembly,gasguardDifficulty: Medium
Module:
contracts/utils/π§ Concept
Build an assembly helper function
MappingResolver.solthat computes nested mapping storage keys directly in scratch memory (0x00β0x40).High-level Solidity nested mapping lookups (
mapping(address => mapping(uint256 => Struct))) generate repetitive memory allocation and keccak256 hashing instructions.π Implementation Scope
contracts/utils/MappingResolver.soltest/utils/MappingResolver.test.tsπ οΈ Requirements
mstoreto write key and slot index directly to scratch space (0x00).keccak256(0x00, 0x40)opcode execution.sload(slot).π― Acceptance Criteria