Skip to content

Commit

Permalink
Merge pull request #94 from FilOzone/feat/expose-fee-calculation
Browse files Browse the repository at this point in the history
ProofFee endpoint
  • Loading branch information
ZenGround0 authored Jan 28, 2025
2 parents 254b84f + bcbb024 commit 53f9238
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/PDPVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -428,19 +428,31 @@ contract PDPVerifier is Initializable, UUPSUpgradeable, OwnableUpgradeable {
proofSetLastProvenEpoch[setId] = block.number;
}

function calculateAndBurnProofFee(uint256 setId, uint256 gasUsed) internal {
function calculateProofFee(uint256 setId, uint256 estimatedGasFee) public view returns (uint256) {
uint256 rawSize = 32 * challengeRange[setId];
uint256 estimatedGasFee = gasUsed * block.basefee;
(uint64 filUsdPrice, int32 filUsdPriceExpo) = getFILUSDPrice();

uint256 proofFee = PDPFees.proofFeeWithGasFeeBound(
return PDPFees.proofFeeWithGasFeeBound(
estimatedGasFee,
filUsdPrice,
filUsdPriceExpo,
rawSize,
block.number - proofSetLastProvenEpoch[setId]
);
}

function calculateAndBurnProofFee(uint256 setId, uint256 gasUsed) internal {
uint256 estimatedGasFee = gasUsed * block.basefee;
uint256 rawSize = 32 * challengeRange[setId];
(uint64 filUsdPrice, int32 filUsdPriceExpo) = getFILUSDPrice();

uint256 proofFee = PDPFees.proofFeeWithGasFeeBound(
estimatedGasFee,
filUsdPrice,
filUsdPriceExpo,
rawSize,
block.number - proofSetLastProvenEpoch[setId]
);
burnFee(proofFee);
if (msg.value > proofFee) {
// Return the overpayment
Expand Down
7 changes: 6 additions & 1 deletion tools/deploy-calibnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ if [ -z "$KEYSTORE" ]; then
exit 1
fi

if [ -z "$CHALLENGE_FINALITY" ]; then
echo "Error: CHALLENGE_FINALITY is not set"
exit 1
fi

ADDR=$(cast wallet address --keystore "$KEYSTORE" --password "$PASSWORD")
echo "Deploying PDP verifier from address $ADDR"
# Parse the output of forge create to extract the contract address
Expand All @@ -31,7 +36,7 @@ echo "PDP verifier implementation deployed at: $VERIFIER_IMPLEMENTATION_ADDRESS"
echo "Deploying PDP verifier proxy"
NONCE=$(expr $NONCE + "1")

INIT_DATA=$(cast calldata "initialize(uint256)" 150)
INIT_DATA=$(cast calldata "initialize(uint256)" $CHALLENGE_FINALITY)
PDP_VERIFIER_ADDRESS=$(forge create --rpc-url "$RPC_URL" --keystore "$KEYSTORE" --password "$PASSWORD" --broadcast --nonce $NONCE --chain-id 314159 src/ERC1967Proxy.sol:MyERC1967Proxy --constructor-args $VERIFIER_IMPLEMENTATION_ADDRESS $INIT_DATA | grep "Deployed to" | awk '{print $3}')
echo "PDP verifier deployed at: $PDP_VERIFIER_ADDRESS"

Expand Down

0 comments on commit 53f9238

Please sign in to comment.