Skip to content

Commit

Permalink
Upgrade 0.21.0 localnet dev setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mario4tier committed Jan 15, 2023
1 parent 4dcb30d commit 1c04fbc
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 14 deletions.
14 changes: 14 additions & 0 deletions crates/dtp-core/src/types/stats.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#[derive(Default)]
pub struct PingStats {
pub ping_count_attempted: u8,
pub success_request: u8,
pub success_reply: u8,
pub connection_creation_time: u64, // milliseconds (can be zero)
pub min_round_trip_time: u64, // milliseconds
pub max_round_trip_time: u64, // milliseconds
pub avg_round_trip_time: u64, // milliseconds
pub min_gas_cost: u32, // Mist
pub avg_gas_cost: u32, // Mist
pub max_gas_cost: u32, // Mist
pub total_gas_cost: u32, // Mist
}
7 changes: 6 additions & 1 deletion docs/setup/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,9 @@ host:~/$


### Run DTP Integration Test (localnet)
~/dtp$ cargo test
~/dtp$ cargo test

When running integration tests, the test setup makes sure a localnet (sui process) and a peer DTP service Daemon (dtp process) simulate interacting with a remote peer.

This allows to automate your own client/server integration test of your own application on a single machine (Just need to make sure to use a different set of object coin, client address and localhost:port. More on this later).

2 changes: 1 addition & 1 deletion script/genesis_data/client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ envs:
rpc: "https://fullnode.devnet.sui.io:443"
ws: ~
active_env: localnet
active_address: "0xe7f134729591f52cf0638c2500a7ed228033a9e7"
active_address: "0xc7148f0c0086adf172eb4c2076c7d888337789a7"
10 changes: 5 additions & 5 deletions script/genesis_data/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ committee_size: 4
grpc_load_shed: ~
grpc_concurrency_limit: 20000000000
accounts:
- address: 267d4904898cbc15f165a18541154ec8c5732fcb
- address: 4e8b8c06d7aed3c11195794fa7b0469855c57b30
gas_objects:
- object_id: "0xd79b45b89580f92986a9d92b57feb96e6766fbab"
gas_value: 100000000000000
Expand All @@ -19,7 +19,7 @@ accounts:
- object_id: "0x3a713341f43998b53c20de40d9e67116049b37a6"
gas_value: 100000000000000
gas_object_ranges: []
- address: 68db58b41d97e4cf1ea7d9327036ebd306a7930a
- address: 5f11df8d90fef7a642d561aed0f2ee64de5c373c
gas_objects:
- object_id: "0x9463a9d0f5caee14ec695af6552339ab76f62fc5"
gas_value: 100000000000000
Expand All @@ -32,7 +32,7 @@ accounts:
- object_id: "0x7edba2f308678b0c606fcc6cd1546928ddb3dda1"
gas_value: 100000000000000
gas_object_ranges: []
- address: 99d821380348ee02dd685a3af6d7123d92db0d3c
- address: 8638a4d6438b399a77659463a25fdf2bdf0b229b
gas_objects:
- object_id: "0xc7c2cc2d8a52ab722d3fff5f023d92d3e6c83bf7"
gas_value: 100000000000000
Expand All @@ -45,7 +45,7 @@ accounts:
- object_id: "0x5138c6830ea4aa8cb765e0c43fd6b21ebb815abf"
gas_value: 100000000000000
gas_object_ranges: []
- address: bbd8d0695c369b04e9207fca4ef9f5f15b2c0de7
- address: 86f066b23d7e60ec4dbb280a4c265772c186693b
gas_objects:
- object_id: "0xd0fb870ac78a2388ceab2b6ce09429c049058804"
gas_value: 100000000000000
Expand All @@ -58,7 +58,7 @@ accounts:
- object_id: "0x750e819834b39ae10198ca4a6a586ebe0392e5a3"
gas_value: 100000000000000
gas_object_ranges: []
- address: e7f134729591f52cf0638c2500a7ed228033a9e7
- address: c7148f0c0086adf172eb4c2076c7d888337789a7
gas_objects:
- object_id: "0x2d43245a6af1f65847f7c18d5f6aabbd8e11299b"
gas_value: 100000000000000
Expand Down
10 changes: 5 additions & 5 deletions script/genesis_data/sui.keystore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
"ABwZKA6F2VxVw7KKjwUVvGpf+uok9PH+22ExgZA/dobUqh/YD1By71BoCYfjHZMMT9n+DAfSZeXfTW6gtbeh43Q=",
"AB1LmEtdi93his6hshtUdYkeDnkuGLCxavlXYmeS5NVqNJ6vmHhUpiA1U6q9EmtCB8anw6tGglTgvAC6uQfXyLs=",
"AF/pxDHny4DqN7FXndt2dF011ItsYl/JvEIUwGf75UK2mdS44C4WaxVcrI9tdhHpB6254cnJREPjhbN83SMPh9Q=",
"AIXH4RkMMMxLUcHUucwurU2kSOko9G6sF+T0AHZ05F1zRP9ru0YfwlZDOQT1fFs2C6MeZHMafF2kTv3DdIvXtOk=",
"AHnBYkzMJcs3pdVT+5iJrWDOCucROHJ7XPPalh3i/CKeHwoj7Co/nJuL2agdaySLZ55kPFw7aOQad1sRsHBPCpA="
"AFN+bYPrQaSnOtC0Jbo6C+EZQ8INYpcOfGvYEBLOv4La",
"AHMEXsGDQDUrGA0Q9pyBbwZn7ZdwRQJ1N66AY8BuWcuA",
"AOaWqbhk0ot+0mvHlmPixkNH1NbX+qc9QNGKHe5QD8hL",
"AGc10rcDgxkE1USHaLoDrwvoObCRhMvl1agEb6a5ShVY",
"AE6Ug8sqXgD7osbbb3SwrE7ELWbA825f47Le7BdeTB07"
]
2 changes: 1 addition & 1 deletion script/genesis_data/wallet_address.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0xe7f134729591f52cf0638c2500a7ed228033a9e7
0xc7148f0c0086adf172eb4c2076c7d888337789a7
40 changes: 39 additions & 1 deletion script/init-localnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,31 @@
# For future reference, this is how the config.yaml was generated:
# sui genesis --write-config "$GENESIS_DATA_DIR/config.yaml"

# Param
DEBUG_RUN=false
GENESIS=false
while [[ "$#" -gt 0 ]]; do
case $1 in
# -t|--target) target="$2"; shift ;; That's an example with a parameter
# -f|--flag) flag=1 ;; That's an example flag
-g|--genesis) GENESIS=true ;;
-d|--debug) DEBUG_RUN=true ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done


if [ "$GENESIS" = true ]; then
echo "Genesis flag set. Will regenerate the default client addresses and coin objects for localnet."
fi

if [ "$DEBUG_RUN" = true ]; then
echo "Debug flag set. Will run Localnet in foreground Ctrl-C to Exit"
fi

# Scripts does not work with version below these.
MIN_SUI_VERSION="sui 0.18.0"
MIN_SUI_VERSION="sui 0.21.0"
MIN_RUST_VERSION="rustc 1.65.0"

# Utility functions.
Expand Down Expand Up @@ -189,6 +212,13 @@ then
rm -rf "$RM_DIR"
fi

if [ "$GENESIS" = true ]; then
echo "Generating NEW genesis configuration file only"
$SUI_BIN_DIR/sui genesis --working-dir "$GENESIS_DATA_DIR" --write-config "$GENESIS_DATA_DIR/config.yaml.new"
diff "$GENESIS_DATA_DIR/config.yaml.new" "$GENESIS_DATA_DIR/config.yaml"
exit
fi

echo Creating new localnet directory
mkdir -p "$DEV_DIR/localnet"
$SUI_BIN_DIR/sui genesis --from-config "$GENESIS_DATA_DIR/config.yaml" --working-dir "$DEV_DIR/localnet" >& /dev/null
Expand All @@ -203,6 +233,14 @@ SEARCH_STRING="<PUT_WORKING_DIR_PATH_HERE>"
REPLACE_STRING="$DEV_DIR/localnet"
sed -i.bak -e "s+$SEARCH_STRING+$REPLACE_STRING+g" "$DEV_DIR/localnet/client.yaml" && rm "$DEV_DIR/localnet/client.yaml.bak"


# When need to start in foreground to debug.
if [ "$DEBUG_RUN" = true ]; then
echo "Starting new localnet process (foreground for debug)"
$SUI_BIN_DIR/sui start --network.config "$NETWORK_CONFIG"
exit
fi

# Start the new localnet.
echo "Starting new localnet process (may take up to 30 secs)"
$SUI_BIN_DIR/sui start --network.config "$NETWORK_CONFIG" >& "$DEV_DIR/localnet.log" &
Expand Down

0 comments on commit 1c04fbc

Please sign in to comment.