-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static analysis fixes #1147
Static analysis fixes #1147
Conversation
@@ -818,8 +832,8 @@ contract EVM2EVMMultiOffRamp is ITypeAndVersion, MultiOCR3Base { | |||
// We call the pool with exact gas to increase resistance against malicious tokens or token pools. | |||
// We protects against return data bombs by capping the return data size at MAX_RET_BYTES. | |||
(bool success, bytes memory returnData,) = CallWithExactGas._callWithExactGasSafeReturnData( | |||
abi.encodeWithSelector( | |||
IPoolV1.releaseOrMint.selector, | |||
abi.encodeCall( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saves gas AND adds type safety, no brainer
@@ -38,7 +38,7 @@ contract EVM2EVMOffRamp is IAny2EVMOffRamp, AggregateRateLimiter, ITypeAndVersio | |||
error AlreadyExecuted(uint64 sequenceNumber); | |||
error ZeroAddressNotAllowed(); | |||
error CommitStoreAlreadyInUse(); | |||
error ExecutionError(bytes error); | |||
error ExecutionError(bytes err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove shadowing the error
type
@@ -5,7 +5,7 @@ import {Internal} from "../../libraries/Internal.sol"; | |||
|
|||
// MessageHasher is a contract that provides a function to hash an EVM2EVMMessage. | |||
contract MessageHasher { | |||
function hash(Internal.EVM2EVMMessage memory msg, bytes32 metadataHash) public pure returns (bytes32) { | |||
return Internal._hash(msg, metadataHash); | |||
function hash(Internal.EVM2EVMMessage memory message, bytes32 metadataHash) public pure returns (bytes32) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove shadowing msg
LCOV of commit
|
# Conflicts: # contracts/gas-snapshots/ccip.gas-snapshot # contracts/scripts/native_solc_compile_all_ccip # contracts/src/v0.8/ccip/libraries/Internal.sol # contracts/src/v0.8/ccip/offRamp/EVM2EVMMultiOffRamp.sol # contracts/src/v0.8/ccip/onRamp/EVM2EVMMultiOnRamp.sol # contracts/src/v0.8/ccip/test/helpers/MessageHasher.sol # core/gethwrappers/ccip/generated/evm_2_evm_multi_offramp/evm_2_evm_multi_offramp.go # core/gethwrappers/ccip/generated/evm_2_evm_multi_onramp/evm_2_evm_multi_onramp.go # core/gethwrappers/ccip/generated/message_hasher/message_hasher.go # core/gethwrappers/ccip/generation/generated-wrapper-dependency-versions-do-not-edit.txt
# Conflicts: # contracts/gas-snapshots/ccip.gas-snapshot # contracts/scripts/native_solc_compile_all_ccip # contracts/src/v0.8/ccip/libraries/Internal.sol # contracts/src/v0.8/ccip/offRamp/EVM2EVMMultiOffRamp.sol # contracts/src/v0.8/ccip/onRamp/EVM2EVMMultiOnRamp.sol # contracts/src/v0.8/ccip/test/helpers/MessageHasher.sol # core/gethwrappers/ccip/generated/evm_2_evm_multi_offramp/evm_2_evm_multi_offramp.go # core/gethwrappers/ccip/generated/evm_2_evm_multi_onramp/evm_2_evm_multi_onramp.go # core/gethwrappers/ccip/generated/message_hasher/message_hasher.go # core/gethwrappers/ccip/generation/generated-wrapper-dependency-versions-do-not-edit.txt
…/ccip into static-analysis
@@ -284,8 +284,10 @@ contract EVM2EVMMultiOffRamp is ITypeAndVersion, MultiOCR3Base { | |||
for (uint256 msgIndex = 0; msgIndex < numMsgs; ++msgIndex) { | |||
uint256 newLimit = msgGasLimitOverrides[msgIndex]; | |||
// Checks to ensure message cannot be executed with less gas than specified. | |||
if (newLimit != 0 && newLimit < report.messages[msgIndex].gasLimit) { | |||
revert InvalidManualExecutionGasLimit(report.sourceChainSelector, msgIndex, newLimit); | |||
if (newLimit != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: are the gas / contract size changes significant for splitting if statements? I find a && b && c
much more readable in most cases
This PR addresses various static analysis findings, mostly to reduce gas and contract bytecode size. Both before and after use 3600 optimizations. Due to the saves space in the onRamp we can bump the number of optimizations.
Each commit addresses a different change, and each commit contains the gas snapshot to illustrate the impact of that particular change.
Before
After
note: comment slightly outdated since the last merge. Overall diff should still be the same