-
Notifications
You must be signed in to change notification settings - Fork 4
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
Update cost #111
Open
syntrust
wants to merge
8
commits into
main
Choose a base branch
from
update_cost
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update cost #111
+88
−9
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qzhodl
reviewed
Sep 19, 2024
@@ -34,6 +34,9 @@ contract DecentralizedKV is OwnableUpgradeable { | |||
/// https://github.com/ethereum-optimism/optimism/blob/develop/op-service/eth/blob.go#L16 | |||
uint256 internal constant MAX_OPTIMISM_BLOB_DATA_SIZE = (4 * 31 + 3) * 1024 - 4; | |||
|
|||
/// @notice Cost to update the value of an entry (TODO: change to immutable) | |||
uint256 internal constant UPDATE_COST = 150000000000000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it would be compatible if we use immutable here and upgrade the implementation of the current contract.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a dust cost for the update required by #36.
A constant
UPDATE_COST
is added meaning how much should be charged to update a KV entry or blob. Using constant to be compatible with the currently deployed contract, and may change to immutable later.The estimated value of 120,000 Gwei is derived from the maximum possible gas cost of a
putBlobs
batch transaction with a size of 4,872 for the same key, but containing only one blob. In this scenario, the gas used is 29,454,363, which means approximately the gas cost per kv update is 29454363 / 4872 = 6045.Assuming a gas price of 10 Gwei and a blob fee of 1 wei per gas unit,
(10000000000 * 29454363 + 1 * 131072) / 4872 = 60456 Gwei
Round to 60000 and doubled to be on the safe side.
If the DoSer does not care about the gas cost, an extra charge doubles the cost to prevent the attack. On the other hand, a price less than one-tenth of adding a new entry (storageCost = 1,500,000 Gwei) justifies the updates with good reason.