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

Use constant minimum_new_receipt_gas #10941

Merged
merged 1 commit into from
Apr 5, 2024
Merged

Conversation

aborg-dev
Copy link
Contributor

This addresses the issue from #10829.

Because we plan to decrease the function call cost, we need to modify the refund estimation logic that relies on function call base cost.
This PR sets minimum_new_receipt_gas to 108_059_500_000 + 2_319_861_500_000 + 2_319_861_500_000 ~= 4.7TGas which would limit the overcharging to 6x which is the current level.

Copy link
Collaborator

@Ekleog-NEAR Ekleog-NEAR left a comment

Choose a reason for hiding this comment

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

Requesting changes for the issue in fetching the latest protocol version. I’m not an expert in how our blocks look like either, so I’d be happy to yield to anyone knowledgeable who’d confirm the current code is correct and my understanding of the other fetches of the current protocol version are wrong :)

chain/indexer/src/streamer/utils.rs Outdated Show resolved Hide resolved
runtime/runtime/src/config.rs Outdated Show resolved Hide resolved
@aborg-dev aborg-dev force-pushed the akashin/bounded_refunds branch 2 times, most recently from 871ee4e to 923078e Compare April 4, 2024 16:38
@bowenwang1996
Copy link
Collaborator

bowenwang1996 commented Apr 4, 2024

@Akashin I am confused about the number. Why don't we use the exact same number as 108_059_500_000 + 2_319_861_500_000 + 2_319_861_500_000 = 4747782500000 so that there is no protocol change in this part?

// congestion when receipts are delayed before they execute. Hence there is not much
// value to tie this limit to the function call base cost. Making it constant limits
// overcharging to 6x, which was the value before the cost increase.
4_850_000_000_000 // 4.85TGas.
Copy link
Contributor

@tayfunelmas tayfunelmas Apr 4, 2024

Choose a reason for hiding this comment

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

nit. is there some central place (eg. a file containing important constants) that this number be defined with a constant (for discoverability)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general, I agree with introducing dedicated constants. In this particular case, I don't think there is much value to be gained by doing this - we don't plan to reuse it anywhere (if we need to, adding a constant would make sense, otherwise, YAGNI applies), we already have a docstring that explains it and seeing it in a separate file without a usage context will yield very little insight to the reader and will introduce unnecessary indirection when reading this code.

@aborg-dev aborg-dev changed the title [protocol_change] Use constant minimum_new_receipt_gas Use constant minimum_new_receipt_gas Apr 5, 2024
@aborg-dev
Copy link
Contributor Author

@Akashin I am confused about the number. Why don't we use the exact same number as 108_059_500_000 + 2_319_861_500_000 + 2_319_861_500_000 = 4747782500000 so that there is no protocol change in this part?

I've updated the code to avoid the protocol update. We still need to look at the protocol version to keep the behavior consistent for past blocks where the gas costs were different.

This addresses the issue from #10829.

Because we plan to decrease the function call cost, we need to modify the refund estimation logic that relies on function call base cost.
This PR sets minimum_new_receipt_gas to 108_059_500_000 + 2_319_861_500_000 + 2_319_861_500_000 ~= 4.7TGas which would limit the overcharging to 6x which is the current level.
Copy link

codecov bot commented Apr 5, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 71.57%. Comparing base (75f801d) to head (0116edd).

Files Patch % Lines
chain/indexer/src/streamer/mod.rs 0.00% 3 Missing ⚠️
chain/indexer/src/streamer/utils.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10941      +/-   ##
==========================================
+ Coverage   71.56%   71.57%   +0.01%     
==========================================
  Files         758      758              
  Lines      152127   152135       +8     
  Branches   152127   152135       +8     
==========================================
+ Hits       108871   108892      +21     
+ Misses      38752    38736      -16     
- Partials     4504     4507       +3     
Flag Coverage Δ
backward-compatibility 0.24% <0.00%> (-0.01%) ⬇️
db-migration 0.24% <0.00%> (-0.01%) ⬇️
genesis-check 1.42% <0.00%> (-0.01%) ⬇️
integration-tests 37.08% <50.00%> (+<0.01%) ⬆️
linux 70.01% <40.00%> (-0.02%) ⬇️
linux-nightly 71.02% <50.00%> (+<0.01%) ⬆️
macos 54.54% <40.00%> (-0.01%) ⬇️
pytests 1.65% <0.00%> (-0.01%) ⬇️
sanity-checks 1.44% <0.00%> (-0.01%) ⬇️
unittests 67.18% <50.00%> (+<0.01%) ⬆️
upgradability 0.29% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@Ekleog-NEAR Ekleog-NEAR left a comment

Choose a reason for hiding this comment

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

LGTM! :)

We still need to look at the protocol version to keep the behavior consistent for past blocks where the gas costs were different.

Limited replayability when? 😅

@aborg-dev aborg-dev added this pull request to the merge queue Apr 5, 2024
Merged via the queue into master with commit a1ae126 Apr 5, 2024
27 of 29 checks passed
@aborg-dev aborg-dev deleted the akashin/bounded_refunds branch April 5, 2024 16:32
VanBarbascu pushed a commit that referenced this pull request Apr 5, 2024
This addresses the issue from
#10829.

Because we plan to decrease the function call cost, we need to modify
the refund estimation logic that
[relies](https://near.zulipchat.com/#narrow/stream/295306-contract-runtime/topic/major.20function.20call.20fees.20today/near/427527995)
on function call base cost.
This PR sets
[minimum_new_receipt_gas](https://github.com/near/nearcore/blob/32ef06752f3702e22bd69542df07a4e6e123477e/runtime/runtime/src/config.rs#L270)
to 108_059_500_000 + 2_319_861_500_000 + 2_319_861_500_000 ~= 4.7TGas
which would limit the overcharging to 6x which is the current level.
VanBarbascu pushed a commit that referenced this pull request Apr 8, 2024
This addresses the issue from
#10829.

Because we plan to decrease the function call cost, we need to modify
the refund estimation logic that
[relies](https://near.zulipchat.com/#narrow/stream/295306-contract-runtime/topic/major.20function.20call.20fees.20today/near/427527995)
on function call base cost.
This PR sets
[minimum_new_receipt_gas](https://github.com/near/nearcore/blob/32ef06752f3702e22bd69542df07a4e6e123477e/runtime/runtime/src/config.rs#L270)
to 108_059_500_000 + 2_319_861_500_000 + 2_319_861_500_000 ~= 4.7TGas
which would limit the overcharging to 6x which is the current level.
github-merge-queue bot pushed a commit that referenced this pull request Apr 8, 2024
This PR decreases the function call base execution cost to 1TGas.
It is stacked on #10941.
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.

5 participants