Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
96dcbf0
HIP-25: implement Pure HACD Staking (types, actions, rewards, fee red…
Moskyera Jun 15, 2026
44b70f6
HIP-25: fix staking module imports and BlockHeight zero check
Moskyera Jun 15, 2026
74c48bf
HIP-25: fix mutable borrow in staking_on_block_close
Moskyera Jun 15, 2026
02730ff
HIP-25: wire staking RPC, toolchain fixes, and public reward helper
Moskyera Jun 15, 2026
95a35af
HIP-25: integration tests, HVM bridge API, and testnet config
Moskyera Jun 15, 2026
70dbeef
HIP-25: add example fullnode config for testnet RPC
Moskyera Jun 15, 2026
2d7f6e5
fix(HIP-25): correct RPC accrual, fee redirect, activation gate
Moskyera Jun 15, 2026
c20afb3
feat(HIP-25): events, HVM script path, fee share 22%
Moskyera Jun 15, 2026
b1a1476
chore(HIP-25): reduce staking fee share to 13% for burn/miner balance
Moskyera Jun 15, 2026
2ff9268
feat(HIP-25): RPC stake/unstake tx build + smoke test script
Moskyera Jun 15, 2026
2201e6f
feat(HIP-25): testnet seed, live stake E2E, wallet MVP UI
Moskyera Jun 15, 2026
88d844f
HIP-25: multi-HACD testnet seed, WASM hacd_stake/unstake, wallet + bo…
Moskyera Jun 15, 2026
1923b2c
HIP-25: unstake demo periods + hip25_unstake_demo.ps1 (verified E2E)
Moskyera Jun 15, 2026
d0de899
HIP-25: mainnet hardening — config guards, WASM wallet, RPC prikey block
Moskyera Jun 15, 2026
c8e460c
HIP-25 demo: WASM SDK build + wallet create/sign/submit flow
Moskyera Jun 15, 2026
4878f9c
fix(WASM): hacd_stake — use Utc::now in curtimes on wasm32 (SystemTim…
Moskyera Jun 15, 2026
753a9d3
fix(wallet): auto-retry HACD load until block 1 seeds testnet
Moskyera Jun 15, 2026
eadb839
fix(wallet): parse WASM stake JSON without double-wrapping braces
Moskyera Jun 15, 2026
2b80535
security(HIP-25): remediate all 3 audit findings for mainnet readiness
Moskyera Jun 15, 2026
fff56c0
security(Audit #3): harden API surface to PASS grade
Moskyera Jun 15, 2026
a798094
security(audits 4-5): remediate all PARTIAL findings to PASS
Moskyera Jun 15, 2026
c817856
release(hip25): mainnet launcher, CI, community review docs for v0.1.0
Moskyera Jun 16, 2026
a0c03f7
ci(hip25): release-build job; fix BUILD_MAINNET_RELEASE rustup stderr…
Moskyera Jun 16, 2026
0500cb3
feat(hip25): v2 economics per HIP-11 review - 10% insc protocol only,…
Moskyera Jun 16, 2026
6a51023
feat(hip2): HACD system mortgage v2 — actions 15/16, IOU loop, 2% ori…
Moskyera Jun 16, 2026
7a90ed9
feat(hip2): v2.1 economics — 1% origination, 3% flat APR, grace, 103%…
Moskyera Jun 16, 2026
1c96a73
feat(hip2): E2E tests, WASM wallet, supply RPC, 5 audits PASS
Moskyera Jun 16, 2026
b57a498
docs(hip2): record audit commit hash 1c96a73
Moskyera Jun 16, 2026
3ca41b1
fix(hip2): live demo - testnet smelt seed, RPC fixes, submit async
Moskyera Jun 16, 2026
79bfae5
fix(wallet): show HACD + mortgage portfolio, Mortgaged badge, calc loan
Moskyera Jun 16, 2026
844a5d8
fix(wallet): clearer UX, signing address sync, auto loan calc
Moskyera Jun 16, 2026
f18c246
Implement code review follow-ups for HIP-2 mortgage wallet
Moskyera Jun 16, 2026
eeee5da
HIP-25 v3: supply-neutral staking from HACD mint miner share
Moskyera Jun 18, 2026
8446523
docs: HIP-25 reference repositioning — spec, roadmap, v3 PR body
Moskyera Jun 20, 2026
6f33b06
docs: add GitHub PR body file for hacash/rust#13
Moskyera Jun 20, 2026
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
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/hip25-community-review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: HIP-25 community review
about: Security or consensus feedback for HIP-25 staking before mainnet activation
title: "[HIP-25 review] "
labels: hip-25, community-review
assignees: ''
---

## Area

- [ ] Staking consensus (`staking.rs`, actions 34/35)
- [ ] RPC / API security
- [ ] WASM wallet (`wallet/hip25/`)
- [ ] Mainnet config / activation height
- [ ] Other

## Severity

- [ ] Critical (blocks mainnet)
- [ ] High
- [ ] Medium
- [ ] Low / note

## Description

<!-- What is wrong or unclear? -->

## Reproduction

<!-- Steps, config, commit hash -->

## Suggested fix (optional)

<!-- PR welcome on hip-25-staking branch -->

**Fork:** https://github.com/Moskyera/rust/tree/hip-25-staking
**Review guide:** [docs/HIP25_COMMUNITY_REVIEW.md](https://github.com/Moskyera/rust/blob/hip-25-staking/docs/HIP25_COMMUNITY_REVIEW.md)
53 changes: 53 additions & 0 deletions .github/workflows/hip25-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: HIP-25 CI

on:
push:
branches: [hip-25-staking]
tags: ["v*-hip25-*"]
pull_request:
branches: [hip-25-staking]

jobs:
staking-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Run HIP-25 staking unit tests
run: cargo test staking_tests
- name: Run HIP-2 mortgage unit + E2E tests
run: cargo test mortgage_
- name: Verify HIP-2 documentation
run: |
test -f docs/HIP2_MORTGAGE_V2.md
test -f docs/HIP2_COMMUNITY_REVIEW.md
test -f docs/HIP2_SECURITY_AUDITS.md

release-build:
runs-on: ubuntu-latest
needs: staking-tests
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install build deps
run: sudo apt-get update && sudo apt-get install -y cmake build-essential
- name: cargo build --release
run: cargo build --release
- name: Verify mainnet artifacts
run: |
test -f target/release/hacash
test -f scripts/START_MAINNET_WALLET.bat
test -f hacash_mainnet_hip25.config.ini.example

security-audit-note:
runs-on: ubuntu-latest
needs: staking-tests
steps:
- uses: actions/checkout@v4
- name: Verify security artifacts present
run: |
test -f src/server/security.rs
test -f hacash_mainnet_hip25.config.ini.example
test -f wallet/hip25/index.html
test -f scripts/START_MAINNET_WALLET.bat
echo "HIP-25 mainnet artifacts OK"
34 changes: 24 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@ name = "hacash"
version = "0.1.0"
edition = "2021"

[features]
default = []
sdk = ["wasm-bindgen"]


[package.metadata.wasm-pack.profile.release]
wasm-opt = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


# [lib]
# name = "hacash_sdk"
# # version = "0.1.0"
# crate-type = ["staticlib", "cdylib"]
[lib]
name = "hacash_sdk"
path = "src/sdk_lib.rs"
crate-type = ["cdylib"]
required-features = ["sdk"]


[build-dependencies]
cc = "1.0"


[dependencies]
libc = "0.2.4"
chrono = "0.4.38"
lazy_static = "1.4.0"
concat-idents = "1.1.5"
Expand All @@ -36,25 +40,35 @@ sha3 = "0.10.1"
sha2 = "0.10.2"
regex = "1.10.0"
ini = "1.3.0"
leveldb-sys = "2.0.9"
dyn-clone = "1.0.17"
http_req = "0.10.2"
tokio = { version = "1.37.0", features = ["rt", "rt-multi-thread", "sync", "time", "io-util", "net", "macros"] }
ctrlc = "3.4.4"
serde = "1.0.199"
serde_json = "1.0.116"
bytes = "1.6.0"
wasm-bindgen = { version = "0.2.100", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
libc = "0.2.4"
leveldb-sys = "2.0.9"
http_req = "0.10.2"
tokio = { version = "1.37.0", features = ["rt", "rt-multi-thread", "sync", "time", "io-util", "net", "macros"] }
ctrlc = "3.4.4"
axum = "0.7.5"
spmc = "0.3.0"
termsize = "0.1.9"
reqwest = { version = "0.12.5", features = ["blocking"] }

[dev-dependencies]
tempfile = "3.10.1"
serde_urlencoded = "0.7.1"

# rocksdb = { version = "0.22.0", default-features = false, features = ["lz4"] }
# easy-http-request = "0.2.13"
# leveldb-sys = "2.0.9"
# rusty-leveldb = "3.0.0"
# leveldb = "0.8.6"
# wasm-bindgen = "0.2.87"



Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,26 @@ Each layer of the architecture has independent functions and responsibilities fo
6. [Server] Server - RPC API interface service, block and transaction and account data query, other services, etc.
7. [Miner] Miner - block construction and mining, diamond mining, transaction memory pool, mining pool server, mining pool worker, etc.


### HIP-25 HACD staking (reference implementation)

**Branch:** [`hip-25-staking`](https://github.com/Moskyera/rust/tree/hip-25-staking) · **Tag:** `v0.1.0-hip25-reference` · **Audits:** 5/5 PASS @ `a798094`

> **Note:** Official Hacash development is on [fullnodedev](https://github.com/hacash/fullnodedev) → [fullnode](https://github.com/hacash/fullnode/releases). This fork is a **tested reference** for HIP-25 spec review and a future port — not the canonical mainnet merge target for legacy [hacash/rust](https://github.com/hacash/rust).

| Mode | Launcher | Port | Notes |
|------|----------|------|-------|
| Testnet demo | `scripts\START_WALLET.bat` | 8083 | Fresh dev chain, poworker, wipes demo data |
| Mainnet wallet | `scripts\START_MAINNET_WALLET.bat` | 8081 | Release build, synced `data_dir`, no data wipe |

**Mainnet build (once):**
```powershell
powershell -ExecutionPolicy Bypass -File scripts\BUILD_MAINNET_RELEASE.ps1
```

**Spec:** [docs/HIP25_SPEC.md](docs/HIP25_SPEC.md) · **Roadmap:** [docs/HIP25_ROADMAP.md](docs/HIP25_ROADMAP.md)
**Community review:** [docs/HIP25_COMMUNITY_REVIEW.md](docs/HIP25_COMMUNITY_REVIEW.md)
**Discussion PR:** https://github.com/hacash/rust/pull/13

Config template: `hacash_mainnet_hip25.config.ini.example` (`chain_id=0`, loopback RPC, client WASM signing only).

5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ cp target/x86_64-apple-darwin/release/hacash ./hacash_macos


fn main() {
// Browser WASM SDK (hacd_stake / hacd_unstake) does not need native x16rs C code.
let target = std::env::var("TARGET").unwrap_or_default();
if target == "wasm32-unknown-unknown" {
return;
}
cc::Build::new()
.file("src/x16rs/x16rs.c")
.compile("x16rs");
Expand Down
47 changes: 47 additions & 0 deletions docs/HIP25_COMMUNITY_POST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Community post (English) — copy-paste

**Suggested channels:** HacashTalk, Discord, X thread, PR #13

---

## Post

**HIP-25 HACD Staking — reference implementation ready, seeking mainline path**

We've completed a full **HIP-25** prototype: on-chain stake/unstake (actions 34/35), supply-neutral **v3 economics**, WASM wallet, 24 tests, and 5 security audits (all PASS).

### What it does

- Lock HACD to earn a share of HAC from the **existing 10% DiamondMint miner fee** — not new coinbase minting.
- Inscription fees stay **100% burn** (same as today).
- Min stake ~90 days, cooldown ~3 days — reduces mercenary staking around mint events.
- Cannot stake mortgaged diamonds (HIP-2 compatible).

### v3 economics (why it changed)

Early feedback (including @jojoin on PR #13) noted that redirecting burn-bound HAC needs HIP-11-level care. **v3** fixes this: we only redirect the miner share that already goes to the block miner today. Total HAC issuance vs baseline is unchanged — reallocation, not inflation.

### Important: this is a reference impl, not legacy rust merge

Official Hacash development has moved to **fullnodedev → fullnode** ([developer guide](https://www.hacash.org/development)). The legacy `hacash/rust` repo is inactive. Our code is a **tested reference** for community review and a future port — not a claim that PR #13 alone activates mainnet.

### Links

- **Spec:** https://github.com/Moskyera/rust/blob/hip-25-staking/docs/HIP25_SPEC.md
- **Branch:** https://github.com/Moskyera/rust/tree/hip-25-staking
- **Discussion PR:** https://github.com/hacash/rust/pull/13
- **Economics v3:** https://github.com/Moskyera/rust/blob/hip-25-staking/docs/HIP25_ECONOMICS_V3.md
- **Try testnet wallet:** clone fork → `scripts\START_WALLET.bat` → http://127.0.0.1:8083/hip25/wallet

### What we need from the community

1. Review the spec and economics (especially vs HIP-2 mortgage and dynamic-staking proposals).
2. Feedback on min stake / cooldown durations.
3. Support for formal HIP submission to hacash/paper.
4. Maintainer direction on **fullnodedev port** timing (before/after Istanbul @ 765432).

We will **not** announce a mainnet fork height without ≥30 days notice and maintainer agreement.

Thank you to everyone who reviewed PR #13 — the discussion is moving the design in the right direction.

— Moskyera / HIP-25 reference implementation
99 changes: 99 additions & 0 deletions docs/HIP25_COMMUNITY_REVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# HIP-25 — Community Review & Voting Guide

**Proposal:** HIP-25 HACD staking (actions 34/35) — **reference implementation** for spec review and future **fullnodedev** port.
**Fork:** https://github.com/Moskyera/rust/tree/hip-25-staking
**Reference tag:** `v0.1.0-hip25-reference`
**Formal spec:** [HIP25_SPEC.md](./HIP25_SPEC.md) · **Roadmap:** [HIP25_ROADMAP.md](./HIP25_ROADMAP.md)
**Audit status:** 5 independent security audits — **PASS** (local mainnet wallet model)

> Canonical mainnet path is [hacash/fullnodedev](https://github.com/hacash/fullnodedev) → [hacash/fullnode](https://github.com/hacash/fullnode/releases), not legacy `hacash/rust`. PR #13 is for **discussion**, not assumed merge.

---

## What to review

| Area | Key paths |
|------|-----------|
| Staking consensus | `src/mint/operate/staking.rs`, `src/mint/action/diamond_staking.rs` |
| RPC security | `src/server/security.rs`, `src/server/http/start.rs` |
| WASM wallet | `wallet/hip25/index.html`, `src/sdk/web/transfer.rs` |
| Config guards | `src/config/mint.rs`, `hacash_mainnet_hip25.config.ini.example` |
| Tests | `src/mint/operate/staking.rs` (`staking_tests`, 24 cases) |

---

## Security audit summary (commit `a798094`)

| Audit | Scope | Result |
|-------|-------|--------|
| #1 | Auth, secrets, RPC | **PASS** |
| #2 | Staking economics | **PASS** |
| #3 | API, DoS | **PASS** |
| #4 | Tx pipeline, P2P | **PASS** |
| #5 | WASM wallet | **PASS** |

**Mainnet defaults:** `chain_id=0`, `listen_host=127.0.0.1`, `allow_public_rpc=false`, server-side signing **disabled** on mainnet, client WASM signing only.

---

## How to test locally

### Testnet (quick demo)
```cmd
scripts\START_WALLET.bat
```
Opens http://127.0.0.1:8083/hip25/wallet with HIP-25 dev chain (`chain_id=1`).

### Mainnet wallet (production model)
```powershell
powershell -ExecutionPolicy Bypass -File scripts\BUILD_MAINNET_RELEASE.ps1
scripts\START_MAINNET_WALLET.bat
```
Requires **synced mainnet** `data_dir` — does **not** delete chain data.

---

## Community voting checklist

Reviewers / voters should confirm:

- [ ] **Consensus:** stake/unstake rules match HIP-25 **v3** spec (min stake, cooldown, **HACD mint miner-share redirect**, full inscription burn, idle pool burn, ownership).
- [ ] **Mainnet safety:** dev flags (`hip25_testnet_seed`) panic at startup when `chain_id=0`.
- [ ] **Wallet:** secrets never sent to RPC; only signed `tx_body` submitted.
- [ ] **RPC:** loopback-only by default; public bind requires explicit `allow_public_rpc=true`.
- [ ] **Tests:** `cargo test staking_tests` passes (also run in GitHub Actions).
- [ ] **Fork height:** `staking_activation_height` must be set to **agreed** mainnet activation (≥30 day notice per HIP-25).

---

## Discussion PR & mainline path

**Open discussion PR:** https://github.com/hacash/rust/pull/13
**PR body (v3 + reference status):** [docs/UPSTREAM_PR.md](./UPSTREAM_PR.md)
**Maintainer outreach:** [docs/JOJOIN_OUTREACH.md](./JOJOIN_OUTREACH.md)
**Community post:** [docs/HIP25_COMMUNITY_POST.md](./HIP25_COMMUNITY_POST.md)

Next step for mainnet: port to **fullnodedev** after maintainer alignment (see roadmap).

---

## Release artifacts

Tag `v0.1.0-hip25-mainnet` includes:

- Release build scripts (`BUILD_MAINNET_RELEASE.ps1`)
- Mainnet launcher (`START_MAINNET_WALLET.bat`)
- Mainnet config template (`hacash_mainnet_hip25.config.ini.example`)
- CI workflow (`.github/workflows/hip25-ci.yml`)

---

## Contact / feedback

Comment on the fork PR or upstream PR with:

1. Audit finding ID (if any)
2. Severity (Critical / High / Medium / Low)
3. Repro steps

**Target:** community consensus before mainnet fork activation height is set on live network.
37 changes: 37 additions & 0 deletions docs/HIP25_ECONOMICS_V2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# HIP-25 v2 Economics (superseded by v3)

> **Note:** Mainnet/community target is **v3** (`docs/HIP25_ECONOMICS_V3.md`) — inscription fee redirect replaced by HACD mint miner-share redirect for supply-neutral staking.

# HIP-25 v2 Economics (response to HIP-11 / jojoin review)

**Context:** [hacash/rust#13](https://github.com/hacash/rust/pull/13#issuecomment-4714088187) — any redistribution of HAC that would otherwise burn requires long-term community consideration (HIP-11). HIP-2 (mortgage + repay principal+interest) is the reference model for HAC liquidity from HACD.

## What changed (v2)

| Item | v1 | **v2** |
|------|-----|--------|
| Fee sources | 13% inscription protocol + 13% HACD transfer fees | **10% inscription protocol fees only** |
| Transfer fees | Partial redirect | **Unchanged** (full burn/miner split) |
| Idle pool | Accumulates forever if no stakers | **Burned** after `1008` consecutive blocks with zero stakers |
| Supply stats | Pool balance only | `cumulative_deposit_zhu`, `cumulative_paid_zhu`, `cumulative_pool_burned_zhu` |

## What did NOT change

- Stake / unstake mechanics, cooldown, min stake age
- No coinbase minting (not HIP-2-style IOU issuance)
- Mutual exclusion with HIP-2 mortgage diamond status
- Mainnet activation still requires agreed `staking_activation_height` + community notice

## HIP-2 comparison

| | HIP-2 mortgage | HIP-25 v2 staking |
|--|----------------|-------------------|
| HAC source | Coinbase IOU (= bid burn restored) | Redirected inscription protocol burn share |
| Repayment | Principal + interest | None (fee-funded yield) |
| Mainnet | Never activated | Pending HIP-11-style vote |

HIP-25 v2 is a **simpler, lower-impact** complement — not a replacement for HIP-2.

## RPC

`GET /query_global_staking` returns v2 fields: `fee_share_percent`, `fee_sources`, cumulative counters, `pool_sweep_blocks`.
Loading