Skip to content

Commit

Permalink
Minor aggregator cleanup (#12013)
Browse files Browse the repository at this point in the history
* Minor aggregator cleanup

* Addressing PR comments
  • Loading branch information
vusirikala authored Feb 20, 2024
1 parent 6b3219e commit 67f372a
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 43 deletions.
24 changes: 13 additions & 11 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion aptos-move/aptos-aggregator/src/delayed_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ impl<I: Copy + Clone> DelayedApplyEntry<I> {
#[cfg(test)]
mod test {
use super::*;
use crate::{bounded_math::SignedU128, types::DelayedFieldID};
use crate::bounded_math::SignedU128;
use claims::{assert_err, assert_ok};
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use DelayedApplyChange::*;
use DelayedChange::*;
use DelayedFieldValue::*;
Expand Down
5 changes: 3 additions & 2 deletions aptos-move/aptos-aggregator/src/delayed_field_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ use crate::{
delta_change_set::DeltaWithMax,
resolver::DelayedFieldResolver,
types::{
code_invariant_error, expect_ok, DelayedFieldID, DelayedFieldValue,
DelayedFieldsSpeculativeError, PanicOr, ReadPosition,
code_invariant_error, expect_ok, DelayedFieldValue, DelayedFieldsSpeculativeError, PanicOr,
ReadPosition,
},
};
use aptos_types::delayed_fields::{
calculate_width_for_constant_string, calculate_width_for_integer_embedded_string,
SnapshotToStringFormula,
};
use move_binary_format::errors::PartialVMResult;
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use std::collections::{btree_map::Entry, BTreeMap};

fn get_delayed_field_value_from_storage(
Expand Down
3 changes: 2 additions & 1 deletion aptos-move/aptos-aggregator/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
bounded_math::SignedU128,
delta_change_set::{serialize, DeltaOp},
types::{
code_invariant_error, DelayedFieldID, DelayedFieldValue, DelayedFieldsSpeculativeError,
code_invariant_error, DelayedFieldValue, DelayedFieldsSpeculativeError,
DeltaApplicationFailureReason, PanicOr,
},
};
Expand All @@ -21,6 +21,7 @@ use aptos_types::{
};
use move_binary_format::errors::{PartialVMError, PartialVMResult};
use move_core_types::{language_storage::StructTag, value::MoveTypeLayout, vm_status::StatusCode};
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use std::{
collections::{BTreeMap, HashSet},
fmt::Debug,
Expand Down
5 changes: 2 additions & 3 deletions aptos-move/aptos-aggregator/src/tests/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use crate::{
delta_change_set::serialize,
resolver::{TAggregatorV1View, TDelayedFieldView},
types::{
code_invariant_error, expect_ok, DelayedFieldID, DelayedFieldValue,
DelayedFieldsSpeculativeError, PanicOr,
code_invariant_error, expect_ok, DelayedFieldValue, DelayedFieldsSpeculativeError, PanicOr,
},
};
use aptos_types::{
Expand All @@ -20,7 +19,7 @@ use aptos_types::{
};
use move_binary_format::errors::PartialVMResult;
use move_core_types::{language_storage::StructTag, value::MoveTypeLayout};
use move_vm_types::delayed_values::delayed_field_id::ExtractUniqueIndex;
use move_vm_types::delayed_values::delayed_field_id::{DelayedFieldID, ExtractUniqueIndex};
use std::{
cell::RefCell,
collections::{BTreeMap, HashMap, HashSet},
Expand Down
6 changes: 2 additions & 4 deletions aptos-move/aptos-aggregator/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@

use crate::bounded_math::SignedU128;
use aptos_logger::error;
// TODO[agg_v2](cleanup): After aggregators_v2 branch land, consolidate these, instead of using alias here
pub use aptos_types::delayed_fields::PanicError;
use aptos_types::delayed_fields::PanicError;
use move_binary_format::errors::PartialVMError;
use move_core_types::{
value::{IdentifierMappingKind, MoveTypeLayout},
vm_status::StatusCode,
};
pub use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use move_vm_types::{
delayed_values::{
delayed_field_id::TryFromMoveValue,
delayed_field_id::{DelayedFieldID, TryFromMoveValue},
derived_string_snapshot::{
bytes_and_width_to_derived_string_struct, derived_string_struct_to_bytes_and_length,
is_derived_string_struct_layout,
Expand Down
1 change: 1 addition & 0 deletions aptos-move/aptos-vm-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ claims = { workspace = true }
either = { workspace = true }
move-binary-format = { workspace = true }
move-core-types = { workspace = true }
move-vm-types = { workspace = true }
rand = { workspace = true }
serde = { workspace = true }

Expand Down
3 changes: 2 additions & 1 deletion aptos-move/aptos-vm-types/src/change_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use aptos_aggregator::{
delayed_change::DelayedChange,
delta_change_set::{serialize, DeltaOp},
resolver::AggregatorV1Resolver,
types::{code_invariant_error, DelayedFieldID},
types::code_invariant_error,
};
use aptos_types::{
contract_event::ContractEvent,
Expand All @@ -34,6 +34,7 @@ use move_core_types::{
value::MoveTypeLayout,
vm_status::StatusCode,
};
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use rand::Rng;
use std::{
collections::{
Expand Down
6 changes: 2 additions & 4 deletions aptos-move/aptos-vm-types/src/resolver.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

use aptos_aggregator::{
resolver::{TAggregatorV1View, TDelayedFieldView},
types::DelayedFieldID,
};
use aptos_aggregator::resolver::{TAggregatorV1View, TDelayedFieldView};
use aptos_types::{
serde_helper::bcs_utils::size_u32_as_uleb128,
state_store::{
Expand All @@ -19,6 +16,7 @@ use aptos_types::{
use bytes::Bytes;
use move_binary_format::errors::{PartialVMError, PartialVMResult};
use move_core_types::{language_storage::StructTag, value::MoveTypeLayout, vm_status::StatusCode};
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use std::collections::{BTreeMap, HashMap};

/// Allows to query resources from the state.
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-vm-types/src/tests/test_change_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use aptos_aggregator::{
bounded_math::SignedU128,
delayed_change::{DelayedApplyChange, DelayedChange},
delta_change_set::DeltaWithMax,
types::DelayedFieldID,
};
use aptos_types::{
access_path::AccessPath,
Expand All @@ -34,6 +33,7 @@ use move_core_types::{
value::MoveTypeLayout,
vm_status::StatusCode,
};
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use std::{collections::BTreeMap, sync::Arc};

/// Testcases:
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-vm-types/src/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::{
use aptos_aggregator::{
delayed_change::DelayedChange,
delta_change_set::{delta_add, DeltaOp},
types::DelayedFieldID,
};
use aptos_types::{
account_address::AccountAddress,
Expand All @@ -26,6 +25,7 @@ use move_core_types::{
language_storage::{StructTag, TypeTag},
value::MoveTypeLayout,
};
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use std::{collections::BTreeMap, sync::Arc};

pub(crate) struct MockChangeSetChecker;
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-vm/src/block_executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::{
};
use aptos_aggregator::{
delayed_change::DelayedChange, delta_change_set::DeltaOp, resolver::TAggregatorV1View,
types::DelayedFieldID,
};
use aptos_block_executor::{
errors::BlockExecutionError, executor::BlockExecutor,
Expand Down Expand Up @@ -38,6 +37,7 @@ use move_core_types::{
value::MoveTypeLayout,
vm_status::{StatusCode, VMStatus},
};
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use once_cell::sync::OnceCell;
use rayon::ThreadPool;
use std::{
Expand Down
3 changes: 2 additions & 1 deletion aptos-move/aptos-vm/src/data_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
use aptos_aggregator::{
bounded_math::SignedU128,
resolver::{TAggregatorV1View, TDelayedFieldView},
types::{DelayedFieldID, DelayedFieldValue, DelayedFieldsSpeculativeError, PanicOr},
types::{DelayedFieldValue, DelayedFieldsSpeculativeError, PanicOr},
};
use aptos_table_natives::{TableHandle, TableResolver};
use aptos_types::{
Expand Down Expand Up @@ -43,6 +43,7 @@ use move_core_types::{
resolver::{resource_size, ModuleResolver, ResourceResolver},
value::MoveTypeLayout,
};
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use std::{
cell::RefCell,
collections::{BTreeMap, HashMap, HashSet},
Expand Down
4 changes: 2 additions & 2 deletions aptos-move/aptos-vm/src/move_vm_ext/respawned_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use aptos_aggregator::{
delta_change_set::DeltaWithMax,
resolver::{TAggregatorV1View, TDelayedFieldView},
types::{
code_invariant_error, expect_ok, DelayedFieldID, DelayedFieldValue,
DelayedFieldsSpeculativeError, PanicOr,
code_invariant_error, expect_ok, DelayedFieldValue, DelayedFieldsSpeculativeError, PanicOr,
},
};
use aptos_gas_algebra::Fee;
Expand Down Expand Up @@ -44,6 +43,7 @@ use move_core_types::{
value::MoveTypeLayout,
vm_status::{err_msg, StatusCode, VMStatus},
};
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use std::{
collections::{BTreeMap, HashMap, HashSet},
sync::Arc,
Expand Down
7 changes: 3 additions & 4 deletions aptos-move/aptos-vm/src/natives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ use aptos_aggregator::{
types::{DelayedFieldsSpeculativeError, PanicOr},
};
#[cfg(feature = "testing")]
use aptos_aggregator::{
resolver::TDelayedFieldView,
types::{DelayedFieldID, DelayedFieldValue},
};
use aptos_aggregator::{resolver::TDelayedFieldView, types::DelayedFieldValue};
#[cfg(feature = "testing")]
use aptos_framework::natives::{cryptography::algebra::AlgebraContext, event::NativeEventContext};
use aptos_gas_schedule::{MiscGasParameters, NativeGasParameters, LATEST_GAS_FEATURE_VERSION};
Expand Down Expand Up @@ -41,6 +38,8 @@ use move_binary_format::errors::PartialVMResult;
use move_core_types::{language_storage::StructTag, value::MoveTypeLayout};
use move_vm_runtime::native_functions::NativeFunctionTable;
#[cfg(feature = "testing")]
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
#[cfg(feature = "testing")]
use std::{
collections::{BTreeMap, HashSet},
sync::Arc,
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/block-executor/src/captured_reads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,9 +756,9 @@ impl<T: Transaction> UnsyncReadSet<T> {
mod test {
use super::*;
use crate::proptest_types::types::{raw_metadata, KeyType, MockEvent, ValueType};
use aptos_aggregator::types::DelayedFieldID;
use aptos_mvhashmap::types::StorageVersion;
use claims::{assert_err, assert_gt, assert_matches, assert_none, assert_ok, assert_some_eq};
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use test_case::test_case;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/block-executor/src/proptest_types/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use aptos_aggregator::{
delayed_change::DelayedChange,
delta_change_set::{delta_add, delta_sub, serialize, DeltaOp},
resolver::TAggregatorV1View,
types::DelayedFieldID,
};
use aptos_mvhashmap::types::TxnIndex;
use aptos_types::{
Expand All @@ -34,6 +33,7 @@ use aptos_vm_types::resolver::{TExecutorView, TResourceGroupView};
use bytes::Bytes;
use claims::{assert_ge, assert_le, assert_ok};
use move_core_types::value::MoveTypeLayout;
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use once_cell::sync::OnceCell;
use proptest::{arbitrary::Arbitrary, collection::vec, prelude::*, proptest, sample::Index};
use proptest_derive::Arbitrary;
Expand Down
3 changes: 2 additions & 1 deletion aptos-move/block-executor/src/value_exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
use crate::view::{LatestView, ViewState};
use aptos_aggregator::{
resolver::TDelayedFieldView,
types::{code_invariant_error, DelayedFieldValue, PanicError, ReadPosition},
types::{code_invariant_error, DelayedFieldValue, ReadPosition},
};
use aptos_mvhashmap::{types::TxnIndex, versioned_delayed_fields::TVersionedDelayedFieldView};
use aptos_types::{
delayed_fields::PanicError,
executable::Executable,
state_store::{state_value::StateValueMetadata, TStateView},
transaction::BlockExecutableTransaction as Transaction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use aptos_aggregator::{
delayed_field_extension::DelayedFieldData,
delta_change_set::DeltaOp,
resolver::{AggregatorV1Resolver, DelayedFieldResolver},
types::DelayedFieldID,
};
use aptos_types::{
delayed_fields::PanicError,
state_store::{state_key::StateKey, state_value::StateValueMetadata},
};
use better_any::{Tid, TidAble};
use move_core_types::value::MoveTypeLayout;
use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use std::{
cell::RefCell,
collections::{BTreeMap, HashSet},
Expand Down
Loading

0 comments on commit 67f372a

Please sign in to comment.