lfglabs-dev / lfglabs-dev/verity

Storage: Bool/Uint8/Bytes32 scalars, packed bool/address slots and FixedArray Uint256 gaps cannot be declared (solc layout parity)

Open
#2,417 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lean
Stars
148
Forks
20
Avg merge
1d 14h
Merged PRs (30d)
29

Description

Found while declaring the real solc 0.8.10 storage layout of the Pareto Credit Vault contracts (IdleCDOEpochVariant, IdleCreditVault) as verity_contract storage on top of #2413.

Rejected declarations (all needed for a layout-faithful model):

flag : Bool := slot 0            -- error: storage field cannot be Bool; use Uint256 (0/1) encoding
flag : Uint8 := slot 286         -- error: storage field cannot be Uint8; use Uint256 encoding
gap : FixedArray Uint256 49 := slot 1   -- error: storage fixed arrays currently support only Uint128 elements
b : Bytes32 := slot 1            -- error: storage field cannot be Bytes32; use Uint256 encoding

Consequences on the Pareto layout (IdleCDOEpochVariant):

slot Solidity members (byte offset)
0 uint8 _initialized (0), bool _initializing (1)
211 address uniswapRouterV2 (0), bool allowAAWithdraw (20), allowBBWithdraw (21), revertIfTooLow (22), skipDefaultCheck (23)
286 bool isEpochRunning (0), allowAAWithdrawRequest (1), allowBBWithdrawRequest (2)
296 bool allowInstantWithdraw (0), disableInstantWithdraw (1), defaulted (2), address keyring (3)
301 bool isDepositDuringEpochDisabled (0), isInterestMinted (1)

Only narrow UintN/Uint16 fields participate in automatic packing (applyAutomaticPackedLayout), Address resets the packing cursor, and one word-sized field per slot is enforced, so none of these slots can be declared. The OZ uint256[49] __gap arrays and bytes32 _lastCallerBlock are also not declarable.

Workaround used in the closure repo: 0/1 words, offset-0 member at the physical slot, other packed members at a documented logical slot 1000000 + slot*1000 + offset, gaps undeclared.

Ask: allow Bool/Uint8 (1-byte) and Address (20-byte) members in the automatic packing cursor with their Solidity offsets, FixedArray Uint256 n storage, and Bytes32 scalars.

Closure-side tracking: audit/VERITY-GAPS.md G4/G17.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with applyAutomaticPackedLayout and the storage declaration errors, using the rejected Bool, Uint8, FixedArray Uint256, and Bytes32 declarations as cases. Compare the requested Solidity offsets and slot behavior with the workaround documented in audit/VERITY-GAPS.md; done means these declarations are accepted with packed offsets, Uint256 fixed arrays, and Bytes32 scalars.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.