Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(protocol): enhancements to simulation setup and execution documentation #16068

Merged
merged 8 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "mkdir -p simulation/out && forge test --match-test 'test_L2_NoFeeCheck_simulation' -vv > simulation/out/simconf_$(date +%s).txt"
},
"keywords": [
"ZKP",
Expand Down
55 changes: 50 additions & 5 deletions packages/protocol/simulation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,57 @@

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
```

### 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_<timestamp>.txt`):

```
pnpm run export:simconf
```

**Note:** Replace `<timestamp>` 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_<timestamp>.txt` with the name of your specific file:

```
python3 simulate.py out/simconf_<timestamp>.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_<timestamp>.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.
Loading