Skip to content
Open
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
18 changes: 18 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[target.wasm32-unknown-unknown]
rustflags = [
"-C", "link-arg=-zstack-size=32768",
"-C", "target-feature=-reference-types",
"-C", "target-feature=+bulk-memory",
]

[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]

[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
78 changes: 78 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Git
.git/
.gitignore
.github/

# Documentation
README.md
*.md
docs/
header.png

# Rust build artifacts
target/
# IDE and editor files
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store

# Environment and secrets
.env
.env.local
*.pem
*.key
*.p12

# Logs
*.log
logs/

# Test coverage
cobertura.xml
coverage/
tarpaulin-report.html

# Security reports
security-report.md
audit-report.json
unsafe-report.md
proc-macros.txt

# CI/CD artifacts
.github/
ci/

# Package managers
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Temporary files
tmp/
temp/
*.tmp
*.temp

# OS generated files
Thumbs.db
ehthumbs.db
Desktop.ini

# Backup files
*.bak
*.backup
*~

# Examples and test data
examples/
test-data/
fixtures/

# License files that don't affect build
LICENSE*
CHANGELOG*
CONTRIBUTING*
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RPC_URL=
STYLUS_CONTRACT_ADDRESS=
PRIV_KEY_PATH=
ENS_REGISTRY_ADDRESS=0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e
173 changes: 173 additions & 0 deletions .github/BRANCH_PROTECTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# Branch Protection Configuration

This document outlines the required branch protection settings for the Linketh repository to ensure code quality and security.

## Required Branch Protection Rules

### For `main` branch:

**Status Checks (Required)**:
- ✅ `CI Success` (from ci.yml workflow)
- ✅ `Stylus Compatibility Check` (from ci.yml workflow)
- ✅ `Build and Test` (from ci.yml workflow)
- ✅ `Code Validation` (from ci.yml workflow)
- ✅ `Docker Build Test` (from ci.yml workflow)

**Protection Settings**:
- ✅ Require status checks to pass before merging
- ✅ Require branches to be up to date before merging
- ✅ Require pull request reviews before merging (minimum 1 reviewer)
- ✅ Dismiss stale pull request approvals when new commits are pushed
- ✅ Require review from code owners (if CODEOWNERS file exists)
- ✅ Restrict pushes that create files larger than 100MB
- ✅ Require signed commits (recommended)
- ✅ Include administrators in these restrictions
- ✅ Allow force pushes: **DISABLED**
- ✅ Allow deletions: **DISABLED**
Comment on lines +16 to +26

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incorrect protection item: GitHub doesn’t offer “Restrict pushes that create files >100MB” as a branch protection toggle.

Large-file limits are enforced by GitHub globally (100MB) or via Repository Rulesets/LFS, not classic branch protection. Adjust wording or move this to a Ruleset section.

-- ✅ Restrict pushes that create files larger than 100MB
+// Enforce large-file policies via Repository Rulesets or Git LFS (GitHub blocks >100MB by default).

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 LanguageTool

[grammar] ~16-~16: There might be a mistake here.
Context: ....yml workflow) Protection Settings: - ✅ Require status checks to pass before m...

(QB_NEW_EN)

🤖 Prompt for AI Agents
In .github/BRANCH_PROTECTION.md around lines 16 to 26, the document incorrectly
lists "Restrict pushes that create files larger than 100MB" as a branch
protection toggle; update the wording to reflect that GitHub enforces the 100MB
file limit globally or via Repository Rulesets/LFS rather than classic branch
protection, and either remove that bullet or move it into a new "Repository
Rulesets / LFS / Large file limits" section with a brief note explaining where
to configure or enforce large-file restrictions.


### For `develop` branch:

**Status Checks (Required)**:
- ✅ `CI Success` (from ci.yml workflow)
- ✅ `Stylus Compatibility Check` (from ci.yml workflow)
- ✅ `Build and Test` (from ci.yml workflow)
- ✅ `Code Validation` (from ci.yml workflow)

**Protection Settings**:
- ✅ Require status checks to pass before merging
- ✅ Require branches to be up to date before merging
- ✅ Require pull request reviews before merging (minimum 1 reviewer)
- ✅ Restrict pushes that create files larger than 100MB
- ✅ Include administrators in these restrictions
- ✅ Allow force pushes: **DISABLED**
- ✅ Allow deletions: **DISABLED**

## Critical Status Checks

### 🛡️ Stylus Compatibility Check
**Why Critical**: This check ensures the contract compiles correctly for Arbitrum Stylus and passes all WASM validation requirements. **Failures here mean the contract cannot be deployed.**

**What it checks**:
- WASM compilation for `wasm32-unknown-unknown` target
- Stylus runtime compatibility via `cargo stylus check`
- WASM binary size limits (must be under 128KB)
- Contract activation requirements

### 🧪 Build and Test
**Why Critical**: Ensures all unit tests pass and the code compiles without errors.

**What it checks**:
- Rust compilation for both debug and release builds
- All 20 unit tests must pass
- WASM target compilation
- Test coverage reporting

### ✨ Code Validation
**Why Critical**: Maintains code quality and security standards.

**What it checks**:
- Code formatting via `cargo fmt`
- Linting via `cargo clippy` (zero warnings policy)
- Security vulnerability scanning via `cargo audit`

## Setting Up Branch Protection

### Via GitHub Web Interface:

1. Navigate to **Settings** → **Branches**
2. Click **Add rule** or edit existing rule
3. Set **Branch name pattern**: `main` (or `develop`)
4. Configure settings as specified above
5. In **Status checks**, add the required checks:
- Search for and select each required status check
- Enable "Require branches to be up to date"

### Via GitHub CLI:

```bash
# For main branch
gh api repos/:owner/:repo/branches/main/protection \
--method PUT \
--field required_status_checks='{"strict":true,"checks":[{"context":"CI Success"},{"context":"Stylus Compatibility Check"},{"context":"Build and Test"},{"context":"Code Validation"},{"context":"Docker Build Test"}]}' \
--field enforce_admins=true \
--field required_pull_request_reviews='{"required_approving_review_count":1,"dismiss_stale_reviews":true}' \
--field restrictions=null

# For develop branch
gh api repos/:owner/:repo/branches/develop/protection \
--method PUT \
--field required_status_checks='{"strict":true,"checks":[{"context":"CI Success"},{"context":"Stylus Compatibility Check"},{"context":"Build and Test"},{"context":"Code Validation"}]}' \
--field enforce_admins=true \
--field required_pull_request_reviews='{"required_approving_review_count":1}' \
--field restrictions=null
```

## Workflow Dependencies

The `CI Success` job depends on all critical jobs and will only pass if:

1. ✅ **Code Validation** completes successfully
2. ✅ **Build and Test** completes successfully
3. ✅ **Stylus Compatibility Check** completes successfully
4. ✅ **Docker Build Test** completes successfully
5. ✅ **Documentation Check** completes successfully

## Emergency Procedures

### Bypassing Protection (Admins Only)

In rare emergency situations, administrators can temporarily disable branch protection:

```bash
# Disable protection
gh api repos/:owner/:repo/branches/main/protection --method DELETE

# Re-enable after emergency fix
# (Use the setup commands above)
```

**⚠️ Important**: Always re-enable protection immediately after emergency fixes.

### Failing Status Checks

If legitimate code changes cause status check failures:

1. **For Stylus Check Failures**:
- Review WASM compilation errors
- Check contract size limits
- Verify Stylus SDK compatibility

2. **For Test Failures**:
- Fix failing unit tests
- Ensure new code has test coverage
- Verify no breaking changes to existing APIs

3. **For Validation Failures**:
- Run `cargo fmt` to fix formatting
- Address `clippy` warnings
- Update dependencies to fix security issues

## Monitoring

### Check Status via GitHub API:
```bash
# Check protection status
gh api repos/:owner/:repo/branches/main/protection

# Check recent status checks
gh api repos/:owner/:repo/commits/main/status
```

### Weekly Review Checklist:
- [ ] Verify all required status checks are still configured
- [ ] Review security audit results
- [ ] Check for outdated dependencies
- [ ] Validate Docker build performance
- [ ] Review pull request merge patterns

## Contact

For questions about branch protection or to request changes:
- Open an issue with label `ci/cd`
- Contact repository administrators
- Review GitHub Actions logs for specific failure details
12 changes: 12 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Description

Please provide a summary of the changes and any backward incompatibilities.

## Checklist

- [ ] I have documented these changes where necessary.
- [ ] I have read the [DCO][DCO] and ensured that these changes comply.
- [ ] I assign this work under its [open source licensing][terms].

[DCO]: https://github.com/OffchainLabs/stylus-hello-world/blob/main/licenses/DCO.txt
[terms]: https://github.com/OffchainLabs/stylus-hello-world/blob/main/licenses/COPYRIGHT.md
Comment on lines +11 to +12

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix links to use this repo’s files (not OffchainLabs).

Current links point to another repository.

Apply:

-[DCO]: https://github.com/OffchainLabs/stylus-hello-world/blob/main/licenses/DCO.txt
-[terms]: https://github.com/OffchainLabs/stylus-hello-world/blob/main/licenses/COPYRIGHT.md
+[DCO]: ../licenses/DCO.txt
+[terms]: ../licenses/COPYRIGHT.md
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[DCO]: https://github.com/OffchainLabs/stylus-hello-world/blob/main/licenses/DCO.txt
[terms]: https://github.com/OffchainLabs/stylus-hello-world/blob/main/licenses/COPYRIGHT.md
[DCO]: ../licenses/DCO.txt
[terms]: ../licenses/COPYRIGHT.md
🤖 Prompt for AI Agents
.github/pull_request_template.md lines 11-12: the two link references point to
OffchainLabs/stylus-hello-world; update both URLs to reference the corresponding
files within THIS repository (replace the OffchainLabs/stylus-hello-world path
with this repo’s path and ensure the filenames and relative paths are correct),
verify links resolve to the local LICENSE/COPYRIGHT files or to the correct
repo-relative paths, and run a quick link check to confirm they work.

Loading
Loading