Skip to content

Commit

Permalink
Merge branch 'master' into v2.0-testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
peilun-conflux committed Oct 18, 2023
2 parents 6b4fe96 + b63b788 commit 2ec2f96
Show file tree
Hide file tree
Showing 69 changed files with 3,608 additions and 2,290 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ build/
**/testnet.toml
*~
.DS_Store
tests/artifacts/**/*.dbg.json
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "tests/extra-test-toolkits"]
path = tests/extra-test-toolkits
url = https://github.com/Conflux-Chain/conflux-rust-test-toolkits.git
[submodule "tests/test_contracts"]
path = tests/test_contracts
url = https://github.com/Conflux-Chain/conflux-rust-dev-contracts.git
branch = main
29 changes: 29 additions & 0 deletions client/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ build_config! {
(storage_delta_mpts_cache_start_size, (u32), cfx_storage::defaults::DEFAULT_DELTA_MPTS_CACHE_START_SIZE)
(storage_delta_mpts_node_map_vec_size, (u32), cfx_storage::defaults::MAX_CACHED_TRIE_NODES_R_LFU_COUNTER)
(storage_delta_mpts_slab_idle_size, (u32), cfx_storage::defaults::DEFAULT_DELTA_MPTS_SLAB_IDLE_SIZE)
(storage_single_mpt_cache_size, (u32), cfx_storage::defaults::DEFAULT_DELTA_MPTS_CACHE_SIZE * 2)
(storage_single_mpt_cache_start_size, (u32), cfx_storage::defaults::DEFAULT_DELTA_MPTS_CACHE_START_SIZE * 2)
(storage_single_mpt_slab_idle_size, (u32), cfx_storage::defaults::DEFAULT_DELTA_MPTS_SLAB_IDLE_SIZE * 2)
(storage_max_open_snapshots, (u16), cfx_storage::defaults::DEFAULT_MAX_OPEN_SNAPSHOTS)
(storage_max_open_mpt_count, (u32), cfx_storage::defaults::DEFAULT_MAX_OPEN_MPT)
(strict_tx_index_gc, (bool), true)
Expand Down Expand Up @@ -354,6 +357,16 @@ build_config! {
(ln_num_waiting_headers_threshold, (Option<usize>), None)
(keep_snapshot_before_stable_checkpoint, (bool), true)
(force_recompute_height_during_construct_pivot, (Option<u64>), None)

// The snapshot database consists of two tables: snapshot_key_value and snapshot_mpt. However, the size of snapshot_mpt is significantly larger than that of snapshot_key_value.
// When the configuration parameter use_isolated_db_for_mpt_table is set to true, the snapshot_mpt table will be located in a separate database.
(use_isolated_db_for_mpt_table, (bool), false)
// The use_isolated_db_for_mpt_table_height parameter is utilized to determine when to enable the use_isolated_db_for_mpt_table option.
// None: enabled since the next snapshot
// u64: enabled since the specified height
(use_isolated_db_for_mpt_table_height, (Option<u64>), None)
// Recover the latest MPT snapshot from the era checkpoint
(recovery_latest_mpt_snapshot, (bool), false)
}
{
// Development related section.
Expand Down Expand Up @@ -613,6 +626,8 @@ impl Configuration {
None => None,
},
force_recompute_height_during_construct_pivot: self.raw_conf.force_recompute_height_during_construct_pivot,
recovery_latest_mpt_snapshot: self.raw_conf.recovery_latest_mpt_snapshot,
use_isolated_db_for_mpt_table: self.raw_conf.use_isolated_db_for_mpt_table,
},
bench_mode: false,
transaction_epoch_bound: self.raw_conf.transaction_epoch_bound,
Expand Down Expand Up @@ -710,6 +725,7 @@ impl Configuration {
} else {
SNAPSHOT_EPOCHS_CAPACITY
},
era_epoch_count: self.raw_conf.era_epoch_count,
},
debug_snapshot_checker_threads:
DEFAULT_DEBUG_SNAPSHOT_CHECKER_THREADS,
Expand All @@ -726,6 +742,13 @@ impl Configuration {
delta_mpts_slab_idle_size: self
.raw_conf
.storage_delta_mpts_slab_idle_size,
single_mpt_cache_start_size: self
.raw_conf
.storage_single_mpt_cache_start_size,
single_mpt_cache_size: self.raw_conf.storage_single_mpt_cache_size,
single_mpt_slab_idle_size: self
.raw_conf
.storage_single_mpt_slab_idle_size,
max_open_snapshots: self.raw_conf.storage_max_open_snapshots,
path_delta_mpts_dir: conflux_data_path
.join(&*storage_dir::DELTA_MPTS_DIR),
Expand Down Expand Up @@ -757,6 +780,12 @@ impl Configuration {
keep_snapshot_before_stable_checkpoint: self
.raw_conf
.keep_snapshot_before_stable_checkpoint,
use_isolated_db_for_mpt_table: self
.raw_conf
.use_isolated_db_for_mpt_table,
use_isolated_db_for_mpt_table_height: self
.raw_conf
.use_isolated_db_for_mpt_table_height,
}
}

Expand Down
8 changes: 7 additions & 1 deletion client/src/rpc/impls/cfx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ use cfx_types::{
U64,
};
use cfxcore::{
executive::{ExecutionError, ExecutionOutcome, TxDropError},
executive::{
internal_contract::storage_point_prop, ExecutionError,
ExecutionOutcome, TxDropError,
},
rpc_errors::{account_result_to_rpc_result, invalid_params_check},
state_exposer::STATE_EXPOSER,
verification::{compute_epoch_receipt_proof, EpochReceiptProof},
Expand Down Expand Up @@ -1569,9 +1572,12 @@ impl RpcImpl {
/ U256::from(BLOCKS_PER_YEAR);
let pow_base_reward = state_db.get_global_param::<PowBaseReward>()?;

let storage_point_prop =
state_db.get_system_storage(&storage_point_prop())?;
Ok(VoteParamsInfo {
pow_base_reward,
interest_rate,
storage_point_prop,
})
}

Expand Down
5 changes: 4 additions & 1 deletion client/src/rpc/impls/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ pub fn check_balance_against_transaction(

let balance_for_collateral: U512 = contract_account
.as_ref()
.map(|a| a.sponsor_info.sponsor_balance_for_collateral)
.map(|a| {
a.sponsor_info.sponsor_balance_for_collateral
+ a.sponsor_info.unused_storage_points()
})
.unwrap_or_default()
.into();

Expand Down
1 change: 1 addition & 0 deletions client/src/rpc/types/vote_params_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ use cfx_types::U256;
pub struct VoteParamsInfo {
pub(crate) pow_base_reward: U256,
pub(crate) interest_rate: U256,
pub(crate) storage_point_prop: U256,
}
2 changes: 2 additions & 0 deletions core/benchmark/storage/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,7 @@ impl Drop for TxReplayer {
impl TxReplayer {
const EPOCH_TXS: u64 = 20000;
const SNAPSHOT_EPOCHS_CAPACITY: u32 = 400;
const ERA_EPOCHS_CAPACITY: u64 = 20000;

// const SNAPSHOT_EPOCHS_CAPACITY: u32 = 10;

Expand All @@ -1614,6 +1615,7 @@ impl TxReplayer {
let mut storage_configuration = StorageConfiguration::new_default(
&(conflux_data_dir.to_string() + "/"),
Self::SNAPSHOT_EPOCHS_CAPACITY,
Self::ERA_EPOCHS_CAPACITY,
);
// Check data-integrity for snapshot mpt with 4 threads.
if debug_snapshot_integrity {
Expand Down
5 changes: 5 additions & 0 deletions core/examples/snapshot_merge_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ fn main() -> Result<(), Error> {
delta_mpt_iterator,
info,
&storage_manager.snapshot_info_map_by_epoch,
height,
)?;
storage_manager.register_new_snapshot(
snapshot_info1.clone(),
Expand Down Expand Up @@ -168,6 +169,7 @@ fn main() -> Result<(), Error> {
delta_mpt_iterator,
info,
&storage_manager.snapshot_info_map_by_epoch,
height,
)?;
println!(
"After merging: {:?}, accounts size {}",
Expand All @@ -182,6 +184,7 @@ fn main() -> Result<(), Error> {
.get_snapshot_by_epoch_id(
&snapshot2_epoch,
/* try_open = */ false,
true,
)?
.expect("exists");
for (addr, account) in &accounts_map {
Expand Down Expand Up @@ -232,6 +235,7 @@ fn main() -> Result<(), Error> {
delta_mpt_iterator,
info,
&storage_manager.snapshot_info_map_by_epoch,
height,
)?;
storage_manager.register_new_snapshot(
snapshot_info3.clone(),
Expand Down Expand Up @@ -293,6 +297,7 @@ fn new_state_manager(
let mut storage_conf = StorageConfiguration::new_default(
conflux_data_dir,
cfx_parameters::consensus::SNAPSHOT_EPOCHS_CAPACITY,
cfx_parameters::consensus::ERA_DEFAULT_EPOCH_COUNT,
);
storage_conf.consensus_param.snapshot_epoch_count = 10000000;
Ok(Arc::new(StateManager::new(storage_conf).unwrap()))
Expand Down
Loading

0 comments on commit 2ec2f96

Please sign in to comment.