Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract executor into fuel-core-executor crate #1520

Merged
merged 39 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b5a161b
refactoring
Salka1988 Nov 12, 2023
69f4ba7
refactoring
Salka1988 Nov 13, 2023
8390c4d
remove Database
Salka1988 Nov 16, 2023
d30f94e
refactorings
Salka1988 Nov 16, 2023
ebcec84
refactoring
Salka1988 Nov 17, 2023
8898162
refactoring
Salka1988 Nov 17, 2023
b70c3a3
refactoring
Salka1988 Nov 17, 2023
6f6a1f6
remove VmDatabase
Salka1988 Nov 20, 2023
9a7a8b4
add ExecutorVmDatabase
Salka1988 Nov 20, 2023
6a1d5da
passing Tests
Salka1988 Nov 21, 2023
a455cc6
move VmDatabase
Salka1988 Nov 22, 2023
8612e04
move Executor
Salka1988 Nov 22, 2023
1282b53
use Transactional
Salka1988 Nov 22, 2023
6e42250
fmt
Salka1988 Nov 22, 2023
4439133
move traits
Salka1988 Nov 24, 2023
f40eea5
add database test helper
Salka1988 Nov 25, 2023
7ea648a
Merge branch 'master' into Salka1988/extract_executor
Salka1988 Nov 29, 2023
b6a0f61
merge master
Salka1988 Nov 29, 2023
ce0aade
remove traits
Salka1988 Nov 29, 2023
800150e
fix tests
Salka1988 Nov 29, 2023
fadd115
fix tests
Salka1988 Nov 29, 2023
6015099
clear tests
Salka1988 Nov 29, 2023
2cefee5
clean
Salka1988 Nov 30, 2023
7b5dd75
fix VmDatabase tests
Salka1988 Nov 30, 2023
80a822e
fixmore tests
Salka1988 Nov 30, 2023
6850654
Fix compilation issues
xgreenx Nov 30, 2023
103e80c
add fixes
Salka1988 Dec 1, 2023
b2699a4
add fixes
Salka1988 Dec 1, 2023
545e036
fix fmt
Salka1988 Dec 1, 2023
d697bb0
wasm problem
Salka1988 Dec 1, 2023
95485b4
fmt
Salka1988 Dec 1, 2023
d68e3a2
Fix for WASM compilation
xgreenx Dec 1, 2023
e0b6b35
Merge branch 'master' into Salka1988/extract_executor
xgreenx Dec 3, 2023
f0e9d55
Merge branch 'master' into Salka1988/extract_executor
Salka1988 Dec 4, 2023
aae5524
Move trait implementation in right place
xgreenx Dec 4, 2023
e6e56c1
Merge branch 'master' into Salka1988/extract_executor
xgreenx Dec 4, 2023
8a928fe
Added one more todo.
xgreenx Dec 4, 2023
e4ec72e
Merge remote-tracking branch 'origin/Salka1988/extract_executor' into…
xgreenx Dec 4, 2023
1d4e7f8
Sort imports
xgreenx Dec 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Description of the upcoming release here.
### Changed

- [#1517](https://github.com/FuelLabs/fuel-core/pull/1517): Changed default gossip heartbeat interval to 500ms.
- [#1520](https://github.com/FuelLabs/fuel-core/pull/1520): Extract `executor` into `fuel-core-executor` crate.


## [Version 0.21.0]
Expand Down
9 changes: 7 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ cynic = { version = "2.2.1", features = ["http-reqwest"] }
clap = "4.1"
derive_more = { version = "0.99" }
hyper = { version = "0.14.26" }
primitive-types = "0.12"
primitive-types = { version = "0.12", default-features = false }
rand = "0.8"
parking_lot = "0.12"
tokio = { version = "1.27", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ ed25519-dalek = { version = "2.0", features = ["rand_core"] }
ethnum = "1.3"
fuel-core = { path = "../crates/fuel-core", default-features = false, features = ["rocksdb-production"] }
fuel-core-chain-config = { workspace = true }
fuel-core-database = { path = "./../crates/database" }
fuel-core-services = { path = "./../crates/services" }
fuel-core-storage = { path = "./../crates/storage" }
fuel-core-sync = { path = "./../crates/services/sync", features = ["benchmarking"] }
fuel-core-types = { path = "./../crates/types", features = ["test-helpers"] }
futures = "0.3"
p256 = { version = "0.13", default-features = false, features = ["digest", "ecdsa"] }
primitive-types = { workspace = true }
primitive-types = { workspace = true, default-features = false }
quanta = "0.12"
rand = { workspace = true }
serde = { workspace = true, features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/block_target_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use fuel_core_benches::{
use fuel_core_chain_config::ContractConfig;
use fuel_core_storage::{
tables::ContractsRawCode,
vm_storage::IncreaseStorageKey,
StorageAsMut,
};
use fuel_core_types::{
Expand Down Expand Up @@ -244,7 +245,6 @@ fn service_with_many_contracts(
state_size: u64,
contract_ids: Vec<ContractId>,
) -> (FuelService, tokio::runtime::Runtime) {
use fuel_core::database::vm_database::IncreaseStorageKey;
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
Expand Down
24 changes: 11 additions & 13 deletions benches/benches/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ use criterion::{
BenchmarkGroup,
Criterion,
};
use fuel_core::database::{
vm_database::VmDatabase,
Database,
};
use fuel_core_storage::InterpreterStorage;
use fuel_core::database::Database;
use fuel_core_storage::vm_storage::VmStorage;
use fuel_core_types::{
blockchain::header::GeneratedConsensusFields,
fuel_tx::Bytes32,
fuel_types::ContractId,
fuel_vm::InterpreterStorage,
};
use rand::{
rngs::StdRng,
Expand Down Expand Up @@ -53,15 +51,15 @@ fn insert_state_single_contract_database(c: &mut Criterion) {

let mut bench_state = |group: &mut BenchmarkGroup<WallTime>, name: &str, n: usize| {
group.bench_function(name, |b| {
let mut db = VmDatabase::default();
let mut db = VmStorage::default();
let contract: ContractId = rng.gen();
setup(db.database_mut(), &contract, n);
let outer = db.database_mut().transaction();
b.iter_custom(|iters| {
let mut elapsed_time = Duration::default();
for _ in 0..iters {
let mut inner = outer.transaction();
let mut inner_db = VmDatabase::new::<GeneratedConsensusFields>(
let mut inner_db = VmStorage::new::<GeneratedConsensusFields>(
inner.as_mut().clone(),
&Default::default(),
Default::default(),
Expand Down Expand Up @@ -114,15 +112,15 @@ fn insert_state_single_contract_transaction(c: &mut Criterion) {

let mut bench_state = |group: &mut BenchmarkGroup<WallTime>, name: &str, n: usize| {
group.bench_function(name, |b| {
let mut db = VmDatabase::default();
let mut db = VmStorage::<Database>::default();
let contract: ContractId = rng.gen();
let mut outer = db.database_mut().transaction();
setup(outer.as_mut(), &contract, n);
b.iter_custom(|iters| {
let mut elapsed_time = Duration::default();
for _ in 0..iters {
let mut inner = outer.transaction();
let mut inner_db = VmDatabase::new::<GeneratedConsensusFields>(
let mut inner_db = VmStorage::new::<GeneratedConsensusFields>(
inner.as_mut().clone(),
&Default::default(),
Default::default(),
Expand Down Expand Up @@ -175,7 +173,7 @@ fn insert_state_multiple_contracts_database(c: &mut Criterion) {

let mut bench_state = |group: &mut BenchmarkGroup<WallTime>, name: &str, n: usize| {
group.bench_function(name, |b| {
let mut db = VmDatabase::default();
let mut db = VmStorage::<Database>::default();
for _ in 0..n {
let contract: ContractId = rng.gen();
setup(db.database_mut(), &contract, 1);
Expand All @@ -186,7 +184,7 @@ fn insert_state_multiple_contracts_database(c: &mut Criterion) {
let contract: ContractId = rng.gen();
for _ in 0..iters {
let mut inner = outer.transaction();
let mut inner_db = VmDatabase::new::<GeneratedConsensusFields>(
let mut inner_db = VmStorage::new::<GeneratedConsensusFields>(
inner.as_mut().clone(),
&Default::default(),
Default::default(),
Expand Down Expand Up @@ -239,7 +237,7 @@ fn insert_state_multiple_contracts_transaction(c: &mut Criterion) {

let mut bench_state = |group: &mut BenchmarkGroup<WallTime>, name: &str, n: usize| {
group.bench_function(name, |b| {
let mut db = VmDatabase::default();
let mut db = VmStorage::<Database>::default();
let mut outer = db.database_mut().transaction();
for _ in 0..n {
let contract: ContractId = rng.gen();
Expand All @@ -250,7 +248,7 @@ fn insert_state_multiple_contracts_transaction(c: &mut Criterion) {
let contract: ContractId = rng.gen();
for _ in 0..iters {
let mut inner = outer.transaction();
let mut inner_db = VmDatabase::new::<GeneratedConsensusFields>(
let mut inner_db = VmStorage::new::<GeneratedConsensusFields>(
inner.as_mut().clone(),
&Default::default(),
Default::default(),
Expand Down
10 changes: 6 additions & 4 deletions benches/benches/vm_set/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ use criterion::{
Throughput,
};
use fuel_core::{
database::vm_database::VmDatabase,
service::Config,
state::rocks_db::{
RocksDb,
ShallowTempDir,
},
};
use fuel_core_benches::*;
use fuel_core_storage::vm_storage::{
IncreaseStorageKey,
VmStorage,
};
use fuel_core_types::{
blockchain::header::ConsensusHeader,
fuel_asm::{
Expand Down Expand Up @@ -51,7 +54,6 @@ pub struct BenchDb {

impl BenchDb {
fn new(contract_id: &ContractId) -> anyhow::Result<Self> {
use fuel_core::database::vm_database::IncreaseStorageKey;
let tmp_dir = ShallowTempDir::new();

let db = Arc::new(RocksDb::default_open(tmp_dir.path(), None).unwrap());
Expand Down Expand Up @@ -102,14 +104,14 @@ impl BenchDb {
}

/// Creates a `VmDatabase` instance.
fn to_vm_database(&self) -> VmDatabase {
fn to_vm_database(&self) -> VmStorage<Database> {
let header = ConsensusHeader {
prev_root: Default::default(),
height: 1.into(),
time: Tai64::UNIX_EPOCH,
generated: (),
};
VmDatabase::new(self.db.clone(), &header, ContractId::zeroed())
VmStorage::new(self.db.clone(), &header, ContractId::zeroed())
}
}

Expand Down
14 changes: 7 additions & 7 deletions benches/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pub mod default_gas_costs;
pub mod import;

use fuel_core::database::vm_database::VmDatabase;
pub use fuel_core::database::Database;
pub use fuel_core_storage::vm_storage::VmStorage;
use fuel_core_types::{
fuel_asm::{
op,
Expand Down Expand Up @@ -36,9 +36,9 @@ use std::iter;

const LARGE_GAS_LIMIT: u64 = u64::MAX - 1001;

fn new_db() -> VmDatabase {
fn new_db() -> VmStorage<Database> {
// when rocksdb is enabled, this creates a new db instance with a temporary path
VmDatabase::default()
VmStorage::default()
}

pub struct ContractCode {
Expand Down Expand Up @@ -89,7 +89,7 @@ pub struct VmBench {
pub inputs: Vec<Input>,
pub outputs: Vec<Output>,
pub witnesses: Vec<Witness>,
pub db: Option<VmDatabase>,
pub db: Option<VmStorage<Database>>,
pub instruction: Instruction,
pub prepare_call: Option<PrepareCall>,
pub dummy_contract: Option<ContractId>,
Expand All @@ -100,7 +100,7 @@ pub struct VmBench {

#[derive(Debug, Clone)]
pub struct VmBenchPrepared {
pub vm: Interpreter<VmDatabase, Script>,
pub vm: Interpreter<VmStorage<Database>, Script>,
pub instruction: Instruction,
pub diff: diff::Diff<diff::InitialVmState>,
}
Expand Down Expand Up @@ -148,7 +148,7 @@ impl VmBench {

pub fn contract_using_db<R>(
rng: &mut R,
mut db: VmDatabase,
mut db: VmStorage<Database>,
instruction: Instruction,
) -> anyhow::Result<Self>
where
Expand Down Expand Up @@ -209,7 +209,7 @@ impl VmBench {
.with_prepare_call(prepare_call))
}

pub fn with_db(mut self, db: VmDatabase) -> Self {
pub fn with_db(mut self, db: VmStorage<Database>) -> Self {
self.db.replace(db);
self
}
Expand Down
4 changes: 4 additions & 0 deletions ci_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ source .github/workflows/scripts/verify_openssl.sh &&
cargo clippy --all-targets --all-features &&
cargo make check --locked &&
cargo make check --all-features --locked &&
cargo check -p fuel-core-types --target wasm32-unknown-unknown --no-default-features &&
cargo check -p fuel-core-storage --target wasm32-unknown-unknown --no-default-features &&
cargo check -p fuel-core-client --target wasm32-unknown-unknown --no-default-features &&
cargo check -p fuel-core-chain-config --target wasm32-unknown-unknown --no-default-features &&
cargo test --all-features --workspace &&
cargo test -p fuel-core --no-default-features &&
cargo test -p fuel-core-client --no-default-features &&
Expand Down
1 change: 1 addition & 0 deletions crates/database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#![deny(missing_docs)]
#![deny(unused_crate_dependencies)]
#![deny(warnings)]
#![deny(unused_variables)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: isn't this implied by #![deny(warnings)]?


use fuel_core_storage::Error as StorageError;
use fuel_core_types::services::executor::Error as ExecutorError;
Expand Down
3 changes: 1 addition & 2 deletions crates/fuel-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ futures = { workspace = true }
hex = { version = "0.4", features = ["serde"] }
hyper = { workspace = true }
itertools = { workspace = true }
parking_lot = { workspace = true }
postcard = { workspace = true, features = ["use-std"] }
primitive-types = { workspace = true }
rand = { workspace = true }
rocksdb = { version = "0.21", default-features = false, features = [
"lz4",
Expand All @@ -63,6 +61,7 @@ uuid = { version = "1.1", features = ["v4"] }

[dev-dependencies]
assert_matches = "1.5"
fuel-core-executor = { workspace = true, features = ["test-helpers"] }
fuel-core-services = { path = "./../services", features = ["test-helpers"] }
fuel-core-storage = { path = "./../storage", features = ["test-helpers"] }
fuel-core-trace = { path = "./../trace" }
Expand Down
Loading
Loading