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: price per byte #1078

Merged
merged 15 commits into from
Jan 24, 2025
Merged

Feat: price per byte #1078

merged 15 commits into from
Jan 24, 2025

Conversation

marcinczenko
Copy link
Contributor

This PR is one of the PRs for issue #460. See #460 (comment).

  1. Introduces the following naming changes:

    • For StorageAsk:

      • pricePerBytePerSecond,
      • collateralPerByte
    • For Availability:

      • minPricePerBytePerSecond
      • totalRemainingCollateral
      • maxCollateralPerByte (computed helper)
    • StorageAsk helpers:

      • pricePerSlotPerSecond
      • pricePerSlot
      • collateralPerSlot
  2. Fixes related computations and tests

@marcinczenko marcinczenko self-assigned this Jan 20, 2025
@marcinczenko marcinczenko marked this pull request as draft January 20, 2025 02:37
@marcinczenko marcinczenko added the Marketplace See https://miro.com/app/board/uXjVNZ03E-c=/ for details label Jan 20, 2025
@marcinczenko marcinczenko force-pushed the feat/price-per-byte branch 3 times, most recently from dedbed5 to cde6676 Compare January 23, 2025 01:46
@marcinczenko marcinczenko marked this pull request as ready for review January 23, 2025 03:24
Copy link
Contributor

@emizzle emizzle left a comment

Choose a reason for hiding this comment

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

Great job Marcin! I've added a few suggestions.

I'll approve now, since there is nothing major blocking this, however it would be nice if the comments were responded to and/or addressed, in particular:

  • Fix for minPricePerBytePerSecond => collateralPerByte in the marketplacesuite
  • Add tests to testcancelled and testfinished that show the collateral passed into onCleanUp is correct.

Copy link
Contributor

@emizzle emizzle left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes, Marcin.

Comment on lines +538 to +546
check eventually (
onProcessSlotCalledWith ==
@[
(item3.requestId, item3.slotIndex),
(item2.requestId, item2.slotIndex),
(item1.requestId, item1.slotIndex),
(item0.requestId, item0.slotIndex),
]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, i had issues with this passing consistently on slow CI systems due to popping of SlotQueueItems before the new ones are added. Hopefully this doesn't happen 👍

Copy link
Contributor Author

@marcinczenko marcinczenko Jan 23, 2025

Choose a reason for hiding this comment

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

Oh, I see - so far it seems to be working ok. push is not async, so I thought it will not let it happen if we do not have any await in between. We could probably even use a helper that is already there proc push*(self: SlotQueue, items: seq[SlotQueueItem]): ?!void...

Comment on lines +189 to +190
func collateralPerSlot*(ask: StorageAsk): UInt256 =
ask.collateralPerByte * ask.slotSize
Copy link
Member

Choose a reason for hiding this comment

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

As we discussed yesterday, for the sake of explicitness, I would be cautious with this helper as the real collateral that the host has to pay is dependent on the slot's state.

I would suggest replacing this helper with a helper on the market abstraction that would return the correct collateral based on the slot's state. If I see it correctly, then this is used only at the filling state (except all the tests usages), where I exactly suggested replacing this in the review of Arnaud PR: #1083 (comment)

Copy link
Contributor Author

@marcinczenko marcinczenko Jan 24, 2025

Choose a reason for hiding this comment

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

I am kind of fine with it, but could we maybe please handle it on a separate PR - or maybe on Arnoud's PR? I will not be able to work on in in the coming days I am behind with BitTorrent stuff...

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, make sense - I am OK with that 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @AuHau!

openapi.yaml Outdated
type: string
description: Maximum collateral user is willing to pay per filled Slot (in amount of tokens) as decimal string
description: Total remaining collateral (in amount of tokens) that can still be used for matching requests
Copy link
Member

Choose a reason for hiding this comment

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

"remaining" word kind of does not make sense in the context of POST, but I don't really have any idea how to improve it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good catch, "remaining" should not be there. I introduced totalCollateral on the API level exactly for the reason you mention. On API you can only specify totalCollateral and not totalRemainingCollateral.

Now it is: description: Total collateral (in amount of tokens) that can be used for matching requests

@veaceslavdoina veaceslavdoina added this pull request to the merge queue Jan 24, 2025
Merged via the queue into master with commit 962fc1c Jan 24, 2025
20 checks passed
@veaceslavdoina veaceslavdoina deleted the feat/price-per-byte branch January 24, 2025 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Marketplace See https://miro.com/app/board/uXjVNZ03E-c=/ for details
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants