datahaven/operator/runtime/testnet/tests/common.rs

350 lines
11 KiB
Rust
Raw Permalink Normal View History

// Copyright 2025 DataHaven
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
// This file is part of DataHaven.
// DataHaven is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// DataHaven is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with DataHaven. If not, see <http://www.gnu.org/licenses/>.
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
//! Common test utilities for DataHaven testnet runtime tests
use datahaven_testnet_runtime::{
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 20:46:35 +00:00
currency::{HAVE, SUPPLY_FACTOR},
AccountId,
Balance,
Runtime,
RuntimeCall,
RuntimeEvent,
RuntimeOrigin,
Session,
SessionKeys,
System,
// Import governance pallets for common helpers
TechnicalCommittee,
TreasuryCouncil,
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
};
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 20:46:35 +00:00
use frame_support::{
assert_ok,
traits::{OnFinalize, OnInitialize},
};
use frame_system::pallet_prelude::BlockNumberFor;
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use sp_consensus_babe::AuthorityId as BabeId;
use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
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 20:46:35 +00:00
use sp_core::{crypto::UncheckedFrom, H160, H256};
use sp_runtime::{
traits::{BlakeTwo256, Hash},
BuildStorage,
};
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
/// Test account constants
pub const ALICE: [u8; 20] = [1u8; 20];
pub const BOB: [u8; 20] = [2u8; 20];
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
pub const CHARLIE: [u8; 20] = [3u8; 20];
pub const DAVE: [u8; 20] = [4u8; 20];
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 20:46:35 +00:00
pub const EVE: [u8; 20] = [5u8; 20];
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
/// Helper function to convert account constants to AccountId
pub fn account_id(account: [u8; 20]) -> AccountId {
H160(account).into()
}
/// Default balance for test accounts (1M DH tokens)
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 20:46:35 +00:00
pub const DEFAULT_BALANCE: Balance = 1_000_000 * HAVE * SUPPLY_FACTOR;
/// Governance test specific balances
#[allow(dead_code)]
pub const INITIAL_BALANCE: Balance = 1_000_000 * HAVE * SUPPLY_FACTOR; // 1M DH tokens for governance tests
#[allow(dead_code)]
pub const PROPOSAL_BOND: Balance = 100 * HAVE * SUPPLY_FACTOR;
#[allow(dead_code)]
pub const VOTING_BALANCE: Balance = 10 * HAVE * SUPPLY_FACTOR;
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
/// Generate test session keys for a given account
pub fn generate_session_keys(account: AccountId) -> SessionKeys {
let account_bytes: &[u8; 20] = account.as_ref();
let first_byte = account_bytes[0];
SessionKeys {
babe: BabeId::unchecked_from([first_byte; 32]),
grandpa: GrandpaId::unchecked_from([first_byte; 32]),
im_online: ImOnlineId::unchecked_from([first_byte; 32]),
beefy: BeefyId::unchecked_from([first_byte; 33]),
}
}
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
/// Test runtime builder following Moonbeam pattern
#[derive(Default)]
pub struct ExtBuilder {
balances: Vec<(AccountId, Balance)>,
with_default_balances: bool,
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
validators: Vec<AccountId>,
with_default_validators: bool,
feat: ✨ Integrate Proxy pallet into DataHaven runtimes (#128) ## Summary This PR integrates the Substrate Proxy pallet into DataHaven runtimes (testnet, stagenet, mainnet) with comprehensive test coverage. The proxy pallet enables account delegation functionality, allowing accounts to authorize other accounts to execute calls on their behalf with configurable permissions. ## Changes ### Proxy Pallet Integration - **Added proxy pallet** to all three DataHaven runtimes (testnet, stagenet, mainnet) - **Configured custom ProxyType enum** with DataHaven-specific proxy types: - `Any` - Unrestricted proxy access - `NonTransfer` - All calls except balance transfers - `Governance` - Governance and utility calls only - `Staking` - Staking operations (placeholder) - `CancelProxy` - Proxy announcement cancellation - `Balances` - Balance transfer operations only - `IdentityJudgement` - Identity judgement operations - `SudoOnly` - Privileged sudo operations only ### Runtime Configuration - **Integrated pallet-proxy** into runtime construction macros - **Configured proxy deposits** (base + per-proxy fees) - **Set proxy limits** (maximum proxies per account) - **Implemented InstanceFilter** for call filtering per proxy type - **Added proxy pallet to runtime APIs** and metadata ### Comprehensive Test Suite - `operator/runtime/testnet/tests/proxy.rs` - 24 comprehensive proxy tests - `operator/runtime/stagenet/tests/proxy.rs` - 24 comprehensive proxy tests - `operator/runtime/mainnet/tests/proxy.rs` - 24 comprehensive proxy tests - Updated `lib.rs` files in all three runtimes to include proxy test modules <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Enable account proxies across mainnet, stagenet, and testnet with configurable types, delays, and per-type call permissions. - Support anonymous (pure) proxies, proxy announcements with delays, and deposit/limit parameters for proxy management. - Tests - Add comprehensive integration tests covering proxy lifecycle, filtering, pure proxies, announcements, batching, chaining, multisig, identity, and sudo paths. - Test builder now supports optional sudo setup. - Chores - Add benchmarking, weights, and try-runtime support for proxies. - Update internal package metadata version. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com> Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-08-18 07:46:59 +00:00
sudo_key: Option<AccountId>,
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
}
impl ExtBuilder {
pub fn default() -> Self {
Self {
balances: vec![],
with_default_balances: true,
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
validators: vec![],
with_default_validators: true,
feat: ✨ Integrate Proxy pallet into DataHaven runtimes (#128) ## Summary This PR integrates the Substrate Proxy pallet into DataHaven runtimes (testnet, stagenet, mainnet) with comprehensive test coverage. The proxy pallet enables account delegation functionality, allowing accounts to authorize other accounts to execute calls on their behalf with configurable permissions. ## Changes ### Proxy Pallet Integration - **Added proxy pallet** to all three DataHaven runtimes (testnet, stagenet, mainnet) - **Configured custom ProxyType enum** with DataHaven-specific proxy types: - `Any` - Unrestricted proxy access - `NonTransfer` - All calls except balance transfers - `Governance` - Governance and utility calls only - `Staking` - Staking operations (placeholder) - `CancelProxy` - Proxy announcement cancellation - `Balances` - Balance transfer operations only - `IdentityJudgement` - Identity judgement operations - `SudoOnly` - Privileged sudo operations only ### Runtime Configuration - **Integrated pallet-proxy** into runtime construction macros - **Configured proxy deposits** (base + per-proxy fees) - **Set proxy limits** (maximum proxies per account) - **Implemented InstanceFilter** for call filtering per proxy type - **Added proxy pallet to runtime APIs** and metadata ### Comprehensive Test Suite - `operator/runtime/testnet/tests/proxy.rs` - 24 comprehensive proxy tests - `operator/runtime/stagenet/tests/proxy.rs` - 24 comprehensive proxy tests - `operator/runtime/mainnet/tests/proxy.rs` - 24 comprehensive proxy tests - Updated `lib.rs` files in all three runtimes to include proxy test modules <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Enable account proxies across mainnet, stagenet, and testnet with configurable types, delays, and per-type call permissions. - Support anonymous (pure) proxies, proxy announcements with delays, and deposit/limit parameters for proxy management. - Tests - Add comprehensive integration tests covering proxy lifecycle, filtering, pure proxies, announcements, batching, chaining, multisig, identity, and sudo paths. - Test builder now supports optional sudo setup. - Chores - Add benchmarking, weights, and try-runtime support for proxies. - Update internal package metadata version. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com> Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-08-18 07:46:59 +00:00
sudo_key: None,
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
}
}
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 20:46:35 +00:00
/// Alternative constructor for governance tests with smaller balances
#[allow(dead_code)]
pub fn governance() -> Self {
Self {
balances: vec![
(alice(), INITIAL_BALANCE),
(bob(), INITIAL_BALANCE),
(charlie(), INITIAL_BALANCE),
(dave(), INITIAL_BALANCE),
(eve(), INITIAL_BALANCE),
],
with_default_balances: false,
validators: vec![],
with_default_validators: true,
sudo_key: None,
}
}
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
#[allow(dead_code)]
pub fn with_balances(mut self, balances: Vec<(AccountId, Balance)>) -> Self {
self.balances = balances;
self.with_default_balances = false;
self
}
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
#[allow(dead_code)]
pub fn with_validators(mut self, validators: Vec<AccountId>) -> Self {
self.validators = validators;
self.with_default_validators = false;
self
}
feat: ✨ Integrate Proxy pallet into DataHaven runtimes (#128) ## Summary This PR integrates the Substrate Proxy pallet into DataHaven runtimes (testnet, stagenet, mainnet) with comprehensive test coverage. The proxy pallet enables account delegation functionality, allowing accounts to authorize other accounts to execute calls on their behalf with configurable permissions. ## Changes ### Proxy Pallet Integration - **Added proxy pallet** to all three DataHaven runtimes (testnet, stagenet, mainnet) - **Configured custom ProxyType enum** with DataHaven-specific proxy types: - `Any` - Unrestricted proxy access - `NonTransfer` - All calls except balance transfers - `Governance` - Governance and utility calls only - `Staking` - Staking operations (placeholder) - `CancelProxy` - Proxy announcement cancellation - `Balances` - Balance transfer operations only - `IdentityJudgement` - Identity judgement operations - `SudoOnly` - Privileged sudo operations only ### Runtime Configuration - **Integrated pallet-proxy** into runtime construction macros - **Configured proxy deposits** (base + per-proxy fees) - **Set proxy limits** (maximum proxies per account) - **Implemented InstanceFilter** for call filtering per proxy type - **Added proxy pallet to runtime APIs** and metadata ### Comprehensive Test Suite - `operator/runtime/testnet/tests/proxy.rs` - 24 comprehensive proxy tests - `operator/runtime/stagenet/tests/proxy.rs` - 24 comprehensive proxy tests - `operator/runtime/mainnet/tests/proxy.rs` - 24 comprehensive proxy tests - Updated `lib.rs` files in all three runtimes to include proxy test modules <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Enable account proxies across mainnet, stagenet, and testnet with configurable types, delays, and per-type call permissions. - Support anonymous (pure) proxies, proxy announcements with delays, and deposit/limit parameters for proxy management. - Tests - Add comprehensive integration tests covering proxy lifecycle, filtering, pure proxies, announcements, batching, chaining, multisig, identity, and sudo paths. - Test builder now supports optional sudo setup. - Chores - Add benchmarking, weights, and try-runtime support for proxies. - Update internal package metadata version. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com> Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-08-18 07:46:59 +00:00
#[allow(dead_code)]
pub fn with_sudo(mut self, sudo_key: AccountId) -> Self {
self.sudo_key = Some(sudo_key);
self
}
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
pub fn build(self) -> sp_io::TestExternalities {
let mut balances = self.balances;
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
let mut validators = self.validators;
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
if self.with_default_balances {
balances.extend_from_slice(&[
(account_id(ALICE), DEFAULT_BALANCE),
(account_id(BOB), DEFAULT_BALANCE),
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
(account_id(CHARLIE), DEFAULT_BALANCE),
(account_id(DAVE), DEFAULT_BALANCE),
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 20:46:35 +00:00
(account_id(EVE), DEFAULT_BALANCE),
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
// Fund the treasury account (fee recipient) with initial balance
(
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
datahaven_testnet_runtime::configs::TreasuryAccount::get(),
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
DEFAULT_BALANCE,
),
]);
}
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
if self.with_default_validators {
validators.extend_from_slice(&[account_id(CHARLIE), account_id(DAVE)]);
}
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
let mut t = frame_system::GenesisConfig::<Runtime>::default()
.build_storage()
.expect("System pallet builds valid default genesis config");
pallet_balances::GenesisConfig::<Runtime> { balances }
.assimilate_storage(&mut t)
.expect("Pallet balances storage can be assimilated");
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
// Set up session keys for validators
let session_keys: Vec<_> = validators
.iter()
.map(|validator| {
(
validator.clone(),
validator.clone(),
generate_session_keys(validator.clone()),
)
})
.collect();
pallet_session::GenesisConfig::<Runtime> {
keys: session_keys,
non_authority_keys: vec![],
}
.assimilate_storage(&mut t)
.expect("Session genesis config can be assimilated");
feat: ✨ Integrate Proxy pallet into DataHaven runtimes (#128) ## Summary This PR integrates the Substrate Proxy pallet into DataHaven runtimes (testnet, stagenet, mainnet) with comprehensive test coverage. The proxy pallet enables account delegation functionality, allowing accounts to authorize other accounts to execute calls on their behalf with configurable permissions. ## Changes ### Proxy Pallet Integration - **Added proxy pallet** to all three DataHaven runtimes (testnet, stagenet, mainnet) - **Configured custom ProxyType enum** with DataHaven-specific proxy types: - `Any` - Unrestricted proxy access - `NonTransfer` - All calls except balance transfers - `Governance` - Governance and utility calls only - `Staking` - Staking operations (placeholder) - `CancelProxy` - Proxy announcement cancellation - `Balances` - Balance transfer operations only - `IdentityJudgement` - Identity judgement operations - `SudoOnly` - Privileged sudo operations only ### Runtime Configuration - **Integrated pallet-proxy** into runtime construction macros - **Configured proxy deposits** (base + per-proxy fees) - **Set proxy limits** (maximum proxies per account) - **Implemented InstanceFilter** for call filtering per proxy type - **Added proxy pallet to runtime APIs** and metadata ### Comprehensive Test Suite - `operator/runtime/testnet/tests/proxy.rs` - 24 comprehensive proxy tests - `operator/runtime/stagenet/tests/proxy.rs` - 24 comprehensive proxy tests - `operator/runtime/mainnet/tests/proxy.rs` - 24 comprehensive proxy tests - Updated `lib.rs` files in all three runtimes to include proxy test modules <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Enable account proxies across mainnet, stagenet, and testnet with configurable types, delays, and per-type call permissions. - Support anonymous (pure) proxies, proxy announcements with delays, and deposit/limit parameters for proxy management. - Tests - Add comprehensive integration tests covering proxy lifecycle, filtering, pure proxies, announcements, batching, chaining, multisig, identity, and sudo paths. - Test builder now supports optional sudo setup. - Chores - Add benchmarking, weights, and try-runtime support for proxies. - Update internal package metadata version. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com> Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-08-18 07:46:59 +00:00
// Configure Sudo if specified
if let Some(sudo_key) = self.sudo_key {
pallet_sudo::GenesisConfig::<Runtime> {
key: Some(sudo_key),
}
.assimilate_storage(&mut t)
.expect("Sudo genesis config can be assimilated");
}
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| {
System::set_block_number(1);
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
// Initialize session
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 20:46:35 +00:00
<Session as OnInitialize<BlockNumberFor<Runtime>>>::on_initialize(1);
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
});
ext
}
}
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 20:46:35 +00:00
#[allow(dead_code)]
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
pub fn root_origin() -> RuntimeOrigin {
RuntimeOrigin::root()
}
feat: ✨ Standardize currency system to HAVE token with Wei-based units (#130) ## Summary This PR modernizes DataHaven's currency system by standardizing all three runtimes (mainnet, stagenet, testnet) to use Ethereum-compatible Wei-based units with HAVE as the native token name. ### Key Changes #### 🔄 Currency Unit Standardization - **Migrated from decimal-based to Wei-based system** (18 decimals) - **Wei units**: WEI → KILOWEI → MEGAWEI → GIGAWEI - **HAVE units**: MICROHAVE → MILLIHAVE → HAVE → KILOHAVE - **Zero Existential Deposit**: Enables dust account support with `insecure_zero_ed` feature #### 🏷️ Token Naming - **UNIT → HAVE**: Native token renamed to reflect DataHaven branding - **Consistent terminology**: All constants, comments, and documentation updated - **Supply factors preserved**: Mainnet (100x), Stagenet/Testnet (1x) #### ⚖️ Block Weights & Gas Configuration - **Solochain-optimized**: Updated MAX_POV_SIZE and block weight parameters - **EVM compatibility**: Fixed GasLimitPovSizeRatio (u32 → u64) and storage growth ratios - **Proper fee structure**: Aligned with Ethereum standards #### 🧪 Test Updates - **Treasury tests fixed**: Updated to handle zero existential deposit behavior - **All tests passing**: Currency references updated across all runtime tests - **Storage hub parameters**: Updated to use HAVE token terminology ### Breaking Changes ⚠️ **Currency precision changed from 12 to 18 decimals** - Applications using currency constants must update to new HAVE-based naming - ExistentialDeposit now 0 (was previously enforced minimum balance) ### Runtime Coverage - ✅ **Mainnet runtime** (supply factor: 100) - ✅ **Stagenet runtime** (supply factor: 1) - ✅ **Testnet runtime** (supply factor: 1) - ✅ **Storage hub parameters** (runtime params updated) ### Technical Details #### Fee Structure ```rust pub const TRANSACTION_BYTE_FEE: Balance = 1 * GIGAWEI * SUPPLY_FACTOR; pub const STORAGE_BYTE_FEE: Balance = 100 * MICROHAVE * SUPPLY_FACTOR; pub const WEIGHT_FEE: Balance = 50 * KILOWEI * SUPPLY_FACTOR / 4; ``` #### Block Configuration ```rust pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), MAX_POV_SIZE as u64, ); ``` ## Test Plan - [x] All runtime builds compile successfully - [x] All unit tests pass across three runtimes - [x] Treasury fee handling verified with zero existential deposit - [x] Storage hub parameter compatibility confirmed - [x] EVM gas limit calculations validated ## Files Modified **27 files changed, 728 insertions(+), 342 deletions(-)** - Runtime lib.rs files (currency module definitions) - Cargo.toml files (insecure_zero_ed feature) - Configuration modules (block weights, gas limits) - Test suites (currency constant references) - Storage hub runtime parameters --- 🤖 *Generated with [Claude Code](https://claude.ai/code)* <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Introduced a unified currency module with HAVE units (18 decimals), fees, and a deposit helper. - Adopted dynamic block weight/length configuration (5 MB blocks) and re-exported gas-to-weight constants. - Improvements - Switched all runtimes and pricing parameters from UNIT/NANO_UNIT to HAVE/GIGAWEI. - Updated deposits, fees, and rewards to HAVE-based values across modules (including StorageHub and Snowbridge). - Made existential deposit runtime-configurable; enabled zero-ED mode on selected networks. - Updated metadata hash and token metadata to reference HAVE (symbol wHAVE, 18 decimals). <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com>
2025-08-18 11:26:30 +00:00
#[allow(dead_code)]
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
pub fn datahaven_token_metadata() -> snowbridge_core::AssetMetadata {
snowbridge_core::AssetMetadata {
name: b"MOCK".to_vec().try_into().unwrap(),
symbol: b"wMOCK".to_vec().try_into().unwrap(),
feat: ✨ Native Token Transfer to Ethereum (#88) ### Summary - Implement native token transfers from DataHaven to Ethereum using Snowbridge infrastructure - Add comprehensive datahaven-native-transfer pallet with lock-and-mint mechanism for cross-chain token representation ### Key Features **New Pallet: datahaven-native-transfer** - Cross-chain transfers: Transfer DataHaven native tokens to Ethereum addresses via `transfer_to_ethereum extrinsic` - Token locking mechanism: Secure token storage in deterministic Ethereum sovereign account during transfers - Fee management: Required fees for all transfers to compensate relayers and prevent spam - Emergency controls: Pause/unpause functionality - Token registration: Integration with Snowbridge's token registration for native token identification <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the DataHaven Native Transfer pallet enabling secure cross-chain transfers of DataHaven native tokens to and from Ethereum via Snowbridge. - Added token locking on DataHaven, minting on Ethereum, and mandatory fee collection to cover gas costs and incentivize relayers. - Implemented pause and unpause controls for emergency management of token transfers. - **Configuration** - Integrated the new pallet into mainnet, stagenet, and testnet runtimes with updated network, account, and treasury settings. - Added Ethereum sovereign account constants and native token ID support for optimized cross-chain operations. - **Documentation** - Added comprehensive README and inline documentation detailing pallet features, extrinsics, events, errors, and security considerations. - **Tests** - Added extensive unit and integration tests covering token transfers, native token registration, fee handling, pause functionality, and event validation across all supported networks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-06-11 22:07:36 +00:00
decimals: 18,
}
}
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
/// Get validator AccountId by index (for testing)
/// Index 0: Charlie, Index 1: Dave
feat: ✨ Standardize currency system to HAVE token with Wei-based units (#130) ## Summary This PR modernizes DataHaven's currency system by standardizing all three runtimes (mainnet, stagenet, testnet) to use Ethereum-compatible Wei-based units with HAVE as the native token name. ### Key Changes #### 🔄 Currency Unit Standardization - **Migrated from decimal-based to Wei-based system** (18 decimals) - **Wei units**: WEI → KILOWEI → MEGAWEI → GIGAWEI - **HAVE units**: MICROHAVE → MILLIHAVE → HAVE → KILOHAVE - **Zero Existential Deposit**: Enables dust account support with `insecure_zero_ed` feature #### 🏷️ Token Naming - **UNIT → HAVE**: Native token renamed to reflect DataHaven branding - **Consistent terminology**: All constants, comments, and documentation updated - **Supply factors preserved**: Mainnet (100x), Stagenet/Testnet (1x) #### ⚖️ Block Weights & Gas Configuration - **Solochain-optimized**: Updated MAX_POV_SIZE and block weight parameters - **EVM compatibility**: Fixed GasLimitPovSizeRatio (u32 → u64) and storage growth ratios - **Proper fee structure**: Aligned with Ethereum standards #### 🧪 Test Updates - **Treasury tests fixed**: Updated to handle zero existential deposit behavior - **All tests passing**: Currency references updated across all runtime tests - **Storage hub parameters**: Updated to use HAVE token terminology ### Breaking Changes ⚠️ **Currency precision changed from 12 to 18 decimals** - Applications using currency constants must update to new HAVE-based naming - ExistentialDeposit now 0 (was previously enforced minimum balance) ### Runtime Coverage - ✅ **Mainnet runtime** (supply factor: 100) - ✅ **Stagenet runtime** (supply factor: 1) - ✅ **Testnet runtime** (supply factor: 1) - ✅ **Storage hub parameters** (runtime params updated) ### Technical Details #### Fee Structure ```rust pub const TRANSACTION_BYTE_FEE: Balance = 1 * GIGAWEI * SUPPLY_FACTOR; pub const STORAGE_BYTE_FEE: Balance = 100 * MICROHAVE * SUPPLY_FACTOR; pub const WEIGHT_FEE: Balance = 50 * KILOWEI * SUPPLY_FACTOR / 4; ``` #### Block Configuration ```rust pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), MAX_POV_SIZE as u64, ); ``` ## Test Plan - [x] All runtime builds compile successfully - [x] All unit tests pass across three runtimes - [x] Treasury fee handling verified with zero existential deposit - [x] Storage hub parameter compatibility confirmed - [x] EVM gas limit calculations validated ## Files Modified **27 files changed, 728 insertions(+), 342 deletions(-)** - Runtime lib.rs files (currency module definitions) - Cargo.toml files (insecure_zero_ed feature) - Configuration modules (block weights, gas limits) - Test suites (currency constant references) - Storage hub runtime parameters --- 🤖 *Generated with [Claude Code](https://claude.ai/code)* <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Introduced a unified currency module with HAVE units (18 decimals), fees, and a deposit helper. - Adopted dynamic block weight/length configuration (5 MB blocks) and re-exported gas-to-weight constants. - Improvements - Switched all runtimes and pricing parameters from UNIT/NANO_UNIT to HAVE/GIGAWEI. - Updated deposits, fees, and rewards to HAVE-based values across modules (including StorageHub and Snowbridge). - Made existential deposit runtime-configurable; enabled zero-ED mode on selected networks. - Updated metadata hash and token metadata to reference HAVE (symbol wHAVE, 18 decimals). <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com>
2025-08-18 11:26:30 +00:00
#[allow(dead_code)]
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
pub fn get_validator_by_index(index: u32) -> AccountId {
match index {
0 => account_id(CHARLIE),
1 => account_id(DAVE),
_ => panic!("Only validators 0 (Charlie) and 1 (Dave) are configured for tests"),
}
}
/// Set block author directly in authorship pallet storage (for testing)
feat: ✨ Standardize currency system to HAVE token with Wei-based units (#130) ## Summary This PR modernizes DataHaven's currency system by standardizing all three runtimes (mainnet, stagenet, testnet) to use Ethereum-compatible Wei-based units with HAVE as the native token name. ### Key Changes #### 🔄 Currency Unit Standardization - **Migrated from decimal-based to Wei-based system** (18 decimals) - **Wei units**: WEI → KILOWEI → MEGAWEI → GIGAWEI - **HAVE units**: MICROHAVE → MILLIHAVE → HAVE → KILOHAVE - **Zero Existential Deposit**: Enables dust account support with `insecure_zero_ed` feature #### 🏷️ Token Naming - **UNIT → HAVE**: Native token renamed to reflect DataHaven branding - **Consistent terminology**: All constants, comments, and documentation updated - **Supply factors preserved**: Mainnet (100x), Stagenet/Testnet (1x) #### ⚖️ Block Weights & Gas Configuration - **Solochain-optimized**: Updated MAX_POV_SIZE and block weight parameters - **EVM compatibility**: Fixed GasLimitPovSizeRatio (u32 → u64) and storage growth ratios - **Proper fee structure**: Aligned with Ethereum standards #### 🧪 Test Updates - **Treasury tests fixed**: Updated to handle zero existential deposit behavior - **All tests passing**: Currency references updated across all runtime tests - **Storage hub parameters**: Updated to use HAVE token terminology ### Breaking Changes ⚠️ **Currency precision changed from 12 to 18 decimals** - Applications using currency constants must update to new HAVE-based naming - ExistentialDeposit now 0 (was previously enforced minimum balance) ### Runtime Coverage - ✅ **Mainnet runtime** (supply factor: 100) - ✅ **Stagenet runtime** (supply factor: 1) - ✅ **Testnet runtime** (supply factor: 1) - ✅ **Storage hub parameters** (runtime params updated) ### Technical Details #### Fee Structure ```rust pub const TRANSACTION_BYTE_FEE: Balance = 1 * GIGAWEI * SUPPLY_FACTOR; pub const STORAGE_BYTE_FEE: Balance = 100 * MICROHAVE * SUPPLY_FACTOR; pub const WEIGHT_FEE: Balance = 50 * KILOWEI * SUPPLY_FACTOR / 4; ``` #### Block Configuration ```rust pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), MAX_POV_SIZE as u64, ); ``` ## Test Plan - [x] All runtime builds compile successfully - [x] All unit tests pass across three runtimes - [x] Treasury fee handling verified with zero existential deposit - [x] Storage hub parameter compatibility confirmed - [x] EVM gas limit calculations validated ## Files Modified **27 files changed, 728 insertions(+), 342 deletions(-)** - Runtime lib.rs files (currency module definitions) - Cargo.toml files (insecure_zero_ed feature) - Configuration modules (block weights, gas limits) - Test suites (currency constant references) - Storage hub runtime parameters --- 🤖 *Generated with [Claude Code](https://claude.ai/code)* <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Introduced a unified currency module with HAVE units (18 decimals), fees, and a deposit helper. - Adopted dynamic block weight/length configuration (5 MB blocks) and re-exported gas-to-weight constants. - Improvements - Switched all runtimes and pricing parameters from UNIT/NANO_UNIT to HAVE/GIGAWEI. - Updated deposits, fees, and rewards to HAVE-based values across modules (including StorageHub and Snowbridge). - Made existential deposit runtime-configurable; enabled zero-ED mode on selected networks. - Updated metadata hash and token metadata to reference HAVE (symbol wHAVE, 18 decimals). <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com>
2025-08-18 11:26:30 +00:00
#[allow(dead_code)]
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
pub fn set_block_author(author: AccountId) {
// Use direct storage access since the Author storage is private
frame_support::storage::unhashed::put(
&frame_support::storage::storage_prefix(b"Authorship", b"Author"),
&author,
);
}
/// Set block author by validator index (for testing)
feat: ✨ Standardize currency system to HAVE token with Wei-based units (#130) ## Summary This PR modernizes DataHaven's currency system by standardizing all three runtimes (mainnet, stagenet, testnet) to use Ethereum-compatible Wei-based units with HAVE as the native token name. ### Key Changes #### 🔄 Currency Unit Standardization - **Migrated from decimal-based to Wei-based system** (18 decimals) - **Wei units**: WEI → KILOWEI → MEGAWEI → GIGAWEI - **HAVE units**: MICROHAVE → MILLIHAVE → HAVE → KILOHAVE - **Zero Existential Deposit**: Enables dust account support with `insecure_zero_ed` feature #### 🏷️ Token Naming - **UNIT → HAVE**: Native token renamed to reflect DataHaven branding - **Consistent terminology**: All constants, comments, and documentation updated - **Supply factors preserved**: Mainnet (100x), Stagenet/Testnet (1x) #### ⚖️ Block Weights & Gas Configuration - **Solochain-optimized**: Updated MAX_POV_SIZE and block weight parameters - **EVM compatibility**: Fixed GasLimitPovSizeRatio (u32 → u64) and storage growth ratios - **Proper fee structure**: Aligned with Ethereum standards #### 🧪 Test Updates - **Treasury tests fixed**: Updated to handle zero existential deposit behavior - **All tests passing**: Currency references updated across all runtime tests - **Storage hub parameters**: Updated to use HAVE token terminology ### Breaking Changes ⚠️ **Currency precision changed from 12 to 18 decimals** - Applications using currency constants must update to new HAVE-based naming - ExistentialDeposit now 0 (was previously enforced minimum balance) ### Runtime Coverage - ✅ **Mainnet runtime** (supply factor: 100) - ✅ **Stagenet runtime** (supply factor: 1) - ✅ **Testnet runtime** (supply factor: 1) - ✅ **Storage hub parameters** (runtime params updated) ### Technical Details #### Fee Structure ```rust pub const TRANSACTION_BYTE_FEE: Balance = 1 * GIGAWEI * SUPPLY_FACTOR; pub const STORAGE_BYTE_FEE: Balance = 100 * MICROHAVE * SUPPLY_FACTOR; pub const WEIGHT_FEE: Balance = 50 * KILOWEI * SUPPLY_FACTOR / 4; ``` #### Block Configuration ```rust pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), MAX_POV_SIZE as u64, ); ``` ## Test Plan - [x] All runtime builds compile successfully - [x] All unit tests pass across three runtimes - [x] Treasury fee handling verified with zero existential deposit - [x] Storage hub parameter compatibility confirmed - [x] EVM gas limit calculations validated ## Files Modified **27 files changed, 728 insertions(+), 342 deletions(-)** - Runtime lib.rs files (currency module definitions) - Cargo.toml files (insecure_zero_ed feature) - Configuration modules (block weights, gas limits) - Test suites (currency constant references) - Storage hub runtime parameters --- 🤖 *Generated with [Claude Code](https://claude.ai/code)* <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Introduced a unified currency module with HAVE units (18 decimals), fees, and a deposit helper. - Adopted dynamic block weight/length configuration (5 MB blocks) and re-exported gas-to-weight constants. - Improvements - Switched all runtimes and pricing parameters from UNIT/NANO_UNIT to HAVE/GIGAWEI. - Updated deposits, fees, and rewards to HAVE-based values across modules (including StorageHub and Snowbridge). - Made existential deposit runtime-configurable; enabled zero-ED mode on selected networks. - Updated metadata hash and token metadata to reference HAVE (symbol wHAVE, 18 decimals). <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com>
2025-08-18 11:26:30 +00:00
#[allow(dead_code)]
feat: ✨ Add Treasury 💰 pallet to DataHaven runtimes (#98) This PR integrates the Substrate FRAME Treasury pallet across all three DataHaven runtime environments (`testnet`, `mainnet`, `stagenet`) with a custom fee allocation mechanism and comprehensive test coverage. ### Key Changes #### Treasury Pallet Integration: - Added Treasury pallet to all three runtimes (testnet, mainnet, stagenet) with 20% fee allocation and 80% burn mechanism. - Implemented dynamic fee proportion control via `FeesTreasuryProportion` runtime parameter. - Integrated treasury with custom fee handlers: `DealWithEthereumBaseFees`, `DealWithEthereumPriorityFees`, and `DealWithSubstrateFeesAndTip`. #### Comprehensive Testing Infrastructure: - Created robust test architecture with session management and validator setup across all runtimes - Added block author management utilities for treasury testing requiring pallet_authorship integration - Implemented 15 total tests (5 tests × 3 runtimes) covering: - EVM transaction fee allocation with/without priority fees - Substrate fee and tip handling validation - Treasury spending functionality via sudo - Complete fee flow verification with actual network base fee calculations #### Technnical Implementation Fee Allocation Logic: - Base fees: 20% to treasury, 80% burned - Priority fees: 100% to block author - Substrate tips: 100% to block author The implementation is based on https://github.com/moonbeam-foundation/moonbeam/pull/3120 in [Moonbeam](https://github.com/moonbeam-foundation/moonbeam), and assisted by Claude Code.
2025-06-25 06:09:26 +00:00
pub fn set_block_author_by_index(validator_index: u32) {
let author = get_validator_by_index(validator_index);
set_block_author(author);
}
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 20:46:35 +00:00
// ═══════════════════════════════════════════════════════════════════════════════════════════════════
// Governance-specific helper functions
// ═══════════════════════════════════════════════════════════════════════════════════════════════════
/// Helper function to get accounts as AccountId (governance naming convention)
#[allow(dead_code)]
pub fn alice() -> AccountId {
account_id(ALICE)
}
#[allow(dead_code)]
pub fn bob() -> AccountId {
account_id(BOB)
}
#[allow(dead_code)]
pub fn charlie() -> AccountId {
account_id(CHARLIE)
}
#[allow(dead_code)]
pub fn dave() -> AccountId {
account_id(DAVE)
}
#[allow(dead_code)]
pub fn eve() -> AccountId {
account_id(EVE)
}
/// Helper function to run to block
pub fn run_to_block(n: BlockNumberFor<Runtime>) {
while System::block_number() < n {
if System::block_number() > 1 {
<System as OnFinalize<BlockNumberFor<Runtime>>>::on_finalize(System::block_number());
}
System::set_block_number(System::block_number() + 1);
<System as OnInitialize<BlockNumberFor<Runtime>>>::on_initialize(System::block_number());
}
}
/// Helper function to make a proposal hash
#[allow(dead_code)]
pub fn make_proposal_hash(proposal: &RuntimeCall) -> H256 {
BlakeTwo256::hash_of(proposal)
}
/// Helper to get last event
#[allow(dead_code)]
pub fn last_event() -> RuntimeEvent {
System::events().pop().expect("Event expected").event
}
/// Helper to check if event exists
#[allow(dead_code)]
pub fn has_event(event: RuntimeEvent) -> bool {
System::events().iter().any(|record| record.event == event)
}
/// Helper to setup technical committee members
#[allow(dead_code)]
pub fn setup_technical_committee(members: Vec<AccountId>) {
assert_ok!(TechnicalCommittee::set_members(
RuntimeOrigin::root(),
members,
None,
3
));
}
/// Helper to setup treasury council members
#[allow(dead_code)]
pub fn setup_treasury_council(members: Vec<AccountId>) {
assert_ok!(TreasuryCouncil::set_members(
RuntimeOrigin::root(),
members,
None,
3
));
}
/// Helper to create a simple proposal
#[allow(dead_code)]
pub fn make_simple_proposal() -> RuntimeCall {
RuntimeCall::System(frame_system::Call::set_storage {
items: vec![(b":test".to_vec(), b"value".to_vec())],
})
}
#[allow(dead_code)]
/// Helper to advance time for voting
pub fn advance_referendum_time(blocks: BlockNumberFor<Runtime>) {
let current_block = System::block_number();
run_to_block(current_block + blocks);
}