mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-11-20 15:05:19 +00:00
Compare commits
4 Commits
23d25b3453
...
b0e273e141
Author | SHA1 | Date | |
---|---|---|---|
|
b0e273e141 | ||
|
1dd7bf7734 | ||
|
5849e9c2ba | ||
|
b7badcda5e |
@ -6,12 +6,13 @@ use ethereum_types::H256;
|
||||
use ethers::{prelude::Middleware, types::BlockNumber};
|
||||
use futures::FutureExt;
|
||||
use jsonrpsee::tracing::{debug, error, warn};
|
||||
use shared_types::{ChunkArray, Transaction};
|
||||
use shared_types::{bytes_to_chunks, ChunkArray, Transaction};
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::Debug;
|
||||
use std::future::Future;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
use storage::log_store::log_manager::sector_to_segment;
|
||||
use storage::log_store::{tx_store::BlockHashAndSubmissionIndex, Store};
|
||||
use task_executor::{ShutdownReason, TaskExecutor};
|
||||
use thiserror::Error;
|
||||
@ -477,6 +478,17 @@ impl LogSyncManager {
|
||||
error!("put_tx data error: e={:?}", e);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
let store = self.store.clone();
|
||||
let shard_config = store.flow().get_shard_config();
|
||||
if sector_to_segment(bytes_to_chunks(tx.size as usize) as u64)
|
||||
< shard_config.shard_id
|
||||
{
|
||||
if let Err(e) = store.finalize_tx_with_hash(tx.seq, tx.hash()) {
|
||||
error!("finalize file that does not need to store: e={:?}", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
self.data_cache.garbage_collect(self.next_tx_seq);
|
||||
self.next_tx_seq += 1;
|
||||
|
@ -198,11 +198,11 @@ impl Pruner {
|
||||
))),
|
||||
Ordering::Equal => Ok(None),
|
||||
Ordering::Greater => {
|
||||
bail!(
|
||||
error!(
|
||||
"Unexpected first_rewardable_chunk revert: old={} new={}",
|
||||
self.first_rewardable_chunk,
|
||||
new_first_rewardable
|
||||
self.first_rewardable_chunk, new_first_rewardable
|
||||
);
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -261,30 +261,30 @@ mod tests {
|
||||
#[test]
|
||||
fn test_shard_intersect() {
|
||||
// 1 shard
|
||||
assert_eq!(new_config(0, 1).intersect(&new_config(0, 1)), true);
|
||||
assert!(new_config(0, 1).intersect(&new_config(0, 1)));
|
||||
|
||||
// either is 1 shard
|
||||
assert_eq!(new_config(0, 1).intersect(&new_config(0, 2)), true);
|
||||
assert_eq!(new_config(0, 1).intersect(&new_config(1, 2)), true);
|
||||
assert_eq!(new_config(0, 2).intersect(&new_config(0, 1)), true);
|
||||
assert_eq!(new_config(1, 2).intersect(&new_config(0, 1)), true);
|
||||
assert!(new_config(0, 1).intersect(&new_config(0, 2)));
|
||||
assert!(new_config(0, 1).intersect(&new_config(1, 2)));
|
||||
assert!(new_config(0, 2).intersect(&new_config(0, 1)));
|
||||
assert!(new_config(1, 2).intersect(&new_config(0, 1)));
|
||||
|
||||
// same shards
|
||||
assert_eq!(new_config(1, 4).intersect(&new_config(0, 4)), false);
|
||||
assert_eq!(new_config(1, 4).intersect(&new_config(1, 4)), true);
|
||||
assert_eq!(new_config(1, 4).intersect(&new_config(2, 4)), false);
|
||||
assert_eq!(new_config(1, 4).intersect(&new_config(3, 4)), false);
|
||||
assert!(!new_config(1, 4).intersect(&new_config(0, 4)));
|
||||
assert!(new_config(1, 4).intersect(&new_config(1, 4)));
|
||||
assert!(!new_config(1, 4).intersect(&new_config(2, 4)));
|
||||
assert!(!new_config(1, 4).intersect(&new_config(3, 4)));
|
||||
|
||||
// left shards is less
|
||||
assert_eq!(new_config(1, 2).intersect(&new_config(0, 4)), false);
|
||||
assert_eq!(new_config(1, 2).intersect(&new_config(1, 4)), false);
|
||||
assert_eq!(new_config(1, 2).intersect(&new_config(2, 4)), true);
|
||||
assert_eq!(new_config(1, 2).intersect(&new_config(3, 4)), true);
|
||||
assert!(!new_config(1, 2).intersect(&new_config(0, 4)));
|
||||
assert!(!new_config(1, 2).intersect(&new_config(1, 4)));
|
||||
assert!(new_config(1, 2).intersect(&new_config(2, 4)));
|
||||
assert!(new_config(1, 2).intersect(&new_config(3, 4)));
|
||||
|
||||
// right shards is less
|
||||
assert_eq!(new_config(1, 4).intersect(&new_config(0, 2)), true);
|
||||
assert_eq!(new_config(1, 4).intersect(&new_config(1, 2)), false);
|
||||
assert_eq!(new_config(2, 4).intersect(&new_config(0, 2)), false);
|
||||
assert_eq!(new_config(2, 4).intersect(&new_config(1, 2)), true);
|
||||
assert!(new_config(1, 4).intersect(&new_config(0, 2)));
|
||||
assert!(!new_config(1, 4).intersect(&new_config(1, 2)));
|
||||
assert!(!new_config(2, 4).intersect(&new_config(0, 2)));
|
||||
assert!(new_config(2, 4).intersect(&new_config(1, 2)));
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,12 @@ jq --version >/dev/null 2>&1 || sudo snap install jq -y
|
||||
|
||||
mkdir -p $ROOT_DIR
|
||||
|
||||
SED_I="sed -i"
|
||||
OS_NAME=`uname -o`
|
||||
if [[ "$OS_NAME" = "Darwin" ]]; then
|
||||
SED_I="sed -i ''"
|
||||
fi
|
||||
|
||||
# Init configs
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
$BINARY init node$i --home $ROOT_DIR/node$i --chain-id $CHAIN_ID
|
||||
@ -22,10 +28,10 @@ for ((i=0; i<$NUM_NODES; i++)) do
|
||||
TMP_GENESIS=$ROOT_DIR/node$i/config/tmp_genesis.json
|
||||
|
||||
# Replace stake with neuron
|
||||
sed -in-place='' 's/stake/ua0gi/g' "$GENESIS"
|
||||
$SED_I 's/stake/ua0gi/g' "$GENESIS"
|
||||
|
||||
# Replace the default evm denom of aphoton with neuron
|
||||
sed -in-place='' 's/aphoton/neuron/g' "$GENESIS"
|
||||
$SED_I 's/aphoton/neuron/g' "$GENESIS"
|
||||
|
||||
cat $GENESIS | jq '.consensus_params.block.max_gas = "25000000"' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
@ -53,24 +59,24 @@ for ((i=0; i<$NUM_NODES; i++)) do
|
||||
|
||||
# Change app.toml
|
||||
APP_TOML=$ROOT_DIR/node$i/config/app.toml
|
||||
sed -i 's/minimum-gas-prices = "0ua0gi"/minimum-gas-prices = "1000000000neuron"/' $APP_TOML
|
||||
sed -i '/\[grpc\]/,/^\[/ s/enable = true/enable = false/' $APP_TOML
|
||||
sed -i '/\[grpc-web\]/,/^\[/ s/enable = true/enable = false/' $APP_TOML
|
||||
sed -i '/\[json-rpc\]/,/^\[/ s/enable = false/enable = true/' $APP_TOML
|
||||
$SED_I 's/minimum-gas-prices = "0ua0gi"/minimum-gas-prices = "1000000000neuron"/' $APP_TOML
|
||||
$SED_I '/\[grpc\]/,/^\[/ s/enable = true/enable = false/' $APP_TOML
|
||||
$SED_I '/\[grpc-web\]/,/^\[/ s/enable = true/enable = false/' $APP_TOML
|
||||
$SED_I '/\[json-rpc\]/,/^\[/ s/enable = false/enable = true/' $APP_TOML
|
||||
|
||||
# Change config.toml
|
||||
CONFIG_TOML=$ROOT_DIR/node$i/config/config.toml
|
||||
sed -i '/seeds = /c\seeds = ""' $CONFIG_TOML
|
||||
sed -i 's/addr_book_strict = true/addr_book_strict = false/' $CONFIG_TOML
|
||||
# $SED_I '/seeds = /c\seeds = ""' $CONFIG_TOML
|
||||
$SED_I 's/addr_book_strict = true/addr_book_strict = false/' $CONFIG_TOML
|
||||
|
||||
# Change block time to very small
|
||||
sed -i '/timeout_propose = "3s"/c\timeout_propose = "300ms"' $CONFIG_TOML
|
||||
sed -i '/timeout_propose_delta = "500ms"/c\timeout_propose_delta = "50ms"' $CONFIG_TOML
|
||||
sed -i '/timeout_prevote = "1s"/c\timeout_prevote = "100ms"' $CONFIG_TOML
|
||||
sed -i '/timeout_prevote_delta = "500ms"/c\timeout_prevote_delta = "50ms"' $CONFIG_TOML
|
||||
sed -i '/timeout_precommit = "1s"/c\timeout_precommit = "100ms"' $CONFIG_TOML
|
||||
sed -i '/timeout_precommit_delta = "500ms"/c\timeout_precommit_delta = "50ms"' $CONFIG_TOML
|
||||
sed -i '/timeout_commit = "5s"/c\timeout_commit = "500ms"' $CONFIG_TOML
|
||||
$SED_I 's/timeout_propose = "3s"/timeout_propose = "300ms"/' $CONFIG_TOML
|
||||
$SED_I 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "50ms"/' $CONFIG_TOML
|
||||
$SED_I 's/timeout_prevote = "1s"/timeout_prevote = "100ms"/' $CONFIG_TOML
|
||||
$SED_I 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "50ms"/' $CONFIG_TOML
|
||||
$SED_I 's/timeout_precommit = "1s"/timeout_precommit = "100ms"/' $CONFIG_TOML
|
||||
$SED_I 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "50ms"/' $CONFIG_TOML
|
||||
$SED_I 's/timeout_commit = "5s"/timeout_commit = "500ms"/' $CONFIG_TOML
|
||||
done
|
||||
|
||||
# Update persistent_peers in config.toml
|
||||
@ -82,7 +88,7 @@ for ((i=1; i<$NUM_NODES; i++)) do
|
||||
P2P_PORT=$(($P2P_PORT_START+$j))
|
||||
PERSISTENT_NODES=$PERSISTENT_NODES$NODE_ID@127.0.0.1:$P2P_PORT
|
||||
done
|
||||
sed -i "/persistent_peers = /c\persistent_peers = \"$PERSISTENT_NODES\"" $ROOT_DIR/node$i/config/config.toml
|
||||
$SED_I "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_NODES\"/" $ROOT_DIR/node$i/config/config.toml
|
||||
done
|
||||
|
||||
# Create genesis with a single validator
|
||||
|
Loading…
Reference in New Issue
Block a user