Skip to content

Price delayed publications #97

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Conversation

ggonzalez94
Copy link
Collaborator

@ggonzalez94 ggonzalez94 commented Apr 4, 2025

Fixes #68

This PR is an attempt to give the flexibility to price delayed publications differently, while still keeping them as part of the fees(more details can be found on the issue).

Pros of this approach:

  • Flexibility, delayed publications can be priced differently than regular pubs(we are using a uint16, so they can represent up to ~6.55x the normal fee - alternatively we can use a uint24 and that would allow ~167.77x)
  • Delayed fees are treated just as regular fees, and payed to provers when calling prove(no need to wait until the end of the period or put them in the stake)

Cons:
For now it:

  • Uses more storage since we have a new variable for the delayedFeePercentage. This shouldn't be an issue once we pack the storage variables
  • Adds another config parameter(which will be abstracted with an internal function soon)

These both are fixed in #100

This PR also:

  • Removes the ability to deposit from the payPublicationFee function
  • Fixes a bug where the Inbox was always sending the publication fee as part of the call to payPublicationFee. Now we rely on the proposer to deposit before and the call this function. This saves some gas since we don't need to query the fees beforehand

- Fixes a bug we had where the proposer would always have to send value with their tx
- Makes the process more gas efficient, since the inbox does not need to query the fees before
/// @param period The period that the prover is bidding to prove
/// @param fee The fee that the prover is willing to charge for proving each publication
/// @param stake The stake that the prover is going to put as stake for the period
event ProverOffer(address indexed prover, uint256 period, uint256 fee, uint256 stake);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: This is true for other events, we have period to mean periodID, since we have a Period struct, we should rename to periodId

/// @notice The percentage (in bps) of the fee that is charged for delayed publications
/// @dev It is recommended to set this to >10,000 bps since delayed publications should usually be charged at a
/// higher rate
uint16 public immutable delayedFeePercentage;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is probably very rare but is uint16 enough? given the percentage is given in bps. (we could only charge up to ~6.5x the normal fee)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct. I have a feeling that's more than enough, but we could make it an uint24 and that would allow ~167.77x. For now it wouldn't do any impact on storage since we are only using 25 bytes, so we still have 7 bytes available in that slot. But when the protocol evolves those bytes might be useful for some other purposes.

Co-authored-by: Leo <leonard.paturel@openzeppelin.com>
Copy link

github-actions bot commented Apr 24, 2025

Changes to gas cost

Generated at commit: 268903f6c8a44244ae57378107ed46c96e160fd9, compared to commit: 6d08743d2312340033442e3745582597c7041ff9

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
CheckpointTracker proveTransition +593 ❌ +0.80%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
CheckpointTracker 970,364 (+60,532) proveTransition 74,267 (+593) +0.80% 74,267 (+593) +0.80% 74,267 (+593) +0.80% 74,267 (+593) +0.80% 1 (0)
PublicationFeed 760,671 (0) validateHeader 4,991 (0) 0.00% 6,167 (-24) -0.39% 6,991 (0) 0.00% 6,991 (0) 0.00% 34 (+19)

/// @inheritdoc IProposerFees
/// @dev This function advances to the next period if the current period has ended.
function payPublicationFee(address proposer, bool isDelayed) external {
require(msg.sender == inbox, "Only the Inbox contract can call this function");
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are several examples of error strings rather than custom errors (as required by the style guide). It's probably worth creating them as we go.

We now use it consistently every time. The intuition is that the overflow
is a low-level computer science concept but the rationale about whether
it can overflow is a statement about likely business-level configurations.

We can optimise it later if it turns out to be prohibitive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Price delayed publications for proving and modify the ProverMarket
3 participants