Labels: medium-difficulty, yul, memory, gasguard
Difficulty: Medium
Module: contracts/utils/
🧠 Concept
Build an assembly helper function bytesConcat(bytes calldata a, bytes calldata b) that constructs concatenated byte arrays directly in contiguous free memory.
⚠️ Problem
Solidity's native bytes.concat() allocates temporary intermediate memory buffers and executes repetitive loop boundaries for each byte segment.
📁 Implementation Scope
contracts/utils/YulBytesUtils.sol
test/utils/YulBytesUtils.test.ts
🛠️ Requirements
- Read free memory pointer at
0x40.
- Copy memory chunks using 32-byte word loops (
calldatacopy / mcopy where available).
- Update free memory pointer precisely without allocating unused padding space.
🎯 Acceptance Criteria
Labels:
medium-difficulty,yul,memory,gasguardDifficulty: Medium
Module:
contracts/utils/🧠 Concept
Build an assembly helper function
bytesConcat(bytes calldata a, bytes calldata b)that constructs concatenated byte arrays directly in contiguous free memory.Solidity's native
bytes.concat()allocates temporary intermediate memory buffers and executes repetitive loop boundaries for each byte segment.📁 Implementation Scope
contracts/utils/YulBytesUtils.soltest/utils/YulBytesUtils.test.ts🛠️ Requirements
0x40.calldatacopy/mcopywhere available).🎯 Acceptance Criteria