Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fbe88da
✨ Add minimal branch (#6)
heyJonBray Mar 18, 2025
544b8f1
📝 Add minimal install instructions to README
heyJonBray Mar 18, 2025
a44235e
📝 Add minimal install instructions to README
heyJonBray Mar 18, 2025
159dcc4
📝 Add branch guidelines
heyJonBray Mar 18, 2025
a1e263d
📄 Update license to Lazer
heyJonBray Mar 19, 2025
4802661
📝 Clarify repo goals for contributors (#7)
heyJonBray Mar 19, 2025
4aee2b3
🩹 Update vscode settings (#8)
heyJonBray Apr 1, 2025
903525b
🔧 Update vscode solidity settings
heyJonBray Apr 1, 2025
2579466
✨ Add test utils and ERC20 mocks
heyJonBray May 20, 2025
03dcc0d
✨ add CREATE3 contract and deployment script
heyJonBray May 20, 2025
954000a
🔨 add script to sync to `minimal` branch
heyJonBray May 20, 2025
ce8fe21
♻️ enhance sync script to create `sync-branch` if it doesn't exist
heyJonBray May 20, 2025
38898db
👷 add workflow to prevent direct merges between main and minimal
heyJonBray May 20, 2025
3535b66
🔧 add `anvil` config to `foundry.toml`
heyJonBray Sep 11, 2025
79ad2b7
🔧 add default anvil `chain_id`
heyJonBray Sep 11, 2025
d0d5920
♻️ update Solidity version and EVM version in foundry.toml
heyJonBray Nov 4, 2025
bbc134e
⚰️ remove stray anvil entry in etherscan config
heyJonBray Nov 4, 2025
65b60bf
🔧 update remappings
heyJonBray Nov 8, 2025
4dd0eb5
♻️ wrap modifier logic to reduce code size
heyJonBray Nov 8, 2025
f0d2a4c
♻️ update solidity version and import syntax
heyJonBray Nov 8, 2025
63f34fb
📝 move sync script usage into CONTRIBUTING
heyJonBray Nov 8, 2025
1c94ae8
📝 reorganize README
heyJonBray Nov 8, 2025
b2d62b5
✅ pass tests
heyJonBray Nov 8, 2025
6388a49
Merge origin/minimal into sync-branch - keep sync-branch (main) versions
heyJonBray Nov 8, 2025
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
56 changes: 56 additions & 0 deletions .github/workflows/branch-consistency.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Branch Consistency Check

on:
pull_request:
branches:
- main
- minimal

jobs:
consistency-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all branches and history

# Check consistency of critical files
- name: Compare Critical Files
run: |
# Ensure both branches exist
git branch -r

# List of files to compare
critical_files=(
"foundry.toml"
".gitignore"
"LICENSE"
"sample.env"
)

# Function to compare files
compare_files() {
local file="$1"
echo "Comparing $file"

# Get file contents from both branches
main_content=$(git show main:"$file" 2>/dev/null || echo "")
minimal_content=$(git show minimal:"$file" 2>/dev/null || echo "")

# Compare contents
if [ "$main_content" != "$minimal_content" ]; then
echo "Inconsistency detected in $file"
echo "Main branch content:"
echo "$main_content"
echo "Minimal branch content:"
echo "$minimal_content"
exit 1
fi
}

# Compare each critical file
for file in "${critical_files[@]}"; do
compare_files "$file"
done

echo "All critical files are consistent between branches."
40 changes: 40 additions & 0 deletions .github/workflows/prevent-direct-merges.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# .github/workflows/prevent-direct-merges.yml
name: Prevent Direct Merges

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
check-branches:
runs-on: ubuntu-latest
steps:
- name: Check for direct merges between main and minimal
run: |
BASE="${{ github.event.pull_request.base.ref }}"
HEAD="${{ github.event.pull_request.head.ref }}"

# Block direct merges between main and minimal
if [[ "$BASE" == "main" && "$HEAD" == "minimal" ]]; then
echo "::error::Direct merges from minimal to main are not allowed. Please use the sync-to-main script instead."
exit 1
fi

if [[ "$BASE" == "minimal" && "$HEAD" == "main" ]]; then
echo "::error::Direct merges from main to minimal are not allowed. Please use the sync-to-minimal script instead."
exit 1
fi

# Allow sync branches explicitly
if [[ "$BASE" == "minimal" && "$HEAD" == "sync-branch" ]]; then
echo "Sync branch to minimal is allowed"
exit 0
fi

if [[ "$BASE" == "main" && "$HEAD" == "sync-branch-reverse" ]]; then
echo "Sync branch to main is allowed"
exit 0
fi

# All other PRs are allowed
echo "Regular feature branch PR - allowed"
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"solidity.formatter": "forge",
"solidity.defaultCompiler": "localFile",
"solidity.monoRepoSupport": true,
"solidity.packageDefaultDependenciesDirectory": "lib",
"solidity.packageDefaultDependenciesContractsDirectory": "src"
}
49 changes: 47 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Contributing

The goal of this repo is to provide not only an optimized configuration for experienced Solidity developers but to also serve as a starting point for developers who are new to Foundry or Solidity. We're looking in particular for the following Contributions to the `main` branch:

- Reusable utility and library contracts that add value to LazerForge as a template
- Expanded [tutorials](/lazerTutorial/README.md) on smart contract development and testing in foundry
- Helpful test examples

## Branch Structure and Guidelines

### Branch Overview
Expand All @@ -21,7 +29,7 @@ This repository maintains two primary branches with distinct purposes:
- Direct merges between these branches are prohibited
- Branch protection rules are in place to prevent accidental merging

### Contributing
### Config Contributions

- If you want to contribute changes that should apply to both branches:
1. Make changes in the `main` branch first
Expand All @@ -45,6 +53,43 @@ This repository maintains two primary branches with distinct purposes:
git commit -m "Selectively update minimal branch"
```

### Questions or Clarifications
## Syncing Changes Between Branches

We use a dedicated synchronization workflow to maintain consistency between branches while respecting their different purposes.

**To sync changes from `main` to `minimal`:**

1. Ensure your changes are merged to `main` first
2. Run the sync script:

```bash
./tools/sync-to-minimal.sh
```

3. The script will:

- Update a dedicated sync branch with the latest from `main`
- Open a PR creation page targeting `minimal`

4. During PR review:
- Verify only appropriate files are included
- Exclude tutorial content or other files not needed in `minimal`

**For emergency fixes in `minimal`:**

If you need to make a hotfix directly to `minimal` and then sync back to `main`:

1. Make and merge your changes to `minimal`
2. Run:

```bash
./tools/sync-to-main.sh
```

3. Complete a PR to sync these changes back to `main`

> Always make feature development PRs to `main` first, and use the sync scripts rather than manually cherry-picking to maintain consistency.

## Questions or Clarifications

If you have any questions about the branch structure or contribution process, please open an issue in the repository.
57 changes: 11 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,52 +56,7 @@ LazerForge maintains two primary branches to cater to different needs:

For detailed info on branches and contribution, check out the [Contributing Guide](CONTRIBUTING.md).

## Syncing Changes Between Branches

We use a dedicated synchronization workflow to maintain consistency between branches while respecting their different purposes.

**To sync changes from `main` to `minimal`:**

1. Ensure your changes are merged to `main` first
2. Run the sync script:

```bash
./tools/sync-to-minimal.sh
```

3. The script will:

- Update a dedicated sync branch with the latest from `main`
- Open a PR creation page targeting `minimal`

4. During PR review:
- Verify only appropriate files are included
- Exclude tutorial content or other files not needed in `minimal`

**For emergency fixes in `minimal`:**

If you need to make a hotfix directly to `minimal` and then sync back to `main`:

1. Make and merge your changes to `minimal`
2. Run:

```bash
./tools/sync-to-main.sh
```

3. Complete a PR to sync these changes back to `main`

> Always make feature development PRs to `main` first, and use the sync scripts rather than manually cherry-picking to maintain consistency.

## Documentation

For detailed guides on various aspects of LazerForge, check out:

- [Setup Guide](lazerTutorial/setup.md) - Initial setup and configuration
- [Testing Guide](lazerTutorial/testing.md) - Writing and running tests
- [Deployment Guide](lazerTutorial/deployment.md) - Deploying contracts
- [Network Configuration](lazerTutorial/networks.md) - Setting up networks and RPC endpoints
- [Profiles](lazerTutorial/profiles.md) - Using different Foundry profiles
> See [sync script usage](CONTRIBUTING.md#syncing-changes-between-branches) for automating branch sync.

## Reinitialize Submodules

Expand Down Expand Up @@ -134,3 +89,13 @@ To generate reports, run
```bash
./coverage-report
```

## Documentation

For detailed guides on various aspects of LazerForge, check out:

- [Setup Guide](lazerTutorial/setup.md) - Initial setup and configuration
- [Testing Guide](lazerTutorial/testing.md) - Writing and running tests
- [Deployment Guide](lazerTutorial/deployment.md) - Deploying contracts
- [Network Configuration](lazerTutorial/networks.md) - Setting up networks and RPC endpoints
- [Profiles](lazerTutorial/profiles.md) - Using different Foundry profiles
45 changes: 43 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@
# update solc values if needed for compatability with older contracts
auto_detect_solc = false
solc = '0.8.28'
evm_version = "prague"
src = "src"
out = "out"
libs = ["lib"]
remappings = [
'forge-std/=lib/forge-std/src',
'solady/=lib/solady/src/',
'solady-test/=lib/solady/test/',
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/',
'openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/',
'openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/',
'@uniswap/v2-core/=lib/uniswap/v2-core/contracts/',
'@uniswap/v3-core/=lib/uniswap/v3-core/contracts/',
'@uniswap/v3-periphery/=lib/uniswap/v3-periphery/contracts/',
'@uniswap/v4-core/=lib/uniswap/v4-core/src/',
'@uniswap/v4-periphery/=lib/uniswap/v4-periphery/src/',
'uniswap-v2-core/=lib/uniswap/v2-core/contracts/',
'uniswap-v3-core/=lib/uniswap/v3-core/contracts/',
'uniswap-v3-periphery/=lib/uniswap/v3-periphery/contracts/',
'uniswap-v4-core/=lib/uniswap/v4-core/src/',
'uniswap-v4-periphery/=lib/uniswap/v4-periphery/src/'
]
# ensure that block number + timestamp are realistic when running tests
block_number = 17722462
Expand All @@ -31,7 +41,6 @@ sepolia = "${SEPOLIA_RPC_URL}"
mainnet = "${ETHEREUM_RPC_URL}"
base = "${BASE_RPC_URL}"
base_sepolia = "${BASE_SEPOLIA_RPC_URL}"
anvil = "http://127.0.0.1:8545"

[etherscan]
ethereum = { key = "${ETHERSCAN_API_KEY}"}
Expand Down Expand Up @@ -66,4 +75,36 @@ optimizer = true
optimizer_runs = 1000000
via_ir = true

# Local anvil profile
[profile.anvil]
evm_version = 'prague'
optimizer = true
optimizer_runs = 500_000

# paste an anvil-generated account here
# sender = "0x..."

# Testing knobs for local chain realism and speed
[profile.anvil.fuzz]
runs = 64

# Broadcast configuration - write to ./broadcast by default on scripts
[profile.anvil.broadcast]
retries = 10
retries_delay_ms = 500

# If you use forked anvil often, set a default fork here (optional)
# [profile.anvil.rpc_storage_caching]
# chains = ["anvil"]

# Permissions for scripts that need artifacts/IO locally (inherits your default, add more if needed)
[profile.anvil.fs_permissions]
# carry over the via_ir read permission
# additional example:
# { access = "read-write", path = "./broadcast" }

# Gas reporting locally (optional)
[profile.anvil.gas_reports]
# contracts = ["MyContract","AnotherContract"]

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
Loading