mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-11-10 10:05:17 +00:00
Compare commits
3 Commits
bc51d8dffb
...
153fb34015
Author | SHA1 | Date | |
---|---|---|---|
|
153fb34015 | ||
|
29fcc415a6 | ||
|
bf3694d138 |
@ -238,6 +238,10 @@ impl PoraService {
|
||||
return Err("too many mine shards");
|
||||
}
|
||||
|
||||
if puzzle.context.flow_length <= U256::one() {
|
||||
return Err("no data submitted");
|
||||
}
|
||||
|
||||
if self.mine_range.shard_config.num_shard as u64 > puzzle.context.flow_length.as_u64() {
|
||||
return Err("Not enough flow length to shard");
|
||||
}
|
||||
|
@ -90,6 +90,14 @@ impl FlowStore {
|
||||
}
|
||||
self.db.delete_batch_list(batch_list)
|
||||
}
|
||||
|
||||
pub fn get_raw_batch(&self, batch_index: u64) -> Result<Option<EntryBatch>> {
|
||||
self.db.get_entry_batch(batch_index)
|
||||
}
|
||||
|
||||
pub fn get_batch_root(&self, batch_index: u64) -> Result<Option<DataRoot>> {
|
||||
self.db.get_batch_root(batch_index)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@ -575,6 +583,13 @@ impl FlowDBStore {
|
||||
}
|
||||
Ok(self.kvdb.write(tx)?)
|
||||
}
|
||||
|
||||
fn get_batch_root(&self, batch_index: u64) -> Result<Option<DataRoot>> {
|
||||
Ok(self
|
||||
.kvdb
|
||||
.get(COL_ENTRY_BATCH_ROOT, &batch_index.to_be_bytes())?
|
||||
.map(|v| DataRoot::from_slice(&v)))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveEncode, DeriveDecode, Clone, Debug)]
|
||||
|
@ -6,6 +6,7 @@ use std::mem;
|
||||
use tracing::error;
|
||||
use zgs_spec::{BYTES_PER_LOAD, BYTES_PER_SECTOR, SECTORS_PER_LOAD, SECTORS_PER_SEAL};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum EntryBatchData {
|
||||
Complete(Vec<u8>),
|
||||
/// All `PartialBatch`s are ordered based on `start_index`.
|
||||
|
@ -23,7 +23,7 @@ use super::SealAnswer;
|
||||
use chunk_data::EntryBatchData;
|
||||
use seal::SealInfo;
|
||||
|
||||
#[derive(Encode, Decode)]
|
||||
#[derive(Debug, Encode, Decode)]
|
||||
pub struct EntryBatch {
|
||||
seal: SealInfo,
|
||||
// the inner data
|
||||
|
@ -19,7 +19,7 @@ pub struct SealContextInfo {
|
||||
type ChunkSealBitmap = WrappedBitmap<SEALS_PER_LOAD>;
|
||||
const_assert!(SEALS_PER_LOAD <= u128::BITS as usize);
|
||||
|
||||
#[derive(Default, DeriveEncode, DeriveDecode)]
|
||||
#[derive(Debug, Default, DeriveEncode, DeriveDecode)]
|
||||
pub struct SealInfo {
|
||||
// a bitmap specify which sealing chunks have been sealed
|
||||
bitmap: ChunkSealBitmap,
|
||||
|
@ -776,7 +776,21 @@ impl LogManager {
|
||||
.gen_proof(flow_index as usize % PORA_CHUNK_SIZE)?,
|
||||
}
|
||||
};
|
||||
entry_proof(&top_proof, &sub_proof)
|
||||
let r = entry_proof(&top_proof, &sub_proof);
|
||||
if r.is_err() {
|
||||
let raw_batch = self.flow_store.get_raw_batch(seg_index as u64)?;
|
||||
let db_root = self.flow_store.get_batch_root(seg_index as u64)?;
|
||||
error!(
|
||||
?r,
|
||||
?raw_batch,
|
||||
?db_root,
|
||||
?seg_index,
|
||||
"gen proof error: top_leaves={}, last={}",
|
||||
merkle.pora_chunks_merkle.leaves(),
|
||||
merkle.last_chunk_merkle.leaves()
|
||||
);
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
#[instrument(skip(self, merkle))]
|
||||
|
@ -13,7 +13,7 @@ class MineTest(TestFramework):
|
||||
self.zgs_node_configs[0] = {
|
||||
"miner_key": GENESIS_PRIV_KEY,
|
||||
}
|
||||
self.mine_period = int(40 / self.block_time)
|
||||
self.mine_period = int(45 / self.block_time)
|
||||
self.launch_wait_seconds = 15
|
||||
self.log.info("Contract Info: Est. block time %.2f, Mine period %d", self.block_time, self.mine_period)
|
||||
|
||||
@ -35,6 +35,11 @@ class MineTest(TestFramework):
|
||||
self.log.info("flow address: %s", self.contract.address())
|
||||
self.log.info("mine address: %s", self.mine_contract.address())
|
||||
|
||||
first_block = self.contract.first_block()
|
||||
self.log.info("Current block number %d", int(blockchain.eth_blockNumber(), 16))
|
||||
self.log.info("Flow deployment block number %d, epoch 1 start %d", first_block, first_block + self.mine_period)
|
||||
wait_until(lambda: self.contract.epoch() >= 1, timeout=180)
|
||||
|
||||
quality = int(2**256 / 100 / estimate_st_performance())
|
||||
self.mine_contract.set_quality(quality)
|
||||
|
||||
@ -71,6 +76,8 @@ class MineTest(TestFramework):
|
||||
self.log.info("Wait for the third mine answer")
|
||||
wait_until(lambda: self.mine_contract.last_mined_epoch() == start_epoch + 3 and not self.mine_contract.can_submit(), timeout=180)
|
||||
|
||||
self.log.info("Current block number %d", int(blockchain.eth_blockNumber(), 16))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
MineTest(blockchain_node_type=BlockChainNodeType.BSC).main()
|
||||
|
@ -21,7 +21,7 @@ class MineTest(TestFramework):
|
||||
"shard_position": "3 / 8",
|
||||
}
|
||||
self.enable_market = True
|
||||
self.mine_period = int(45 / self.block_time)
|
||||
self.mine_period = int(50 / self.block_time)
|
||||
self.launch_wait_seconds = 15
|
||||
self.log.info("Contract Info: Est. block time %.2f, Mine period %d", self.block_time, self.mine_period)
|
||||
|
||||
@ -50,6 +50,10 @@ class MineTest(TestFramework):
|
||||
|
||||
SECTORS_PER_PRICING = int(8 * ( 2 ** 30 ) / 256)
|
||||
|
||||
first_block = self.contract.first_block()
|
||||
self.log.info("Current block number %d", int(blockchain.eth_blockNumber(), 16))
|
||||
self.log.info("Flow deployment block number %d, epoch 1 start %d, wait for epoch 1 start", first_block, first_block + self.mine_period)
|
||||
wait_until(lambda: self.contract.epoch() >= 1, timeout=180)
|
||||
|
||||
self.log.info("Submit the actual data chunk (256 MB)")
|
||||
self.submit_data(b"\x11", int(SECTORS_PER_PRICING / 32))
|
||||
@ -98,6 +102,8 @@ class MineTest(TestFramework):
|
||||
|
||||
assert_greater_than(secondReward, 100 * firstReward / (start_epoch + 1))
|
||||
|
||||
self.log.info("Current block number %d", int(blockchain.eth_blockNumber(), 16))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
MineTest(blockchain_node_type=BlockChainNodeType.BSC).main()
|
||||
|
@ -30,9 +30,9 @@ class BlockChainNodeType(Enum):
|
||||
if self == BlockChainNodeType.Conflux:
|
||||
return 0.5
|
||||
elif self == BlockChainNodeType.BSC:
|
||||
return 25 / estimate_st_performance()
|
||||
return 32 / estimate_st_performance()
|
||||
else:
|
||||
return 3.0
|
||||
return 5.0
|
||||
|
||||
@unique
|
||||
class NodeType(Enum):
|
||||
|
@ -78,6 +78,7 @@ class ZGNode(BlockchainNode):
|
||||
"--rpc.laddr", "tcp://127.0.0.1:%s" % arrange_port(ZGNODE_PORT_CATEGORY_RPC, index),
|
||||
# overwrite pprof port: 6060
|
||||
"--rpc.pprof_laddr", "127.0.0.1:%s" % arrange_port(ZGNODE_PORT_CATEGORY_PPROF, index),
|
||||
"--log_level", "debug"
|
||||
]
|
||||
|
||||
for k, v in updated_config.items():
|
||||
|
Loading…
Reference in New Issue
Block a user