Skip to content

YCC3741/BlockChainSecurity

Repository files navigation

BlockChainSecurity

Build Status

Blockchain security research project, utilizing Foundry for smart contract development and testing.

Project Structure

BlockChainSecurity/
├── src/
│   ├── interface.sol          # Contract interface definitions
│   └── test/
│       └── gmx_exp.sol         # GMX related test contracts
├── lib/                        # Dependencies
├── out/                        # Compilation output
├── foundry.toml                # Foundry configuration
└── docker-compose.yml          # Docker configuration

Install

Method 1: Using Docker (Recommended)

# Start container (newer Docker Desktop uses docker compose, older versions use docker-compose)
docker compose up -d --build
# or
docker-compose up -d --build

# Execute commands in container
docker compose exec lab forge <command>
# or
docker-compose exec lab forge <command>

Method 2: Install Foundry Locally

Windows

  1. Install Git for Windows (if not already installed):

  2. Install Foundry using Git Bash:

    • Open Git Bash (not PowerShell)
    • Run the following commands:
    curl -L https://foundry.paradigm.xyz | bash
    foundryup
  3. Add Foundry to system PATH:

    • Press Win + R, type sysdm.cpl, press Enter
    • Click "Environment Variables"
    • Find Path in "System variables", click "Edit"
    • Click "New", add: C:\Users\<YourUsername>\.foundry\bin
    • Click OK and restart PowerShell
  4. Verify installation:

    forge --version

Note: Foundryup currently does not support PowerShell or Cmd. You must use Git Bash or WSL to run the installation commands.

Linux/macOS

curl -L https://foundry.paradigm.xyz | bash
foundryup

Usage

Running PoC

Run GMX related tests using Docker:

docker compose up -d --build
docker compose exec lab forge test --contracts ./src/test/gmx_exp.sol -vvv

Or using the legacy command format:

docker-compose up -d --build
docker-compose exec lab forge test --contracts ./src/test/gmx_exp.sol -vvv

Note: Synchronizing past blocks may take some time.

Format Code

Using Locally Installed Foundry

# Format all Solidity files
forge fmt

# Check format only (does not modify files)
forge fmt --check

# Format specific file
forge fmt src/test/gmx_exp.sol

Using Docker

# Ensure container is running
docker compose up -d

# Format all Solidity files (changes sync back to local)
docker compose exec lab forge fmt

# Check format only (does not modify files)
docker compose exec lab forge fmt --check

# Format specific file
docker compose exec lab forge fmt src/test/gmx_exp.sol

Note: When using Docker, formatted files automatically sync back to local due to volume mounting.

CI/CD

The project uses GitHub Actions for continuous integration. On every push or PR, it automatically runs:

  • ✅ Code format check (forge fmt --check)
  • ✅ Contract compilation (forge build)
  • ✅ Test execution (forge test)

References

About

Just for BlcokChain Security Demo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •