graphprotocol / contracts

Contracts repository for The Graph protocol

Home Page:https://thegraph.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a authority counting fees for every allocation?

jongrun opened this issue · comments

/**
* @notice Redeem a voucher signed by the authority. No voucher double spending is allowed.
* @dev The voucher must be signed using an Ethereum signed message
* @param _voucher Voucher data
*/
function _redeem(AllocationVoucher memory _voucher) private {
require(_voucher.amount > 0, "Exchange: zero tokens voucher");
require(_voucher.signature.length == SIGNATURE_LENGTH, "Exchange: invalid signature");
// Already redeemed check
require(
!allocationsRedeemed[_voucher.allocationID],
"Exchange: allocation already redeemed"
);
// Signature check
bytes32 messageHash = keccak256(abi.encodePacked(_voucher.allocationID, _voucher.amount));
address voucherSigner = ECDSA.recover(messageHash, _voucher.signature);
require(authority[voucherSigner], "Exchange: invalid signer");
// Mark allocation as collected
allocationsRedeemed[_voucher.allocationID] = true;
// Make the staking contract collect funds from this contract
// The Staking contract will validate if the allocation is valid
staking.collect(_voucher.amount, _voucher.allocationID);
emit AllocationRedeemed(_voucher.allocationID, _voucher.amount);
}
}

Does it mean that there is a authority ( Gateway? ) who counts fees for every allocation?

Hey @jongrun, sorry for the delayed response here. This one slipped through the cracks.

There is an authority (the gateway) however it's not "counting" or keeping track of fees as far as I know. The process has two steps:

  1. The indexer provides a service (serves queries) and the gateway signs a voucher in exchange. The voicher contains the following information:
  • beneficiary (the indexer serving the queries)
  • allocation id (the allocation for which the voucher is for)
  • amount (the amount of query fees in GRT that the indexer is owed)
  1. The indexer redeems the voucher.

Since the voucher already contains all the information, and it is signed by the gateway, there is no need to keep track of amounts owed per indexer or per allocation.

Hope this is useful information, let me know if I can further assist.