Commit graph

13 commits

Author SHA1 Message Date
Steve Degosserie
10a7805648
feat: Add CI license check (#269)
## Summary

- Adds automated license compliance checking via GitHub Actions CI
workflow
- Implements a license verification script that validates all Rust
dependencies against approved licenses, authors, and packages
- Standardizes author metadata across Cargo manifests to "Moonsong Labs"

## Changes

**CI Workflow** (`.github/workflows/task-check-licenses.yml`)
- Triggers on pull requests and manual dispatch
- Installs Rust 1.88.0 toolchain and `cargo-license` tool
- Executes license verification script to enforce compliance

**License Verification Script** (`operator/scripts/verify-licenses.sh`)
- Uses `cargo-license` to extract dependency license information
- Maintains three allowlists:
- **Licenses**: Apache-2.0, MIT, BSD variants, GPL-3.0, MPL-2.0, and
compatible combinations
- **Authors**: PureStake, Parity Technologies, Moonsong Labs, Frontier
developers, StorageHub Team
  - **Package Names**: Known safe packages like ring
- Fails the build if any dependency has unapproved license/author/name
combination

**Cargo Manifest Updates**
- `operator/Cargo.toml`: Standardized workspace author to "Moonsong
Labs"
- `operator/precompiles/precompile-registry/Cargo.toml`: Uses workspace
author field
- `operator/runtime/common/Cargo.toml`: Added workspace author field

## Benefits

- **Legal Compliance**: Ensures all dependencies use OSI-approved or
compatible licenses
- **Supply Chain Security**: Validates dependencies come from trusted
sources
- **Automated Enforcement**: Catches licensing issues during PR review
rather than at release time
- **Transparency**: Provides clear audit trail of approved licenses and
authors
2025-11-02 23:32:59 +02:00
Gonza Montiel
70a505e9d8
fix: update weight configurations for the three runtimes (#249)
# Update Runtime Weights and WeightInfo Implementations

## Summary
Updated runtime weights across all three runtimes (mainnet, stagenet,
testnet) and configured WeightInfo implementations to use the new
benchmarked weights.

## Changes
- All weight files have been updated with new benchmark data from
Substrate Benchmark CLI v51.0.0
- Updated some WeightInfo configurations to use custom weights instead
of the default `()`, such as `pallet_im_online`.

## Weights comparison against Moonbeam

Some weights are much higher than it's counterpart in Moonbeam, as we
can observe in the following table. We need to investigate if this is
expected.

EDIT:

### Weights using the `production` profile comparing stagenet vs
moonbase

| **Pallet** | **Function** | **DataHaven Weight** | **Moonbase Weight**
| **Difference** | **Notes** |

|------------|--------------|----------------------|---------------------|----------------|-----------|
| **pallet_balances** | transfer_allow_death | 68,497,000 | 43,117,000 |
**+59%** | DataHaven higher |
| | transfer_keep_alive | 55,245,000 | 41,490,000 | **+33%** | DataHaven
higher |
| | force_set_balance_creating | 22,034,000 | 21,537,000 | **+2%** |
Similar |
| | force_set_balance_killing | 31,246,000 | 23,467,000 | **+33%** |
DataHaven higher |
| | force_transfer | 72,181,000 | 45,384,000 | **+59%** | DataHaven
higher |
| | transfer_all | 67,765,000 | 51,403,000 | **+32%** | DataHaven higher
|
| | force_unreserve | 25,876,000 | 19,490,000 | **+33%** | DataHaven
higher |
| | upgrade_accounts (base) | 23,200,000 | 17,599,000 | **+32%** |
DataHaven higher |
| | force_adjust_total_issuance | 8,780,000 | 6,780,000 | **+29%** |
DataHaven higher |
| | burn_allow_death | 43,258,000 | 25,822,000 | **+68%** | DataHaven
higher |
| | burn_keep_alive | 30,368,000 | 22,961,000 | **+32%** | DataHaven
higher |
| **pallet_evm** | withdraw | 3,174,000 | 2,104,000 | **+51%** |
DataHaven higher |
| **frame_system** | remark (base) | 33,694,157 | 38,668,753 | **-13%**
| Moonbase higher |
| | remark_with_event (base) | 8,210,000 | 5,745,000 | **+43%** |
DataHaven higher |
| | set_heap_pages | 5,204,000 | 3,734,000 | **+39%** | DataHaven higher
|
| | set_code | 139,034,247,000 | 102,532,308,000 | **+36%** | DataHaven
higher |
| | set_storage (base) | 3,248,000 | 2,094,000 | **+55%** | DataHaven
higher |
| | kill_storage (base) | 3,344,000 | 2,120,000 | **+58%** | DataHaven
higher |
| | kill_prefix (base) | 6,028,000 | 4,258,000 | **+42%** | DataHaven
higher |
| | authorize_upgrade | 12,866,000 | 8,966,000 | **+44%** | DataHaven
higher |
| | apply_authorized_upgrade | 142,435,318,000 | 106,561,461,000 |
**+34%** | DataHaven higher |
| **pallet_multisig** | as_multi_threshold_1 (base) | 30,107,366 |
17,588,619 | **+71%** | DataHaven higher |
| | as_multi_create (base) | 45,353,453 | 32,782,725 | **+38%** |
DataHaven higher |
| | as_multi_approve (base) | 22,928,808 | 18,299,865 | **+25%** |
DataHaven higher |
| | as_multi_complete (base) | 57,510,735 | 41,555,387 | **+38%** |
DataHaven higher |
| | approve_as_multi_create (base) | 42,860,897 | 32,390,857 | **+32%**
| DataHaven higher |
| | approve_as_multi_approve (base) | 21,640,639 | 16,839,439 | **+29%**
| DataHaven higher |
| | cancel_as_multi (base) | 44,014,197 | 32,643,060 | **+35%** |
DataHaven higher |
| **pallet_treasury** | spend_local | 15,605,000 | 12,992,000 | **+20%**
| DataHaven higher |
| | remove_approval | 8,641,000 | 7,766,000 | **+11%** | DataHaven
higher |
| | on_initialize_proposals (base) | 19,249,676 | 16,973,066 | **+13%**
| DataHaven higher |
| | spend | 14,082,000 | 26,612,000 | **-47%** | Moonbase higher |
| | payout | 74,847,000 | 247,397,000 | **-70%** | Moonbase
significantly higher |
| | check_status | 16,325,000 | 16,223,000 | **+1%** | Similar |
| | void_spend | 15,059,000 | 15,167,000 | **-1%** | Similar |
| **pallet_scheduler** | service_agendas_base | 4,583,000 | 6,215,000 |
**-26%** | Moonbase higher |
| | service_agenda_base (base) | 8,728,153 | 6,640,549 | **+31%** |
DataHaven higher |
| | service_task_base | 4,875,000 | 3,455,000 | **+41%** | DataHaven
higher |
| | service_task_fetched (base) | 24,253,000 | 18,898,000 | **+28%** |
DataHaven higher |
| | service_task_named | 7,176,000 | 5,027,000 | **+43%** | DataHaven
higher |
| | service_task_periodic | 4,842,000 | 3,415,000 | **+42%** | DataHaven
higher |
| | execute_dispatch_signed | 10,378,000 | 4,837,000 | **+115%** |
DataHaven significantly higher |
| | execute_dispatch_unsigned | 3,511,000 | 2,451,000 | **+43%** |
DataHaven higher |
| | schedule (base) | 17,795,637 | 13,165,173 | **+35%** | DataHaven
higher |
| | cancel (base) | 20,509,326 | 15,513,197 | **+32%** | DataHaven
higher |

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com>
Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-10-29 17:14:21 +02:00
Steve Degosserie
8c950af4a4
fix: 🔧 Add Podman support to srtool runtime build script (#222)
## Summary

- Adds support for both Docker and Podman container engines in
`build-runtime-srtool.sh` via `IS_PODMAN` environment variable
- Uses `--userns=keep-id` for Podman (proper user namespace handling)
and `--user $(id -u):$(id -g)` for Docker
- Sets `IS_PODMAN=true` in `task-publish-runtime.yml` workflow to enable
Podman by default

## Changes

**`operator/scripts/build-runtime-srtool.sh`:**
- Added conditional logic to detect `IS_PODMAN` env var
- Dynamically selects between `podman` and `docker` as container engine
- Sets appropriate user/namespace flags based on container engine

**`.github/workflows/task-publish-runtime.yml`:**
- Added `IS_PODMAN: true` environment variable to the srtool build step
- Updated comment to use generic "container user" instead of "docker
user"

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-10 22:57:34 +02:00
Steve Degosserie
ba5ce56c5f
Revert "fix: 🔧 Fix build runtime srtool permission issue" (#221)
This reverts commit 5645c2f9f4.
2025-10-10 18:15:22 +02:00
Steve Degosserie
062584d1a2
fix: 🔧 Fix build runtime srtool permission issue (#220)
Co-authored-by: Claude <noreply@anthropic.com>
2025-10-10 16:38:11 +02:00
Steve Degosserie
8c693bfde7
fix: resolve srtool metadata hash build error (#219)
## Summary
- Fixes srtool build failure with `UnknownOpcode(252)` error during
metadata hash generation
- Removes hardcoded `WASM_BUILD_STD=0` to allow srtool to auto-detect
correct settings based on Rust version
- Adds `metadata-hash` feature to node Cargo.toml for CheckMetadataHash
extension

## Root Cause
The `WASM_BUILD_STD=0` setting forced srtool to use pre-built standard
library crates that were compiled with incompatible WASM features.
During metadata hash generation, the runtime builder encountered opcode
252 (likely from bulk memory operations) which the deserializer couldn't
recognize, causing the build to fail with:

```
thread 'main' panicked at metadata_hash.rs:73:10:
`Metadata::metadata_at_version` should exist.: RuntimeConstruction(Other("cannot deserialize module: UnknownOpcode(252)"))
```

## Changes
1. **operator/scripts/build-runtime-srtool.sh**: Removed hardcoded `-e
WASM_BUILD_STD=0` line
- Allows srtool to determine appropriate setting based on Rust version
   - For Rust < 1.84: defaults to WASM_BUILD_STD=1 (enabled)
   - For Rust >= 1.84: defaults to WASM_BUILD_STD=0 (disabled)

2. **operator/node/Cargo.toml**: Added `metadata-hash` feature
propagation
- Enables metadata-hash feature for all runtime variants (stagenet,
mainnet, testnet)
   - Required for CheckMetadataHash extension support

## Test Plan
- [x] Successfully built stagenet runtime with srtool 1.88.0
- [x] Build completed in ~14 minutes without metadata hash errors
- [x] Verified WASM artifacts generated correctly

## Testing Command
```bash
GH_WORKFLOW_MATRIX_CHAIN=stagenet \
RUNTIME_BUILD_OPTS="--features=on-chain-release-build" \
RUNTIME_BUILD_PROFILE="production" \
GH_WORKFLOW_MATRIX_SRTOOL_IMAGE="paritytech/srtool" \
GH_WORKFLOW_MATRIX_SRTOOL_IMAGE_TAG="1.88.0" \
WASM_BUILD_STD=1 \
./operator/scripts/build-runtime-srtool.sh
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-10 15:04:03 +02:00
Ahmad Kaouk
de2a1c1181
fix: fix srtool user (#215) 2025-10-08 11:40:13 +00:00
Steve Degosserie
bded4e9d5f
fix: 🔧 Fix build-runtime-srtool script (#210) 2025-10-07 13:45:34 +02:00
Steve Degosserie
51f4e1b0f3
feat: Publish runtime release Github action (#196) 2025-09-30 14:53:15 +02:00
Ahmad Kaouk
5db1f4ee74
refactor: cleanup obsolete test folder (#166)
### Summary
Removes the obsolete `operator/test` folder that was no longer being
used and contained outdated test scripts.

### Changes
-  Deleted `operator/test/` directory and all contents
-  Moved `test_message_encoding.sh` script to `operator/scripts/` for
proper organization
-  Updated comment reference in `contracts/test/MessageEncoding.t.sol`
to point to new script location

### Impact
- **No breaking changes** - All legitimate test files remain properly
organized within their respective pallets
- **Cleaner codebase** - Removes unused/obsolete code
2025-09-17 14:21:55 +02:00
Steve Degosserie
f0b2de3906
feat: Implement Moonbeam-style OpenGov governance (#131)
## 🎯 Overview

This PR implements a comprehensive Moonbeam-inspired OpenGov (Gov2)
governance system across all DataHaven runtime environments (Stagenet,
Testnet, and Mainnet). The implementation provides multi-track
referenda, conviction voting, collective decision-making through dual
councils, and complete benchmarking support.

##  Key Features

### 🗳️ Multi-Track Referendum System
Implements **6 distinct governance tracks** with different thresholds
and parameters:

| Track | Purpose |
|-------|---------|
| **Root (0)** | Critical runtime upgrades |
| **Whitelisted Caller (1)** | Fast-tracked technical proposals |
| **General Admin (2)** | General governance proposals |
| **Referendum Canceller (3)** | Cancel dangerous referenda |
| **Referendum Killer (4)** | Emergency removal of malicious referenda |
| **Fast General Admin (5)** | Expedited administrative decisions |

### 🏛️ Dual Council Structure
- **Technical Committee**: Manages technical proposals with fast-track
powers
- **Treasury Council**: Oversees treasury spending with shorter motion
duration

### 🔐 Custom Origins System
5 specialized permission levels for granular governance control:
- `GeneralAdmin`
- `ReferendumCanceller`
- `ReferendumKiller`
- `WhitelistedCaller`
- `FastGeneralAdmin`

### ⚖️ Conviction Voting
- Vote multipliers from 0.1x to 6x based on lock duration
- Delegation support for proxy voting
- Maximum 20 concurrent votes per account

🤖 Implementation assisted by [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-09-02 22:46:35 +02:00
Federico Rodríguez
843502d21a
test: init benchmark infra (#110)
* Add `run_benchmarks.sh` script to run runtime benchmarks
* Sets up benchmark configs and directory structure to store weights
(`operator/runtime/<RUNTIME>/weights`)
* (naive) fixes to some benchmarks: 
    * `pallet_datahaven_native_transfer`: 
      * use a mock for `NativeTokenId`
* look at the balance difference of the treasury instead of the total
(this makes the benchmark agnostic to genesis setup)
* `snowbridge_pallet_system` / `snowbridge_pallet_system_v2` use native
token xcm location vs relay chain one. Add missing benchmark methods and
update fixture with valid data.
* `snowbridge_pallet_ethereum_client`: update fixtures with valid data
* `snowbrige_pallet_inbound_queue_v2`: set EthereumGatewayAddress when
initializing storage on benchmark and use a mock message processor ( as
fixture has `CreateAsset` payload which is not supported in the
`EigenLayerMessageProcessor`)
* `snowbridge_pallet_outbound_queue_v2`: add missing
`submit_delivery_receipt` benchmark which required a dedicated fixture
(all copied from the upstream pallet)
* `pallet_treasury`: Use an `ExistentialDeposit` of `1` on benchmark,
else payout fails.
* `pallet_transaction_payment`: Use a custom `WeightToFee` that makes
the Fee small, else account in benchmark cannot pay for fees (It is
funded a multiplier of `ExistentialDeposit` and is expected for that to
be enough, but it's not in our particular setup).
* comment out `pallet_identity` and `pallet_im_online` due to
incompatibilities (to be addressed later)
* Basic benchmark run to set `WeightInfo` from `weights` in configs
(real run should be done later using target hardware)

---------

Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com>
Co-authored-by: Tobi Demeco <50408393+TDemeco@users.noreply.github.com>
Co-authored-by: undercover-cactus <lola@moonsonglabs.com>
Co-authored-by: TDemeco <tdemeco@itba.edu.ar>
2025-08-06 13:44:42 +02:00
Gonza Montiel
e16420f266
feat(ci): add script to sort cargo deps (#62)
This PR introduces a new script in `./operator/scripts` that allows us
to sort cargo dependencies alphabetically, it is based in my
[gist](https://gist.github.com/gonzamontiel/b4594c62685175f99760442ad2e2dd98).

I modified it so we can run it both in `--fix` and `--check` modes.

To sort a single cargo file, you can do:

```
./scripts/sort-cargo-deps.sh  /path/to/Cargo.toml
```

Btw, make sure you are in the operator folder and you have exec
permissions:

```
cd operator
chmod +x ./scripts/sort-cargo-deps.sh
```
But what I recommend is that you format every Cargo.toml just in case,
like this:
```
find . -name "Cargo.toml" -exec ./scripts/sort-cargo-deps.sh {} \;
```

The CI will run 

```
find . -name "Cargo.toml" -exec ./scripts/sort-cargo-deps.sh {} check \;
```

---------

Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-05-06 17:22:01 +00:00