Skip to content

Commit

Permalink
mock fix starcoin-executors errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg committed Oct 15, 2024
1 parent 2f3497c commit a398eeb
Show file tree
Hide file tree
Showing 19 changed files with 474 additions and 36 deletions.
47 changes: 45 additions & 2 deletions Cargo.lock

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

13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ members = [
"chain",
"chain/api",
"chain/open-block",
"chain/force-upgrade",
"vm/force-upgrade",
"chain/mock",
"chain/chain-notify",
"chain/service",
Expand Down Expand Up @@ -70,6 +70,7 @@ members = [
"rpc/client",
"rpc/server",
"vm/types",
"vm/vm-runtime-mock",
"vm/vm-runtime-types",
"vm/vm-runtime",
"vm/frameworks",
Expand Down Expand Up @@ -164,7 +165,7 @@ default-members = [
"chain",
"chain/api",
"chain/open-block",
"chain/force-upgrade",
"vm/force-upgrade",
"chain/mock",
"chain/chain-notify",
"chain/service",
Expand Down Expand Up @@ -192,6 +193,7 @@ default-members = [
"rpc/client",
"rpc/server",
"vm/types",
"vm/vm-runtime-mock",
"vm/vm-runtime-types",
"vm/vm-runtime",
"vm/framework",
Expand Down Expand Up @@ -481,7 +483,7 @@ rustyline-derive = "0.6.0"
sc-peerset = { path = "network-p2p/peerset" }
schemars = { git = "https://github.com/starcoinorg/schemars", rev = "9b3705780b8fe9c8676ff82919869ba7405b1062" }
scmd = { path = "commons/scmd" }
serde = { version = "1.0.130", features = ["derive"] }
serde = { version = "1.0.130", features = ["derive"] }
serde-generate = { git = "https://github.com/starcoinorg/serde-reflection", rev = "eb95fd4e3b67e08d71432b522c53833a0b855d80" }
serde-helpers = { path = "commons/serde-helpers" }
serde-reflection = { git = "https://github.com/starcoinorg/serde-reflection", rev = "eb95fd4e3b67e08d71432b522c53833a0b855d80" }
Expand Down Expand Up @@ -523,7 +525,7 @@ starcoin-crypto = { git = "https://github.com/starcoinorg/starcoin-crypto", rev
starcoin-decrypt = { path = "commons/decrypt" }
starcoin-dev = { path = "vm/dev" }
starcoin-executor = { path = "executor" }
starcoin-framework-legacy = { git = "https://github.com/starcoinorg/starcoin-framework", rev = "94bcd77e80232b169cf95754ef4e87775645afcd" , package = "starcoin-framework" }
starcoin-framework-legacy = { git = "https://github.com/starcoinorg/starcoin-framework", rev = "94bcd77e80232b169cf95754ef4e87775645afcd", package = "starcoin-framework" }
starcoin-framework = { path = "vm/framework" }
starcoin-sdk-builder = { path = "vm/starcoin-sdk-builder" }
starcoin-genesis = { path = "genesis" }
Expand All @@ -546,7 +548,7 @@ starcoin-network-rpc-api = { path = "network-rpc/api" }
starcoin-node = { path = "node" }
starcoin-node-api = { path = "node/api" }
starcoin-open-block = { path = "chain/open-block" }
starcoin-force-upgrade = { path = "chain/force-upgrade" }
starcoin-force-upgrade = { path = "vm/force-upgrade" }
starcoin-resource-viewer = { path = "vm/resource-viewer" }
starcoin-package-builder = { path = "vm/package-builder" }
starcoin-move-stdlib = { path = "vm/framework/move-stdlib" }
Expand Down Expand Up @@ -576,6 +578,7 @@ starcoin-txpool-mock-service = { path = "txpool/mock-service" }
starcoin-types = { path = "types" }
starcoin-uint = { path = "types/uint" }
starcoin-vm-runtime = { path = "vm/vm-runtime" }
starcoin-vm-runtime-mock = { path = "vm/vm-runtime-mock" }
starcoin-vm-runtime-types = { path = "vm/vm-runtime-types" }
starcoin-vm-types = { path = "vm/types" }
stdlib = { path = "vm/stdlib" }
Expand Down
8 changes: 5 additions & 3 deletions chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ proptest-derive = { workspace = true }
starcoin-account-api = { workspace = true }
starcoin-chain-mock = { workspace = true }
starcoin-genesis = { workspace = true }
starcoin-metrics = { workspace = true }
starcoin-resource-viewer = { workspace = true }
starcoin-transaction-builder = { workspace = true }
starcoin-types = { features = ["fuzzing"], workspace = true }
starcoin-vm-runtime = { workspace = true }
starcoin-vm-runtime-mock = { workspace = true }
stdlib = { workspace = true }
stest = { workspace = true }
test-helper = { workspace = true }
Expand All @@ -49,9 +50,10 @@ starcoin-network-rpc-api = { workspace = true }
starcoin-force-upgrade = { workspace = true }

[features]
default = []
default = ["metrics"]
metrics = ["starcoin-metrics/metrics"]
fuzzing = ["proptest", "proptest-derive", "starcoin-types/fuzzing"]
force-deploy = ["starcoin-vm-runtime/force-deploy", "starcoin-vm-runtime", "starcoin-executor/force-deploy"]
force-deploy = []

[package]
authors = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions chain/open-block/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ parking_lot = { workspace = true }
starcoin-accumulator = { workspace = true }
starcoin-chain-api = { workspace = true }
starcoin-executor = { workspace = true }
starcoin-metrics = { workspace = true }
starcoin-state-api = { workspace = true }
starcoin-statedb = { workspace = true }
starcoin-storage = { workspace = true }
starcoin-types = { workspace = true }
starcoin-vm-types = { workspace = true }
starcoin-vm-runtime = { workspace = true }
starcoin-force-upgrade = { workspace = true }

[dev-dependencies]
Expand All @@ -30,4 +30,4 @@ publish = { workspace = true }
version = "2.0.1"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
rust-version = { workspace = true }
9 changes: 5 additions & 4 deletions chain/open-block/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::{bail, format_err, Result};
use starcoin_accumulator::{node::AccumulatorStoreType, Accumulator, MerkleAccumulator};
use starcoin_chain_api::ExcludedTxns;
use starcoin_crypto::HashValue;
use starcoin_executor::{execute_block_transactions, execute_transactions, VMMetrics};
use starcoin_executor::{execute_block_transactions, execute_transactions};
use starcoin_logger::prelude::*;
use starcoin_state_api::{ChainStateReader, ChainStateWriter};
use starcoin_statedb::ChainStateDB;
Expand All @@ -25,13 +25,14 @@ use starcoin_types::{
};
use std::{convert::TryInto, sync::Arc};

use starcoin_metrics::metrics::VMMetrics;
#[cfg(feature = "force-deploy")]
use {
starcoin_force_upgrade::ForceUpgrade,
starcoin_types::{account::DEFAULT_EXPIRATION_TIME, identifier::Identifier},
starcoin_vm_runtime::force_upgrade_management::{
starcoin_force_upgrade::force_upgrade_management::{
get_force_upgrade_account, get_force_upgrade_block_number,
},
starcoin_force_upgrade::ForceUpgrade,
starcoin_types::{account::DEFAULT_EXPIRATION_TIME, identifier::Identifier},
starcoin_vm_types::{
access_path::AccessPath,
account_config::{genesis_address, ModuleUpgradeStrategy},
Expand Down
2 changes: 1 addition & 1 deletion chain/service/src/chain_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use starcoin_dag::blockdag::BlockDAG;
use starcoin_dag::consensusdb::consenses_state::DagStateView;
use starcoin_dag::types::ghostdata::GhostdagData;
use starcoin_logger::prelude::*;
use starcoin_metrics::metrics::VMMetrics;
use starcoin_service_registry::{
ActorService, EventHandler, ServiceContext, ServiceFactory, ServiceHandler,
};
Expand All @@ -28,7 +29,6 @@ use starcoin_types::{
startup_info::StartupInfo,
transaction::Transaction,
};
use starcoin_vm_runtime::metrics::VMMetrics;
use starcoin_vm_types::access_path::AccessPath;
use std::sync::Arc;

Expand Down
6 changes: 1 addition & 5 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ use starcoin_types::{
transaction::{SignedUserTransaction, Transaction},
U256,
};
#[cfg(feature = "force-deploy")]
use starcoin_vm_runtime::force_upgrade_management::get_force_upgrade_block_number;
use starcoin_vm_types::access_path::AccessPath;
use starcoin_vm_types::account_config::genesis_address;
use starcoin_vm_types::genesis_config::{ChainId, ConsensusStrategy};
Expand Down Expand Up @@ -2389,7 +2387,5 @@ pub(crate) fn info_2_accumulator(

fn get_epoch_from_statedb(statedb: &ChainStateDB) -> Result<Epoch> {
let account_reader = AccountStateReader::new(statedb);
account_reader
.get_resource::<Epoch>(genesis_address())?
.ok_or_else(|| format_err!("Epoch is none."))
account_reader.get_resource::<Epoch>(genesis_address())
}
4 changes: 2 additions & 2 deletions commons/metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ pub fn get_metric_from_registry(
})
}

#[cfg(test)]
mod tests;
#[cfg(feature = "metrics")]
pub mod metrics;
#[cfg(test)]
mod tests;
6 changes: 3 additions & 3 deletions executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ anyhow = { workspace = true }
log = { workspace = true }
starcoin-logger = { workspace = true }
starcoin-crypto = { workspace = true }
starcoin-metrics = { workspace = true }
starcoin-state-api = { workspace = true }
starcoin-types = { workspace = true }
starcoin-vm-types = { workspace = true }
starcoin-vm-runtime = { workspace = true }
starcoin-vm-runtime-mock = { workspace = true }
starcoin-statedb = { workspace = true }
starcoin-force-upgrade = { workspace = true }
serde = { workspace = true }
Expand All @@ -27,7 +28,6 @@ starcoin-resource-viewer = { workspace = true }
starcoin-transaction-builder = { workspace = true }
starcoin-state-tree = { workspace = true }
starcoin-statedb = { workspace = true }
starcoin-vm-runtime = { workspace = true }
starcoin-force-upgrade = { workspace = true }
stdlib = { workspace = true }
stest = { workspace = true }
Expand All @@ -38,7 +38,7 @@ move-transactional-test-runner = { workspace = true }
[features]
default = []
fuzzing = ["starcoin-types/fuzzing"]
force-deploy = ["starcoin-vm-runtime/force-deploy"]
force-deploy = []

[package]
authors = { workspace = true }
Expand Down
8 changes: 4 additions & 4 deletions executor/src/block_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ use starcoin_types::error::BlockExecutorError;
use starcoin_types::error::ExecutorResult;
use starcoin_types::transaction::TransactionStatus;
use starcoin_types::transaction::{Transaction, TransactionInfo};
use starcoin_vm_runtime::metrics::VMMetrics;
use starcoin_vm_types::contract_event::ContractEvent;
use starcoin_vm_types::state_store::table::{TableHandle, TableInfo};
use starcoin_vm_types::write_set::WriteSet;
use std::collections::BTreeMap;

use starcoin_metrics::metrics::VMMetrics;
#[cfg(feature = "force-deploy")]
use {
crate::execute_transactions,
anyhow::bail,
log::info,
starcoin_force_upgrade::force_upgrade_management::{
get_force_upgrade_account, get_force_upgrade_block_number,
},
starcoin_force_upgrade::ForceUpgrade,
starcoin_types::account::DEFAULT_EXPIRATION_TIME,
starcoin_types::identifier::Identifier,
starcoin_vm_runtime::force_upgrade_management::{
get_force_upgrade_account, get_force_upgrade_block_number,
},
starcoin_vm_types::{
access_path::AccessPath,
account_config::{genesis_address, ModuleUpgradeStrategy},
Expand Down
6 changes: 4 additions & 2 deletions executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
// SPDX-License-Identifier: Apache-2.0

use anyhow::Result;
pub use starcoin_metrics::metrics::VMMetrics;
use starcoin_types::transaction::{SignedUserTransaction, Transaction, TransactionOutput};
use starcoin_vm_runtime::{metrics::VMMetrics, starcoin_vm::StarcoinVM, VMExecutor};
use starcoin_vm_runtime_mock::{starcoin_vm::StarcoinVM, VMExecutor};
use starcoin_vm_types::state_store::StateView;
use starcoin_vm_types::{
identifier::Identifier,
language_storage::{ModuleId, TypeTag},
{state_view::StateView, vm_status::VMStatus},
vm_status::VMStatus,
};

pub fn execute_transactions<S: StateView>(
Expand Down
1 change: 0 additions & 1 deletion executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub use executor::*;
// encode_transfer_script_function, peer_to_peer_txn_sent_as_association, DEFAULT_EXPIRATION_TIME,
// DEFAULT_MAX_GAS_AMOUNT,
// };
pub use starcoin_vm_runtime::metrics::VMMetrics;

mod block_executor;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ use starcoin_vm_types::{
};
use stdlib::COMPILED_MOVE_CODE_DIR;

#[cfg(feature = "force-deploy")]
pub mod force_upgrade_management;

pub struct ForceUpgrade;

impl ForceUpgrade {
Expand Down
Loading

0 comments on commit a398eeb

Please sign in to comment.