From 4fd3a2efd4859bd9d3013138103b9318ec4784f3 Mon Sep 17 00:00:00 2001 From: NaijaCoderGirl <150683513+NaijaCoderGirl@users.noreply.github.com> Date: Sun, 25 Feb 2024 17:04:34 +0000 Subject: [PATCH 1/4] change simulation test target in script --- packages/protocol/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/protocol/package.json b/packages/protocol/package.json index 0df847bf02..bed2659776 100644 --- a/packages/protocol/package.json +++ b/packages/protocol/package.json @@ -16,7 +16,7 @@ "test": "forge test -vvv --match-path test/*.t.sol", "test:coverage": "mkdir -p coverage && forge coverage --report lcov && lcov --remove ./lcov.info -o ./coverage/lcov.info 'test/' 'script/' 'contracts/thirdparty/' && genhtml coverage/lcov.info --branch-coverage --output-dir coverage --ignore-errors category && open coverage/index.html", "test:genesis": "pnpm compile && FOUNDRY_PROFILE=genesis ./genesis/generate_genesis.test.sh", - "export:simconf": "forge test --match-test 'test_simulation' -vv > simulation/out/simconf_$(date +%s).txt" + "export:simconf": "forge test --match-test 'test_L2_NoFeeCheck_simulation' -vv > simulation/out/simconf_$(date +%s).txt" }, "keywords": [ "ZKP", From 7d8c60c9da9649ea90f5b02dced5c623e0ad2778 Mon Sep 17 00:00:00 2001 From: NaijaCoderGirl <150683513+NaijaCoderGirl@users.noreply.github.com> Date: Sun, 25 Feb 2024 17:33:37 +0000 Subject: [PATCH 2/4] update README for clarity in simulation setup and execution --- packages/protocol/simulation/README.md | 63 ++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 5 deletions(-) diff --git a/packages/protocol/simulation/README.md b/packages/protocol/simulation/README.md index ad01e2f587..67efe841a2 100644 --- a/packages/protocol/simulation/README.md +++ b/packages/protocol/simulation/README.md @@ -4,12 +4,65 @@ Assuming you are in this directory. -1. Install required packages: `python3 -m pip install -r requirements.txt` +### Setup -1. Make the output directory: `mkdir -p out` +1. **Update Foundry** -1. Run `pnpm run export:simconf` to export a new the config used in test `test_eip1559_math` to a file in `out/`, the file name will be automatically generated, for example `simconf_1697809145.txt` + Before installing any packages, ensure your Foundry environment is up to date by running: -1. Run `python3 simulate.py out/simconf_1697809145.txt` + ``` + foundryup + ``` + + This command updates Foundry tools to their latest versions. + +2. **Install Required Packages** + + Install the necessary Python packages using pip: + + ``` + python3 -m pip install -r requirements.txt + ``` + +3. **Create Output Directory** + + Ensure there's a directory to store the output files: + + ``` + mkdir -p out + ``` + +### Exporting Configuration + +4. **Export Simulation Configuration** + + Run the following command to export the configuration used in the `test_eip1559_math` test to a file in the `out/` directory. A unique file name based on the current timestamp will be generated automatically (e.g., `simconf_.txt`): + + ``` + pnpm run export:simconf + ``` + + **Note:** Replace `` with the actual timestamp from the generated file name. + +### Running Simulation + +5. **Run Simulation** + + After exporting the configuration, locate the newly created file in the `out/` directory. Run the simulation using the command below, replacing `simconf_.txt` with the name of your specific file: + + ``` + python3 simulate.py out/simconf_.txt + ``` + + For example, if your file is named `simconf_1697809145.txt`, the command would be: + + ``` + python3 simulate.py out/simconf_1697809145.txt + ``` + +**Important:** The filename `simconf_.txt` is provided as an example. Your file will have a different timestamp. Please adjust the command according to the actual file name generated by the export process. + +### Understanding the Outcome + +The parameters set in the `test_eip1559_math` test simulate approximations of possible mainnet scenarios (e.g., 10x the Ethereum gas target). Run the commands as described above to become familiar with the simulation outcome and generated plots. -Currently, every parameter set in the `test_eip1559_math` is an approximation of a possible mainnet scenario (like 10x the ethereum gas target), so you can just run the commands below to get familiar with the outcome and plots. From 3928674c775b5d2d27e65474c5a48336e563654d Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Mon, 26 Feb 2024 16:04:19 +0800 Subject: [PATCH 3/4] Update packages/protocol/package.json --- packages/protocol/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/protocol/package.json b/packages/protocol/package.json index bed2659776..8d556d22a0 100644 --- a/packages/protocol/package.json +++ b/packages/protocol/package.json @@ -16,7 +16,7 @@ "test": "forge test -vvv --match-path test/*.t.sol", "test:coverage": "mkdir -p coverage && forge coverage --report lcov && lcov --remove ./lcov.info -o ./coverage/lcov.info 'test/' 'script/' 'contracts/thirdparty/' && genhtml coverage/lcov.info --branch-coverage --output-dir coverage --ignore-errors category && open coverage/index.html", "test:genesis": "pnpm compile && FOUNDRY_PROFILE=genesis ./genesis/generate_genesis.test.sh", - "export:simconf": "forge test --match-test 'test_L2_NoFeeCheck_simulation' -vv > simulation/out/simconf_$(date +%s).txt" + "export:simconf": "mkdir -p simulation/out && forge test --match-test 'test_L2_NoFeeCheck_simulation' -vv > simulation/out/simconf_$(date +%s).txt" }, "keywords": [ "ZKP", From b3f1d3fd521cbb685e5e29ef803a06ff404209d9 Mon Sep 17 00:00:00 2001 From: NaijaCoderGirl <150683513+NaijaCoderGirl@users.noreply.github.com> Date: Mon, 26 Feb 2024 13:52:48 +0000 Subject: [PATCH 4/4] remove from README command to mkdir -p out --- packages/protocol/simulation/README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/protocol/simulation/README.md b/packages/protocol/simulation/README.md index 67efe841a2..b8838980b0 100644 --- a/packages/protocol/simulation/README.md +++ b/packages/protocol/simulation/README.md @@ -24,14 +24,6 @@ Assuming you are in this directory. python3 -m pip install -r requirements.txt ``` -3. **Create Output Directory** - - Ensure there's a directory to store the output files: - - ``` - mkdir -p out - ``` - ### Exporting Configuration 4. **Export Simulation Configuration**