Skip to content

Commit

Permalink
refactor: move gw-types and gw-common to gwos folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyr committed Dec 13, 2022
1 parent beafdab commit 7d84d1d
Show file tree
Hide file tree
Showing 138 changed files with 1,006 additions and 1,325 deletions.
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[workspace]
members = [
"gwos/crates/types",
"gwos/crates/common",
"crates/challenge",
"crates/chain",
"crates/config",
"crates/common",
"crates/mem-pool",
"crates/generator",
"crates/traits",
"crates/db",
"crates/store",
"crates/types",
"crates/block-producer",
"crates/jsonrpc-types",
"crates/rpc-server",
Expand All @@ -30,7 +30,9 @@ members = [
]

exclude = [
"gwos-evm/polyjuice-tests"
"gwos-evm/polyjuice-tests",
"gwos/c-uint256-tests",
"gwos/contracts",
]

[profile.release]
Expand Down
4 changes: 2 additions & 2 deletions crates/benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ anyhow = "1.0.66"
criterion = { version = "0.3", features = ["html_reports"] }
pprof = { version = "0.6", features = ["flamegraph", "criterion"] }
gw-store = { path = "../store" }
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-mem-pool = { path = "../mem-pool" }
gw-generator = { path = "../generator" }
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-traits = { path = "../traits" }
gw-db = { path = "../db" }
gw-config = { path = "../config" }
Expand Down
4 changes: 2 additions & 2 deletions crates/block-producer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ edition = "2021"

[dependencies]
gw-challenge = { path = "../challenge" }
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-config = { path = "../config" }
gw-chain = { path = "../chain" }
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-db = { path = "../db" }
gw-store = { path = "../store" }
gw-generator = { path = "../generator" }
Expand Down
6 changes: 3 additions & 3 deletions crates/block-producer/src/block_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use gw_types::{
prelude::*,
};
use gw_utils::{
block_timepoint, fee::fill_tx_fee_with_local, genesis_info::CKBGenesisInfo,
fee::fill_tx_fee_with_local, finalized_timepoint, genesis_info::CKBGenesisInfo,
local_cells::LocalCellsManager, query_rollup_cell, since::Since,
transaction_skeleton::TransactionSkeleton, wallet::Wallet, RollupContext,
};
Expand All @@ -60,14 +60,14 @@ fn generate_custodian_cells(
deposit_cells: &[DepositInfo],
) -> Vec<(CellOutput, Bytes)> {
let block_hash: H256 = block.hash().into();
let block_timepoint = block_timepoint(
let finalized_timepoint = finalized_timepoint(
&rollup_context.rollup_config,
&rollup_context.fork_config,
block.raw().number().unpack(),
block.raw().timestamp().unpack(),
);
let to_custodian = |deposit| -> _ {
to_custodian_cell(rollup_context, &block_hash, &block_timepoint, deposit)
to_custodian_cell(rollup_context, &block_hash, &finalized_timepoint, deposit)
.expect("sanitized deposit")
};

Expand Down
4 changes: 2 additions & 2 deletions crates/block-producer/src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use gw_types::{
use gw_utils::local_cells::{
collect_local_and_indexer_cells, CollectLocalAndIndexerCursor, LocalCellsManager,
};
use gw_utils::{block_timepoint, RollupContext};
use gw_utils::{finalized_timepoint, RollupContext};

pub struct GeneratedStake {
pub deps: Vec<CellDep>,
Expand All @@ -39,7 +39,7 @@ pub async fn generate(
local_cells_manager: &LocalCellsManager,
) -> Result<GeneratedStake> {
let owner_lock_hash = lock_script.hash();
let stake_block_timepoint = block_timepoint(
let stake_block_timepoint = finalized_timepoint(
&rollup_context.rollup_config,
&rollup_context.fork_config,
block.raw().number().unpack(),
Expand Down
5 changes: 1 addition & 4 deletions crates/block-producer/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ pub async fn dump_transaction<P: AsRef<Path>>(dir: P, rpc_client: &RPCClient, tx
pub fn global_state_last_finalized_timepoint_to_since(global_state: &GlobalState) -> u64 {
match Timepoint::from_full_value(global_state.last_finalized_timepoint().unpack()) {
Timepoint::BlockNumber(_) => 0,
Timepoint::Timestamp(time_ms) => {
// ATTENTION: I am not sure if I am do right. Please review intensively.
Since::new_timestamp_seconds(time_ms.saturating_div(1000).saturating_sub(1)).as_u64()
}
Timepoint::Timestamp(time_ms) => Since::new_timestamp_seconds(time_ms / 1000).as_u64(),
}
}
4 changes: 2 additions & 2 deletions crates/chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ edition = "2018"

[dependencies]
gw-challenge = { path = "../challenge" }
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-config = { path = "../config" }
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-generator = { path = "../generator" }
gw-mem-pool = { path = "../mem-pool" }
gw-store = { path = "../store" }
Expand Down
4 changes: 2 additions & 2 deletions crates/challenge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gw-common = { path = "../common" }
gw-types = { path = "../../gwos/crates/types" }
gw-common = { path = "../../gwos/crates/common" }
gw-config = { path = "../config" }
gw-types = { path = "../types" }
gw-db = { path = "../db" }
gw-store = { path = "../store" }
gw-generator = { path = "../generator" }
Expand Down
4 changes: 2 additions & 2 deletions crates/generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ detect-asm = ["ckb-vm/detect-asm", "ckb-vm-aot"]
enable-always-success-lock = []

[dependencies]
gw-types = { path = "../types" }
gw-common = { path = "../common" }
gw-types = { path = "../../gwos/crates/types" }
gw-common = { path = "../../gwos/crates/common" }
gw-config = { path = "../config" }
gw-store = { path = "../store" }
gw-traits = { path = "../traits" }
Expand Down
4 changes: 2 additions & 2 deletions crates/godwoken-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ indicatif = "0.16"
gw-block-producer = { path = "../block-producer" }
gw-chain = { path = "../chain" }
gw-challenge = { path = "../challenge" }
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-config = { path = "../config" }
gw-db = { path = "../db" }
gw-generator = { path = "../generator" }
gw-jsonrpc-types = { path = "../jsonrpc-types" }
gw-telemetry = { path = "../telemetry" }
gw-store = { path = "../store" }
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-utils = { path = "../utils" }
gw-version = { path = "../version" }
gw-metrics = { path = "../metrics" }
Expand Down
4 changes: 2 additions & 2 deletions crates/jsonrpc-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ edition = "2018"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
faster-hex = "0.4"
gw-types = { path = "../types" }
gw-common = { path = "../common" }
gw-types = { path = "../../gwos/crates/types" }
gw-common = { path = "../../gwos/crates/common" }
ckb-jsonrpc-types = "0.105.1"
ckb-fixed-hash = "0.105.1"
anyhow = "1.0"
4 changes: 2 additions & 2 deletions crates/mem-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gw-types = { path = "../types" }
gw-common = { path = "../common" }
gw-types = { path = "../../gwos/crates/types" }
gw-common = { path = "../../gwos/crates/common" }
gw-challenge = { path = "../challenge" }
gw-generator = { path = "../generator" }
gw-store = { path = "../store" }
Expand Down
6 changes: 3 additions & 3 deletions crates/mem-pool/src/withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use gw_types::{
packed::{CellOutput, L2Block, Script, WithdrawalRequest, WithdrawalRequestExtra},
prelude::*,
};
use gw_utils::{block_timepoint, RollupContext};
use gw_utils::{finalized_timepoint, RollupContext};
use std::collections::HashMap;

use crate::custodian::{
Expand Down Expand Up @@ -116,7 +116,7 @@ impl<'a> Generator<'a> {
sudt_custodian.map(|sudt| sudt.script.to_owned())
};
let block_hash: H256 = block.hash().into();
let block_timepoint = block_timepoint(
let finalized_timepoint = finalized_timepoint(
&self.rollup_context.rollup_config,
&self.rollup_context.fork_config,
block.raw().number().unpack(),
Expand All @@ -126,7 +126,7 @@ impl<'a> Generator<'a> {
self.rollup_context,
req_extra,
&block_hash,
&block_timepoint,
&finalized_timepoint,
sudt_script,
) {
Ok(output) => output,
Expand Down
4 changes: 2 additions & 2 deletions crates/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-store = { path = "../store" }
gw-telemetry = { path = "../telemetry" }
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-config = { path = "../config" }

arc-swap = "1.5"
Expand Down
2 changes: 1 addition & 1 deletion crates/p2p-network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-config = { path = "../config" }
gw-utils = { path = "../utils" }
tokio = "1"
Expand Down
4 changes: 2 additions & 2 deletions crates/polyjuice-sender-recover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"

[dependencies]
anyhow = "1.0"
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-generator = { path = "../generator" }
gw-traits = { path = "../traits" }
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-utils = { path = "../utils" }
gw-store = { path = "../store" }
log = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions crates/replay-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ edition = "2018"
[dependencies]
gw-chain = { path = "../chain" }
gw-challenge = { path = "../challenge" }
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-config = { path = "../config" }
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-generator = { path = "../generator" }
gw-mem-pool = { path = "../mem-pool" }
gw-store = { path = "../store" }
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-config = { path = "../config" }
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-jsonrpc-types = { path = "../jsonrpc-types" }
faster-hex = "0.4"
ckb-crypto = "0.105.1"
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ edition = "2018"

[dependencies]
gw-challenge = { path = "../challenge" }
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-config = { path = "../config" }
gw-chain = { path = "../chain" }
gw-db = { path = "../db" }
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-store = { path = "../store" }
gw-traits = { path = "../traits" }
gw-generator = { path = "../generator" }
Expand Down
4 changes: 2 additions & 2 deletions crates/store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ edition = "2018"

[dependencies]
gw-db = { path = "../db" }
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-config = { path = "../config" }
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-traits = { path = "../traits" }
anyhow = "1.0"
arc-swap = "1.5.0"
Expand Down
4 changes: 2 additions & 2 deletions crates/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ edition = "2018"
scripts = []

[dependencies]
gw-types = { path = "../types", features = ["std", "deprecated"] }
gw-common = { path = "../common" }
gw-types = { path = "../../gwos/crates/types", features = ["std", "deprecated"] }
gw-common = { path = "../../gwos/crates/common" }
gw-config = { path = "../config" }
gw-db = { path = "../db" }
gw-store = { path = "../store" }
Expand Down
4 changes: 2 additions & 2 deletions crates/tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ ckb-crypto = "0.105.1"
ckb-traits = "0.105.1"
ckb-dao-utils = "0.105.1"
gw-db = { path = "../db" }
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-config = { path = "../config" }
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-generator = { path = "../generator" }
gw-jsonrpc-types = { path = "../jsonrpc-types" }
gw-utils = { path = "../utils" }
Expand Down
4 changes: 2 additions & 2 deletions crates/traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gw-types = { path = "../types" }
gw-common = { path = "../common" }
gw-types = { path = "../../gwos/crates/types" }
gw-common = { path = "../../gwos/crates/common" }
gw-db = { path = "../db" }
anyhow = "1.0.66"
4 changes: 2 additions & 2 deletions crates/tx-filter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-config = { path = "../config" }
gw-traits = { path = "../traits" }
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
thiserror = "1.0"
log = "0.4"
hex = "0.4"
4 changes: 2 additions & 2 deletions crates/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gw-types = { path = "../types" }
gw-types = { path = "../../gwos/crates/types" }
gw-config = { path = "../config" }
gw-common = { path = "../common" }
gw-common = { path = "../../gwos/crates/common" }
gw-rpc-client = { path = "../rpc-client" }
gw-jsonrpc-types = { path = "../jsonrpc-types" }
gw-store = { path = "../store" }
Expand Down
4 changes: 2 additions & 2 deletions crates/utils/src/calc_finalizing_range.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::block_timepoint;
use crate::finalized_timepoint;
use anyhow::{Context, Result};
use gw_config::ForkConfig;
use gw_store::traits::chain_store::ChainStore;
Expand All @@ -23,7 +23,7 @@ fn is_older_block_finalized(
let older_block = db
.get_block(&older_block_hash)?
.context("get older block")?;
let older_block_timepoint = block_timepoint(
let older_block_timepoint = finalized_timepoint(
rollup_config,
fork_config,
older_block_number,
Expand Down
2 changes: 1 addition & 1 deletion crates/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ pub mod withdrawal;
pub use calc_finalizing_range::calc_finalizing_range;
pub use query_rollup_cell::query_rollup_cell;
pub use rollup_context::RollupContext;
pub use timepoint::{block_timepoint, global_state_finalized_timepoint};
pub use timepoint::{finalized_timepoint, global_state_finalized_timepoint};
2 changes: 1 addition & 1 deletion crates/utils/src/timepoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use gw_types::core::Timepoint;
use gw_types::packed::RollupConfig;
use gw_types::prelude::*;

pub fn block_timepoint(
pub fn finalized_timepoint(
rollup_config: &RollupConfig,
fork_config: &ForkConfig,
block_number: u64,
Expand Down
Loading

0 comments on commit 7d84d1d

Please sign in to comment.