Skip to content

azx#44

Open
Raroford32 wants to merge 18 commits intosbip-sg:mainfrom
Raroford32:main
Open

azx#44
Raroford32 wants to merge 18 commits intosbip-sg:mainfrom
Raroford32:main

Conversation

@Raroford32
Copy link
Copy Markdown

No description provided.

Copilot AI and others added 18 commits January 18, 2026 00:36
Co-authored-by: Raroford32 <109440929+Raroford32@users.noreply.github.com>
Co-authored-by: Raroford32 <109440929+Raroford32@users.noreply.github.com>
Co-authored-by: Raroford32 <109440929+Raroford32@users.noreply.github.com>
Co-authored-by: Raroford32 <109440929+Raroford32@users.noreply.github.com>
Co-authored-by: Raroford32 <109440929+Raroford32@users.noreply.github.com>
Co-authored-by: Raroford32 <109440929+Raroford32@users.noreply.github.com>
Co-authored-by: Raroford32 <109440929+Raroford32@users.noreply.github.com>
Co-authored-by: Raroford32 <109440929+Raroford32@users.noreply.github.com>
Co-authored-by: Raroford32 <109440929+Raroford32@users.noreply.github.com>
Co-authored-by: Raroford32 <109440929+Raroford32@users.noreply.github.com>
Co-authored-by: Raroford32 <109440929+Raroford32@users.noreply.github.com>
…vidia-b300

Align B300 build defaults, CI, GPU fuzzing enhancements, and roadmap docs
This commit adds a comprehensive GPU-accelerated smart contract fuzzing
infrastructure optimized for NVIDIA B300 GPUs (SM 103, Blackwell architecture).

## Core Components Added:

### GPU Coverage Instrumentation (coverage.cuh/cu)
- Edge coverage tracking with AFL-style bitmap
- Branch coverage with gradient-guided distance tracking
- Storage access coverage (SLOAD/SSTORE patterns)
- Call coverage for inter-contract interactions
- Per-instance and global coverage merging
- Coverage snapshot serialization for corpus management

### Advanced Mutation Engine (mutation.cuh/cu)
- 41 mutation types including bit/byte flips, arithmetic, interesting values
- ABI-aware mutation for smart contract parameters
- EVM-specific mutations (address, uint256, selector, calldata)
- Sequence mutation for multi-transaction fuzzing
- Dictionary-based mutation with automatic extraction
- GPU RNG state management with curand

### Comprehensive Bug Detection (oracle.cuh/cu)
- Integer overflow/underflow detection
- Division/modulo by zero detection
- Reentrancy vulnerability detection (ETH, ERC20, cross-function)
- Access control violation detection
- tx.origin authentication detection
- Ether leak and stuck ether detection
- Token vulnerability detection (ERC20/ERC721)
- Gas-related DoS detection
- Selfdestruct vulnerability detection
- Composite oracle for combined checking

### Corpus Management (corpus.cuh)
- GPU-optimized seed storage with coverage deduplication
- Energy-based seed scheduling for weighted selection
- Delta-debug minimization support
- Corpus distillation for minimal coverage
- Import/export with checkpoint support

### Invariant System (corpus.cuh)
- Protocol invariant DSL (storage, balance, supply constraints)
- Pre-built templates for ERC20, ERC721, ERC4626, AMM, lending
- GPU-parallel invariant checking
- Violation tracking and reporting

### B300 Optimization (gpu_fuzzer.cuh/cu)
- Auto-tuning batch size for optimal throughput
- Memory pool management for efficient allocation
- Multi-stream execution for overlap
- Profiling hooks for Nsight Systems
- 65K default instances per batch

### Main Fuzzer Orchestrator (gpu_fuzzer.cuh/cu)
- Complete fuzzing lifecycle management
- Configurable via JSON or programmatic API
- Progress callbacks and bug callbacks
- Checkpoint/resume support
- Results export (JSON, corpus seeds)

### Python Interface (gpu_fuzzer.py)
- Full Python bindings for all functionality
- CLI tool with comprehensive options
- Integration with existing CuEVM Python wrapper
- Standalone mutation, coverage, and oracle classes

## Build System Updates:
- Added curand library linking for GPU RNG
- Automatic inclusion of fuzzing sources via GLOB

## Performance Targets:
- 65,536+ instances per batch on B300
- Sub-millisecond mutation per instance
- Full coverage merge in single kernel launch
- Throughput: 100,000+ executions/second

This implementation follows the roadmap in plans.md and provides
production-grade GPU fuzzing capabilities.
Complete the GPU fuzzing implementation by adding the missing corpus.cu file:
- GPUCorpusManager: Full seed storage and management with deduplication
- SeedMinimizer: Delta-debugging based seed minimization
- CorpusDistiller: Greedy set-cover for corpus minimization
- InvariantChecker: Protocol invariant verification for ERC20/721/4626/AMM
- CUDA kernels for parallel seed selection and energy updates
- Import/export and checkpoint functionality
- Energy-based scheduling for seed selection
Debug and cleanup changes:
- Fix evm_word_t access: use ._limbs[] instead of .limbs[] (CGBN internal storage)
- Fix coverage_snapshot_t: add edge_bitmap array for compatibility with corpus.cu
- Fix __constant__ arrays: move definitions from mutation.cuh to mutation.cu to avoid multiple definition errors
- Fix corpus.cu: use correct gpu_coverage_map_t::edge_bitmap access instead of edges.hit_bitmap
- Fix CMakeLists.txt: change minimum cmake version from 4.2 to 3.20 (4.2 doesn't exist)
- Fix gpu_fuzzer.py: remove duplicate imports, add proper fallbacks for optional dependencies

All .limbs[] accesses changed to ._limbs[] in:
- coverage.cu
- mutation.cu
- oracle.cu
- corpus.cu
Copilot AI review requested due to automatic review settings January 20, 2026 02:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a comprehensive GPU-accelerated smart contract fuzzing framework optimized for NVIDIA B300 GPUs. The changes include:

Changes:

  • Addition of complete GPU fuzzing infrastructure with mutation engine, coverage tracking, and bug oracles
  • Infrastructure updates for B300 GPU support (CMake 4.2.1, CUDA compute capability 103)
  • Fork selection capability for Ethereum test execution
  • Multi-sequence fuzzing with invariant checking
  • New documentation and planning files

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
CMakeLists.txt (both) Updated CMake version requirements and CUDA compute capabilities for B300
Dockerfile.ngc New Docker image based on NVIDIA NGC PyTorch 25.12
README.md Updated prerequisites and build instructions for B300 support
plans.md Comprehensive roadmap for GPU fuzzing features
AGENTS.md Implementation guide for advanced contributors
scripts/run-ethtest-by-fork.py Added fork selection parameter with mapping
scripts/run-ci-tests-gpu.py Added EVM_FORK environment variable support
fuzzing/library_wrapper.py Added state tracking and receiver selection
fuzzing/fuzzer.py Fixed typo and added invariant checking, multi-sequence support
fuzzing/gpu_fuzzer.py New comprehensive GPU fuzzer implementation (1416 lines)
CuEVM/src/fuzzing/*.cu New CUDA implementations for oracle, mutation, gpu_fuzzer, coverage
CuEVM/include/CuEVM/fuzzing/*.cuh New CUDA headers for oracle and mutation
.github/workflows/test.yml Updated actions versions and added EVM_FORK environment variable

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

def _execute_simulated(self, inputs: List[bytes]) -> List[dict]:
"""Simulated execution for testing"""
results = []
for inp in inputs:
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For loop variable 'inp' is not used in the loop body.

Suggested change
for inp in inputs:
for _ in inputs:

Copilot uses AI. Check for mistakes.
import json
import time
import argparse
import hashlib
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'hashlib' is not used.

Suggested change
import hashlib

Copilot uses AI. Check for mistakes.
import hashlib
import signal
from dataclasses import dataclass, field, asdict
from typing import List, Dict, Optional, Callable, Any, Tuple
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'Callable' is not used.

Suggested change
from typing import List, Dict, Optional, Callable, Any, Tuple
from typing import List, Dict, Optional, Any, Tuple

Copilot uses AI. Check for mistakes.
import signal
from dataclasses import dataclass, field, asdict
from typing import List, Dict, Optional, Callable, Any, Tuple
from pathlib import Path
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'Path' is not used.

Suggested change
from pathlib import Path

Copilot uses AI. Check for mistakes.
from pathlib import Path
from enum import Enum, auto
import random
import struct
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'struct' is not used.

Suggested change
import struct

Copilot uses AI. Check for mistakes.
import struct
from concurrent.futures import ThreadPoolExecutor
from collections import defaultdict
import threading
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'threading' is not used.

Suggested change
import threading

Copilot uses AI. Check for mistakes.
sys.path.append("./binary/")

try:
import libcuevm
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'libcuevm' is not used.

Suggested change
import libcuevm
import libcuevm
_ = libcuevm # ensure libcuevm import is treated as used (side effects on import)

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +49
compile_file, get_transaction_data_from_config,
get_transaction_data_from_processed_abi,
EVMBranch, EVMBug, EVMCall, TraceEvent
)
except ImportError:
# utils module not available, define minimal stubs
compile_file = None
get_transaction_data_from_config = None
get_transaction_data_from_processed_abi = None
EVMBranch = EVMBug = EVMCall = TraceEvent = None
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'get_transaction_data_from_config' is not used.
Import of 'get_transaction_data_from_processed_abi' is not used.
Import of 'EVMBranch' is not used.
Import of 'EVMBug' is not used.
Import of 'EVMCall' is not used.
Import of 'TraceEvent' is not used.

Suggested change
compile_file, get_transaction_data_from_config,
get_transaction_data_from_processed_abi,
EVMBranch, EVMBug, EVMCall, TraceEvent
)
except ImportError:
# utils module not available, define minimal stubs
compile_file = None
get_transaction_data_from_config = None
get_transaction_data_from_processed_abi = None
EVMBranch = EVMBug = EVMCall = TraceEvent = None
compile_file,
)
except ImportError:
# utils module not available, define minimal stubs
compile_file = None

Copilot uses AI. Check for mistakes.
Comment on lines +52 to +56
from eth_abi import encode as eth_encode
except ImportError:
eth_encode = None

try:
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'eth_encode' is not used.

Suggested change
from eth_abi import encode as eth_encode
except ImportError:
eth_encode = None
try:

Copilot uses AI. Check for mistakes.
return k.digest()[:4]
except ImportError:
# Last resort fallback - use SHA256 (not correct for Ethereum but works for testing)
import hashlib
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import of module hashlib is redundant, as it was previously imported on line 15.

Suggested change
import hashlib

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants