Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/nkysg/compiler-v2-update' into n…
Browse files Browse the repository at this point in the history
…kysg/compiler-v2-update
  • Loading branch information
welbon committed Nov 7, 2024
2 parents fcc7117 + b6f2eee commit 173f978
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type Bytes = Vec<u8>;
/// pub fn decode(&TransactionPayload) -> Option<EntryFunctionCall> { .. }
/// }
/// ```
#[allow(clippy::large_enum_variant)]
#[derive(Clone, Debug, PartialEq, Eq)]
#[allow(clippy::large_enum_variant)]
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
#[cfg_attr(feature = "fuzzing", proptest(no_params))]
pub enum EntryFunctionCall {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Bytes = Vec<u8>;
/// }
/// ```
#[derive(Clone, Debug, PartialEq, Eq)]
#[allow(clippy::large_enum_variant)]
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
#[cfg_attr(feature = "fuzzing", proptest(no_params))]
pub enum EntryFunctionCall {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Bytes = Vec<u8>;
/// }
/// ```
#[derive(Clone, Debug, PartialEq, Eq)]
#[allow(clippy::large_enum_variant)]
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
#[cfg_attr(feature = "fuzzing", proptest(no_params))]
pub enum EntryFunctionCall {
Expand Down
3 changes: 2 additions & 1 deletion vm/starcoin-sdk-builder/src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ impl EntryFunctionCall {

let custom_derive_block = if self.local_types {
Some(
r#"#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
r#"#[allow(clippy::large_enum_variant)]
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
#[cfg_attr(feature = "fuzzing", proptest(no_params))]"#
.to_string(),
)
Expand Down
15 changes: 8 additions & 7 deletions vm/vm-runtime/src/data_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub struct StorageAdapter<'e, E> {
/// track of incremental changes is vital to the consistency of the data store and the system.
pub struct StateViewCache<'a, S> {
data_view: &'a S,
data_map: BTreeMap<StateKey, Option<Vec<u8>>>,
data_map: BTreeMap<StateKey, Option<StateValue>>,
}

impl<'a, S: StateView> StateViewCache<'a, S> {
Expand All @@ -90,13 +90,14 @@ impl<'a, S: StateView> StateViewCache<'a, S> {
// track of the data as if the changes were applied immediately.
pub(crate) fn push_write_set(&mut self, write_set: &WriteSet) {
for (ap, ref write_op) in write_set.iter() {
// todo: handle WriteOp properly
match write_op {
WriteOp::Creation { data, metadata: _ } => {
self.data_map.insert(ap.clone(), Some(data.to_vec()));
WriteOp::Creation { data, metadata } => {
let value = StateValue::new_with_metadata(data.clone(), metadata.clone());
self.data_map.insert(ap.clone(), Some(value));
}
WriteOp::Modification { data, metadata: _ } => {
self.data_map.insert(ap.clone(), Some(data.to_vec()));
WriteOp::Modification { data, metadata } => {
let value = StateValue::new_with_metadata(data.clone(), metadata.clone());
self.data_map.insert(ap.clone(), Some(value));
}
WriteOp::Deletion { metadata: _ } => {
self.data_map.remove(ap);
Expand All @@ -113,7 +114,7 @@ impl<'block, S: StateView> TStateView for StateViewCache<'block, S> {
// Get some data either through the cache or the `StateView` on a cache miss.
fn get_state_value(&self, state_key: &Self::Key) -> Result<Option<StateValue>, StateviewError> {
match self.data_map.get(state_key) {
Some(opt_data) => Ok(opt_data.clone().map(StateValue::from)),
Some(opt_data) => Ok(opt_data.clone()),
None => match self.data_view.get_state_value(state_key) {
Ok(remote_data) => Ok(remote_data),
// TODO: should we forward some error info?
Expand Down

0 comments on commit 173f978

Please sign in to comment.