-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #697 from matter-labs/sb-synced-sync-layer-reorg
Port some commits from kl/sync-layer-reorg
- Loading branch information
Showing
131 changed files
with
2,708 additions
and
1,987 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,3 +215,56 @@ jobs: | |
coverage-files: ./l1-contracts/lcov.info | ||
working-directory: l1-contracts | ||
minimum-coverage: 85 # Set coverage threshold. | ||
|
||
gas-report: | ||
needs: [build, lint] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Use Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.18.0 | ||
cache: yarn | ||
|
||
- name: Install dependencies | ||
run: yarn | ||
|
||
- name: Restore artifacts cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
fail-on-cache-miss: true | ||
key: artifacts-l1-${{ github.sha }} | ||
path: | | ||
l1-contracts/artifacts | ||
l1-contracts/cache | ||
l1-contracts/typechain | ||
# Add any step generating a gas report to a temporary file named gasreport.ansi. For example: | ||
- name: Run tests | ||
run: yarn l1 test:foundry --gas-report | tee gasreport.ansi # <- this file name should be unique in your repository! | ||
|
||
- name: Compare gas reports | ||
uses: Rubilmax/[email protected] | ||
with: | ||
summaryQuantile: 0.0 # only display the 10% most significant gas diffs in the summary (defaults to 20%) | ||
sortCriteria: avg,max # sort diff rows by criteria | ||
sortOrders: desc,asc # and directions | ||
ignore: test-foundry/**/*,l1-contracts/contracts/dev-contracts/**/*,l1-contracts/lib/**/*,l1-contracts/contracts/common/Dependencies.sol | ||
id: gas_diff | ||
|
||
- name: Add gas diff to sticky comment | ||
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
# delete the comment in case changes no longer impact gas costs | ||
delete: ${{ !steps.gas_diff.outputs.markdown }} | ||
message: ${{ steps.gas_diff.outputs.markdown }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
// solhint-disable gas-custom-errors | ||
|
||
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; | ||
|
||
/** | ||
* @author Matter Labs | ||
* @custom:security-contact [email protected] | ||
* @notice Helper library for working with L2 contracts on L1. | ||
*/ | ||
library BridgeHelper { | ||
/// @dev Receives and parses (name, symbol, decimals) from the token contract | ||
function getERC20Getters(address _token, address _ethTokenAddress) internal view returns (bytes memory) { | ||
if (_token == _ethTokenAddress) { | ||
bytes memory name = abi.encode("Ether"); | ||
bytes memory symbol = abi.encode("ETH"); | ||
bytes memory decimals = abi.encode(uint8(18)); | ||
return abi.encode(name, symbol, decimals); // when depositing eth to a non-eth based chain it is an ERC20 | ||
} | ||
|
||
(, bytes memory data1) = _token.staticcall(abi.encodeCall(IERC20Metadata.name, ())); | ||
(, bytes memory data2) = _token.staticcall(abi.encodeCall(IERC20Metadata.symbol, ())); | ||
(, bytes memory data3) = _token.staticcall(abi.encodeCall(IERC20Metadata.decimals, ())); | ||
return abi.encode(data1, data2, data3); | ||
} | ||
} |
Oops, something went wrong.