Skip to content

Commit

Permalink
[vm-validator] hot fix for vm-validator memory leak (aptos-labs#2193)
Browse files Browse the repository at this point in the history
  • Loading branch information
lightmark authored Jul 25, 2022
1 parent fd60a8b commit 2653c88
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions vm-validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ aptos-vm = { path = "../aptos-move/aptos-vm" }

executor = { path = "../execution/executor" }
executor-types = { path = "../execution/executor-types" }
scratchpad = { path = "../storage/scratchpad" }
storage-interface = { path = "../storage/storage-interface" }

[dev-dependencies]
Expand Down
20 changes: 12 additions & 8 deletions vm-validator/src/vm_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use aptos_types::{
};
use aptos_vm::AptosVM;
use fail::fail_point;
use scratchpad::SparseMerkleTree;
use std::ops::Deref;
use std::sync::Arc;
use storage_interface::no_proof_fetcher::NoProofFetcher;
use storage_interface::{
Expand Down Expand Up @@ -40,14 +42,16 @@ fn latest_state_view(db_reader: &Arc<dyn DbReader>) -> CachedStateView<NoProofFe
.get_latest_executed_trees()
.expect("Should not fail.");

ledger_view
.state_view(
StateViewId::TransactionValidation {
base_version: ledger_view.version().expect("Must be bootstrapped."),
},
db_reader,
)
.expect("failed to get latest state view.")
CachedStateView::new(
StateViewId::TransactionValidation {
base_version: ledger_view.version().expect("Must be bootstrapped."),
},
db_reader.deref(),
ledger_view.txn_accumulator().num_leaves(),
SparseMerkleTree::new(ledger_view.state().current.root_hash()),
NoProofFetcher::new(db_reader.clone()),
)
.expect("failed to get latest state view.")
}

pub struct VMValidator {
Expand Down

0 comments on commit 2653c88

Please sign in to comment.