Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add data request incentives #83

Merged
merged 25 commits into from
Jan 14, 2025
Merged

feat: add data request incentives #83

merged 25 commits into from
Jan 14, 2025

Conversation

mariocao
Copy link
Member

@mariocao mariocao commented Jan 13, 2025

Motivation

This PR implements fee management functionality in the SEDA Core contract, allowing for:

  • Request fees with gas-based refunds (derived from data results)
  • Result fees for result solvers
  • Batch fees for batch solver
  • Support of fee increases for pending requests

Explanation of Changes

The changes introduce several key components:

  • Added fee distribution logic in postResult function
  • Implemented gas-based refund mechanism for request fees
  • Added increaseFees function to allow updating fees for pending requests
  • Added batch sender tracking for proper fee distribution
  • Introduced RequestDetails struct to efficiently store fee-related data
  • Added relevant events for fee distribution tracking
  • Updated interfaces to support fee functionality

Testing

The changes are covered by comprehensive tests:

  • Fee distribution logic
  • Gas-based refund calculations
  • Fee increase functionality
  • Event emission verification
  • Edge cases and error conditions

Related PRs and Issues

Closes #77
Closes #78
Closes #79
Closes #80

@mariocao mariocao requested review from gluax and jasperdg January 13, 2025 17:40
Copy link

@gluax gluax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code logic looks good to me.

I'm going to nit on the comments as the auditors want comment coverage.
Some of the comments describe what the code is doing. Which should only be done if something complex is happening, which I don't think most of this is.
Comments should describe why the code is doing what it's doing. This helps maintain readability and understanding more than stating what something is doing.

The comments on functions and types are good though :).

contracts/core/SedaCoreV1.sol Show resolved Hide resolved
contracts/core/SedaCoreV1.sol Outdated Show resolved Hide resolved
contracts/core/SedaCoreV1.sol Outdated Show resolved Hide resolved
contracts/core/SedaCoreV1.sol Outdated Show resolved Hide resolved
contracts/core/SedaCoreV1.sol Outdated Show resolved Hide resolved
@gluax
Copy link

gluax commented Jan 13, 2025

Comments looking much better!!


function postRequest(
SedaDataTypes.RequestInputs calldata inputs,
uint256 requestFee,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to fix here but we should really have a wrapper or something to simplify the 3 fees and the rest of the inputs properties. (even if the user is overpaying, they'll get it refunded.)

contracts/mocks/SedaPermissioned.sol Outdated Show resolved Hide resolved
@mariocao mariocao merged commit 4a84692 into main Jan 14, 2025
2 checks passed
@mariocao mariocao deleted the feat/incentives branch January 14, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants