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

Release v2.0.3 #4243

Merged
merged 3 commits into from
Oct 23, 2024
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
222 changes: 111 additions & 111 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ starcoin-crypto = { git = "https://github.com/starcoinorg/starcoin-crypto", rev
starcoin-decrypt = { path = "commons/decrypt" }
starcoin-dev = { path = "vm/dev" }
starcoin-executor = { path = "executor" }
starcoin-framework = { git = "https://github.com/starcoinorg/starcoin-framework", rev = "94bcd77e80232b169cf95754ef4e87775645afcd" }
starcoin-framework = { git = "https://github.com/starcoinorg/starcoin-framework", rev = "a2546b32ad26d048e97d729e45153e0cba26ba18" }
starcoin-genesis = { path = "genesis" }
starcoin-logger = { path = "commons/logger" }
starcoin-metrics = { path = "commons/metrics" }
Expand Down
2 changes: 1 addition & 1 deletion abi/decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
name = "starcoin-abi-decoder"
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
publish = { workspace = true }
repository = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion abi/resolver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test-helper = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
name = "starcoin-abi-resolver"
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
license = { workspace = true }
publish = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion abi/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
name = "starcoin-abi-types"
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
publish = { workspace = true }
repository = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-account"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion account/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-account-api"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion account/provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ starcoin-types = { workspace = true }
[package]
edition = { workspace = true }
name = "starcoin-account-provider"
version = "2.0.1"
version = "2.0.2"
authors = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion account/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-account-service"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "benchmarks"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion block-relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-block-relayer"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-chain"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion chain/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-chain-api"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
1 change: 1 addition & 0 deletions chain/api/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub trait ChainReader {
) -> Result<GhostdagData>;
fn is_dag_ancestor_of(&self, ancestor: HashValue, descendants: Vec<HashValue>) -> Result<bool>;
fn get_pruning_height(&self) -> BlockNumber;
fn get_pruning_config(&self) -> (u64, u64);
}

pub trait ChainWriter {
Expand Down
2 changes: 1 addition & 1 deletion chain/chain-notify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-chain-notify"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion chain/mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-chain-mock"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
21 changes: 8 additions & 13 deletions chain/mock/src/mock_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,8 @@ impl MockChain {
Ok(Self::new_inner(net, chain, miner, storage))
}

pub fn new_with_params(
net: ChainNetwork,
k: KType,
pruning_depth: u64,
pruning_finality: u64,
) -> Result<Self> {
let (storage, chain_info, _, dag) =
Genesis::init_storage_for_test_with_param(&net, k, pruning_depth, pruning_finality)?;

pub fn new_with_params(net: ChainNetwork, k: KType) -> Result<Self> {
let (storage, chain_info, _, dag) = Genesis::init_storage_for_test_with_param(&net, k)?;
let chain = BlockChain::new(
net.time_service(),
chain_info.head().id(),
Expand Down Expand Up @@ -268,10 +261,12 @@ impl MockChain {
tips: pruned_tips,
blue_blocks,
pruning_point,
} = self
.head
.dag()
.calc_mergeset_and_tips(previous_pruning, prevous_ghostdata.as_ref())?;
} = self.head.dag().calc_mergeset_and_tips(
previous_pruning,
prevous_ghostdata.as_ref(),
4,
3,
)?;

debug!(
"tips: {:?}, blue_blocks: {:?}, pruning_point: {:?}",
Expand Down
2 changes: 1 addition & 1 deletion chain/open-block/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-open-block"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion chain/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-chain-service"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
17 changes: 16 additions & 1 deletion chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use starcoin_types::{
use starcoin_vm_types::access_path::AccessPath;
use starcoin_vm_types::account_config::genesis_address;
use starcoin_vm_types::genesis_config::{ChainId, ConsensusStrategy};
use starcoin_vm_types::on_chain_config::FlexiDagConfigV2;
use starcoin_vm_types::on_chain_resource::Epoch;
use std::cmp::min;
use std::iter::Extend;
Expand Down Expand Up @@ -1389,7 +1390,7 @@ impl ChainReader for BlockChain {
.get_block_header_by_hash(header.parent_hash())?
.ok_or_else(|| format_err!("cannot find parent block header"))?;
let next_ghostdata = self.dag().verify_and_ghostdata(uncles, header)?;

let (pruning_depth, pruning_finality) = self.get_pruning_config();
if self.status().head().pruning_point() != HashValue::zero() {
let previous_ghostdata = if previous_header.pruning_point() == HashValue::zero() {
let genesis = self
Expand All @@ -1409,6 +1410,8 @@ impl ChainReader for BlockChain {
previous_ghostdata.as_ref(),
header.pruning_point(),
&next_ghostdata,
pruning_depth,
pruning_finality,
)?;
}

Expand All @@ -1422,6 +1425,18 @@ impl ChainReader for BlockChain {
fn get_pruning_height(&self) -> BlockNumber {
self.get_pruning_height()
}

fn get_pruning_config(&self) -> (u64, u64) {
let reader = AccountStateReader::new(&self.statedb);
let FlexiDagConfigV2 {
pruning_depth,
pruning_finality,
} = reader
.get_dag_config()
.unwrap_or_default()
.unwrap_or_default();
(pruning_depth, pruning_finality)
}
Comment on lines +1430 to +1439
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider handling errors explicitly in get_pruning_config

The method get_pruning_config uses multiple unwrap_or_default() calls, which may suppress errors and return default values unintentionally. Consider handling errors explicitly to ensure any issues are caught and addressed appropriately.

Refactor the method to handle errors properly:

-fn get_pruning_config(&self) -> (u64, u64) {
-    let reader = AccountStateReader::new(&self.statedb);
-    let FlexiDagConfigV2 {
-        pruning_depth,
-        pruning_finality,
-    } = reader
-        .get_dag_config()
-        .unwrap_or_default()
-        .unwrap_or_default();
-    (pruning_depth, pruning_finality)
-}
+fn get_pruning_config(&self) -> Result<(u64, u64)> {
+    let reader = AccountStateReader::new(&self.statedb);
+    if let Some(config) = reader.get_dag_config()? {
+        Ok((config.pruning_depth, config.pruning_finality))
+    } else {
+        Err(format_err!("Failed to retrieve DAG configuration"))
+    }
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let reader = AccountStateReader::new(&self.statedb);
let FlexiDagConfigV2 {
pruning_depth,
pruning_finality,
} = reader
.get_dag_config()
.unwrap_or_default()
.unwrap_or_default();
(pruning_depth, pruning_finality)
}
fn get_pruning_config(&self) -> Result<(u64, u64)> {
let reader = AccountStateReader::new(&self.statedb);
if let Some(config) = reader.get_dag_config()? {
Ok((config.pruning_depth, config.pruning_finality))
} else {
Err(format_err!("Failed to retrieve DAG configuration"))
}
}

}

impl BlockChain {
Expand Down
2 changes: 1 addition & 1 deletion chain/tests/test_prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::collections::HashSet;

#[stest::test]
fn test_block_chain_prune() -> anyhow::Result<()> {
let mut mock_chain = MockChain::new_with_params(ChainNetwork::new_test(), 3, 4, 3)?;
let mut mock_chain = MockChain::new_with_params(ChainNetwork::new_test(), 3)?;
let genesis = mock_chain.head().status().head.clone();

// blue blocks
Expand Down
2 changes: 1 addition & 1 deletion cmd/airdrop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tokio = { features = ["full"], workspace = true }
authors = { workspace = true }
edition = { workspace = true }
name = "airdrop"
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
license = { workspace = true }
publish = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion cmd/db-exporter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "db-exporter"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion cmd/faucet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-faucet"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion cmd/generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-generator"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion cmd/genesis-nft-miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "genesis-nft-miner"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion cmd/indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-indexer"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion cmd/merkle-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ starcoin-vm-types = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
name = "merkle-generator"
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
license = { workspace = true }
publish = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion cmd/miner_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ starcoin-miner = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
name = "starcoin-miner-client"
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
license = { workspace = true }
publish = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion cmd/miner_client/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ starcoin-types = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
name = "starcoin-miner-client-api"
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
license = { workspace = true }
publish = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion cmd/peer-watcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-peer-watcher"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion cmd/replay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-replay"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion cmd/resource-exporter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "resource-exporter"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion cmd/starcoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-cmd"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion cmd/tx-factory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-tx-factory"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion commons/accumulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "starcoin-accumulator"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
2 changes: 1 addition & 1 deletion commons/api-limiter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
name = "api-limiter"
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
publish = { workspace = true }
repository = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion commons/bcs_ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = { workspace = true }
license = { workspace = true }
name = "bcs-ext"
publish = { workspace = true }
version = "2.0.1"
version = "2.0.2"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
Loading
Loading