Skip to content

✨ Add TBytes32Stack to LibTransient (issue #1185) - #1542

Open
BhariGowda wants to merge 1 commit into
Vectorized:mainfrom
BhariGowda:feat/transient-bytes32-stack
Open

✨ Add TBytes32Stack to LibTransient (issue #1185)#1542
BhariGowda wants to merge 1 commit into
Vectorized:mainfrom
BhariGowda:feat/transient-bytes32-stack

Conversation

@BhariGowda

Copy link
Copy Markdown
Contributor

Closes#1185

Adds TBytes32Stack a transient storage value stack for bytes32.

Unlike TStack (which generates typed pointers), this stores values directly.

API

  • tBytes32Stack(bytes32/uint256) → pointer
  • push(ptr, bytes32) store value
  • pop(ptr) → remove and return top (reverts if empty)
  • top(ptr) → peek top (reverts if empty)
  • top(ptr, uint256 i) → i-th from top, 0=top
  • size(ptr) → element count
  • clear(ptr) → reset stack

Design

  • Pure assembly, TSTORE/TLOAD
  • Reuses existing StackIsEmpty error
  • Element stride: _STACK_BASE_SALT * slot + ((i+1) << 32)
  • clear() zeroes size only — push always writes before read, no stale values

Tests

7 new tests concrete, fuzz, collision, 3 revert cases
Run: FOUNDRY_PROFILE=post_osaka forge test --match-path test/LibTransient.t.sol
29 passed, 0 failed

@github-actions

Copy link
Copy Markdown

Gas Snapshot Comparison Report

Generated at commit : a723db1, Compared to commit : ab96a83

Contract NameTest NameMain GasPR GasDiff
LibRLPWithCLZTesttestComputeAddressForLargeNonces()1750--
testComputeAddressForSmallNonces()997--
testComputeAddressOriginalForLargeNonces()3495--
testComputeAddressOriginalForSmallNonces()2088--
testRLPEncodeBytes()250090--
testRLPEncodeBytes2()155904--
testRLPEncodeList()735942--
testRLPEncodeList2()810708--
testRLPEncodeListEdgeCases()1807743--
testRLPEncodeStringEdgeCases()20424--
testRLPEncodeUint()1175570--
testRLPPUint256()363834--
test__codesize()18292--
LibTransientTesttestEmptyStackPopReverts()3908394234
testEmptyStackTopReverts()3879394667
testRegistryAB()429436429381-55
testRegistryNotDeployed()723697239122
testSetAndGetBytesTransient()510715111544
testStackPlacePopBytes()378653790944
testUint256IncDecTransient()123992124436444
test__codesize()23261253452084
testBytes32StackPushPop()-4544-
testEmptyBytes32StackPopReverts()-3933-
testEmptyBytes32StackTopIndexReverts()-4362-
testEmptyBytes32StackTopReverts()-3939-

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ LibTransient TStack

1 participant

@BhariGowda