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

[aptosvm] charge more for keyless #13005

Merged
merged 2 commits into from
Apr 24, 2024
Merged

[aptosvm] charge more for keyless #13005

merged 2 commits into from
Apr 24, 2024

Conversation

davidiw
Copy link
Contributor

@davidiw davidiw commented Apr 24, 2024

Description

add a 150x multiplier for intrinsic gas for keyless txns

  • Swap min_transaction_gas_units from InternalGas to InternalGasPerByte -- that has no underlying change but the semantic change allows for it to be multiplied
  • Add in a multiplier for all intrinsic gas charges which will be 1 by default
  • Set a gas schedule of 150 for keyless -- defaults to 150 since this is live on testnet already...

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Other (specify)

How Has This Been Tested?

  • went to e2e-move-tests
  • added a println to output the gas consumed to a keyless transaction
  • Without the change the gas cost was 7
  • With the change it was 418
    No other impacts otherwise some goldens would have been modified.

Key Areas to Review

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

add a 150x multiplier for intrinsic gas for keyless txns
* Swap `min_transaction_gas_units` from `InternalGas` to
  `InternalGasPerByte` -- that has no underlying change but the semantic
  change allows for it to be multiplied
* Add in a multiplier for all intrinsic gas charges which will be 1 by default
* Set a gas schedule of 150 for keyless -- defaults to 150 since this is
  live on testnet already...
Copy link

trunk-io bot commented Apr 24, 2024

⏱️ 7h 49m total CI duration on this PR
Job Cumulative Duration Recent Runs
execution-performance / single-node-performance 2h 19m 🟩🟩🟩🟩
rust-targeted-unit-tests 1h 5m 🟩🟩🟩
rust-move-tests 39m 🟩🟩🟩
windows-build 36m 🟩
rust-smoke-tests 32m 🟩
rust-images / rust-all 30m 🟩🟩
rust-unit-tests 25m 🟩
rust-lints 22m 🟩🟩🟩
run-tests-main-branch 17m 🟩🟩🟩🟩
forge-compat-test / forge 14m 🟩
forge-e2e-test / forge 14m 🟩
general-lints 7m 🟩🟩🟩🟩
check-dynamic-deps 7m 🟩🟩🟩🟩🟩
cli-e2e-tests / run-cli-tests 6m 🟩
check 4m 🟩
rust-build-cached-packages 4m 🟩
semgrep/ci 2m 🟩🟩🟩🟩🟩
file_change_determinator 51s 🟩🟩🟩🟩
node-api-compatibility-tests / node-api-compatibility-tests 49s 🟩
execution-performance / file_change_determinator 48s 🟩🟩🟩🟩
file_change_determinator 38s 🟩🟩🟩🟩
file_change_determinator 36s 🟩🟩🟩
permission-check 16s 🟩🟩🟩🟩🟩
permission-check 13s 🟩🟩🟩🟩
permission-check 13s 🟩🟩🟩🟩🟩
permission-check 8s 🟩🟩🟩
permission-check 7s 🟩🟩🟩
determine-docker-build-metadata 7s 🟩🟩🟩

🚨 3 jobs on the last run were significantly faster/slower than expected

Job Duration vs 7d avg Delta
execution-performance / single-node-performance 35m 24m +44%
windows-build 36m 25m +42%
check-dynamic-deps 59s 2m -54%

settingsfeedbackdocs ⋅ learn more about trunk.io

Copy link
Contributor

@alinush alinush left a comment

Choose a reason for hiding this comment

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

Stamping, but I am no gas expert; so IDK if this is missing something 🙈

@igor-aptos igor-aptos added CICD:run-execution-performance-test Run execution performance test CICD:run-execution-performance-full-test Run execution performance test (full version) labels Apr 24, 2024
Copy link
Contributor

@igor-aptos igor-aptos left a comment

Choose a reason for hiding this comment

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

added labels to see if performance will be impacted by the call to check if txns is keyless

from the cleanliness of the code, I would've preferred:

  • if it wasn't a multiplier, but an addition. i.e. keyless transactions cost that much more, and we take current intrinsic cost and multiply by 149 to initialize it
  • if charge_intrinsic_gas_for_transaction was receiving the context (i.e. a is_keyless: bool, or authenticator_type: AuthenticatorTypeForCharging, with AuthenticatorTypeForCharging being an enum with Normal and Keyless values), and have it access the value. That way we don't have multiple places doing get_or_vm_startup_failure and accessing keyless_multiplier.

but these are nits, and can be changed later as well, so given time, looks good to me as is as well, up to you if you want to apply any of those or not.

@davidiw davidiw changed the title [aptosvm] hack to charge more for keyless [aptosvm] charge more for keyless Apr 24, 2024
This reimplements the gas charging for keyless in a more proper way,
decoupling the keyless charge from the exisitng intrinsic charge.
Copy link
Contributor Author

@davidiw davidiw 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 "approved", but can't approve my own PR :P

[
keyless_base_cost: InternalGas,
{ 17.. => "keyless.base" },
414_000_000,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

might have been cleaner to make this x*y, but still works

@davidiw davidiw enabled auto-merge (squash) April 24, 2024 18:57
@@ -110,9 +110,14 @@ pub trait AptosGasMeter: MoveGasMeter {
/// Charges an intrinsic cost for executing the transaction.
///
/// The cost stays constant for transactions below a certain size, but will grow proportionally
/// for bigger ones.
/// for bigger ones. THe multiplier can be used to increase the unit cost for exceptional
/// transactions like keyless.
Copy link
Contributor

Choose a reason for hiding this comment

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

Forgot to delete the extra comment here, but let's not bother with it right now as that'll trigger a rerun for all the tests

Copy link
Contributor

@igor-aptos igor-aptos left a comment

Choose a reason for hiding this comment

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

update looks good.

@vgao1996 for gas calibration utilities, we should see whether to treat keyless gas charge as part of the intrinsic or not

This comment has been minimized.

This comment has been minimized.

@vgao1996
Copy link
Contributor

for gas calibration utilities, we should see whether to treat keyless gas charge as part of the intrinsic or not
@igor-aptos It'll make our lives easier if we treat them as separate charges in terms of gas calibration.

Copy link
Contributor

✅ Forge suite realistic_env_max_load success on 7653329ee84ab49fe1d78229d3a6a99d589b93d8

two traffics test: inner traffic : committed: 7702 txn/s, latency: 5087 ms, (p50: 4800 ms, p90: 5900 ms, p99: 11700 ms), latency samples: 3327580
two traffics test : committed: 100 txn/s, latency: 1938 ms, (p50: 1800 ms, p90: 2100 ms, p99: 8400 ms), latency samples: 1760
Latency breakdown for phase 0: ["QsBatchToPos: max: 0.204, avg: 0.202", "QsPosToProposal: max: 0.254, avg: 0.235", "ConsensusProposalToOrdered: max: 0.488, avg: 0.435", "ConsensusOrderedToCommit: max: 0.392, avg: 0.377", "ConsensusProposalToCommit: max: 0.880, avg: 0.811"]
Max round gap was 1 [limit 4] at version 1446032. Max no progress secs was 6.3511972 [limit 15] at version 1446032.
Test Ok

Copy link
Contributor

✅ Forge suite compat success on aptos-node-v1.10.1 ==> 7653329ee84ab49fe1d78229d3a6a99d589b93d8

Compatibility test results for aptos-node-v1.10.1 ==> 7653329ee84ab49fe1d78229d3a6a99d589b93d8 (PR)
1. Check liveness of validators at old version: aptos-node-v1.10.1
compatibility::simple-validator-upgrade::liveness-check : committed: 6637 txn/s, latency: 5007 ms, (p50: 5000 ms, p90: 8000 ms, p99: 9500 ms), latency samples: 232320
2. Upgrading first Validator to new version: 7653329ee84ab49fe1d78229d3a6a99d589b93d8
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 1732 txn/s, latency: 16065 ms, (p50: 18800 ms, p90: 22900 ms, p99: 23900 ms), latency samples: 91820
3. Upgrading rest of first batch to new version: 7653329ee84ab49fe1d78229d3a6a99d589b93d8
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 1762 txn/s, latency: 15955 ms, (p50: 19300 ms, p90: 22100 ms, p99: 22900 ms), latency samples: 91660
4. upgrading second batch to new version: 7653329ee84ab49fe1d78229d3a6a99d589b93d8
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 2969 txn/s, latency: 10619 ms, (p50: 11400 ms, p90: 13500 ms, p99: 13800 ms), latency samples: 118780
5. check swarm health
Compatibility test for aptos-node-v1.10.1 ==> 7653329ee84ab49fe1d78229d3a6a99d589b93d8 passed
Test Ok

@davidiw davidiw merged commit 553f171 into main Apr 24, 2024
84 of 97 checks passed
@davidiw davidiw deleted the keylessgas branch April 24, 2024 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CICD:run-execution-performance-full-test Run execution performance test (full version) CICD:run-execution-performance-test Run execution performance test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants