Skip to content

feat: add BytesParser library, update TypeConverter#51

Merged
0xIryna merged 1 commit intomainfrom
feat/bytes-parser
Mar 26, 2026
Merged

feat: add BytesParser library, update TypeConverter#51
0xIryna merged 1 commit intomainfrom
feat/bytes-parser

Conversation

@0xIryna
Copy link
Copy Markdown
Collaborator

@0xIryna 0xIryna commented Mar 26, 2026

Motivation

Extract libraries used by different Portals repos to reduce code duplication.

Proposed Changes

  • add BytesParser library
  • update TypeConverter library to include toUint16 and toUnit32

Note

Both BytesParser and TypeConverter have been audited externally as a part of Portal V2 codebase

@0xIryna 0xIryna requested a review from PierrickGT March 26, 2026 04:29
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 26, 2026

CLA assistant check
All committers have signed the CLA.

@0xIryna 0xIryna requested a review from denalimarsh March 26, 2026 04:29
@github-actions
Copy link
Copy Markdown

Changes to gas cost

Generated at commit: 3e660a6379cd9b6dc1af3de97b0236607ef07b58, compared to commit: 4a405007235b8b145c08456a05cdbdcd43609bd2

🧾 Summary (20% most significant diffs)

Contract Method Avg (+/-) %
Proxy fallback
mint
transferFrom
+30,966 ❌
+156 ❌
-63 ✅
+76.18%
+0.21%
-0.15%
ERC20ExtendedHarness transferFrom -53 ✅ -0.16%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
Proxy 104,329 (+12) burn
fallback
mint
permit
receiveWithAuthorization(address,address,uint256,uint256,uint256,bytes32,bytes)
receiveWithAuthorization(address,address,uint256,uint256,uint256,bytes32,bytes32,bytes32)
receiveWithAuthorization(address,address,uint256,uint256,uint256,bytes32,uint8,bytes32,bytes32)
transfer
transferFrom
transferWithAuthorization(address,address,uint256,uint256,uint256,bytes32,bytes)
transferWithAuthorization(address,address,uint256,uint256,uint256,bytes32,bytes32,bytes32)
transferWithAuthorization(address,address,uint256,uint256,uint256,bytes32,uint8,bytes32,bytes32)
28,930 (0)
5,107 (0)
33,504 (0)
28,708 (+12)
69,846 (0)
69,068 (0)
38,250 (0)
28,931 (0)
29,457 (0)
69,807 (0)
69,052 (0)
38,113 (0)
0.00%
0.00%
0.00%
+0.04%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
34,151 (-37)
71,617 (+30,966)
73,235 (+156)
68,811 (+3)
87,840 (-2)
87,062 (-2)
84,757 (-2)
40,552 (+1)
40,640 (-63)
87,791 (-2)
87,036 (-2)
84,795 (-2)
-0.11%
+76.18%
+0.21%
+0.00%
-0.00%
-0.00%
-0.00%
+0.00%
-0.15%
-0.00%
-0.00%
-0.00%
31,311 (0)
73,364 (+63,749)
73,412 (+12)
84,102 (+12)
88,114 (0)
87,336 (0)
87,533 (0)
40,459 (0)
35,293 (-12)
88,063 (0)
87,308 (0)
87,403 (+8)
0.00%
+663.02%
+0.02%
+0.01%
0.00%
0.00%
0.00%
0.00%
-0.03%
0.00%
0.00%
+0.01%
39,486 (0)
118,807 (0)
73,688 (0)
84,979 (0)
88,498 (0)
87,720 (0)
87,925 (0)
51,976 (0)
57,803 (0)
88,447 (0)
87,692 (0)
87,787 (0)
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
513 (0)
1,602 (+1,542)
2,056 (-1,542)
1,542 (0)
257 (0)
257 (0)
271 (0)
514 (0)
772 (0)
257 (0)
257 (0)
270 (0)
ERC20ExtendedUpgradeableHarness 1,964,420 (0) burn
mint
receiveWithAuthorization(address,address,uint256,uint256,uint256,bytes32,bytes)
receiveWithAuthorization(address,address,uint256,uint256,uint256,bytes32,bytes32,bytes32)
receiveWithAuthorization(address,address,uint256,uint256,uint256,bytes32,uint8,bytes32,bytes32)
transferFrom
transferWithAuthorization(address,address,uint256,uint256,uint256,bytes32,bytes)
transferWithAuthorization(address,address,uint256,uint256,uint256,bytes32,bytes32,bytes32)
2,789 (0)
7,154 (0)
41,138 (0)
40,798 (0)
9,766 (0)
2,936 (0)
41,087 (0)
40,770 (0)
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
7,737 (-22)
46,566 (-22)
63,492 (-1)
63,152 (-1)
60,463 (-1)
15,321 (-70)
63,443 (0)
63,126 (0)
-0.28%
-0.05%
-0.00%
-0.00%
-0.00%
-0.45%
0.00%
0.00%
7,176 (0)
46,954 (0)
63,838 (0)
63,498 (0)
63,557 (0)
8,262 (0)
63,807 (+20)
63,490 (+20)
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
+0.03%
+0.03%
12,776 (0)
46,954 (0)
63,858 (0)
63,518 (0)
63,577 (0)
35,516 (0)
63,807 (0)
63,490 (0)
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
513 (0)
3,598 (0)
257 (0)
257 (0)
271 (0)
772 (0)
257 (0)
257 (0)
ERC20ExtendedHarness 1,668,770 (+2,040) approve
burn
mint
permit
receiveWithAuthorization(address,address,uint256,uint256,uint256,bytes32,bytes)
receiveWithAuthorization(address,address,uint256,uint256,uint256,bytes32,bytes32,bytes32)
receiveWithAuthorization(address,address,uint256,uint256,uint256,bytes32,uint8,bytes32,bytes32)
transfer
transferFrom
transferWithAuthorization(address,address,uint256,uint256,uint256,bytes32,bytes)
transferWithAuthorization(address,address,uint256,uint256,uint256,bytes32,bytes32,bytes32)
transferWithAuthorization(address,address,uint256,uint256,uint256,bytes32,uint8,bytes32,bytes32)
24,253 (0)
24,120 (+12)
28,461 (0)
23,844 (-24)
60,722 (0)
59,867 (0)
29,135 (0)
24,121 (+12)
24,606 (+12)
60,574 (0)
59,851 (0)
29,038 (0)
0.00%
+0.05%
0.00%
-0.10%
0.00%
0.00%
0.00%
+0.05%
+0.05%
0.00%
0.00%
0.00%
43,213 (-2)
29,328 (-16)
47,671 (+38)
60,385 (+4)
78,714 (-1)
77,859 (-1)
75,574 (-2)
33,166 (-21)
33,079 (-53)
78,554 (-2)
77,831 (-2)
75,611 (-2)
-0.00%
-0.05%
+0.08%
+0.01%
-0.00%
-0.00%
-0.00%
-0.06%
-0.16%
-0.00%
-0.00%
-0.00%
46,237 (0)
28,711 (0)
51,413 (0)
74,948 (+10)
78,982 (0)
78,127 (0)
78,344 (0)
28,871 (0)
31,885 (0)
78,830 (0)
78,107 (0)
78,210 (-8)
0.00%
0.00%
0.00%
+0.01%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
-0.01%
46,537 (0)
34,695 (0)
68,873 (0)
75,845 (0)
79,374 (+12)
78,519 (+12)
78,740 (+12)
51,955 (0)
54,647 (-24)
79,202 (0)
78,479 (0)
78,590 (0)
0.00%
0.00%
0.00%
0.00%
+0.02%
+0.02%
+0.02%
0.00%
-0.04%
0.00%
0.00%
0.00%
14,008 (-15)
13,363 (0)
16,535 (-2)
1,542 (0)
257 (0)
257 (0)
271 (0)
13,346 (0)
13,687 (0)
257 (0)
257 (0)
270 (0)
ERC20ExtendedHandler 766,618 (0) approve
burn
mint
transfer
transferFrom
29,595 (0)
41,975 (-386)
381 (0)
477 (0)
488 (0)
0.00%
-0.91%
0.00%
0.00%
0.00%
48,241 (+3)
45,600 (-20)
52,431 (+47)
65,689 (-39)
62,492 (-93)
+0.01%
-0.04%
+0.09%
-0.06%
-0.15%
51,567 (0)
44,691 (0)
62,063 (0)
60,908 (0)
61,141 (0)
0.00%
0.00%
0.00%
0.00%
0.00%
51,879 (0)
53,627 (0)
96,839 (0)
131,481 (0)
133,635 (-24)
0.00%
0.00%
0.00%
0.00%
-0.02%
12,707 (0)
12,850 (0)
12,941 (0)
12,833 (0)
12,919 (0)
ContractHelperHarness 221,136 (0) getContractFrom 697 (0) 0.00% 750 (-1) -0.13% 768 (0) 0.00% 781 (0) 0.00% 269 (0)
TransferHelperHarness 472,638 (+12) safeTransfer
safeTransferExact
safeTransferExactFrom
safeTransferFrom
28,406 (0)
32,918 (0)
36,230 (0)
34,039 (0)
0.00%
0.00%
0.00%
0.00%
41,022 (-10)
68,226 (-8)
74,329 (-8)
47,173 (-9)
-0.02%
-0.01%
-0.01%
-0.02%
29,679 (0)
68,274 (0)
74,383 (0)
34,839 (0)
0.00%
0.00%
0.00%
0.00%
53,780 (0)
80,919 (0)
87,024 (0)
59,931 (0)
0.00%
0.00%
0.00%
0.00%
1,024 (0)
512 (0)
512 (0)
1,024 (0)
SignatureCheckerHarness 618,084 (0) isValidECDSASignature(address,bytes32,bytes)
isValidECDSASignature(address,bytes32,bytes32,bytes32)
recoverECDSASigner(bytes32,bytes)
recoverECDSASigner(bytes32,bytes32,bytes32)
recoverECDSASigner(bytes32,uint8,bytes32,bytes32)
validateECDSASignature(address,bytes32,bytes)
validateECDSASignature(address,bytes32,bytes32,bytes32)
1,349 (0)
938 (0)
1,147 (0)
805 (0)
742 (0)
1,230 (0)
861 (0)
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
4,844 (0)
4,446 (0)
4,548 (0)
4,219 (0)
4,143 (0)
4,725 (0)
4,376 (0)
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
4,861 (-20)
4,458 (-12)
4,565 (-10)
4,223 (-20)
4,160 (-10)
4,742 (-20)
4,373 (-20)
-0.41%
-0.27%
-0.22%
-0.47%
-0.24%
-0.42%
-0.46%
4,897 (0)
4,486 (0)
4,585 (0)
4,243 (0)
4,180 (0)
4,778 (0)
4,409 (0)
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
262 (0)
262 (0)
260 (0)
259 (0)
260 (0)
262 (0)
518 (0)
AccountWithFunctionReturningNothing 124,195 (+12)
AccountWithRevertingFunction 129,175 (-12)
Bytes32StringHarness 238,492 (+12)
ERC1271MaliciousWalletMock 132,435 (-12)

@github-actions
Copy link
Copy Markdown

LCOV of commit 71a88e6 during Forge Coverage #159

Summary coverage rate:
  lines......: 93.7% (464 of 495 lines)
  functions..: 93.2% (150 of 161 functions)
  branches...: no data found

Files changed coverage rate:
                                     |Lines       |Functions  |Branches    
  Filename                           |Rate     Num|Rate    Num|Rate     Num
  =========================================================================
  src/libs/BytesParser.sol           |32.0%     25| 0.0%     7|    -      0
  src/libs/TypeConverter.sol         |36.8%     19| 0.0%     7|    -      0

@0xIryna 0xIryna merged commit 20440d0 into main Mar 26, 2026
3 checks passed
@0xIryna 0xIryna deleted the feat/bytes-parser branch March 26, 2026 17:09
Sign up for free to 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.

3 participants