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

Storage fee for state bytes refundable #11279

Merged
merged 5 commits into from
Feb 14, 2024
Merged

Conversation

msmouse
Copy link
Contributor

@msmouse msmouse commented Dec 11, 2023

Description

  1. treat storage fee for bytes as deposit, which is refundable.
  2. When slot increase in size on modification, charge additionally into the deposit.
    1. legacy slots that didn't pay bytes deposits won't get charged for the bytes allocated for free.
    1. Considering pricing change, charge only to the point where the total deposit for bytes don't go beyond current_price_per_byte x num_current_bytes
  3. When slot decrease in size, don't refund, to simplify implementation.
  4. If slot doesn't change in size on modification, no charging even if pricing changes.
  5. Refund only on deletion.
  6. There's no longer non-refundable penalty when a slot larger than 1KB gets touched.

Pricing is reduced to 4k octas per slot and 40 octas per byte. As a result:
1. allocating an item smaller than 250 bytes is cheaper than before.
2. allocating an item of the size between 250 to 4K bytes will be slightly more expensive. The price increase peaks at 1KB at about 60%
image
3. merely touching a slot > 1KB no longer imposes penalty so such txns get significantly cheaper. As seen in MutateLargeTokenV2, UpgradeLarge, etc.

image

Test Plan

Copy link

trunk-io bot commented Dec 11, 2023

⏱️ 64h 16m total CI duration on this PR
Job Cumulative Duration Recent Runs
windows-build 14h 2m 🟩🟩🟩🟩🟩 (+44 more)
rust-unit-tests 11h 22m 🟥🟩 (+27 more)
rust-move-unit-coverage 7h 48m 🟩🟩🟩 (+30 more)
rust-unit-coverage 4h 19m 🟩
rust-lints 3h 30m 🟩🟩 (+27 more)
forge-framework-upgrade-test / forge 3h 2m 🟥🟥🟥🟥🟥
rust-images / rust-all 2h 59m 🟩🟩🟩🟩 (+15 more)
rust-smoke-coverage 2h 46m 🟩
run-tests-main-branch 2h 23m 🟩🟩🟩🟥🟥 (+29 more)
check 2h 7m 🟩🟩🟩 (+36 more)
check-dynamic-deps 1h 45m 🟩🟩🟩🟩🟩 (+44 more)
general-lints 1h 14m 🟩🟩🟩 (+27 more)
rust-smoke-tests 1h 5m 🟩🟩
execution-performance / single-node-performance 1h 1m 🟩🟩🟩
forge-compat-test / forge 28m 🟩🟩
forge-e2e-test / forge 26m 🟩🟩
cli-e2e-tests / run-cli-tests 21m 🟩🟩
semgrep/ci 18m 🟩🟩🟩🟩🟩 (+46 more)
rust-move-tests 15m
replay-mainnet / replay-verify (10) 9m
replay-mainnet / replay-verify (11) 9m
replay-mainnet / replay-verify (0) 9m
replay-mainnet / replay-verify (1) 9m
replay-mainnet / replay-verify (12) 9m
replay-mainnet / replay-verify (14) 9m
replay-mainnet / replay-verify (13) 9m
replay-mainnet / replay-verify (15) 9m
replay-mainnet / replay-verify (2) 9m
replay-mainnet / replay-verify (16) 9m
replay-mainnet / replay-verify (3) 9m
replay-mainnet / replay-verify (4) 9m
replay-mainnet / replay-verify (5) 8m
replay-mainnet / replay-verify (9) 8m
replay-mainnet / replay-verify (6) 8m
replay-mainnet / replay-verify (8) 8m
replay-mainnet / replay-verify (7) 8m
file_change_determinator 8m 🟩🟩🟩🟩🟩 (+26 more)
indexer-grpc-e2e-tests / test-indexer-grpc-docker-compose 6m 🟩🟥🟩🟥
file_change_determinator 6m 🟩🟩🟩🟩 (+30 more)
file_change_determinator 4m 🟩🟩🟩🟩🟩 (+15 more)
permission-check 2m 🟩🟩🟩🟩🟩 (+42 more)
permission-check 2m 🟩🟩🟩🟩🟩 (+42 more)
node-api-compatibility-tests / node-api-compatibility-tests 2m 🟩🟩
docs-lint 1m 🟩🟩
permission-check 1m 🟩🟩🟩🟩 (+35 more)
permission-check 1m 🟩🟩🟩🟩🟩 (+29 more)
permission-check 54s 🟩🟩🟩🟩🟩 (+19 more)
determine-docker-build-metadata 53s 🟩🟩🟩🟩🟩 (+16 more)
execution-performance / file_change_determinator 23s 🟩🟩
execution-performance / parallel-execution-performance 22s 🟩🟩🟩
execution-performance / sequential-execution-performance 21s 🟩🟩🟩
upload-to-codecov 16s 🟩
determine-test-metadata 5s 🟩

🚨 1 job on the last run was significantly faster/slower than expected

Job Duration vs 7d avg Delta
run-tests-main-branch 7m 4m +66%

settingsfeedbackdocs ⋅ learn more about trunk.io

@msmouse
Copy link
Contributor Author

msmouse commented Dec 11, 2023

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Attention: 47 lines in your changes are missing coverage. Please review.

Comparison is base (e7bedbb) 71.4% compared to head (6ae89bd) 71.4%.

❗ Current head 6ae89bd differs from pull request most recent head f1aca08. Consider uploading reports for the commit f1aca08 to get more accurate results

Files Patch % Lines
...aptos-gas-schedule/src/gas_schedule/transaction.rs 0.0% 22 Missing ⚠️
...s-move/aptos-vm-types/src/storage/space_pricing.rs 88.6% 11 Missing ⚠️
...move/aptos-gas-schedule/src/gas_schedule/macros.rs 0.0% 5 Missing ⚠️
aptos-move/aptos-vm-types/src/change_set.rs 85.2% 5 Missing ⚠️
aptos-move/aptos-vm-types/src/abstract_write_op.rs 83.3% 3 Missing ⚠️
aptos-move/aptos-vm-types/src/storage/mod.rs 83.3% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #11279    +/-   ##
========================================
  Coverage    71.4%    71.4%            
========================================
  Files         799      799            
  Lines      183539   183702   +163     
========================================
+ Hits       131050   131217   +167     
+ Misses      52489    52485     -4     

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

@msmouse msmouse force-pushed the 1210-alden-ephemeral-bytes-fee branch 2 times, most recently from 9b277b2 to c38c619 Compare December 11, 2023 17:17
@msmouse msmouse requested review from igor-aptos, a team and vgao1996 December 11, 2023 17:17
@msmouse msmouse mentioned this pull request Dec 12, 2023
@msmouse msmouse force-pushed the 1210-alden-ephemeral-bytes-fee branch from c38c619 to d177cc6 Compare December 12, 2023 04:25
@msmouse msmouse changed the base branch from 1208-alden-no-free-quota to 1206_consolidate_to_pricing December 12, 2023 04:25
@msmouse msmouse mentioned this pull request Dec 12, 2023
@msmouse msmouse force-pushed the 1210-alden-ephemeral-bytes-fee branch 2 times, most recently from b745f5c to 690c116 Compare December 12, 2023 04:54
@msmouse msmouse changed the title Introduce Ephemeral Bytes Fee Introduce Ephemeral Storage Fee Dec 12, 2023
@msmouse msmouse force-pushed the 1210-alden-ephemeral-bytes-fee branch from 690c116 to 4afcf64 Compare December 12, 2023 16:47
@msmouse msmouse force-pushed the 1210-alden-ephemeral-bytes-fee branch from 4afcf64 to ba94712 Compare December 12, 2023 17:25
@msmouse msmouse force-pushed the 1210-alden-ephemeral-bytes-fee branch from ba94712 to 7c75a2b Compare December 12, 2023 19:00
@msmouse msmouse force-pushed the 1210-alden-ephemeral-bytes-fee branch from 7c75a2b to 7a33a9a Compare December 12, 2023 22:01

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

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.

@gelash can you take a look, and recheck would access to prev_size be properly captured and validated (especially new field in ResourceGroupWrite?

do we need test/proptest for that?

@msmouse msmouse force-pushed the 1210-alden-ephemeral-bytes-fee branch from fff37b8 to 568e8d7 Compare February 14, 2024 17:07
@msmouse msmouse force-pushed the 1210-alden-ephemeral-bytes-fee branch 2 times, most recently from 71410f1 to 6ae89bd Compare February 14, 2024 17:12
@msmouse
Copy link
Contributor Author

msmouse commented Feb 14, 2024

@gelash can you take a look, and recheck would access to prev_size be properly captured and validated (especially new field in ResourceGroupWrite?

It's the third commit, @gelash
Thank you!

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

@gelash gelash left a comment

Choose a reason for hiding this comment

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

pre_group_size looks good

@@ -133,6 +154,7 @@ pub struct GroupWrite {
pub(crate) inner_ops: BTreeMap<StructTag, (WriteOp, Option<Arc<MoveTypeLayout>>)>,
/// Group size as used for gas charging, None if (metadata_)op is Deletion.
pub(crate) maybe_group_op_size: Option<u64>,
pub(crate) prev_group_size: u64,
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this is 0 if group is being created?
I'm fine with it, just wondering whether we should have maybe_group_op_size and prev_group_size have a consistent convention. It's also fine to wait for later (can add a TODO)

@@ -255,6 +255,7 @@ impl<'r> WriteOpConverter<'r> {
self.convert(state_value_metadata, metadata_op, false)?,
inner_ops,
post_group_size.get(),
pre_group_size.get(),
Copy link
Contributor

Choose a reason for hiding this comment

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

@msmouse if you don't mind, and are making changes to the PR anyway (otherwise i'll do it later), could you update the comment above, just noticed it's outdated (we don't encode the size, also an important point is to explain why we even need an Op now).
i.e. could you please replace 243-246 with
"Create an op to encode the proper kind for resource group operation"
(@igor-aptos I think now this is the main reason?)
Interestingly, we may be able to get rid of the ugly metadata_op, since we have both pre_group_size and post_group_size, thanks @msmouse! (but not in this PR obviously :)

Otherwise, pre_group_size should be properly validated, we rely on it for resource group correctness, in fact the kind, i.e. Creation/Modification/Deletion, and it passed replay.
proptests for resource groups do already check the resource_group_size() call (re: @igor-aptos)

@msmouse msmouse force-pushed the 1210-alden-ephemeral-bytes-fee branch from 6ae89bd to f1aca08 Compare February 14, 2024 19:39
@msmouse msmouse enabled auto-merge (rebase) February 14, 2024 19:39
@msmouse msmouse enabled auto-merge (rebase) February 14, 2024 19:39

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

✅ Forge suite compat success on aptos-node-v1.8.3 ==> f1aca08f21637d9863c455ec2dfe84d744e6eeaf

Compatibility test results for aptos-node-v1.8.3 ==> f1aca08f21637d9863c455ec2dfe84d744e6eeaf (PR)
1. Check liveness of validators at old version: aptos-node-v1.8.3
compatibility::simple-validator-upgrade::liveness-check : committed: 4630 txn/s, latency: 6836 ms, (p50: 6600 ms, p90: 9600 ms, p99: 17300 ms), latency samples: 171320
2. Upgrading first Validator to new version: f1aca08f21637d9863c455ec2dfe84d744e6eeaf
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 1783 txn/s, latency: 16094 ms, (p50: 19300 ms, p90: 22300 ms, p99: 22800 ms), latency samples: 92760
3. Upgrading rest of first batch to new version: f1aca08f21637d9863c455ec2dfe84d744e6eeaf
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 1776 txn/s, latency: 15591 ms, (p50: 19400 ms, p90: 21700 ms, p99: 22200 ms), latency samples: 92360
4. upgrading second batch to new version: f1aca08f21637d9863c455ec2dfe84d744e6eeaf
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 2794 txn/s, latency: 11044 ms, (p50: 9900 ms, p90: 15400 ms, p99: 16000 ms), latency samples: 128540
5. check swarm health
Compatibility test for aptos-node-v1.8.3 ==> f1aca08f21637d9863c455ec2dfe84d744e6eeaf passed
Test Ok

Copy link
Contributor

✅ Forge suite realistic_env_max_load success on f1aca08f21637d9863c455ec2dfe84d744e6eeaf

two traffics test: inner traffic : committed: 7522 txn/s, latency: 5078 ms, (p50: 4800 ms, p90: 6300 ms, p99: 13200 ms), latency samples: 3257220
two traffics test : committed: 100 txn/s, latency: 2221 ms, (p50: 2000 ms, p90: 2400 ms, p99: 11400 ms), latency samples: 1880
Latency breakdown for phase 0: ["QsBatchToPos: max: 0.247, avg: 0.206", "QsPosToProposal: max: 0.166, avg: 0.154", "ConsensusProposalToOrdered: max: 0.591, avg: 0.553", "ConsensusOrderedToCommit: max: 0.457, avg: 0.438", "ConsensusProposalToCommit: max: 1.038, avg: 0.991"]
Max round gap was 1 [limit 4] at version 1427758. Max no progress secs was 9.995772 [limit 15] at version 1427758.
Test Ok

@msmouse msmouse merged commit a39fd1e into main Feb 14, 2024
92 of 127 checks passed
@msmouse msmouse deleted the 1210-alden-ephemeral-bytes-fee branch February 14, 2024 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CICD:run-e2e-tests when this label is present github actions will run all land-blocking e2e tests from the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants