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

add sync and flexidag service for flexidag #3984

Merged
merged 1 commit into from
Nov 6, 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
26 changes: 26 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ members = [
"cmd/miner_client/api",
"cmd/db-exporter",
"cmd/genesis-nft-miner",
"flexidag",
]

default-members = [
Expand Down Expand Up @@ -217,6 +218,7 @@ default-members = [
"stratum",
"cmd/miner_client/api",
"cmd/db-exporter",
"flexidag",
]

[profile.dev]
Expand Down Expand Up @@ -499,6 +501,7 @@ 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" }

syn = { version = "1.0.107", features = [
"full",
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.as_ref());
println!("hash value is {:?}", hash_value);
println!("key is {:?}", key.derived_address());
println!("address is {:?},result is {:?}", address, result);

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl ChainBencher {
let block = ConsensusStrategy::Dummy
.create_block(block_template, self.net.time_service().as_ref())
.unwrap();
self.chain.write().apply(block, None).unwrap();
self.chain.write().apply(block).unwrap();
}
}

Expand Down
1 change: 1 addition & 0 deletions chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ starcoin-vm-types = { workspace = true }
starcoin-storage = { workspace = true }
thiserror = { workspace = true }
starcoin-network-rpc-api = { workspace = true }
async-std = { workspace = true }

[dev-dependencies]
proptest = { 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
17 changes: 1 addition & 16 deletions chain/api/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub trait ChainReader {
fn execute(
&self,
block: VerifiedBlock,
parents_hash: Option<Vec<HashValue>>,
transaction_parent: Option<HashValue>,
) -> Result<ExecutedBlock>;
/// Get chain transaction infos
fn get_transaction_infos(
Expand All @@ -107,8 +107,6 @@ pub trait ChainReader {
access_path: Option<AccessPath>,
) -> Result<Option<TransactionInfoWithProof>>;

/// get the current tips hash value
fn current_tips_hash(&self) -> Option<HashValue>;
fn net_id(&self) -> ChainNetworkID;
}

Expand All @@ -121,22 +119,9 @@ pub trait ChainWriter {
fn apply(
&mut self,
block: Block,
parents_hash: Option<Vec<HashValue>>,
) -> Result<ExecutedBlock>;

fn chain_state(&mut self) -> &ChainStateDB;

/// Get the dag accumulator info
fn get_current_dag_accumulator_info(&self) -> Result<AccumulatorInfo>;

/// Fork the accumulator
fn fork_dag_accumulator(&mut self, accumulator_info: AccumulatorInfo) -> Result<()>;

/// Append the dag accumulator leaf
fn append_dag_accumulator_leaf(
&mut self,
tips: Vec<HashValue>,
) -> Result<(HashValue, AccumulatorInfo)>;
}

/// `Chain` is a trait that defines a single Chain.
Expand Down
6 changes: 4 additions & 2 deletions chain/api/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2

use std::sync::{Arc, Mutex};

use crate::message::{ChainRequest, ChainResponse};
use crate::TransactionInfoWithProof;
use anyhow::{bail, Result};
Expand All @@ -9,7 +11,7 @@ use starcoin_network_rpc_api::dag_protocol::{
self, GetDagAccumulatorLeaves, GetTargetDagAccumulatorLeafDetail, TargetDagAccumulatorLeaf,
TargetDagAccumulatorLeafDetail,
};
use starcoin_service_registry::{ActorService, ServiceHandler, ServiceRef};
use starcoin_service_registry::{ActorService, ServiceContext, ServiceHandler, ServiceRef};
use starcoin_types::contract_event::{ContractEvent, ContractEventInfo};
use starcoin_types::filter::Filter;
use starcoin_types::startup_info::ChainStatus;
Expand Down Expand Up @@ -91,7 +93,7 @@ pub trait ReadableChainService {

/// Writeable block chain service trait
pub trait WriteableChainService: Send + Sync {
fn try_connect(&mut self, block: Block, tips_header: Option<Vec<HashValue>>) -> Result<()>;
fn try_connect(&mut self, block: Block) -> Result<()>;
}

#[async_trait::async_trait]
Expand Down
6 changes: 3 additions & 3 deletions chain/mock/src/mock_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ impl MockChain {
.create_block(template, self.net.time_service().as_ref())
}

pub fn apply(&mut self, block: Block, parents_hash: Option<Vec<HashValue>>) -> Result<()> {
self.head.apply(block, parents_hash)?;
pub fn apply(&mut self, block: Block) -> Result<()> {
self.head.apply(block, None)?;
Ok(())
}

pub fn produce_and_apply(&mut self) -> Result<BlockHeader> {
let block = self.produce()?;
let header = block.header().clone();
self.apply(block, None)?;
self.apply(block)?;
Ok(header)
}

Expand Down
2 changes: 2 additions & 0 deletions 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 All @@ -21,6 +22,7 @@ tokio = { workspace = true }
starcoin-network-rpc-api = { workspace = true }
starcoin-consensus = { workspace = true }
starcoin-accumulator = { package = "starcoin-accumulator", workspace = true }
starcoin-flexidag = { workspace = true }

[dev-dependencies]
stest = { workspace = true }
Expand Down
Loading
Loading