Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EthereumTokenTransfers pallet #835

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5c81a43
initial approach
Agusrodri Jan 16, 2025
3e15747
add transfer_native_token call and config traits
Agusrodri Jan 18, 2025
92aef0f
initial code for mock
Agusrodri Jan 18, 2025
8848120
start adding unit tests
Agusrodri Jan 21, 2025
c623366
Merge remote-tracking branch 'origin/master' into agustin-ethereum-to…
Agusrodri Jan 21, 2025
d596358
use snowbridge components
Agusrodri Jan 23, 2025
8a45e28
Merge remote-tracking branch 'origin/master' into agustin-ethereum-to…
Agusrodri Jan 23, 2025
50f0d66
add events and more unit tests
Agusrodri Jan 23, 2025
8b22ab7
add more tests
Agusrodri Jan 24, 2025
e9582a1
Merge remote-tracking branch 'origin/master' into agustin-ethereum-to…
Agusrodri Jan 24, 2025
6dd2ac6
fmt
Agusrodri Jan 24, 2025
f8e6e6d
add token location conversion to EthereumTokenTransfers pallet
Agusrodri Jan 27, 2025
cdffee5
add benchmarks and weights
Agusrodri Jan 28, 2025
0e2bba1
Merge remote-tracking branch 'origin/master' into agustin-ethereum-to…
Agusrodri Jan 28, 2025
c869c91
use proper BenchmarkHelper in EthereumTokenTransfers pallet
Agusrodri Jan 28, 2025
047ccd7
cleanup
Agusrodri Jan 28, 2025
abf9c12
more cleanup
Agusrodri Jan 28, 2025
072ccac
add ts test for setTokenTransferChannel
Agusrodri Jan 29, 2025
45367f6
add ts test for transferNativeToken
Agusrodri Jan 29, 2025
0c7a5bc
Merge remote-tracking branch 'origin/master' into agustin-ethereum-to…
Agusrodri Jan 29, 2025
52672e0
add message_id to event and optimize storage items
Agusrodri Jan 30, 2025
5ee1111
fmt and clippy fixes
Agusrodri Jan 30, 2025
c31bbea
api-augment
Agusrodri Jan 30, 2025
4fe6131
Merge remote-tracking branch 'origin/master' into agustin-ethereum-to…
Agusrodri Jan 30, 2025
d1ce751
move EthereumSystemChannelManager to tp_bridge
Agusrodri Jan 30, 2025
96cc01b
Merge remote-tracking branch 'origin/master' into agustin-ethereum-to…
Agusrodri Feb 4, 2025
9474366
api-augment
Agusrodri Feb 4, 2025
8795a1d
remove if let nesting
Agusrodri Feb 8, 2025
39c534d
move channel managers and helpers to tp_bridge
Agusrodri Feb 8, 2025
c5e12f1
add more tests
Agusrodri Feb 8, 2025
6dde19d
toml fmt
Agusrodri Feb 8, 2025
2088e22
Merge remote-tracking branch 'origin/master' into agustin-ethereum-to…
Agusrodri Feb 8, 2025
c38fb12
add test for channel and agent initialization
Agusrodri Feb 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pallet-collator-assignment-runtime-api = { path = "pallets/collator-assignment/r
pallet-configuration = { path = "pallets/configuration", default-features = false }
pallet-data-preservers = { path = "pallets/data-preservers", default-features = false }
pallet-data-preservers-runtime-api = { path = "pallets/data-preservers/runtime-api", default-features = false }
pallet-ethereum-token-transfers = { path = "pallets/ethereum-token-transfers", default-features = false }
pallet-external-validator-slashes = { path = "pallets/external-validator-slashes", default-features = false }
pallet-external-validators = { path = "pallets/external-validators", default-features = false }
pallet-external-validators-rewards = { path = "pallets/external-validators-rewards", default-features = false }
Expand Down
4 changes: 4 additions & 0 deletions chains/orchestrator-relays/runtime/dancelight/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pallet-collective = { workspace = true }
pallet-conviction-voting = { workspace = true }
pallet-democracy = { workspace = true }
pallet-elections-phragmen = { workspace = true }
pallet-ethereum-token-transfers = { workspace = true }
pallet-external-validator-slashes = { workspace = true }
pallet-external-validators = { workspace = true }
pallet-external-validators-rewards = { workspace = true }
Expand Down Expand Up @@ -235,6 +236,7 @@ std = [
"pallet-data-preservers/std",
"pallet-democracy/std",
"pallet-elections-phragmen/std",
"pallet-ethereum-token-transfers/std",
"pallet-external-validator-slashes/std",
"pallet-external-validators-rewards-runtime-api/std",
"pallet-external-validators-rewards/std",
Expand Down Expand Up @@ -358,6 +360,7 @@ runtime-benchmarks = [
"pallet-data-preservers/runtime-benchmarks",
"pallet-democracy/runtime-benchmarks",
"pallet-elections-phragmen/runtime-benchmarks",
"pallet-ethereum-token-transfers/runtime-benchmarks",
"pallet-external-validator-slashes/runtime-benchmarks",
"pallet-external-validators-rewards/runtime-benchmarks",
"pallet-external-validators/runtime-benchmarks",
Expand Down Expand Up @@ -441,6 +444,7 @@ try-runtime = [
"pallet-data-preservers/try-runtime",
"pallet-democracy/try-runtime",
"pallet-elections-phragmen/try-runtime",
"pallet-ethereum-token-transfers/try-runtime",
"pallet-external-validator-slashes/try-runtime",
"pallet-external-validators-rewards/try-runtime",
"pallet-external-validators/try-runtime",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ use tp_bridge::symbiotic_message_processor::SymbioticMessageProcessor;
use {
crate::{
parameter_types, weights, xcm_config, AggregateMessageOrigin, Balance, Balances,
EthereumInboundQueue, EthereumOutboundQueue, EthereumSystem, FixedU128,
GetAggregateMessageOrigin, Keccak256, MessageQueue, OutboundMessageCommitmentRecorder,
Runtime, RuntimeEvent, TransactionByteFee, TreasuryAccount, WeightToFee, UNITS,
EthereumInboundQueue, EthereumOutboundQueue, EthereumSovereignAccount, EthereumSystem,
FixedU128, GetAggregateMessageOrigin, Keccak256, MessageQueue,
OutboundMessageCommitmentRecorder, Runtime, RuntimeEvent, TokenLocationReanchored,
TransactionByteFee, TreasuryAccount, WeightToFee, UNITS,
},
frame_support::{traits::Nothing, weights::ConstantMultiplier},
pallet_xcm::EnsureXcm,
snowbridge_beacon_primitives::{Fork, ForkVersions},
snowbridge_core::{gwei, meth, PricingParameters, Rewards},
snowbridge_pallet_outbound_queue::OnNewCommitment,
sp_core::{ConstU32, ConstU8, H160, H256},
tp_bridge::{DoNothingConvertMessage, DoNothingRouter},
tp_bridge::{DoNothingConvertMessage, DoNothingRouter, EthereumSystemHandler},
};

// Ethereum Bridge
Expand Down Expand Up @@ -183,6 +184,20 @@ impl snowbridge_pallet_system::Config for Runtime {
type WeightInfo = crate::weights::snowbridge_pallet_system::SubstrateWeight<Runtime>;
}

impl pallet_ethereum_token_transfers::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type OutboundQueue = EthereumOutboundQueue;
type EthereumSystemHandler = EthereumSystemHandler<Runtime>;
type EthereumSovereignAccount = EthereumSovereignAccount;
type FeesAccount = TreasuryAccount;
type TokenLocationReanchored = TokenLocationReanchored;
type TokenIdFromLocation = EthereumSystem;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = tp_bridge::EthereumTokenTransfersBenchHelper<Runtime>;
type WeightInfo = crate::weights::pallet_ethereum_token_transfers::SubstrateWeight<Runtime>;
}

#[cfg(feature = "runtime-benchmarks")]
mod benchmark_helper {
use snowbridge_beacon_primitives::BeaconHeader;
Expand Down
15 changes: 11 additions & 4 deletions chains/orchestrator-relays/runtime/dancelight/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ pub use {
primitives::{AccountId, Balance},
};

#[cfg(feature = "runtime-benchmarks")]
use snowbridge_core::{AgentId, TokenId};

/// Constant values used within the runtime.
use dancelight_runtime_constants::{currency::*, fee::*, snowbridge::EthereumLocation, time::*};

Expand Down Expand Up @@ -1424,7 +1427,7 @@ parameter_types! {
// to properly write integration tests.
pub ExternalRewardsEraInflationProvider: u128 = InflationRate::get() * Balances::total_issuance();

pub RewardTokenLocation: Location = xcm_config::TokenLocation::get().reanchored(
pub TokenLocationReanchored: Location = xcm_config::TokenLocation::get().reanchored(
&EthereumLocation::get(),
&xcm_config::UniversalLocation::get()
).expect("unable to reanchor reward token");
Expand All @@ -1440,11 +1443,13 @@ impl Get<Vec<AccountId>> for GetWhitelistedValidators {
#[cfg(feature = "runtime-benchmarks")]
pub struct RewardsBenchHelper;
#[cfg(feature = "runtime-benchmarks")]
impl tp_bridge::TokenSetterBenchmarkHelperTrait for RewardsBenchHelper {
fn set_up_token(location: Location, token_id: snowbridge_core::TokenId) {
impl tp_bridge::TokenChannelSetterBenchmarkHelperTrait for RewardsBenchHelper {
fn set_up_token(location: Location, token_id: TokenId) {
snowbridge_pallet_system::ForeignToNativeId::<Runtime>::insert(&token_id, &location);
snowbridge_pallet_system::NativeToForeignId::<Runtime>::insert(&location, &token_id);
}

fn set_up_channel(_channel_id: ChannelId, _para_id: ParaId, _agent_id: AgentId) {}
}
impl pallet_external_validators_rewards::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand All @@ -1463,7 +1468,7 @@ impl pallet_external_validators_rewards::Config for Runtime {
type OutboundQueue = tp_bridge::CustomSendMessage<Runtime, GetAggregateMessageOriginTanssi>;
type Currency = Balances;
type RewardsEthereumSovereignAccount = EthereumSovereignAccount;
type TokenLocationReanchored = RewardTokenLocation;
type TokenLocationReanchored = TokenLocationReanchored;
type TokenIdFromLocation = EthereumSystem;
type WeightInfo = weights::pallet_external_validators_rewards::SubstrateWeight<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
Expand Down Expand Up @@ -1901,6 +1906,7 @@ construct_runtime! {
EthereumInboundQueue: snowbridge_pallet_inbound_queue = 24,
EthereumSystem: snowbridge_pallet_system = 25,
OutboundMessageCommitmentRecorder: pallet_outbound_message_commitment_recorder = 26,
EthereumTokenTransfers: pallet_ethereum_token_transfers = 27,

// Session management
Session: pallet_session = 30,
Expand Down Expand Up @@ -2319,6 +2325,7 @@ mod benches {
[pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::<Runtime>]
[pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::<Runtime>]
// Bridges
[pallet_ethereum_token_transfers, EthereumTokenTransfers]
[snowbridge_pallet_ethereum_client, EthereumBeaconClient]
[snowbridge_pallet_outbound_queue, EthereumOutboundQueue]
[snowbridge_pallet_system, EthereumSystem]
Expand Down
Loading
Loading