Commit 855fc76a authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #2133 from ethereum-optimism/m/cleanup

Remove some unused code
parents a22b4ed6 4710779b
---
'@eth-optimism/contracts': patch
---
Remove unused gas testing utils
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.9; pragma solidity ^0.8.9;
/* Library Imports */
import { Lib_RLPReader } from "../rlp/Lib_RLPReader.sol";
/** /**
* @title Lib_CrossDomainUtils * @title Lib_CrossDomainUtils
*/ */
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract Helper_GasMeasurer {
function measureCallGas(address _target, bytes memory _data) public returns (uint256) {
uint256 gasBefore;
uint256 gasAfter;
uint256 calldataStart;
uint256 calldataLength;
assembly {
calldataStart := add(_data, 0x20)
calldataLength := mload(_data)
}
bool success;
assembly {
gasBefore := gas()
success := call(gas(), _target, 0, calldataStart, calldataLength, 0, 0)
gasAfter := gas()
}
require(success, "Call failed, but calls we want to measure gas for should succeed!");
return gasBefore - gasAfter;
}
}
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
*This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.* *This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. [CAUTION] ==== Avoid leaving a contract uninitialized. An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: [.hljs-theme-light.nopadding] ```*
import { ethers } from 'hardhat'
import { Contract, Signer } from 'ethers'
export class GasMeasurement {
GasMeasurementContract: Contract
public async init(wallet: Signer) {
this.GasMeasurementContract = await (
await (await ethers.getContractFactory('Helper_GasMeasurer')).deploy()
).connect(wallet)
}
public async getGasCost(
targetContract: Contract,
methodName: string,
methodArgs: Array<any> = []
): Promise<number> {
const gasCost: number =
await this.GasMeasurementContract.callStatic.measureCallGas(
targetContract.address,
targetContract.interface.encodeFunctionData(methodName, methodArgs)
)
return gasCost
}
}
...@@ -5,4 +5,3 @@ export * from './utils' ...@@ -5,4 +5,3 @@ export * from './utils'
export * from './codec' export * from './codec'
export * from './test-runner' export * from './test-runner'
export * from './trie' export * from './trie'
export * from './gas'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment