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

Price event bytes at the same rate as storage #370

Merged
merged 2 commits into from
Jul 2, 2024
Merged

Conversation

ureeves
Copy link
Member

@ureeves ureeves commented Jul 1, 2024

This PR introduces a cost to event emission proportional to the amount of bytes emitted, and at the same rate as a storage instruction. The rationale is that, while nodes are not necessarily required by protocol to hold this data like normal storage, it is still crucial data to hold for external applications, and contracts should be discouraged from emitting events that are "too large".

Hence, a payment at the same rate of storage seems appropriate for now. We may always choose to fine-tune this in a future protocol upgrade.

This should be the final round of pricing PRs, as I can't see the sense in pricing any other WebAssembly import offered to the contracts.

Resolves #359

Each byte in an event, be it topic or data, is priced at the same rate
as each byte in a storage instruction. This ensures each event is priced
more than a simple host function, since they require a larger processing
window.

This should be the final commit in pricing imports and host functions,
apart from adding additional functionality such as external
configuration.

Resolves #359
Copy link
Member

@HDauven HDauven left a comment

Choose a reason for hiding this comment

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

LGTM

Just to clarify, events are supposed to be stored in RocksDB for archival nodes and not as part of the smart contract storage, correct?

If this is the case, I believe we should consider incentivizing the use of events over storing data directly on the contract by making the price lower from the start.

Encouraging the use of events early on would help with reducing state bloat due to it being a cheaper option for certain use cases.

@ureeves
Copy link
Member Author

ureeves commented Jul 2, 2024

If this is the case, I believe we should consider incentivizing the use of events over storing data directly on the contract by making the price lower from the start.

The lowest we're getting event storage is not pricing the emit import at all and just relying on the fact that the contract has to write to the argument buffer - using storage instructions.

To be honest, if I look at all of this, prices are pretty low regardless of the choice. It's just the relative value that's important.

Copy link
Contributor

@fed-franz fed-franz left a comment

Choose a reason for hiding this comment

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

LGTM

@ureeves ureeves merged commit ac5c8b8 into main Jul 2, 2024
6 checks passed
@ureeves ureeves deleted the price-imports branch July 2, 2024 10:25
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.

Pricing strategy for Host Functions and Storage
3 participants