From fdae84215a191625803af02a82ec9942d3f6bc24 Mon Sep 17 00:00:00 2001 From: simonjiao Date: Mon, 23 Sep 2024 17:37:57 +0800 Subject: [PATCH] fix starcoin abi & aggregator (#4204) revert update on StateView --- abi/decoder/src/lib.rs | 2 +- abi/resolver/src/lib.rs | 2 +- vm/resource-viewer/src/lib.rs | 12 +++++++----- vm/resource-viewer/src/resolver.rs | 3 +-- vm/starcoin-aggregator/src/resolver.rs | 2 +- vm/types/src/on_chain_config/mod.rs | 2 +- vm/types/src/state_store/mod.rs | 5 ++++- vm/types/src/state_view.rs | 6 +----- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/abi/decoder/src/lib.rs b/abi/decoder/src/lib.rs index 8b9a5a3155..0651998a0b 100644 --- a/abi/decoder/src/lib.rs +++ b/abi/decoder/src/lib.rs @@ -12,7 +12,7 @@ use starcoin_resource_viewer::{AnnotatedMoveStruct, AnnotatedMoveValue}; use starcoin_vm_types::account_address::AccountAddress; use starcoin_vm_types::identifier::Identifier; use starcoin_vm_types::language_storage::{ModuleId, TypeTag}; -use starcoin_vm_types::state_view::StateView; +use starcoin_vm_types::state_store::StateView; use starcoin_vm_types::transaction::{Module, Package, Script, ScriptFunction, TransactionPayload}; #[derive(Clone, Debug, Eq, PartialEq)] pub enum DecodedTransactionPayload { diff --git a/abi/resolver/src/lib.rs b/abi/resolver/src/lib.rs index 033c1b9c73..af328230c9 100644 --- a/abi/resolver/src/lib.rs +++ b/abi/resolver/src/lib.rs @@ -17,7 +17,7 @@ use starcoin_vm_types::file_format::{ use starcoin_vm_types::identifier::{IdentStr, Identifier}; use starcoin_vm_types::language_storage::{ModuleId, StructTag, TypeTag}; use starcoin_vm_types::normalized::{Function, Module, Struct, Type}; -use starcoin_vm_types::state_view::StateView; +use starcoin_vm_types::state_store::StateView; #[allow(clippy::upper_case_acronyms)] pub struct ABIResolver<'a> { diff --git a/vm/resource-viewer/src/lib.rs b/vm/resource-viewer/src/lib.rs index 7c6d00b72e..c0b801b44f 100644 --- a/vm/resource-viewer/src/lib.rs +++ b/vm/resource-viewer/src/lib.rs @@ -12,9 +12,9 @@ use anyhow::{anyhow, Result}; use move_core_types::u256; use starcoin_vm_types::language_storage::TypeTag; use starcoin_vm_types::state_store::state_key::StateKey; +use starcoin_vm_types::state_store::state_storage_usage::StateStorageUsage; use starcoin_vm_types::state_store::state_value::StateValue; -use starcoin_vm_types::state_store::TStateView; -use starcoin_vm_types::state_view::StateView; +use starcoin_vm_types::state_store::{StateView, TStateView}; use starcoin_vm_types::value::MoveTypeLayout; use starcoin_vm_types::{ account_address::AccountAddress, @@ -30,7 +30,6 @@ use std::{ convert::TryInto, fmt::{Display, Formatter}, }; -use starcoin_vm_types::state_store::state_storage_usage::StateStorageUsage; mod fat_type; pub mod module_cache; @@ -318,11 +317,14 @@ pub struct NullStateView; impl TStateView for NullStateView { type Key = StateKey; - fn get_state_value(&self, _state_key: &StateKey) -> starcoin_vm_types::state_store::Result> { + fn get_state_value( + &self, + _state_key: &StateKey, + ) -> starcoin_vm_types::state_store::Result> { Ok(None) } fn get_usage(&self) -> starcoin_vm_types::state_store::Result { - unimplemented!() + unimplemented!("get_usage not implemented for NullStateView") } } diff --git a/vm/resource-viewer/src/resolver.rs b/vm/resource-viewer/src/resolver.rs index 21baab51be..a66375b495 100644 --- a/vm/resource-viewer/src/resolver.rs +++ b/vm/resource-viewer/src/resolver.rs @@ -9,7 +9,6 @@ use crate::{ module_cache::ModuleCache, }; use anyhow::{anyhow, Result}; -use starcoin_vm_types::state_store::state_key::StateKey; use starcoin_vm_types::{ access::ModuleAccess, account_address::AccountAddress, @@ -20,7 +19,7 @@ use starcoin_vm_types::{ }, identifier::{IdentStr, Identifier}, language_storage::{ModuleId, StructTag, TypeTag}, - state_view::StateView, + state_store::{state_key::StateKey, StateView}, }; use std::rc::Rc; diff --git a/vm/starcoin-aggregator/src/resolver.rs b/vm/starcoin-aggregator/src/resolver.rs index c6fa4744d1..4bf00e2b57 100644 --- a/vm/starcoin-aggregator/src/resolver.rs +++ b/vm/starcoin-aggregator/src/resolver.rs @@ -19,8 +19,8 @@ use starcoin_vm_types::{ state_store::{ state_key::StateKey, state_value::{StateValue, StateValueMetadata}, + StateView, }, - state_view::StateView, write_set::WriteOp, }; use std::fmt::Debug; diff --git a/vm/types/src/on_chain_config/mod.rs b/vm/types/src/on_chain_config/mod.rs index 7cc0af2317..2aa7a979c5 100644 --- a/vm/types/src/on_chain_config/mod.rs +++ b/vm/types/src/on_chain_config/mod.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use crate::account_config::genesis_address; -use crate::state_view::StateView; +use crate::state_store::StateView; use crate::{ access_path::AccessPath, account_address::AccountAddress, diff --git a/vm/types/src/state_store/mod.rs b/vm/types/src/state_store/mod.rs index 385e6beb1f..8373380a9d 100644 --- a/vm/types/src/state_store/mod.rs +++ b/vm/types/src/state_store/mod.rs @@ -5,7 +5,6 @@ use crate::state_store::{ errors::StateviewError, in_memory_state_view::InMemoryStateView, state_key::StateKey, state_storage_usage::StateStorageUsage, state_value::StateValue, }; -use crate::state_view::StateView; use crate::transaction::Version; use arr_macro::arr; use bytes::Bytes; @@ -50,6 +49,10 @@ pub trait TStateView { } } +pub trait StateView: TStateView {} + +impl> StateView for T {} + #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum StateViewId { // XXX FIXME YSG should remove diff --git a/vm/types/src/state_view.rs b/vm/types/src/state_view.rs index 20ce541ac4..afa9f81c94 100644 --- a/vm/types/src/state_view.rs +++ b/vm/types/src/state_view.rs @@ -9,7 +9,7 @@ //! This crate defines [`trait StateView`](StateView). use crate::state_store::state_key::StateKey; -use crate::state_store::TStateView; +use crate::state_store::StateView; use crate::{ account_config::{ genesis_address, token_code::TokenCode, AccountResource, BalanceResource, TokenInfo, @@ -31,10 +31,6 @@ use move_core_types::{ language_storage::{ModuleId, StructTag}, }; -pub trait StateView: TStateView {} - -impl> StateView for T {} - impl StateReaderExt for T where T: StateView {} pub trait StateReaderExt: StateView {