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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Added

- Expand CONTRIBUTING.md with local development setup: prerequisites, clone/build steps, unit/e2e test commands, linting, protobuf, and precompile workflows; fix stale link references ([#64](https://github.com/KiiChain/kiichain/issues/64))

### Fixed

- Fix division-by-zero chain halt in `CalculateReward` caused by sub-second schedule durations; replace `Seconds()` truncation with `Nanoseconds()` precision and release full remaining reward when `EndTime <= LastReleaseTime` ([#267](https://github.com/KiiChain/kiichain/issues/267))
Expand Down
117 changes: 112 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Contribution Guidelines

Contributions to the Kiijs library are welcome. As a contributor, here are the guidelines we would like you to follow:
Contributions to KiiChain are welcome. As a contributor, here are the guidelines we would like you to follow:
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The intro now refers to "KiiChain", but this file still contains references to "Kiijs" later (e.g., "The Kiijs team..." and "code under Kiijs"), which is inconsistent and confusing for contributors. Please update those remaining mentions so the project name is consistent throughout the guide.

Copilot uses AI. Check for mistakes.

- [Code of Conduct](#code-of-conduct)
- [Issues and Bugs](#found-a-bug)
- [Feature Requests](#missing-a-feature)
- [Local Development Setup](#local-development-setup)
- [Submission Guidelines](#submission-guidelines)
- [Coding Rules](#coding-rules)
- [Commit Message Guidelines](#commit-message-convention)
Expand All @@ -26,6 +27,112 @@ If you would like to *implement* a new feature:
- For a **Major Feature**, first [open an issue](#submitting-an-issue) and outline your proposal so that it can be discussed.
- **Small Features** can be crafted and directly [submitted as a Pull Request](#submitting-a-pull-request-pr).

## Local Development Setup

### Prerequisites

| Tool | Version | Required |
|------|---------|----------|
| [Go](https://golang.org/dl/) | 1.24+ | Yes |
| [Git](https://git-scm.com/) | any recent | Yes |
| [GNU Make](https://www.gnu.org/software/make/) | any recent | Recommended |
| [Docker](https://docs.docker.com/get-docker/) | any recent | For e2e tests only |
Comment on lines +34 to +39
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The prerequisites table syntax has an extra leading | on each row (|| Tool | ...), which renders an empty first column in Markdown. Use standard table formatting (| Tool | Version | Required | and | --- | --- | --- |) so the table renders correctly on GitHub.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This line says Docker is "for e2e tests only", but the Protobuf targets (make proto-gen/format/lint) run a Docker-based proto-builder image (see Makefile protoImage=$(DOCKER) run ...). Please update the prerequisites to reflect that Docker is also required for protobuf workflows (or document an alternative non-Docker path).

Copilot uses AI. Check for mistakes.

Verify your setup:

```bash
go version # Should show 1.24+
git --version
make --version # Optional but recommended
docker --version # Only needed for e2e tests
```

### Clone and Build

```bash
# 1. Fork the repository on GitHub, then clone your fork
git clone https://github.com/<your-username>/kiichain.git
cd kiichain

# 2. Add the upstream remote
git remote add upstream https://github.com/KiiChain/kiichain.git

# 3. Create a feature branch
git checkout -b feat/my-change

# 4. Build the binary
make build # Output: ./build/kiichaind

# Or install to $GOPATH/bin
make install
```

If you don't have GNU Make:

```bash
go build -o ./build/kiichaind ./cmd/kiichaind
```

### Running Tests

**Unit tests:**

```bash
make test-unit # Run all unit tests (5 min timeout)
make test-unit-cover # Run with coverage report
make test-unit-cover-html # Generate HTML coverage report
```

Or directly with `go test`:

```bash
go test ./... -count=1 -timeout=5m
```

**Race condition detection:**

```bash
make test-race
```

**End-to-end tests** (requires Docker):

```bash
# Build the required Docker images first
docker build -t kiichain/kiichaind-e2e -f Dockerfile .
cd tests/e2e/docker && docker build -t kiichain/hermes-e2e:1.0.0 -f hermes.Dockerfile .
cd ../../..
Comment on lines +102 to +104
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This doc uses raw docker build/cd ... && docker build commands for e2e images, but the Makefile already provides make docker-build-debug, make docker-build-hermes, and make docker-build-all. Referencing the Makefile targets here would reduce duplication and prevent the docs from drifting if image names/paths change.

Suggested change
docker build -t kiichain/kiichaind-e2e -f Dockerfile .
cd tests/e2e/docker && docker build -t kiichain/hermes-e2e:1.0.0 -f hermes.Dockerfile .
cd ../../..
make docker-build-debug # Build kiichain e2e image
make docker-build-hermes # Build Hermes e2e image
# Or build all e2e images at once:
# make docker-build-all

Copilot uses AI. Check for mistakes.

# Run e2e tests
make test-e2e
```

### Linting and Formatting

```bash
make lint # Run golangci-lint
make lint-fix # Auto-fix lint issues where possible
make format # Format code
```

### Protobuf

If you modify `.proto` files under `proto/`:

```bash
make proto-gen # Regenerate Go code from proto definitions
make proto-format # Format .proto files
make proto-lint # Lint .proto files
```

### EVM Precompiles

If you modify Solidity interfaces under `precompiles/`:

```bash
make compile-evm-precompiles
```

## Submission Guidelines

### Submitting an Issue
Expand Down Expand Up @@ -111,8 +218,8 @@ Please follow the [Conventional Commits v1.0.0][convcommit]. The commit types mu
- **test**: Adding missing tests or correcting existing tests

[coc]: ./CODE_OF_CONDUCT.md
[issues]: https://github.com/KiiChain/kiijs-sdk/issues
[new-issue]: https://github.com/KiiChain/kiijs-sdk/issues/new/choose
[prs]: https://github.com/KiiChain/kiijs-sdk/pulls
[issues]: https://github.com/KiiChain/kiichain/issues
[new-issue]: https://github.com/KiiChain/kiichain/issues/new/choose
[prs]: https://github.com/KiiChain/kiichain/pulls
[convcommit]: https://www.conventionalcommits.org/en/v1.0.0/
[github]: https://github.com/KiiChain/kiijs-sdk
[github]: https://github.com/KiiChain/kiichain
Loading