## Polkadot upgrade 2503 In this PR, we upgrade form Polkadot SDK 2412 to Polkadot SDK 2503. In order to upgrade the SDK we need to upgrade some dependencies : StorageHub and frontier simultaneously. ## What changes ### Trivial changes * https://github.com/paritytech/polkadot-sdk/pull/7634 -> The new trait is required in all the pallets using scale encoding. * https://github.com/paritytech/polkadot-sdk/pull/7043 -> Remove deprecated `sp-std` and replace with `alloc` or `core`. * https://github.com/paritytech/polkadot-sdk/pull/6140 -> Accurate weight reclaim with frame_system::WeightReclaim ### Breaking changes * https://github.com/paritytech/polkadot-sdk/pull/2072 -> There is a change in `pallet-referenda`. Now, the tracks are retrieved as a list of `Track`s. Also, the names of the tracks might have some trailing null values (`\0`). This means display representation of the tracks' names must be sanitized. * https://github.com/paritytech/polkadot-sdk/pull/5723 -> adds the ability for these pallets to specify their source of the block number. This is useful when these pallets are migrated from the relay chain to a parachain and vice versa. (Not entirely sure it is breaking as it is being marked as backward compatible). * https://github.com/paritytech/polkadot-sdk/pull/6338 -> Update Referenda to Support Block Number Provider ### Notable changes * https://github.com/paritytech/polkadot-sdk/pull/5703 -> Not changes required in the codebase but impact fastSync mode. Should improve testing. * https://github.com/paritytech/polkadot-sdk/pull/5842 -> Removes `libp2p` types in authority-discovery, and replace them with network backend agnostic types from `sc-network-types`. The `sc-network` interface is therefore updated accordingly. ## What changes in Frontier * https://github.com/polkadot-evm/frontier/pull/1693 -> Add support for EIP 7702 which has been enable with Pectra. This EIP add a new field `AuthorizationList` in Ethereum transaction. Changes example : ```rust #[test] fn validate_transaction_fails_on_filtered_call() { ... pallet_evm::Call::<Runtime>::call { source: H160::default(), target: H160::default(), input: Vec::new(), value: sp_core::U256::zero(), gas_limit: 21000, max_fee_per_gas: sp_core::U256::zero(), max_priority_fee_per_gas: Some(sp_core::U256::zero()), nonce: None, access_list: Vec::new(), authorization_list: Vec::new(), } .into(), ``` ## ⚠️ Breaking Changes ⚠️ * Upgrade to Stirage hub v0.5.1 * Support for Ethereum latest upgrade (txs now have the `authoriation_list` for support EIP 7702) --------- Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.toml | ||
| README.md | ||
DataHaven Native Transfer Pallet
A Substrate pallet that enables cross-chain transfers of DataHaven native tokens to and from Ethereum using the Snowbridge infrastructure.
Overview
This pallet facilitates the transfer of DataHaven (DH) native tokens to Ethereum, where they are represented as wrapped ERC20 tokens. It implements a lock-and-mint mechanism: tokens are locked on DataHaven when transferred to Ethereum, and unlocked when transferred back.
Features
- Cross-chain Transfers: Transfer DH tokens to Ethereum addresses
- Token Locking: Secure token locking in a sovereign account during transfers
- Fee Management: Mandatory fee collection for bridge relayers
- Pause Mechanism: Emergency pause functionality for security
Fee Structure
Fees are mandatory for all transfers and serve to:
- Compensate relayers for Ethereum gas costs
- Provide incentive for timely message delivery
- Prevent spam transactions
The fee is:
- Collected in DataHaven native tokens
- Transferred to a designated fee recipient account
- Separate from the transfer amount
Fee Calculation Guidelines
When calculating fees, consider:
- Ethereum Gas Costs: Estimate gas required for the Ethereum transaction
- Gas Price: Current Ethereum gas prices (use oracles or fixed estimates)
- Exchange Rate: DH to ETH conversion rate
- Relayer Margin: Additional incentive
Example calculation:
Ethereum gas required: 100,000 gas
Gas price: 30 gwei
ETH cost: 0.003 ETH
DH/ETH rate: 1000 DH per ETH
Base fee: 3 DH
With 20% margin: 3.6 DH
Extrinsics
transfer_to_ethereum
Transfer DataHaven native tokens to an Ethereum address.
Parameters:
origin: The account initiating the transferrecipient: The Ethereum address (H160) to receive the tokensamount: The amount of tokens to transferfee: The fee to cover Ethereum gas costs and incentivize relayers (must be non-zero)
pause
Pause all transfers. Only callable by PauseOrigin (typically governance).
unpause
Resume transfers after pause. Only callable by PauseOrigin.
Public Functions
total_locked_balance
Get the total balance of tokens locked in the Ethereum sovereign account.
ethereum_sovereign_account
Get the account ID of the Ethereum sovereign account for monitoring purposes.
Events
TokensLocked: Emitted when tokens are locked for transferTokensUnlocked: Emitted when tokens are unlocked from EthereumTokensTransferredToEthereum: Emitted on successful transfer to EthereumPaused: Emitted when the pallet is pausedUnpaused: Emitted when the pallet is unpaused
Errors
InsufficientBalance: Account has insufficient balance for transferOverflow: Arithmetic overflow in calculationsSendMessageFailed: Failed to send message through SnowbridgeInvalidEthereumAddress: Provided Ethereum address is zeroInvalidAmount: Transfer amount is zeroTransfersDisabled: Transfers are pausedZeroFee: Fee cannot be zero
Security Considerations
- Pause Mechanism: The pallet can be paused by governance in case of emergencies
- Fee Validation: All transfers require non-zero fees to prevent spam
- Balance Preservation: The pallet uses
Preservation::Preserveto maintain existential deposits - Address Validation: Zero Ethereum addresses are rejected