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

feature: Re-introduce Compute Costs #8915

Merged
merged 1 commit into from
Apr 18, 2023

Conversation

aborg-dev
Copy link
Contributor

@aborg-dev aborg-dev commented Apr 14, 2023

This PR re-introduces changes from #8805 together with #8892 after fixing #8908:

The PR addresses #8265 by introducing aggregation of compute usage across all operations performed during chunk application and limiting this compute usage to 1s.

This should not change the behavior of nodes in the short run because compute costs match gas costs which is validated by the assert, so any discrepancy should be caught on canary nodes.

@aborg-dev aborg-dev added the A-contract-runtime Area: contract compilation and execution, virtual machines, etc label Apr 17, 2023
@aborg-dev aborg-dev requested a review from jakmeier April 17, 2023 12:00
@aborg-dev aborg-dev marked this pull request as ready for review April 17, 2023 12:00
@aborg-dev aborg-dev requested a review from a team as a code owner April 17, 2023 12:00
@aborg-dev aborg-dev self-assigned this Apr 17, 2023
Copy link
Contributor

@jakmeier jakmeier left a comment

Choose a reason for hiding this comment

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

Looks good to me.

I'm still not quite sure how we can ensure profiles and gas match everywhere... But I gave it another round of questioning myself about cases we might have forgotten but couldn't find anything. And I would reason that we should have everything as follows:

  1. We use the gas profiles instead of the old counter only for function calls, which narrows down the potential problems.
  2. Inside function calls, we either pay for host function calls in VM logic or we account for the WASM op counter. The first case always goes through one of pay_action_accumulated, pay_per or pay_base, which we have now covered. The second case (WASM cost) is already computed through profiles, so there shouldn't be any changes.
  3. There is (always) one exception: contract_loading_fee is not a host function but is still charged from the dynamic gas. Fortunately, we charge it using pay_per and pay_base which covers this concern as well.
  4. Other places have no business changing the function call gas cost.

All in all, I think we can merge this again and should be fine this time.

feature: Limit compute usage of a chunk

The commit addresses near#8265  by introducing aggregation of compute usage across all operations performed during chunk application and limiting this compute usage to 1s.

This should not change the behavior of nodes in the short run because compute costs match gas costs which is validated by the `assert`, so any discrepancy should be caught on canary nodes.

There are two follow-ups to this work:
- near#8859
- near#8860
@near-bulldozer near-bulldozer bot merged commit 825997c into near:master Apr 18, 2023
nikurt pushed a commit that referenced this pull request Apr 18, 2023
This PR re-introduces changes from #8805 together with #8892 after fixing #8908:

The PR addresses #8265 by introducing aggregation of compute usage across all operations performed during chunk application and limiting this compute usage to 1s.

This should not change the behavior of nodes in the short run because compute costs match gas costs which is validated by the assert, so any discrepancy should be caught on canary nodes.
nikurt pushed a commit that referenced this pull request Apr 18, 2023
This PR re-introduces changes from #8805 together with #8892 after fixing #8908:

The PR addresses #8265 by introducing aggregation of compute usage across all operations performed during chunk application and limiting this compute usage to 1s.

This should not change the behavior of nodes in the short run because compute costs match gas costs which is validated by the assert, so any discrepancy should be caught on canary nodes.
nikurt pushed a commit that referenced this pull request Apr 25, 2023
This PR re-introduces changes from #8805 together with #8892 after fixing #8908:

The PR addresses #8265 by introducing aggregation of compute usage across all operations performed during chunk application and limiting this compute usage to 1s.

This should not change the behavior of nodes in the short run because compute costs match gas costs which is validated by the assert, so any discrepancy should be caught on canary nodes.
nikurt pushed a commit that referenced this pull request Apr 25, 2023
This PR re-introduces changes from #8805 together with #8892 after fixing #8908:

The PR addresses #8265 by introducing aggregation of compute usage across all operations performed during chunk application and limiting this compute usage to 1s.

This should not change the behavior of nodes in the short run because compute costs match gas costs which is validated by the assert, so any discrepancy should be caught on canary nodes.
nikurt pushed a commit that referenced this pull request Apr 28, 2023
This PR re-introduces changes from #8805 together with #8892 after fixing #8908:

The PR addresses #8265 by introducing aggregation of compute usage across all operations performed during chunk application and limiting this compute usage to 1s.

This should not change the behavior of nodes in the short run because compute costs match gas costs which is validated by the assert, so any discrepancy should be caught on canary nodes.
@aborg-dev aborg-dev deleted the compute_costs_debug branch June 12, 2023 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-contract-runtime Area: contract compilation and execution, virtual machines, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants