From f0d34dcb018b9edcd482a77b0b2231fe81946185 Mon Sep 17 00:00:00 2001 From: Anthony Graignic <anthony.graignic@uca.fr> Date: Tue, 9 Jan 2024 11:30:31 +0100 Subject: [PATCH 1/2] Update testnets scripts & readme --- README.md | 14 +++++++++ scripts/t0-1mine-2sync.sh | 8 +++-- scripts/t1-1mine-with-simulation-2sync.sh | 8 +++-- scripts/t2-n-miners-m-sync.sh | 38 +++++++++++++++++++++++ 4 files changed, 62 insertions(+), 6 deletions(-) create mode 100755 scripts/t2-n-miners-m-sync.sh diff --git a/README.md b/README.md index 4e1cc62..937a0ce 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,22 @@ flowchart LR end ``` +## Network Tests + +Scripts in `./scripts` are useful to test an EcoMobiCoin network. + +| Script | Scope | +| -------------------------------- | ------------------------------------------------------------------------------------------ | +| `t0-1mine-2sync.sh` | 1 node mine an empty block every X seconds, the others sync | +| `t1-1mine-with-simulation-2sync` | 1 node mine a block with bxs from simulation data every X seconds, the others sync | +| `t2-n-miners-m-sync.sh` | 2 nodes in turn mine blocks with bxs from simulation data every X seconds, the others sync | + ## Development +Build the project for dev with `cargo build` or release with `cargo build --release` + +Run unit tests with `cargo test` + ### Auto-Reloading Development Server `cargo watch -x run` diff --git a/scripts/t0-1mine-2sync.sh b/scripts/t0-1mine-2sync.sh index f8c7983..3dd826e 100755 --- a/scripts/t0-1mine-2sync.sh +++ b/scripts/t0-1mine-2sync.sh @@ -2,11 +2,13 @@ export MINER_SIGNING_KEY=4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318; # MINER_SIGNING_KEY & MNEMONIC env vars are set on workstation. -export CHAIN_ID=6363; # 12 sec BLOCK_TIME=12; -export RPC_URL=http://ecomobicoin-1.cri.local.isima.fr:8545; +# export RPC_URL=http://ecomobicoin-1.cri.local.isima.fr:8545; +# export CHAIN_ID=6363; +export RPC_URL=http://127.0.0.1:8545; +export CHAIN_ID=636363; # Mine on eco1 with `--max-block 0` # @@ -16,7 +18,7 @@ export RPC_URL=http://ecomobicoin-1.cri.local.isima.fr:8545; # ./truite --chain-spec-file clermont-bootnode.ron --no-dns-discovery --cidr 192.168.0.0/16 --rpc-listen-address 0.0.0.0:8545 # -# Mine every 10 secs or number of blocks +# Mine for ((i=1; i<=100; i++)) do echo "MINE $i/100"; diff --git a/scripts/t1-1mine-with-simulation-2sync.sh b/scripts/t1-1mine-with-simulation-2sync.sh index d536649..c8d6321 100755 --- a/scripts/t1-1mine-with-simulation-2sync.sh +++ b/scripts/t1-1mine-with-simulation-2sync.sh @@ -3,13 +3,15 @@ export MINER_SIGNING_KEY=4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01 export MNEMONIC='before exclude interest push zone jealous boat ice chimney juice young side diagram silent pipe'; # MINER_SIGNING_KEY & MNEMONIC env vars are set on workstation. -export CHAIN_ID=6363; # 30 mins TOTAL_SIMULATION_TIME=1800; # 12 sec BLOCK_TIME=12; -export RPC_URL=http://ecomobicoin-1.cri.local.isima.fr:8545; +# export RPC_URL=http://ecomobicoin-1.cri.local.isima.fr:8545; +# export CHAIN_ID=6363; +export RPC_URL=http://127.0.0.1:8545; +export CHAIN_ID=636363; # Mine on eco1 with `--max-block 0` # @@ -22,7 +24,7 @@ export RPC_URL=http://ecomobicoin-1.cri.local.isima.fr:8545; # ./target/release/testnet-injector simulate-bx-from-csv ../movement-data/public-transport/MF_user_mobility_june-to-august-2023_mulhouse_dataset/anonymized_june-to-august-2023_mulhouse_dataset.csv $TOTAL_SIMULATION_TIME & ./target/release/testnet-injector simulate-bx-from-csv ./data/dataset-extract.csv $TOTAL_SIMULATION_TIME & -# Mine every 10 secs or number of blocks +# Mine for ((i=1; i<=100; i++)) do echo "MINE $i/100"; diff --git a/scripts/t2-n-miners-m-sync.sh b/scripts/t2-n-miners-m-sync.sh new file mode 100755 index 0000000..f213094 --- /dev/null +++ b/scripts/t2-n-miners-m-sync.sh @@ -0,0 +1,38 @@ +#!/bin/bash +export MINER_SIGNING_KEY=4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318; +export MNEMONIC='before exclude interest push zone jealous boat ice chimney juice young side diagram silent pipe'; + +# MINER_SIGNING_KEY & MNEMONIC env vars are set on workstation. +# 30 mins +TOTAL_SIMULATION_TIME=1800; +# 12 sec +BLOCK_TIME=12; + +# export RPC_URL=http://ecomobicoin-1.cri.local.isima.fr:8545; +# export CHAIN_ID=6363; +export RPC_URL=http://127.0.0.1:8545; +export CHAIN_ID=636363; + +export RPC_URL_MINER_1=http://127.0.0.1:8545; +export RPC_URL_MINER_2=http://127.0.0.1:28545; + +# ./target/release/testnet-injector simulate-bx-from-csv ../movement-data/public-transport/MF_user_mobility_june-to-august-2023_mulhouse_dataset/anonymized_june-to-august-2023_mulhouse_dataset.csv $TOTAL_SIMULATION_TIME & +# Send BX +./target/release/testnet-injector simulate-bx-from-csv ./data/dataset-extract.csv $TOTAL_SIMULATION_TIME & + +# Mine +for ((i=1; i<=100; i++)) +do + echo "MINE $i/100"; + if ((i % 2 == 0)); then + export RPC_URL=$RPC_URL_MINER_1; ./target/release/testnet-injector mine + else + export RPC_URL=$RPC_URL_MINER_2; ./target/release/testnet-injector mine + fi + + if [ $i -ne 100 ]; then + sleep $BLOCK_TIME + fi +done + + -- GitLab From 4daa362ef57dc4432d73d66acc49ce3544f06354 Mon Sep 17 00:00:00 2001 From: Anthony Graignic <anthony.graignic@uca.fr> Date: Tue, 9 Jan 2024 11:43:31 +0100 Subject: [PATCH 2/2] Update simulation input doc --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 937a0ce..03cb1b7 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ flowchart LR end ``` -## Network Tests +### Scripts for testnets Scripts in `./scripts` are useful to test an EcoMobiCoin network. @@ -107,6 +107,25 @@ Scripts in `./scripts` are useful to test an EcoMobiCoin network. | `t1-1mine-with-simulation-2sync` | 1 node mine a block with bxs from simulation data every X seconds, the others sync | | `t2-n-miners-m-sync.sh` | 2 nodes in turn mine blocks with bxs from simulation data every X seconds, the others sync | +### Configuration + +#### CSV Dataset + +**Behaviors** are created from CSV files like the example file `data/dataset-extract.csv`. More data can be found in https://gitlab.limos.fr/ecomobicoin/data/movement-data/-/tree/master/public-transport/MF_user_mobility_june-to-august-2023_mulhouse_dataset?ref_type=heads + +**Transactions** could also be created from CSV if accounts are not empty. + +#### Chainspec + +`.ron` file included in node, see https://gitlab.limos.fr/ecomobicoin/truite/-/tree/dev/src/res/chainspec?ref_type=heads and documentation about it https://docs.ecomobicoin.limos.fr/docs/basics/protocol-specs + +#### Nodes & Miner config + +**Node configuration** has low to no impact on the simulation but can be useful to customize data path, api or debug options. + +**Miner configuration** can be useful for simulations to have different mining strategies or bx/tx inclusion in block. +Please refer to [`MiningStrategy`](https://gitlab.limos.fr/ecomobicoin/truite/-/blob/dev/src/consensus/pob/miner.rs?ref_type=heads#L90) + ## Development Build the project for dev with `cargo build` or release with `cargo build --release` -- GitLab