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 ethers::{prelude::Middleware, types::BlockNumber};
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use jsonrpsee::tracing::{debug, error, warn};
|
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::collections::BTreeMap;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
use storage::log_store::log_manager::sector_to_segment;
|
||||||
use storage::log_store::{tx_store::BlockHashAndSubmissionIndex, Store};
|
use storage::log_store::{tx_store::BlockHashAndSubmissionIndex, Store};
|
||||||
use task_executor::{ShutdownReason, TaskExecutor};
|
use task_executor::{ShutdownReason, TaskExecutor};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
@ -477,6 +478,17 @@ impl LogSyncManager {
|
|||||||
error!("put_tx data error: e={:?}", e);
|
error!("put_tx data error: e={:?}", e);
|
||||||
return false;
|
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.data_cache.garbage_collect(self.next_tx_seq);
|
||||||
self.next_tx_seq += 1;
|
self.next_tx_seq += 1;
|
||||||
|
@ -198,11 +198,11 @@ impl Pruner {
|
|||||||
))),
|
))),
|
||||||
Ordering::Equal => Ok(None),
|
Ordering::Equal => Ok(None),
|
||||||
Ordering::Greater => {
|
Ordering::Greater => {
|
||||||
bail!(
|
error!(
|
||||||
"Unexpected first_rewardable_chunk revert: old={} new={}",
|
"Unexpected first_rewardable_chunk revert: old={} new={}",
|
||||||
self.first_rewardable_chunk,
|
self.first_rewardable_chunk, new_first_rewardable
|
||||||
new_first_rewardable
|
|
||||||
);
|
);
|
||||||
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,30 +261,30 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_shard_intersect() {
|
fn test_shard_intersect() {
|
||||||
// 1 shard
|
// 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
|
// either is 1 shard
|
||||||
assert_eq!(new_config(0, 1).intersect(&new_config(0, 2)), true);
|
assert!(new_config(0, 1).intersect(&new_config(0, 2)));
|
||||||
assert_eq!(new_config(0, 1).intersect(&new_config(1, 2)), true);
|
assert!(new_config(0, 1).intersect(&new_config(1, 2)));
|
||||||
assert_eq!(new_config(0, 2).intersect(&new_config(0, 1)), true);
|
assert!(new_config(0, 2).intersect(&new_config(0, 1)));
|
||||||
assert_eq!(new_config(1, 2).intersect(&new_config(0, 1)), true);
|
assert!(new_config(1, 2).intersect(&new_config(0, 1)));
|
||||||
|
|
||||||
// same shards
|
// same shards
|
||||||
assert_eq!(new_config(1, 4).intersect(&new_config(0, 4)), false);
|
assert!(!new_config(1, 4).intersect(&new_config(0, 4)));
|
||||||
assert_eq!(new_config(1, 4).intersect(&new_config(1, 4)), true);
|
assert!(new_config(1, 4).intersect(&new_config(1, 4)));
|
||||||
assert_eq!(new_config(1, 4).intersect(&new_config(2, 4)), false);
|
assert!(!new_config(1, 4).intersect(&new_config(2, 4)));
|
||||||
assert_eq!(new_config(1, 4).intersect(&new_config(3, 4)), false);
|
assert!(!new_config(1, 4).intersect(&new_config(3, 4)));
|
||||||
|
|
||||||
// left shards is less
|
// left shards is less
|
||||||
assert_eq!(new_config(1, 2).intersect(&new_config(0, 4)), false);
|
assert!(!new_config(1, 2).intersect(&new_config(0, 4)));
|
||||||
assert_eq!(new_config(1, 2).intersect(&new_config(1, 4)), false);
|
assert!(!new_config(1, 2).intersect(&new_config(1, 4)));
|
||||||
assert_eq!(new_config(1, 2).intersect(&new_config(2, 4)), true);
|
assert!(new_config(1, 2).intersect(&new_config(2, 4)));
|
||||||
assert_eq!(new_config(1, 2).intersect(&new_config(3, 4)), true);
|
assert!(new_config(1, 2).intersect(&new_config(3, 4)));
|
||||||
|
|
||||||
// right shards is less
|
// right shards is less
|
||||||
assert_eq!(new_config(1, 4).intersect(&new_config(0, 2)), true);
|
assert!(new_config(1, 4).intersect(&new_config(0, 2)));
|
||||||
assert_eq!(new_config(1, 4).intersect(&new_config(1, 2)), false);
|
assert!(!new_config(1, 4).intersect(&new_config(1, 2)));
|
||||||
assert_eq!(new_config(2, 4).intersect(&new_config(0, 2)), false);
|
assert!(!new_config(2, 4).intersect(&new_config(0, 2)));
|
||||||
assert_eq!(new_config(2, 4).intersect(&new_config(1, 2)), true);
|
assert!(new_config(2, 4).intersect(&new_config(1, 2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
# List of nodes to bootstrap UDP discovery. Note, `network_enr_address` should be
|
# List of nodes to bootstrap UDP discovery. Note, `network_enr_address` should be
|
||||||
# configured as well to enable UDP discovery.
|
# configured as well to enable UDP discovery.
|
||||||
network_boot_nodes = ["/ip4/35.95.5.134/udp/1234/p2p/16Uiu2HAmFGrDV8wKToa1dd8uh6bz8bSY28n33iRP3pvfeBU6ysCw","/ip4/35.84.189.77/udp/1234/p2p/16Uiu2HAmF7t5iuRoWLMvQVfHbbJr5TFgHo2oU1CDxJm56eLdxRAY","/ip4/8.154.34.28/udp/1234/p2p/16Uiu2HAmBb7PQzvfZjHBENcF7E7mZaiHSrpBoH7mKTyNijYdqMM6"]
|
network_boot_nodes = ["/ip4/52.24.167.216/udp/1234/p2p/16Uiu2HAmFGrDV8wKToa1dd8uh6bz8bSY28n33iRP3pvfeBU6ysCw","/ip4/44.237.182.79/udp/1234/p2p/16Uiu2HAmF7t5iuRoWLMvQVfHbbJr5TFgHo2oU1CDxJm56eLdxRAY","/ip4/47.97.193.51/udp/1234/p2p/16Uiu2HAmBb7PQzvfZjHBENcF7E7mZaiHSrpBoH7mKTyNijYdqMM6"]
|
||||||
|
|
||||||
# List of libp2p nodes to initially connect to.
|
# List of libp2p nodes to initially connect to.
|
||||||
# network_libp2p_nodes = []
|
# network_libp2p_nodes = []
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
# List of nodes to bootstrap UDP discovery. Note, `network_enr_address` should be
|
# List of nodes to bootstrap UDP discovery. Note, `network_enr_address` should be
|
||||||
# configured as well to enable UDP discovery.
|
# configured as well to enable UDP discovery.
|
||||||
network_boot_nodes = ["/ip4/54.219.26.22/udp/1234/p2p/16Uiu2HAmTVDGNhkHD98zDnJxQWu3i1FL1aFYeh9wiQTNu4pDCgps","/ip4/52.52.127.117/udp/1234/p2p/16Uiu2HAkzRjxK2gorngB1Xq84qDrT4hSVznYDHj6BkbaE4SGx9oS","/ip4/8.154.47.100/udp/1234/p2p/16Uiu2HAm2k6ua2mGgvZ8rTMV8GhpW71aVzkQWy7D37TTDuLCpgmX"]
|
network_boot_nodes = ["/ip4/54.219.26.22/udp/1234/p2p/16Uiu2HAmTVDGNhkHD98zDnJxQWu3i1FL1aFYeh9wiQTNu4pDCgps","/ip4/52.52.127.117/udp/1234/p2p/16Uiu2HAkzRjxK2gorngB1Xq84qDrT4hSVznYDHj6BkbaE4SGx9oS","/ip4/121.43.181.26/udp/1234/p2p/16Uiu2HAm2k6ua2mGgvZ8rTMV8GhpW71aVzkQWy7D37TTDuLCpgmX"]
|
||||||
|
|
||||||
# List of libp2p nodes to initially connect to.
|
# List of libp2p nodes to initially connect to.
|
||||||
# network_libp2p_nodes = []
|
# network_libp2p_nodes = []
|
||||||
|
@ -13,6 +13,12 @@ jq --version >/dev/null 2>&1 || sudo snap install jq -y
|
|||||||
|
|
||||||
mkdir -p $ROOT_DIR
|
mkdir -p $ROOT_DIR
|
||||||
|
|
||||||
|
SED_I="sed -i"
|
||||||
|
OS_NAME=`uname -o`
|
||||||
|
if [[ "$OS_NAME" = "Darwin" ]]; then
|
||||||
|
SED_I="sed -i ''"
|
||||||
|
fi
|
||||||
|
|
||||||
# Init configs
|
# Init configs
|
||||||
for ((i=0; i<$NUM_NODES; i++)) do
|
for ((i=0; i<$NUM_NODES; i++)) do
|
||||||
$BINARY init node$i --home $ROOT_DIR/node$i --chain-id $CHAIN_ID
|
$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
|
TMP_GENESIS=$ROOT_DIR/node$i/config/tmp_genesis.json
|
||||||
|
|
||||||
# Replace stake with neuron
|
# 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
|
# 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
|
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
|
# Change app.toml
|
||||||
APP_TOML=$ROOT_DIR/node$i/config/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 's/minimum-gas-prices = "0ua0gi"/minimum-gas-prices = "1000000000neuron"/' $APP_TOML
|
||||||
sed -i '/\[grpc\]/,/^\[/ s/enable = true/enable = false/' $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 '/\[grpc-web\]/,/^\[/ s/enable = true/enable = false/' $APP_TOML
|
||||||
sed -i '/\[json-rpc\]/,/^\[/ s/enable = false/enable = true/' $APP_TOML
|
$SED_I '/\[json-rpc\]/,/^\[/ s/enable = false/enable = true/' $APP_TOML
|
||||||
|
|
||||||
# Change config.toml
|
# Change config.toml
|
||||||
CONFIG_TOML=$ROOT_DIR/node$i/config/config.toml
|
CONFIG_TOML=$ROOT_DIR/node$i/config/config.toml
|
||||||
sed -i '/seeds = /c\seeds = ""' $CONFIG_TOML
|
# $SED_I '/seeds = /c\seeds = ""' $CONFIG_TOML
|
||||||
sed -i 's/addr_book_strict = true/addr_book_strict = false/' $CONFIG_TOML
|
$SED_I 's/addr_book_strict = true/addr_book_strict = false/' $CONFIG_TOML
|
||||||
|
|
||||||
# Change block time to very small
|
# Change block time to very small
|
||||||
sed -i '/timeout_propose = "3s"/c\timeout_propose = "300ms"' $CONFIG_TOML
|
$SED_I 's/timeout_propose = "3s"/timeout_propose = "300ms"/' $CONFIG_TOML
|
||||||
sed -i '/timeout_propose_delta = "500ms"/c\timeout_propose_delta = "50ms"' $CONFIG_TOML
|
$SED_I 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "50ms"/' $CONFIG_TOML
|
||||||
sed -i '/timeout_prevote = "1s"/c\timeout_prevote = "100ms"' $CONFIG_TOML
|
$SED_I 's/timeout_prevote = "1s"/timeout_prevote = "100ms"/' $CONFIG_TOML
|
||||||
sed -i '/timeout_prevote_delta = "500ms"/c\timeout_prevote_delta = "50ms"' $CONFIG_TOML
|
$SED_I 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "50ms"/' $CONFIG_TOML
|
||||||
sed -i '/timeout_precommit = "1s"/c\timeout_precommit = "100ms"' $CONFIG_TOML
|
$SED_I 's/timeout_precommit = "1s"/timeout_precommit = "100ms"/' $CONFIG_TOML
|
||||||
sed -i '/timeout_precommit_delta = "500ms"/c\timeout_precommit_delta = "50ms"' $CONFIG_TOML
|
$SED_I 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "50ms"/' $CONFIG_TOML
|
||||||
sed -i '/timeout_commit = "5s"/c\timeout_commit = "500ms"' $CONFIG_TOML
|
$SED_I 's/timeout_commit = "5s"/timeout_commit = "500ms"/' $CONFIG_TOML
|
||||||
done
|
done
|
||||||
|
|
||||||
# Update persistent_peers in config.toml
|
# Update persistent_peers in config.toml
|
||||||
@ -82,7 +88,7 @@ for ((i=1; i<$NUM_NODES; i++)) do
|
|||||||
P2P_PORT=$(($P2P_PORT_START+$j))
|
P2P_PORT=$(($P2P_PORT_START+$j))
|
||||||
PERSISTENT_NODES=$PERSISTENT_NODES$NODE_ID@127.0.0.1:$P2P_PORT
|
PERSISTENT_NODES=$PERSISTENT_NODES$NODE_ID@127.0.0.1:$P2P_PORT
|
||||||
done
|
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
|
done
|
||||||
|
|
||||||
# Create genesis with a single validator
|
# Create genesis with a single validator
|
||||||
|
Loading…
Reference in New Issue
Block a user