Platform: Code4rena
Start Date: 01/12/2022
End Date: 05/12/2022
Period: 4 days
Status: Completed
Pot Size: $26,900 USDC
Participants: 19
Reporter: liveactionllama
Judge: GalloDaSballo
Id: 188
League: ETH
ktg | 1/19 | $4,203.70 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
0x52 | 2/19 | $3,233.62 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
ladboy233 | 3/19 | $1,921.21 | 2 | 0 | 0 | 1 | 0 | Grade A | 0 | 0 |
AkshaySrivastav | 4/19 | $1,755.92 | 2 | 0 | 0 | 1 | 0 | 0 | Grade B | 0 |
cccz | 5/19 | $1,702.50 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
joestakey | 6/19 | $1,309.61 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
Chom | 7/19 | $1,309.61 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
enckrish | 8/19 | $1,309.61 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
hihen | 9/19 | $1,309.61 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
csanuragjain | 10/19 | $1,309.61 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
Auditor per page
The C4audit output for the contest can be found here within an hour of contest opening.
Note for C4 wardens: Anything included in the C4udit output is considered a publicly known issue and is ineligible for awards.
This is a contest to evaluate various implementations of EIP-5164, a cross-chain execution interface for EVM-based blockchains.
The specification defines two components: the Cross Chain Relayer and the Cross Chain Executor. The Cross Chain Relayer lives on the calling side, and the executor lives on the receiving side. Calls sent to Cross Chain Relayers will move through a transport layer to Cross Chain Executor(s), where they are executed.
Implementations that are part of this audit all rely on native bridges.
The following documentations will help you understand how the native bridges work:
Bridges process messages in various ways, the how to section of the README will help you understand how to bridge messages:
https://github.com/pooltogether/ERC5164/blob/5647bd84f2a6d1a37f41394874d567e45a97bf48/README.md
File | SLOC | Coverage | Libraries |
---|---|---|---|
Contracts (6) | |||
Ethereum to Arbitrum bridge | |||
src/ethereum-arbitrum/EthereumToArbitrumRelayer.sol 💰 🧮 | 82 | 100.00% | @arbitrum/* |
src/ethereum-arbitrum/EthereumToArbitrumExecutor.sol | 30 | 100.00% | @arbitrum/* |
Ethereum to Optimism bridge | |||
src/ethereum-optimism/EthereumToOptimismRelayer.sol 💰 | 45 | 100.00% | @eth-optimism/* |
src/ethereum-optimism/EthereumToOptimismExecutor.sol | 37 | 100.00% | @eth-optimism/* |
Ethereum to Polygon bridge | |||
src/ethereum-polygon/EthereumToPolygonRelayer.sol 💰 | 34 | 100.00% | @maticnetwork/* |
src/ethereum-polygon/EthereumToPolygonExecutor.sol | 22 | 100.00% | @maticnetwork/* |
Libraries (1) | |||
src/libraries/CallLib.sol | 29 | 100.00% | |
Total (over 7 files): | 279 | 100.00% |
File | SLOC | Coverage |
---|---|---|
Abstracts (1) | ||
src/abstract/ExecutorAware.sol 🖥 | 27 | 100.00% |
Interfaces (2) | ||
src/interfaces/ICrossChainExecutor.sol | 11 | - |
src/interfaces/ICrossChainRelayer.sol 💰 | 15 | - |
Tests (1) | ||
test/contracts/Greeter.sol 💰 | 22 | 100.00% |
Total (over 4 files): | 75 | 100.00% |
The following reports will be disregarded:
setExecutor
and setRelayer
functions can be front-run during the deployment. We can simply redeploy the contracts if it happens.processCalls
, we store _data
in a variable that is only used once. We do so to avoid a stack too deep error. Any report recommending to compile using via-ir, will be disregarded.
If a recommendation is made, gas usage should be at least the same or lower. Code clarity should also be preserved.The main areas of concern are the following:
relayCalls
and executeCalls
.abi.encode
calls.When suggesting gas optimizations, please run the yarn test
command and write down the improvement in gas usage in your report. Don't forget to set the FORGE_GAS_REPORT
environment variable to true
in order to generate the gas report.
Any report that does not follow the above rule will be disregarded.
- If you have a public code repo, please share it here: https://github.com/pooltogether/ERC5164 - How many contracts are in scope?: 11 - Total SLoC for these contracts?: ~354 - How many external imports are there?: 6 - How many separate interfaces and struct definitions are there for the contracts within scope?: 2 - Does most of your code generally use composition or inheritance?: Inheritance - How many external calls?: 3 - What is the overall line coverage percentage provided by your tests?: lines: 100.0% (77 of 77 lines) functions: 90.9% (20 of 22 functions) - Is there a need to understand a separate part of the codebase / get context in order to audit this part of the protocol?: true - Please describe required context: Need to understand how native bridges for Arbitrum, Optimism and Polygon work - Does it use an oracle?: false - Does the token conform to the ERC20 standard?: There is no ERC20 token to audit - Are there any novel or unique curve logic or mathematical models?: No - Does it use a timelock function?: No - Is it an NFT?: No - Does it have an AMM?: No - Is it a fork of a popular project?: false - Does it use rollups?: true - Is it multi-chain?: true - Does it use a side-chain?: Yes
Follow the Development section to setup your environment.
Refer to the Test and Coverage sections to run tests.
You need to install foundryup to run the following command.
If you are on Mac OS, you will need to install gnu-sed.
export MAINNET_RPC_URL="<your-mainnnet-rpc-url-goes-here>" && export ARBITRUM_RPC_URL="<your-arbitrum-rpc-url-goes-here>" && export OPTIMISM_RPC_URL="<your-optimism-rpc-url-goes-here>" && export POLYGON_RPC_URL="<your-polygon-rpc-url-goes-here>" && ( rm -Rf ERC5164 || true ) && git clone https://github.com/pooltogether/ERC5164 -n -j8 && cd ERC5164 && git checkout 5647bd84f2a6d1a37f41394874d567e45a97bf48 && git submodule update --init --force && foundryup && cd lib/forge-std && forge install && cd ../../ && cp .envrc.example .envrc && sed -i "s@export MAINNET_RPC_URL.*@export MAINNET_RPC_URL=\"$MAINNET_RPC_URL\"@g" .envrc && sed -i "s@export ARBITRUM_RPC_URL.*@export ARBITRUM_RPC_URL=\"$ARBITRUM_RPC_URL\"@g" .envrc && sed -i "s@export OPTIMISM_RPC_URL.*@export OPTIMISM_RPC_URL=\"$OPTIMISM_RPC_URL\"@g" .envrc && sed -i "s@export POLYGON_RPC_URL.*@export POLYGON_RPC_URL=\"$POLYGON_RPC_URL\"@g" .envrc && ( direnv || source .envrc ) && yarn && yarn compile && yarn test
If you have any questions, don't hesitate to reach out to us on the C4 Discord channel setup for this contest.