Skip to content

Commit

Permalink
Changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkaseman committed Feb 19, 2024
1 parent e26672d commit 09df392
Show file tree
Hide file tree
Showing 18 changed files with 184 additions and 184 deletions.
138 changes: 69 additions & 69 deletions contracts/gas-snapshots/functions.gas-snapshot

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions contracts/scripts/native_solc_compile_all_functions
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export SOLC_VERSION=$SOLC_VERSION

compileContract v1_X dev/v1_X/libraries/FunctionsRequest.sol
compileContract v1_X dev/v1_X/FunctionsRouter.sol
compileContract v1_X dev/v1_X/FunctionsCoordinator.sol # Latest
compileContract v1_1_0 v1_1_0/FunctionsCoordinator.sol # Coordinator v1.1.0
compileContract v1_X dev/v1_X/FunctionsCoordinator.sol
compileContract v1_X dev/v1_X/accessControl/TermsOfServiceAllowList.sol
compileContract v1_X dev/v1_X/example/FunctionsClientExample.sol

Expand Down
50 changes: 25 additions & 25 deletions contracts/src/v0.8/functions/dev/v1_X/FunctionsBilling.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,19 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling {
// ================================================================

/// @inheritdoc IFunctionsBilling
function getDONFee(bytes memory /* requestData */) public view override returns (uint72) {
function getDONFeeJuels(bytes memory /* requestData */) public view override returns (uint72) {
// s_config.donFee is in cents of USD. Get Juel amount then convert to dollars.
return SafeCast.toUint72(_getJuelsFromUsd(s_config.donFee) / 100);
return SafeCast.toUint72(_getJuelsFromUsd(s_config.donFeeCentsUsd) / 100);
}

/// @inheritdoc IFunctionsBilling
function getOperationFee() public view override returns (uint72) {
function getOperationFeeJuels() public view override returns (uint72) {
// s_config.donFee is in cents of USD. Get Juel amount then convert to dollars.
return SafeCast.toUint72(_getJuelsFromUsd(s_config.operationFee) / 100);
return SafeCast.toUint72(_getJuelsFromUsd(s_config.operationFeeCentsUsd) / 100);
}

/// @inheritdoc IFunctionsBilling
function getAdminFee() public view override returns (uint72) {
function getAdminFeeJuels() public view override returns (uint72) {
return _getRouter().getAdminFee();
}

Expand Down Expand Up @@ -177,9 +177,9 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling {
if (gasPriceWei > REASONABLE_GAS_PRICE_CEILING) {
revert InvalidCalldata();
}
uint72 adminFee = getAdminFee();
uint72 donFee = getDONFee(data);
uint72 operationFee = getOperationFee();
uint72 adminFee = getAdminFeeJuels();
uint72 donFee = getDONFeeJuels(data);
uint72 operationFee = getOperationFeeJuels();
return _calculateCostEstimate(callbackGasLimit, gasPriceWei, donFee, adminFee, operationFee);
}

Expand All @@ -189,9 +189,9 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling {
function _calculateCostEstimate(
uint32 callbackGasLimit,
uint256 gasPriceWei,
uint72 donFee,
uint72 adminFee,
uint72 operationFee
uint72 donFeeJuels,
uint72 adminFeeJuels,
uint72 operationFeeJuels
) internal view returns (uint96) {
// If gas price is less than the minimum fulfillment gas price, override to using the minimum
if (gasPriceWei < s_config.minimumEstimateGasPriceWei) {
Expand All @@ -206,7 +206,7 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling {
uint256 l1FeeWei = ChainSpecificUtil._getCurrentTxL1GasFees(msg.data);
uint96 estimatedGasReimbursementJuels = _getJuelsFromWei((gasPriceWithOverestimation * executionGas) + l1FeeWei);

uint96 feesJuels = uint96(donFee) + uint96(adminFee) + uint96(operationFee);
uint96 feesJuels = uint96(donFeeJuels) + uint96(adminFeeJuels) + uint96(operationFeeJuels);

return estimatedGasReimbursementJuels + feesJuels;
}
Expand All @@ -227,8 +227,8 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling {
revert UnsupportedRequestDataVersion();
}

uint72 donFee = getDONFee(request.data);
uint72 operationFee = getOperationFee();
uint72 donFee = getDONFeeJuels(request.data);
uint72 operationFee = getOperationFeeJuels();
uint96 estimatedTotalCostJuels = _calculateCostEstimate(
request.callbackGasLimit,
tx.gasprice,
Expand Down Expand Up @@ -260,16 +260,16 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling {
);

commitment = FunctionsResponse.CommitmentWithOperationFee({
adminFee: request.adminFee,
adminFeeJuels: request.adminFee,
coordinator: address(this),
client: request.requestingContract,
subscriptionId: request.subscriptionId,
callbackGasLimit: request.callbackGasLimit,
estimatedTotalCostJuels: estimatedTotalCostJuels,
timeoutTimestamp: timeoutTimestamp,
requestId: requestId,
donFee: donFee,
operationFee: operationFee,
donFeeJuels: donFee,
operationFeeJuels: operationFee,
gasOverheadBeforeCallback: s_config.gasOverheadBeforeCallback,
gasOverheadAfterCallback: s_config.gasOverheadAfterCallback
});
Expand Down Expand Up @@ -311,18 +311,18 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling {
response,
err,
juelsPerGas,
gasOverheadJuels + commitment.donFee + commitment.operationFee, // cost without callback or admin fee, those will be added by the Router
gasOverheadJuels + commitment.donFeeJuels + commitment.operationFeeJuels, // cost without callback or admin fee, those will be added by the Router
msg.sender,
FunctionsResponse.Commitment({
adminFee: commitment.adminFee,
adminFee: commitment.adminFeeJuels,
coordinator: commitment.coordinator,
client: commitment.client,
subscriptionId: commitment.subscriptionId,
callbackGasLimit: commitment.callbackGasLimit,
estimatedTotalCostJuels: commitment.estimatedTotalCostJuels,
timeoutTimestamp: commitment.timeoutTimestamp,
requestId: commitment.requestId,
donFee: commitment.donFee,
donFee: commitment.donFeeJuels,
gasOverheadBeforeCallback: commitment.gasOverheadBeforeCallback,
gasOverheadAfterCallback: commitment.gasOverheadAfterCallback
})
Expand All @@ -340,17 +340,17 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling {
s_withdrawableTokens[msg.sender] += gasOverheadJuels + callbackCostJuels;
// Put donFee into the pool of fees, to be split later
// Saves on storage writes that would otherwise be charged to the user
s_feePool += commitment.donFee;
s_feePool += commitment.donFeeJuels;
// Pay the operation fee to the Coordinator owner
s_withdrawableTokens[_owner()] += commitment.operationFee;
s_withdrawableTokens[_owner()] += commitment.operationFeeJuels;
emit RequestBilled({
requestId: requestId,
juelsPerGas: juelsPerGas,
l1FeeShareWei: l1FeeShareWei,
callbackCostJuels: callbackCostJuels,
donFeeJuels: commitment.donFee,
adminFeeJuels: commitment.adminFee,
operationFeeJuels: commitment.operationFee
donFeeJuels: commitment.donFeeJuels,
adminFeeJuels: commitment.adminFeeJuels,
operationFeeJuels: commitment.operationFeeJuels
});
}
return resultCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ contract FunctionsCoordinator is OCR2Base, IFunctionsCoordinator, FunctionsBilli

return
FunctionsResponse.Commitment({
adminFee: commitmentWithOperationFee.adminFee,
adminFee: commitmentWithOperationFee.adminFeeJuels,
coordinator: commitmentWithOperationFee.coordinator,
client: commitmentWithOperationFee.client,
subscriptionId: commitmentWithOperationFee.subscriptionId,
callbackGasLimit: commitmentWithOperationFee.callbackGasLimit,
estimatedTotalCostJuels: commitmentWithOperationFee.estimatedTotalCostJuels,
timeoutTimestamp: commitmentWithOperationFee.timeoutTimestamp,
requestId: commitmentWithOperationFee.requestId,
donFee: commitmentWithOperationFee.donFee,
donFee: commitmentWithOperationFee.donFeeJuels,
gasOverheadBeforeCallback: commitmentWithOperationFee.gasOverheadBeforeCallback,
gasOverheadAfterCallback: commitmentWithOperationFee.gasOverheadAfterCallback
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ interface IFunctionsBilling {
/// @notice Determine the fee that will be split between Node Operators for servicing a request
/// @param requestCBOR - CBOR encoded Chainlink Functions request data, use FunctionsRequest library to encode a request
/// @return fee - Cost in Juels (1e18) of LINK
function getDONFee(bytes memory requestCBOR) external view returns (uint72);
function getDONFeeJuels(bytes memory requestCBOR) external view returns (uint72);

/// @notice Determine the fee that will be paid to the Coordinator owner for operating the network
/// @return fee - Cost in Juels (1e18) of LINK
function getOperationFee() external view returns (uint72);
function getOperationFeeJuels() external view returns (uint72);

/// @notice Determine the fee that will be paid to the Router owner for operating the network
/// @return fee - Cost in Juels (1e18) of LINK
function getAdminFee() external view returns (uint72);
function getAdminFeeJuels() external view returns (uint72);

/// @notice Estimate the total cost that will be charged to a subscription to make a request: transmitter gas re-reimbursement, plus DON fee, plus Registry fee
/// @param - subscriptionId An identifier of the billing account
Expand Down Expand Up @@ -68,6 +68,6 @@ struct FunctionsBillingConfig {
uint8 fallbackUsdPerUnitLinkDecimals; // ════════╝ Fallback LINK / USD conversion rate decimal places if the data feed is stale
uint224 fallbackNativePerUnitLink; // ═══════════╗ Fallback NATIVE CURRENCY / LINK conversion rate if the data feed is stale
uint32 requestTimeoutSeconds; // ════════════════╝ How many seconds it takes before we consider a request to be timed out
uint16 donFee; // ═══════════════════════════════╗ Additional flat fee (denominated in cents of USD, paid as LINK) that will be split between Node Operators.
uint16 operationFee; // ═════════════════════════╝ Additional flat fee (denominated in cents of USD, paid as LINK) that will be paid to the owner of the Coordinator contract.
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.
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ library FunctionsResponse {
address client; // ════════════════════╗ The client contract that sent the request
uint64 subscriptionId; // ║ Identifier of the billing subscription that will be charged for the request
uint32 callbackGasLimit; // ═══════════╝ The amount of gas that the callback to the consuming contract will be given
uint72 adminFee; // ═══════════════════╗ Flat fee (in Juels of LINK) that will be paid to the Router Owner for operation of the network
uint72 donFee; // ║ Fee (in Juels of LINK) that will be split between Node Operators for servicing a request
uint72 adminFeeJuels; // ══════════════╗ Flat fee (in Juels of LINK) that will be paid to the Router Owner for operation of the network
uint72 donFeeJuels; // ║ Fee (in Juels of LINK) that will be split between Node Operators for servicing a request
uint40 gasOverheadBeforeCallback; // ║ Represents the average gas execution cost before the fulfillment callback.
uint40 gasOverheadAfterCallback; // ║ Represents the average gas execution cost after the fulfillment callback.
uint32 timeoutTimestamp; // ═══════════╝ The timestamp at which a request will be eligible to be timed out
uint72 operationFee; // ═══════════════╸ Flat fee (in Juels of LINK) that will be paid to the Coordinator Owner for operation of the network
uint72 operationFeeJuels; // ══════════╸ Flat fee (in Juels of LINK) that will be paid to the Coordinator Owner for operation of the network
}
}
Loading

0 comments on commit 09df392

Please sign in to comment.