-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Conversation
693d085
to
517d911
Compare
api/src/context.rs
Outdated
@@ -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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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], |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
api/src/context.rs
Outdated
@@ -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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let featrure_version = gas_schedule.feature_version; | |
let feature_version = gas_schedule.feature_version; |
api/src/context.rs
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AptosGasParameters::from_on_chain_gas_schedule(&gas_schedule, featrure_version) | |
AptosGasParameters::from_on_chain_gas_schedule(&gas_schedule, feature_version) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
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
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.optional
marker with a new syntax that allows one to define a versioned gas schedule.Here's how the versioned gas schedule work:
This new system effectively allows one to rename or delete gas parameters.