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

refactor: estimate gas and fee #9889

Merged
merged 10 commits into from
Nov 12, 2024
Merged

refactor: estimate gas and fee #9889

merged 10 commits into from
Nov 12, 2024

Conversation

LeilaWang
Copy link
Contributor

@LeilaWang LeilaWang commented Nov 11, 2024

  • Private kernel tail does not include teardown gas limits at all.
  • Private kernel tail_to_public only includes teardown gas limits when teardown call request is not empty.
  • Private kernel tail_to_public combines both gas_used for non_revertible and revertible data, and export one single gas_used value, since revertible gas_used is still used for calculating fee when the tx reverts, there's no need to separate them.
  • Remove inclusion_fee in GasSettings: it's included in tx overhead.
  • Remove the logic and tests for aggregating gas used and computing fees in public kernel.
  • Aggregate gas used and computing fees properly in enqueued calls processor.

@LeilaWang LeilaWang added the e2e-all CI: Enables this CI job. label Nov 11, 2024
Copy link
Contributor

github-actions bot commented Nov 11, 2024

Changes to circuit sizes

Generated at commit: c1435120a49f60bc43615682b3f4f4fc61f5028d, compared to commit: d51309954ab4a5ae1c829c86185b02c156baf3c7

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_tail_to_public 0 ➖ 0.00% +7 ❌ +0.02%
private_kernel_empty -1 ✅ -0.16% -1 ✅ -0.00%
rollup_base_private 0 ➖ 0.00% -7 ✅ -0.00%
private_kernel_reset -2 ✅ -0.00% -2 ✅ -0.00%
rollup_base_public 0 ➖ 0.00% -94 ✅ -0.00%
private_kernel_reset_4_4_4_4_4_4_4_4_1 -2 ✅ -0.01% -3 ✅ -0.00%
private_kernel_inner -3 ✅ -0.01% -3 ✅ -0.01%
private_kernel_tail -2 ✅ -0.04% -1 ✅ -0.01%
private_kernel_init -5 ✅ -0.02% -5 ✅ -0.01%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_tail_to_public 18,849 (0) 0.00% 31,297 (+7) +0.02%
private_kernel_empty 607 (-1) -0.16% 942,834 (-1) -0.00%
rollup_base_private 332,869 (0) 0.00% 3,432,515 (-7) -0.00%
private_kernel_reset 84,096 (-2) -0.00% 618,116 (-2) -0.00%
rollup_base_public 470,052 (0) 0.00% 3,770,556 (-94) -0.00%
private_kernel_reset_4_4_4_4_4_4_4_4_1 32,454 (-2) -0.01% 86,599 (-3) -0.00%
private_kernel_inner 38,067 (-3) -0.01% 57,508 (-3) -0.01%
private_kernel_tail 4,490 (-2) -0.04% 13,042 (-1) -0.01%
private_kernel_init 21,703 (-5) -0.02% 34,866 (-5) -0.01%

const feeFromEstimatedGas = getFeeFromEstimatedGas(estimatedGas);

// The actual fee should be under the estimate, but not too much
// TODO(palla/gas): 3x is too much, find out why we cannot bring this down to 2x
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was too much because gasLimits included teardown gas, and getFeeFromEstimatedGas doubled the cost for teardown.

@@ -106,6 +105,7 @@ impl PublicBaseRollupInputs {
end,
start_state,
revert_code,
gas_used: Gas::empty(), // gas_used is not used in rollup circuits.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This unnecessary empty gas will go away after we deprecate public kernel tail.

Copy link
Contributor

@sirasistant sirasistant left a comment

Choose a reason for hiding this comment

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

Nice! 🚀

@LeilaWang LeilaWang merged commit a43c107 into master Nov 12, 2024
99 checks passed
@LeilaWang LeilaWang deleted the lw/gas_and_fee branch November 12, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e-all CI: Enables this CI job.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants