Skip to content

Commit

Permalink
refactor a bit (#7918)
Browse files Browse the repository at this point in the history
* refactor a bit

* remove arc from VM

* Fix is_resource_group

* fix build error

* temp

* tmp

* refactor

* add utils

* remove generic type params

* remove unused

* revert

* fmt

* Add new macro

* undo changes

* improve map_err

* remove map_err
  • Loading branch information
gerben-stavenga authored May 2, 2023
1 parent d4b0c62 commit 41cf471
Show file tree
Hide file tree
Showing 21 changed files with 378 additions and 408 deletions.
5 changes: 5 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ members = [
"aptos-move/vm-genesis",
"aptos-move/writeset-transaction-generator",
"aptos-node",
"aptos-utils",
"config",
"config/global-constants",
"consensus",
Expand Down Expand Up @@ -358,6 +359,7 @@ aptos-transaction-emitter-lib = { path = "crates/transaction-emitter-lib" }
aptos-transaction-generator-lib = { path = "crates/transaction-generator-lib" }
aptos-transactional-test-harness = { path = "aptos-move/aptos-transactional-test-harness" }
aptos-types = { path = "types" }
aptos-utils = { path = "aptos-utils" }
aptos-validator-interface = { path = "aptos-move/aptos-validator-interface" }
aptos-vault-client = { path = "secure/storage/vault" }
aptos-vm = { path = "aptos-move/aptos-vm" }
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-debugger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl AptosDebugger {

pub fn run_session_at_version<F>(&self, version: Version, f: F) -> Result<ChangeSet>
where
F: FnOnce(&mut SessionExt<StorageAdapter<DebuggerStateView>>) -> VMResult<()>,
F: FnOnce(&mut SessionExt) -> VMResult<()>,
{
let state_view = DebuggerStateView::new(self.debugger.clone(), version);
let state_view_storage = StorageAdapter::new(&state_view);
Expand Down
1 change: 1 addition & 0 deletions aptos-move/aptos-vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ aptos-move-stdlib = { workspace = true }
aptos-mvhashmap = { workspace = true }
aptos-state-view = { workspace = true }
aptos-types = { workspace = true }
aptos-utils = { workspace = true }
aptos-vm-logging = { workspace = true }
bcs = { workspace = true }
dashmap = { workspace = true }
Expand Down
24 changes: 12 additions & 12 deletions aptos-move/aptos-vm/src/adapter_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ use aptos_vm_logging::log_schema::AdapterLogSchema;

/// This trait describes the VM adapter's interface.
/// TODO: bring more of the execution logic in aptos_vm into this file.
pub trait VMAdapter {
pub(crate) trait VMAdapter {
/// Creates a new Session backed by the given storage.
/// TODO: this doesn't belong in this trait. We should be able to remove
/// this after redesigning cache ownership model.
fn new_session<'r, R: MoveResolverExt>(
fn new_session<'r>(
&self,
remote: &'r R,
remote: &'r impl MoveResolverExt,
session_id: SessionId,
) -> SessionExt<'r, '_, R>;
) -> SessionExt<'r, '_>;

/// Checks the signature of the given signed transaction and returns
/// `Ok(SignatureCheckedTransaction)` if the signature is valid.
Expand All @@ -36,10 +36,10 @@ pub trait VMAdapter {
fn check_transaction_format(&self, txn: &SignedTransaction) -> Result<(), VMStatus>;

/// Runs the prologue for the given transaction.
fn run_prologue<S: MoveResolverExt, SS: MoveResolverExt>(
fn run_prologue(
&self,
session: &mut SessionExt<SS>,
storage: &S,
session: &mut SessionExt,
storage: &impl MoveResolverExt,
transaction: &SignatureCheckedTransaction,
log_context: &AdapterLogSchema,
) -> Result<(), VMStatus>;
Expand All @@ -48,17 +48,17 @@ pub trait VMAdapter {
fn should_restart_execution(output: &TransactionOutput) -> bool;

/// Execute a single transaction.
fn execute_single_transaction<S: MoveResolverExt>(
fn execute_single_transaction(
&self,
txn: &PreprocessedTransaction,
data_cache: &S,
data_cache: &impl MoveResolverExt,
log_context: &AdapterLogSchema,
) -> Result<(VMStatus, TransactionOutputExt, Option<String>), VMStatus>;

fn validate_signature_checked_transaction<S: MoveResolverExt, SS: MoveResolverExt>(
fn validate_signature_checked_transaction(
&self,
session: &mut SessionExt<SS>,
storage: &S,
session: &mut SessionExt,
storage: &impl MoveResolverExt,
transaction: &SignatureCheckedTransaction,
allow_too_new: bool,
log_context: &AdapterLogSchema,
Expand Down
Loading

0 comments on commit 41cf471

Please sign in to comment.