This document provides comprehensive instructions for contributing to EthStorage's Optimism Monorepo. It outlines a practical process for running tests locally to verify code changes and ensure successful CircleCI tests.
We offer two methods to achieve the same goal:
- A convenient command that performs all checks and tests in one step.
- Step-by-step instructions, which are especially helpful if you need to debug issues or explore further.
If you are a first-time contributor to EthStorage's Optimism repository or are not yet using mise
for managing software dependencies, please complete the steps to set up your development environment.
In the root directory of your Optimism repo, execute the following command, replacing the placeholders with your prepared RPC endpoints:
# Set your own RPC URLs below.
export SEPOLIA_RPC_URL=<YOUR_SEPOLIA_RPC_URL>
export MAINNET_RPC_URL=<YOUR_MAINNET_RPC_URL>
mise run dt
This section provides a step-by-step guide based on how programming languages are organized in the repository: Solidity and Go.
Before proceeding, check if mise
is activated in your current terminal session:
mise doctor | grep 'activated:'
The expected output should be:
bashactivated: yes
If the output is no
, ensure that this step has been executed correctly. In some IDE scenarios, you may need to manually activate mise
each time you open the terminal based on your shell type:
eval "$(mise activate zsh)"
# or
eval "$(mise activate bash)"
Navigate to the contracts-bedrock
directory:
cd packages/contracts-bedrock
Run the following command to clean, build, lint, and check all contracts:
just pre-pr
For detailed explanations and potential fixes for specific errors, refer to this section.
Execute the following command to run contract tests using Forge:
just test
Review the results and make necessary fixes if errors occur. A successful output may look like this:
Ran 282 test suites in 396.48s (1890.89s CPU time): 1763 tests passed, 0 failed, 1 skipped (1764 total tests)
Navigate to the root directory of your Optimism Monorepo.
Before proceeding with tests, ensure that your Go code is correctly linted:
make lint-go
If any lint errors are detected, attempt to fix them with:
make lint-go-fix
Note that some errors may require manual intervention.
Go tests require building Go components along with contracts. Execute:
# Builds op-node, op-proposer, op-batcher, and contracts-bedrock
make build
# Build additional essential components
cd op-program && make op-program-client && cd ..
cd cannon && make elf && cd ..
cd op-e2e && make pre-test && cd ..
Allocations are also required by the following tests. To generate allocations, use:
make devnet-allocs
Prepare your environment by setting necessary variables as follows. Replace placeholders with your RPC endpoints as outlined in this step.
export ENABLE_KURTOSIS=true
export OP_E2E_CANNON_ENABLED="false"
export OP_E2E_SKIP_SLOW_TEST=true
export OP_E2E_USE_HTTP=true
export ENABLE_ANVIL=true
# Set your own RPC URLs below.
export SEPOLIA_RPC_URL=<YOUR_SEPOLIA_RPC_URL>
export MAINNET_RPC_URL=<YOUR_MAINNET_RPC_URL>
Execute Go tests with:
gotestsum --no-summary=skipped,output \
--format=testname \
--rerun-fails=2
After completion, check the console for any errors or failures. A successful result should appear as follows:
DONE 8567 tests, 95 skipped in 189.396s
To run end-to-end tests, execute:
cd op-e2e
make test-actions
make test-ws
For detailed information on end-to-end testing, refer to this README.
The just pre-pr
command includes several checks:
-
Gas Snapshot Check (
gas-snapshot-check-no-build
): Ensures gas snapshots are up-to-date. Update using:just gas-snapshot-no-build
-
Semgrep Test Validity Check (
semgrep-test-validity-check
): Ensures semgrep tests are properly configured. -
Unused Imports Check (
unused-imports-check-no-build
): Flags unused imports in Solidity contracts. -
Snapshots Check (
snapshots-check-no-build
): Ensures all snapshots are current. Regenerate snapshots with:just snapshots-no-build
-
Lint Check (
lint-check
): Ensures contracts are properly linted. Auto-fix lint errors with:just lint-fix
-
Semver Diff Check (
semver-diff-check-no-build
): Ensures modified contracts have updated semver versions. Fix with:just semver-lock
-
Deploy Config Validation (
validate-deploy-configs
): Validates deploy configurations. -
Spacer Variable Check (
validate-spacers-no-build
): Validates spacer variables without requiring a build. -
Interface Check (
interfaces-check-no-build
): Validates interfaces without requiring a build. -
Forge Test Linting (
lint-forge-tests-check-no-build
): Validates Forge test names adhere to correct formats.
This section guides you through setting up your local development environment step-by-step for beginners.
Start by cloning the repository:
git clone https://github.com/ethstorage/optimism.git
cd optimism
Optimism uses mise
as a dependency manager for installing and maintaining various software dependencies necessary for development and testing. Once installed correctly, mise
will provide appropriate versions for each tool.
-
Execute the following command to install
mise
:curl https://mise.run | sh
-
The
mise activate
command updates environment variables and PATH each time your prompt is run:Choose a command based on your shell type:
# for bash echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc # for zsh echo 'eval "$(~/.local/bin/mise activate zsh)"' >> ~/.zshrc
-
Check that
mise
is installed correctly:mise --version # Expected output: mise 2025.x.x
-
The
mise.toml
file lists the dependencies used by this repository:mise trust mise.toml
-
Use
mise
to install required tools:mise install
-
Verify that all dependent tools are correctly installed with required versions:
mise ls
For more information on mise
commands, please refer to https://mise.jdx.dev/cli/.
-
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list sudo apt update sudo apt install kurtosis-cli # This command should start the Kurtosis Engine Server. kurtosis engine start # After starting the engine, you can check its status with: kurtosis engine status
You will need access to Sepolia and Mainnet during upcoming Go tests; set RPC endpoints as environment variables as outlined in this step.
RPC URLs with a free BlockPI API key will suffice for testing purposes. For assistance, refer to this link for detailed instructions.
By following this guide, you will be well-equipped to contribute effectively to EthStorage's Optimism Monorepo.