From fae2d5efb64b720239b1886c28aaacde35e12464 Mon Sep 17 00:00:00 2001
From: 0g-peterzhb <158457852+0g-peterzhb@users.noreply.github.com>
Date: Fri, 8 Nov 2024 22:06:45 +0800
Subject: [PATCH] @peter/db split (#262)
* do not pad tx during sync phase
* add pad data store
* support async padding after sync phase
* split misc
* add sleep for the next loop
---
common/contract-interface/src/lib.rs | 12 +-
node/log_entry_sync/src/sync_manager/mod.rs | 4 +
node/miner/src/miner_id.rs | 7 +-
node/pruner/src/lib.rs | 13 +-
node/router/src/libp2p_event_handler.rs | 3 +-
node/src/client/builder.rs | 5 +-
node/storage-async/src/lib.rs | 8 +-
node/storage/benches/benchmark.rs | 30 +---
node/storage/src/log_store/config.rs | 91 +++++++++---
node/storage/src/log_store/flow_store.rs | 69 ++++++++-
node/storage/src/log_store/log_manager.rs | 154 +++++++++++---------
node/storage/src/log_store/mod.rs | 31 ++++
node/storage/src/log_store/tests.rs | 12 +-
node/sync/src/auto_sync/sync_store.rs | 19 ++-
node/sync/src/auto_sync/tx_store.rs | 11 +-
node/sync/src/controllers/serial.rs | 2 +-
node/sync/src/service.rs | 4 +-
node/sync/src/test_util.rs | 14 +-
18 files changed, 309 insertions(+), 180 deletions(-)
diff --git a/common/contract-interface/src/lib.rs b/common/contract-interface/src/lib.rs
index 5e3badb..900f189 100644
--- a/common/contract-interface/src/lib.rs
+++ b/common/contract-interface/src/lib.rs
@@ -15,19 +15,13 @@ abigen!(
);
#[cfg(feature = "dev")]
-abigen!(
- ZgsFlow,
- "../../0g-storage-contracts-dev/artifacts/contracts/dataFlow/Flow.sol/Flow.json"
-);
+abigen!(ZgsFlow, "../../storage-contracts-abis/Flow.json");
#[cfg(feature = "dev")]
-abigen!(
- PoraMine,
- "../../0g-storage-contracts-dev/artifacts/contracts/miner/Mine.sol/PoraMine.json"
-);
+abigen!(PoraMine, "../../storage-contracts-abis/PoraMine.json");
#[cfg(feature = "dev")]
abigen!(
ChunkLinearReward,
- "../../0g-storage-contracts-dev/artifacts/contracts/reward/ChunkLinearReward.sol/ChunkLinearReward.json"
+ "../../storage-contracts-abis/ChunkLinearReward.json"
);
diff --git a/node/log_entry_sync/src/sync_manager/mod.rs b/node/log_entry_sync/src/sync_manager/mod.rs
index 8c07d8d..2412990 100644
--- a/node/log_entry_sync/src/sync_manager/mod.rs
+++ b/node/log_entry_sync/src/sync_manager/mod.rs
@@ -277,6 +277,9 @@ impl LogSyncManager {
.remove_finalized_block_interval_minutes,
);
+ // start the pad data store
+ log_sync_manager.store.start_padding(&executor_clone);
+
let (watch_progress_tx, watch_progress_rx) =
tokio::sync::mpsc::unbounded_channel();
let watch_rx = log_sync_manager.log_fetcher.start_watch(
@@ -509,6 +512,7 @@ impl LogSyncManager {
}
}
self.data_cache.garbage_collect(self.next_tx_seq);
+
self.next_tx_seq += 1;
// Check if the computed data root matches on-chain state.
diff --git a/node/miner/src/miner_id.rs b/node/miner/src/miner_id.rs
index bf638d5..16f692f 100644
--- a/node/miner/src/miner_id.rs
+++ b/node/miner/src/miner_id.rs
@@ -5,17 +5,20 @@ use ethereum_types::Address;
use ethers::contract::ContractCall;
use ethers::contract::EthEvent;
use std::sync::Arc;
+use storage::log_store::log_manager::DATA_DB_KEY;
use storage::H256;
use storage_async::Store;
const MINER_ID: &str = "mine.miner_id";
pub async fn load_miner_id(store: &Store) -> storage::error::Result