Skip to content

Commit

Permalink
Clean up todos (smartcontractkit#12098)
Browse files Browse the repository at this point in the history
  • Loading branch information
infiloop2 authored Feb 20, 2024
1 parent 84783a8 commit 724d586
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions contracts/src/v0.8/automation/dev/chains/ArbitrumModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ contract ArbitrumModule is ChainModuleBase {
address private constant ARB_GAS_ADDR = 0x000000000000000000000000000000000000006C;
ArbGasInfo private constant ARB_GAS = ArbGasInfo(ARB_GAS_ADDR);

uint256 private constant FIXED_GAS_OVERHEAD = 20000;
uint256 private constant PER_CALLDATA_BYTE_GAS_OVERHEAD = 20;

function blockHash(uint256 n) external view override returns (bytes32) {
uint256 blockNum = ARB_SYS.arbBlockNumber();
if (n >= blockNum || blockNum - n > 256) {
Expand All @@ -34,7 +37,6 @@ contract ArbitrumModule is ChainModuleBase {

function getMaxL1Fee(uint256 dataSize) external view override returns (uint256) {
(, uint256 perL1CalldataUnit, , , , ) = ARB_GAS.getPricesInWei();
// TODO: Verify this is an accurate estimate
return perL1CalldataUnit * dataSize * 16;
}

Expand All @@ -44,7 +46,6 @@ contract ArbitrumModule is ChainModuleBase {
override
returns (uint256 chainModuleFixedOverhead, uint256 chainModulePerByteOverhead)
{
// TODO: Calculate
return (0, 0);
return (FIXED_GAS_OVERHEAD, PER_CALLDATA_BYTE_GAS_OVERHEAD);
}
}
8 changes: 4 additions & 4 deletions contracts/src/v0.8/automation/dev/chains/OptimismModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ contract OptimismModule is ChainModuleBase {
address private constant OVM_GASPRICEORACLE_ADDR = 0x420000000000000000000000000000000000000F;
OVM_GasPriceOracle private constant OVM_GASPRICEORACLE = OVM_GasPriceOracle(OVM_GASPRICEORACLE_ADDR);

uint256 private constant FIXED_GAS_OVERHEAD = 20000;
uint256 private constant PER_CALLDATA_BYTE_GAS_OVERHEAD = 20;

function getCurrentL1Fee() external view override returns (uint256) {
// TODO: Verify this is accurate calculation with appropriate padding
return OVM_GASPRICEORACLE.getL1Fee(bytes.concat(msg.data, OP_L1_DATA_FEE_PADDING));
}

function getMaxL1Fee(uint256 dataSize) external view override returns (uint256) {
// fee is 4 per 0 byte, 16 per non-zero byte. Worst case we can have all non zero-bytes.
// Instead of setting bytes to non-zero, we initialize 'new bytes' of length 4*dataSize to cover for zero bytes.
bytes memory txCallData = new bytes(4 * dataSize);
// TODO: Verify this is an accurate estimate
return OVM_GASPRICEORACLE.getL1Fee(bytes.concat(txCallData, OP_L1_DATA_FEE_PADDING));
}

Expand All @@ -32,7 +33,6 @@ contract OptimismModule is ChainModuleBase {
override
returns (uint256 chainModuleFixedOverhead, uint256 chainModulePerByteOverhead)
{
// TODO: Calculate
return (0, 0);
return (FIXED_GAS_OVERHEAD, PER_CALLDATA_BYTE_GAS_OVERHEAD);
}
}
8 changes: 4 additions & 4 deletions contracts/src/v0.8/automation/dev/chains/ScrollModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ contract ScrollModule is ChainModuleBase {
address private constant SCROLL_ORACLE_ADDR = 0x5300000000000000000000000000000000000002;
IScrollL1GasPriceOracle private constant SCROLL_ORACLE = IScrollL1GasPriceOracle(SCROLL_ORACLE_ADDR);

uint256 private constant FIXED_GAS_OVERHEAD = 20000;
uint256 private constant PER_CALLDATA_BYTE_GAS_OVERHEAD = 20;

function getCurrentL1Fee() external view override returns (uint256) {
// TODO: Verify this is accurate calculation with appropriate padding
return SCROLL_ORACLE.getL1Fee(bytes.concat(msg.data, SCROLL_L1_FEE_DATA_PADDING));
}

function getMaxL1Fee(uint256 dataSize) external view override returns (uint256) {
// fee is 4 per 0 byte, 16 per non-zero byte. Worst case we can have all non zero-bytes.
// Instead of setting bytes to non-zero, we initialize 'new bytes' of length 4*dataSize to cover for zero bytes.
// this is the same as OP.
// TODO: Verify this is an accurate estimate
bytes memory txCallData = new bytes(4 * dataSize);
return SCROLL_ORACLE.getL1Fee(bytes.concat(txCallData, SCROLL_L1_FEE_DATA_PADDING));
}
Expand All @@ -35,7 +36,6 @@ contract ScrollModule is ChainModuleBase {
override
returns (uint256 chainModuleFixedOverhead, uint256 chainModulePerByteOverhead)
{
// TODO: Calculate
return (0, 0);
return (FIXED_GAS_OVERHEAD, PER_CALLDATA_BYTE_GAS_OVERHEAD);
}
}

0 comments on commit 724d586

Please sign in to comment.