diff --git a/.changeset/gorgeous-garlics-rescue.md b/.changeset/gorgeous-garlics-rescue.md deleted file mode 100644 index 0408383bd03..00000000000 --- a/.changeset/gorgeous-garlics-rescue.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"chainlink": patch ---- - -#internal diff --git a/.changeset/neat-peas-reflect.md b/.changeset/neat-peas-reflect.md index 8e78a4af513..2728e74668b 100644 --- a/.changeset/neat-peas-reflect.md +++ b/.changeset/neat-peas-reflect.md @@ -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 diff --git a/contracts/src/v0.8/functions/dev/v1_X/interfaces/IFunctionsBilling.sol b/contracts/src/v0.8/functions/dev/v1_X/interfaces/IFunctionsBilling.sol index ffa59ea02ab..71434ad3cee 100644 --- a/contracts/src/v0.8/functions/dev/v1_X/interfaces/IFunctionsBilling.sol +++ b/contracts/src/v0.8/functions/dev/v1_X/interfaces/IFunctionsBilling.sol @@ -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 } diff --git a/contracts/src/v0.8/functions/dev/v1_X/libraries/ChainSpecificUtil.sol b/contracts/src/v0.8/functions/dev/v1_X/libraries/ChainSpecificUtil.sol index 3cfba26ac23..39a7002e831 100644 --- a/contracts/src/v0.8/functions/dev/v1_X/libraries/ChainSpecificUtil.sol +++ b/contracts/src/v0.8/functions/dev/v1_X/libraries/ChainSpecificUtil.sol @@ -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); @@ -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; } diff --git a/contracts/src/v0.8/functions/tests/v1_X/ChainSpecificUtil.t.sol b/contracts/src/v0.8/functions/tests/v1_X/ChainSpecificUtil.t.sol index ec2165adbc0..5b0569b2754 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/ChainSpecificUtil.t.sol +++ b/contracts/src/v0.8/functions/tests/v1_X/ChainSpecificUtil.t.sol @@ -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)); @@ -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)); @@ -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)); diff --git a/contracts/src/v0.8/functions/tests/v1_X/Setup.t.sol b/contracts/src/v0.8/functions/tests/v1_X/Setup.t.sol index 815366e62aa..b4cda9914d5 100644 --- a/contracts/src/v0.8/functions/tests/v1_X/Setup.t.sol +++ b/contracts/src/v0.8/functions/tests/v1_X/Setup.t.sol @@ -94,7 +94,7 @@ contract FunctionsRouterSetup is BaseTest { fallbackUsdPerUnitLink: 1400000000, fallbackUsdPerUnitLinkDecimals: 8, minimumEstimateGasPriceWei: 1000000000, // 1 gwei - transmitTxSizeBytes: 1764 + transmitTxSizeBytes: 1879 }); }