MultiSig Timelock

First Flight #55
Beginner FriendlyWallet
100 EXP
Submission Details
Impact: low
Likelihood: low

Storage Optimization via Struct Packing

Author Revealed upon completion

Why it matters

The Transaction struct utilizes 6 storage slots per proposal. By packing fields, this can be reduced to 3 slots, saving ~6000 gas per proposal (3x SSTORE) and reducing gas on reads.

Suggested Optimization

Pack confirmations, proposedAt, executed (and potentially to) into a single slot.

Current:

struct Transaction {
address to; // Slot 0 (20 bytes)
uint256 value; // Slot 1 (32 bytes)
bytes data; // Slot 2 (32 bytes - ptr)
uint256 confirmations; // Slot 3 (32 bytes)
uint256 proposedAt; // Slot 4 (32 bytes)
bool executed; // Slot 5 (1 byte)
}

Proposed:

struct Transaction {
address to; // Slot 0 (20 bytes)
uint64 proposedAt; // Slot 0 (8 bytes) - sufficient for timestamp
uint8 confirmations; // Slot 0 (1 byte) - sufficient for max 5
bool executed; // Slot 0 (1 byte)
// Total Slot 0: 30 bytes
uint256 value; // Slot 1 (32 bytes)
bytes data; // Slot 2
}

Estimated Savings

~6000 gas per transaction proposed.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!