Skip to content

Commit f2dc79b

Browse files
committed
[gas] abstract gas algebra part 3 -- natives
1 parent 5ed4e00 commit f2dc79b

File tree

154 files changed

+4221
-5640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+4221
-5640
lines changed

Cargo.lock

Lines changed: 98 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ members = [
88
"api/types",
99
"aptos-move/aptos-aggregator",
1010
"aptos-move/aptos-debugger",
11-
"aptos-move/aptos-gas",
1211
"aptos-move/aptos-gas-algebra",
12+
"aptos-move/aptos-gas-meter",
1313
"aptos-move/aptos-gas-profiling",
1414
"aptos-move/aptos-gas-schedule",
15+
"aptos-move/aptos-gas-schedule-updator",
1516
"aptos-move/aptos-memory-usage-tracker",
17+
"aptos-move/aptos-native-interface",
1618
"aptos-move/aptos-release-builder",
1719
"aptos-move/aptos-resource-viewer",
1820
"aptos-move/aptos-sdk-builder",
@@ -30,6 +32,7 @@ members = [
3032
"aptos-move/e2e-testsuite",
3133
"aptos-move/framework",
3234
"aptos-move/framework/cached-packages",
35+
"aptos-move/framework/table-natives",
3336
"aptos-move/move-examples",
3437
"aptos-move/mvhashmap",
3538
"aptos-move/package-builder",
@@ -297,10 +300,11 @@ aptos-forge = { path = "testsuite/forge" }
297300
aptos-framework = { path = "aptos-move/framework" }
298301
aptos-fuzzer = { path = "testsuite/aptos-fuzzer" }
299302
fuzzer = { path = "testsuite/fuzzer" }
300-
aptos-gas = { path = "aptos-move/aptos-gas" }
303+
aptos-gas-meter = { path = "aptos-move/aptos-gas-meter" }
301304
aptos-gas-algebra = { path = "aptos-move/aptos-gas-algebra" }
302305
aptos-gas-profiling = { path = "aptos-move/aptos-gas-profiling" }
303306
aptos-gas-schedule = { path = "aptos-move/aptos-gas-schedule" }
307+
aptos-gas-schedule-updator = { path = "aptos-move/aptos-gas-schedule-updator" }
304308
aptos-genesis = { path = "crates/aptos-genesis" }
305309
aptos-github-client = { path = "crates/aptos-github-client" }
306310
aptos-global-constants = { path = "config/global-constants" }
@@ -330,6 +334,7 @@ aptos-metrics-core = { path = "crates/aptos-metrics-core" }
330334
aptos-move-examples = { path = "aptos-move/move-examples" }
331335
aptos-moving-average = { path = "crates/moving-average" }
332336
aptos-mvhashmap = { path = "aptos-move/mvhashmap" }
337+
aptos-native-interface = { path = "aptos-move/aptos-native-interface" }
333338
aptos-netcore = { path = "network/netcore" }
334339
aptos-network = { path = "network" }
335340
aptos-network-builder = { path = "network/builder" }
@@ -633,6 +638,7 @@ move-prover = { path = "third_party/move/move-prover" }
633638
move-prover-boogie-backend = { path = "third_party/move/move-prover/boogie-backend" }
634639
move-stackless-bytecode = { path = "third_party/move/move-prover/bytecode" }
635640
aptos-move-stdlib = { path = "aptos-move/framework/move-stdlib" }
641+
aptos-table-natives = { path = "aptos-move/framework/table-natives" }
636642
move-prover-test-utils = { path = "third_party/move/move-prover/test-utils" }
637643
move-resource-viewer = { path = "third_party/move/tools/move-resource-viewer" }
638644
move-symbol-pool = { path = "third_party/move/move-symbol-pool" }

api/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ aptos-api-types = { workspace = true }
1818
aptos-build-info = { workspace = true }
1919
aptos-config = { workspace = true }
2020
aptos-crypto = { workspace = true }
21-
aptos-gas = { workspace = true }
21+
aptos-gas-schedule = { workspace = true }
2222
aptos-logger = { workspace = true }
2323
aptos-mempool = { workspace = true }
2424
aptos-metrics-core = { workspace = true }
@@ -52,7 +52,7 @@ url = { workspace = true }
5252
aptos-api-test-context = { workspace = true }
5353
aptos-cached-packages = { workspace = true }
5454
aptos-framework = { workspace = true }
55-
aptos-gas = { workspace = true, features = ["testing"] }
55+
aptos-gas-meter = { workspace = true }
5656
aptos-proptest-helpers = { workspace = true }
5757
aptos-sdk = { workspace = true }
5858
move-package = { workspace = true }

api/src/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use aptos_api_types::{
1717
};
1818
use aptos_config::config::{NodeConfig, RoleType};
1919
use aptos_crypto::HashValue;
20-
use aptos_gas::{AptosGasParameters, FromOnChainGasSchedule};
20+
use aptos_gas_schedule::{AptosGasParameters, FromOnChainGasSchedule};
2121
use aptos_logger::error;
2222
use aptos_mempool::{MempoolClientRequest, MempoolClientSender, SubmissionStatus};
2323
use aptos_state_view::TStateView;
@@ -1092,7 +1092,7 @@ impl Context {
10921092

10931093
fn min_gas_unit_price<E: InternalError>(&self, ledger_info: &LedgerInfo) -> Result<u64, E> {
10941094
let (_, gas_schedule) = self.get_gas_schedule(ledger_info)?;
1095-
Ok(gas_schedule.txn.min_price_per_gas_unit.into())
1095+
Ok(gas_schedule.vm.txn.min_price_per_gas_unit.into())
10961096
}
10971097

10981098
pub fn get_gas_schedule<E: InternalError>(

api/src/transactions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,9 @@ impl TransactionsApi {
452452
let estimated_max_gas_amount = if estimate_max_gas_amount.0.unwrap_or_default() {
453453
// Retrieve max possible gas units
454454
let (_, gas_params) = self.context.get_gas_schedule(&ledger_info)?;
455-
let min_number_of_gas_units = u64::from(gas_params.txn.min_transaction_gas_units)
456-
/ u64::from(gas_params.txn.gas_unit_scaling_factor);
457-
let max_number_of_gas_units = u64::from(gas_params.txn.maximum_number_of_gas_units);
455+
let min_number_of_gas_units = u64::from(gas_params.vm.txn.min_transaction_gas_units)
456+
/ u64::from(gas_params.vm.txn.gas_unit_scaling_factor);
457+
let max_number_of_gas_units = u64::from(gas_params.vm.txn.maximum_number_of_gas_units);
458458

459459
// Retrieve account balance to determine max gas available
460460
let account_state = self

aptos-move/aptos-aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ rust-version = { workspace = true }
1616
anyhow = { workspace = true }
1717
aptos-crypto = { workspace = true }
1818
aptos-state-view = { workspace = true }
19+
aptos-table-natives = { workspace = true }
1920
aptos-types = { workspace = true }
2021
bcs = { workspace = true }
2122
better_any = { workspace = true }
2223
move-binary-format = { workspace = true }
2324
move-core-types = { workspace = true }
24-
move-table-extension = { workspace = true }
2525
once_cell = { workspace = true }
2626
smallvec = { workspace = true }
2727

aptos-move/aptos-aggregator/src/aggregator_extension.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
use crate::delta_change_set::{addition, deserialize, subtraction};
5+
use aptos_table_natives::{TableHandle, TableResolver};
56
use aptos_types::vm_status::StatusCode;
67
use move_binary_format::errors::{PartialVMError, PartialVMResult};
78
use move_core_types::account_address::AccountAddress;
8-
use move_table_extension::{TableHandle, TableResolver};
99
use std::collections::{BTreeMap, BTreeSet};
1010

1111
/// Describes the state of each aggregator instance.

aptos-move/aptos-debugger/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ edition = "2021"
1212
[dependencies]
1313
anyhow = { workspace = true }
1414
aptos-crypto = { workspace = true }
15-
aptos-gas-schedule = { workspace = true }
16-
aptos-gas = { workspace = true }
15+
aptos-gas-meter = { workspace = true }
1716
aptos-gas-profiling = { workspace = true }
17+
aptos-gas-schedule = { workspace = true }
1818
aptos-logger = { workspace = true }
1919
aptos-memory-usage-tracker = { workspace = true }
2020
aptos-resource-viewer = { workspace = true }
2121
aptos-rest-client = { workspace = true }
2222
aptos-state-view = { workspace = true }
23+
aptos-table-natives = { workspace = true }
2324
aptos-types = { workspace = true }
2425
aptos-validator-interface = { workspace = true }
2526
aptos-vm = { workspace = true }
@@ -31,7 +32,6 @@ move-cli = { workspace = true }
3132
move-compiler = { workspace = true }
3233
move-core-types = { workspace = true }
3334
move-resource-viewer = { workspace = true }
34-
move-table-extension = { workspace = true }
3535
move-vm-runtime = { workspace = true }
3636
move-vm-test-utils = { workspace = true }
3737
tokio = { workspace = true }

aptos-move/aptos-debugger/src/lib.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
use anyhow::{format_err, Result};
5-
use aptos_gas::{
6-
AbstractValueSizeGasParameters, ChangeSetConfigs, NativeGasParameters, StandardGasAlgebra,
7-
StandardGasMeter,
8-
};
5+
use aptos_gas_meter::{StandardGasAlgebra, StandardGasMeter};
96
use aptos_gas_profiling::{GasProfiler, TransactionGasLog};
10-
use aptos_gas_schedule::LATEST_GAS_FEATURE_VERSION;
7+
use aptos_gas_schedule::{MiscGasParameters, NativeGasParameters, LATEST_GAS_FEATURE_VERSION};
118
use aptos_memory_usage_tracker::MemoryTrackedGasMeter;
129
use aptos_resource_viewer::{AnnotatedAccountStateBlob, AptosValueAnnotator};
1310
use aptos_rest_client::Client;
@@ -31,7 +28,7 @@ use aptos_vm::{
3128
AptosVM, VMExecutor,
3229
};
3330
use aptos_vm_logging::log_schema::AdapterLogSchema;
34-
use aptos_vm_types::{change_set::VMChangeSet, output::VMOutput};
31+
use aptos_vm_types::{change_set::VMChangeSet, output::VMOutput, storage::ChangeSetConfigs};
3532
use move_binary_format::errors::VMResult;
3633
use std::{path::Path, sync::Arc};
3734

@@ -231,7 +228,7 @@ impl AptosDebugger {
231228
let features = Features::fetch_config(&state_view_storage).unwrap_or_default();
232229
let move_vm = MoveVmExt::new(
233230
NativeGasParameters::zeros(),
234-
AbstractValueSizeGasParameters::zeros(),
231+
MiscGasParameters::zeros(),
235232
LATEST_GAS_FEATURE_VERSION,
236233
ChainId::test().id(),
237234
features,

0 commit comments

Comments
 (0)