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

chore(marketplace): add a cache for storage requests #1090

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

2-towns
Copy link
Contributor

@2-towns 2-towns commented Jan 28, 2025

Fix #1089

@2-towns 2-towns changed the title chore(marketplace): add a cache to for storage requests chore(marketplace): add a cache for storage requests Jan 28, 2025
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.

Looking good 👍 Just a few small suggestions. Is this PR ready to be out of draft?

_: type OnChainMarket,
contract: Marketplace,
rewardRecipient = Address.none,
requestCacheSize: uint16 = 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we don't need a default value here since there is a default value provided from the config?

Copy link
Contributor

Choose a reason for hiding this comment

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

Another option is you could set a default value in the constructor and in the config similar to how it's being done with DefaultBlockTtl. This would remove the need to pass in a value to the constructor in the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the DefaultBlockTtl solution. I applied it.

codex/conf.nim Outdated
Comment on lines 352 to 353
"The size of the request cache - " &
"reduce the contract calls to get the request data.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"The size of the request cache - " &
"reduce the contract calls to get the request data.",
"Maximum number of StorageRequests kept in memory. " &
"Reduces fetching of StorageRequest data from the contract.",

@2-towns
Copy link
Contributor Author

2-towns commented Jan 30, 2025

Looking good 👍 Just a few small suggestions. Is this PR ready to be out of draft?

Okay I will check your suggestions.

It is still in draft because you mentioned in #1083 that it would be good to include calls to marketplace.config but I think Adam already addressed it here:

proc config(market: OnChainMarket): Future[MarketplaceConfig] {.async.} =
without resolvedConfig =? market.configuration:
let fetchedConfig = await market.contract.configuration()
market.configuration = some fetchedConfig
return fetchedConfig
return resolvedConfig
.
Am I missing something ?

@2-towns 2-towns marked this pull request as ready for review January 30, 2025 08:42
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.

LGTM! 🚀

codex/conf.nim Outdated
Comment on lines 351 to 358
marketplaceRequestCacheSize* {.
desc:
"Maximum number of StorageRequests kept in memory." &
"Reduces fetching of StorageRequest data from the contract.",
defaultValue: DefaultRequestCacheSize,
defaultValueDesc: $DefaultRequestCacheSize,
name: "request-cache-size"
.}: uint16
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if this really needs to be CLI flag 😅 IMHO this only will confuse users who do not need this sort of granular control over the node. I would either remove this, or make this flag hidden, which will make it not show on CLI help page and maybe add note to our documentation. Which btw. should be updated anyhow as you are adding new CLI flag - the configuration section. aa

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we need to keep it because we would be in a situation where we are trying to debug something and we may want to change the value without building a new version. But I agree with you that it would confuse the users, so I think the best solution is to make it hidden.
For the documentation, yes I will update it after the PR is merged.

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.

Use a cache for the storage requests
3 participants