Skip to content

Commit

Permalink
Addressed feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
KuphJr committed May 22, 2024
1 parent a60f54c commit 230cc33
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 17 deletions.
5 changes: 0 additions & 5 deletions .changeset/gorgeous-garlics-rescue.md

This file was deleted.

2 changes: 1 addition & 1 deletion .changeset/neat-peas-reflect.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"chainlink": patch
---

Updated wrappers for improved L1 -> L2 fee calculation for Functions
#internal Updated wrappers for improved L1 -> L2 fee calculation for Functions
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ struct FunctionsBillingConfig {
uint32 requestTimeoutSeconds; // ════════════════╝ How many seconds it takes before we consider a request to be timed out
uint16 donFeeCentsUsd; // ═══════════════════════════════╗ Additional flat fee (denominated in cents of USD, paid as LINK) that will be split between Node Operators.
uint16 operationFeeCentsUsd; // ║ Additional flat fee (denominated in cents of USD, paid as LINK) that will be paid to the owner of the Coordinator contract.
uint16 transmitTxSizeBytes; // ══════════════════════════╝ The size of the transmit transaction in bytes assuming a single 256 byte response payload. Used to estimate L1 cost for fulfillments on L2 chains.
uint16 transmitTxSizeBytes; // ══════════════════════════╝ The full size of the ransmit transaction in bytes assuming a single 256 byte response payload. Used to estimate L1 cost for fulfillments on L2 chains. Note that this is the size of the raw transaction data, not just the calldata. Example: https://sepolia.basescan.org/getRawTx?tx=0x83b76a9abd8bf370e078ac71fe05d3a384fbf0aa176126dc632899b8e63703a3
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ library ChainSpecificUtil {
// ------------ End Arbitrum Constants ------------

// ------------ Start Optimism Constants ------------
/// @dev OP_L1_FEE_DATA_PADDING_SIZE is the L1 data padding for Optimism
uint256 private constant OP_L1_FEE_DATA_PADDING_SIZE = 35;
/// @dev L1BLOCK_ADDR is the address of the L1Block precompile on Optimism.
address private constant L1BLOCK_ADDR = address(0x4200000000000000000000000000000000000015);
L1Block private constant L1BLOCK = L1Block(L1BLOCK_ADDR);
Expand Down Expand Up @@ -56,8 +54,8 @@ library ChainSpecificUtil {
uint256 l1BaseFeeScalar = L1BLOCK.baseFeeScalar();
uint256 l1BlobBaseFeeWei = L1BLOCK.blobBaseFee();
uint256 l1BlobBaseFeeScalar = L1BLOCK.blobBaseFeeScalar();
uint256 weightedGasPrice = (l1BaseFeeScalar * l1BaseFeeWei + l1BlobBaseFeeScalar * l1BlobBaseFeeWei) / 10 ** 6;
return weightedGasPrice * (dataSizeBytes + OP_L1_FEE_DATA_PADDING_SIZE);
uint256 weightedGasPrice = (16 * l1BaseFeeScalar * l1BaseFeeWei + l1BlobBaseFeeScalar * l1BlobBaseFeeWei) / (16 * 10 ** 6);
return weightedGasPrice * dataSizeBytes;
}
return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions contracts/src/v0.8/functions/tests/v1_X/ChainSpecificUtil.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract ChainSpecificUtil__getL1FeeUpperLimit_Arbitrum is FunctionsFulfillmentS
address private constant ARBGAS_ADDR = address(0x000000000000000000000000000000000000006C);
uint256 private constant WEI_PER_L1_CALLDATA_BYTE = 2_243_708_528;

uint256 private constant L1_FEE_ESTIMATE_WITH_OVERESTIMATION_WEI = 6_408_031_555_968;
uint256 private constant L1_FEE_ESTIMATE_WITH_OVERESTIMATION_WEI = 6_795_071_277_048;
uint256 private constant L1_FEE_WEI = 3_697_631_654_144;

uint96 l1FeeEstimateJuels = uint96((1e18 * L1_FEE_ESTIMATE_WITH_OVERESTIMATION_WEI) / uint256(LINK_ETH_RATE));
Expand Down Expand Up @@ -112,8 +112,8 @@ contract ChainSpecificUtil__getL1FeeUpperLimit_Optimism is FunctionsFulfillmentS
uint256 private constant L1_BLOB_BASE_FEE_WEI = 1;
uint256 private constant L1_BLOB_BASE_FEE_SCALAR = 810_949;

uint256 private constant L1_FEE_ESTIMATE_WITH_OVERESTIMATION_WEI = 101_151_947_536;
uint256 private constant L1_FEE_WEI = 57_838_597_387;
uint256 private constant L1_FEE_ESTIMATE_WITH_OVERESTIMATION_WEI = 105_650_085_798;
uint256 private constant L1_FEE_WEI = 56_526_638_064;

uint96 l1FeeEstimateJuels = uint96((1e18 * L1_FEE_ESTIMATE_WITH_OVERESTIMATION_WEI) / uint256(LINK_ETH_RATE));
uint96 l1FeeJuels = uint96((1e18 * L1_FEE_WEI) / uint256(LINK_ETH_RATE));
Expand Down Expand Up @@ -203,8 +203,8 @@ contract ChainSpecificUtil__getL1FeeUpperLimit_Base is FunctionsFulfillmentSetup
uint256 private constant L1_BLOB_BASE_FEE_WEI = 1;
uint256 private constant L1_BLOB_BASE_FEE_SCALAR = 659_851;

uint256 private constant L1_FEE_ESTIMATE_WITH_OVERESTIMATION_WEI = 147_294_629_863;
uint256 private constant L1_FEE_WEI = 84_222_943_813;
uint256 private constant L1_FEE_ESTIMATE_WITH_OVERESTIMATION_WEI = 153_844_693_965;
uint256 private constant L1_FEE_WEI = 82_312_506_120;

uint96 l1FeeEstimateJuels = uint96((1e18 * L1_FEE_ESTIMATE_WITH_OVERESTIMATION_WEI) / uint256(LINK_ETH_RATE));
uint96 l1FeeJuels = uint96((1e18 * L1_FEE_WEI) / uint256(LINK_ETH_RATE));
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/functions/tests/v1_X/Setup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ contract FunctionsRouterSetup is BaseTest {
fallbackUsdPerUnitLink: 1400000000,
fallbackUsdPerUnitLinkDecimals: 8,
minimumEstimateGasPriceWei: 1000000000, // 1 gwei
transmitTxSizeBytes: 1764
transmitTxSizeBytes: 1879
});
}

Expand Down

0 comments on commit 230cc33

Please sign in to comment.