Skip to content

[CORE] Implement Dynamic Reentrancy Guard with EIP-1153 Transient Support #753

Description

@mijinummi

Labels: high-difficulty, yul, security, gasguard
Difficulty: High
Module: contracts/security/


🧠 Concept

Develop an adaptive reentrancy guard module in Yul assembly that utilizes EIP-1153 transient storage (TSTORE/TLOAD) if supported by the EVM target, falling back to storage slot packing if transient storage is unavailable.

⚠️ Problem

Standard reentrancy guards write to storage slots (SSTORE), costing $2,100\text{--}5,000\text{ gas}$ per call, whereas transient storage locks cost only $100\text{ gas}$.

📁 Implementation Scope

  • contracts/security/AdaptiveReentrancyGuard.sol
  • test/security/AdaptiveReentrancyGuard.test.ts

🛠️ Requirements

  1. Detect or feature-flag EIP-1153 transient opcode availability.
  2. Implement low-level Yul locks using tstore(slot, 1) and tload(slot) for transient mode.
  3. Fall back gracefully to sstore mode if transient storage is disabled.

🎯 Acceptance Criteria

  • Executes reentrancy checks for under $200\text{ gas}$ in transient mode.
  • Full protection against reentrant function invocations across both modes.

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions