Commit graph

81 commits

Author SHA1 Message Date
Facundo Farall
ae35a0824d
build: ⬆️ Upgrade to StorageHub version 0.2.6 (#357)
Upgrade to StorageHub release v0.2.6

No breaking changes, just a patch release

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
(cherry picked from commit d5e64d59e8)
2025-12-16 17:04:05 +01:00
Facundo Farall
d2dc4b846d
build: ⬆️ Upgrade to StorageHub v0.2.5 (#347)
Upgrades to StorageHub patch release v0.2.5

(cherry picked from commit 0d5f294097)
2025-12-09 15:27:09 +01:00
Tobi Demeco
f5c0397960
build: ⬆️ Upgrade to SH v0.2.3 (#340)
Upgrade StorageHub to v0.2.3 which includes some fixes for the indexer
plus minor changes to the runtime (which required a DataHaven metadata
update).

(cherry picked from commit 5f2b366031)
2025-12-04 21:39:40 +01:00
Steve Degosserie
f0e5bd449b
feat: RT810 runtime release (#339)
This PR bumps the runtime version to RT810 for an upcoming runtime
hotfix release (base branch is perm-runtime-rt800).
2025-12-04 17:19:58 +01:00
Gonza Montiel
e1e566568d
fix: update weights for RT800 (#329)
Weights update for release v0.8.0 (RT800).

- [x] Stagenet
- [x] Testnet
- [x] Mainnet

Showing some +10% changes:

Network | Pallet | Call | Old weight | New weight | Change %
-- | -- | -- | -- | -- | --
mainnet | frame_system | authorize_upgrade | 12496000 | 22629000 |
81.09%
mainnet | frame_system | remark | 30798441 | 8695261 | -71.77%
mainnet | pallet_conviction_voting | undelegate | 21395950 | 23795285 |
11.21%
mainnet | pallet_external_validators | remove_whitelisted | 17773467 |
15404854 | -13.33%
mainnet | pallet_multisig | as_multi_complete | 58059065 | 50189845 |
-13.55%
mainnet | pallet_preimage | request_no_deposit_preimage | 18808000 |
29216000 | 55.34%
mainnet | pallet_preimage | request_preimage | 26608000 | 40720000 |
53.04%
mainnet | pallet_preimage | request_requested_preimage | 13880000 |
16912000 | 21.84%
mainnet | pallet_preimage | request_unnoted_preimage | 19245000 |
33023000 | 71.59%
mainnet | pallet_preimage | unnote_no_deposit_preimage | 32229000 |
46218000 | 43.41%
mainnet | pallet_preimage | unnote_preimage | 70700000 | 91185000 |
28.97%
mainnet | pallet_preimage | unrequest_multi_referenced_preimage |
13961000 | 16754000 | 20.01%
mainnet | pallet_preimage | unrequest_preimage | 27274000 | 42435000 |
55.59%
mainnet | pallet_preimage | unrequest_unnoted_preimage | 13946000 |
16113000 | 15.54%
mainnet | pallet_scheduler | service_task_fetched | 24397000 | 4128742 |
-83.08%
mainnet | pallet_sudo | check_only_sudo_account | 5248000 | 6034000 |
14.98%
mainnet | pallet_utility | batch | 18376045 | 14956939 | -18.61%
mainnet | pallet_utility | batch_all | 13623778 | 9310421 | -31.66%
mainnet | pallet_utility | force_batch | 13126526 | 11589563 | -11.71%
stagenet | frame_system | authorize_upgrade | 12866000 | 23295000 |
81.06%
stagenet | frame_system | remark | 33694157 | 25734885 | -23.62%
stagenet | pallet_external_validators_rewards | on_era_end | 1583951000
| 1749571000 | 10.46%
stagenet | pallet_multisig | as_multi_complete | 57510735 | 51491532 |
-10.47%
stagenet | pallet_preimage | request_no_deposit_preimage | 18612000 |
30396000 | 63.31%
stagenet | pallet_preimage | request_preimage | 26129000 | 37317000 |
42.82%
stagenet | pallet_preimage | request_requested_preimage | 13912000 |
17268000 | 24.12%
stagenet | pallet_preimage | request_unnoted_preimage | 19198000 |
35428000 | 84.54%
stagenet | pallet_preimage | unnote_no_deposit_preimage | 31195000 |
45321000 | 45.28%
stagenet | pallet_preimage | unnote_preimage | 70675000 | 89916000 |
27.22%
stagenet | pallet_preimage | unrequest_multi_referenced_preimage |
13422000 | 16452000 | 22.57%
stagenet | pallet_preimage | unrequest_preimage | 27349000 | 43421000 |
58.77%
stagenet | pallet_preimage | unrequest_unnoted_preimage | 14104000 |
16640000 | 17.98%
stagenet | pallet_sudo | check_only_sudo_account | 5247000 | 5923000 |
12.88%
stagenet | pallet_utility | batch | 17077975 | 10949120 | -35.89%
stagenet | pallet_utility | batch_all | 11105082 | 4628520 | -58.32%
stagenet | pallet_utility | force_batch | 9291805 | 4409497 | -52.54%
testnet | frame_system | authorize_upgrade | 12576000 | 24096000 |
91.60%
testnet | frame_system | remark | 49594571 | 14515706 | -70.73%
testnet | pallet_external_validators_rewards | on_era_end | 1547405000 |
1732185000 | 11.94%
testnet | pallet_preimage | request_no_deposit_preimage | 17857000 |
30407000 | 70.28%
testnet | pallet_preimage | request_preimage | 25375000 | 42504000 |
67.50%
testnet | pallet_preimage | request_requested_preimage | 14069000 |
16591000 | 17.93%
testnet | pallet_preimage | request_unnoted_preimage | 19174000 |
34375000 | 79.28%
testnet | pallet_preimage | unnote_no_deposit_preimage | 29893000 |
46805000 | 56.58%
testnet | pallet_preimage | unnote_preimage | 71971000 | 89858000 |
24.85%
testnet | pallet_preimage | unrequest_multi_referenced_preimage |
13934000 | 16085000 | 15.44%
testnet | pallet_preimage | unrequest_preimage | 28700000 | 43751000 |
52.44%
testnet | pallet_preimage | unrequest_unnoted_preimage | 13989000 |
17138000 | 22.51%
testnet | pallet_sudo | check_only_sudo_account | 5279000 | 5881000 |
11.40%
testnet | pallet_utility | batch | 17940544 | 20806579 | 15.98%
testnet | pallet_utility | batch_all | 20328522 | 18215679 | -10.39%
testnet | pallet_utility | force_batch | 13240132 | 18456500 | 39.40%

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-12-02 22:46:27 +01:00
Facundo Farall
c1202e5d51
build: ⬆️ Upgrade to SH release 0.2.1 (#331) 2025-12-02 21:38:59 +01:00
Steve Degosserie
51ffcae5f0
Revert "feat: statically build binary (#292)" (#330)
This reverts commit f84b6debb7.
2025-12-02 15:42:43 +01:00
Gonza Montiel
82c581d495
feat: Add datahaven native transfer precompile (#309)
## DataHaven Native Transfer Precompile

Implements EVM precompile at address
`0x00000000000000000000000000000007F5` (2073) to expose
`pallet-datahaven-native-transfer` functionality to the EVM layer.

### Features
- **Transfer to Ethereum**: Locks native tokens and sends them via
Snowbridge to Ethereum addresses
- **Pause/Unpause**: Admin controls to halt/resume transfers
- **View Functions**: Query paused state, total locked balance, and
sovereign account address

### Implementation
- Precompile using `#[precompile_utils::precompile]` macro with proper
gas accounting
- 15+ test cases covering success/failure scenarios
- Solidity interface with NatSpec documentation for contract integration

Enables seamless cross-chain transfers of DataHaven native tokens to
Ethereum L1.

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-12-02 13:57:40 +01:00
Facundo Farall
4d5716fdcb
build(operator): ⬆️ Upgrade to storage-hub 0.2.0 (#327)
## ⚠️ Breaking Changes ⚠️

Upgrades to SH version 0.2.0. Breaking changes for this version are
outlined in the corresponding
[release](https://github.com/Moonsong-Labs/storage-hub/releases/tag/v0.2.0).

Particularly, in this PR, the following breaking changes are implemented
for DH node operators:

### Breaking CLI changes vs `main`

- **Fisherman vs provider role**  
- `--fisherman` now has `conflicts_with = "provider"`
(`FishermanConfigurations::fisherman`).
- Any existing scripts that started a node with both `--provider` and
`--fisherman` will now fail clap validation.

- **Removed / replaced fisherman tuning flags**  
- The following flags no longer exist and will cause errors if still
used:
- `--fisherman-incomplete-sync-max` (field
`fisherman_incomplete_sync_max`)
- `--fisherman-incomplete-sync-page-size` (field
`fisherman_incomplete_sync_page_size`)
- `--fisherman-sync-mode-min-blocks-behind` (field
`fisherman_sync_mode_min_blocks_behind`)
  - They are replaced by:  
- `--fisherman-batch-interval-seconds`
(`fisherman_batch_interval_seconds`, default `60`)
- `--fisherman-batch-deletion-limit` (`fisherman_batch_deletion_limit`,
default `1000`)

- **MSP DB wiring no longer piggybacks on the indexer DB**  
- Previously, enabling the indexer (`IndexerConfigurations`) also wired
its DB pool into the MSP move‑bucket path via
`with_indexer_db_pool(maybe_indexer_db_pool)`.
- Now, MSP DB access is **only** configured if you pass the new
`--msp-database-url` provider flag; the indexer’s `--indexer` /
`--indexer-database-url` no longer implicitly provide DB access to MSP
logic. This will change behaviour for MSP nodes that relied on just the
indexer flags.

### New / additive CLI flags (non‑breaking but behaviourally relevant)

- **Provider flags**  
- `--pending-db-url` (`pending_db_url`, env `SH_PENDING_DB_URL`) for
persisting pending extrinsics.
- `--internal-buffer-size` (`internal_buffer_size`, default `1024`) for
DB chunk batching during file transfer.

- **Reordered but unchanged**  
- `--msp-distribute-files` still exists (bool flag), just moved within
`ProviderConfigurations`; name and type are unchanged, but now also
explicitly toggles `enable_msp_distribute_files` only when
`provider_type == msp`.
2025-12-02 11:55:31 +01:00
undercover-cactus
f84b6debb7
feat: statically build binary (#292)
Co-authored-by: Gonza Montiel <gonzamontiel@users.noreply.github.com>
2025-11-28 13:38:05 +00:00
Steve Degosserie
32480f1bbc
feat: Bump client version to v0.8.0 & Runtime version to RT800 (#312) 2025-11-19 18:30:02 +00:00
Facundo Farall
ae9eef7307
build: ⬆️ Upgrade to StorageHub release 0.1.4 (#298)
Upgrades to StorageHub release
[v0.1.4](https://github.com/Moonsong-Labs/storage-hub/releases/tag/v0.1.4).

## ⚠️ Breaking Changes ⚠️
- A DB migration for the indexer DB. Should be auto-applied by the
indexer node on startup, if this is not disabled by the env var
`SH_INDEXER_DB_AUTO_MIGRATE`. By default, it applies them.
- A new runtime API (`shp_tx_implicits_runtime_api::TxImplicitsApi`)
needed for StorageHub's Blockchain Service to build transactions using
the runtime spec version from the currently run runtime.

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-11-16 16:44:17 +01:00
Steve Degosserie
4c8384499f
feat: Bump client version to v0.7.0 & Runtime version to RT700 (#299) 2025-11-16 11:43:11 +01:00
Facundo Farall
0d2333ed02
build: ⬆️ Upgrade to SH release 0.1.3 (#294)
Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-11-10 21:58:40 +01:00
Steve Degosserie
e6cba95563
fix: 🪳 Fix gas cost in collective precompile (#291)
Cherry-pick fix from
https://github.com/moonbeam-foundation/moonbeam/pull/3540 for the
Collective precompile.

> In the `members` and `is_member` functions, the `MaxProposals` value
was being used instead of `MaxMembers` to record gas costs for database
access.
2025-11-10 14:55:57 +01:00
Facundo Farall
ff5cd8dc59
build: ⬆️ Upgrade to SH v0.1.2 (#289) 2025-11-07 21:34:43 +01:00
Steve Degosserie
a97f0547a9
feat: Update chain IDs & native token tickers for all 3 environments (#280)
Update the 3 DataHaven environments' chain IDs & native token ticker as
follows:

* **Mainnet**
  * **Chain ID**: 55930
  * **Ticker**: HAVE
* **TestNet**
  * **Chain ID**: 55931
  * **Ticker**: MOCK
* **Stagenet**
  * **Chain ID**: 55932
  * **Ticker**: STAGE

The PR includes a storage migration for the Stagenet & Testnet
environments, that are already live, to update the EVM Chain ID stored
in the `pallet-evm-chain-id` pallet.

Note: the token symbol will only be updated with the genesis config
presets or newly generated chain specs. For already live networks, the
existing chain spec must be updated (i.e. the tokenSymbol property
changed) and used by all nodes in the network. This change in the chain
spec will not alter the chain genesis so it safe to do (in the very
early stages of the chain obviously).

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-07 12:14:28 +01:00
Steve Degosserie
c7d73af4ca
feat: Bump client version to v0.6.0 & runtime version to RT600 (#276) 2025-11-04 12:51:23 +02:00
Steve Degosserie
c09ff91a66
feat: Bump client version to v0.5.0 & runtime version to RT500 (#274) 2025-11-03 16:35:22 +02:00
Facundo Farall
1fd0abccd7
build: ⬆️ Upgrade to SH v0.1.1 (#273)
Upgrade to SH release
[v0.1.1](https://github.com/Moonsong-Labs/storage-hub/releases/tag/v0.1.1)

---------

Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com>
Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-11-03 15:49:30 +02:00
Gonza Montiel
96c4408682
fix: add missing weights (#271)
### Add missing weights for BABE, GRANDPA, and Randomness

#### Summary
Adds generated weights and wires them into the runtime for the BABE,
GRANDPA, and Randomness pallets to replace defaults and ensure accurate
execution costs across networks.

#### What’s changed
- **New weights added** for `pallet_grandpa`, `pallet_babe` and
`pallet_randomness`
- **Runtime configs updated to use new weights**
  - `operator/runtime/mainnet/src/configs/mod.rs`
  - `operator/runtime/stagenet/src/configs/mod.rs`
  - `operator/runtime/testnet/src/configs/mod.rs`
 
 #### For follow-up PRS
- fix `pallet_identity` failure at running benchmarks
- fix `pallet_collective` benchmarking missmatch (related to
https://github.com/paritytech/polkadot-sdk/pull/6435)
- add `pallet_session_benchmarking` without including `pallet_staking`
(or some workaround)
- add StorageHub weights to our benchmarked pallets (`pallet_nfts`,
`pallet_storage_providers`, `pallet_payment_streams`,
`pallet_proofs_dealer`, `pallet_file_system`, `pallet_bucket_nfts`, etc)
2025-11-02 22:50:55 +02:00
Steve Degosserie
e860c503c8
feat: Bump client version to v0.4.0 & runtime version to RT400 (#268) 2025-10-30 18:02:25 +02:00
undercover-cactus
7c8227f1ab
feat: set slashing mode in genesis config (#264)
In this PR we set the slashing mode value in the genesis config. For the
3 different runtime we specify the slashing mode : `mainnet/testnet` is
set to `Disabled` and for `stagenet` to `LogOnly`.

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-10-29 18:24:49 +02:00
undercover-cactus
f0896907ae
feat: add slashing support (#242)
## 🔨 Add Slashing Support for Runtime

This PR introduces the slashing functionality for the DataHaven runtime,
enabling punitive measures against misbehaving validators.


### Features
- Deferred slashing with configurable veto periods
- Cross-chain slashing message delivery trough Snowbridge
- Governance controls for slashing parameters and emergency cancellation

We introduced the `external-validator-slashes` pallet, which allows to
slash validators that misbehave. The slashing is triggered when an
offence is reported via the offence pallet (which is already
implemented). The message is sent through Snowbrige's outbound queue and
the real slashing happens in the contracts side, which will come in a
follow up PR.

There is a configurable window of time between the time the validator is
being reported, and the time the slash is triggered. This allows that in
case of an error we are still able to cancel the slashing, using a sudo
account.

For convenience, we also have extrinsics for corner cases:

- **`force_inject_slash`**: Root-only function to manually inject
slashes for specific validators with custom percentages. Useful for
emergency situations or governance-directed slashing outside normal
offence detection
- **`cancel_deferred_slash`**: Allows governance to cancel pending
slashes during the defer period by specifying era and slash indices.
Provides safety mechanism against false positives or malicious slash
reports
- **`set_slashing_mode`**: Configurable slashing behavior with three
modes - `Enabled` (normal operation), `LogOnly` (track offences without
applying slashes), and `Disabled` (completely halt slashing). Critical
for emergency response and testing

---------

Co-authored-by: Gonza Montiel <gon.montiel@gmail.com>
Co-authored-by: Gonza Montiel <gonzamontiel@users.noreply.github.com>
2025-10-29 10:43:55 +00:00
Steve Degosserie
879be715b5
feat: Bump client version to v0.3.1 & runtime spec_version to 310 (#250) 2025-10-24 19:57:07 +03:00
Steve Degosserie
f934707d7c
feat: Bump client version to v0.3.0 & runtime spec_version to 300 (#224) 2025-10-11 00:38:19 +02:00
Gonza Montiel
1ec56681a5
feat: add referenda precompile (#217)
# Add Referenda Precompile

This PR introduces the referenda precompile from Moonbeam to enable
governance functionality through EVM calls.

## Changes Made

- Added `operator/precompiles/referenda/` with complete implementation
- Updated all runtime configs (mainnet, stagenet, testnet) to include
the referenda precompile
- Adapted track processing logic to work with DataHaven's runtime
configuration
- Adapted tests and mock according to our runtime

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-10-11 00:17:21 +02:00
Facundo Farall
c978150582
build: ⬆️ Upgrade to StorageHub v0.0.6-alpha (#212)
This PR upgrades the StorageHub dependencies to tag
[v0.0.6-alpha](https://github.com/Moonsong-Labs/storage-hub/releases/tag/v0.0.6-alpha).
This includes the fix to connect through TLS to a Postgres DB (allowing
connecting to an AWS hosted DB for instance), and a fix for a missing
indexer DB migration.

Additionally, it adds a new runtime API.

EDIT (previously breaking changes):
As of the new version, the name of a column in the indexer DB has
changed. This can affect the functionality of nodes running a Postgres
DB with the old schema. A
[migration](05d269a26d)
is included in the new
[tag](https://github.com/Moonsong-Labs/storage-hub/commits/v0.0.6-alpha/),
so no need to mark it as breaking.

---------

Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
Co-authored-by: Gonza Montiel <gonzamontiel@users.noreply.github.com>
Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-10-10 22:04:32 +02:00
Ahmad Kaouk
55e973b8f0
fix: change pallet_evm alias to EVM to fix eth_getCode (#213)
## Summary
- rename the FRAME alias for `pallet_evm` from `Evm` to `EVM` across the
mainnet, stagenet, and testnet runtimes
- adjust benchmarks, configuration modules, genesis builders, and
runtime tests to rely on the new alias
- keep precompile genesis setup and proxy/precompile tests aligned with
the updated names

  ## Context
Frontier’s `StorageOverrideHandler` (see
`fc_storage::StorageQuerier::account_code`) reads contract bytecode from
`pallet_evm::AccountCodes` using the constant `PALLET_EVM = b"EVM"` to
build the storage key:
  `twox_128("EVM") ++ twox_128("AccountCodes") ++ …`

Our runtimes exported `pallet_evm` as `Evm`, so substrate stored
bytecode under the *camel-cased* prefix (`twox_128("Evm")`). Every call
that ultimately hits the storage override—including `eth_getCode`,
`eth_call`, and state queries during replay—therefore failed to locate
code for *any* account (deployed contracts and precompiles alike).
Renaming the alias to `EVM` realigns the storage prefix with Frontier’s
  expectations so the override layers can pull bytecode correctly.

  ## Testing
  - `cargo check -p datahaven-node`
  - `cargo build --release -p datahaven-node`
- `eth_getCode 0x0000000000000000000000000000000000000802` → returns
`0x60006000fd`
  
## Storage Migration
Renaming a pallet alias changes the storage prefix for all pallet data.
Without migration, existing EVM data (smart contracts, account codes,
storage) would become inaccessible.

  **Migration details:**

  - **Type**: Multi-Block Migration (MBM)
- **Storage migrated**: `AccountCodes`, `AccountCodesMetadata`,
`AccountStorages`
  - **Migration ID**: `datahaven-evm-mbm` (version 0 → 1)

  **Testing the migration:**

  ```bash
  # Build runtime with try-runtime
cargo build --release --features try-runtime -p
datahaven-stagenet-runtime

  # Test against stagenet
try-runtime \
--runtime
./target/release/wbuild/datahaven-stagenet-runtime/datahaven_stagenet_runtime.wasm
\
      on-runtime-upgrade \
      --blocktime 6000 \
      --checks all \
      --disable-spec-version-check \
      live --uri wss://dh-validator-0.datahaven-kt.xyz
```

  Test results from stagenet:
  -  Migration completes in 1 block
  -  PoV size: ~5.3 KB
  -  Weight consumption: <0.1% of block capacity
  -  All 39 keys successfully migrated

  ## ⚠️ Breaking Changes ⚠️
If you are manually computing storage keys for the EVM pallet (e.g., directly querying chain state), you must update your code to use the new storage prefix:
  - Old prefix: twox128("Evm") = 0x8b90cb...
  - New prefix: twox128("EVM") = 0x6a5e91...

  All EVM-facing interfaces remain unchanged.
2025-10-10 17:48:52 +00:00
Gonza Montiel
2d6056721a
feat: add preimage precompile (#211)
## Add Preimage Precompile

This PR integrates the Preimage precompile from Moonbeam into the
DataHaven runtime across all three environments (mainnet, stagenet,
testnet).

**Key Changes:**
- Added Preimage precompile implementation at address `2067` in all
runtime configurations
- Updated precompile sets in mainnet, stagenet, and testnet runtimes
- Updated `is_governance_precompile()` for the Preimage precompile
2025-10-09 13:16:46 +02:00
Gonza Montiel
0988ce46d0
feat: add conviction voting precompile (#202)
## Add Conviction Voting Precompile

This PR introduces a new EVM precompile for conviction voting
functionality, enabling smart contracts to interact with the Substrate
conviction voting pallet.

### Key Changes

- **New Precompile**: Added `ConvictionVotingPrecompile` at address
`0x0000000000000000000000000000000000000812` (2066)
- **Solidity Interface**: Complete Solidity interface
(`ConvictionVoting.sol`) with all conviction voting operations
- **Runtime Integration**: Integrated precompile across all runtime
configurations (mainnet, testnet, stagenet)
- **Comprehensive Testing**: Inherits test suite from Moonbeam

### Features

- Vote casting with different conviction levels (None, Locked1x-6x)
- Vote delegation and undelegation
- Poll management and tallying
- Support for all conviction voting pallet operations

---------

Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-10-09 10:30:50 +02:00
Gonza Montiel
f7d441d9e5
feat: add collective precompile (#204)
## Add Collective Precompile

Adds the pallet collective precompile to `mainnet`, `stagenet`, and
`testnet` according to Moonbeam's configuration.

### Changes:
- Added `pallet-evm-precompile-collective` dependency to workspace
- Configured collective precompile at address `2064` using
`TreasuryCouncilInstanc`
- Configured collective precompile at address `2068` using
`TechnicalCommitteeInstance`

The precompile provides EVM access to collective governance
functionality including proposal execution, voting, and membership
management.

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-10-08 23:16:34 +02:00
Gonza Montiel
65e245a82e
feat: add identity precompile (#205)
## Add Identity Precompile

Adds the pallet Identity precompile to `mainnet`, `stagenet`, and
`testnet` according to Moonbeam's configuration.

### Changes:
- Added `pallet-evm-precompile-identity` dependency to workspace
- Added and configured at address `2072` for all runtimes

The precompile provides a Solidity interface access to the Substrate
Identity pallet functionality.

---------

Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-10-08 13:48:17 +00:00
Ahmad Kaouk
ac09a4f2bb
feat: Add SafeMode and TxPause Pallets (#192)
### Overview
This PR integrates the `pallet-safe-mode` and `pallet-tx-pause` from
Polkadot SDK to provide comprehensive emergency governance controls
across all DataHaven runtime networks (mainnet, stagenet, testnet).

### Key Changes

#### 🔧 **Core Integration**
- **Dependencies**: Added `pallet-safe-mode` and `pallet-tx-pause` from
`polkadot-stable2412-6`
- **Runtime Integration**: Integrated both pallets across all three
runtime networks with pallet indices 103 and 104
- **Call Filtering**: Implemented unified `RuntimeCallFilter` that
combines Normal, SafeMode, and TxPause restrictions

#### 🛡️ **SafeMode Pallet Configuration**
- **Duration**: 1 day activation period (`DAYS` constant)
- **Deposits**: Disabled permissionless entry/extension (all `None`)
- **Origins**: Root-only for all force operations (`force_enter`,
`force_exit`, `force_extend`, etc.)
- **Whitelisting**: SafeMode and Sudo calls are immune to restrictions

#### ⏸️ **TxPause Pallet Configuration** 
- **Origins**: Root-only pause/unpause control
- **Whitelisting**: SafeMode and Sudo calls cannot be paused
- **Max Call Name Length**: 256 characters

#### 🏗️ **Architecture**
- **Shared Types**: Created `operator/runtime/common/src/safe_mode.rs`
with reusable configurations
- **Combined Filtering**: `RuntimeCallFilter` applies all three filter
layers (Normal + SafeMode + TxPause)
- **Consistent Config**: Identical configuration across mainnet,
stagenet, and testnet

#### 📊 **Infrastructure Updates**
- **Benchmarking**: Added both pallets to benchmark suites across all
networks
- **Weight Mappings**: Placeholder weights using Substrate defaults
(ready for chain-specific benchmarking)
- **Metadata**: Updated runtime metadata for new pallet exposure

#### 🧪 **Testing Framework**
- **Coverage**: Tests for individual pallet behavior, combined
restrictions, whitelisting, and edge cases

### Emergency Control Capabilities

**SafeMode Pallet** (8 calls):
- User calls: `enter`, `extend`, `release_deposit`
- Force calls: `force_enter`, `force_exit`, `force_extend`,
`force_slash_deposit`, `force_release_deposit`

**TxPause Pallet** (2 calls):
- `pause_call` / `unpause_call` - Granular transaction type pausing

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-10-06 17:00:10 +00:00
undercover-cactus
d2ff687dc0
feat: added the possibility to provide a config file for SH (#191)
Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-09-30 17:39:11 +00:00
Steve Degosserie
91e29700a3
feat: Bump client version to v0.2.0 & runtime spec_version to 200 (#194) 2025-09-29 23:35:12 +02:00
undercover-cactus
5165cbbbea
misc: update sh deps to v0.0.4-alpha (#193)
In this PR we update StorageHub to its latest tage `v0.0.4-alpha`. It
includes so minor changes on the FilesystemAPI.

Its also force to specify the `maintenance_mode` options for fisherman.
For now we are not allowing this mode so we just skip entirely.

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-09-29 20:29:17 +00:00
undercover-cactus
e5e3fbe22c
fix: fix RPC for storage hub (#190)
In this PR we actually add the storage hub RPC config to our node in
order to allow RPC call for storage hub service.
2025-09-27 19:03:32 +02:00
Ahmad Kaouk
eb94be1e3f
feat: multi block migration pallet (#180)
## Overview

This PR integrates Substrate's `pallet-migrations` into all DataHaven
runtimes (mainnet, stagenet, testnet) to enable robust multi-block
migration capabilities. This infrastructure allows complex runtime
upgrades to be executed across multiple blocks while maintaining chain
stability and providing governance controls.

## What Changed

### Core Integration
- **Added `pallet-migrations` dependency** across all runtime
configurations
- **Integrated migration pallet** as pallet index 39 in all runtimes  
- **Created shared migration configuration** in
`datahaven-runtime-common`

### Runtime Configuration
- **Mainnet, Stagenet, and Testnet** now include identical migration
configurations
- **MaxServiceWeight** parameter set to 75% of max block weight for safe
migration execution
- **Migration cursor limits** configured (65KB max cursor, 256B max
identifier)
- **Failure handling** configured to freeze the chain on migration
failures (similar to Moonbeam's maintenance mode)

## Future Work

- [ ] Add custom failure handler (safe mode) to replace chain freeze
- [ ] Generate DataHaven-specific benchmarks for migration weights

---------

Co-authored-by: undercover-cactus <lola@moonsonglabs.com>
2025-09-24 12:27:44 +02:00
undercover-cactus
ec91e593f7
misc: update SH deps to v0.0.2-alpha tag (#171)
Update SH dep to ` v0.0.2-alpha`
2025-09-17 17:14:50 +02:00
Gonza Montiel
f8b5706073
feat: add filesystem precompile (#165)
Incorporate `pallet-evm-precompile-file-system` into `stagenet`,
`testnet` and `mainnet`.

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-09-15 10:43:00 +02:00
Ahmad Kaouk
b5a6406470
feat: Add ERC20 Balances precompile (#150)
## Summary
- Introduces an ERC20-compatible precompile backed by `pallet_balances`,
including approvals and EIP-2612 permit.
- Wires the precompile into Mainnet, Testnet, and Stagenet at address
`0x0000000000000000000000000000000000000802` (u64: 2050).
- Adds comprehensive unit tests and a mock runtime.

## Motivation
- Allow EVM contracts and tooling to interact with Substrate balances
via a familiar ERC20 interface.
- Support off-chain approvals via EIP-2612 for gasless approvals and
improved UX.

## Key Changes
- New crate: `operator/precompiles/erc20-balances`
  - Core logic: `src/lib.rs`
  - EIP-2612 helpers and validation: `src/eip2612.rs`
  - Tests + mock runtime: `src/tests.rs`, `src/mock.rs`
- Runtime wiring (all networks): add `Erc20BalancesPrecompile` at
`AddressU64<2050>`
  - `operator/runtime/{mainnet,stagenet,testnet}/src/precompiles.rs`
- Workspace plumbing: include `pallet-evm-precompile-balances-erc20` in
`operator/Cargo.toml`

## Interface
- ERC20: `totalSupply`, `balanceOf`, `allowance`, `approve`, `transfer`,
`transferFrom`, `name`, `symbol`, `decimals`
- Native-only flows: `deposit()` (fallback/payable) and
`withdraw(uint256)`
- EIP-2612: `permit(owner,spender,value,deadline,v,r,s)`,
`nonces(owner)`, `DOMAIN_SEPARATOR()`
- Events: `Transfer`, `Approval`, `Deposit`, `Withdrawal`
- Storage:
- Approvals via `ApprovesStorage` (double map: owner → spender → amount)
  - EIP-2612 nonces via `NoncesStorage` keyed by `H160`
- Instance-aware prefixes to support multiple `pallet_balances`
instances
2025-09-12 08:57:44 +00:00
Ahmad Kaouk
788e5efaa4
feat: Add proxy Precompile (#155) 2025-09-12 09:45:26 +02:00
undercover-cactus
ecd3311bb6
feat: add indexer configurations to cli (#154)
Added missing CLI option for the indexer configuration for Storage Hub.
Indexer is needed for MSP user.

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-09-12 00:11:37 +02:00
undercover-cactus
a9d0f7157a
feat: storage hub client (#149)
Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-09-10 08:15:27 +02:00
Steve Degosserie
479af2e192
feat: Add Moonbeam CallPermit precompile (#140)
## Summary

This PR adds Moonbeam's CallPermit precompile to DataHaven, enabling
gasless meta-transactions through EIP-712 signature-based permissions.
Users can sign transaction permits offline, allowing relayers to execute
transactions on their behalf while maintaining full security and
authentication.

## Key Features

### CallPermit Precompile Functions
- **`dispatch(address from, address to, uint256 value, bytes data,
uint64[] gasLimit, uint256 deadline, uint8 v, bytes32 r, bytes32 s)`**:
Execute permitted calls with signature verification
- **`nonces(address owner)`**: Get current nonce for permit validation

### Technical Implementation
- **Address**: `0x080A` (2058 in decimal)
- **EIP-712 Compliance**: Structured signature validation with proper
domain separation
- **Nonce Management**: Per-user nonce tracking for replay protection
- **Deadline Validation**: Time-bound permits for enhanced security
- **Gas Forwarding**: Proper gas limit enforcement and forwarding

Depends on https://github.com/datahaven-xyz/datahaven/pull/137

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-07 15:00:37 +02:00
Steve Degosserie
757a99b7c6
feat: Add Moonbeam Batch precompile (#138)
## Summary

This PR adds Moonbeam's Batch precompile to DataHaven, enabling
efficient batching of multiple EVM transactions in a single call. This
implementation follows Moonbeam's exact architecture and provides
significant gas savings for batch operations.

## Key Features

### Batch Precompile Functions
- **`batchSome(address[], uint256[], bytes[], uint64[])`**: Execute
multiple calls, continuing on failures
- **`batchSomeUntilFailure(address[], uint256[], bytes[], uint64[])`**:
Execute calls until first failure
- **`batchAll(address[], uint256[], bytes[], uint64[])`**: Execute all
calls, reverting if any fail

### Technical Implementation
- **Address**: `0x0808` (2056 in decimal)
- **Access Control**: Restricted nesting with `SubcallWithMaxNesting<2>`
- **Self-recursion**: Only the Batch precompile can call itself
(`OnlyFrom<AddressU64<2056>>`)
- **Gas Management**: Proper gas estimation and refund handling
- **Error Handling**: Comprehensive revert reasons and event logging

Depends on #137

---------

Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com>
2025-09-05 19:24:09 +02:00
Steve Degosserie
6886bcbdde
feat: Add Moonbeam EVM Precompile Registry (#137)
## Summary

This PR implements a comprehensive EVM precompile registry system for
DataHaven, following Moonbeam's exact architecture and patterns. The
implementation includes:

- **Registry Precompile**: A new precompile at address `0x0815` (2069)
that manages and queries available precompiles
- **Core Ethereum Precompiles**: Standard Ethereum precompiles
(ECRecover, SHA256, RIPEMD160, Identity, ModExp, BN128Add, BN128Mul,
BN128Pairing, Blake2F, SHA3FIPS)
- **Modular Architecture**: Clean separation following Moonbeam's
structure with dedicated precompile modules per runtime

## Key Features

### Registry Precompile Functions
- `isPrecompile(address)`: Check if an address corresponds to any
precompile (active or inactive)
- `isActivePrecompile(address)`: Check if a precompile is currently
active in the runtime
- `updateAccountCode(address)`: Insert dummy EVM bytecode for Solidity
compatibility

### Runtime Integration
- Integrated across all three runtimes (testnet, stagenet, mainnet)
- Uses Moonbeam's `PrecompileSetBuilder` pattern for composable
precompile management
- Proper gas accounting with database read/write operations
- Access control through `CallableByContract` and `CallableByPrecompile`
traits

---------

Co-authored-by: undercover-cactus <lola@moonsonglabs.com>
2025-09-04 10:25:59 +02:00
Steve Degosserie
ee7969b540
chore: ♻️ Update project dependencies (#147)
This PR updates the project dependencies as follows:
- **Polkadot SDK**: from the `stable2412` (moving) branch to the
`polkadot-stable2412-6` (fixed) tag.
- **StorageHub**: to revision
`f8281283b6003a3009a32431ed0f3cd628561d6b`, which also depends on
Polkadot SDK `polkadot-stable2412-6`.
- **Frontier**: revision `75329a2df49e2cc7981485392c31160929d1bd48n`
which, likewise, depends on Polkadot SDK `polkadot-stable2412-6`.
2025-09-04 00:17:11 +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