Skip to content

Commit

Permalink
Introduce code cache and loader V2 (#14184)
Browse files Browse the repository at this point in the history
Replaces existing loader infrastructure with new code cache
  • Loading branch information
georgemitenkov authored Oct 29, 2024
1 parent f05afc2 commit 751c9a3
Show file tree
Hide file tree
Showing 205 changed files with 11,502 additions and 3,166 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/replay-verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
BACKUP_CONFIG_TEMPLATE_PATH: terraform/helm/fullnode/files/backup/gcs.yaml
# workflow config
RUNS_ON: "high-perf-docker-with-local-ssd"
TIMEOUT_MINUTES: 180
TIMEOUT_MINUTES: 240
MAX_VERSIONS_PER_RANGE: 2000000

replay-mainnet:
Expand All @@ -96,7 +96,7 @@ jobs:
BACKUP_CONFIG_TEMPLATE_PATH: terraform/helm/fullnode/files/backup/gcs.yaml
# workflow config
RUNS_ON: "high-perf-docker-with-local-ssd"
TIMEOUT_MINUTES: 180
TIMEOUT_MINUTES: 240
MAX_VERSIONS_PER_RANGE: 800000

test-replay:
Expand Down
68 changes: 65 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ members = [
"aptos-move/aptos-validator-interface",
"aptos-move/aptos-vm",
"aptos-move/aptos-vm-benchmarks",
"aptos-move/aptos-vm-environment",
"aptos-move/aptos-vm-logging",
"aptos-move/aptos-vm-profiling",
"aptos-move/aptos-vm-types",
Expand Down Expand Up @@ -457,6 +458,7 @@ aptos-validator-interface = { path = "aptos-move/aptos-validator-interface" }
aptos-validator-transaction-pool = { path = "crates/validator-transaction-pool" }
aptos-vault-client = { path = "secure/storage/vault" }
aptos-vm = { path = "aptos-move/aptos-vm" }
aptos-vm-environment = { path = "aptos-move/aptos-vm-environment" }
aptos-vm-logging = { path = "aptos-move/aptos-vm-logging" }
aptos-vm-genesis = { path = "aptos-move/vm-genesis" }
aptos-vm-types = { path = "aptos-move/aptos-vm-types" }
Expand All @@ -472,6 +474,7 @@ atty = "0.2.14"
nalgebra = "0.32"
float-cmp = "0.9.0"
again = "0.1.2"
ambassador = "0.4.1"
anyhow = "1.0.71"
anstyle = "1.0.1"
arbitrary = { version = "1.3.2", features = ["derive"] }
Expand Down
4 changes: 2 additions & 2 deletions api/test-context/src/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use aptos_types::{
},
};
use aptos_vm::AptosVM;
use aptos_vm_validator::vm_validator::VMValidator;
use aptos_vm_validator::vm_validator::PooledVMValidator;
use bytes::Bytes;
use hyper::{HeaderMap, Response};
use rand::SeedableRng;
Expand Down Expand Up @@ -172,7 +172,7 @@ pub fn new_test_context_inner(
db_bootstrapper::maybe_bootstrap::<AptosVM>(&db_rw, &genesis, genesis_waypoint).unwrap();
assert!(ret.is_some());

let mempool = MockSharedMempool::new_in_runtime(&db_rw, VMValidator::new(db.clone()));
let mempool = MockSharedMempool::new_in_runtime(&db_rw, PooledVMValidator::new(db.clone(), 1));

node_config
.storage
Expand Down
1 change: 1 addition & 0 deletions aptos-move/aptos-debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ aptos-rest-client = { workspace = true }
aptos-types = { workspace = true }
aptos-validator-interface = { workspace = true }
aptos-vm = { workspace = true }
aptos-vm-environment = { workspace = true }
aptos-vm-logging = { workspace = true }
aptos-vm-types = { workspace = true }
bcs = { workspace = true }
Expand Down
8 changes: 6 additions & 2 deletions aptos-move/aptos-debugger/src/aptos_debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ use aptos_vm::{
data_cache::AsMoveResolver,
AptosVM,
};
use aptos_vm_environment::environment::AptosEnvironment;
use aptos_vm_logging::log_schema::AdapterLogSchema;
use aptos_vm_types::output::VMOutput;
use aptos_vm_types::{module_and_script_storage::AsAptosCodeStorage, output::VMOutput};
use itertools::Itertools;
use std::{path::Path, sync::Arc, time::Instant};

Expand Down Expand Up @@ -119,11 +120,14 @@ impl AptosDebugger {
bail!("Module bundle payload has been removed")
}

let vm = AptosVM::new(&state_view);
let env = AptosEnvironment::new(&state_view);
let vm = AptosVM::new(env.clone(), &state_view);
let resolver = state_view.as_move_resolver();
let code_storage = state_view.as_aptos_code_storage(env);

let (status, output, gas_profiler) = vm.execute_user_transaction_with_modified_gas_meter(
&resolver,
&code_storage,
&txn,
&log_context,
|gas_meter| {
Expand Down
4 changes: 3 additions & 1 deletion aptos-move/aptos-gas-meter/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use aptos_types::{
};
use aptos_vm_types::{
change_set::ChangeSetInterface,
module_and_script_storage::module_storage::AptosModuleStorage,
resolver::ExecutorView,
storage::{
io_pricing::IoPricing,
Expand Down Expand Up @@ -144,6 +145,7 @@ pub trait AptosGasMeter: MoveGasMeter {
txn_size: NumBytes,
gas_unit_price: FeePerGasUnit,
executor_view: &dyn ExecutorView,
module_storage: &impl AptosModuleStorage,
) -> VMResult<Fee> {
// The new storage fee are only active since version 7.
if self.feature_version() < 7 {
Expand All @@ -163,7 +165,7 @@ pub trait AptosGasMeter: MoveGasMeter {
// Write set
let mut write_fee = Fee::new(0);
let mut total_refund = Fee::new(0);
for res in change_set.write_op_info_iter_mut(executor_view) {
for res in change_set.write_op_info_iter_mut(executor_view, module_storage) {
let ChargeAndRefund { charge, refund } = pricing.charge_refund_write_op(
params,
res.map_err(|err| err.finish(Location::Undefined))?,
Expand Down
Loading

0 comments on commit 751c9a3

Please sign in to comment.