diff --git a/README.md b/README.md index 4e1cc62ef7a11cdd4d0e773ac68152481619e1f9..03cb1b7b92054730b7a63c3fcea0e18bcb5b7cae 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,41 @@ flowchart LR end ``` +### Scripts for testnets + +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 | + +### 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` + +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 f8c79834679038fac051c2a38b1f8517f47ef1cc..3dd826e1e6fc7b7ece167c431b12c1a341865073 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 d536649ee610a7b211431a6d8af6ff47c1c10700..c8d6321c68e5c4fb1ca9672419db84bbe2e9d1c8 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 0000000000000000000000000000000000000000..f2130941420dfff7eaeb0d90a20f3dc593148142 --- /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 + +