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

merge fg flexidag #3997

Merged
merged 6 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 40 additions & 2 deletions Cargo.lock

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

16 changes: 11 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[workspace]
resolver = "2"
members = [
"consensus/dag",
"benchmarks",
"commons/stest",
"commons/bcs_ext",
Expand Down Expand Up @@ -112,10 +111,11 @@ members = [
"cmd/miner_client/api",
"cmd/db-exporter",
"cmd/genesis-nft-miner",
"flexidag",
"flexidag/dag",
]

default-members = [
"consensus/dag",
"benchmarks",
"commons/stest",
"commons/bcs_ext",
Expand Down Expand Up @@ -219,6 +219,8 @@ default-members = [
"stratum",
"cmd/miner_client/api",
"cmd/db-exporter",
"flexidag",
"flexidag/dag",
]

[profile.dev]
Expand Down Expand Up @@ -248,7 +250,7 @@ api-limiter = { path = "commons/api-limiter" }
arc-swap = "1.5.1"
arrayref = "0.3"
ascii = "1.0.0"
async-std = "1.12"
async-std = { version = "1.12", features = ["attributes", "tokio1"] }
async-trait = "0.1.53"
asynchronous-codec = "0.5"
atomic-counter = "1.0.1"
Expand All @@ -259,6 +261,9 @@ bcs-ext = { path = "commons/bcs_ext" }
bech32 = "0.9"
bencher = "0.1.5"
bitflags = "1.3.2"
faster-hex = "0.6"
indexmap = "1.9.1"
bincode = { version = "1", default-features = false }
bs58 = "0.3.1"
byteorder = "1.3.4"
bytes = "1"
Expand Down Expand Up @@ -500,7 +505,8 @@ starcoin-parallel-executor = { path = "vm/parallel-executor" }
starcoin-transaction-benchmarks = { path = "vm/transaction-benchmarks" }
starcoin-language-e2e-tests = { path = "vm/e2e-tests" }
starcoin-proptest-helpers = { path = "vm/proptest-helpers" }

starcoin-flexidag = { path = "flexidag" }
starcoin-dag = {path = "flexidag/dag"}
syn = { version = "1.0.107", features = [
"full",
"extra-traits",
Expand Down Expand Up @@ -535,7 +541,7 @@ walkdir = "2.3.1"
wasm-timer = "0.2"
which = "4.1.0"
zeroize = "1.3.0"
starcoin-dag = {path = "consensus/dag"}

[profile.release.package]
starcoin-service-registry.debug = 1
starcoin-chain.debug = 1
Expand Down
2 changes: 1 addition & 1 deletion account/src/account_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub fn test_wallet_account() -> Result<()> {
);
//println!("verify result is {:?}", sign.verify(&raw_txn, &public_key)?);
println!("public key is {:?}", public_key.to_bytes().as_ref());
println!("hash value is {:?}", &hash_value);
println!("hash value is {:?}", hash_value);
println!("key is {:?}", key.derived_address());
println!("address is {:?},result is {:?}", address, result);

Expand Down
1 change: 1 addition & 0 deletions benchmarks/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use starcoin_chain::BlockChain;
use starcoin_chain::{ChainReader, ChainWriter};
use starcoin_config::{temp_dir, ChainNetwork, DataDirPath, RocksdbConfig};
use starcoin_consensus::Consensus;
use starcoin_dag::blockdag::BlockDAG;
use starcoin_genesis::Genesis;
use starcoin_storage::cache_storage::CacheStorage;
use starcoin_storage::db_storage::DBStorage;
Expand Down
8 changes: 5 additions & 3 deletions block-relayer/src/block_relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ impl BlockRelayer {
ctx: &mut ServiceContext<BlockRelayer>,
) -> Result<()> {
let network = ctx.get_shared::<NetworkServiceRef>()?;
let block_connector_service = ctx.service_ref::<BlockConnectorService>()?.clone();
let block_connector_service = ctx
.service_ref::<BlockConnectorService<TxPoolService>>()?
.clone();
let txpool = self.txpool.clone();
let metrics = self.metrics.clone();
let fut = async move {
Expand Down Expand Up @@ -277,7 +279,7 @@ impl EventHandler<Self, NewHeadBlock> for BlockRelayer {
fn handle_event(&mut self, event: NewHeadBlock, ctx: &mut ServiceContext<BlockRelayer>) {
debug!(
"[block-relay] Handle new head block event, block_id: {:?}",
event.0.block().id()
event.executed_block.block().id()
);
let network = match ctx.get_shared::<NetworkServiceRef>() {
Ok(network) => network,
Expand All @@ -286,7 +288,7 @@ impl EventHandler<Self, NewHeadBlock> for BlockRelayer {
return;
}
};
self.broadcast_compact_block(network, event.0);
self.broadcast_compact_block(network, event.executed_block);
}
}

Expand Down
5 changes: 4 additions & 1 deletion chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ starcoin-vm-types = { workspace = true }
starcoin-storage = { workspace = true }
thiserror = { workspace = true }
starcoin-network-rpc-api = { workspace = true }
starcoin-dag = {workspace = true}
async-std = { workspace = true }
starcoin-flexidag ={ workspace = true }
starcoin-dag ={ workspace = true }

[dev-dependencies]
proptest = { workspace = true }
proptest-derive = { workspace = true }
Expand Down
1 change: 0 additions & 1 deletion chain/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ thiserror = { workspace = true }
starcoin-network-rpc-api = { workspace = true }
starcoin-config = { workspace = true }


[dev-dependencies]

[features]
Expand Down
2 changes: 2 additions & 0 deletions chain/api/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2

use anyhow::Result;
use starcoin_config::ChainNetworkID;
use starcoin_crypto::HashValue;
use starcoin_state_api::ChainStateReader;
use starcoin_statedb::ChainStateDB;
Expand Down Expand Up @@ -102,6 +103,7 @@ pub trait ChainReader {
) -> Result<Option<TransactionInfoWithProof>>;

fn current_tips_hash(&self) -> Result<Option<Vec<HashValue>>>;
fn has_dag_block(&self, hash: HashValue) -> Result<bool>;
}

pub trait ChainWriter {
Expand Down
3 changes: 3 additions & 0 deletions chain/api/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ pub enum ChainRequest {
access_path: Option<AccessPath>,
},
GetBlockInfos(Vec<HashValue>),
GetDagBlockChildren {
block_ids: Vec<HashValue>,
}
}

impl ServiceRequest for ChainRequest {
Expand Down
13 changes: 13 additions & 0 deletions chain/api/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub trait ReadableChainService {
) -> Result<Option<TransactionInfoWithProof>>;

fn get_block_infos(&self, ids: Vec<HashValue>) -> Result<Vec<Option<BlockInfo>>>;
fn get_dag_block_children(&self, ids: Vec<HashValue>) -> Result<Vec<HashValue>>;
}

/// Writeable block chain service trait
Expand Down Expand Up @@ -139,6 +140,7 @@ pub trait ChainAsyncService:
) -> Result<Option<TransactionInfoWithProof>>;

async fn get_block_infos(&self, hashes: Vec<HashValue>) -> Result<Vec<Option<BlockInfo>>>;
async fn get_dag_block_children(&self, hashes: Vec<HashValue>) -> Result<Vec<HashValue>>;
}

#[async_trait::async_trait]
Expand Down Expand Up @@ -436,4 +438,15 @@ where
bail!("get block_infos error")
}
}

async fn get_dag_block_children(&self, hashes: Vec<HashValue>) -> Result<Vec<HashValue>> {
let response = self.send(ChainRequest::GetDagBlockChildren {
block_ids: hashes,
}).await??;
if let ChainResponse::HashVec(children) = response {
Ok(children)
} else {
bail!("get dag block children error")
}
}
}
3 changes: 1 addition & 2 deletions chain/chain-notify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ impl EventHandler<Self, NewHeadBlock> for ChainNotifyHandlerService {
item: NewHeadBlock,
ctx: &mut ServiceContext<ChainNotifyHandlerService>,
) {
let NewHeadBlock(block_detail) = item;
let block = block_detail.block();
let block = item.executed_block.block();
// notify header.
self.notify_new_block(block, ctx);
// notify events
Expand Down
12 changes: 4 additions & 8 deletions chain/mock/src/mock_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,9 @@ impl MockChain {
}

pub fn produce(&self) -> Result<Block> {
let (template, _) = self.head.create_block_template(
*self.miner.address(),
None,
vec![],
vec![],
None,
None,
)?;
let (template, _) =
self.head
.create_block_template(*self.miner.address(), None, vec![], vec![], None, None)?;
self.head
.consensus()
.create_block(template, self.net.time_service().as_ref())
Expand All @@ -149,6 +144,7 @@ impl MockChain {
pub fn produce_and_apply(&mut self) -> Result<BlockHeader> {
let block = self.produce()?;
let header = block.header().clone();
println!("jacktest: produce testing block: {:?}, number: {:?}", block.id(), block.header().number());
self.apply(block)?;
Ok(header)
}
Expand Down
3 changes: 2 additions & 1 deletion chain/service/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[dependencies]
anyhow = { workspace = true }
async-std = { workspace = true }
async-trait = { workspace = true }
futures = { workspace = true }
rand = { workspace = true }
Expand Down Expand Up @@ -36,7 +37,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-chain-service"
publish = { workspace = true }
version = "1.13.7"
version = "1.13.8"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
Loading
Loading