Skip to content

Commit

Permalink
[FlexiDag] set HeaderWithBlockLevel block_level 1 and fix some typos (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg authored May 23, 2024
1 parent a989171 commit 1504a8f
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion chain/api/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ pub enum ChainResponse {
BlockInfoVec(Box<Vec<Option<BlockInfo>>>),
DagStateView(Box<DagStateView>),
CheckDagType(DagHeaderType),
DagForkHeigh(Option<BlockNumber>),
DagForkHeight(Option<BlockNumber>),
}
12 changes: 6 additions & 6 deletions chain/api/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub trait ReadableChainService {
fn get_dag_block_children(&self, ids: Vec<HashValue>) -> Result<Vec<HashValue>>;
fn get_dag_state(&self) -> Result<DagStateView>;
fn check_dag_type(&self, header: &BlockHeader) -> Result<DagHeaderType>;
fn dag_fork_heigh(&self) -> Result<Option<BlockNumber>>;
fn dag_fork_height(&self) -> Result<Option<BlockNumber>>;
}

/// Writeable block chain service trait
Expand Down Expand Up @@ -148,7 +148,7 @@ pub trait ChainAsyncService:
async fn get_dag_block_children(&self, hashes: Vec<HashValue>) -> Result<Vec<HashValue>>;
async fn get_dag_state(&self) -> Result<DagStateView>;
async fn check_dag_type(&self, id: HashValue) -> Result<DagHeaderType>;
async fn dag_fork_heigh(&self) -> Result<Option<BlockNumber>>;
async fn dag_fork_height(&self) -> Result<Option<BlockNumber>>;
}

#[async_trait::async_trait]
Expand Down Expand Up @@ -475,12 +475,12 @@ where
bail!("check dag type error")
}
}
async fn dag_fork_heigh(&self) -> Result<Option<BlockNumber>> {
async fn dag_fork_height(&self) -> Result<Option<BlockNumber>> {
let response = self.send(ChainRequest::DagForkHeigh).await??;
if let ChainResponse::DagForkHeigh(dag_fork_heigh) = response {
Ok(dag_fork_heigh)
if let ChainResponse::DagForkHeight(dag_fork_height) = response {
Ok(dag_fork_height)
} else {
bail!("failed to get dag fork heigh")
bail!("failed to get dag fork height")
}
}
}
4 changes: 2 additions & 2 deletions chain/service/src/chain_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl ServiceHandler<Self, ChainRequest> for ChainReaderService {
self.inner.check_dag_type(&header)?
})),
ChainRequest::DagForkHeigh => {
Ok(ChainResponse::DagForkHeigh(self.inner.dag_fork_heigh()?))
Ok(ChainResponse::DagForkHeight(self.inner.dag_fork_height()?))
}
}
}
Expand Down Expand Up @@ -477,7 +477,7 @@ impl ReadableChainService for ChainReaderServiceInner {
self.main.check_dag_type(header)
}

fn dag_fork_heigh(&self) -> Result<Option<BlockNumber>> {
fn dag_fork_height(&self) -> Result<Option<BlockNumber>> {
self.main.dag_fork_height()
}
}
Expand Down
2 changes: 1 addition & 1 deletion flexidag/src/blockdag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl BlockDAG {
process_key_already_error(self.storage.header_store.insert(
header.id(),
Arc::new(header),
0,
1,
))?;
Ok(())
}
Expand Down
12 changes: 6 additions & 6 deletions flexidag/src/consensusdb/consenses_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ impl ValueCodec<DagStateData> for DagState {
}

pub trait DagStateReader {
fn get_state(&self, dag_gensis: Hash) -> Result<DagState, StoreError>;
fn get_state(&self, dag_genesis: Hash) -> Result<DagState, StoreError>;
}

pub trait DagStateStore: DagStateReader {
// This is append only
fn insert(&self, dag_gensis: Hash, state: DagState) -> Result<(), StoreError>;
fn insert(&self, dag_genesis: Hash, state: DagState) -> Result<(), StoreError>;
}

/// A DB + cache implementation of `HeaderStore` trait, with concurrency support.
Expand All @@ -59,16 +59,16 @@ impl DbDagStateStore {
}

impl DagStateReader for DbDagStateStore {
fn get_state(&self, dag_gensis: Hash) -> Result<DagState, StoreError> {
let result = self.dag_state_access.read(dag_gensis)?;
fn get_state(&self, dag_genesis: Hash) -> Result<DagState, StoreError> {
let result = self.dag_state_access.read(dag_genesis)?;
Ok(result)
}
}

impl DagStateStore for DbDagStateStore {
fn insert(&self, dag_gensis: Hash, state: DagState) -> Result<(), StoreError> {
fn insert(&self, dag_genesis: Hash, state: DagState) -> Result<(), StoreError> {
self.dag_state_access
.write(DirectDbWriter::new(&self.db), dag_gensis, state)?;
.write(DirectDbWriter::new(&self.db), dag_genesis, state)?;
Ok(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion flexidag/src/ghostdag/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<
Hash::sha3_256_of(
&[genesis.parent_hash(), genesis.id()]
.encode()
.expect("failed to encode hash for dag gensis and its parent"),
.expect("failed to encode hash for dag genesis and its parent"),
),
BlockHashes::new(vec![]),
BlockHashes::new(Vec::new()),
Expand Down
14 changes: 7 additions & 7 deletions flexidag/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ fn test_dag_genesis_fork() {
let _ghostdata = dag.ghostdata_by_hash(header.id()).unwrap().unwrap();
}

// fork, produce a new dag gensis
// fork, produce a new dag genesis
let new_genesis = BlockHeader::dag_genesis_random()
.as_builder()
.with_difficulty(0.into())
Expand Down Expand Up @@ -313,36 +313,36 @@ fn test_dag_tips_store() {
let state1 = DagState {
tips: vec![Hash::random()],
};
let dag_gensis1 = Hash::random();
let dag_genesis1 = Hash::random();
dag.storage
.state_store
.write()
.insert(dag_gensis1, state1.clone())
.insert(dag_genesis1, state1.clone())
.expect("failed to store the dag state");

let state2 = DagState {
tips: vec![Hash::random()],
};
let dag_gensis2 = Hash::random();
let dag_genesis2 = Hash::random();
dag.storage
.state_store
.write()
.insert(dag_gensis2, state2.clone())
.insert(dag_genesis2, state2.clone())
.expect("failed to store the dag state");

assert_eq!(
dag.storage
.state_store
.read()
.get_state(dag_gensis1)
.get_state(dag_genesis1)
.expect("failed to get the dag state"),
state1
);
assert_eq!(
dag.storage
.state_store
.read()
.get_state(dag_gensis2)
.get_state(dag_genesis2)
.expect("failed to get the dag state"),
state2
);
Expand Down
2 changes: 1 addition & 1 deletion kube/manifest/starcoin-proxima.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
ret=$?;
echo "Now ret is - $ret";
if [ $ret -eq 120 ] || [ $ret -eq 139 ]; then
echo "Start failed with gensis mismatch code 120, clean data...";
echo "Start failed with genesis mismatch code 120, clean data...";
rm -rf /sc-data/proxima/ &>/dev/null;
elif [ $ret -ne 0 ]; then
echo "Node start fail, try to remove config.";
Expand Down
2 changes: 1 addition & 1 deletion sync/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl SyncService {
storage.get_block_info(current_block_id)?.ok_or_else(|| {
format_err!("Can not find block info by id: {}", current_block_id)
})?;
let dag_fork_height = chain_service.dag_fork_heigh().await?;
let dag_fork_height = chain_service.dag_fork_height().await?;
let rpc_client = Self::create_verified_client(
network.clone(),
config.clone(),
Expand Down

0 comments on commit 1504a8f

Please sign in to comment.