Skip to content

Commit

Permalink
Multicall gas improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
tsudmi committed Oct 1, 2023
1 parent dfa2be4 commit 966f394
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions contracts/base/Multicall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import '../interfaces/IMulticall.sol';
abstract contract Multicall is IMulticall {
/// @inheritdoc IMulticall
function multicall(bytes[] calldata data) external override returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; ) {
uint256 dataLength = data.length;
results = new bytes[](dataLength);
for (uint256 i = 0; i < dataLength; ) {
(bool success, bytes memory result) = address(this).delegatecall(data[i]);

if (!success) {
Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/EthGenesisVault.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ Object {
exports[`EthGenesisVault pulls assets on claim exited assets 1`] = `
Object {
"calldataByteLength": 68,
"gasUsed": 64329,
"gasUsed": 64321,
}
`;

exports[`EthGenesisVault pulls assets on multiple validators registration 1`] = `
Object {
"calldataByteLength": 3716,
"gasUsed": 682468,
"gasUsed": 682648,
}
`;

Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/EthVault.register.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`EthVault - register multiple validators succeeds 1`] = `
Object {
"calldataByteLength": 3652,
"gasUsed": 723005,
"gasUsed": 722975,
}
`;

Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/KeeperValidators.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
exports[`KeeperValidators register multiple validators succeeds 1`] = `
Object {
"calldataByteLength": 3716,
"gasUsed": 724184,
"gasUsed": 724154,
}
`;

exports[`KeeperValidators register multiple validators succeeds 2`] = `
Object {
"calldataByteLength": 3716,
"gasUsed": 632505,
"gasUsed": 632475,
}
`;

Expand Down

0 comments on commit 966f394

Please sign in to comment.