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

[gas] remove test_only and optional, and support versioned gas schedule #5794

Merged
merged 3 commits into from
Dec 18, 2022

Conversation

vgao1996
Copy link
Contributor

@vgao1996 vgao1996 commented Dec 7, 2022

This makes a few improvements to the macros we use to generate the bindings between the Rust representation of the gas schedule and its on-chain form. Specifically, this

  1. Removes test_only. test_only doubles the complexity of the macros and all it does is to allow us to assign non-zero gas costs to two test-only natives in move-stdlib, which isn't really necessary.
  2. Replaces the optional marker with a new syntax that allows one to define a versioned gas schedule.

Here's how the versioned gas schedule work:

/* before */
"foo" // or
optional "foo"

/* after */
"foo" // means the entry is expected to be found in all versions, under key "foo"
{ 1.. => "foo" } // means the entry is expected to be found in version 1 and above, under key "foo"
{ 3..=4 => "foo" } // means the entry is expected to be found in version 3 and 4 under key "foo", but not above 3 or below 4
{ 1 => "foo", 2.. => "bar" } // means the entry is expected to be found under key "foo" in version, and under key "bar" in version 2 and above

This new system effectively allows one to rename or delete gas parameters.

@@ -912,14 +912,15 @@ impl Context {

let gas_schedule_params =
match GasScheduleV2::fetch_config(&storage_adapter).and_then(|gas_schedule| {
let featrure_version = gas_schedule.feature_version;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: typo featrure_version => feature_version

Copy link
Contributor

Choose a reason for hiding this comment

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

Also nit: Why not just inline this if this var is only used once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: typo featrure_version => feature_version

Thanks for catching this! I can't believe I made so many typos yesterday...

Also nit: Why not just inline this if this var is only used once?

Tried that. Borrow checker's not happy.


// Reusing SHA2-512's cost from Ristretto
[.hash.sha2_512.base, optional "hash.sha2_512.base", 3_240],
[.hash.sha2_512.per_byte, optional "hash.sha2_512.per_byte", 60],
[.hash.sha2_512.base, { 4.. => "hash.sha2_512.base" }, 3_240],
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean 4 or above or exactly 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

4 or above. It's basically a rust pattern

@@ -912,14 +912,15 @@ impl Context {

let gas_schedule_params =
match GasScheduleV2::fetch_config(&storage_adapter).and_then(|gas_schedule| {
let featrure_version = gas_schedule.feature_version;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let featrure_version = gas_schedule.feature_version;
let feature_version = gas_schedule.feature_version;

let gas_schedule = gas_schedule.to_btree_map();
AptosGasParameters::from_on_chain_gas_schedule(&gas_schedule)
AptosGasParameters::from_on_chain_gas_schedule(&gas_schedule, featrure_version)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
AptosGasParameters::from_on_chain_gas_schedule(&gas_schedule, featrure_version)
AptosGasParameters::from_on_chain_gas_schedule(&gas_schedule, feature_version)

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

✅ Forge suite land_blocking success on 33c71d8d1aff23137735e39ff8d2fa802bb4422f

performance benchmark with full nodes : 6359 TPS, 6236 ms latency, 12900 ms p99 latency,(!) expired 600 out of 2715900 txns
Test Ok

@github-actions
Copy link
Contributor

✅ Forge suite compat success on testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> 33c71d8d1aff23137735e39ff8d2fa802bb4422f

Compatibility test results for testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> 33c71d8d1aff23137735e39ff8d2fa802bb4422f (PR)
1. Check liveness of validators at old version: testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b
compatibility::simple-validator-upgrade::liveness-check : 7312 TPS, 5301 ms latency, 7300 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: 33c71d8d1aff23137735e39ff8d2fa802bb4422f
compatibility::simple-validator-upgrade::single-validator-upgrade : 4638 TPS, 8779 ms latency, 11200 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: 33c71d8d1aff23137735e39ff8d2fa802bb4422f
compatibility::simple-validator-upgrade::half-validator-upgrade : 4534 TPS, 8890 ms latency, 11700 ms p99 latency,no expired txns
4. upgrading second batch to new version: 33c71d8d1aff23137735e39ff8d2fa802bb4422f
compatibility::simple-validator-upgrade::rest-validator-upgrade : 6372 TPS, 6068 ms latency, 10300 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> 33c71d8d1aff23137735e39ff8d2fa802bb4422f passed
Test Ok

@vgao1996 vgao1996 merged commit 7f74006 into aptos-labs:main Dec 18, 2022
@Markuze Markuze mentioned this pull request Dec 26, 2022
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.

3 participants