From 81ce907d93416ecec40a0186cfa6e376677693fc Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 21 Nov 2024 13:08:27 +0100 Subject: [PATCH 01/23] checkpoint --- pallets/rolldown/src/benchmarking.rs | 196 ++++++++++++--- pallets/rolldown/src/lib.rs | 359 ++++++++++++++------------- pallets/rolldown/src/messages/mod.rs | 19 ++ 3 files changed, 360 insertions(+), 214 deletions(-) diff --git a/pallets/rolldown/src/benchmarking.rs b/pallets/rolldown/src/benchmarking.rs index 6dd7e3c89..8e5c627c5 100644 --- a/pallets/rolldown/src/benchmarking.rs +++ b/pallets/rolldown/src/benchmarking.rs @@ -466,6 +466,7 @@ mod benchmarks { Ok(()) } + //FIX: check and possibly allign this benchmark #[benchmark] fn cancel_requests_from_l1() -> Result<(), BenchmarkError> { setup_sequencer::(SEQUENCER_ACCOUNT.into(), None, true, false)?; @@ -474,17 +475,21 @@ mod benchmarks { get_chain_and_address_for_asset_id::(TOKEN_ID.into())?; let l1_chain: ::ChainId = l1_aset_chain.into(); + let requests = vec![L1UpdateRequest::Deposit(Default::default())]; let update = L1UpdateBuilder::default() .with_requests(vec![L1UpdateRequest::Deposit(Default::default())]) .build(); + let update_hash = H256::default(); let sequencer_account: T::AccountId = SEQUENCER_ACCOUNT.into(); PendingSequencerUpdates::::insert( DUMMY_REQUEST_ID, l1_chain, - (sequencer_account, update, H256::default()), + (sequencer_account, H256::default(), requests.len() as u128), ); + PendingSequencerUpdateContent::::insert(update_hash, update); + assert!( L2Requests::::get(l1_chain, RequestId::from((Origin::L2, FIRST_REQUEST_ID))) .is_none(), @@ -508,6 +513,7 @@ mod benchmarks { Ok(()) } + //FIX: check and possibly allign this benchmark #[benchmark] fn force_cancel_requests_from_l1() -> Result<(), BenchmarkError> { setup_sequencer::(SEQUENCER_ACCOUNT.into(), None, true, true)?; @@ -519,7 +525,7 @@ mod benchmarks { PendingSequencerUpdates::::insert( DUMMY_REQUEST_ID, l1_chain, - (sequencer_account, messages::L1Update::default(), H256::default()), + (sequencer_account, H256::default(), 0u128), ); assert!( @@ -882,53 +888,171 @@ mod benchmarks { Ok(()) } + // #[benchmark] + // fn schedule_requests(x: Linear<2, 200>) -> Result<(), BenchmarkError> { + // let (l1_aset_chain, l1_asset_address) = + // get_chain_and_address_for_asset_id::(TOKEN_ID.into())?; + // let l1_chain: ::ChainId = l1_aset_chain.into(); + // + // let x_deposits: usize = (x as usize) / 2; + // let x_cancel_resolution: usize = (x as usize) - x_deposits; + // let mut update = L1UpdateBuilder::default() + // .with_requests( + // [ + // vec![L1UpdateRequest::Deposit(Default::default()); x_deposits], + // vec![ + // L1UpdateRequest::CancelResolution(Default::default()); + // x_cancel_resolution + // ], + // ] + // .concat(), + // ) + // .build(); + // + // assert!( + // MaxAcceptedRequestIdOnl2::::get(l1_chain).is_zero(), + // "BEFORE MaxAcceptedRequestIdOnl2 {:?} chain should be zero", + // l1_chain + // ); + // assert!( + // UpdatesExecutionQueue::::get(FIRST_SCHEDULED_UPDATE_ID).is_none(), + // "BEFORE UpdatesExecutionQueue {:?} scheduled update id should be none", + // FIRST_SCHEDULED_UPDATE_ID + // ); + // + // #[block] + // { + // Rolldown::::schedule_requests(BlockNumberFor::::default(), l1_chain, update); + // } + // + // assert!( + // !MaxAcceptedRequestIdOnl2::::get(l1_chain).is_zero(), + // "AFTER MaxAcceptedRequestIdOnl2 {:?} chain should NOT be zero", + // l1_chain + // ); + // assert!( + // UpdatesExecutionQueue::::get(FIRST_SCHEDULED_UPDATE_ID).is_some(), + // "AFTER UpdatesExecutionQueue {:?} scheduled update id should be some", + // FIRST_SCHEDULED_UPDATE_ID + // ); + // Ok(()) + // } + + #[benchmark] + fn schedule_request_for_execution_if_dispute_period_has_passsed() -> Result<(), BenchmarkError> + { + setup_account::(USER_ACCOUNT.into())?; + setup_and_do_withdrawal::(USER_ACCOUNT.into())?; + + let block_for_automatic_batch = + (::MerkleRootAutomaticBatchSize::get() + 1u128).saturated_into::(); + let chain: ::ChainId = crate::messages::Chain::Ethereum.into(); + let update_hash = + H256::from(hex!("1111111111111111111111111111111111111111111111111111111111111111")); + + let sequencer_account: T::AccountId = SEQUENCER_ACCOUNT.into(); + PendingSequencerUpdates::::insert(1u128, chain, (sequencer_account, update_hash, 0u128)); + assert_eq!(LastScheduledUpdateIdInExecutionQueue::::get(), 0u128); + assert_eq!(UpdatesExecutionQueue::::get(FIRST_SCHEDULED_UPDATE_ID), None); + + #[block] + { + Rolldown::::schedule_request_for_execution_if_dispute_period_has_passsed( + block_for_automatic_batch.into(), + ); + } + + assert_eq!(LastScheduledUpdateIdInExecutionQueue::::get(), 1u128); + assert_eq!( + UpdatesExecutionQueue::::get(FIRST_SCHEDULED_UPDATE_ID), + Some((block_for_automatic_batch.into(), chain, update_hash)) + ); + + Ok(()) + } + #[benchmark] - fn schedule_requests(x: Linear<2, 200>) -> Result<(), BenchmarkError> { + fn maybe_create_batch() -> Result<(), BenchmarkError> { + // trigger batch creating because of automatic batch size + setup_sequencer::(SEQUENCER_ACCOUNT.into(), None, true, true)?; + let (l1_aset_chain, l1_asset_address) = get_chain_and_address_for_asset_id::(TOKEN_ID.into())?; let l1_chain: ::ChainId = l1_aset_chain.into(); + let automatic_batch_size = Pallet::::automatic_batch_size(); - let x_deposits: usize = (x as usize) / 2; - let x_cancel_resolution: usize = (x as usize) - x_deposits; - let mut update = L1UpdateBuilder::default() - .with_requests( - [ - vec![L1UpdateRequest::Deposit(Default::default()); x_deposits], - vec![ - L1UpdateRequest::CancelResolution(Default::default()); - x_cancel_resolution - ], - ] - .concat(), - ) - .build(); + let last_batch_id = 1u128; + let latest_element_in_previous_batch = 123u128; + let last_batch_range = (1u128, latest_element_in_previous_batch); + let latest_element_now = latest_element_in_previous_batch + automatic_batch_size; - assert!( - MaxAcceptedRequestIdOnl2::::get(l1_chain).is_zero(), - "BEFORE MaxAcceptedRequestIdOnl2 {:?} chain should be zero", - l1_chain - ); - assert!( - UpdatesExecutionQueue::::get(FIRST_SCHEDULED_UPDATE_ID).is_none(), - "BEFORE UpdatesExecutionQueue {:?} scheduled update id should be none", - FIRST_SCHEDULED_UPDATE_ID - ); + assert!(T::SequencerStakingProvider::is_selected_sequencer( + l1_chain, + &SEQUENCER_ACCOUNT.into() + )); + + L2OriginRequestId::::mutate(|map| { + map.insert(l1_chain, latest_element_now.saturating_add(1u128)); + }); + + L2RequestsBatchLast::::mutate(|map| { + map.insert(l1_chain, (20u32.into(), 1u128, (1u128, latest_element_in_previous_batch))); + }); + + assert_eq!(L2RequestsBatch::::get((l1_chain, 2u128)), None); + + >::set_block_number(20u32.into()); #[block] { - Rolldown::::schedule_requests(BlockNumberFor::::default(), l1_chain, update); + Rolldown::::maybe_create_batch(21u32.into()); } - assert!( - !MaxAcceptedRequestIdOnl2::::get(l1_chain).is_zero(), - "AFTER MaxAcceptedRequestIdOnl2 {:?} chain should NOT be zero", - l1_chain + assert_eq!( + L2RequestsBatch::::get((l1_chain, 2u128)), + Some(( + 21u32.into(), + (latest_element_in_previous_batch + 1, latest_element_now), + SEQUENCER_ACCOUNT.into() + )) ); - assert!( - UpdatesExecutionQueue::::get(FIRST_SCHEDULED_UPDATE_ID).is_some(), - "AFTER UpdatesExecutionQueue {:?} scheduled update id should be some", - FIRST_SCHEDULED_UPDATE_ID + + Ok(()) + } + + #[benchmark] + fn execute_requests_from_execute_queue() -> Result<(), BenchmarkError> { + let (l1_aset_chain, l1_asset_address) = + get_chain_and_address_for_asset_id::(TOKEN_ID.into())?; + let l1_chain: ::ChainId = l1_aset_chain.into(); + + >::set_block_number(20u32.into()); + let execution_id = 123u128; + let scheduled_at: BlockNumberFor = 19u32.into(); + let l1_chain: ::ChainId = l1_aset_chain.into(); + let update_hash = + H256::from(hex!("1111111111111111111111111111111111111111111111111111111111111111")); + + UpdatesExecutionQueueNextId::::put(execution_id); + UpdatesExecutionQueue::::insert(execution_id, (scheduled_at, l1_chain, update_hash)); + LastProcessedRequestOnL2::::insert(l1_chain, 0u128); + + let update = L1UpdateBuilder::default() + .with_requests(vec![L1UpdateRequest::Deposit(Default::default()); 10_000]) + .build(); + PendingSequencerUpdateContent::::insert(update_hash, update); + + #[block] + { + Rolldown::::execute_requests_from_execute_queue(21u32.into()); + } + + UpdatesExecutionQueue::::get(execution_id).expect("update partially executed"); + assert_eq!( + LastProcessedRequestOnL2::::get(l1_chain), + ::RequestsPerBlock::get() ); + Ok(()) } } diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index 2fa346cee..47446b3eb 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -61,6 +61,7 @@ macro_rules! log { }; } + #[derive(Debug, PartialEq)] pub struct EthereumAddressConverter(sp_std::marker::PhantomData); @@ -140,6 +141,34 @@ mod mock; use crate::messages::L1Update; pub use pallet::*; +fn get_read_scalling_factor(size: usize) -> u128 { + const base_read_cost: u128 = 25; + let approximated_cost = match size{ + 0..=50 => 25u128, + 51..=100 => 45u128, + 101..=500 => 210u128, + 501..=1000 => 400u128, + 1001..=5000 => 1800u128, + _ => 2800u128, + }; + approximated_cost.saturating_div(base_read_cost).saturating_add(1u128) +} + + +fn get_write_scalling_factor(size: usize) -> u128 { + const base_write_cost: u128 = 100; + + let approximated_cost = match size{ + 0..=50 => 25u128, + 51..=100 => 150u128, + 101..=500 => 700u128, + 501..=1000 => 1050u128, + 1001..=5000 => 5000u128, + _ => 9000u128, + }; + approximated_cost.saturating_div(base_write_cost).saturating_add(1u128) +} + #[frame_support::pallet] pub mod pallet { @@ -151,28 +180,43 @@ pub mod pallet { #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(PhantomData); + #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(now: BlockNumberFor) -> Weight { - let mut total_weight: Weight = Weight::default(); + let mut total_weight: Weight = T::DbWeight::get().reads(1); if T::MaintenanceStatusProvider::is_maintenance() { LastMaintananceMode::::put(now.saturated_into::()); + total_weight += T::DbWeight::get().writes(1); + }else{ + Self::maybe_create_batch(now); + Self::schedule_request_for_execution_if_dispute_period_has_passsed(now); + // total_weight = + // total_weight.saturating_add(::WeightInfo::maybe_create_batch()); + // total_weight = total_weight.saturating_add(::WeightInfo::schedule_request_for_execution_if_dispute_period_has_passsed()); } - // weight for is_maintenance - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); - let weight = Self::maybe_create_batch(now); - total_weight = total_weight.saturating_add(weight); - let weight = Self::schedule_request_for_execution_if_dispute_period_has_passsed(now); - total_weight = total_weight.saturating_add(weight); - let weight = Self::execute_requests_from_execute_queue(now); - total_weight = total_weight.saturating_add(weight); - // We multiply by two so that we can have our large storage access (update requests) - // go upto 500 requests per update - // 500 also is really pushing it - it should probably be something like 100... - // https://substrate.stackexchange.com/questions/525/how-expensive-is-it-to-access-storage-items total_weight - .saturating_mul(2) - .saturating_add(Weight::from_parts(200__000_000, 0)) + } + + fn on_idle(now: BlockNumberFor, mut remaining_weight: Weight) -> Weight { + let mut used_weight = Weight::default(); + + if T::MaintenanceStatusProvider::is_maintenance() { + return used_weight; + } + + + let get_update_size_weight = T::DbWeight::get().reads(2); + if remaining_weight.ref_time() > get_update_size_weight.ref_time() { + used_weight += get_update_size_weight; + if let Some(size) = Self::get_current_update_size_from_execution_queue() { + return used_weight; + }else{ + return used_weight; + } + } + + return used_weight; } } @@ -184,6 +228,17 @@ pub mod pallet { pub cancel_rights: u128, } + #[derive( + Eq, PartialEq, RuntimeDebug, Clone, Encode, Decode, MaxEncodedLen, TypeInfo + )] + pub struct UpdateMetadata{ + pub max_id: u128, + pub min_id: u128, + pub update_size: u128, + pub sequencer: T::AccountId, + pub update_hash: H256, + } + #[derive(Eq, PartialEq, RuntimeDebug, Clone, Copy, Encode, Decode, TypeInfo)] pub enum L2Request { FailedDepositResolution(FailedDepositResolution), @@ -245,10 +300,16 @@ pub mod pallet { u128, Blake2_128Concat, ::ChainId, - (T::AccountId, messages::L1Update, H256), + UpdateMetadata, OptionQuery, >; + #[pallet::storage] + #[pallet::unbounded] + // Stores requests brought by sequencer that are under dispute period. + pub type PendingSequencerUpdateContent = + StorageMap<_, Blake2_128Concat, H256, messages::L1Update, OptionQuery>; + #[pallet::storage] #[pallet::unbounded] // queue of all updates that went through dispute period and are ready to be processed @@ -256,7 +317,8 @@ pub mod pallet { _, Blake2_128Concat, u128, - (BlockNumberFor, ::ChainId, messages::L1Update), + // scheduled_at, chain, update_hash, update_size + (BlockNumberFor, ::ChainId, H256, u128), OptionQuery, >; @@ -540,7 +602,7 @@ pub mod pallet { origin: OriginFor, update: messages::L1Update, ) -> DispatchResultWithPostInfo { - let _ = ensure_root(origin)?; + let root = ensure_root(origin)?; let chain: ::ChainId = update.chain.into(); ensure!( @@ -548,9 +610,13 @@ pub mod pallet { Error::::BlockedByMaintenanceMode ); - Self::validate_l1_update(chain, &update)?; + let metadata = Self::validate_l1_update(chain, &update, T::AddressConverter::convert([0u8;20]))?; + + PendingSequencerUpdateContent::::insert(metadata.update_hash, update); + let now = >::block_number(); - Self::schedule_requests(now, chain, update.into()); + let update_size = update.get_requests_count(); + Self::schedule_requests(now, chain, metadata); Ok(().into()) } @@ -577,11 +643,15 @@ pub mod pallet { Ok::<_, Error>(()) })?; - let (submitter, request, _) = + let metadata = PendingSequencerUpdates::::take(requests_to_cancel, chain) .ok_or(Error::::RequestDoesNotExist)?; - let hash_of_pending_request = Self::calculate_hash_of_sequencer_update(request.clone()); + let submitter = metadata.sequencer; + let request_hash = metadata.update_hash; + + let request = PendingSequencerUpdateContent::::take(request_hash) + .ok_or(Error::::RequestDoesNotExist)?; let l2_request_id = Self::acquire_l2_request_id(chain); @@ -590,7 +660,7 @@ pub mod pallet { updater: submitter.clone(), canceler: canceler.clone(), range: request.range().ok_or(Error::::InvalidUpdate)?, - hash: hash_of_pending_request, + hash: request_hash, }; AwaitingCancelResolution::::mutate(chain, |v| { @@ -723,10 +793,13 @@ pub mod pallet { Error::::BlockedByMaintenanceMode ); - let (submitter, _request, _hash) = + let metadata = PendingSequencerUpdates::::take(requests_to_cancel, chain) .ok_or(Error::::RequestDoesNotExist)?; + let submitter = metadata.sequencer; + let hash = metadata.update_hash; + if T::SequencerStakingProvider::is_active_sequencer(chain, &submitter) { SequencersRights::::mutate(chain, |sequencers| { if let Some(rights) = sequencers.get_mut(&submitter) { @@ -941,31 +1014,29 @@ impl Pallet { request_id: u128, ) -> Option { let pending_requests_to_process = PendingSequencerUpdates::::get(request_id, chain); - if let Some((_, l1_update, _hash)) = pending_requests_to_process { - let calculated_hash = Self::calculate_hash_of_sequencer_update(l1_update); - Some(hash == calculated_hash) + if let Some(metadata) = pending_requests_to_process { + + if let Some(l1_update) = PendingSequencerUpdateContent::::get(metadata.update_hash) { + let calculated_hash = Self::calculate_hash_of_sequencer_update(&l1_update); + Some(hash == calculated_hash) + } else { + None + } } else { None } } - fn maybe_create_batch(now: BlockNumberFor) -> Weight { - let mut total_weight: Weight = Weight::default(); + fn maybe_create_batch(now: BlockNumberFor) { let batch_size = Self::automatic_batch_size(); let batch_period: BlockNumberFor = Self::automatic_batch_period().saturated_into(); // weight for is_maintenance - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); if T::MaintenanceStatusProvider::is_maintenance() { - return total_weight + return; } - // weight for L2OriginRequestId iter extra read incase empty - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); for (chain, next_id) in L2OriginRequestId::::get().iter() { - // weight for L2OriginRequestId iter - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); - let last_id = next_id.saturating_sub(1); let (last_batch_block_number, last_batch_id, last_id_in_batch) = @@ -976,8 +1047,6 @@ impl Pallet { (block_number, batch_id, last_reqeust_id) }) .unwrap_or_default(); - // weight for L2RequestsBatchLast - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); let trigger = if last_id >= last_id_in_batch + batch_size { Some(BatchSource::AutomaticSizeReached) @@ -988,8 +1057,6 @@ impl Pallet { }; if let Some(trigger) = trigger { - // weight for selected_sequencer - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); let updater = T::SequencerStakingProvider::selected_sequencer(*chain) .unwrap_or(T::AddressConverter::convert([0u8; 20])); let batch_id = last_batch_id.saturating_add(1); @@ -1003,13 +1070,9 @@ impl Pallet { (chain, batch_id), (now, (range_start, range_end), updater.clone()), ); - // weight for L2RequestsBatch - total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); L2RequestsBatchLast::::mutate(|batches| { batches.insert(chain.clone(), (now, batch_id, (range_start, range_end))); }); - // weight for L2RequestsBatchLast - total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); Pallet::::deposit_event(Event::TxBatchCreated { chain: *chain, source: trigger, @@ -1017,33 +1080,22 @@ impl Pallet { batch_id, range: (range_start, range_end), }); - // Not sure about this - not sure exactly what is cached and how across extrinsics (/hooks) - // weight for deposit_event - total_weight = - total_weight.saturating_add(T::DbWeight::get().reads_writes(2, 3)); break } } } - total_weight + Default::default() } - fn schedule_request_for_execution_if_dispute_period_has_passsed( - now: BlockNumberFor, - ) -> Weight { - // weight = 0 -> pretty sure reading blocknumber is free + fn schedule_request_for_execution_if_dispute_period_has_passsed(now: BlockNumberFor) { let block_number = >::block_number().saturated_into::(); - let mut total_weight: Weight = Weight::default(); - let mut number_of_updates: u32 = u32::zero(); - // weight for PendingSequencerUpdates iter extra read incase empty - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); - for (l1, (sequencer, requests, l1_read_hash)) in + for (l1, metadata) in PendingSequencerUpdates::::iter_prefix(block_number) { - number_of_updates = number_of_updates.saturating_add(1u32); - // weight for PendingSequencerUpdates iter - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); + let sequencer = metadata.sequencer; + let l1_read_hash = metadata.update_hash; + let update_size = metadata.update_size; if T::SequencerStakingProvider::is_active_sequencer(l1, &sequencer) { SequencersRights::::mutate(l1, |sequencers| { @@ -1052,56 +1104,31 @@ impl Pallet { } }); } - // weight for above block - total_weight = total_weight.saturating_add(T::DbWeight::get().reads_writes(2, 1)); let update_creation_block = block_number.saturating_sub(Self::get_dispute_period()); - // weight for LastMaintananceMode - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); match LastMaintananceMode::::get() { Some(last_maintanance_mode) if update_creation_block < last_maintanance_mode => { Self::deposit_event(Event::L1ReadIgnoredBecauseOfMaintenanceMode { chain: l1, hash: l1_read_hash, }); - - // Not sure about this - not sure exactly what is cached and how across extrinsics (/hooks) - // weight for deposit_event - total_weight = - total_weight.saturating_add(T::DbWeight::get().reads_writes(2, 3)); }, _ => { - Self::schedule_requests(now, l1, requests.clone()); - // weight for schedule_requests - total_weight = - total_weight.saturating_add(::WeightInfo::schedule_requests( - requests - .pendingDeposits - .len() - .saturating_add(requests.pendingCancelResolutions.len()) as u32, - )); + Self::schedule_requests(now, l1, metadata); Self::deposit_event(Event::L1ReadScheduledForExecution { chain: l1, hash: l1_read_hash, }); - // Not sure about this - not sure exactly what is cached and how across extrinsics (/hooks) - // weight for deposit_event - total_weight = - total_weight.saturating_add(T::DbWeight::get().reads_writes(2, 3)); }, } } - // weight for PendingSequencerUpdates iter - total_weight = - total_weight.saturating_add(T::DbWeight::get().writes(number_of_updates.into())); + // FIXME: remove update from storage somwhere else let _ = PendingSequencerUpdates::::clear_prefix( >::block_number().saturated_into::(), u32::MAX, None, ); - - total_weight } fn process_single_request( @@ -1160,106 +1187,76 @@ impl Pallet { total_weight } - fn execute_requests_from_execute_queue(now: BlockNumberFor) -> Weight { - let mut total_weight: Weight = Weight::default(); - - // weight for the if in the below block - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(3)); - if T::MaintenanceStatusProvider::is_maintenance() && - UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()).is_some() - { - let new_id: u128 = LastScheduledUpdateIdInExecutionQueue::::mutate(|v| { - v.saturating_inc(); - *v - }); - UpdatesExecutionQueueNextId::::put(new_id); + fn has_next_update_to_execute() -> bool { + UpdatesExecutionQueue::::contains_key(UpdatesExecutionQueueNextId::::get().saturating_add(1)) + } - // weight for this block - total_weight = total_weight.saturating_add(T::DbWeight::get().writes(2)); - return total_weight - } + fn get_current_update_size_from_execution_queue() -> Option { + UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()).map(|(_, _, _, size)| size) + } + fn execute_requests_from_execute_queue(now: BlockNumberFor) -> Weight { let mut limit = Self::get_max_requests_per_block(); - loop { - if limit == 0 { - return total_weight - } - - // weight for the if in the below block - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(2)); - if let Some((scheduled_at, l1, r)) = - UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()) - { - if scheduled_at == now { - return total_weight - } - - // Repeated reads of the same value should be cached - // weight for LastProcessedRequestOnL2 - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); - for req in r - .into_requests() - .into_iter() - .filter(|request| request.id() > LastProcessedRequestOnL2::::get(l1)) - .map(|val| Some(val)) - .chain(sp_std::iter::repeat(None)) - .take(limit.try_into().unwrap()) - { - if let Some(request) = req { - let weight = Self::process_single_request(l1, request); - // weight for process_single_request - total_weight = total_weight.saturating_add(weight); - limit -= 1; - } else { + while limit > 0 { + match (UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()), LastMaintananceMode::::get(), Self::has_next_update_to_execute()) { + (Some((scheduled_at, l1, hash, _)), Some(last_maintanance_mode), _) if scheduled_at.saturated_into::() <= last_maintanance_mode => { + UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); + UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); + break; + }, + (Some((scheduled_at, l1, hash, _)), _, _) => { + if let Some(update) = PendingSequencerUpdateContent::::get(hash){ + for req in update + .into_requests() + .into_iter() + .filter(|request| request.id() > LastProcessedRequestOnL2::::get(l1)) + .map(|val| Some(val)) + .chain(sp_std::iter::repeat(None)) + .take(limit.saturated_into()) + { + if let Some(request) = req { + let weight = Self::process_single_request(l1, request); + limit -= 1; + } else { + UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); + UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); + break; + } + } + }else { UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); - UpdatesExecutionQueueNextId::::mutate(|v| *v += 1); - // weight for this block - total_weight = - total_weight.saturating_add(T::DbWeight::get().reads_writes(1, 2)); - break + UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); } + }, + (None, _, true) => { + if UpdatesExecutionQueue::::contains_key( + UpdatesExecutionQueueNextId::::get().saturating_add(1), + ) { + UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); + } + break; } - } else { - // weight for the if in the below block - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(2)); - if UpdatesExecutionQueue::::contains_key( - UpdatesExecutionQueueNextId::::get() + 1, - ) { - UpdatesExecutionQueueNextId::::mutate(|v| *v += 1); - // weight for UpdatesExecutionQueueNextId - total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); - } else { - break + (None, _, false) => { + break; } } } - total_weight + Default::default() } fn schedule_requests( now: BlockNumberFor, chain: ::ChainId, - update: messages::L1Update, + metadata: UpdateMetadata, ) { - let max_id = [ - update.pendingDeposits.iter().map(|r| r.requestId.id).max(), - update.pendingCancelResolutions.iter().map(|r| r.requestId.id).max(), - ] - .iter() - .filter_map(|elem| elem.clone()) - .max(); - - if let Some(max_id) = max_id { - MaxAcceptedRequestIdOnl2::::mutate(chain, |cnt| { - *cnt = sp_std::cmp::max(*cnt, max_id) - }); - } + MaxAcceptedRequestIdOnl2::::mutate(chain, |cnt| *cnt = sp_std::cmp::max(*cnt, metadata.max_id)); let id = LastScheduledUpdateIdInExecutionQueue::::mutate(|id| { id.saturating_inc(); *id }); - UpdatesExecutionQueue::::insert(id, (now, chain, update)); + let size = metadata.max_id.saturating_sub(metadata.min_id).saturating_add(1); + UpdatesExecutionQueue::::insert(id, (now, chain, metadata.update_hash, size)); } /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -1347,8 +1344,8 @@ impl Pallet { Ok(()) } - fn calculate_hash_of_sequencer_update(update: messages::L1Update) -> H256 { - let update: messages::eth_abi::L1Update = update.into(); + fn calculate_hash_of_sequencer_update(update: &messages::L1Update) -> H256 { + let update: messages::eth_abi::L1Update = update.clone().into(); let hash: [u8; 32] = keccak_256(&update.abi_encode()[..]).into(); H256::from(hash) } @@ -1386,7 +1383,8 @@ impl Pallet { pub fn validate_l1_update( l1: ::ChainId, update: &messages::L1Update, - ) -> DispatchResult { + sequencer: T::AccountId + ) -> Result, Error> { ensure!( !update.pendingDeposits.is_empty() || !update.pendingCancelResolutions.is_empty(), Error::::EmptyUpdate @@ -1473,7 +1471,13 @@ impl Pallet { } } - Ok(().into()) + Ok(UpdateMetadata { + sequencer, + update_hash: Self::calculate_hash_of_sequencer_update(&update), + update_size: update.pendingDeposits.len() as u128 + update.pendingCancelResolutions.len() as u128, + max_id: lowest_id, + min_id: last_id, + }) } pub fn update_impl(sequencer: T::AccountId, read: messages::L1Update) -> DispatchResult { @@ -1488,7 +1492,7 @@ impl Pallet { T::SequencerStakingProvider::is_selected_sequencer(l1, &sequencer), Error::::OnlySelectedSequencerisAllowedToUpdate ); - Self::validate_l1_update(l1, &read)?; + let metadata = Self::validate_l1_update(l1, &read, sequencer)?; // check json length to prevent big data spam, maybe not necessary as it will be checked later and slashed let current_block_number = @@ -1519,16 +1523,15 @@ impl Pallet { Error::::MultipleUpdatesInSingleBlock ); - let update: messages::eth_abi::L1Update = read.clone().into(); - let request_hash = keccak_256(&update.abi_encode()); - let l1_read_hash = H256::from_slice(request_hash.as_slice()); PendingSequencerUpdates::::insert( dispute_period_end, l1, - (sequencer.clone(), read.clone(), l1_read_hash), + metadata ); + PendingSequencerUpdateContent::::insert(metadata.update_hash, read.clone()); + LastUpdateBySequencer::::insert((l1, &sequencer), current_block_number); let requests_range = read.range().ok_or(Error::::InvalidUpdate)?; @@ -1538,7 +1541,7 @@ impl Pallet { sequencer: sequencer.clone(), dispute_period_end, range: requests_range, - hash: l1_read_hash, + hash: metadata.update_hash, }); // 2 storage reads & writes in seqs pallet diff --git a/pallets/rolldown/src/messages/mod.rs b/pallets/rolldown/src/messages/mod.rs index ab8a64f47..de21b8b72 100644 --- a/pallets/rolldown/src/messages/mod.rs +++ b/pallets/rolldown/src/messages/mod.rs @@ -104,6 +104,19 @@ pub enum Chain { Arbitrum, } +pub trait NextEnum { + fn next(self) -> Self; +} + +impl NextEnum for Chain { + fn next(self) -> Self { + match self { + Chain::Ethereum => Chain::Arbitrum, + Chain::Arbitrum => Chain::Ethereum, + } + } +} + #[repr(u8)] #[derive( Default, Eq, PartialEq, RuntimeDebug, Clone, Encode, Decode, TypeInfo, Serialize, Copy, @@ -233,6 +246,12 @@ pub struct L1Update { pub pendingCancelResolutions: Vec, } +impl L1Update{ + pub fn get_requests_count(&self) -> u128 { + self.pendingDeposits.len() as u128 + self.pendingCancelResolutions.len() as u128 + } +} + impl NativeToEthMapping for L1Update where Self: Clone, From 00a5955580f99a5e751756a8f27bff424236b2b0 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 21 Nov 2024 13:13:53 +0100 Subject: [PATCH 02/23] compiled --- pallets/rolldown/src/lib.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index 47446b3eb..5a56bde23 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -231,11 +231,11 @@ pub mod pallet { #[derive( Eq, PartialEq, RuntimeDebug, Clone, Encode, Decode, MaxEncodedLen, TypeInfo )] - pub struct UpdateMetadata{ + pub struct UpdateMetadata{ pub max_id: u128, pub min_id: u128, pub update_size: u128, - pub sequencer: T::AccountId, + pub sequencer: AccountId, pub update_hash: H256, } @@ -300,7 +300,7 @@ pub mod pallet { u128, Blake2_128Concat, ::ChainId, - UpdateMetadata, + UpdateMetadata, OptionQuery, >; @@ -612,10 +612,10 @@ pub mod pallet { let metadata = Self::validate_l1_update(chain, &update, T::AddressConverter::convert([0u8;20]))?; - PendingSequencerUpdateContent::::insert(metadata.update_hash, update); - let now = >::block_number(); let update_size = update.get_requests_count(); + PendingSequencerUpdateContent::::insert(metadata.update_hash, update); + Self::schedule_requests(now, chain, metadata); Ok(().into()) } @@ -1093,9 +1093,9 @@ impl Pallet { for (l1, metadata) in PendingSequencerUpdates::::iter_prefix(block_number) { - let sequencer = metadata.sequencer; - let l1_read_hash = metadata.update_hash; - let update_size = metadata.update_size; + let sequencer = metadata.sequencer.clone(); + let l1_read_hash = metadata.update_hash.clone(); + let update_size = metadata.update_size.clone(); if T::SequencerStakingProvider::is_active_sequencer(l1, &sequencer) { SequencersRights::::mutate(l1, |sequencers| { @@ -1247,7 +1247,7 @@ impl Pallet { fn schedule_requests( now: BlockNumberFor, chain: ::ChainId, - metadata: UpdateMetadata, + metadata: UpdateMetadata, ) { MaxAcceptedRequestIdOnl2::::mutate(chain, |cnt| *cnt = sp_std::cmp::max(*cnt, metadata.max_id)); @@ -1384,7 +1384,7 @@ impl Pallet { l1: ::ChainId, update: &messages::L1Update, sequencer: T::AccountId - ) -> Result, Error> { + ) -> Result, Error> { ensure!( !update.pendingDeposits.is_empty() || !update.pendingCancelResolutions.is_empty(), Error::::EmptyUpdate @@ -1492,7 +1492,7 @@ impl Pallet { T::SequencerStakingProvider::is_selected_sequencer(l1, &sequencer), Error::::OnlySelectedSequencerisAllowedToUpdate ); - let metadata = Self::validate_l1_update(l1, &read, sequencer)?; + let metadata = Self::validate_l1_update(l1, &read, sequencer.clone())?; // check json length to prevent big data spam, maybe not necessary as it will be checked later and slashed let current_block_number = @@ -1527,7 +1527,7 @@ impl Pallet { PendingSequencerUpdates::::insert( dispute_period_end, l1, - metadata + metadata.clone() ); PendingSequencerUpdateContent::::insert(metadata.update_hash, read.clone()); From 5105cc8c33cb10470efc6f33d42627ef51f041d1 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 21 Nov 2024 15:21:54 +0100 Subject: [PATCH 03/23] all compiles --- pallets/rolldown/src/benchmarking.rs | 43 ++++++++++++++++++++++++---- pallets/rolldown/src/lib.rs | 8 +++--- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/pallets/rolldown/src/benchmarking.rs b/pallets/rolldown/src/benchmarking.rs index 8e5c627c5..1d4dd6227 100644 --- a/pallets/rolldown/src/benchmarking.rs +++ b/pallets/rolldown/src/benchmarking.rs @@ -353,6 +353,14 @@ mod benchmarks { .build(); let update_hash = update.abi_encode_hash(); + let metadata = UpdateMetadata { + min_id: 0u128, + max_id: 0u128, + update_size: 0u128, + sequencer: SEQUENCER_ACCOUNT, + update_hash, + }; + >::set_block_number(1u32.into()); let dispute_period_end = >::block_number().saturated_into::() + Rolldown::::get_dispute_period(); @@ -482,10 +490,18 @@ mod benchmarks { let update_hash = H256::default(); let sequencer_account: T::AccountId = SEQUENCER_ACCOUNT.into(); + let metadata = UpdateMetadata { + min_id: 1u128, + max_id: 1u128, + update_size: 1u128, + sequencer: sequencer_account.clone(), + update_hash: H256::zero(), + }; + PendingSequencerUpdates::::insert( DUMMY_REQUEST_ID, l1_chain, - (sequencer_account, H256::default(), requests.len() as u128), + metadata, ); PendingSequencerUpdateContent::::insert(update_hash, update); @@ -521,11 +537,20 @@ mod benchmarks { get_chain_and_address_for_asset_id::(TOKEN_ID.into())?; let l1_chain: ::ChainId = l1_aset_chain.into(); + let metadata = UpdateMetadata:: { + min_id: 1u128, + max_id: 1u128, + update_size: 1u128, + sequencer: T::AddressConverter::convert(SEQUENCER_ACCOUNT), + update_hash: H256::zero(), + }; + + let sequencer_account: T::AccountId = SEQUENCER_ACCOUNT.into(); PendingSequencerUpdates::::insert( DUMMY_REQUEST_ID, l1_chain, - (sequencer_account, H256::default(), 0u128), + metadata, ); assert!( @@ -951,7 +976,15 @@ mod benchmarks { H256::from(hex!("1111111111111111111111111111111111111111111111111111111111111111")); let sequencer_account: T::AccountId = SEQUENCER_ACCOUNT.into(); - PendingSequencerUpdates::::insert(1u128, chain, (sequencer_account, update_hash, 0u128)); + let metadata = UpdateMetadata { + min_id: 1u128, + max_id: 1u128, + update_size: 1u128, + sequencer: sequencer_account.clone(), + update_hash: H256::zero(), + }; + + PendingSequencerUpdates::::insert(1u128, chain, metadata); assert_eq!(LastScheduledUpdateIdInExecutionQueue::::get(), 0u128); assert_eq!(UpdatesExecutionQueue::::get(FIRST_SCHEDULED_UPDATE_ID), None); @@ -965,7 +998,7 @@ mod benchmarks { assert_eq!(LastScheduledUpdateIdInExecutionQueue::::get(), 1u128); assert_eq!( UpdatesExecutionQueue::::get(FIRST_SCHEDULED_UPDATE_ID), - Some((block_for_automatic_batch.into(), chain, update_hash)) + Some((block_for_automatic_batch.into(), chain, update_hash, 1u128)) ); Ok(()) @@ -1034,7 +1067,7 @@ mod benchmarks { H256::from(hex!("1111111111111111111111111111111111111111111111111111111111111111")); UpdatesExecutionQueueNextId::::put(execution_id); - UpdatesExecutionQueue::::insert(execution_id, (scheduled_at, l1_chain, update_hash)); + UpdatesExecutionQueue::::insert(execution_id, (scheduled_at, l1_chain, update_hash, 10u128)); LastProcessedRequestOnL2::::insert(l1_chain, 0u128); let update = L1UpdateBuilder::default() diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index 5a56bde23..be9a692a2 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -142,7 +142,7 @@ use crate::messages::L1Update; pub use pallet::*; fn get_read_scalling_factor(size: usize) -> u128 { - const base_read_cost: u128 = 25; + const BASE_READ_COST: u128 = 25; let approximated_cost = match size{ 0..=50 => 25u128, 51..=100 => 45u128, @@ -151,12 +151,12 @@ fn get_read_scalling_factor(size: usize) -> u128 { 1001..=5000 => 1800u128, _ => 2800u128, }; - approximated_cost.saturating_div(base_read_cost).saturating_add(1u128) + approximated_cost.saturating_div(BASE_READ_COST).saturating_add(1u128) } fn get_write_scalling_factor(size: usize) -> u128 { - const base_write_cost: u128 = 100; + const BASE_WRITE_COST: u128 = 100; let approximated_cost = match size{ 0..=50 => 25u128, @@ -166,7 +166,7 @@ fn get_write_scalling_factor(size: usize) -> u128 { 1001..=5000 => 5000u128, _ => 9000u128, }; - approximated_cost.saturating_div(base_write_cost).saturating_add(1u128) + approximated_cost.saturating_div(BASE_WRITE_COST).saturating_add(1u128) } #[frame_support::pallet] From 39c780f3343690537bc1977566ae13a1fff5befe Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 21 Nov 2024 17:28:59 +0100 Subject: [PATCH 04/23] unit tests passes --- pallets/rolldown/src/lib.rs | 94 ++++++++++++++++++++++++++--------- pallets/rolldown/src/mock.rs | 1 + pallets/rolldown/src/tests.rs | 21 ++++++-- 3 files changed, 89 insertions(+), 27 deletions(-) diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index be9a692a2..98cbb07d3 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -190,31 +190,60 @@ pub mod pallet { total_weight += T::DbWeight::get().writes(1); }else{ Self::maybe_create_batch(now); - Self::schedule_request_for_execution_if_dispute_period_has_passsed(now); - // total_weight = + } + + Self::schedule_request_for_execution_if_dispute_period_has_passsed(now); + // total_weight = // total_weight.saturating_add(::WeightInfo::maybe_create_batch()); // total_weight = total_weight.saturating_add(::WeightInfo::schedule_request_for_execution_if_dispute_period_has_passsed()); - } total_weight } fn on_idle(now: BlockNumberFor, mut remaining_weight: Weight) -> Weight { let mut used_weight = Weight::default(); + println!("here1"); if T::MaintenanceStatusProvider::is_maintenance() { return used_weight; } + let load_next_update_from_execution_queue_weight = T::DbWeight::get().reads_writes(3, 1); + if remaining_weight.ref_time() > load_next_update_from_execution_queue_weight.ref_time() { + println!("here2"); + used_weight += load_next_update_from_execution_queue_weight; + remaining_weight -= load_next_update_from_execution_queue_weight; + if Self::load_next_update_from_execution_queue(){ + return used_weight; + }else{ + Self::execute_requests_from_execute_queue(now); + // Self::get_current_update_size_from_execution_queue(); + } + } - let get_update_size_weight = T::DbWeight::get().reads(2); - if remaining_weight.ref_time() > get_update_size_weight.ref_time() { - used_weight += get_update_size_weight; - if let Some(size) = Self::get_current_update_size_from_execution_queue() { - return used_weight; - }else{ - return used_weight; - } - } + // let get_update_size_weight = T::DbWeight::get().reads(2); + // if remaining_weight.ref_time() > get_update_size_weight.ref_time() { + // used_weight += get_update_size_weight; + // remaining_weight -= get_update_size_weight; + // println!("here3"); + // if let Some(size) = Self::get_current_update_size_from_execution_queue() { + // + // println!("here4"); + // // if remaining_weight >= T::DbWeight::get().reads(1) { + // Self::execute_requests_from_execute_queue(now); + // // used_weight += T::DbWeight::get().reads(1); + // // } + // } + // } + // used_weight += get_update_size_weight; + // if let Some(size) = Self::get_current_update_size_from_execution_queue() { + // println!("here2222222222222222222222222222222222222222"); + // Self::execute_requests_from_execute_queue(now); + // return used_weight; + // }else{ + // println!("here1111111111111111111111111111111111111111"); + // return used_weight; + // } + // } return used_weight; } @@ -1124,8 +1153,10 @@ impl Pallet { } // FIXME: remove update from storage somwhere else + println!("HELLLLO WORLDDD!!!!!!!!!!!!!!!!"); + println!("{}", block_number); let _ = PendingSequencerUpdates::::clear_prefix( - >::block_number().saturated_into::(), + block_number, u32::MAX, None, ); @@ -1181,6 +1212,7 @@ impl Pallet { // weight for deposit_event total_weight = total_weight.saturating_add(T::DbWeight::get().reads_writes(2, 3)); + println!("8888888888888888888888888888888888888888"); LastProcessedRequestOnL2::::insert(l1, request.id()); // weight for LastProcessedRequestOnL2 total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); @@ -1189,11 +1221,23 @@ impl Pallet { fn has_next_update_to_execute() -> bool { UpdatesExecutionQueue::::contains_key(UpdatesExecutionQueueNextId::::get().saturating_add(1)) - } + } fn get_current_update_size_from_execution_queue() -> Option { UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()).map(|(_, _, _, size)| size) + } + + fn load_next_update_from_execution_queue() -> bool { + let current_execution_id = UpdatesExecutionQueueNextId::::get(); + let next_execution_id = current_execution_id.saturating_add(1u128); + match (UpdatesExecutionQueue::::get(current_execution_id), UpdatesExecutionQueue::::get(next_execution_id)) { + (None, Some(_)) => { + UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); + true + }, + _ => false, } + } fn execute_requests_from_execute_queue(now: BlockNumberFor) -> Weight { let mut limit = Self::get_max_requests_per_block(); @@ -1205,6 +1249,7 @@ impl Pallet { break; }, (Some((scheduled_at, l1, hash, _)), _, _) => { + println!("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); if let Some(update) = PendingSequencerUpdateContent::::get(hash){ for req in update .into_requests() @@ -1215,11 +1260,11 @@ impl Pallet { .take(limit.saturated_into()) { if let Some(request) = req { + println!("YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"); let weight = Self::process_single_request(l1, request); limit -= 1; } else { UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); - UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); break; } } @@ -1228,15 +1273,15 @@ impl Pallet { UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); } }, - (None, _, true) => { - if UpdatesExecutionQueue::::contains_key( - UpdatesExecutionQueueNextId::::get().saturating_add(1), - ) { - UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); - } - break; - } - (None, _, false) => { + // (None, _, true) => { + // if UpdatesExecutionQueue::::contains_key( + // UpdatesExecutionQueueNextId::::get().saturating_add(1), + // ) { + // UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); + // } + // break; + // } + _ => { break; } } @@ -1255,6 +1300,7 @@ impl Pallet { id.saturating_inc(); *id }); + println!("scheduled at {}", id); let size = metadata.max_id.saturating_sub(metadata.min_id).saturating_add(1); UpdatesExecutionQueue::::insert(id, (now, chain, metadata.update_hash, size)); } diff --git a/pallets/rolldown/src/mock.rs b/pallets/rolldown/src/mock.rs index 28605457f..bef085bbd 100644 --- a/pallets/rolldown/src/mock.rs +++ b/pallets/rolldown/src/mock.rs @@ -317,6 +317,7 @@ where frame_system::Pallet::::on_initialize(new_block_number); rolldown::Pallet::::on_initialize(new_block_number); + rolldown::Pallet::::on_idle(new_block_number, Weight::from_parts(u64::MAX, 0u64)); } } diff --git a/pallets/rolldown/src/tests.rs b/pallets/rolldown/src/tests.rs index d71f6c002..39b8c8b9e 100644 --- a/pallets/rolldown/src/tests.rs +++ b/pallets/rolldown/src/tests.rs @@ -152,6 +152,7 @@ fn l2_counter_updates_when_requests_are_processed() { forward_to_next_block::(); assert_eq!(Rolldown::get_last_processed_request_on_l2(Chain::Ethereum), 1u128.into()); + forward_to_next_block::(); forward_to_next_block::(); assert_eq!(Rolldown::get_last_processed_request_on_l2(Chain::Ethereum), 2u128.into()); }); @@ -333,7 +334,7 @@ fn test_withdrawal_can_be_refunded_only_by_account_deposit_recipient() { #[test] #[serial] -fn l1_upate_executed_immaidately_if_force_submitted() { +fn l1_upate_executed_immediately_if_force_submitted() { ExtBuilder::new() .issue(ALICE, ETH_TOKEN_ADDRESS_MGX, 0u128) .execute_with_default_mocks(|| { @@ -358,7 +359,8 @@ fn l1_upate_executed_immaidately_if_force_submitted() { Rolldown::force_update_l2_from_l1(RuntimeOrigin::root(), update).unwrap(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); - forward_to_block::(11); + forward_to_next_block::(); + forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 1u128.into()); assert_eq!(TokensOf::::free_balance(ETH_TOKEN_ADDRESS_MGX, &CHARLIE), MILLION); }); @@ -882,6 +884,7 @@ fn ignore_duplicated_requests_when_already_executed() { forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 5u128.into()); + forward_to_next_block::(); forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 6u128.into()); }); @@ -911,6 +914,10 @@ fn process_l1_reads_in_order() { forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 10u128.into()); + forward_to_next_block::(); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 11u128.into()); + + forward_to_next_block::(); forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 20u128.into()); }); @@ -1074,6 +1081,7 @@ fn execute_two_consecutive_incremental_reqeusts() { forward_to_next_block::(); assert_eq!(TokensOf::::free_balance(ETH_TOKEN_ADDRESS_MGX, &CHARLIE), MILLION); + forward_to_next_block::(); forward_to_next_block::(); assert_eq!( TokensOf::::free_balance(ETH_TOKEN_ADDRESS_MGX, &CHARLIE), @@ -1687,7 +1695,8 @@ fn consider_awaiting_cancel_resolutions_and_cancel_disputes_when_assigning_initi ) .unwrap(); - forward_to_block::(12); + forward_to_next_block::(); + forward_to_next_block::(); assert_eq!( *SequencersRights::::get(consts::CHAIN).get(&ALICE).unwrap(), SequencerRights { read_rights: 1u128, cancel_rights: 2u128 } @@ -2622,6 +2631,12 @@ fn test_sequencer_updates_are_ignored_and_removed_in_maintanance_mode() { assert!(PendingSequencerUpdates::::contains_key(15u128, Chain::Ethereum)); forward_to_block::(15); + + is_maintenance_mock.checkpoint(); + let is_maintenance_mock = MockMaintenanceStatusProviderApi::is_maintenance_context(); + is_maintenance_mock.expect().return_const(true); + forward_to_next_block::(); + forward_to_next_block::(); assert!(!PendingSequencerUpdates::::contains_key(15u128, Chain::Ethereum)); assert_event_emitted!(Event::L1ReadIgnoredBecauseOfMaintenanceMode { chain: consts::CHAIN, From 82a4c452391d61759848974c883cb82a37692ee2 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 21 Nov 2024 17:33:31 +0100 Subject: [PATCH 05/23] ut & benchmarks works --- pallets/rolldown/src/benchmarking.rs | 2 +- pallets/rolldown/src/lib.rs | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/pallets/rolldown/src/benchmarking.rs b/pallets/rolldown/src/benchmarking.rs index 1d4dd6227..1d8b9997f 100644 --- a/pallets/rolldown/src/benchmarking.rs +++ b/pallets/rolldown/src/benchmarking.rs @@ -981,7 +981,7 @@ mod benchmarks { max_id: 1u128, update_size: 1u128, sequencer: sequencer_account.clone(), - update_hash: H256::zero(), + update_hash, }; PendingSequencerUpdates::::insert(1u128, chain, metadata); diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index 98cbb07d3..cafffe61d 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -202,14 +202,12 @@ pub mod pallet { fn on_idle(now: BlockNumberFor, mut remaining_weight: Weight) -> Weight { let mut used_weight = Weight::default(); - println!("here1"); if T::MaintenanceStatusProvider::is_maintenance() { return used_weight; } let load_next_update_from_execution_queue_weight = T::DbWeight::get().reads_writes(3, 1); if remaining_weight.ref_time() > load_next_update_from_execution_queue_weight.ref_time() { - println!("here2"); used_weight += load_next_update_from_execution_queue_weight; remaining_weight -= load_next_update_from_execution_queue_weight; if Self::load_next_update_from_execution_queue(){ @@ -1153,8 +1151,6 @@ impl Pallet { } // FIXME: remove update from storage somwhere else - println!("HELLLLO WORLDDD!!!!!!!!!!!!!!!!"); - println!("{}", block_number); let _ = PendingSequencerUpdates::::clear_prefix( block_number, u32::MAX, @@ -1212,7 +1208,6 @@ impl Pallet { // weight for deposit_event total_weight = total_weight.saturating_add(T::DbWeight::get().reads_writes(2, 3)); - println!("8888888888888888888888888888888888888888"); LastProcessedRequestOnL2::::insert(l1, request.id()); // weight for LastProcessedRequestOnL2 total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); @@ -1249,7 +1244,6 @@ impl Pallet { break; }, (Some((scheduled_at, l1, hash, _)), _, _) => { - println!("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); if let Some(update) = PendingSequencerUpdateContent::::get(hash){ for req in update .into_requests() @@ -1260,7 +1254,6 @@ impl Pallet { .take(limit.saturated_into()) { if let Some(request) = req { - println!("YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"); let weight = Self::process_single_request(l1, request); limit -= 1; } else { @@ -1300,7 +1293,6 @@ impl Pallet { id.saturating_inc(); *id }); - println!("scheduled at {}", id); let size = metadata.max_id.saturating_sub(metadata.min_id).saturating_add(1); UpdatesExecutionQueue::::insert(id, (now, chain, metadata.update_hash, size)); } From 0a56bd87d0c2c30d2594c3248a3946ae43b9d39a Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Nov 2024 08:29:39 +0100 Subject: [PATCH 06/23] allign tests --- pallets/rolldown/src/benchmarking.rs | 76 +++++------ pallets/rolldown/src/lib.rs | 190 +++++++++++++-------------- pallets/rolldown/src/messages/mod.rs | 2 +- pallets/rolldown/src/tests.rs | 68 ++++------ 4 files changed, 158 insertions(+), 178 deletions(-) diff --git a/pallets/rolldown/src/benchmarking.rs b/pallets/rolldown/src/benchmarking.rs index 1d8b9997f..24f314c77 100644 --- a/pallets/rolldown/src/benchmarking.rs +++ b/pallets/rolldown/src/benchmarking.rs @@ -353,13 +353,13 @@ mod benchmarks { .build(); let update_hash = update.abi_encode_hash(); - let metadata = UpdateMetadata { - min_id: 0u128, - max_id: 0u128, - update_size: 0u128, - sequencer: SEQUENCER_ACCOUNT, - update_hash, - }; + let metadata = UpdateMetadata { + min_id: 0u128, + max_id: 0u128, + update_size: 0u128, + sequencer: SEQUENCER_ACCOUNT, + update_hash, + }; >::set_block_number(1u32.into()); let dispute_period_end = >::block_number().saturated_into::() + @@ -490,19 +490,15 @@ mod benchmarks { let update_hash = H256::default(); let sequencer_account: T::AccountId = SEQUENCER_ACCOUNT.into(); - let metadata = UpdateMetadata { - min_id: 1u128, - max_id: 1u128, - update_size: 1u128, - sequencer: sequencer_account.clone(), - update_hash: H256::zero(), - }; - - PendingSequencerUpdates::::insert( - DUMMY_REQUEST_ID, - l1_chain, - metadata, - ); + let metadata = UpdateMetadata { + min_id: 1u128, + max_id: 1u128, + update_size: 1u128, + sequencer: sequencer_account.clone(), + update_hash: H256::zero(), + }; + + PendingSequencerUpdates::::insert(DUMMY_REQUEST_ID, l1_chain, metadata); PendingSequencerUpdateContent::::insert(update_hash, update); @@ -537,21 +533,16 @@ mod benchmarks { get_chain_and_address_for_asset_id::(TOKEN_ID.into())?; let l1_chain: ::ChainId = l1_aset_chain.into(); - let metadata = UpdateMetadata:: { - min_id: 1u128, - max_id: 1u128, - update_size: 1u128, - sequencer: T::AddressConverter::convert(SEQUENCER_ACCOUNT), - update_hash: H256::zero(), - }; - + let metadata = UpdateMetadata:: { + min_id: 1u128, + max_id: 1u128, + update_size: 1u128, + sequencer: T::AddressConverter::convert(SEQUENCER_ACCOUNT), + update_hash: H256::zero(), + }; let sequencer_account: T::AccountId = SEQUENCER_ACCOUNT.into(); - PendingSequencerUpdates::::insert( - DUMMY_REQUEST_ID, - l1_chain, - metadata, - ); + PendingSequencerUpdates::::insert(DUMMY_REQUEST_ID, l1_chain, metadata); assert!( T::SequencerStakingProvider::is_selected_sequencer(l1_chain, &SEQUENCER_ACCOUNT.into()), @@ -976,13 +967,13 @@ mod benchmarks { H256::from(hex!("1111111111111111111111111111111111111111111111111111111111111111")); let sequencer_account: T::AccountId = SEQUENCER_ACCOUNT.into(); - let metadata = UpdateMetadata { - min_id: 1u128, - max_id: 1u128, - update_size: 1u128, - sequencer: sequencer_account.clone(), - update_hash, - }; + let metadata = UpdateMetadata { + min_id: 1u128, + max_id: 1u128, + update_size: 1u128, + sequencer: sequencer_account.clone(), + update_hash, + }; PendingSequencerUpdates::::insert(1u128, chain, metadata); assert_eq!(LastScheduledUpdateIdInExecutionQueue::::get(), 0u128); @@ -1067,7 +1058,10 @@ mod benchmarks { H256::from(hex!("1111111111111111111111111111111111111111111111111111111111111111")); UpdatesExecutionQueueNextId::::put(execution_id); - UpdatesExecutionQueue::::insert(execution_id, (scheduled_at, l1_chain, update_hash, 10u128)); + UpdatesExecutionQueue::::insert( + execution_id, + (scheduled_at, l1_chain, update_hash, 10u128), + ); LastProcessedRequestOnL2::::insert(l1_chain, 0u128); let update = L1UpdateBuilder::default() diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index cafffe61d..606b56473 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -61,7 +61,6 @@ macro_rules! log { }; } - #[derive(Debug, PartialEq)] pub struct EthereumAddressConverter(sp_std::marker::PhantomData); @@ -143,7 +142,7 @@ pub use pallet::*; fn get_read_scalling_factor(size: usize) -> u128 { const BASE_READ_COST: u128 = 25; - let approximated_cost = match size{ + let approximated_cost = match size { 0..=50 => 25u128, 51..=100 => 45u128, 101..=500 => 210u128, @@ -154,11 +153,10 @@ fn get_read_scalling_factor(size: usize) -> u128 { approximated_cost.saturating_div(BASE_READ_COST).saturating_add(1u128) } - fn get_write_scalling_factor(size: usize) -> u128 { const BASE_WRITE_COST: u128 = 100; - let approximated_cost = match size{ + let approximated_cost = match size { 0..=50 => 25u128, 51..=100 => 150u128, 101..=500 => 700u128, @@ -180,7 +178,6 @@ pub mod pallet { #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(PhantomData); - #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(now: BlockNumberFor) -> Weight { @@ -188,14 +185,16 @@ pub mod pallet { if T::MaintenanceStatusProvider::is_maintenance() { LastMaintananceMode::::put(now.saturated_into::()); total_weight += T::DbWeight::get().writes(1); - }else{ + } else { Self::maybe_create_batch(now); - } + } - Self::schedule_request_for_execution_if_dispute_period_has_passsed(now); - // total_weight = - // total_weight.saturating_add(::WeightInfo::maybe_create_batch()); - // total_weight = total_weight.saturating_add(::WeightInfo::schedule_request_for_execution_if_dispute_period_has_passsed()); + Self::schedule_request_for_execution_if_dispute_period_has_passsed(now); + + Self::load_next_update_from_execution_queue(); + // total_weight = + // total_weight.saturating_add(::WeightInfo::maybe_create_batch()); + // total_weight = total_weight.saturating_add(::WeightInfo::schedule_request_for_execution_if_dispute_period_has_passsed()); total_weight } @@ -206,32 +205,34 @@ pub mod pallet { return used_weight; } - let load_next_update_from_execution_queue_weight = T::DbWeight::get().reads_writes(3, 1); - if remaining_weight.ref_time() > load_next_update_from_execution_queue_weight.ref_time() { - used_weight += load_next_update_from_execution_queue_weight; - remaining_weight -= load_next_update_from_execution_queue_weight; - if Self::load_next_update_from_execution_queue(){ - return used_weight; - }else{ - Self::execute_requests_from_execute_queue(now); - // Self::get_current_update_size_from_execution_queue(); - } - } - - // let get_update_size_weight = T::DbWeight::get().reads(2); - // if remaining_weight.ref_time() > get_update_size_weight.ref_time() { - // used_weight += get_update_size_weight; - // remaining_weight -= get_update_size_weight; - // println!("here3"); - // if let Some(size) = Self::get_current_update_size_from_execution_queue() { - // - // println!("here4"); - // // if remaining_weight >= T::DbWeight::get().reads(1) { - // Self::execute_requests_from_execute_queue(now); - // // used_weight += T::DbWeight::get().reads(1); - // // } - // } - // } + let load_next_update_from_execution_queue_weight = + T::DbWeight::get().reads_writes(3, 1); + if remaining_weight.ref_time() > load_next_update_from_execution_queue_weight.ref_time() + { + used_weight += load_next_update_from_execution_queue_weight; + remaining_weight -= load_next_update_from_execution_queue_weight; + // if Self::load_next_update_from_execution_queue(){ + // return used_weight; + // }else{ + Self::execute_requests_from_execute_queue(now); + // Self::get_current_update_size_from_execution_queue(); + // } + } + + // let get_update_size_weight = T::DbWeight::get().reads(2); + // if remaining_weight.ref_time() > get_update_size_weight.ref_time() { + // used_weight += get_update_size_weight; + // remaining_weight -= get_update_size_weight; + // println!("here3"); + // if let Some(size) = Self::get_current_update_size_from_execution_queue() { + // + // println!("here4"); + // // if remaining_weight >= T::DbWeight::get().reads(1) { + // Self::execute_requests_from_execute_queue(now); + // // used_weight += T::DbWeight::get().reads(1); + // // } + // } + // } // used_weight += get_update_size_weight; // if let Some(size) = Self::get_current_update_size_from_execution_queue() { // println!("here2222222222222222222222222222222222222222"); @@ -255,10 +256,8 @@ pub mod pallet { pub cancel_rights: u128, } - #[derive( - Eq, PartialEq, RuntimeDebug, Clone, Encode, Decode, MaxEncodedLen, TypeInfo - )] - pub struct UpdateMetadata{ + #[derive(Eq, PartialEq, RuntimeDebug, Clone, Encode, Decode, MaxEncodedLen, TypeInfo)] + pub struct UpdateMetadata { pub max_id: u128, pub min_id: u128, pub update_size: u128, @@ -637,7 +636,8 @@ pub mod pallet { Error::::BlockedByMaintenanceMode ); - let metadata = Self::validate_l1_update(chain, &update, T::AddressConverter::convert([0u8;20]))?; + let metadata = + Self::validate_l1_update(chain, &update, T::AddressConverter::convert([0u8; 20]))?; let now = >::block_number(); let update_size = update.get_requests_count(); @@ -670,9 +670,8 @@ pub mod pallet { Ok::<_, Error>(()) })?; - let metadata = - PendingSequencerUpdates::::take(requests_to_cancel, chain) - .ok_or(Error::::RequestDoesNotExist)?; + let metadata = PendingSequencerUpdates::::take(requests_to_cancel, chain) + .ok_or(Error::::RequestDoesNotExist)?; let submitter = metadata.sequencer; let request_hash = metadata.update_hash; @@ -820,9 +819,8 @@ pub mod pallet { Error::::BlockedByMaintenanceMode ); - let metadata = - PendingSequencerUpdates::::take(requests_to_cancel, chain) - .ok_or(Error::::RequestDoesNotExist)?; + let metadata = PendingSequencerUpdates::::take(requests_to_cancel, chain) + .ok_or(Error::::RequestDoesNotExist)?; let submitter = metadata.sequencer; let hash = metadata.update_hash; @@ -1042,9 +1040,8 @@ impl Pallet { ) -> Option { let pending_requests_to_process = PendingSequencerUpdates::::get(request_id, chain); if let Some(metadata) = pending_requests_to_process { - if let Some(l1_update) = PendingSequencerUpdateContent::::get(metadata.update_hash) { - let calculated_hash = Self::calculate_hash_of_sequencer_update(&l1_update); + let calculated_hash = l1_update.abi_encode_hash(); Some(hash == calculated_hash) } else { None @@ -1117,9 +1114,7 @@ impl Pallet { fn schedule_request_for_execution_if_dispute_period_has_passsed(now: BlockNumberFor) { let block_number = >::block_number().saturated_into::(); - for (l1, metadata) in - PendingSequencerUpdates::::iter_prefix(block_number) - { + for (l1, metadata) in PendingSequencerUpdates::::iter_prefix(block_number) { let sequencer = metadata.sequencer.clone(); let l1_read_hash = metadata.update_hash.clone(); let update_size = metadata.update_size.clone(); @@ -1133,8 +1128,11 @@ impl Pallet { } let update_creation_block = block_number.saturating_sub(Self::get_dispute_period()); + println!("hello world"); + println!("{}", update_creation_block); + match LastMaintananceMode::::get() { - Some(last_maintanance_mode) if update_creation_block < last_maintanance_mode => { + Some(last_maintanance_mode) if update_creation_block <= last_maintanance_mode => { Self::deposit_event(Event::L1ReadIgnoredBecauseOfMaintenanceMode { chain: l1, hash: l1_read_hash, @@ -1151,11 +1149,7 @@ impl Pallet { } // FIXME: remove update from storage somwhere else - let _ = PendingSequencerUpdates::::clear_prefix( - block_number, - u32::MAX, - None, - ); + let _ = PendingSequencerUpdates::::clear_prefix(block_number, u32::MAX, None); } fn process_single_request( @@ -1215,36 +1209,48 @@ impl Pallet { } fn has_next_update_to_execute() -> bool { - UpdatesExecutionQueue::::contains_key(UpdatesExecutionQueueNextId::::get().saturating_add(1)) - } + UpdatesExecutionQueue::::contains_key( + UpdatesExecutionQueueNextId::::get().saturating_add(1), + ) + } fn get_current_update_size_from_execution_queue() -> Option { - UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()).map(|(_, _, _, size)| size) - } + UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()) + .map(|(_, _, _, size)| size) + } fn load_next_update_from_execution_queue() -> bool { - let current_execution_id = UpdatesExecutionQueueNextId::::get(); - let next_execution_id = current_execution_id.saturating_add(1u128); - match (UpdatesExecutionQueue::::get(current_execution_id), UpdatesExecutionQueue::::get(next_execution_id)) { - (None, Some(_)) => { - UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); - true - }, - _ => false, - } - } + let current_execution_id = UpdatesExecutionQueueNextId::::get(); + let next_execution_id = current_execution_id.saturating_add(1u128); + match ( + UpdatesExecutionQueue::::get(current_execution_id), + UpdatesExecutionQueue::::get(next_execution_id), + ) { + (None, Some(_)) => { + UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); + true + }, + _ => false, + } + } fn execute_requests_from_execute_queue(now: BlockNumberFor) -> Weight { let mut limit = Self::get_max_requests_per_block(); while limit > 0 { - match (UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()), LastMaintananceMode::::get(), Self::has_next_update_to_execute()) { - (Some((scheduled_at, l1, hash, _)), Some(last_maintanance_mode), _) if scheduled_at.saturated_into::() <= last_maintanance_mode => { + match ( + UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()), + LastMaintananceMode::::get(), + Self::has_next_update_to_execute(), + ) { + (Some((scheduled_at, l1, hash, _)), Some(last_maintanance_mode), _) + if scheduled_at.saturated_into::() <= last_maintanance_mode => + { UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); break; }, (Some((scheduled_at, l1, hash, _)), _, _) => { - if let Some(update) = PendingSequencerUpdateContent::::get(hash){ + if let Some(update) = PendingSequencerUpdateContent::::get(hash) { for req in update .into_requests() .into_iter() @@ -1257,11 +1263,13 @@ impl Pallet { let weight = Self::process_single_request(l1, request); limit -= 1; } else { - UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); + UpdatesExecutionQueue::::remove( + UpdatesExecutionQueueNextId::::get(), + ); break; } } - }else { + } else { UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); } @@ -1276,7 +1284,7 @@ impl Pallet { // } _ => { break; - } + }, } } Default::default() @@ -1287,7 +1295,9 @@ impl Pallet { chain: ::ChainId, metadata: UpdateMetadata, ) { - MaxAcceptedRequestIdOnl2::::mutate(chain, |cnt| *cnt = sp_std::cmp::max(*cnt, metadata.max_id)); + MaxAcceptedRequestIdOnl2::::mutate(chain, |cnt| { + *cnt = sp_std::cmp::max(*cnt, metadata.max_id) + }); let id = LastScheduledUpdateIdInExecutionQueue::::mutate(|id| { id.saturating_inc(); @@ -1382,12 +1392,6 @@ impl Pallet { Ok(()) } - fn calculate_hash_of_sequencer_update(update: &messages::L1Update) -> H256 { - let update: messages::eth_abi::L1Update = update.clone().into(); - let hash: [u8; 32] = keccak_256(&update.abi_encode()[..]).into(); - H256::from(hash) - } - fn handle_sequencer_deactivation( chain: ::ChainId, deactivated_sequencers: BTreeSet, @@ -1421,7 +1425,7 @@ impl Pallet { pub fn validate_l1_update( l1: ::ChainId, update: &messages::L1Update, - sequencer: T::AccountId + sequencer: T::AccountId, ) -> Result, Error> { ensure!( !update.pendingDeposits.is_empty() || !update.pendingCancelResolutions.is_empty(), @@ -1511,8 +1515,9 @@ impl Pallet { Ok(UpdateMetadata { sequencer, - update_hash: Self::calculate_hash_of_sequencer_update(&update), - update_size: update.pendingDeposits.len() as u128 + update.pendingCancelResolutions.len() as u128, + update_hash: update.abi_encode_hash(), + update_size: update.pendingDeposits.len() as u128 + + update.pendingCancelResolutions.len() as u128, max_id: lowest_id, min_id: last_id, }) @@ -1561,12 +1566,7 @@ impl Pallet { Error::::MultipleUpdatesInSingleBlock ); - - PendingSequencerUpdates::::insert( - dispute_period_end, - l1, - metadata.clone() - ); + PendingSequencerUpdates::::insert(dispute_period_end, l1, metadata.clone()); PendingSequencerUpdateContent::::insert(metadata.update_hash, read.clone()); diff --git a/pallets/rolldown/src/messages/mod.rs b/pallets/rolldown/src/messages/mod.rs index de21b8b72..cc76ba7a2 100644 --- a/pallets/rolldown/src/messages/mod.rs +++ b/pallets/rolldown/src/messages/mod.rs @@ -246,7 +246,7 @@ pub struct L1Update { pub pendingCancelResolutions: Vec, } -impl L1Update{ +impl L1Update { pub fn get_requests_count(&self) -> u128 { self.pendingDeposits.len() as u128 + self.pendingCancelResolutions.len() as u128 } diff --git a/pallets/rolldown/src/tests.rs b/pallets/rolldown/src/tests.rs index 39b8c8b9e..dddbd9926 100644 --- a/pallets/rolldown/src/tests.rs +++ b/pallets/rolldown/src/tests.rs @@ -149,10 +149,8 @@ fn l2_counter_updates_when_requests_are_processed() { Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(BOB), update2).unwrap(); forward_to_block::(15); - forward_to_next_block::(); assert_eq!(Rolldown::get_last_processed_request_on_l2(Chain::Ethereum), 1u128.into()); - forward_to_next_block::(); forward_to_next_block::(); assert_eq!(Rolldown::get_last_processed_request_on_l2(Chain::Ethereum), 2u128.into()); }); @@ -840,7 +838,6 @@ fn execute_a_lot_of_requests_in_following_blocks() { assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); assert_eq!(UpdatesExecutionQueueNextId::::get(), 0u128); - forward_to_block::(15); forward_to_next_block::(); assert_eq!( LastProcessedRequestOnL2::::get(Chain::Ethereum), @@ -881,10 +878,8 @@ fn ignore_duplicated_requests_when_already_executed() { assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); forward_to_block::(15); - forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 5u128.into()); - forward_to_next_block::(); forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 6u128.into()); }); @@ -911,13 +906,11 @@ fn process_l1_reads_in_order() { assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); forward_to_block::(15); - forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 10u128.into()); forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 11u128.into()); - forward_to_next_block::(); forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 20u128.into()); }); @@ -1029,13 +1022,6 @@ fn accept_consecutive_update_split_into_two() { assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0); forward_to_block::(15); - let mut expected_updates = L2Requests::::iter_prefix(Chain::Ethereum) - .map(|(k, _)| k.id) - .collect::>(); - expected_updates.sort(); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0); - - forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 10); forward_to_next_block::(); @@ -1045,7 +1031,7 @@ fn accept_consecutive_update_split_into_two() { #[test] #[serial] -fn execute_two_consecutive_incremental_reqeusts() { +fn execute_two_consecutive_incremental_requests() { ExtBuilder::new() .issue(ALICE, ETH_TOKEN_ADDRESS_MGX, 0u128) .execute_with_default_mocks(|| { @@ -1078,10 +1064,8 @@ fn execute_two_consecutive_incremental_reqeusts() { assert_eq!(TokensOf::::free_balance(ETH_TOKEN_ADDRESS_MGX, &CHARLIE), 0_u128); forward_to_block::(15); - forward_to_next_block::(); assert_eq!(TokensOf::::free_balance(ETH_TOKEN_ADDRESS_MGX, &CHARLIE), MILLION); - forward_to_next_block::(); forward_to_next_block::(); assert_eq!( TokensOf::::free_balance(ETH_TOKEN_ADDRESS_MGX, &CHARLIE), @@ -2664,7 +2648,6 @@ fn test_reqeust_scheduled_for_execution_are_not_execute_in_the_same_block() { assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); forward_to_block::(15); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); assert_event_emitted!(Event::L1ReadScheduledForExecution { chain: consts::CHAIN, hash: H256::from(hex!( @@ -2672,7 +2655,7 @@ fn test_reqeust_scheduled_for_execution_are_not_execute_in_the_same_block() { )), }); - forward_to_block::(16); + forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 1u128.into()); assert_event_emitted!(Event::RequestProcessedOnL2 { chain: consts::CHAIN, @@ -2694,32 +2677,31 @@ fn test_sequencer_updates_that_went_though_dispute_period_are_not_executed_in_ma forward_to_block::(10); let deposit_update = L1UpdateBuilder::default() - .with_requests(vec![L1UpdateRequest::Deposit(messages::Deposit::default())]) + .with_requests(vec![L1UpdateRequest::Deposit(messages::Deposit::default()); 11]) .build(); + let update_hash = deposit_update.abi_encode_hash(); Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), deposit_update) .unwrap(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); forward_to_block::(15); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 10u128.into()); assert_event_emitted!(Event::L1ReadScheduledForExecution { chain: consts::CHAIN, - hash: H256::from(hex!( - "75207958ce929568193284a176e012a8cf5058dc19d73dafee61a419eb667398" - )), + hash: update_hash, }); - is_maintenance_mock.checkpoint(); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 10u128.into()); + is_maintenance_mock.checkpoint(); let is_maintenance_mock = MockMaintenanceStatusProviderApi::is_maintenance_context(); is_maintenance_mock.expect().return_const(true); + forward_to_block::(20); - forward_to_block::(50); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); is_maintenance_mock.checkpoint(); - let is_maintenance_mock = MockMaintenanceStatusProviderApi::is_maintenance_context(); is_maintenance_mock.expect().return_const(false); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); + forward_to_block::(100); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 10u128.into()); }) } @@ -2762,7 +2744,7 @@ fn test_sequencer_updates_that_went_though_dispute_period_are_not_scheduled_for_ #[test] #[serial] -fn test_sequencer_can_submit_same_update_again_after_maintenance_mode() { +fn test_sequencer_can_submit_update_with_remaining_elements() { ExtBuilder::new() .issue(ALICE, ETH_TOKEN_ADDRESS_MGX, MILLION) .issue(BOB, ETH_TOKEN_ADDRESS_MGX, MILLION) @@ -2771,22 +2753,25 @@ fn test_sequencer_can_submit_same_update_again_after_maintenance_mode() { is_maintenance_mock.expect().return_const(false); forward_to_block::(10); + let requests = vec![L1UpdateRequest::Deposit(messages::Deposit::default()); 11]; let deposit_update = L1UpdateBuilder::default() - .with_requests(vec![L1UpdateRequest::Deposit(messages::Deposit::default())]) + .with_requests(requests.clone()) .build(); - Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), deposit_update) - .unwrap(); + Rolldown::update_l2_from_l1_unsafe( + RuntimeOrigin::signed(ALICE), + deposit_update.clone(), + ) + .unwrap(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); forward_to_block::(15); assert_event_emitted!(Event::L1ReadScheduledForExecution { chain: consts::CHAIN, - hash: H256::from(hex!( - "75207958ce929568193284a176e012a8cf5058dc19d73dafee61a419eb667398" - )), + hash: deposit_update.abi_encode_hash() }); - is_maintenance_mock.checkpoint(); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 10u128.into()); + is_maintenance_mock.checkpoint(); let is_maintenance_mock = MockMaintenanceStatusProviderApi::is_maintenance_context(); is_maintenance_mock.expect().return_const(true); @@ -2798,13 +2783,14 @@ fn test_sequencer_can_submit_same_update_again_after_maintenance_mode() { forward_to_block::(20); let deposit_update = L1UpdateBuilder::default() - .with_requests(vec![L1UpdateRequest::Deposit(messages::Deposit::default())]) + .with_requests(requests.into_iter().skip(10).collect()) + .with_offset(11) .build(); Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), deposit_update) .unwrap(); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); - forward_to_block::(26); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 1u128.into()); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 10u128.into()); + forward_to_block::(25); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 11u128.into()); }) } From ae464d01acf006f525ebcb0901a0585c6bc7173c Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Nov 2024 09:59:34 +0100 Subject: [PATCH 07/23] simplify --- pallets/rolldown/src/benchmarking.rs | 76 ++++++------------- pallets/rolldown/src/lib.rs | 72 +++--------------- pallets/rolldown/src/tests.rs | 6 +- pallets/rolldown/src/weights.rs | 30 ++++---- rollup/runtime/src/weights/pallet_rolldown.rs | 43 ++++------- 5 files changed, 71 insertions(+), 156 deletions(-) diff --git a/pallets/rolldown/src/benchmarking.rs b/pallets/rolldown/src/benchmarking.rs index 24f314c77..4dc8cc5eb 100644 --- a/pallets/rolldown/src/benchmarking.rs +++ b/pallets/rolldown/src/benchmarking.rs @@ -904,55 +904,30 @@ mod benchmarks { Ok(()) } - // #[benchmark] - // fn schedule_requests(x: Linear<2, 200>) -> Result<(), BenchmarkError> { - // let (l1_aset_chain, l1_asset_address) = - // get_chain_and_address_for_asset_id::(TOKEN_ID.into())?; - // let l1_chain: ::ChainId = l1_aset_chain.into(); - // - // let x_deposits: usize = (x as usize) / 2; - // let x_cancel_resolution: usize = (x as usize) - x_deposits; - // let mut update = L1UpdateBuilder::default() - // .with_requests( - // [ - // vec![L1UpdateRequest::Deposit(Default::default()); x_deposits], - // vec![ - // L1UpdateRequest::CancelResolution(Default::default()); - // x_cancel_resolution - // ], - // ] - // .concat(), - // ) - // .build(); - // - // assert!( - // MaxAcceptedRequestIdOnl2::::get(l1_chain).is_zero(), - // "BEFORE MaxAcceptedRequestIdOnl2 {:?} chain should be zero", - // l1_chain - // ); - // assert!( - // UpdatesExecutionQueue::::get(FIRST_SCHEDULED_UPDATE_ID).is_none(), - // "BEFORE UpdatesExecutionQueue {:?} scheduled update id should be none", - // FIRST_SCHEDULED_UPDATE_ID - // ); - // - // #[block] - // { - // Rolldown::::schedule_requests(BlockNumberFor::::default(), l1_chain, update); - // } - // - // assert!( - // !MaxAcceptedRequestIdOnl2::::get(l1_chain).is_zero(), - // "AFTER MaxAcceptedRequestIdOnl2 {:?} chain should NOT be zero", - // l1_chain - // ); - // assert!( - // UpdatesExecutionQueue::::get(FIRST_SCHEDULED_UPDATE_ID).is_some(), - // "AFTER UpdatesExecutionQueue {:?} scheduled update id should be some", - // FIRST_SCHEDULED_UPDATE_ID - // ); - // Ok(()) - // } + #[benchmark] + fn load_next_update_from_execution_queue() -> Result<(), BenchmarkError> { + let current_execution_id = 1u128; + let next_execution_id = 2u128; + let scheduled_at: BlockNumberFor = 19u32.into(); + let (l1_aset_chain, _) = get_chain_and_address_for_asset_id::(TOKEN_ID.into())?; + let l1_chain: ::ChainId = l1_aset_chain.into(); + + UpdatesExecutionQueue::::remove(current_execution_id); + UpdatesExecutionQueue::::insert( + next_execution_id, + (scheduled_at, l1_chain, H256::zero(), 10u128), + ); + UpdatesExecutionQueueNextId::::put(current_execution_id); + + #[block] + { + Rolldown::::load_next_update_from_execution_queue(); + } + + assert_eq!(UpdatesExecutionQueueNextId::::get(), next_execution_id); + + Ok(()) + } #[benchmark] fn schedule_request_for_execution_if_dispute_period_has_passsed() -> Result<(), BenchmarkError> @@ -1071,7 +1046,7 @@ mod benchmarks { #[block] { - Rolldown::::execute_requests_from_execute_queue(21u32.into()); + Rolldown::::execute_requests_from_execute_queue(); } UpdatesExecutionQueue::::get(execution_id).expect("update partially executed"); @@ -1079,7 +1054,6 @@ mod benchmarks { LastProcessedRequestOnL2::::get(l1_chain), ::RequestsPerBlock::get() ); - Ok(()) } } diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index 606b56473..9be6cb413 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -182,6 +182,7 @@ pub mod pallet { impl Hooks> for Pallet { fn on_initialize(now: BlockNumberFor) -> Weight { let mut total_weight: Weight = T::DbWeight::get().reads(1); + if T::MaintenanceStatusProvider::is_maintenance() { LastMaintananceMode::::put(now.saturated_into::()); total_weight += T::DbWeight::get().writes(1); @@ -190,11 +191,7 @@ pub mod pallet { } Self::schedule_request_for_execution_if_dispute_period_has_passsed(now); - Self::load_next_update_from_execution_queue(); - // total_weight = - // total_weight.saturating_add(::WeightInfo::maybe_create_batch()); - // total_weight = total_weight.saturating_add(::WeightInfo::schedule_request_for_execution_if_dispute_period_has_passsed()); total_weight } @@ -214,36 +211,11 @@ pub mod pallet { // if Self::load_next_update_from_execution_queue(){ // return used_weight; // }else{ - Self::execute_requests_from_execute_queue(now); + Self::execute_requests_from_execute_queue(); // Self::get_current_update_size_from_execution_queue(); // } } - // let get_update_size_weight = T::DbWeight::get().reads(2); - // if remaining_weight.ref_time() > get_update_size_weight.ref_time() { - // used_weight += get_update_size_weight; - // remaining_weight -= get_update_size_weight; - // println!("here3"); - // if let Some(size) = Self::get_current_update_size_from_execution_queue() { - // - // println!("here4"); - // // if remaining_weight >= T::DbWeight::get().reads(1) { - // Self::execute_requests_from_execute_queue(now); - // // used_weight += T::DbWeight::get().reads(1); - // // } - // } - // } - // used_weight += get_update_size_weight; - // if let Some(size) = Self::get_current_update_size_from_execution_queue() { - // println!("here2222222222222222222222222222222222222222"); - // Self::execute_requests_from_execute_queue(now); - // return used_weight; - // }else{ - // println!("here1111111111111111111111111111111111111111"); - // return used_weight; - // } - // } - return used_weight; } } @@ -1128,8 +1100,6 @@ impl Pallet { } let update_creation_block = block_number.saturating_sub(Self::get_dispute_period()); - println!("hello world"); - println!("{}", update_creation_block); match LastMaintananceMode::::get() { Some(last_maintanance_mode) if update_creation_block <= last_maintanance_mode => { @@ -1154,13 +1124,14 @@ impl Pallet { fn process_single_request( l1: ::ChainId, - request: messages::L1UpdateRequest, + request: &messages::L1UpdateRequest, ) -> Weight { let mut total_weight: Weight = Weight::default(); // weight for LastProcessedRequestOnL2 total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); - if request.id() <= LastProcessedRequestOnL2::::get(l1) { + let request_id = request.id(); + if request_id <= LastProcessedRequestOnL2::::get(l1) { return total_weight } @@ -1193,11 +1164,7 @@ impl Pallet { }, }; - Pallet::::deposit_event(Event::RequestProcessedOnL2 { - chain: l1, - request_id: request.id(), - status, - }); + Pallet::::deposit_event(Event::RequestProcessedOnL2 { chain: l1, request_id, status }); // Not sure about this - not sure exactly what is cached and how across extrinsics (/hooks) // weight for deposit_event total_weight = total_weight.saturating_add(T::DbWeight::get().reads_writes(2, 3)); @@ -1208,12 +1175,6 @@ impl Pallet { total_weight } - fn has_next_update_to_execute() -> bool { - UpdatesExecutionQueue::::contains_key( - UpdatesExecutionQueueNextId::::get().saturating_add(1), - ) - } - fn get_current_update_size_from_execution_queue() -> Option { UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()) .map(|(_, _, _, size)| size) @@ -1234,29 +1195,28 @@ impl Pallet { } } - fn execute_requests_from_execute_queue(now: BlockNumberFor) -> Weight { + fn execute_requests_from_execute_queue() -> Weight { let mut limit = Self::get_max_requests_per_block(); while limit > 0 { match ( UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()), LastMaintananceMode::::get(), - Self::has_next_update_to_execute(), ) { - (Some((scheduled_at, l1, hash, _)), Some(last_maintanance_mode), _) + (Some((scheduled_at, _, _, _)), Some(last_maintanance_mode)) if scheduled_at.saturated_into::() <= last_maintanance_mode => { UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); break; }, - (Some((scheduled_at, l1, hash, _)), _, _) => { + (Some((_, l1, hash, _)), _) => { if let Some(update) = PendingSequencerUpdateContent::::get(hash) { for req in update .into_requests() - .into_iter() + .iter() .filter(|request| request.id() > LastProcessedRequestOnL2::::get(l1)) - .map(|val| Some(val)) - .chain(sp_std::iter::repeat(None)) + .map(Some) + .chain(sp_std::iter::once(None)) .take(limit.saturated_into()) { if let Some(request) = req { @@ -1274,14 +1234,6 @@ impl Pallet { UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); } }, - // (None, _, true) => { - // if UpdatesExecutionQueue::::contains_key( - // UpdatesExecutionQueueNextId::::get().saturating_add(1), - // ) { - // UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); - // } - // break; - // } _ => { break; }, diff --git a/pallets/rolldown/src/tests.rs b/pallets/rolldown/src/tests.rs index dddbd9926..1d50b1439 100644 --- a/pallets/rolldown/src/tests.rs +++ b/pallets/rolldown/src/tests.rs @@ -2753,10 +2753,8 @@ fn test_sequencer_can_submit_update_with_remaining_elements() { is_maintenance_mock.expect().return_const(false); forward_to_block::(10); - let requests = vec![L1UpdateRequest::Deposit(messages::Deposit::default()); 11]; - let deposit_update = L1UpdateBuilder::default() - .with_requests(requests.clone()) - .build(); + let requests = vec![L1UpdateRequest::Deposit(messages::Deposit::default()); 11]; + let deposit_update = L1UpdateBuilder::default().with_requests(requests.clone()).build(); Rolldown::update_l2_from_l1_unsafe( RuntimeOrigin::signed(ALICE), deposit_update.clone(), diff --git a/pallets/rolldown/src/weights.rs b/pallets/rolldown/src/weights.rs index 098114150..6bbf88b7b 100644 --- a/pallets/rolldown/src/weights.rs +++ b/pallets/rolldown/src/weights.rs @@ -69,7 +69,22 @@ pub trait WeightInfo { fn ferry_deposit_unsafe() -> Weight; fn process_deposit() -> Weight; fn process_cancel_resolution() -> Weight; - fn schedule_requests(x: u32, ) -> Weight; + fn load_next_update_from_execution_queue() -> Weight{ + (Weight::from_parts(22_558_000, 0)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn schedule_request_for_execution_if_dispute_period_has_passsed() -> Weight{ + (Weight::from_parts(22_558_000, 0)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn maybe_create_batch() -> Weight{ + (Weight::from_parts(22_558_000, 0)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn execute_requests_from_execute_queue() -> Weight{ + (Weight::from_parts(22_558_000, 0)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } } // For backwards compatibility and tests @@ -319,17 +334,4 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(12 as u64)) .saturating_add(RocksDbWeight::get().writes(9 as u64)) } - // Storage: `Rolldown::MaxAcceptedRequestIdOnl2` (r:1 w:1) - // Proof: `Rolldown::MaxAcceptedRequestIdOnl2` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) - // Storage: `Rolldown::LastScheduledUpdateIdInExecutionQueue` (r:1 w:1) - // Proof: `Rolldown::LastScheduledUpdateIdInExecutionQueue` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - // Storage: `Rolldown::UpdatesExecutionQueue` (r:0 w:1) - // Proof: `Rolldown::UpdatesExecutionQueue` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn schedule_requests(x: u32, ) -> Weight { - (Weight::from_parts(8_898_848, 0)) - // Standard Error: 8_479 - .saturating_add((Weight::from_parts(299_825, 0)).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - } } diff --git a/rollup/runtime/src/weights/pallet_rolldown.rs b/rollup/runtime/src/weights/pallet_rolldown.rs index 8846e77f7..010d7f301 100644 --- a/rollup/runtime/src/weights/pallet_rolldown.rs +++ b/rollup/runtime/src/weights/pallet_rolldown.rs @@ -69,7 +69,22 @@ pub trait WeightInfo { fn ferry_deposit_unsafe() -> Weight; fn process_deposit() -> Weight; fn process_cancel_resolution() -> Weight; - fn schedule_requests(x: u32, ) -> Weight; + fn load_next_update_from_execution_queue() -> Weight{ + (Weight::from_parts(22_558_000, 0)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn schedule_request_for_execution_if_dispute_period_has_passsed() -> Weight{ + (Weight::from_parts(22_558_000, 0)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn maybe_create_batch() -> Weight{ + (Weight::from_parts(22_558_000, 0)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn execute_requests_from_execute_queue() -> Weight{ + (Weight::from_parts(22_558_000, 0)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } } /// Weights for pallet_rolldown using the Mangata node and recommended hardware. @@ -320,19 +335,6 @@ impl pallet_rolldown::WeightInfo for ModuleWeight { .saturating_add(T::DbWeight::get().reads(12 as u64)) .saturating_add(T::DbWeight::get().writes(9 as u64)) } - // Storage: `Rolldown::MaxAcceptedRequestIdOnl2` (r:1 w:1) - // Proof: `Rolldown::MaxAcceptedRequestIdOnl2` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) - // Storage: `Rolldown::LastScheduledUpdateIdInExecutionQueue` (r:1 w:1) - // Proof: `Rolldown::LastScheduledUpdateIdInExecutionQueue` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - // Storage: `Rolldown::UpdatesExecutionQueue` (r:0 w:1) - // Proof: `Rolldown::UpdatesExecutionQueue` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn schedule_requests(x: u32, ) -> Weight { - (Weight::from_parts(8_898_848, 0)) - // Standard Error: 8_479 - .saturating_add((Weight::from_parts(299_825, 0)).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } } // For backwards compatibility and tests @@ -582,17 +584,4 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(12 as u64)) .saturating_add(RocksDbWeight::get().writes(9 as u64)) } - // Storage: `Rolldown::MaxAcceptedRequestIdOnl2` (r:1 w:1) - // Proof: `Rolldown::MaxAcceptedRequestIdOnl2` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) - // Storage: `Rolldown::LastScheduledUpdateIdInExecutionQueue` (r:1 w:1) - // Proof: `Rolldown::LastScheduledUpdateIdInExecutionQueue` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - // Storage: `Rolldown::UpdatesExecutionQueue` (r:0 w:1) - // Proof: `Rolldown::UpdatesExecutionQueue` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn schedule_requests(x: u32, ) -> Weight { - (Weight::from_parts(8_898_848, 0)) - // Standard Error: 8_479 - .saturating_add((Weight::from_parts(299_825, 0)).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - } } From c430e37dfbc74d091890932b1643970c70d65a34 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Nov 2024 14:35:01 +0100 Subject: [PATCH 08/23] on_idle hook --- pallets/rolldown/src/benchmarking.rs | 6 +- pallets/rolldown/src/lib.rs | 157 ++++++++++++--------------- 2 files changed, 74 insertions(+), 89 deletions(-) diff --git a/pallets/rolldown/src/benchmarking.rs b/pallets/rolldown/src/benchmarking.rs index 4dc8cc5eb..71437ffcd 100644 --- a/pallets/rolldown/src/benchmarking.rs +++ b/pallets/rolldown/src/benchmarking.rs @@ -1020,7 +1020,7 @@ mod benchmarks { } #[benchmark] - fn execute_requests_from_execute_queue() -> Result<(), BenchmarkError> { + fn execute_empty_request_from_execute_queue() -> Result<(), BenchmarkError> { let (l1_aset_chain, l1_asset_address) = get_chain_and_address_for_asset_id::(TOKEN_ID.into())?; let l1_chain: ::ChainId = l1_aset_chain.into(); @@ -1039,9 +1039,7 @@ mod benchmarks { ); LastProcessedRequestOnL2::::insert(l1_chain, 0u128); - let update = L1UpdateBuilder::default() - .with_requests(vec![L1UpdateRequest::Deposit(Default::default()); 10_000]) - .build(); + let update = L1UpdateBuilder::default().build(); PendingSequencerUpdateContent::::insert(update_hash, update); #[block] diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index 9be6cb413..9ea42fc68 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -6,6 +6,7 @@ pub mod messages; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +mod weight_utils; pub mod weights; pub use weights::WeightInfo; @@ -140,33 +141,6 @@ mod mock; use crate::messages::L1Update; pub use pallet::*; -fn get_read_scalling_factor(size: usize) -> u128 { - const BASE_READ_COST: u128 = 25; - let approximated_cost = match size { - 0..=50 => 25u128, - 51..=100 => 45u128, - 101..=500 => 210u128, - 501..=1000 => 400u128, - 1001..=5000 => 1800u128, - _ => 2800u128, - }; - approximated_cost.saturating_div(BASE_READ_COST).saturating_add(1u128) -} - -fn get_write_scalling_factor(size: usize) -> u128 { - const BASE_WRITE_COST: u128 = 100; - - let approximated_cost = match size { - 0..=50 => 25u128, - 51..=100 => 150u128, - 101..=500 => 700u128, - 501..=1000 => 1050u128, - 1001..=5000 => 5000u128, - _ => 9000u128, - }; - approximated_cost.saturating_div(BASE_WRITE_COST).saturating_add(1u128) -} - #[frame_support::pallet] pub mod pallet { @@ -188,35 +162,53 @@ pub mod pallet { total_weight += T::DbWeight::get().writes(1); } else { Self::maybe_create_batch(now); + total_weight += ::WeightInfo::maybe_create_batch(); } Self::schedule_request_for_execution_if_dispute_period_has_passsed(now); + total_weight += ::WeightInfo::schedule_request_for_execution_if_dispute_period_has_passsed(); + Self::load_next_update_from_execution_queue(); + total_weight += ::WeightInfo::load_next_update_from_execution_queue(); total_weight } fn on_idle(now: BlockNumberFor, mut remaining_weight: Weight) -> Weight { let mut used_weight = Weight::default(); - if T::MaintenanceStatusProvider::is_maintenance() { - return used_weight; - } + // already cached by using in on_initialize hook + if !T::MaintenanceStatusProvider::is_maintenance() { + let get_update_size_cost = T::DbWeight::get().reads(2); + + if remaining_weight.ref_time() < get_update_size_cost.ref_time() { + return used_weight; + } + + remaining_weight -= get_update_size_cost; + used_weight += get_update_size_cost; + + let update_size = + Self::get_current_update_size_from_execution_queue().unwrap_or(1u128); + + let mut cost_of_processing_requests = + ::WeightInfo::execute_requests_from_execute_queue(); + cost_of_processing_requests += + ::WeightInfo::process_cancel_resolution() + .saturating_mul(Self::get_max_requests_per_block().saturated_into()); + cost_of_processing_requests += T::DbWeight::get().reads(1).saturating_mul( + weight_utils::get_read_scalling_factor(update_size.saturated_into()) + .saturated_into(), + ); + + if remaining_weight.ref_time() < cost_of_processing_requests.ref_time() { + return used_weight; + } - let load_next_update_from_execution_queue_weight = - T::DbWeight::get().reads_writes(3, 1); - if remaining_weight.ref_time() > load_next_update_from_execution_queue_weight.ref_time() - { - used_weight += load_next_update_from_execution_queue_weight; - remaining_weight -= load_next_update_from_execution_queue_weight; - // if Self::load_next_update_from_execution_queue(){ - // return used_weight; - // }else{ Self::execute_requests_from_execute_queue(); - // Self::get_current_update_size_from_execution_queue(); - // } + used_weight += cost_of_processing_requests; + remaining_weight -= cost_of_processing_requests; } - - return used_weight; + used_weight } } @@ -459,6 +451,10 @@ pub mod pallet { deposit: messages::Deposit, deposit_hash: H256, }, + L1ReadExecuted { + chain: ::ChainId, + hash: H256, + }, } #[pallet::error] @@ -1118,7 +1114,6 @@ impl Pallet { } } - // FIXME: remove update from storage somwhere else let _ = PendingSequencerUpdates::::clear_prefix(block_number, u32::MAX, None); } @@ -1196,49 +1191,41 @@ impl Pallet { } fn execute_requests_from_execute_queue() -> Weight { - let mut limit = Self::get_max_requests_per_block(); - while limit > 0 { - match ( - UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()), - LastMaintananceMode::::get(), - ) { - (Some((scheduled_at, _, _, _)), Some(last_maintanance_mode)) - if scheduled_at.saturated_into::() <= last_maintanance_mode => - { - UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); - UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); - break; - }, - (Some((_, l1, hash, _)), _) => { - if let Some(update) = PendingSequencerUpdateContent::::get(hash) { - for req in update - .into_requests() - .iter() - .filter(|request| request.id() > LastProcessedRequestOnL2::::get(l1)) - .map(Some) - .chain(sp_std::iter::once(None)) - .take(limit.saturated_into()) - { - if let Some(request) = req { - let weight = Self::process_single_request(l1, request); - limit -= 1; - } else { - UpdatesExecutionQueue::::remove( - UpdatesExecutionQueueNextId::::get(), - ); - break; - } - } - } else { + let limit = Self::get_max_requests_per_block(); + match ( + UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()), + LastMaintananceMode::::get(), + ) { + (Some((scheduled_at, _, _, _)), Some(last_maintanance_mode)) + if scheduled_at.saturated_into::() <= last_maintanance_mode => + { + UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); + UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); + }, + (Some((_, l1, hash, _)), _) => { + if let Some(update) = PendingSequencerUpdateContent::::get(hash) { + let requests = update + .into_requests() + .into_iter() + .filter(|request| request.id() > LastProcessedRequestOnL2::::get(l1)) + .take(limit.saturated_into()) + .collect::>(); + + if requests.is_empty() { UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); - UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); + PendingSequencerUpdateContent::::remove(hash); + Self::deposit_event(Event::L1ReadExecuted { chain: l1, hash }); + } else { + for r in requests { + let weight = Self::process_single_request(l1, &r); + } } - }, - _ => { - break; - }, - } - } + } else { + PendingSequencerUpdateContent::::remove(hash); + } + }, + _ => {}, + }; Default::default() } From 506a071e9b95c5174c0f9f0a224a0a52f63564b6 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Nov 2024 14:37:34 +0100 Subject: [PATCH 09/23] on_idle hook --- pallets/rolldown/src/benchmarking.rs | 5 ++++- pallets/rolldown/src/weight_utils.rs | 30 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 pallets/rolldown/src/weight_utils.rs diff --git a/pallets/rolldown/src/benchmarking.rs b/pallets/rolldown/src/benchmarking.rs index 71437ffcd..18dd4d4bc 100644 --- a/pallets/rolldown/src/benchmarking.rs +++ b/pallets/rolldown/src/benchmarking.rs @@ -1020,7 +1020,10 @@ mod benchmarks { } #[benchmark] - fn execute_empty_request_from_execute_queue() -> Result<(), BenchmarkError> { + //NOTE: accounts only for the cost of processing the update + //assumes the update is emtpy, so cost of processing individual deposits/cancel resultions + //needs to be taken into account manually + fn execute_requests_from_execute_queue() -> Result<(), BenchmarkError> { let (l1_aset_chain, l1_asset_address) = get_chain_and_address_for_asset_id::(TOKEN_ID.into())?; let l1_chain: ::ChainId = l1_aset_chain.into(); diff --git a/pallets/rolldown/src/weight_utils.rs b/pallets/rolldown/src/weight_utils.rs new file mode 100644 index 000000000..44ca7d71f --- /dev/null +++ b/pallets/rolldown/src/weight_utils.rs @@ -0,0 +1,30 @@ +use sp_runtime::traits::Saturating; + +/// accounts for cost of reading huge L1Update from runtime storage (rocksdb) +pub const fn get_read_scalling_factor(size: usize) -> u128 { + const BASE_READ_COST: u128 = 25; + let approximated_cost = match size { + 0..=50 => 25u128, + 51..=100 => 45u128, + 101..=500 => 210u128, + 501..=1000 => 400u128, + 1001..=5000 => 1800u128, + _ => 2800u128, + }; + approximated_cost.saturating_div(BASE_READ_COST).saturating_add(1u128) +} + +/// accounts for cost of writing huge L1Update from runtime storage (rocksdb) +pub const fn get_write_scalling_factor(size: usize) -> u128 { + const BASE_WRITE_COST: u128 = 100; + + let approximated_cost = match size { + 0..=50 => 25u128, + 51..=100 => 150u128, + 101..=500 => 700u128, + 501..=1000 => 1050u128, + 1001..=5000 => 5000u128, + _ => 9000u128, + }; + approximated_cost.saturating_div(BASE_WRITE_COST).saturating_add(1u128) +} From 83b94b2c3817123d91af2a7efa7976cc701cec3e Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Nov 2024 14:48:18 +0100 Subject: [PATCH 10/23] properly account for corner case scenario --- pallets/rolldown/src/benchmarking.rs | 4 +++- pallets/rolldown/src/lib.rs | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pallets/rolldown/src/benchmarking.rs b/pallets/rolldown/src/benchmarking.rs index 18dd4d4bc..8479a82b3 100644 --- a/pallets/rolldown/src/benchmarking.rs +++ b/pallets/rolldown/src/benchmarking.rs @@ -1042,7 +1042,9 @@ mod benchmarks { ); LastProcessedRequestOnL2::::insert(l1_chain, 0u128); - let update = L1UpdateBuilder::default().build(); + let update = L1UpdateBuilder::default() + .with_requests(vec![L1UpdateRequest::Deposit(Default::default()); 10_000]) + .build(); PendingSequencerUpdateContent::::insert(update_hash, update); #[block] diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index 9ea42fc68..4f9b886b7 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -190,11 +190,20 @@ pub mod pallet { let update_size = Self::get_current_update_size_from_execution_queue().unwrap_or(1u128); + // NOTE: execute_requests_from_execute_queue accounts for overal cost of processing + // biggest expected update (with 10k requests) assuming that all of them are deposits + // to accounts for most expensive case now need to substract cost of processing deposits + // and add cost of processing cancels instead let mut cost_of_processing_requests = ::WeightInfo::execute_requests_from_execute_queue(); + cost_of_processing_requests += ::WeightInfo::process_cancel_resolution() .saturating_mul(Self::get_max_requests_per_block().saturated_into()); + cost_of_processing_requests -= ::WeightInfo::process_deposit() + .saturating_mul(Self::get_max_requests_per_block().saturated_into()); + + // account for huge read cost when reading huge update cost_of_processing_requests += T::DbWeight::get().reads(1).saturating_mul( weight_utils::get_read_scalling_factor(update_size.saturated_into()) .saturated_into(), @@ -1190,7 +1199,7 @@ impl Pallet { } } - fn execute_requests_from_execute_queue() -> Weight { + fn execute_requests_from_execute_queue() { let limit = Self::get_max_requests_per_block(); match ( UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()), @@ -1217,7 +1226,7 @@ impl Pallet { Self::deposit_event(Event::L1ReadExecuted { chain: l1, hash }); } else { for r in requests { - let weight = Self::process_single_request(l1, &r); + let _ = Self::process_single_request(l1, &r); } } } else { From 84f573ea98e0d95926e3554dac3bba081ade97ea Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Nov 2024 14:49:06 +0100 Subject: [PATCH 11/23] on_idle hook fixed --- pallets/rolldown/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index 4f9b886b7..742305b62 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -173,7 +173,7 @@ pub mod pallet { total_weight } - fn on_idle(now: BlockNumberFor, mut remaining_weight: Weight) -> Weight { + fn on_idle(_now: BlockNumberFor, mut remaining_weight: Weight) -> Weight { let mut used_weight = Weight::default(); // already cached by using in on_initialize hook From fa5acf569ae1b01af6b73f6c3e3910b63f29a96b Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Nov 2024 14:51:27 +0100 Subject: [PATCH 12/23] allign tests --- pallets/rolldown/src/tests.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pallets/rolldown/src/tests.rs b/pallets/rolldown/src/tests.rs index 1d50b1439..4a88da3ae 100644 --- a/pallets/rolldown/src/tests.rs +++ b/pallets/rolldown/src/tests.rs @@ -151,6 +151,7 @@ fn l2_counter_updates_when_requests_are_processed() { forward_to_block::(15); assert_eq!(Rolldown::get_last_processed_request_on_l2(Chain::Ethereum), 1u128.into()); + forward_to_next_block::(); forward_to_next_block::(); assert_eq!(Rolldown::get_last_processed_request_on_l2(Chain::Ethereum), 2u128.into()); }); @@ -880,6 +881,7 @@ fn ignore_duplicated_requests_when_already_executed() { forward_to_block::(15); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 5u128.into()); + forward_to_next_block::(); forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 6u128.into()); }); @@ -911,6 +913,7 @@ fn process_l1_reads_in_order() { forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 11u128.into()); + forward_to_next_block::(); forward_to_next_block::(); assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 20u128.into()); }); @@ -1066,6 +1069,7 @@ fn execute_two_consecutive_incremental_requests() { forward_to_block::(15); assert_eq!(TokensOf::::free_balance(ETH_TOKEN_ADDRESS_MGX, &CHARLIE), MILLION); + forward_to_next_block::(); forward_to_next_block::(); assert_eq!( TokensOf::::free_balance(ETH_TOKEN_ADDRESS_MGX, &CHARLIE), From 79b89af109f870a5ac1875d839175c1d9fc26197 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Nov 2024 14:54:14 +0100 Subject: [PATCH 13/23] remove outdated comment --- pallets/rolldown/src/benchmarking.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/pallets/rolldown/src/benchmarking.rs b/pallets/rolldown/src/benchmarking.rs index 8479a82b3..4dc8cc5eb 100644 --- a/pallets/rolldown/src/benchmarking.rs +++ b/pallets/rolldown/src/benchmarking.rs @@ -1020,9 +1020,6 @@ mod benchmarks { } #[benchmark] - //NOTE: accounts only for the cost of processing the update - //assumes the update is emtpy, so cost of processing individual deposits/cancel resultions - //needs to be taken into account manually fn execute_requests_from_execute_queue() -> Result<(), BenchmarkError> { let (l1_aset_chain, l1_asset_address) = get_chain_and_address_for_asset_id::(TOKEN_ID.into())?; From 44ef23e241702640ded3f00d1b851131094a54af Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Nov 2024 15:12:30 +0100 Subject: [PATCH 14/23] account for big reads/writes --- pallets/rolldown/src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index 742305b62..ff8ff5ba1 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -585,7 +585,9 @@ pub mod pallet { #[pallet::call] impl Pallet { #[pallet::call_index(0)] - #[pallet::weight(::WeightInfo::update_l2_from_l1(requests.pendingDeposits.len().saturating_add(requests.pendingCancelResolutions.len()).saturating_mul(2) as u32))] + #[pallet::weight(::WeightInfo::update_l2_from_l1( + requests.get_requests_count().saturated_into() + ).saturating_add(T::DbWeight::get().reads(weight_utils::get_read_scalling_factor(requests.get_requests_count().saturated_into()).saturated_into())))] pub fn update_l2_from_l1( origin: OriginFor, requests: messages::L1Update, @@ -625,8 +627,9 @@ pub mod pallet { } #[pallet::call_index(3)] - #[pallet::weight(::WeightInfo::cancel_requests_from_l1().saturating_mul(2))] - //EXTRINSIC2 (who canceled, dispute_period_end(u32-blocknum))) + // NOTE: account for worst case scenario, in the future we should introduce the mandatory + // parameter 'update_size' so we can parametrize weight with it + #[pallet::weight(::WeightInfo::cancel_requests_from_l1().saturating_mul(weight_utils::get_read_scalling_factor(10_000).saturated_into()))] pub fn cancel_requests_from_l1( origin: OriginFor, chain: ::ChainId, From 833f0c91d2c522f7373b58003fad5613b09f4d43 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sat, 23 Nov 2024 09:20:04 +0100 Subject: [PATCH 15/23] different dispute period per l1 --- pallets/rolldown/src/benchmarking.rs | 4 +- pallets/rolldown/src/lib.rs | 112 +++++++++++++++++++-------- pallets/rolldown/src/mock.rs | 20 ++--- pallets/rolldown/src/tests.rs | 9 ++- rollup/node/src/chain_spec.rs | 11 ++- rollup/runtime/src/lib.rs | 1 - rollup/runtime/src/runtime_config.rs | 2 - 7 files changed, 106 insertions(+), 53 deletions(-) diff --git a/pallets/rolldown/src/benchmarking.rs b/pallets/rolldown/src/benchmarking.rs index 4dc8cc5eb..67bdf6f95 100644 --- a/pallets/rolldown/src/benchmarking.rs +++ b/pallets/rolldown/src/benchmarking.rs @@ -363,7 +363,7 @@ mod benchmarks { >::set_block_number(1u32.into()); let dispute_period_end = >::block_number().saturated_into::() + - Rolldown::::get_dispute_period(); + Rolldown::::get_dispute_period(l1_chain).unwrap(); assert!( PendingSequencerUpdates::::get(dispute_period_end, l1_chain).is_none(), "BEFORE PendingSequencerUpdates {:?} dispute_period_end {:?} l1_chain should be uninit", @@ -414,7 +414,7 @@ mod benchmarks { >::set_block_number(1u32.into()); let dispute_period_end = >::block_number().saturated_into::() + - Rolldown::::get_dispute_period(); + Rolldown::::get_dispute_period(l1_chain).unwrap(); assert!( PendingSequencerUpdates::::get(dispute_period_end, l1_chain).is_none(), "BEFORE PendingSequencerUpdates {:?} dispute_period_end {:?} l1_chain should be uninit", diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index ff8ff5ba1..0e353faa4 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -405,6 +405,16 @@ pub mod pallet { ValueQuery, >; + #[pallet::storage] + pub type DisputePeriod = StorageMap< + _, + Blake2_128Concat, + ChainIdOf, + u128, + OptionQuery, + >; + + #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { @@ -455,6 +465,10 @@ pub mod pallet { chain: ::ChainId, hash: H256, }, + L1ReadIgnoredBecauseOfUnknownDisputePeriod { + chain: ::ChainId, + hash: H256, + }, DepositFerried { chain: ::ChainId, deposit: messages::Deposit, @@ -464,6 +478,10 @@ pub mod pallet { chain: ::ChainId, hash: H256, }, + DisputePeriodSet { + chain: ::ChainId, + dispute_period_length: u128, + }, } #[pallet::error] @@ -502,6 +520,7 @@ pub mod pallet { AssetRegistrationProblem, UpdateHashMishmatch, AlreadyExecuted, + UninitializedChainId, } #[cfg(feature = "runtime-benchmarks")] @@ -526,8 +545,6 @@ pub mod pallet { + MultiTokenCurrencyExtended; type AssetRegistryProvider: AssetRegistryProviderTrait>; #[pallet::constant] - type DisputePeriodLength: Get; - #[pallet::constant] type RightsMultiplier: Get; #[pallet::constant] type RequestsPerBlock: Get; @@ -564,17 +581,25 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { pub _phantom: PhantomData, + pub dispute_periods: BTreeMap, u128>, } impl Default for GenesisConfig { fn default() -> Self { - GenesisConfig { _phantom: Default::default() } + GenesisConfig { + _phantom: Default::default(), + dispute_periods : Default::default() + } } } #[pallet::genesis_build] impl BuildGenesisConfig for GenesisConfig { - fn build(&self) {} + fn build(&self) { + for (chain, period) in &self.dispute_periods { + DisputePeriod::::insert(chain, *period); + } + } } // Many calls that deal with large storage items have their weight mutiplied by 2 @@ -1001,12 +1026,28 @@ pub mod pallet { let sequencer = ensure_signed(origin)?; Self::update_impl(sequencer, requests) } + + #[pallet::call_index(13)] + #[pallet::weight(T::DbWeight::get().reads_writes(0, 2))] + pub fn set_dispute_period( + origin: OriginFor, + chain: ::ChainId, + dispute_period_length: u128, + ) -> DispatchResult { + let _ = ensure_root(origin)?; + DisputePeriod::::insert(chain, dispute_period_length); + Self::deposit_event(Event::DisputePeriodSet { + chain, + dispute_period_length, + }); + Ok(()) + } } } impl Pallet { - fn get_dispute_period() -> u128 { - T::DisputePeriodLength::get() + fn get_dispute_period(chain: ChainIdOf) -> Option { + DisputePeriod::::get(chain) } fn get_max_requests_per_block() -> u128 { @@ -1098,31 +1139,38 @@ impl Pallet { let sequencer = metadata.sequencer.clone(); let l1_read_hash = metadata.update_hash.clone(); let update_size = metadata.update_size.clone(); + if let Some(dispute_period) = Self::get_dispute_period(l1){ - if T::SequencerStakingProvider::is_active_sequencer(l1, &sequencer) { - SequencersRights::::mutate(l1, |sequencers| { - if let Some(rights) = sequencers.get_mut(&sequencer) { - rights.read_rights.saturating_accrue(T::RightsMultiplier::get()); - } - }); - } - - let update_creation_block = block_number.saturating_sub(Self::get_dispute_period()); - - match LastMaintananceMode::::get() { - Some(last_maintanance_mode) if update_creation_block <= last_maintanance_mode => { - Self::deposit_event(Event::L1ReadIgnoredBecauseOfMaintenanceMode { - chain: l1, - hash: l1_read_hash, - }); - }, - _ => { - Self::schedule_requests(now, l1, metadata); - Self::deposit_event(Event::L1ReadScheduledForExecution { - chain: l1, - hash: l1_read_hash, + if T::SequencerStakingProvider::is_active_sequencer(l1, &sequencer) { + SequencersRights::::mutate(l1, |sequencers| { + if let Some(rights) = sequencers.get_mut(&sequencer) { + rights.read_rights.saturating_accrue(T::RightsMultiplier::get()); + } }); - }, + } + + let update_creation_block = block_number.saturating_sub(dispute_period); + + match LastMaintananceMode::::get() { + Some(last_maintanance_mode) if update_creation_block <= last_maintanance_mode => { + Self::deposit_event(Event::L1ReadIgnoredBecauseOfMaintenanceMode { + chain: l1, + hash: l1_read_hash, + }); + }, + _ => { + Self::schedule_requests(now, l1, metadata); + Self::deposit_event(Event::L1ReadScheduledForExecution { + chain: l1, + hash: l1_read_hash, + }); + }, + } + }else{ + Self::deposit_event(Event::L1ReadIgnoredBecauseOfUnknownDisputePeriod { + chain: l1, + hash: l1_read_hash, + }); } } @@ -1491,7 +1539,8 @@ impl Pallet { // check json length to prevent big data spam, maybe not necessary as it will be checked later and slashed let current_block_number = >::block_number().saturated_into::(); - let dispute_period_length = Self::get_dispute_period(); + let dispute_period_length = Self::get_dispute_period(l1).ok_or(Error::::UninitializedChainId)?; + let dispute_period_end: u128 = current_block_number + dispute_period_length; // ensure sequencer has rights to update @@ -1542,9 +1591,10 @@ impl Pallet { fn count_of_read_rights_under_dispute(chain: ChainIdOf, sequencer: &AccountIdOf) -> u128 { let mut read_rights = 0u128; let last_update = LastUpdateBySequencer::::get((chain, sequencer)); + let dispute_period = Self::get_dispute_period(chain).unwrap_or(u128::MAX); if last_update != 0 && - last_update.saturating_add(T::DisputePeriodLength::get()) >= + last_update.saturating_add(dispute_period) >= >::block_number().saturated_into::() { read_rights += 1; diff --git a/pallets/rolldown/src/mock.rs b/pallets/rolldown/src/mock.rs index bef085bbd..aa4a0e0e5 100644 --- a/pallets/rolldown/src/mock.rs +++ b/pallets/rolldown/src/mock.rs @@ -141,7 +141,6 @@ impl rolldown::Config for Test { type Tokens = orml_tokens::MultiTokenCurrencyAdapter; type AssetRegistryProvider = MockAssetRegistryProviderApi; type AddressConverter = DummyAddressConverter; - type DisputePeriodLength = ConstU128<5>; type RequestsPerBlock = ConstU128<10>; type MaintenanceStatusProvider = MockMaintenanceStatusProviderApi; type ChainId = messages::Chain; @@ -166,7 +165,10 @@ impl ExtBuilder { .build_storage() .expect("Frame system builds valid default genesis config"); - rolldown::GenesisConfig:: { _phantom: Default::default() } + rolldown::GenesisConfig:: { + _phantom: Default::default(), + dispute_periods: [(crate::messages::Chain::Ethereum, 5u128), (crate::messages::Chain::Arbitrum, 10u128)].into_iter().cloned().collect() + } .assimilate_storage(&mut t) .expect("Tokens storage can be assimilated"); @@ -186,7 +188,10 @@ impl ExtBuilder { .build_storage() .expect("Frame system builds valid default genesis config"); - rolldown::GenesisConfig:: { _phantom: Default::default() } + rolldown::GenesisConfig:: { + _phantom: Default::default(), + dispute_periods: [(crate::messages::Chain::Ethereum, 5u128), (crate::messages::Chain::Arbitrum, 10u128)].into_iter().cloned().collect() + } .assimilate_storage(&mut t) .expect("Tokens storage can be assimilated"); @@ -195,15 +200,6 @@ impl ExtBuilder { Self { ext } } - pub fn single_sequencer(_seq: AccountId) -> Self { - let t = frame_system::GenesisConfig::::default() - .build_storage() - .expect("Frame system builds valid default genesis config"); - - let ext = sp_io::TestExternalities::new(t); - Self { ext } - } - fn create_if_does_not_exists(&mut self, token_id: TokenId) { self.ext.execute_with(|| { while token_id >= Tokens::next_asset_id() { diff --git a/pallets/rolldown/src/tests.rs b/pallets/rolldown/src/tests.rs index 4a88da3ae..b23b3327d 100644 --- a/pallets/rolldown/src/tests.rs +++ b/pallets/rolldown/src/tests.rs @@ -39,6 +39,7 @@ impl L1UpdateBuilder { pub fn build(self) -> messages::L1Update { let mut update = messages::L1Update::default(); + update.chain = Chain::Ethereum; for (id, r) in self.1.into_iter().enumerate() { let rid = if let Some(offset) = self.0 { (id as u128) + offset } else { r.id() }; @@ -94,7 +95,7 @@ fn process_single_deposit() { forward_to_block::(36); let current_block_number = >::block_number().saturated_into::(); - let dispute_period: u128 = Rolldown::get_dispute_period(); + let dispute_period: u128 = Rolldown::get_dispute_period(consts::CHAIN).unwrap(); let update = L1UpdateBuilder::default() .with_requests(vec![L1UpdateRequest::Deposit(Default::default())]) .build(); @@ -1289,7 +1290,7 @@ fn test_sequencer_unstaking() { let is_maintenance_mock = MockMaintenanceStatusProviderApi::is_maintenance_context(); is_maintenance_mock.expect().return_const(false); forward_to_block::(1); - let dispute_period_length = Rolldown::get_dispute_period(); + let dispute_period_length = Rolldown::get_dispute_period(consts::CHAIN).unwrap(); let now = frame_system::Pallet::::block_number().saturated_into::(); LastUpdateBySequencer::::insert((consts::CHAIN, ALICE), now); @@ -1533,7 +1534,7 @@ fn test_maintenance_mode_blocks_extrinsics() { #[test] #[serial] fn test_single_sequencer_cannot_cancel_request_without_cancel_rights_in_same_block() { - ExtBuilder::single_sequencer(BOB) + ExtBuilder::new_without_default_sequencers() .issue(ETH_RECIPIENT_ACCOUNT_MGX, ETH_TOKEN_ADDRESS_MGX, MILLION) .execute_with_default_mocks(|| { forward_to_block::(10); @@ -1577,7 +1578,7 @@ fn test_single_sequencer_cannot_cancel_request_without_cancel_rights_in_same_blo #[test] #[serial] fn test_single_sequencer_cannot_cancel_request_without_cancel_rights_in_next_block() { - ExtBuilder::single_sequencer(BOB) + ExtBuilder::new_without_default_sequencers() .issue(ETH_RECIPIENT_ACCOUNT_MGX, ETH_TOKEN_ADDRESS_MGX, MILLION) .execute_with_default_mocks(|| { forward_to_block::(10); diff --git a/rollup/node/src/chain_spec.rs b/rollup/node/src/chain_spec.rs index 2a3b7fd98..ef0c3dfe0 100644 --- a/rollup/node/src/chain_spec.rs +++ b/rollup/node/src/chain_spec.rs @@ -395,7 +395,16 @@ fn rollup_genesis( .cloned() .collect(), }, - rolldown: rollup_runtime::RolldownConfig { _phantom: Default::default() }, + #[cfg(not(feature = "fast-runtime"))] + rolldown: rollup_runtime::RolldownConfig { + _phantom: Default::default(), + dispute_periods: [(pallet_rolldown::messages::Chain::Ethereum, 300u128), (pallet_rolldown::messages::Chain::Arbitrum, 600u128)].iter().cloned().collect(), + }, + #[cfg(feature = "fast-runtime")] + rolldown: rollup_runtime::RolldownConfig { + _phantom: Default::default(), + dispute_periods: [(pallet_rolldown::messages::Chain::Ethereum, 10u128), (pallet_rolldown::messages::Chain::Arbitrum, 600u128)].iter().cloned().collect(), + }, metamask: rollup_runtime::MetamaskConfig { name: "Gasp".to_string(), version: "0.0.1".to_string(), diff --git a/rollup/runtime/src/lib.rs b/rollup/runtime/src/lib.rs index d08d03f39..25b006780 100644 --- a/rollup/runtime/src/lib.rs +++ b/rollup/runtime/src/lib.rs @@ -784,7 +784,6 @@ impl pallet_rolldown::Config for Runtime { type SequencerStakingProvider = SequencerStaking; type Tokens = orml_tokens::MultiTokenCurrencyAdapter; type AssetRegistryProvider = cfg::orml_asset_registry::AssetRegistryProvider; - type DisputePeriodLength = cfg::pallet_rolldown::DisputePeriodLength; type RequestsPerBlock = cfg::pallet_rolldown::RequestsPerBlock; // We havent spent any time considering rights multiplier being > 1. There might be some corner // cases that should be investigated. diff --git a/rollup/runtime/src/runtime_config.rs b/rollup/runtime/src/runtime_config.rs index 85629701b..d3ac2ceda 100644 --- a/rollup/runtime/src/runtime_config.rs +++ b/rollup/runtime/src/runtime_config.rs @@ -1435,14 +1435,12 @@ pub mod config { #[cfg(feature = "fast-runtime")] parameter_types! { - pub const DisputePeriodLength: u32 = 10; pub const MerkleRootAutomaticBatchPeriod: u128 = 25; pub const MerkleRootAutomaticBatchSize: u128 = 32; } #[cfg(not(feature = "fast-runtime"))] parameter_types! { - pub const DisputePeriodLength: u32 = 300; pub const MerkleRootAutomaticBatchPeriod: u128 = 1200; pub const MerkleRootAutomaticBatchSize: u128 = 1024; } From e8caabeaa4761479d47e4ffc9f09c750b6d1697d Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sat, 23 Nov 2024 09:20:27 +0100 Subject: [PATCH 16/23] different dispute period per l1 --- pallets/rolldown/src/lib.rs | 32 +++++++++++--------------------- pallets/rolldown/src/mock.rs | 24 ++++++++++++++++++------ rollup/node/src/chain_spec.rs | 16 ++++++++++++++-- 3 files changed, 43 insertions(+), 29 deletions(-) diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index 0e353faa4..5d920419c 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -406,14 +406,8 @@ pub mod pallet { >; #[pallet::storage] - pub type DisputePeriod = StorageMap< - _, - Blake2_128Concat, - ChainIdOf, - u128, - OptionQuery, - >; - + pub type DisputePeriod = + StorageMap<_, Blake2_128Concat, ChainIdOf, u128, OptionQuery>; #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] @@ -586,10 +580,7 @@ pub mod pallet { impl Default for GenesisConfig { fn default() -> Self { - GenesisConfig { - _phantom: Default::default(), - dispute_periods : Default::default() - } + GenesisConfig { _phantom: Default::default(), dispute_periods: Default::default() } } } @@ -1036,10 +1027,7 @@ pub mod pallet { ) -> DispatchResult { let _ = ensure_root(origin)?; DisputePeriod::::insert(chain, dispute_period_length); - Self::deposit_event(Event::DisputePeriodSet { - chain, - dispute_period_length, - }); + Self::deposit_event(Event::DisputePeriodSet { chain, dispute_period_length }); Ok(()) } } @@ -1139,8 +1127,7 @@ impl Pallet { let sequencer = metadata.sequencer.clone(); let l1_read_hash = metadata.update_hash.clone(); let update_size = metadata.update_size.clone(); - if let Some(dispute_period) = Self::get_dispute_period(l1){ - + if let Some(dispute_period) = Self::get_dispute_period(l1) { if T::SequencerStakingProvider::is_active_sequencer(l1, &sequencer) { SequencersRights::::mutate(l1, |sequencers| { if let Some(rights) = sequencers.get_mut(&sequencer) { @@ -1152,7 +1139,9 @@ impl Pallet { let update_creation_block = block_number.saturating_sub(dispute_period); match LastMaintananceMode::::get() { - Some(last_maintanance_mode) if update_creation_block <= last_maintanance_mode => { + Some(last_maintanance_mode) + if update_creation_block <= last_maintanance_mode => + { Self::deposit_event(Event::L1ReadIgnoredBecauseOfMaintenanceMode { chain: l1, hash: l1_read_hash, @@ -1166,7 +1155,7 @@ impl Pallet { }); }, } - }else{ + } else { Self::deposit_event(Event::L1ReadIgnoredBecauseOfUnknownDisputePeriod { chain: l1, hash: l1_read_hash, @@ -1539,7 +1528,8 @@ impl Pallet { // check json length to prevent big data spam, maybe not necessary as it will be checked later and slashed let current_block_number = >::block_number().saturated_into::(); - let dispute_period_length = Self::get_dispute_period(l1).ok_or(Error::::UninitializedChainId)?; + let dispute_period_length = + Self::get_dispute_period(l1).ok_or(Error::::UninitializedChainId)?; let dispute_period_end: u128 = current_block_number + dispute_period_length; diff --git a/pallets/rolldown/src/mock.rs b/pallets/rolldown/src/mock.rs index aa4a0e0e5..ed4d1a061 100644 --- a/pallets/rolldown/src/mock.rs +++ b/pallets/rolldown/src/mock.rs @@ -167,10 +167,16 @@ impl ExtBuilder { rolldown::GenesisConfig:: { _phantom: Default::default(), - dispute_periods: [(crate::messages::Chain::Ethereum, 5u128), (crate::messages::Chain::Arbitrum, 10u128)].into_iter().cloned().collect() + dispute_periods: [ + (crate::messages::Chain::Ethereum, 5u128), + (crate::messages::Chain::Arbitrum, 10u128), + ] + .into_iter() + .cloned() + .collect(), } - .assimilate_storage(&mut t) - .expect("Tokens storage can be assimilated"); + .assimilate_storage(&mut t) + .expect("Tokens storage can be assimilated"); let mut ext = sp_io::TestExternalities::new(t); @@ -190,10 +196,16 @@ impl ExtBuilder { rolldown::GenesisConfig:: { _phantom: Default::default(), - dispute_periods: [(crate::messages::Chain::Ethereum, 5u128), (crate::messages::Chain::Arbitrum, 10u128)].into_iter().cloned().collect() + dispute_periods: [ + (crate::messages::Chain::Ethereum, 5u128), + (crate::messages::Chain::Arbitrum, 10u128), + ] + .into_iter() + .cloned() + .collect(), } - .assimilate_storage(&mut t) - .expect("Tokens storage can be assimilated"); + .assimilate_storage(&mut t) + .expect("Tokens storage can be assimilated"); let ext = sp_io::TestExternalities::new(t); diff --git a/rollup/node/src/chain_spec.rs b/rollup/node/src/chain_spec.rs index ef0c3dfe0..4cb01dc10 100644 --- a/rollup/node/src/chain_spec.rs +++ b/rollup/node/src/chain_spec.rs @@ -398,12 +398,24 @@ fn rollup_genesis( #[cfg(not(feature = "fast-runtime"))] rolldown: rollup_runtime::RolldownConfig { _phantom: Default::default(), - dispute_periods: [(pallet_rolldown::messages::Chain::Ethereum, 300u128), (pallet_rolldown::messages::Chain::Arbitrum, 600u128)].iter().cloned().collect(), + dispute_periods: [ + (pallet_rolldown::messages::Chain::Ethereum, 300u128), + (pallet_rolldown::messages::Chain::Arbitrum, 600u128), + ] + .iter() + .cloned() + .collect(), }, #[cfg(feature = "fast-runtime")] rolldown: rollup_runtime::RolldownConfig { _phantom: Default::default(), - dispute_periods: [(pallet_rolldown::messages::Chain::Ethereum, 10u128), (pallet_rolldown::messages::Chain::Arbitrum, 600u128)].iter().cloned().collect(), + dispute_periods: [ + (pallet_rolldown::messages::Chain::Ethereum, 10u128), + (pallet_rolldown::messages::Chain::Arbitrum, 600u128), + ] + .iter() + .cloned() + .collect(), }, metamask: rollup_runtime::MetamaskConfig { name: "Gasp".to_string(), From 9ce6e7fe3d4b0c89f95b65d014cad7f838890802 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sat, 23 Nov 2024 09:34:46 +0100 Subject: [PATCH 17/23] tests for dispute period set --- pallets/rolldown/src/mock.rs | 16 ++-------- pallets/rolldown/src/tests.rs | 59 ++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 15 deletions(-) diff --git a/pallets/rolldown/src/mock.rs b/pallets/rolldown/src/mock.rs index ed4d1a061..bb73d5f26 100644 --- a/pallets/rolldown/src/mock.rs +++ b/pallets/rolldown/src/mock.rs @@ -167,13 +167,7 @@ impl ExtBuilder { rolldown::GenesisConfig:: { _phantom: Default::default(), - dispute_periods: [ - (crate::messages::Chain::Ethereum, 5u128), - (crate::messages::Chain::Arbitrum, 10u128), - ] - .into_iter() - .cloned() - .collect(), + dispute_periods: [(crate::messages::Chain::Ethereum, 5u128)].iter().cloned().collect(), } .assimilate_storage(&mut t) .expect("Tokens storage can be assimilated"); @@ -196,13 +190,7 @@ impl ExtBuilder { rolldown::GenesisConfig:: { _phantom: Default::default(), - dispute_periods: [ - (crate::messages::Chain::Ethereum, 5u128), - (crate::messages::Chain::Arbitrum, 10u128), - ] - .into_iter() - .cloned() - .collect(), + dispute_periods: [(crate::messages::Chain::Ethereum, 5u128)].iter().cloned().collect(), } .assimilate_storage(&mut t) .expect("Tokens storage can be assimilated"); diff --git a/pallets/rolldown/src/tests.rs b/pallets/rolldown/src/tests.rs index b23b3327d..938dd3ba8 100644 --- a/pallets/rolldown/src/tests.rs +++ b/pallets/rolldown/src/tests.rs @@ -38,8 +38,12 @@ impl L1UpdateBuilder { } pub fn build(self) -> messages::L1Update { + Self::build_for_chain(self, Chain::Ethereum) + } + + pub fn build_for_chain(self, chain: Chain) -> messages::L1Update { let mut update = messages::L1Update::default(); - update.chain = Chain::Ethereum; + update.chain = chain; for (id, r) in self.1.into_iter().enumerate() { let rid = if let Some(offset) = self.0 { (id as u128) + offset } else { r.id() }; @@ -3321,3 +3325,56 @@ fn ferry_already_executed_deposit_fails() { ); }); } + +#[test] +#[serial] +fn reject_update_for_unknown_chain_id() { + ExtBuilder::new() + .issue(ALICE, ETH_TOKEN_ADDRESS_MGX, 0u128) + .execute_with_default_mocks(|| { + forward_to_block::(10); + let update = L1UpdateBuilder::default() + .with_requests(vec![L1UpdateRequest::Deposit(messages::Deposit { + requestId: Default::default(), + depositRecipient: DummyAddressConverter::convert_back(CHARLIE), + tokenAddress: ETH_TOKEN_ADDRESS, + amount: sp_core::U256::from(MILLION), + timeStamp: sp_core::U256::from(1), + ferryTip: sp_core::U256::from(0), + })]) + .build_for_chain(Chain::Arbitrum); + assert_err!( + Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), update.clone()), + Error::::UninitializedChainId + ); + }); +} + +#[test] +#[serial] +fn set_dispute_period() { + ExtBuilder::new() + .issue(ALICE, ETH_TOKEN_ADDRESS_MGX, 0u128) + .execute_with_default_mocks(|| { + forward_to_block::(10); + + let dispute_period = Rolldown::get_dispute_period(Chain::Ethereum).unwrap(); + Rolldown::set_dispute_period( + RuntimeOrigin::root(), + Chain::Ethereum, + dispute_period + 1u128, + ) + .unwrap(); + + assert_event_emitted!(Event::DisputePeriodSet { + chain: messages::Chain::Ethereum, + dispute_period_length: dispute_period + 1u128 + }); + + Rolldown::set_dispute_period(RuntimeOrigin::root(), Chain::Arbitrum, 1234).unwrap(); + assert_event_emitted!(Event::DisputePeriodSet { + chain: messages::Chain::Arbitrum, + dispute_period_length: 1234 + }); + }); +} From 0ddae4f78fd7ba9a4542e9d5b4a286d410f37778 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sat, 23 Nov 2024 10:38:02 +0100 Subject: [PATCH 18/23] [GASP-1632] - stop processing on first failed request --- pallets/rolldown/src/lib.rs | 61 +++++----- pallets/rolldown/src/tests.rs | 214 +++++++++++++++++++++------------- 2 files changed, 159 insertions(+), 116 deletions(-) diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index 5d920419c..99552432a 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -1,6 +1,6 @@ #![cfg_attr(not(feature = "std"), no_std)] -use messages::{EthAbi, EthAbiHash}; +use messages::{EthAbi, EthAbiHash, L1UpdateRequest}; pub mod messages; #[cfg(feature = "runtime-benchmarks")] @@ -213,7 +213,11 @@ pub mod pallet { return used_weight; } - Self::execute_requests_from_execute_queue(); + // NOTE: here we could adjust the used weight based on the actual executed requests + // as the benchmarks accounts for the worst case scenario which is cancel_resultion + // processing + let _executed: Vec = Self::execute_requests_from_execute_queue(); + used_weight += cost_of_processing_requests; remaining_weight -= cost_of_processing_requests; } @@ -1169,54 +1173,39 @@ impl Pallet { fn process_single_request( l1: ::ChainId, request: &messages::L1UpdateRequest, - ) -> Weight { - let mut total_weight: Weight = Weight::default(); - - // weight for LastProcessedRequestOnL2 - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); + ) -> bool { let request_id = request.id(); if request_id <= LastProcessedRequestOnL2::::get(l1) { - return total_weight + return true; } let status = match request.clone() { messages::L1UpdateRequest::Deposit(deposit) => { let deposit_status = Self::process_deposit(l1, &deposit); - total_weight = - total_weight.saturating_add(::WeightInfo::process_deposit()); TotalNumberOfDeposits::::mutate(|v| *v = v.saturating_add(One::one())); - // weight for TotalNumberOfDeposits - total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); deposit_status.or_else(|err| { let who: T::AccountId = T::AddressConverter::convert(deposit.depositRecipient); FailedL1Deposits::::insert( (l1, deposit.requestId.id), (who, deposit.abi_encode_hash()), ); - // weight for FailedL1Deposits - total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); Err(err.into()) }) }, - messages::L1UpdateRequest::CancelResolution(cancel) => { - total_weight = total_weight - .saturating_add(::WeightInfo::process_cancel_resolution()); + messages::L1UpdateRequest::CancelResolution(cancel) => Self::process_cancel_resolution(l1, &cancel).or_else(|err| { T::MaintenanceStatusProvider::trigger_maintanance_mode(); Err(err) - }) - }, + }), }; - Pallet::::deposit_event(Event::RequestProcessedOnL2 { chain: l1, request_id, status }); - // Not sure about this - not sure exactly what is cached and how across extrinsics (/hooks) - // weight for deposit_event - total_weight = total_weight.saturating_add(T::DbWeight::get().reads_writes(2, 3)); - + Pallet::::deposit_event(Event::RequestProcessedOnL2 { + chain: l1, + request_id, + status: status.clone(), + }); LastProcessedRequestOnL2::::insert(l1, request.id()); - // weight for LastProcessedRequestOnL2 - total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); - total_weight + status.is_ok() } fn get_current_update_size_from_execution_queue() -> Option { @@ -1239,7 +1228,7 @@ impl Pallet { } } - fn execute_requests_from_execute_queue() { + fn execute_requests_from_execute_queue() -> Vec { let limit = Self::get_max_requests_per_block(); match ( UpdatesExecutionQueue::::get(UpdatesExecutionQueueNextId::::get()), @@ -1250,6 +1239,7 @@ impl Pallet { { UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); UpdatesExecutionQueueNextId::::mutate(Saturating::saturating_inc); + Default::default() }, (Some((_, l1, hash, _)), _) => { if let Some(update) = PendingSequencerUpdateContent::::get(hash) { @@ -1264,18 +1254,23 @@ impl Pallet { UpdatesExecutionQueue::::remove(UpdatesExecutionQueueNextId::::get()); PendingSequencerUpdateContent::::remove(hash); Self::deposit_event(Event::L1ReadExecuted { chain: l1, hash }); + Default::default() } else { - for r in requests { - let _ = Self::process_single_request(l1, &r); + for r in requests.iter() { + if !Self::process_single_request(l1, &r) { + // maintanance mode triggered + break; + } } + requests } } else { PendingSequencerUpdateContent::::remove(hash); + Default::default() } }, - _ => {}, - }; - Default::default() + _ => Default::default(), + } } fn schedule_requests( diff --git a/pallets/rolldown/src/tests.rs b/pallets/rolldown/src/tests.rs index 938dd3ba8..124e73ba1 100644 --- a/pallets/rolldown/src/tests.rs +++ b/pallets/rolldown/src/tests.rs @@ -831,97 +831,136 @@ fn cancel_request_as_council_executed_immadiately() { #[test] #[serial] fn execute_a_lot_of_requests_in_following_blocks() { - ExtBuilder::new().execute_with_default_mocks(|| { - forward_to_block::(10); + ExtBuilder::new() + .issue(ALICE, ETH_TOKEN_ADDRESS_MGX, 0u128) + .execute_with_default_mocks(|| { + forward_to_block::(10); - let requests_count = 25; - let requests = vec![L1UpdateRequest::Deposit(messages::Deposit::default()); requests_count]; + let requests_count = 25; - let deposit_update = L1UpdateBuilder::default().with_requests(requests).build(); - Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), deposit_update).unwrap(); + let dummy_update = L1UpdateRequest::Deposit(messages::Deposit { + requestId: Default::default(), + depositRecipient: DummyAddressConverter::convert_back(CHARLIE), + tokenAddress: ETH_TOKEN_ADDRESS, + amount: sp_core::U256::from(MILLION), + timeStamp: sp_core::U256::from(1), + ferryTip: sp_core::U256::from(0), + }); - forward_to_block::(14); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); - assert_eq!(UpdatesExecutionQueueNextId::::get(), 0u128); + let requests = vec![dummy_update; requests_count]; - forward_to_next_block::(); - assert_eq!( - LastProcessedRequestOnL2::::get(Chain::Ethereum), - Rolldown::get_max_requests_per_block().into() - ); + let deposit_update = L1UpdateBuilder::default().with_requests(requests).build(); + Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), deposit_update) + .unwrap(); - forward_to_next_block::(); - assert_eq!( - LastProcessedRequestOnL2::::get(Chain::Ethereum), - (2u128 * Rolldown::get_max_requests_per_block()).into() - ); + forward_to_block::(14); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); + assert_eq!(UpdatesExecutionQueueNextId::::get(), 0u128); - forward_to_next_block::(); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), requests_count as u128); + forward_to_next_block::(); + assert_eq!( + LastProcessedRequestOnL2::::get(Chain::Ethereum), + Rolldown::get_max_requests_per_block().into() + ); - forward_to_next_block::(); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), requests_count as u128); - }); + forward_to_next_block::(); + assert_eq!( + LastProcessedRequestOnL2::::get(Chain::Ethereum), + (2u128 * Rolldown::get_max_requests_per_block()).into() + ); + + forward_to_next_block::(); + assert_eq!( + LastProcessedRequestOnL2::::get(Chain::Ethereum), + requests_count as u128 + ); + + forward_to_next_block::(); + assert_eq!( + LastProcessedRequestOnL2::::get(Chain::Ethereum), + requests_count as u128 + ); + }); } #[test] #[serial] fn ignore_duplicated_requests_when_already_executed() { - ExtBuilder::new().execute_with_default_mocks(|| { - let dummy_request = L1UpdateRequest::Deposit(Default::default()); - let first_update = - L1UpdateBuilder::default().with_requests(vec![dummy_request.clone(); 5]).build(); - let second_update = - L1UpdateBuilder::default().with_requests(vec![dummy_request; 6]).build(); + ExtBuilder::new() + .issue(ALICE, ETH_TOKEN_ADDRESS_MGX, 0u128) + .execute_with_default_mocks(|| { + let dummy_request = L1UpdateRequest::Deposit(messages::Deposit { + requestId: Default::default(), + depositRecipient: DummyAddressConverter::convert_back(CHARLIE), + tokenAddress: ETH_TOKEN_ADDRESS, + amount: sp_core::U256::from(MILLION), + timeStamp: sp_core::U256::from(1), + ferryTip: sp_core::U256::from(0), + }); - forward_to_block::(10); - Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), first_update).unwrap(); + let first_update = + L1UpdateBuilder::default().with_requests(vec![dummy_request.clone(); 5]).build(); + let second_update = + L1UpdateBuilder::default().with_requests(vec![dummy_request; 6]).build(); - forward_to_block::(11); - Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(BOB), second_update).unwrap(); + forward_to_block::(10); + Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), first_update).unwrap(); - forward_to_block::(14); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); + forward_to_block::(11); + Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(BOB), second_update).unwrap(); - forward_to_block::(15); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 5u128.into()); + forward_to_block::(14); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); - forward_to_next_block::(); - forward_to_next_block::(); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 6u128.into()); - }); + forward_to_block::(15); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 5u128.into()); + + forward_to_next_block::(); + forward_to_next_block::(); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 6u128.into()); + }); } #[test] #[serial] fn process_l1_reads_in_order() { - ExtBuilder::new().execute_with_default_mocks(|| { - let dummy_request = L1UpdateRequest::Deposit(Default::default()); - let first_update = L1UpdateBuilder::default() - .with_requests(vec![dummy_request.clone(); 11]) - .build(); - let second_update = - L1UpdateBuilder::default().with_requests(vec![dummy_request; 20]).build(); + ExtBuilder::new() + .issue(ALICE, ETH_TOKEN_ADDRESS_MGX, 0u128) + .execute_with_default_mocks(|| { + let dummy_request = L1UpdateRequest::Deposit(messages::Deposit { + requestId: Default::default(), + depositRecipient: DummyAddressConverter::convert_back(CHARLIE), + tokenAddress: ETH_TOKEN_ADDRESS, + amount: sp_core::U256::from(MILLION), + timeStamp: sp_core::U256::from(1), + ferryTip: sp_core::U256::from(0), + }); - forward_to_block::(10); - Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), first_update).unwrap(); + let first_update = L1UpdateBuilder::default() + .with_requests(vec![dummy_request.clone(); 11]) + .build(); + let second_update = + L1UpdateBuilder::default().with_requests(vec![dummy_request; 20]).build(); - forward_to_block::(11); - Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(BOB), second_update).unwrap(); + forward_to_block::(10); + Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), first_update).unwrap(); - forward_to_block::(14); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); + forward_to_block::(11); + Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(BOB), second_update).unwrap(); - forward_to_block::(15); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 10u128.into()); + forward_to_block::(14); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0u128.into()); - forward_to_next_block::(); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 11u128.into()); + forward_to_block::(15); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 10u128.into()); - forward_to_next_block::(); - forward_to_next_block::(); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 20u128.into()); - }); + forward_to_next_block::(); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 11u128.into()); + + forward_to_next_block::(); + forward_to_next_block::(); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 20u128.into()); + }); } #[test] @@ -1008,33 +1047,42 @@ fn reject_second_update_in_the_same_block() { #[test] #[serial] fn accept_consecutive_update_split_into_two() { - ExtBuilder::new().execute_with_default_mocks(|| { - forward_to_block::(10); + ExtBuilder::new() + .issue(ALICE, ETH_TOKEN_ADDRESS_MGX, 0u128) + .execute_with_default_mocks(|| { + forward_to_block::(10); - // imagine that there are 20 request on L1 waiting to be processed - // they need to be split into 2 update_l2_from_l1_unsafe calls + // imagine that there are 20 request on L1 waiting to be processed + // they need to be split into 2 update_l2_from_l1_unsafe calls - let dummy_update = L1UpdateRequest::Deposit(Default::default()); + let dummy_update = L1UpdateRequest::Deposit(messages::Deposit { + requestId: Default::default(), + depositRecipient: DummyAddressConverter::convert_back(CHARLIE), + tokenAddress: ETH_TOKEN_ADDRESS, + amount: sp_core::U256::from(MILLION), + timeStamp: sp_core::U256::from(1), + ferryTip: sp_core::U256::from(0), + }); - let first_update = L1UpdateBuilder::default() - .with_requests(vec![ - dummy_update.clone(); - (2 * Rolldown::get_max_requests_per_block()) as usize - ]) - .with_offset(1u128) - .build(); + let first_update = L1UpdateBuilder::default() + .with_requests(vec![ + dummy_update.clone(); + (2 * Rolldown::get_max_requests_per_block()) as usize + ]) + .with_offset(1u128) + .build(); - Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), first_update).unwrap(); + Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), first_update).unwrap(); - forward_to_next_block::(); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0); + forward_to_next_block::(); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 0); - forward_to_block::(15); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 10); + forward_to_block::(15); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 10); - forward_to_next_block::(); - assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 20); - }); + forward_to_next_block::(); + assert_eq!(LastProcessedRequestOnL2::::get(Chain::Ethereum), 20); + }); } #[test] From 8eff3239dd63c39e0a289d44e08bdd5af04526be Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sat, 23 Nov 2024 10:53:27 +0100 Subject: [PATCH 19/23] allign with base --- pallets/rolldown/src/messages/mod.rs | 13 ------------- rollup/node/src/chain_spec.rs | 4 +++- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/pallets/rolldown/src/messages/mod.rs b/pallets/rolldown/src/messages/mod.rs index 4a10019c4..59d83d63f 100644 --- a/pallets/rolldown/src/messages/mod.rs +++ b/pallets/rolldown/src/messages/mod.rs @@ -105,19 +105,6 @@ pub enum Chain { Base, } -pub trait NextEnum { - fn next(self) -> Self; -} - -impl NextEnum for Chain { - fn next(self) -> Self { - match self { - Chain::Ethereum => Chain::Arbitrum, - Chain::Arbitrum => Chain::Ethereum, - } - } -} - #[repr(u8)] #[derive( Default, Eq, PartialEq, RuntimeDebug, Clone, Encode, Decode, TypeInfo, Serialize, Copy, diff --git a/rollup/node/src/chain_spec.rs b/rollup/node/src/chain_spec.rs index 90ddc27ca..f67a13d86 100644 --- a/rollup/node/src/chain_spec.rs +++ b/rollup/node/src/chain_spec.rs @@ -410,6 +410,7 @@ fn rollup_genesis( dispute_periods: [ (pallet_rolldown::messages::Chain::Ethereum, 300u128), (pallet_rolldown::messages::Chain::Arbitrum, 600u128), + (pallet_rolldown::messages::Chain::Base, 600u128), ] .iter() .cloned() @@ -420,7 +421,8 @@ fn rollup_genesis( _phantom: Default::default(), dispute_periods: [ (pallet_rolldown::messages::Chain::Ethereum, 10u128), - (pallet_rolldown::messages::Chain::Arbitrum, 600u128), + (pallet_rolldown::messages::Chain::Arbitrum, 20u128), + (pallet_rolldown::messages::Chain::Base, 20u128), ] .iter() .cloned() From e334a7d06263b179dd36540af91e7649234753cf Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sun, 24 Nov 2024 18:49:09 +0100 Subject: [PATCH 20/23] configure features --- rollup/node/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/rollup/node/Cargo.toml b/rollup/node/Cargo.toml index 41e9f7091..2939c3460 100644 --- a/rollup/node/Cargo.toml +++ b/rollup/node/Cargo.toml @@ -98,6 +98,7 @@ substrate-build-script-utils = { workspace = true } [features] default = ["std"] +fast-runtime = [] std = [ "rollup-runtime/std", "xyk-rpc/std", From 06f8e012d249e57854e79b9c0639b58b0caca4fe Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 25 Nov 2024 17:22:11 +0100 Subject: [PATCH 21/23] adjust dispute period --- rollup/node/src/chain_spec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rollup/node/src/chain_spec.rs b/rollup/node/src/chain_spec.rs index f67a13d86..4b6d36760 100644 --- a/rollup/node/src/chain_spec.rs +++ b/rollup/node/src/chain_spec.rs @@ -421,8 +421,8 @@ fn rollup_genesis( _phantom: Default::default(), dispute_periods: [ (pallet_rolldown::messages::Chain::Ethereum, 10u128), - (pallet_rolldown::messages::Chain::Arbitrum, 20u128), - (pallet_rolldown::messages::Chain::Base, 20u128), + (pallet_rolldown::messages::Chain::Arbitrum, 15u128), + (pallet_rolldown::messages::Chain::Base, 15u128), ] .iter() .cloned() From 4e0b2bc3c513ba0a41dda9f3a7e86caae4637659 Mon Sep 17 00:00:00 2001 From: Marian Vanderka Date: Thu, 28 Nov 2024 15:40:34 +0100 Subject: [PATCH 22/23] Feature/market improvs (#845) - RPC add calc_price_impact variant - fix swap buy call missing in feelock filter - adjust create pool to infer fixed rate from initial deposit --- Cargo.lock | 271 +++++++++--------- Cargo.toml | 134 +++++++++ pallets/market/rpc/src/lib.rs | 60 ++++ pallets/market/src/lib.rs | 76 ++++- pallets/stable-swap/src/lib.rs | 232 +++++++++++---- pallets/xyk/src/lib.rs | 28 ++ rollup/runtime/integration-test/Cargo.toml | 1 + rollup/runtime/integration-test/src/market.rs | 233 +++++---------- rollup/runtime/src/lib.rs | 21 ++ 9 files changed, 688 insertions(+), 368 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e3e9d53e..7c59cd4d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2421,7 +2421,7 @@ dependencies = [ [[package]] name = "extrinsic-shuffler" version = "4.0.0-dev" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "derive_more", "log", @@ -2604,7 +2604,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "12.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "parity-scale-codec", ] @@ -2627,7 +2627,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-support", "frame-support-procedural", @@ -2652,7 +2652,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "32.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "Inflector", "array-bytes 6.2.3", @@ -2706,7 +2706,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "aquamarine 0.3.3", "extrinsic-shuffler", @@ -2740,7 +2740,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.35.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#cc2046d2ba128a9ad452953ea5971ccc02248893" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#6661f2890fa822ae738bff9d8072438a270054cd" dependencies = [ "futures", "indicatif", @@ -2762,7 +2762,7 @@ dependencies = [ [[package]] name = "frame-support" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "aquamarine 0.5.0", "array-bytes 6.2.3", @@ -2804,7 +2804,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "23.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "Inflector", "cfg-expr", @@ -2823,7 +2823,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "10.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 3.2.0", @@ -2835,7 +2835,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "11.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "proc-macro2", "quote", @@ -2845,7 +2845,7 @@ dependencies = [ [[package]] name = "frame-system" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "cfg-if", "docify", @@ -2867,7 +2867,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-benchmarking", "frame-support", @@ -2882,7 +2882,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "26.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "parity-scale-codec", "sp-api", @@ -2891,7 +2891,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.34.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-support", "parity-scale-codec", @@ -4775,7 +4775,7 @@ dependencies = [ [[package]] name = "mangata-support" version = "0.1.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-support", "mangata-types", @@ -4788,7 +4788,7 @@ dependencies = [ [[package]] name = "mangata-types" version = "0.1.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "parity-scale-codec", "scale-info", @@ -5490,7 +5490,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "27.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-support", "frame-system", @@ -5507,7 +5507,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-support", "frame-system", @@ -5522,7 +5522,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-benchmarking", "frame-support", @@ -5546,7 +5546,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "docify", "frame-benchmarking", @@ -5594,7 +5594,7 @@ dependencies = [ [[package]] name = "pallet-collective-mangata" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-benchmarking", "frame-support", @@ -5665,7 +5665,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-benchmarking", "frame-support", @@ -5688,7 +5688,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5785,7 +5785,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-benchmarking", "frame-support", @@ -5887,7 +5887,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-benchmarking", "frame-support", @@ -5964,7 +5964,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-benchmarking", "frame-support", @@ -6008,7 +6008,7 @@ dependencies = [ [[package]] name = "pallet-sudo-mangata" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "docify", "frame-benchmarking", @@ -6042,7 +6042,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "27.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "docify", "frame-benchmarking", @@ -6062,7 +6062,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-support", "frame-system", @@ -6078,7 +6078,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "30.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -6094,7 +6094,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -6106,7 +6106,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "27.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "docify", "frame-benchmarking", @@ -6125,7 +6125,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-benchmarking", "frame-support", @@ -6141,7 +6141,7 @@ dependencies = [ [[package]] name = "pallet-utility-mangata" version = "4.0.0-dev" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-benchmarking", "frame-support", @@ -6157,7 +6157,7 @@ dependencies = [ [[package]] name = "pallet-vesting-mangata" version = "4.0.0-dev" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-benchmarking", "frame-support", @@ -7649,6 +7649,7 @@ dependencies = [ "pallet-proxy", "pallet-rolldown", "pallet-session", + "pallet-stable-swap", "pallet-sudo-origin", "pallet-transaction-payment", "pallet-xyk", @@ -7980,7 +7981,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "23.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "log", "sp-core", @@ -7991,7 +7992,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship-ver" version = "0.10.0-dev" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "aquamarine 0.3.3", "futures", @@ -8017,7 +8018,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "parity-scale-codec", "sp-api", @@ -8032,7 +8033,7 @@ dependencies = [ [[package]] name = "sc-block-builder-ver" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "aquamarine 0.1.12", "extrinsic-shuffler", @@ -8052,7 +8053,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "27.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 6.2.3", "docify", @@ -8078,7 +8079,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "11.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", @@ -8089,7 +8090,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.36.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 6.2.3", "chrono", @@ -8130,7 +8131,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "fnv", "futures", @@ -8157,7 +8158,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.35.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "hash-db", "kvdb", @@ -8183,7 +8184,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "futures", @@ -8208,7 +8209,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.34.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "futures", @@ -8237,7 +8238,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.19.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "ahash 0.8.11", "array-bytes 6.2.3", @@ -8280,7 +8281,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "futures", @@ -8305,7 +8306,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.32.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", @@ -8328,7 +8329,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.29.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "polkavm", "sc-allocator", @@ -8341,7 +8342,7 @@ dependencies = [ [[package]] name = "sc-executor-polkavm" version = "0.29.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "log", "polkavm", @@ -8352,7 +8353,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.29.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "anyhow", "cfg-if", @@ -8370,7 +8371,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "ansi_term", "futures", @@ -8387,7 +8388,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "25.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 6.2.3", "parking_lot 0.12.3", @@ -8401,7 +8402,7 @@ dependencies = [ [[package]] name = "sc-mixnet" version = "0.4.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 4.2.0", "arrayvec 0.7.6", @@ -8430,7 +8431,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.34.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 6.2.3", "async-channel", @@ -8473,7 +8474,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-channel", "cid", @@ -8493,7 +8494,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "bitflags 1.3.2", @@ -8510,7 +8511,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.34.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "ahash 0.8.11", "futures", @@ -8529,7 +8530,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 6.2.3", "async-channel", @@ -8550,7 +8551,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 6.2.3", "async-channel", @@ -8586,7 +8587,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 6.2.3", "futures", @@ -8605,7 +8606,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "29.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 6.2.3", "bytes", @@ -8639,7 +8640,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.17.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -8648,7 +8649,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "29.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "futures", "jsonrpsee", @@ -8680,7 +8681,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -8700,7 +8701,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "11.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "futures", "governor", @@ -8718,7 +8719,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.34.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 6.2.3", "futures", @@ -8749,7 +8750,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.35.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "directories", @@ -8814,7 +8815,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.30.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "log", "parity-scale-codec", @@ -8825,7 +8826,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "27.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "derive_more", "futures", @@ -8846,7 +8847,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "15.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "chrono", "futures", @@ -8865,7 +8866,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "ansi_term", "chrono", @@ -8895,7 +8896,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "11.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", @@ -8906,7 +8907,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "futures", @@ -8933,7 +8934,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "futures", @@ -8949,7 +8950,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "14.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-channel", "futures", @@ -9495,7 +9496,7 @@ dependencies = [ [[package]] name = "sp-api" version = "26.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "hash-db", "log", @@ -9517,7 +9518,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "15.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "Inflector", "blake2 0.10.6", @@ -9531,7 +9532,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "30.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "parity-scale-codec", "scale-info", @@ -9544,7 +9545,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "23.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "integer-sqrt", "num-traits", @@ -9576,7 +9577,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "26.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "sp-api", "sp-inherents", @@ -9587,7 +9588,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "futures", "log", @@ -9605,7 +9606,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.32.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "futures", @@ -9620,7 +9621,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.32.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "parity-scale-codec", @@ -9637,7 +9638,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.32.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "parity-scale-codec", @@ -9656,7 +9657,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "13.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "finality-grandpa", "log", @@ -9674,7 +9675,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.32.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "parity-scale-codec", "scale-info", @@ -9686,7 +9687,7 @@ dependencies = [ [[package]] name = "sp-core" version = "28.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 6.2.3", "bandersnatch_vrfs", @@ -9733,7 +9734,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#f96b7fd48c5b5ed6d08a62a6a0ebdac22287e19a" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#6661f2890fa822ae738bff9d8072438a270054cd" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -9754,7 +9755,7 @@ dependencies = [ [[package]] name = "sp-crypto-hashing" version = "0.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "blake2b_simd", "byteorder", @@ -9767,7 +9768,7 @@ dependencies = [ [[package]] name = "sp-crypto-hashing-proc-macro" version = "0.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "quote", "sp-crypto-hashing", @@ -9777,7 +9778,7 @@ dependencies = [ [[package]] name = "sp-database" version = "10.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "kvdb", "parking_lot 0.12.3", @@ -9786,7 +9787,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "proc-macro2", "quote", @@ -9796,7 +9797,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "environmental", "parity-scale-codec", @@ -9807,7 +9808,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.7.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "serde_json", "sp-api", @@ -9818,7 +9819,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "26.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -9832,7 +9833,7 @@ dependencies = [ [[package]] name = "sp-io" version = "30.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "bytes", "ed25519-dalek", @@ -9858,7 +9859,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "31.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "sp-core", "sp-runtime", @@ -9868,7 +9869,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.34.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", @@ -9879,7 +9880,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "11.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "thiserror", "zstd 0.12.4", @@ -9888,7 +9889,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.6.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -9899,7 +9900,7 @@ dependencies = [ [[package]] name = "sp-mixnet" version = "0.4.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "parity-scale-codec", "scale-info", @@ -9911,7 +9912,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "26.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "sp-api", "sp-core", @@ -9921,7 +9922,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "13.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "backtrace", "lazy_static", @@ -9931,7 +9932,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "26.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "rustc-hash", "serde", @@ -9941,7 +9942,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "31.0.1" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -9972,7 +9973,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -9991,7 +9992,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "Inflector", "expander", @@ -10004,7 +10005,7 @@ dependencies = [ [[package]] name = "sp-session" version = "27.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "parity-scale-codec", "scale-info", @@ -10019,7 +10020,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "26.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10033,7 +10034,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.35.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "hash-db", "log", @@ -10054,7 +10055,7 @@ dependencies = [ [[package]] name = "sp-statement-store" version = "10.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "aes-gcm", "curve25519-dalek 4.1.1", @@ -10079,12 +10080,12 @@ dependencies = [ [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "impl-serde 0.4.0", "parity-scale-codec", @@ -10097,7 +10098,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "26.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "parity-scale-codec", @@ -10110,7 +10111,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "parity-scale-codec", "sp-std", @@ -10122,7 +10123,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "26.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "sp-api", "sp-runtime", @@ -10131,7 +10132,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "26.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "parity-scale-codec", @@ -10146,7 +10147,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "29.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "ahash 0.8.11", "hash-db", @@ -10170,7 +10171,7 @@ dependencies = [ [[package]] name = "sp-ver" version = "4.0.0-dev" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "async-trait", "parity-scale-codec", @@ -10187,7 +10188,7 @@ dependencies = [ [[package]] name = "sp-version" version = "29.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "impl-serde 0.4.0", "parity-scale-codec", @@ -10204,7 +10205,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "13.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10215,7 +10216,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -10228,7 +10229,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "27.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "bounded-collections", "parity-scale-codec", @@ -10387,7 +10388,7 @@ dependencies = [ [[package]] name = "substrate-bip39" version = "0.4.7" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "hmac 0.12.1", "pbkdf2", @@ -10399,12 +10400,12 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "11.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" [[package]] name = "substrate-prometheus-endpoint" version = "0.17.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "hyper", "log", @@ -10416,7 +10417,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#cc2046d2ba128a9ad452953ea5971ccc02248893" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#6661f2890fa822ae738bff9d8072438a270054cd" dependencies = [ "async-trait", "jsonrpsee", @@ -10429,7 +10430,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 6.2.3", "async-trait", @@ -10456,7 +10457,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime" version = "2.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "array-bytes 6.2.3", "frame-executive", @@ -10499,7 +10500,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime-client" version = "2.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "futures", "sc-block-builder", @@ -10518,7 +10519,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "17.0.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "build-helper", "cargo_metadata", @@ -11134,7 +11135,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "try-runtime-cli" version = "0.38.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#cc2046d2ba128a9ad452953ea5971ccc02248893" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#6661f2890fa822ae738bff9d8072438a270054cd" dependencies = [ "async-trait", "clap", @@ -11320,7 +11321,7 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "ver-api" version = "4.0.0-dev" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#b326df58169f4e1559acf7fbe38ed2a6ab8bb96b" +source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" dependencies = [ "derive_more", "frame-support", diff --git a/Cargo.toml b/Cargo.toml index 962b6880a..bde327505 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -193,3 +193,137 @@ ver-api = { git = "https://github.com/gasp-xyz/polkadot-sdk", branch = "eth-roll [patch."https://github.com/paritytech/polkadot-sdk"] # ... which satisfies git dependency `sp-crypto-ec-utils` of package `sp-ark-bls12-381 v0.4.2 (https://github.com/paritytech/arkworks-substrate#caa2eed7)` sp-crypto-ec-utils = { git = "https://github.com/gasp-xyz/polkadot-sdk", branch = "eth-rollup-develop" } + +# patch generated by './scripts/dev_manifest.sh ../polkadot-sdk' +[patch."https://github.com/gasp-xyz/polkadot-sdk"] +substrate-test-runtime = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +substrate-test-runtime-client = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +substrate-test-client = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-transaction-payment = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-transaction-payment-rpc = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-collective-mangata = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-proxy = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-identity = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-sudo-mangata = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +mangata-support = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-utility-mangata = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-authorship = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-grandpa = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-vesting-mangata = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +frame-system = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +frame-system-benchmarking = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +frame-system-rpc-runtime-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +frame-support = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +frame-support-procedural = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +frame-support-procedural-tools = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +frame-support-procedural-tools-derive = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-balances = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-aura = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +frame-benchmarking = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-treasury = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +frame-try-runtime = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-timestamp = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-babe = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-membership = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-utility = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +frame-executive = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +pallet-session = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +substrate-wasm-builder = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +fork-tree = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +substrate-build-script-utils = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +frame-benchmarking-cli = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +substrate-bip39 = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +substrate-prometheus-endpoint = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-database = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-runtime-interface = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-runtime-interface-proc-macro = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-consensus-grandpa = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-consensus = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-consensus-aura = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-consensus-babe = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-consensus-slots = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-tracing = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-crypto-hashing = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-crypto-hashing-proc-macro = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-ver = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-maybe-compressed-blob = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-core = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-state-machine = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-keystore = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-metadata-ir = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-statement-store = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-weights = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-io = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-runtime = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-inherents = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-transaction-pool = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-std = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-storage = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-panic-handler = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-debug-derive = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-blockchain = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-externalities = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-mixnet = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-trie = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +mangata-types = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-version = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-version-proc-macro = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-block-builder = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-keyring = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-staking = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-wasm-interface = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-transaction-storage-proof = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +extrinsic-shuffler = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-arithmetic = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-api-proc-macro = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-offchain = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-timestamp = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-application-crypto = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-rpc = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +ver-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-genesis-builder = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sp-session = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-consensus-grandpa = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-consensus = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-consensus-aura = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-consensus-slots = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-tracing = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-tracing-proc-macro = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-rpc-spec-v2 = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-state-db = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-proposer-metrics = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-keystore = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-basic-authorship-ver = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-rpc-server = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-network = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-network-bitswap = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-network-transactions = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-network-common = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-network-light = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-network-sync = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-informant = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-transaction-pool = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-transaction-pool-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-utils = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-cli = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-chain-spec = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-chain-spec-derive = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-block-builder-ver = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-mixnet = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-block-builder = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-allocator = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-network-gossip = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-client-db = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-client-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-sysinfo = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-executor = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-executor-wasmtime = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-executor-common = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-executor-polkavm = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-telemetry = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-offchain = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-service = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-rpc = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } +sc-rpc-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } diff --git a/pallets/market/rpc/src/lib.rs b/pallets/market/rpc/src/lib.rs index 206c0cd22..c5ae30981 100644 --- a/pallets/market/rpc/src/lib.rs +++ b/pallets/market/rpc/src/lib.rs @@ -25,6 +25,15 @@ pub trait MarketApi { at: Option, ) -> RpcResult; + #[method(name = "market_calculate_sell_price_with_impact")] + fn calculate_sell_price_with_impact( + &self, + pool_id: TokenId, + sell_asset_id: TokenId, + sell_amount: NumberOrHex, + at: Option, + ) -> RpcResult<(NumberOrHex, NumberOrHex)>; + #[method(name = "market_calculate_buy_price")] fn calculate_buy_price( &self, @@ -34,6 +43,15 @@ pub trait MarketApi { at: Option, ) -> RpcResult; + #[method(name = "market_calculate_buy_price_with_impact")] + fn calculate_buy_price_with_impact( + &self, + pool_id: TokenId, + buy_asset_id: TokenId, + buy_amount: NumberOrHex, + at: Option, + ) -> RpcResult<(NumberOrHex, NumberOrHex)>; + #[method(name = "market_calculate_expected_amount_for_minting")] fn calculate_expected_amount_for_minting( &self, @@ -130,6 +148,27 @@ where }) } + fn calculate_sell_price_with_impact( + &self, + pool_id: TokenId, + sell_asset_id: TokenId, + sell_amount: NumberOrHex, + _at: Option<::Hash>, + ) -> RpcResult<(NumberOrHex, NumberOrHex)> { + let api = self.client.runtime_api(); + let at = self.client.info().best_hash; + + api.calculate_sell_price_with_impact( + at, + pool_id, + sell_asset_id, + sell_amount.try_into_balance()?, + ) + .map(|val| val.unwrap_or_default()) + .map(|val| (val.0.into(), val.1.into())) + .map_err(|e| ErrorObject::owned(1, "Unable to serve the request", Some(format!("{:?}", e)))) + } + fn calculate_buy_price( &self, pool_id: TokenId, @@ -147,6 +186,27 @@ where }) } + fn calculate_buy_price_with_impact( + &self, + pool_id: TokenId, + buy_asset_id: TokenId, + buy_amount: NumberOrHex, + _at: Option<::Hash>, + ) -> RpcResult<(NumberOrHex, NumberOrHex)> { + let api = self.client.runtime_api(); + let at = self.client.info().best_hash; + + api.calculate_buy_price_with_impact( + at, + pool_id, + buy_asset_id, + buy_amount.try_into_balance()?, + ) + .map(|val| val.unwrap_or_default()) + .map(|val| (val.0.into(), val.1.into())) + .map_err(|e| ErrorObject::owned(1, "Unable to serve the request", Some(format!("{:?}", e)))) + } + fn get_burn_amount( &self, pool_id: TokenId, diff --git a/pallets/market/src/lib.rs b/pallets/market/src/lib.rs index 358896cd9..cac14017a 100644 --- a/pallets/market/src/lib.rs +++ b/pallets/market/src/lib.rs @@ -7,7 +7,7 @@ use codec::Codec; use serde::{Deserialize, Serialize}; use frame_support::{ - ensure, fail, + ensure, pallet_prelude::*, traits::{ tokens::{ @@ -259,6 +259,7 @@ pub mod pallet { #[pallet::call] impl Pallet { /// Creates a liquidity pool and an associated new `lp_token` asset + /// For a StableSwap pool, the "stable" rate is computed from the ratio of input amounts, max rate is 1e18:1 #[pallet::call_index(0)] #[pallet::weight( T::WeightInfo::create_pool_xyk().max( @@ -293,15 +294,12 @@ pub mod pallet { lp_token }, PoolKind::StableSwap => { - let first_decimal = Self::get_decimals(&first_asset_id)?; - let second_decimal = Self::get_decimals(&second_asset_id)?; - let lp_token = T::StableSwap::create_pool( &sender, first_asset_id, - first_decimal, + first_asset_amount, second_asset_id, - second_decimal, + second_asset_amount, )?; T::StableSwap::add_liquidity( @@ -649,15 +647,16 @@ pub mod pallet { /// Executes a multiswap asset in a series of swap asset atomic swaps. /// /// Multiswaps must fee lock instead of paying transaction fees. + /// For a single atomic swap, both `asset_amount_in` and `min_amount_out` are considered to allow free execution without locks. /// /// # Args: /// - `swap_token_list` - This list of tokens is the route of the atomic swaps, starting with the asset sold and ends with the asset finally bought /// - `asset_id_in`: The id of the asset sold /// - `asset_amount_in`: The amount of the asset sold /// - `asset_id_out`: The id of the asset received - /// - `min_amount_out` - The minimum amount of requested asset that must be bought in order to not fail on slippage. Slippage failures still charge exchange commission. - // This call is part of the fee lock mechanism, which allows free execution in some cases - // in case of an error a 'trade fee' is subtracted from input swap asset to avoid DOS attacks + /// - `min_amount_out` - The minimum amount of requested asset that must be bought in order to not fail on slippage, use RPC calls to calc expected value + // This call is part of the fee lock mechanism, which allows free execution on success + // in case of an error & no native asset to cover fees, a fixed % is subtracted from input swap asset to avoid DOS attacks // `OnChargeTransaction` impl should check whether the sender has funds to cover such fee // or consider transaction invalid #[pallet::call_index(6)] @@ -693,7 +692,22 @@ pub mod pallet { Ok(Pays::No.into()) } - /// Buy variant of the multiswap, a precise output amount should be provided instead. + /// Executes a multiswap asset in a series of swap asset atomic swaps. + /// The precise output amount is provided instead. + /// + /// Multiswaps must fee lock instead of paying transaction fees. + /// For a single atomic swap, both `asset_amount_out` and `max_amount_in` are considered to allow free execution without locks. + /// + /// # Args: + /// - `swap_token_list` - This list of tokens is the route of the atomic swaps, starting with the asset sold and ends with the asset finally bought + /// - `asset_id_out`: The id of the asset received + /// - `asset_amount_out`: The amount of the asset received + /// - `asset_id_in`: The id of the asset sold + /// - `max_amount_in` - The maximum amount of sold asset in order to not fail on slippage, use RPC calls to calc expected value + // This call is part of the fee lock mechanism, which allows free execution on success + // in case of an error & no native asset to cover fees, a fixed % is subtracted from input swap asset to avoid DOS attacks + // `OnChargeTransaction` impl should check whether the sender has funds to cover such fee + // or consider transaction invalid #[pallet::call_index(7)] #[pallet::weight( T::WeightInfo::multiswap_asset_buy_xyk(swap_pool_list.len() as u32).max( @@ -753,6 +767,21 @@ pub mod pallet { } } + pub fn calculate_sell_price_with_impact( + pool_id: T::CurrencyId, + sell_asset_id: T::CurrencyId, + sell_amount: T::Balance, + ) -> Option<(T::Balance, T::Balance)> { + let pool_info = Self::get_pool_info(pool_id).ok()?; + let (_, other) = pool_info.same_and_other(sell_asset_id)?; + match pool_info.kind { + PoolKind::Xyk => + T::Xyk::get_dy_with_impact(pool_id, sell_asset_id, other, sell_amount), + PoolKind::StableSwap => + T::StableSwap::get_dy_with_impact(pool_id, sell_asset_id, other, sell_amount), + } + } + pub fn calculate_buy_price( pool_id: T::CurrencyId, bought_asset_id: T::CurrencyId, @@ -767,6 +796,21 @@ pub mod pallet { } } + pub fn calculate_buy_price_with_impact( + pool_id: T::CurrencyId, + bought_asset_id: T::CurrencyId, + buy_amount: T::Balance, + ) -> Option<(T::Balance, T::Balance)> { + let pool_info = Self::get_pool_info(pool_id).ok()?; + let (_, other) = pool_info.same_and_other(bought_asset_id)?; + match pool_info.kind { + PoolKind::Xyk => + T::Xyk::get_dx_with_impact(pool_id, other, bought_asset_id, buy_amount), + PoolKind::StableSwap => + T::StableSwap::get_dx_with_impact(pool_id, other, bought_asset_id, buy_amount), + } + } + pub fn get_burn_amount( pool_id: T::CurrencyId, lp_burn_amount: T::Balance, @@ -1029,12 +1073,24 @@ sp_api::decl_runtime_apis! { sell_amount: Balance ) -> Option; + fn calculate_sell_price_with_impact( + pool_id: AssetId, + sell_asset_id: AssetId, + sell_amount: Balance + ) -> Option<(Balance, Balance)>; + fn calculate_buy_price( pool_id: AssetId, buy_asset_id: AssetId, buy_amount: Balance ) -> Option; + fn calculate_buy_price_with_impact( + pool_id: AssetId, + buy_asset_id: AssetId, + buy_amount: Balance + ) -> Option<(Balance, Balance)>; + fn get_burn_amount( pool_id: AssetId, lp_burn_amount: Balance, diff --git a/pallets/stable-swap/src/lib.rs b/pallets/stable-swap/src/lib.rs index 1b6136eba..820a1210b 100644 --- a/pallets/stable-swap/src/lib.rs +++ b/pallets/stable-swap/src/lib.rs @@ -139,6 +139,8 @@ pub mod pallet { pub enum Error { /// Amplification coefficient lower then 1 or too large AmpCoeffOutOfRange, + /// Initial pool rate multipliers are too large + InitialPoolRateOutOfRange, /// Too many assets for pool creation TooManyAssets, /// Pool already exists @@ -277,6 +279,8 @@ pub mod pallet { /// /// * `assets` - An array of asset ids in pool /// * `rates` - An array of: [10 ** (36 - _coins[n].decimals()), ... for n in range(N_COINS)] + /// A custom rate can also be used & values needs to be multiplied by 1e18, with max value of 1e36 + /// eg. for a rate 2:1 it's [2e18, 1e18] /// * `amp_coeff` - Amplification co-efficient - a lower value here means less tolerance for imbalance within the pool's assets. /// Suggested values include: /// * Uncollateralized algorithmic stablecoins: 5-10 @@ -534,7 +538,8 @@ pub mod pallet { impl Pallet { pub const FEE_DENOMINATOR: u128 = 10_u128.pow(10); - const PRECISION: u128 = 10_u128.pow(18); + pub(crate) const PRECISION_EXP: u32 = 18; + const PRECISION: u128 = 10_u128.pow(Self::PRECISION_EXP); const A_PRECISION: u128 = 100; // calls impl @@ -884,45 +889,32 @@ pub mod pallet { let i = pool.get_asset_index::(asset_in)?; let j = pool.get_asset_index::(asset_out)?; - let (_, d) = Self::get_invariant_pool(&pool_account, &pool)?; + Self::get_dx_xp(&pool, i, j, dy, xp) + } - let mut x = xp[i]; - let mut y = xp[j]; - for _i in 0..255 { - let x_prev = x; - let dyn_fee = Self::dynamic_fee( - &Self::checked_add_div_2(&xp[i], &x)?, - &Self::checked_add_div_2(&xp[j], &y)?, - )?; - let dy_fee = Self::checked_mul_div_u128( - &T::HigherPrecisionBalance::from(dy), - &T::HigherPrecisionBalance::from(pool.rate_multipliers[j]), - Self::PRECISION, - )? - .checked_add(&One::one()) - .ok_or(Error::::MathOverflow)? - .checked_mul(&T::HigherPrecisionBalance::from(Self::FEE_DENOMINATOR)) - .ok_or(Error::::MathOverflow)? - .checked_div( - &T::HigherPrecisionBalance::from(Self::FEE_DENOMINATOR) - .checked_sub(&dyn_fee) - .ok_or(Error::::MathOverflow)?, - ) - .ok_or(Error::::MathOverflow)?; + pub fn get_dx_with_impact( + pool_id: &PoolIdOf, + asset_in: T::CurrencyId, + asset_out: T::CurrencyId, + dy: T::Balance, + ) -> Result<(T::Balance, T::Balance), Error> { + let maybe_pool = Pools::::get(pool_id.clone()); + let pool = maybe_pool.as_ref().ok_or(Error::::NoSuchPool)?; + let pool_account = Self::get_pool_account(&pool_id); + let (reserves, xp) = Self::get_balances_xp_pool(&pool_account, &pool)?; + let i = pool.get_asset_index::(asset_in)?; + let j = pool.get_asset_index::(asset_out)?; - y = xp[j].checked_sub(&dy_fee).ok_or(Error::::MathOverflow)?; - x = Self::get_y(j, i, &y, &xp, pool.amp_coeff, &d)?; + let dx = Self::get_dx_xp(&pool, i, j, dy, xp)?; - // if we don't have dynamic fee we can return immediatelly, otherwise loop with adjusted fee - if !Self::has_dynamic_fee() || Self::check_diff_le_one(&x, &x_prev) { - return Ok(Self::checked_mul_div_to_balance( - &x.checked_sub(&xp[i]).ok_or(Error::::MathOverflow)?, - pool.rate_multipliers[i], - )?); - } - } + let mut reserves = reserves.clone(); + reserves[i] = reserves[i] + T::HigherPrecisionBalance::from(dx); + reserves[j] = reserves[j] - T::HigherPrecisionBalance::from(dy); + let xp = Self::xp(&pool.rate_multipliers, &reserves)?; - Err(Error::::UnexpectedFailure) + let dx2 = Self::get_dx_xp(&pool, i, j, dy, xp)?; + + Ok((dx, dx2)) } /// Calculate the output dy given input dx. @@ -939,19 +931,32 @@ pub mod pallet { let i = pool.get_asset_index::(asset_in)?; let j = pool.get_asset_index::(asset_out)?; - let (dy, dy_fee) = Self::calc_dy( - i, - j, - T::HigherPrecisionBalance::from(dx), - pool.amp_coeff, - &xp, - pool.rate_multipliers.to_vec(), - )?; + Self::get_dy_xp(&pool, i, j, dx, xp) + } - Self::checked_mul_div_to_balance( - &dy.checked_sub(&dy_fee).ok_or(Error::::MathOverflow)?, - pool.rate_multipliers[j], - ) + pub fn get_dy_with_impact( + pool_id: &PoolIdOf, + asset_in: T::CurrencyId, + asset_out: T::CurrencyId, + dx: T::Balance, + ) -> Result<(T::Balance, T::Balance), Error> { + let maybe_pool = Pools::::get(pool_id.clone()); + let pool = maybe_pool.as_ref().ok_or(Error::::NoSuchPool)?; + let pool_account = Self::get_pool_account(&pool_id); + let (reserves, xp) = Self::get_balances_xp_pool(&pool_account, &pool)?; + let i = pool.get_asset_index::(asset_in)?; + let j = pool.get_asset_index::(asset_out)?; + + let dy = Self::get_dy_xp(&pool, i, j, dx, xp)?; + + let mut reserves = reserves.clone(); + reserves[i] = reserves[i] + T::HigherPrecisionBalance::from(dx); + reserves[j] = reserves[j] - T::HigherPrecisionBalance::from(dy); + let xp = Self::xp(&pool.rate_multipliers, &reserves)?; + + let dy2 = Self::get_dy_xp(&pool, i, j, dx, xp)?; + + Ok((dy, dy2)) } pub fn calc_lp_token_amount( @@ -1184,6 +1189,76 @@ pub mod pallet { Ok(xp) } + pub fn get_dx_xp( + pool: &PoolInfoOf, + i: usize, + j: usize, + dy: T::Balance, + xp: Vec, + ) -> Result> { + let d = Self::get_invariant(&xp, pool.amp_coeff)?; + + let mut x = xp[i]; + let mut y = xp[j]; + for _i in 0..255 { + let x_prev = x; + let dyn_fee = Self::dynamic_fee( + &Self::checked_add_div_2(&xp[i], &x)?, + &Self::checked_add_div_2(&xp[j], &y)?, + )?; + let dy_fee = Self::checked_mul_div_u128( + &T::HigherPrecisionBalance::from(dy), + &T::HigherPrecisionBalance::from(pool.rate_multipliers[j]), + Self::PRECISION, + )? + .checked_add(&One::one()) + .ok_or(Error::::MathOverflow)? + .checked_mul(&T::HigherPrecisionBalance::from(Self::FEE_DENOMINATOR)) + .ok_or(Error::::MathOverflow)? + .checked_div( + &T::HigherPrecisionBalance::from(Self::FEE_DENOMINATOR) + .checked_sub(&dyn_fee) + .ok_or(Error::::MathOverflow)?, + ) + .ok_or(Error::::MathOverflow)?; + + y = xp[j].checked_sub(&dy_fee).ok_or(Error::::MathOverflow)?; + x = Self::get_y(j, i, &y, &xp, pool.amp_coeff, &d)?; + + // if we don't have dynamic fee we can return immediatelly, otherwise loop with adjusted fee + if !Self::has_dynamic_fee() || Self::check_diff_le_one(&x, &x_prev) { + return Ok(Self::checked_mul_div_to_balance( + &x.checked_sub(&xp[i]).ok_or(Error::::MathOverflow)?, + pool.rate_multipliers[i], + )?); + } + } + + Err(Error::::UnexpectedFailure) + } + + fn get_dy_xp( + pool: &PoolInfoOf, + i: usize, + j: usize, + dx: T::Balance, + xp: Vec, + ) -> Result> { + let (dy, dy_fee) = Self::calc_dy( + i, + j, + T::HigherPrecisionBalance::from(dx), + pool.amp_coeff, + &xp, + pool.rate_multipliers.to_vec(), + )?; + + Self::checked_mul_div_to_balance( + &dy.checked_sub(&dy_fee).ok_or(Error::::MathOverflow)?, + pool.rate_multipliers[j], + ) + } + /// Computes the Stable Swap invariant (D). /// /// The invariant is defined as follows: @@ -1620,14 +1695,6 @@ pub mod pallet { } return false; } - - // 10 ** (36 - _coins[n].decimals()) - pub(crate) fn get_decimals_mul(asset_decimals: u32) -> Result> { - let m = (36_u32 - asset_decimals) - .try_into() - .map_err(|_| Error::::UnexpectedFailure)?; - checked_pow(T::Balance::from(10_u32), m).ok_or(Error::::MathOverflow) - } } } @@ -1662,6 +1729,15 @@ impl Inspect for Pallet { Self::get_dy(&pool_id, asset_in, asset_out, dx).ok() } + fn get_dy_with_impact( + pool_id: Self::CurrencyId, + asset_in: Self::CurrencyId, + asset_out: Self::CurrencyId, + dx: Self::Balance, + ) -> Option<(Self::Balance, Self::Balance)> { + Self::get_dy_with_impact(&pool_id, asset_in, asset_out, dx).ok() + } + fn get_dx( pool_id: Self::CurrencyId, asset_in: Self::CurrencyId, @@ -1671,6 +1747,15 @@ impl Inspect for Pallet { Self::get_dx(&pool_id, asset_in, asset_out, dy).ok() } + fn get_dx_with_impact( + pool_id: Self::CurrencyId, + asset_in: Self::CurrencyId, + asset_out: Self::CurrencyId, + dy: Self::Balance, + ) -> Option<(Self::Balance, Self::Balance)> { + Self::get_dx_with_impact(&pool_id, asset_in, asset_out, dy).ok() + } + fn get_burn_amounts( pool_id: Self::CurrencyId, lp_burn_amount: Self::Balance, @@ -1702,13 +1787,40 @@ impl Mutate for Pallet { fn create_pool( sender: &T::AccountId, asset_1: Self::CurrencyId, - asset_1_decimals: u32, + amount_1: Self::Balance, asset_2: Self::CurrencyId, - asset_2_decimals: u32, + amount_2: Self::Balance, ) -> Result { let assets = vec![asset_1, asset_2]; - let rate_1 = Self::get_decimals_mul(asset_1_decimals)?; - let rate_2 = Self::get_decimals_mul(asset_2_decimals)?; + let ten = T::Balance::from(10_u32); + + let exp = |amount: Self::Balance| { + let mut i = 0_usize; + let mut pow_10 = T::Balance::one() * ten; + while amount % pow_10 == Zero::zero() { + i += 1; + pow_10 *= ten; + } + i + }; + + let exp1 = exp(amount_1); + let exp2 = exp(amount_2); + let min = exp1.min(exp2); + let exp = checked_pow(ten, min).ok_or(Error::::MathOverflow)?; + + let rate_1_mul = amount_1 / exp; + let rate_2_mul = amount_2 / exp; + + // the max rate cannot be more than 1e18 + let precision = + checked_pow(ten, Self::PRECISION_EXP as usize).ok_or(Error::::MathOverflow)?; + ensure!(rate_1_mul <= precision, Error::::InitialPoolRateOutOfRange); + ensure!(rate_2_mul <= precision, Error::::InitialPoolRateOutOfRange); + + let rate_1 = rate_2_mul.checked_mul(&precision).ok_or(Error::::MathOverflow)?; + let rate_2 = rate_1_mul.checked_mul(&precision).ok_or(Error::::MathOverflow)?; + let rates = vec![rate_1, rate_2]; let info = Self::do_create_pool(sender, assets, rates, T::DefaultApmCoeff::get())?; Ok(info.lp_token) diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 1e1607770..6ec7eca32 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -3725,6 +3725,20 @@ impl Inspect for Pallet { Self::calculate_sell_price_id(asset_in, asset_out, dx).ok() } + fn get_dy_with_impact( + _: Self::CurrencyId, + asset_in: Self::CurrencyId, + asset_out: Self::CurrencyId, + dx: Self::Balance, + ) -> Option<(Self::Balance, Self::Balance)> { + let mut reserves = Self::get_reserves(asset_in, asset_out).ok()?; + let dy = Self::calculate_sell_price(reserves.0, reserves.1, dx).ok()?; + reserves.0 = reserves.0 + dx; + reserves.1 = reserves.1 - dy; + let dy2 = Self::calculate_sell_price(reserves.0, reserves.1, dx).ok()?; + Some((dy, dy2)) + } + fn get_dx( _: Self::CurrencyId, asset_in: Self::CurrencyId, @@ -3734,6 +3748,20 @@ impl Inspect for Pallet { Self::calculate_buy_price_id(asset_in, asset_out, dy).ok() } + fn get_dx_with_impact( + _: Self::CurrencyId, + asset_in: Self::CurrencyId, + asset_out: Self::CurrencyId, + dy: Self::Balance, + ) -> Option<(Self::Balance, Self::Balance)> { + let mut reserves = Self::get_reserves(asset_in, asset_out).ok()?; + let dx = Self::calculate_buy_price(reserves.0, reserves.1, dy).ok()?; + reserves.0 = reserves.0 + dx; + reserves.1 = reserves.1 - dy; + let dx2 = Self::calculate_buy_price(reserves.0, reserves.1, dy).ok()?; + Some((dx, dx2)) + } + fn get_burn_amounts( pool_id: Self::CurrencyId, lp_burn_amount: Self::Balance, diff --git a/rollup/runtime/integration-test/Cargo.toml b/rollup/runtime/integration-test/Cargo.toml index f0403e144..aad3c456d 100644 --- a/rollup/runtime/integration-test/Cargo.toml +++ b/rollup/runtime/integration-test/Cargo.toml @@ -40,6 +40,7 @@ pallet-proof-of-stake = { path = "../../../pallets/proof-of-stake" } pallet-rolldown = { path = "../../../pallets/rolldown" } pallet-sudo-origin = { path = "../../../pallets/sudo-origin" } pallet-xyk = { path = "../../../pallets/xyk" } +pallet-stable-swap = { path = "../../../pallets/stable-swap" } parachain-staking = { path = "../../../pallets/parachain-staking" } rolldown-runtime-api = { path = "../../../pallets/rolldown/runtime-api" } rollup-runtime = { path = "../" } diff --git a/rollup/runtime/integration-test/src/market.rs b/rollup/runtime/integration-test/src/market.rs index d5236786f..e0cc3c334 100644 --- a/rollup/runtime/integration-test/src/market.rs +++ b/rollup/runtime/integration-test/src/market.rs @@ -6,10 +6,7 @@ use sp_runtime::{traits::Zero, DispatchResult}; const ASSET_ID_1: u32 = NATIVE_ASSET_ID + 1; const ASSET_ID_2: u32 = ASSET_ID_1 + 1; const ASSET_ID_3: u32 = ASSET_ID_2 + 1; -const ASSET_ID_4_DISABLED: u32 = ASSET_ID_3 + 1; -const ASSET_ID_5: u32 = ASSET_ID_4_DISABLED + 1; -const ASSET_ID_6: u32 = ASSET_ID_5 + 1; -const POOL_ID_1: u32 = ASSET_ID_6 + 1; +const POOL_ID_1: u32 = ASSET_ID_3 + 1; const POOL_ID_2: u32 = POOL_ID_1 + 1; const POOL_ID_3: u32 = POOL_ID_2 + 1; @@ -20,84 +17,6 @@ fn test_env() -> TestExternalities { (AccountId::from(ALICE), ASSET_ID_1, 100 * UNIT), (AccountId::from(ALICE), ASSET_ID_2, 100 * UNIT), (AccountId::from(ALICE), ASSET_ID_3, 100 * UNIT), - (AccountId::from(ALICE), ASSET_ID_4_DISABLED, 100 * UNIT), - (AccountId::from(ALICE), ASSET_ID_5, 100 * UNIT), - (AccountId::from(ALICE), ASSET_ID_6, 100 * UNIT), - ], - assets: vec![ - ( - NATIVE_ASSET_ID, - AssetMetadataOf { - decimals: 18, - name: BoundedVec::truncate_from(b"Asset".to_vec()), - symbol: BoundedVec::truncate_from(b"Asset".to_vec()), - existential_deposit: Default::default(), - additional: Default::default(), - }, - ), - ( - ASSET_ID_1, - AssetMetadataOf { - decimals: 18, - name: BoundedVec::truncate_from(b"Asset".to_vec()), - symbol: BoundedVec::truncate_from(b"Asset".to_vec()), - existential_deposit: Default::default(), - additional: Default::default(), - }, - ), - ( - ASSET_ID_2, - AssetMetadataOf { - decimals: 18, - name: BoundedVec::truncate_from(b"Asset".to_vec()), - symbol: BoundedVec::truncate_from(b"Asset".to_vec()), - existential_deposit: Default::default(), - additional: Default::default(), - }, - ), - ( - ASSET_ID_3, - AssetMetadataOf { - decimals: 18, - name: BoundedVec::truncate_from(b"Asset".to_vec()), - symbol: BoundedVec::truncate_from(b"Asset".to_vec()), - existential_deposit: Default::default(), - additional: Default::default(), - }, - ), - ( - ASSET_ID_4_DISABLED, - AssetMetadataOf { - decimals: 18, - name: BoundedVec::truncate_from(b"Asset".to_vec()), - symbol: BoundedVec::truncate_from(b"Asset".to_vec()), - existential_deposit: Default::default(), - additional: CustomMetadata { - xyk: Some(XykMetadata { operations_disabled: true }), - ..CustomMetadata::default() - }, - }, - ), - ( - ASSET_ID_5, - AssetMetadataOf { - decimals: 10, - name: BoundedVec::truncate_from(b"Asset".to_vec()), - symbol: BoundedVec::truncate_from(b"Asset".to_vec()), - existential_deposit: Default::default(), - additional: Default::default(), - }, - ), - ( - ASSET_ID_6, - AssetMetadataOf { - decimals: 12, - name: BoundedVec::truncate_from(b"Asset".to_vec()), - symbol: BoundedVec::truncate_from(b"Asset".to_vec()), - existential_deposit: Default::default(), - additional: Default::default(), - }, - ), ], ..ExtBuilder::default() } @@ -111,6 +30,10 @@ fn origin() -> RuntimeOrigin { } fn create_pool(kind: PoolKind, assets: (u32, u32)) -> DispatchResult { + Market::create_pool(origin(), kind, assets.0, 10 * UNIT, assets.1, 10 * UNIT) +} + +fn create_pool_unb(kind: PoolKind, assets: (u32, u32)) -> DispatchResult { Market::create_pool(origin(), kind, assets.0, 10 * UNIT, assets.1, 5 * UNIT) } @@ -138,13 +61,17 @@ fn create_pool_works() { System::assert_has_event(RuntimeEvent::Market(Event::LiquidityMinted { who: AccountId::from(ALICE), pool_id: POOL_ID_1, - amounts_provided: (10000000000000000000, 5000000000000000000), + amounts_provided: (10000000000000000000, 10000000000000000000), lp_token: POOL_ID_1, - lp_token_minted: 7500000000000000000, - total_supply: 7500000000000000000, + lp_token_minted: 10000000000000000000, + total_supply: 10000000000000000000, })); assert_ok!(create_pool(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); + + let p = pallet_stable_swap::Pools::::get(POOL_ID_2).unwrap(); + assert_eq!(p.rate_multipliers[0], UNIT); + assert_eq!(p.rate_multipliers[1], UNIT); System::assert_has_event(RuntimeEvent::Market(Event::PoolCreated { creator: AccountId::from(ALICE), pool_id: POOL_ID_2, @@ -154,10 +81,33 @@ fn create_pool_works() { System::assert_has_event(RuntimeEvent::Market(Event::LiquidityMinted { who: AccountId::from(ALICE), pool_id: POOL_ID_2, - amounts_provided: (10000000000000000000, 5000000000000000000), + amounts_provided: (10000000000000000000, 10000000000000000000), lp_token: POOL_ID_2, - lp_token_minted: 14999063611862273044, - total_supply: 14999063611862273044, + lp_token_minted: 20000000000000000000, + total_supply: 20000000000000000000, + })); + + assert_ok!(create_pool_unb(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); + + let p = pallet_stable_swap::Pools::::get(POOL_ID_3).unwrap(); + println!("{:?}", p); + assert_eq!(p.rate_multipliers[0], 5 * UNIT); + assert_eq!(p.rate_multipliers[1], 10 * UNIT); + + System::assert_has_event(RuntimeEvent::Market(Event::PoolCreated { + creator: AccountId::from(ALICE), + pool_id: POOL_ID_3, + lp_token: POOL_ID_3, + assets: (0, 1), + })); + // lp_token_minted are correct since we applied the rates, and the pool is balanced + System::assert_has_event(RuntimeEvent::Market(Event::LiquidityMinted { + who: AccountId::from(ALICE), + pool_id: POOL_ID_3, + amounts_provided: (10000000000000000000, 5000000000000000000), + lp_token: POOL_ID_3, + lp_token_minted: 100000000000000000000, + total_supply: 100000000000000000000, })); }) } @@ -165,8 +115,8 @@ fn create_pool_works() { #[test] fn add_liquidity_works() { test_env().execute_with(|| { - assert_ok!(create_pool(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); - assert_ok!(create_pool(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); let expected = Market::calculate_expected_amount_for_minting(POOL_ID_1, NATIVE_ASSET_ID, UNIT) @@ -195,7 +145,7 @@ fn add_liquidity_works() { amounts_provided: (1000000000000000000, expected), lp_token: POOL_ID_2, lp_token_minted: lp_expected, - total_supply: 16998182477145509576, + total_supply: 114992390693470089383, })); }) } @@ -203,8 +153,8 @@ fn add_liquidity_works() { #[test] fn add_liquidity_fixed_works() { test_env().execute_with(|| { - assert_ok!(create_pool(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); - assert_ok!(create_pool(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); assert_ok!(Market::mint_liquidity_fixed_amounts(origin(), POOL_ID_1, (UNIT, 0), 0)); System::assert_last_event(RuntimeEvent::Market(Event::LiquidityMinted { @@ -224,7 +174,7 @@ fn add_liquidity_fixed_works() { amounts_provided: (1000000000000000000, 5000000000000000000), lp_token: POOL_ID_2, lp_token_minted: expected, - total_supply: 20990943480975169792, + total_supply: 154925100814226884776, })); }) } @@ -232,8 +182,8 @@ fn add_liquidity_fixed_works() { #[test] fn remove_liquidity_works() { test_env().execute_with(|| { - assert_ok!(create_pool(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); - assert_ok!(create_pool(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); assert_ok!(Market::burn_liquidity(origin(), POOL_ID_1, UNIT, 0, 0)); System::assert_last_event(RuntimeEvent::Market(Event::LiquidityBurned { @@ -248,9 +198,9 @@ fn remove_liquidity_works() { System::assert_last_event(RuntimeEvent::Market(Event::LiquidityBurned { who: AccountId::from(ALICE), pool_id: POOL_ID_2, - amounts: (666708286515387818, 333354143257693909), + amounts: (100000000000000000, 50000000000000000), burned_amount: 1000000000000000000, - total_supply: 13999063611862273044, + total_supply: 99000000000000000000, })); }) } @@ -258,9 +208,9 @@ fn remove_liquidity_works() { #[test] fn multiswap_should_work_xyk() { test_env().execute_with(|| { - assert_ok!(create_pool(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); - assert_ok!(create_pool(PoolKind::Xyk, (ASSET_ID_1, ASSET_ID_2))); - assert_ok!(create_pool(PoolKind::Xyk, (ASSET_ID_2, ASSET_ID_3))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (ASSET_ID_1, ASSET_ID_2))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (ASSET_ID_2, ASSET_ID_3))); assert_ok!(Market::multiswap_asset( origin(), @@ -308,13 +258,15 @@ fn multiswap_should_work_xyk() { #[test] fn multiswap_should_work_stable_swap_with_bnb() { test_env().execute_with(|| { - assert_ok!(create_pool(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); - assert_ok!(create_pool(PoolKind::StableSwap, (ASSET_ID_1, ASSET_ID_2))); + // 2:1 rate + assert_ok!(create_pool_unb(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::StableSwap, (ASSET_ID_1, ASSET_ID_2))); + // 1:1 rate assert_ok!(create_pool(PoolKind::StableSwap, (ASSET_ID_2, ASSET_ID_3))); // for bnb - assert_ok!(create_pool(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); - assert_ok!(create_pool(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_2))); - assert_ok!(create_pool(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_3))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_2))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_3))); let before = Tokens::total_issuance(NATIVE_ASSET_ID); @@ -331,7 +283,7 @@ fn multiswap_should_work_stable_swap_with_bnb() { // issuance decreased because of bnb assert!(before > after); assert_eq!(before, 100000000000000000000); - assert_eq!(after, 99996758378067624442); + assert_eq!(after, 99999001734203514767); println!("{:#?}", events()); @@ -344,23 +296,23 @@ fn multiswap_should_work_stable_swap_with_bnb() { asset_in: 0, asset_out: 1, amount_in: 1000000000000000000, - amount_out: 995595345298031754, + amount_out: 498447826003559573, }, AtomicSwap { pool_id: POOL_ID_2, kind: PoolKind::StableSwap, asset_in: 1, asset_out: 2, - amount_in: 995595345298031754, - amount_out: 991212132384121611, + amount_in: 498447826003559573, + amount_out: 248463606016707341, }, AtomicSwap { pool_id: POOL_ID_3, kind: PoolKind::StableSwap, asset_in: 2, asset_out: 3, - amount_in: 991212132384121611, - amount_out: 986850235267668399, + amount_in: 248463606016707341, + amount_out: 247712005295675461, }, ], })); @@ -370,9 +322,9 @@ fn multiswap_should_work_stable_swap_with_bnb() { #[test] fn multiswap_should_work_mixed() { test_env().execute_with(|| { - assert_ok!(create_pool(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); - assert_ok!(create_pool(PoolKind::StableSwap, (ASSET_ID_1, ASSET_ID_2))); - assert_ok!(create_pool(PoolKind::Xyk, (ASSET_ID_2, ASSET_ID_3))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::StableSwap, (ASSET_ID_1, ASSET_ID_2))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (ASSET_ID_2, ASSET_ID_3))); assert_ok!(Market::multiswap_asset( origin(), @@ -402,62 +354,17 @@ fn multiswap_should_work_mixed() { asset_in: 1, asset_out: 2, amount_in: 453305446940074565, - amount_out: 451412806019623895, + amount_out: 225962336828316482, }, AtomicSwap { pool_id: POOL_ID_3, kind: PoolKind::Xyk, asset_in: 2, asset_out: 3, - amount_in: 451412806019623895, - amount_out: 215337820687860400, + amount_in: 225962336828316482, + amount_out: 110160480582936294, }, ], })); }) } - -#[test] -fn test_diff_decimals_work() { - test_env().execute_with(|| { - let unit10 = 10_000_000_000_u128; - let unit12 = 1_000_000_000_000_u128; - assert_ok!(Market::create_pool( - origin(), - PoolKind::StableSwap, - ASSET_ID_5, - 100 * unit10, - ASSET_ID_6, - 100 * unit12 - )); - - let pool = Market::get_pools(Some(POOL_ID_1)); - let price = Market::calculate_sell_price(POOL_ID_1, ASSET_ID_5, 1).unwrap(); - - println!("{:#?}", pool); - println!("{:#?}", price); - - assert_ok!(Market::multiswap_asset( - origin(), - vec![POOL_ID_1], - ASSET_ID_5, - 1, - ASSET_ID_6, - 1, - )); - - println!("{:#?}", events()); - - System::assert_last_event(RuntimeEvent::Market(Event::AssetsSwapped { - who: AccountId::from(ALICE), - swaps: vec![AtomicSwap { - pool_id: POOL_ID_1, - kind: PoolKind::StableSwap, - asset_in: ASSET_ID_5, - asset_out: ASSET_ID_6, - amount_in: 1, - amount_out: 99, - }], - })); - }) -} diff --git a/rollup/runtime/src/lib.rs b/rollup/runtime/src/lib.rs index 50aa5e2eb..8b2e78389 100644 --- a/rollup/runtime/src/lib.rs +++ b/rollup/runtime/src/lib.rs @@ -428,6 +428,19 @@ impl Into for RuntimeCall { asset_id_out, asset_amount_out: min_amount_out, }, + RuntimeCall::Market(pallet_market::Call::multiswap_asset_buy { + swap_pool_list, + asset_id_out, + asset_amount_out, + asset_id_in, + max_amount_in, + }) => CallType::Swap { + swap_pool_list, + asset_id_in, + asset_amount_in: max_amount_in, + asset_id_out, + asset_amount_out, + }, RuntimeCall::FeeLock(pallet_fee_lock::Call::unlock_fee { .. }) => CallType::UnlockFee, _ => CallType::Other, } @@ -1314,10 +1327,18 @@ impl_runtime_apis! { Market::calculate_sell_price(pool_id, sell_asset_id, sell_amount) } + fn calculate_sell_price_with_impact(pool_id: TokenId, sell_asset_id: TokenId, sell_amount: Balance) -> Option<(Balance, Balance)> { + Market::calculate_sell_price_with_impact(pool_id, sell_asset_id, sell_amount) + } + fn calculate_buy_price(pool_id: TokenId, buy_asset_id: TokenId, buy_amount: Balance) -> Option { Market::calculate_buy_price(pool_id, buy_asset_id, buy_amount) } + fn calculate_buy_price_with_impact(pool_id: TokenId, buy_asset_id: TokenId, buy_amount: Balance) -> Option<(Balance, Balance)> { + Market::calculate_buy_price_with_impact(pool_id, buy_asset_id, buy_amount) + } + fn get_burn_amount(pool_id: TokenId, lp_burn_amount: Balance) -> Option<(Balance, Balance)> { Market::get_burn_amount(pool_id, lp_burn_amount) } From 07f2897124c5c591a94e42d87d5cc6d982562e9b Mon Sep 17 00:00:00 2001 From: Marian Vanderka Date: Fri, 29 Nov 2024 10:12:54 +0100 Subject: [PATCH 23/23] GASP-1625 Feature/locked tokens (#841) adds checks for non transferable tokens `--features=unlocked` removes such restrictions runtime cofing defines the native currency - `0` as non transferable token tokens all transfer calls, set_balance, mint extrinsics are checked market create, mint, burn are checked market swaps are allowed foundation members have veto over: market create_pool & burn --- Cargo.lock | 280 +++++++++--------- Cargo.toml | 134 --------- pallets/bootstrap/src/mock.rs | 1 + pallets/crowdloan-rewards/src/mock.rs | 1 + pallets/fee-lock/src/mock.rs | 3 +- pallets/issuance/src/mock.rs | 3 +- pallets/market/src/lib.rs | 71 ++++- pallets/market/src/mock.rs | 6 +- pallets/multipurpose-liquidity/src/mock.rs | 3 +- pallets/parachain-staking/src/mock.rs | 3 +- pallets/proof-of-stake/src/mock.rs | 1 + pallets/rolldown/src/mock.rs | 3 +- pallets/sequencer-staking/src/mock.rs | 3 +- pallets/stable-swap/Cargo.toml | 1 + pallets/stable-swap/src/lib.rs | 21 +- pallets/stable-swap/src/mock.rs | 2 + pallets/xyk/src/mock.rs | 1 + rollup/runtime/Cargo.toml | 5 +- rollup/runtime/integration-test/src/lib.rs | 1 + rollup/runtime/integration-test/src/market.rs | 51 ++-- .../integration-test/src/nontransfer.rs | 228 ++++++++++++++ rollup/runtime/src/lib.rs | 8 +- rollup/runtime/src/runtime_config.rs | 13 + 23 files changed, 519 insertions(+), 324 deletions(-) create mode 100644 rollup/runtime/integration-test/src/nontransfer.rs diff --git a/Cargo.lock b/Cargo.lock index 7c59cd4d0..b92aed867 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2421,7 +2421,7 @@ dependencies = [ [[package]] name = "extrinsic-shuffler" version = "4.0.0-dev" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "derive_more", "log", @@ -2604,7 +2604,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "12.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "parity-scale-codec", ] @@ -2627,7 +2627,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-support", "frame-support-procedural", @@ -2652,7 +2652,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "32.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "Inflector", "array-bytes 6.2.3", @@ -2706,7 +2706,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "aquamarine 0.3.3", "extrinsic-shuffler", @@ -2740,7 +2740,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.35.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#6661f2890fa822ae738bff9d8072438a270054cd" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "futures", "indicatif", @@ -2762,7 +2762,7 @@ dependencies = [ [[package]] name = "frame-support" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "aquamarine 0.5.0", "array-bytes 6.2.3", @@ -2804,7 +2804,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "23.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "Inflector", "cfg-expr", @@ -2823,7 +2823,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "10.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 3.2.0", @@ -2835,7 +2835,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "11.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "proc-macro2", "quote", @@ -2845,7 +2845,7 @@ dependencies = [ [[package]] name = "frame-system" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "cfg-if", "docify", @@ -2867,7 +2867,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-benchmarking", "frame-support", @@ -2882,7 +2882,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "26.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "parity-scale-codec", "sp-api", @@ -2891,7 +2891,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.34.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-support", "parity-scale-codec", @@ -4775,7 +4775,7 @@ dependencies = [ [[package]] name = "mangata-support" version = "0.1.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-support", "mangata-types", @@ -4788,7 +4788,7 @@ dependencies = [ [[package]] name = "mangata-types" version = "0.1.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "parity-scale-codec", "scale-info", @@ -5418,7 +5418,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "orml-asset-registry" version = "0.9.0" -source = "git+https://github.com/gasp-xyz/open-runtime-module-library?branch=eth-rollup-develop#75849a348e30c60e5b642f839774ee5a90ae7991" +source = "git+https://github.com/gasp-xyz/open-runtime-module-library?branch=eth-rollup-develop#0aef284df3c185168db3fbe5f1deb7ec3e643163" dependencies = [ "frame-benchmarking", "frame-support", @@ -5437,7 +5437,7 @@ dependencies = [ [[package]] name = "orml-tokens" version = "0.9.0" -source = "git+https://github.com/gasp-xyz/open-runtime-module-library?branch=eth-rollup-develop#75849a348e30c60e5b642f839774ee5a90ae7991" +source = "git+https://github.com/gasp-xyz/open-runtime-module-library?branch=eth-rollup-develop#0aef284df3c185168db3fbe5f1deb7ec3e643163" dependencies = [ "frame-benchmarking", "frame-support", @@ -5456,7 +5456,7 @@ dependencies = [ [[package]] name = "orml-traits" version = "0.9.0" -source = "git+https://github.com/gasp-xyz/open-runtime-module-library?branch=eth-rollup-develop#75849a348e30c60e5b642f839774ee5a90ae7991" +source = "git+https://github.com/gasp-xyz/open-runtime-module-library?branch=eth-rollup-develop#0aef284df3c185168db3fbe5f1deb7ec3e643163" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -5475,7 +5475,7 @@ dependencies = [ [[package]] name = "orml-utilities" version = "0.9.0" -source = "git+https://github.com/gasp-xyz/open-runtime-module-library?branch=eth-rollup-develop#75849a348e30c60e5b642f839774ee5a90ae7991" +source = "git+https://github.com/gasp-xyz/open-runtime-module-library?branch=eth-rollup-develop#0aef284df3c185168db3fbe5f1deb7ec3e643163" dependencies = [ "frame-support", "parity-scale-codec", @@ -5490,7 +5490,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "27.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-support", "frame-system", @@ -5507,7 +5507,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-support", "frame-system", @@ -5522,7 +5522,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-benchmarking", "frame-support", @@ -5546,7 +5546,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "docify", "frame-benchmarking", @@ -5594,7 +5594,7 @@ dependencies = [ [[package]] name = "pallet-collective-mangata" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-benchmarking", "frame-support", @@ -5665,7 +5665,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-benchmarking", "frame-support", @@ -5688,7 +5688,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5785,7 +5785,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-benchmarking", "frame-support", @@ -5887,7 +5887,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-benchmarking", "frame-support", @@ -5964,7 +5964,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-benchmarking", "frame-support", @@ -5991,6 +5991,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "mangata-support", "mangata-types", "orml-tokens", @@ -6008,7 +6009,7 @@ dependencies = [ [[package]] name = "pallet-sudo-mangata" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "docify", "frame-benchmarking", @@ -6042,7 +6043,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "27.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "docify", "frame-benchmarking", @@ -6062,7 +6063,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-support", "frame-system", @@ -6078,7 +6079,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "30.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -6094,7 +6095,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -6106,7 +6107,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "27.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "docify", "frame-benchmarking", @@ -6125,7 +6126,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-benchmarking", "frame-support", @@ -6141,7 +6142,7 @@ dependencies = [ [[package]] name = "pallet-utility-mangata" version = "4.0.0-dev" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-benchmarking", "frame-support", @@ -6157,7 +6158,7 @@ dependencies = [ [[package]] name = "pallet-vesting-mangata" version = "4.0.0-dev" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-benchmarking", "frame-support", @@ -7556,6 +7557,7 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", + "hex-literal 0.3.4", "log", "mangata-support", "mangata-types", @@ -7981,7 +7983,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "23.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "log", "sp-core", @@ -7992,7 +7994,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship-ver" version = "0.10.0-dev" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "aquamarine 0.3.3", "futures", @@ -8018,7 +8020,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.33.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "parity-scale-codec", "sp-api", @@ -8033,7 +8035,7 @@ dependencies = [ [[package]] name = "sc-block-builder-ver" version = "0.33.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "aquamarine 0.1.12", "extrinsic-shuffler", @@ -8053,7 +8055,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "27.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 6.2.3", "docify", @@ -8079,7 +8081,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "11.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", @@ -8090,7 +8092,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.36.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 6.2.3", "chrono", @@ -8131,7 +8133,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "fnv", "futures", @@ -8158,7 +8160,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.35.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "hash-db", "kvdb", @@ -8184,7 +8186,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.33.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "futures", @@ -8209,7 +8211,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.34.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "futures", @@ -8238,7 +8240,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.19.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "ahash 0.8.11", "array-bytes 6.2.3", @@ -8281,7 +8283,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.33.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "futures", @@ -8306,7 +8308,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.32.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", @@ -8329,7 +8331,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.29.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "polkavm", "sc-allocator", @@ -8342,7 +8344,7 @@ dependencies = [ [[package]] name = "sc-executor-polkavm" version = "0.29.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "log", "polkavm", @@ -8353,7 +8355,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.29.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "anyhow", "cfg-if", @@ -8371,7 +8373,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.33.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "ansi_term", "futures", @@ -8388,7 +8390,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "25.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 6.2.3", "parking_lot 0.12.3", @@ -8402,7 +8404,7 @@ dependencies = [ [[package]] name = "sc-mixnet" version = "0.4.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 4.2.0", "arrayvec 0.7.6", @@ -8431,7 +8433,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.34.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 6.2.3", "async-channel", @@ -8474,7 +8476,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.33.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-channel", "cid", @@ -8494,7 +8496,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.33.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "bitflags 1.3.2", @@ -8511,7 +8513,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.34.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "ahash 0.8.11", "futures", @@ -8530,7 +8532,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.33.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 6.2.3", "async-channel", @@ -8551,7 +8553,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.33.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 6.2.3", "async-channel", @@ -8587,7 +8589,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.33.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 6.2.3", "futures", @@ -8606,7 +8608,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "29.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 6.2.3", "bytes", @@ -8640,7 +8642,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.17.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -8649,7 +8651,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "29.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "futures", "jsonrpsee", @@ -8681,7 +8683,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.33.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -8701,7 +8703,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "11.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "futures", "governor", @@ -8719,7 +8721,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.34.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 6.2.3", "futures", @@ -8750,7 +8752,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.35.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "directories", @@ -8815,7 +8817,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.30.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "log", "parity-scale-codec", @@ -8826,7 +8828,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "27.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "derive_more", "futures", @@ -8847,7 +8849,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "15.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "chrono", "futures", @@ -8866,7 +8868,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "ansi_term", "chrono", @@ -8896,7 +8898,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "11.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", @@ -8907,7 +8909,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "futures", @@ -8934,7 +8936,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "futures", @@ -8950,7 +8952,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "14.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-channel", "futures", @@ -9496,7 +9498,7 @@ dependencies = [ [[package]] name = "sp-api" version = "26.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "hash-db", "log", @@ -9518,7 +9520,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "15.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "Inflector", "blake2 0.10.6", @@ -9532,7 +9534,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "30.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "parity-scale-codec", "scale-info", @@ -9545,7 +9547,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "23.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "integer-sqrt", "num-traits", @@ -9577,7 +9579,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "26.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "sp-api", "sp-inherents", @@ -9588,7 +9590,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "futures", "log", @@ -9606,7 +9608,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.32.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "futures", @@ -9621,7 +9623,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.32.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "parity-scale-codec", @@ -9638,7 +9640,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.32.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "parity-scale-codec", @@ -9657,7 +9659,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "13.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "finality-grandpa", "log", @@ -9675,7 +9677,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.32.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "parity-scale-codec", "scale-info", @@ -9687,7 +9689,7 @@ dependencies = [ [[package]] name = "sp-core" version = "28.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 6.2.3", "bandersnatch_vrfs", @@ -9734,7 +9736,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#6661f2890fa822ae738bff9d8072438a270054cd" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -9755,7 +9757,7 @@ dependencies = [ [[package]] name = "sp-crypto-hashing" version = "0.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "blake2b_simd", "byteorder", @@ -9768,7 +9770,7 @@ dependencies = [ [[package]] name = "sp-crypto-hashing-proc-macro" version = "0.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "quote", "sp-crypto-hashing", @@ -9778,7 +9780,7 @@ dependencies = [ [[package]] name = "sp-database" version = "10.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "kvdb", "parking_lot 0.12.3", @@ -9787,7 +9789,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "proc-macro2", "quote", @@ -9797,7 +9799,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "environmental", "parity-scale-codec", @@ -9808,7 +9810,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.7.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "serde_json", "sp-api", @@ -9819,7 +9821,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "26.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -9833,7 +9835,7 @@ dependencies = [ [[package]] name = "sp-io" version = "30.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "bytes", "ed25519-dalek", @@ -9859,7 +9861,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "31.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "sp-core", "sp-runtime", @@ -9869,7 +9871,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.34.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", @@ -9880,7 +9882,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "11.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "thiserror", "zstd 0.12.4", @@ -9889,7 +9891,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.6.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -9900,7 +9902,7 @@ dependencies = [ [[package]] name = "sp-mixnet" version = "0.4.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "parity-scale-codec", "scale-info", @@ -9912,7 +9914,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "26.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "sp-api", "sp-core", @@ -9922,7 +9924,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "13.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "backtrace", "lazy_static", @@ -9932,7 +9934,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "26.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "rustc-hash", "serde", @@ -9942,7 +9944,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "31.0.1" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -9973,7 +9975,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -9992,7 +9994,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "Inflector", "expander", @@ -10005,7 +10007,7 @@ dependencies = [ [[package]] name = "sp-session" version = "27.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "parity-scale-codec", "scale-info", @@ -10020,7 +10022,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "26.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10034,7 +10036,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.35.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "hash-db", "log", @@ -10055,7 +10057,7 @@ dependencies = [ [[package]] name = "sp-statement-store" version = "10.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "aes-gcm", "curve25519-dalek 4.1.1", @@ -10080,12 +10082,12 @@ dependencies = [ [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "impl-serde 0.4.0", "parity-scale-codec", @@ -10098,7 +10100,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "26.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "parity-scale-codec", @@ -10111,7 +10113,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "parity-scale-codec", "sp-std", @@ -10123,7 +10125,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "26.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "sp-api", "sp-runtime", @@ -10132,7 +10134,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "26.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "parity-scale-codec", @@ -10147,7 +10149,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "29.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "ahash 0.8.11", "hash-db", @@ -10171,7 +10173,7 @@ dependencies = [ [[package]] name = "sp-ver" version = "4.0.0-dev" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "parity-scale-codec", @@ -10188,7 +10190,7 @@ dependencies = [ [[package]] name = "sp-version" version = "29.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "impl-serde 0.4.0", "parity-scale-codec", @@ -10205,7 +10207,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "13.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10216,7 +10218,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -10229,7 +10231,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "27.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "bounded-collections", "parity-scale-codec", @@ -10388,7 +10390,7 @@ dependencies = [ [[package]] name = "substrate-bip39" version = "0.4.7" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "hmac 0.12.1", "pbkdf2", @@ -10400,12 +10402,12 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "11.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" [[package]] name = "substrate-prometheus-endpoint" version = "0.17.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "hyper", "log", @@ -10417,7 +10419,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.33.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#6661f2890fa822ae738bff9d8072438a270054cd" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "jsonrpsee", @@ -10430,7 +10432,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 6.2.3", "async-trait", @@ -10457,7 +10459,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime" version = "2.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "array-bytes 6.2.3", "frame-executive", @@ -10500,7 +10502,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime-client" version = "2.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "futures", "sc-block-builder", @@ -10519,7 +10521,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "17.0.0" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "build-helper", "cargo_metadata", @@ -11135,7 +11137,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "try-runtime-cli" version = "0.38.0" -source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#6661f2890fa822ae738bff9d8072438a270054cd" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "async-trait", "clap", @@ -11321,7 +11323,7 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "ver-api" version = "4.0.0-dev" -source = "git+https://github.com//gasp-xyz/polkadot-sdk?branch=feature/market-improvs#b23759df6d12551c29a5f1734752fca0efbbf995" +source = "git+https://github.com/gasp-xyz/polkadot-sdk?branch=eth-rollup-develop#46fdae444f71731021c0d8107dced84c4fc36278" dependencies = [ "derive_more", "frame-support", diff --git a/Cargo.toml b/Cargo.toml index bde327505..962b6880a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -193,137 +193,3 @@ ver-api = { git = "https://github.com/gasp-xyz/polkadot-sdk", branch = "eth-roll [patch."https://github.com/paritytech/polkadot-sdk"] # ... which satisfies git dependency `sp-crypto-ec-utils` of package `sp-ark-bls12-381 v0.4.2 (https://github.com/paritytech/arkworks-substrate#caa2eed7)` sp-crypto-ec-utils = { git = "https://github.com/gasp-xyz/polkadot-sdk", branch = "eth-rollup-develop" } - -# patch generated by './scripts/dev_manifest.sh ../polkadot-sdk' -[patch."https://github.com/gasp-xyz/polkadot-sdk"] -substrate-test-runtime = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -substrate-test-runtime-client = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -substrate-test-client = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-transaction-payment = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-transaction-payment-rpc = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-collective-mangata = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-proxy = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-identity = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-sudo-mangata = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -mangata-support = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-utility-mangata = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-authorship = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-grandpa = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-vesting-mangata = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -frame-system = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -frame-system-benchmarking = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -frame-system-rpc-runtime-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -frame-support = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -frame-support-procedural = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -frame-support-procedural-tools = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -frame-support-procedural-tools-derive = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-balances = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-aura = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -frame-benchmarking = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-treasury = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -frame-try-runtime = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-timestamp = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-babe = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-membership = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-utility = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -frame-executive = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -pallet-session = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -substrate-wasm-builder = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -fork-tree = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -substrate-build-script-utils = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -frame-benchmarking-cli = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -substrate-bip39 = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -substrate-prometheus-endpoint = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-database = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-runtime-interface = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-runtime-interface-proc-macro = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-consensus-grandpa = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-consensus = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-consensus-aura = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-consensus-babe = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-consensus-slots = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-tracing = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-crypto-hashing = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-crypto-hashing-proc-macro = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-ver = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-maybe-compressed-blob = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-core = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-state-machine = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-keystore = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-metadata-ir = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-statement-store = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-weights = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-io = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-runtime = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-inherents = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-transaction-pool = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-std = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-storage = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-panic-handler = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-debug-derive = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-blockchain = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-externalities = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-mixnet = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-trie = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -mangata-types = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-version = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-version-proc-macro = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-block-builder = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-keyring = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-staking = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-wasm-interface = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-transaction-storage-proof = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -extrinsic-shuffler = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-arithmetic = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-api-proc-macro = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-offchain = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-timestamp = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-application-crypto = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-rpc = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -ver-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-genesis-builder = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sp-session = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-consensus-grandpa = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-consensus = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-consensus-aura = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-consensus-slots = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-tracing = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-tracing-proc-macro = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-rpc-spec-v2 = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-state-db = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-proposer-metrics = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-keystore = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-basic-authorship-ver = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-rpc-server = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-network = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-network-bitswap = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-network-transactions = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-network-common = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-network-light = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-network-sync = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-informant = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-transaction-pool = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-transaction-pool-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-utils = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-cli = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-chain-spec = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-chain-spec-derive = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-block-builder-ver = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-mixnet = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-block-builder = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-allocator = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-network-gossip = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-client-db = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-client-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-sysinfo = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-executor = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-executor-wasmtime = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-executor-common = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-executor-polkavm = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-telemetry = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-offchain = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-service = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-rpc = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } -sc-rpc-api = { git = "https://github.com//gasp-xyz/polkadot-sdk", branch = "feature/market-improvs" } diff --git a/pallets/bootstrap/src/mock.rs b/pallets/bootstrap/src/mock.rs index 8fd1873ab..ea3aa0248 100644 --- a/pallets/bootstrap/src/mock.rs +++ b/pallets/bootstrap/src/mock.rs @@ -75,6 +75,7 @@ impl orml_tokens::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type CurrencyHooks = (); + type NontransferableTokens = Nothing; } parameter_types! { diff --git a/pallets/crowdloan-rewards/src/mock.rs b/pallets/crowdloan-rewards/src/mock.rs index af28c10a1..3d0418b63 100644 --- a/pallets/crowdloan-rewards/src/mock.rs +++ b/pallets/crowdloan-rewards/src/mock.rs @@ -92,6 +92,7 @@ impl orml_tokens::Config for Test { type CurrencyHooks = (); type MaxReserves = (); type ReserveIdentifier = [u8; 8]; + type NontransferableTokens = Nothing; } parameter_types! { diff --git a/pallets/fee-lock/src/mock.rs b/pallets/fee-lock/src/mock.rs index 173d3ccab..954fc21b3 100644 --- a/pallets/fee-lock/src/mock.rs +++ b/pallets/fee-lock/src/mock.rs @@ -5,7 +5,7 @@ use super::*; use crate as pallet_fee_lock; use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{Contains, Everything}, + traits::{Contains, Nothing}, weights::constants::RocksDbWeight, PalletId, }; @@ -68,6 +68,7 @@ impl orml_tokens::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type CurrencyHooks = (); + type NontransferableTokens = Nothing; } parameter_types! { diff --git a/pallets/issuance/src/mock.rs b/pallets/issuance/src/mock.rs index 607703ca8..c76803c11 100644 --- a/pallets/issuance/src/mock.rs +++ b/pallets/issuance/src/mock.rs @@ -20,7 +20,7 @@ use super::*; use crate as pallet_issuance; use frame_support::{ assert_ok, construct_runtime, derive_impl, parameter_types, - traits::{Contains, Everything, WithdrawReasons}, + traits::{Contains, Nothing, WithdrawReasons}, PalletId, }; use orml_traits::parameter_type_with_key; @@ -79,6 +79,7 @@ impl orml_tokens::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type CurrencyHooks = (); + type NontransferableTokens = Nothing; } parameter_types! { diff --git a/pallets/market/src/lib.rs b/pallets/market/src/lib.rs index cac14017a..684dbb7da 100644 --- a/pallets/market/src/lib.rs +++ b/pallets/market/src/lib.rs @@ -159,6 +159,15 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; + /// Tokens which cannot be transfered by extrinsics/user or use in pool, unless foundation override + type NontransferableTokens: Contains; + + /// A list of Foundation members with elevated rights + type FoundationAccountsProvider: Get>; + + /// A special account used for nontransferable tokens to allow 'selling' to balance pools + type ArbitrageBot: Contains; + #[cfg(feature = "runtime-benchmarks")] type ComputeIssuance: ComputeIssuance; } @@ -189,6 +198,8 @@ pub mod pallet { MultiSwapSamePool, /// Input asset id is not connected with output asset id for given pools MultiSwapPathInvalid, + /// Asset cannot be used to create or modify a pool + NontransferableToken, } // Pallet's events. @@ -275,6 +286,14 @@ pub mod pallet { ) -> DispatchResult { let sender = ensure_signed(origin)?; + // check assets id, or the foundation has a veto + ensure!( + (!T::NontransferableTokens::contains(&first_asset_id) && + !T::NontransferableTokens::contains(&second_asset_id)) || + T::FoundationAccountsProvider::get().contains(&sender), + Error::::NontransferableToken + ); + Self::check_assets_allowed((first_asset_id, second_asset_id))?; ensure!( @@ -302,13 +321,6 @@ pub mod pallet { second_asset_amount, )?; - T::StableSwap::add_liquidity( - &sender, - lp_token, - (first_asset_amount, second_asset_amount), - Zero::zero(), - )?; - T::AssetRegistry::create_pool_asset(lp_token, first_asset_id, second_asset_id)?; lp_token }, @@ -354,6 +366,12 @@ pub mod pallet { let sender = ensure_signed(origin)?; let pool_info = Self::get_pool_info(pool_id)?; + // check assets id, foundation has no veto + ensure!( + !T::NontransferableTokens::contains(&pool_info.pool.0) && + !T::NontransferableTokens::contains(&pool_info.pool.1), + Error::::NontransferableToken + ); Self::check_assets_allowed(pool_info.pool)?; let (lp_amount, other_asset_amount) = Self::do_mint_liquidity( @@ -396,6 +414,12 @@ pub mod pallet { let sender = ensure_signed(origin)?; let pool_info = Self::get_pool_info(pool_id)?; + // check assets id, foundation has no veto + ensure!( + !T::NontransferableTokens::contains(&pool_info.pool.0) && + !T::NontransferableTokens::contains(&pool_info.pool.1), + Error::::NontransferableToken + ); Self::check_assets_allowed(pool_info.pool)?; let lp_amount = match pool_info.kind { @@ -472,6 +496,12 @@ pub mod pallet { let sender = ensure_signed(origin)?; let pool_info = Self::get_pool_info(pool_id)?; + // check assets id, foundation has no veto + ensure!( + !T::NontransferableTokens::contains(&pool_info.pool.0) && + !T::NontransferableTokens::contains(&pool_info.pool.1), + Error::::NontransferableToken + ); Self::check_assets_allowed(pool_info.pool)?; let native_id = T::NativeCurrencyId::get(); @@ -534,6 +564,12 @@ pub mod pallet { let sender = ensure_signed(origin)?; let pool_info = Self::get_pool_info(pool_id)?; + // check assets id, foundation has no veto + ensure!( + !T::NontransferableTokens::contains(&pool_info.pool.0) && + !T::NontransferableTokens::contains(&pool_info.pool.1), + Error::::NontransferableToken + ); Self::check_assets_allowed(pool_info.pool)?; let native_id = T::NativeCurrencyId::get(); @@ -595,6 +631,13 @@ pub mod pallet { let sender = ensure_signed(origin)?; let pool_info = Self::get_pool_info(pool_id)?; + // check assets id, or the foundation has a veto + ensure!( + (!T::NontransferableTokens::contains(&pool_info.pool.0) && + !T::NontransferableTokens::contains(&pool_info.pool.1)) || + T::FoundationAccountsProvider::get().contains(&sender), + Error::::NontransferableToken + ); Self::check_assets_allowed(pool_info.pool)?; let amounts = match pool_info.kind { @@ -872,13 +915,6 @@ pub mod pallet { } } - // private helpers - fn get_decimals(asset_id: &T::CurrencyId) -> Result> { - T::AssetRegistry::metadata(&asset_id) - .map(|meta| meta.decimals) - .ok_or(Error::::AssetDoesNotExists) - } - fn get_pool_info(pool_id: PoolIdOf) -> Result, Error> { if let Some(pool) = T::Xyk::get_pool_info(pool_id) { return Ok(PoolInfo { pool_id, kind: PoolKind::Xyk, pool }) @@ -994,6 +1030,13 @@ pub mod pallet { let mut swaps: Vec> = vec![]; let mut amount_out = amount_in; for (pool, swap) in pools.iter().zip(path.into_iter()) { + // check input asset id, or the foundation has a veto + ensure!( + !T::NontransferableTokens::contains(&swap.0) || + T::ArbitrageBot::contains(sender), + Error::::NontransferableToken + ); + let amount_in = amount_out; amount_out = match pool.kind { PoolKind::StableSwap => { diff --git a/pallets/market/src/mock.rs b/pallets/market/src/mock.rs index 62c2ea769..3221e3777 100644 --- a/pallets/market/src/mock.rs +++ b/pallets/market/src/mock.rs @@ -5,7 +5,7 @@ use frame_support::{ construct_runtime, derive_impl, parameter_types, traits::{ tokens::currency::MultiTokenCurrency, ConstU128, ConstU32, Contains, ExistenceRequirement, - Nothing, WithdrawReasons, + GetDefault, Nothing, WithdrawReasons, }, PalletId, }; @@ -80,6 +80,7 @@ impl orml_tokens::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type CurrencyHooks = (); + type NontransferableTokens = Nothing; } parameter_types! { @@ -404,6 +405,9 @@ impl market::Config for Test { type WeightInfo = (); #[cfg(feature = "runtime-benchmarks")] type ComputeIssuance = mocks::MockIssuance; + type NontransferableTokens = Nothing; + type FoundationAccountsProvider = GetDefault; + type ArbitrageBot = Nothing; } impl Pallet diff --git a/pallets/multipurpose-liquidity/src/mock.rs b/pallets/multipurpose-liquidity/src/mock.rs index 7914f351f..b3e7d7f90 100644 --- a/pallets/multipurpose-liquidity/src/mock.rs +++ b/pallets/multipurpose-liquidity/src/mock.rs @@ -5,7 +5,7 @@ use super::*; use crate as pallet_multipurpose_liquidity; use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{Contains, Everything}, + traits::{Contains, Nothing}, PalletId, }; use frame_system as system; @@ -69,6 +69,7 @@ impl orml_tokens::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type CurrencyHooks = (); + type NontransferableTokens = Nothing; } parameter_types! { diff --git a/pallets/parachain-staking/src/mock.rs b/pallets/parachain-staking/src/mock.rs index 5c05d2880..e68bb9803 100644 --- a/pallets/parachain-staking/src/mock.rs +++ b/pallets/parachain-staking/src/mock.rs @@ -24,7 +24,7 @@ use codec::{Decode, Encode}; use frame_support::{ assert_ok, construct_runtime, derive_impl, parameter_types, traits::{ - Contains, Everything, MultiTokenCurrency, MultiTokenVestingSchedule, OnFinalize, + Contains, Everything, MultiTokenCurrency, MultiTokenVestingSchedule, Nothing, OnFinalize, OnInitialize, }, PalletId, @@ -204,6 +204,7 @@ impl orml_tokens::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type CurrencyHooks = (); + type NontransferableTokens = Nothing; } pub struct TokensStakingPassthrough(PhantomData); diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index cfdc64b0b..77ae3407a 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -102,6 +102,7 @@ impl orml_tokens::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type CurrencyHooks = (); + type NontransferableTokens = Nothing; } parameter_types! { diff --git a/pallets/rolldown/src/mock.rs b/pallets/rolldown/src/mock.rs index 25a8d8031..7e0755808 100644 --- a/pallets/rolldown/src/mock.rs +++ b/pallets/rolldown/src/mock.rs @@ -4,7 +4,7 @@ use super::*; use crate as rolldown; use core::convert::TryFrom; -use frame_support::{construct_runtime, derive_impl, parameter_types, traits::Everything}; +use frame_support::{construct_runtime, derive_impl, parameter_types, traits::Nothing}; use sp_runtime::traits::One; use std::collections::HashSet; @@ -66,6 +66,7 @@ impl orml_tokens::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type CurrencyHooks = (); + type NontransferableTokens = Nothing; } mockall::mock! { diff --git a/pallets/sequencer-staking/src/mock.rs b/pallets/sequencer-staking/src/mock.rs index 2de7b2bc9..a83093aa1 100644 --- a/pallets/sequencer-staking/src/mock.rs +++ b/pallets/sequencer-staking/src/mock.rs @@ -5,7 +5,7 @@ use crate as sequencer_staking; use core::convert::TryFrom; use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{tokens::fungible::Mutate, Everything}, + traits::{tokens::fungible::Mutate, Nothing}, PalletId, }; use mangata_support::traits::{ComputeIssuance, GetIssuance}; @@ -124,6 +124,7 @@ impl orml_tokens::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type CurrencyHooks = (); + type NontransferableTokens = Nothing; } parameter_types! { diff --git a/pallets/stable-swap/Cargo.toml b/pallets/stable-swap/Cargo.toml index f80fe1e98..07cab9de6 100644 --- a/pallets/stable-swap/Cargo.toml +++ b/pallets/stable-swap/Cargo.toml @@ -13,6 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { workspace = true, default-features = false } scale-info = { workspace = true, default-features = false, features = ["derive"] } +log = { workspace = true, default-features = false } frame-benchmarking = { workspace = true, default-features = false } frame-support = { workspace = true, default-features = false } diff --git a/pallets/stable-swap/src/lib.rs b/pallets/stable-swap/src/lib.rs index 820a1210b..07584bd2f 100644 --- a/pallets/stable-swap/src/lib.rs +++ b/pallets/stable-swap/src/lib.rs @@ -3,7 +3,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{ - ensure, + ensure, fail, pallet_prelude::*, traits::{ tokens::{Balance, CurrencyId}, @@ -565,8 +565,11 @@ pub mod pallet { ); ensure!(rates.len() == assets_in_len, Error::::ArgumentsLengthMismatch); - let mut assets = assets.clone(); - assets.sort(); + let mut to_sort: Vec<(T::CurrencyId, T::Balance)> = + assets.into_iter().zip(rates.into_iter()).collect(); + to_sort.sort_by_key(|&(a, _)| a); + let (mut assets, rates): (Vec, Vec) = + to_sort.into_iter().unzip(); assets.dedup(); ensure!(assets_in_len == assets.len(), Error::::SameAsset); @@ -931,6 +934,7 @@ pub mod pallet { let i = pool.get_asset_index::(asset_in)?; let j = pool.get_asset_index::(asset_out)?; + log::debug!(target: "", "{:?} {:?} {:?} {:?}", i, j, dx, xp); Self::get_dy_xp(&pool, i, j, dx, xp) } @@ -1823,6 +1827,17 @@ impl Mutate for Pallet { let rates = vec![rate_1, rate_2]; let info = Self::do_create_pool(sender, assets, rates, T::DefaultApmCoeff::get())?; + + // asset ids are ordered + let asset_pool_1 = *info.assets.get(0).ok_or(Error::::UnexpectedFailure)?; + let amounts = if asset_pool_1 == asset_1 { + vec![amount_1, amount_2] + } else { + vec![amount_2, amount_1] + }; + + let _ = Self::do_add_liquidity(&sender, info.lp_token, amounts, Zero::zero())?; + Ok(info.lp_token) } diff --git a/pallets/stable-swap/src/mock.rs b/pallets/stable-swap/src/mock.rs index 3fc5786bc..ad911b871 100644 --- a/pallets/stable-swap/src/mock.rs +++ b/pallets/stable-swap/src/mock.rs @@ -7,6 +7,7 @@ use frame_support::{ construct_runtime, derive_impl, parameter_types, traits::{ tokens::currency::MultiTokenCurrency, ConstU128, ConstU32, Contains, ExistenceRequirement, + Nothing, }, PalletId, }; @@ -75,6 +76,7 @@ impl orml_tokens::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type CurrencyHooks = (); + type NontransferableTokens = Nothing; } impl swap::Config for Test { diff --git a/pallets/xyk/src/mock.rs b/pallets/xyk/src/mock.rs index 56c0589b3..f0a42dc73 100644 --- a/pallets/xyk/src/mock.rs +++ b/pallets/xyk/src/mock.rs @@ -77,6 +77,7 @@ impl orml_tokens::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type CurrencyHooks = (); + type NontransferableTokens = Nothing; } parameter_types! { diff --git a/rollup/runtime/Cargo.toml b/rollup/runtime/Cargo.toml index bd448a3cb..596ec17a1 100644 --- a/rollup/runtime/Cargo.toml +++ b/rollup/runtime/Cargo.toml @@ -15,10 +15,11 @@ targets = ["x86_64-unknown-linux-gnu"] substrate-wasm-builder = { workspace = true } [dependencies] +array-bytes = { workspace = true } codec = { workspace = true, default-features = false, features = ["derive"] } -scale-info = { workspace = true, default-features = false, features = ["derive"] } +hex-literal = { workspace = true } log = { workspace = true, default-features = false } -array-bytes = { workspace = true } +scale-info = { workspace = true, default-features = false, features = ["derive"] } smallvec = "1.6.1" static_assertions = "1.1.0" diff --git a/rollup/runtime/integration-test/src/lib.rs b/rollup/runtime/integration-test/src/lib.rs index 37e3f65c5..52419ae4c 100644 --- a/rollup/runtime/integration-test/src/lib.rs +++ b/rollup/runtime/integration-test/src/lib.rs @@ -6,6 +6,7 @@ mod identity; mod maintenance; mod market; mod membership; +mod nontransfer; mod proof_of_stake; mod proxy; mod setup; diff --git a/rollup/runtime/integration-test/src/market.rs b/rollup/runtime/integration-test/src/market.rs index e0cc3c334..3959591f6 100644 --- a/rollup/runtime/integration-test/src/market.rs +++ b/rollup/runtime/integration-test/src/market.rs @@ -115,15 +115,14 @@ fn create_pool_works() { #[test] fn add_liquidity_works() { test_env().execute_with(|| { - assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); - assert_ok!(create_pool_unb(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (ASSET_ID_2, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::StableSwap, (ASSET_ID_2, ASSET_ID_1))); let expected = - Market::calculate_expected_amount_for_minting(POOL_ID_1, NATIVE_ASSET_ID, UNIT) - .unwrap(); + Market::calculate_expected_amount_for_minting(POOL_ID_1, ASSET_ID_2, UNIT).unwrap(); let lp_expected = Market::calculate_expected_lp_minted(POOL_ID_1, (UNIT, expected)).unwrap(); - assert_ok!(Market::mint_liquidity(origin(), POOL_ID_1, NATIVE_ASSET_ID, UNIT, 10 * UNIT)); + assert_ok!(Market::mint_liquidity(origin(), POOL_ID_1, ASSET_ID_2, UNIT, 10 * UNIT)); System::assert_last_event(RuntimeEvent::Market(Event::LiquidityMinted { who: AccountId::from(ALICE), pool_id: POOL_ID_1, @@ -134,11 +133,10 @@ fn add_liquidity_works() { })); let expected = - Market::calculate_expected_amount_for_minting(POOL_ID_2, NATIVE_ASSET_ID, UNIT) - .unwrap(); + Market::calculate_expected_amount_for_minting(POOL_ID_2, ASSET_ID_2, UNIT).unwrap(); let lp_expected = Market::calculate_expected_lp_minted(POOL_ID_2, (UNIT, expected)).unwrap(); - assert_ok!(Market::mint_liquidity(origin(), POOL_ID_2, NATIVE_ASSET_ID, UNIT, 10 * UNIT)); + assert_ok!(Market::mint_liquidity(origin(), POOL_ID_2, ASSET_ID_2, UNIT, 10 * UNIT)); System::assert_last_event(RuntimeEvent::Market(Event::LiquidityMinted { who: AccountId::from(ALICE), pool_id: POOL_ID_2, @@ -153,8 +151,8 @@ fn add_liquidity_works() { #[test] fn add_liquidity_fixed_works() { test_env().execute_with(|| { - assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); - assert_ok!(create_pool_unb(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (ASSET_ID_2, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::StableSwap, (ASSET_ID_2, ASSET_ID_1))); assert_ok!(Market::mint_liquidity_fixed_amounts(origin(), POOL_ID_1, (UNIT, 0), 0)); System::assert_last_event(RuntimeEvent::Market(Event::LiquidityMinted { @@ -166,12 +164,12 @@ fn add_liquidity_fixed_works() { total_supply: 7865524961509654622, })); - let expected = Market::calculate_expected_lp_minted(POOL_ID_2, (UNIT, 5 * UNIT)).unwrap(); - assert_ok!(Market::mint_liquidity_fixed_amounts(origin(), POOL_ID_2, (UNIT, 5 * UNIT), 0)); + let expected = Market::calculate_expected_lp_minted(POOL_ID_2, (5 * UNIT, UNIT)).unwrap(); + assert_ok!(Market::mint_liquidity_fixed_amounts(origin(), POOL_ID_2, (5 * UNIT, UNIT), 0)); System::assert_last_event(RuntimeEvent::Market(Event::LiquidityMinted { who: AccountId::from(ALICE), pool_id: POOL_ID_2, - amounts_provided: (1000000000000000000, 5000000000000000000), + amounts_provided: (5000000000000000000, 1000000000000000000), lp_token: POOL_ID_2, lp_token_minted: expected, total_supply: 154925100814226884776, @@ -208,14 +206,14 @@ fn remove_liquidity_works() { #[test] fn multiswap_should_work_xyk() { test_env().execute_with(|| { - assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (ASSET_ID_3, ASSET_ID_1))); assert_ok!(create_pool_unb(PoolKind::Xyk, (ASSET_ID_1, ASSET_ID_2))); assert_ok!(create_pool_unb(PoolKind::Xyk, (ASSET_ID_2, ASSET_ID_3))); assert_ok!(Market::multiswap_asset( origin(), vec![POOL_ID_1, POOL_ID_2, POOL_ID_3], - NATIVE_ASSET_ID, + ASSET_ID_3, UNIT, ASSET_ID_3, Zero::zero(), @@ -229,7 +227,7 @@ fn multiswap_should_work_xyk() { AtomicSwap { pool_id: POOL_ID_1, kind: PoolKind::Xyk, - asset_in: 0, + asset_in: 3, asset_out: 1, amount_in: 1000000000000000000, amount_out: 453305446940074565, @@ -259,7 +257,7 @@ fn multiswap_should_work_xyk() { fn multiswap_should_work_stable_swap_with_bnb() { test_env().execute_with(|| { // 2:1 rate - assert_ok!(create_pool_unb(PoolKind::StableSwap, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::StableSwap, (ASSET_ID_3, ASSET_ID_1))); assert_ok!(create_pool_unb(PoolKind::StableSwap, (ASSET_ID_1, ASSET_ID_2))); // 1:1 rate assert_ok!(create_pool(PoolKind::StableSwap, (ASSET_ID_2, ASSET_ID_3))); @@ -268,12 +266,19 @@ fn multiswap_should_work_stable_swap_with_bnb() { assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_2))); assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_3))); + let p = pallet_stable_swap::Pools::::get(POOL_ID_1).unwrap(); + // println!("{:#?}", p); + // assets are ordered by id, same sa as the corresponding rates + assert_eq!(p.assets, vec![ASSET_ID_1, ASSET_ID_3]); + assert_eq!(p.rate_multipliers[0], 10 * UNIT); + assert_eq!(p.rate_multipliers[1], 5 * UNIT); + let before = Tokens::total_issuance(NATIVE_ASSET_ID); assert_ok!(Market::multiswap_asset( origin(), vec![POOL_ID_1, POOL_ID_2, POOL_ID_3], - NATIVE_ASSET_ID, + ASSET_ID_3, UNIT, ASSET_ID_3, Zero::zero(), @@ -285,7 +290,7 @@ fn multiswap_should_work_stable_swap_with_bnb() { assert_eq!(before, 100000000000000000000); assert_eq!(after, 99999001734203514767); - println!("{:#?}", events()); + // println!("{:#?}", events()); System::assert_last_event(RuntimeEvent::Market(Event::AssetsSwapped { who: AccountId::from(ALICE), @@ -293,7 +298,7 @@ fn multiswap_should_work_stable_swap_with_bnb() { AtomicSwap { pool_id: POOL_ID_1, kind: PoolKind::StableSwap, - asset_in: 0, + asset_in: ASSET_ID_3, asset_out: 1, amount_in: 1000000000000000000, amount_out: 498447826003559573, @@ -322,14 +327,14 @@ fn multiswap_should_work_stable_swap_with_bnb() { #[test] fn multiswap_should_work_mixed() { test_env().execute_with(|| { - assert_ok!(create_pool_unb(PoolKind::Xyk, (NATIVE_ASSET_ID, ASSET_ID_1))); + assert_ok!(create_pool_unb(PoolKind::Xyk, (ASSET_ID_3, ASSET_ID_1))); assert_ok!(create_pool_unb(PoolKind::StableSwap, (ASSET_ID_1, ASSET_ID_2))); assert_ok!(create_pool_unb(PoolKind::Xyk, (ASSET_ID_2, ASSET_ID_3))); assert_ok!(Market::multiswap_asset( origin(), vec![POOL_ID_1, POOL_ID_2, POOL_ID_3], - NATIVE_ASSET_ID, + ASSET_ID_3, UNIT, ASSET_ID_3, Zero::zero(), @@ -343,7 +348,7 @@ fn multiswap_should_work_mixed() { AtomicSwap { pool_id: POOL_ID_1, kind: PoolKind::Xyk, - asset_in: 0, + asset_in: ASSET_ID_3, asset_out: 1, amount_in: 1000000000000000000, amount_out: 453305446940074565, diff --git a/rollup/runtime/integration-test/src/nontransfer.rs b/rollup/runtime/integration-test/src/nontransfer.rs new file mode 100644 index 000000000..f9c3c0624 --- /dev/null +++ b/rollup/runtime/integration-test/src/nontransfer.rs @@ -0,0 +1,228 @@ +use crate::setup::*; + +const ASSET_ID_1: TokenId = NATIVE_ASSET_ID + 1; +const POOL_ID: TokenId = ASSET_ID_1 + 1; +const ARB: [u8; 20] = hex_literal::hex!["fc741134c82b81b7ab7efbf334b0c90ff8dbf22c"]; + +fn test_env() -> TestExternalities { + ExtBuilder { + balances: vec![ + (AccountId::from(ALICE), NATIVE_ASSET_ID, 100 * UNIT), + (AccountId::from(ARB), NATIVE_ASSET_ID, 100 * UNIT), + (AccountId::from(ALICE), ASSET_ID_1, 100 * UNIT), + ], + ..ExtBuilder::default() + } + .build() +} + +fn root() -> RuntimeOrigin { + RuntimeOrigin::root().into() +} + +fn origin() -> RuntimeOrigin { + RuntimeOrigin::signed(AccountId::from(ALICE)) +} + +#[test] +fn test_tokens_calls_should_block() { + let mut ext = test_env(); + ext.execute_with(|| { + let who = AccountId::from(ALICE); + let bob = AccountId::from(BOB); + let amount = UNIT; + assert_err!( + orml_tokens::Pallet::::mint(root(), NATIVE_ASSET_ID, who, amount), + orml_tokens::Error::::NontransferableToken + ); + assert_err!( + orml_tokens::Pallet::::set_balance( + root(), + who, + NATIVE_ASSET_ID, + amount, + amount + ), + orml_tokens::Error::::NontransferableToken + ); + assert_err!( + orml_tokens::Pallet::::transfer(origin(), bob, NATIVE_ASSET_ID, amount), + orml_tokens::Error::::NontransferableToken + ); + assert_err!( + orml_tokens::Pallet::::force_transfer( + root(), + who, + bob, + NATIVE_ASSET_ID, + amount + ), + orml_tokens::Error::::NontransferableToken + ); + assert_err!( + orml_tokens::Pallet::::transfer_all(origin(), bob, NATIVE_ASSET_ID, false), + orml_tokens::Error::::NontransferableToken + ); + assert_err!( + orml_tokens::Pallet::::transfer_keep_alive( + origin(), + bob, + NATIVE_ASSET_ID, + amount + ), + orml_tokens::Error::::NontransferableToken + ); + }); +} + +#[test] +fn test_market_should_block() { + let mut ext = test_env(); + ext.execute_with(|| { + let foundation = AccountId::from(ALICE); + let bob = AccountId::from(BOB); + let amount = 100 * UNIT; + + // user cannot create pool, foundation can + assert_err!( + pallet_market::Pallet::::create_pool( + RuntimeOrigin::signed(bob), + pallet_market::PoolKind::Xyk, + NATIVE_ASSET_ID, + amount, + ASSET_ID_1, + amount, + ), + pallet_market::Error::::NontransferableToken + ); + assert_ok!(pallet_market::Pallet::::create_pool( + RuntimeOrigin::signed(foundation), + pallet_market::PoolKind::Xyk, + NATIVE_ASSET_ID, + amount, + ASSET_ID_1, + amount, + )); + + // none can mint + assert_err!( + pallet_market::Pallet::::mint_liquidity( + RuntimeOrigin::signed(foundation), + POOL_ID, + NATIVE_ASSET_ID, + amount, + amount, + ), + pallet_market::Error::::NontransferableToken + ); + assert_err!( + pallet_market::Pallet::::mint_liquidity_fixed_amounts( + RuntimeOrigin::signed(foundation), + POOL_ID, + (amount, amount), + amount, + ), + pallet_market::Error::::NontransferableToken + ); + assert_err!( + pallet_market::Pallet::::mint_liquidity_using_vesting_native_tokens( + RuntimeOrigin::signed(foundation), + POOL_ID, + amount, + amount, + ), + pallet_market::Error::::NontransferableToken + ); + assert_err!( + pallet_market::Pallet::::mint_liquidity_using_vesting_native_tokens_by_vesting_index( + RuntimeOrigin::signed(foundation), + POOL_ID, + 0, + None, + amount, + ), + pallet_market::Error::::NontransferableToken + ); + + // user cannot burn, foundation can + assert_err!( + pallet_market::Pallet::::burn_liquidity( + RuntimeOrigin::signed(bob), + POOL_ID, + amount, + amount, + amount, + ), + pallet_market::Error::::NontransferableToken + ); + assert_ok!(pallet_market::Pallet::::burn_liquidity( + RuntimeOrigin::signed(foundation), + POOL_ID, + UNIT, + 0, + 0, + )); + + // user & foundation cannot sell, ARB bot can + assert_err!( + pallet_market::Pallet::::multiswap_asset( + RuntimeOrigin::signed(bob), + vec![POOL_ID], + NATIVE_ASSET_ID, + UNIT, + ASSET_ID_1, + 0, + ), + pallet_market::Error::::NontransferableToken + ); + assert_err!( + pallet_market::Pallet::::multiswap_asset( + RuntimeOrigin::signed(foundation), + vec![POOL_ID], + NATIVE_ASSET_ID, + UNIT, + ASSET_ID_1, + 0, + ), + pallet_market::Error::::NontransferableToken + ); + assert_ok!(pallet_market::Pallet::::multiswap_asset( + RuntimeOrigin::signed(AccountId::from(ARB)), + vec![POOL_ID], + NATIVE_ASSET_ID, + UNIT, + ASSET_ID_1, + 0, + )); + assert_err!( + pallet_market::Pallet::::multiswap_asset_buy( + RuntimeOrigin::signed(bob), + vec![POOL_ID], + ASSET_ID_1, + UNIT, + NATIVE_ASSET_ID, + amount, + ), + pallet_market::Error::::NontransferableToken + ); + assert_err!( + pallet_market::Pallet::::multiswap_asset_buy( + RuntimeOrigin::signed(foundation), + vec![POOL_ID], + ASSET_ID_1, + UNIT, + NATIVE_ASSET_ID, + amount, + ), + pallet_market::Error::::NontransferableToken + ); + assert_ok!(pallet_market::Pallet::::multiswap_asset_buy( + RuntimeOrigin::signed(AccountId::from(ARB)), + vec![POOL_ID], + ASSET_ID_1, + UNIT, + NATIVE_ASSET_ID, + amount, + )); + }); +} diff --git a/rollup/runtime/src/lib.rs b/rollup/runtime/src/lib.rs index 8b2e78389..69e4918a4 100644 --- a/rollup/runtime/src/lib.rs +++ b/rollup/runtime/src/lib.rs @@ -55,8 +55,8 @@ pub use frame_support::{ UnityAssetBalanceConversion, }, ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, Contains, EitherOfDiverse, EnsureOrigin, - EnsureOriginWithArg, Everything, ExistenceRequirement, FindAuthor, Get, Imbalance, - InstanceFilter, KeyOwnerProofSystem, NeverEnsureOrigin, Randomness, StorageInfo, + EnsureOriginWithArg, Equals, Everything, ExistenceRequirement, FindAuthor, Get, Imbalance, + InstanceFilter, KeyOwnerProofSystem, NeverEnsureOrigin, Nothing, Randomness, StorageInfo, WithdrawReasons, }, unsigned::TransactionValidityError, @@ -308,6 +308,7 @@ impl orml_tokens::Config for Runtime { type CurrencyHooks = (); type MaxReserves = (); type ReserveIdentifier = cfg::orml_tokens::ReserveIdentifier; + type NontransferableTokens = tokens::NontransferableTokens; } impl pallet_xyk::Config for Runtime { @@ -838,6 +839,9 @@ impl pallet_market::Config for Runtime { type WeightInfo = weights::pallet_market_weights::ModuleWeight; #[cfg(feature = "runtime-benchmarks")] type ComputeIssuance = Issuance; + type NontransferableTokens = tokens::NontransferableTokens; + type FoundationAccountsProvider = cfg::pallet_membership::FoundationAccountsProvider; + type ArbitrageBot = tokens::ArbitrageBot; } // Create the runtime by composing the FRAME pallets that were previously configured. diff --git a/rollup/runtime/src/runtime_config.rs b/rollup/runtime/src/runtime_config.rs index 3356a0ad5..5ca4611b5 100644 --- a/rollup/runtime/src/runtime_config.rs +++ b/rollup/runtime/src/runtime_config.rs @@ -48,9 +48,22 @@ pub mod tokens { pub const RX_TOKEN_ID: TokenId = 0; pub const ETH_TOKEN_ID: TokenId = 1; + #[cfg(any(feature = "unlocked", feature = "runtime-benchmarks"))] + pub type NontransferableTokens = Nothing; + #[cfg(not(any(feature = "unlocked", feature = "runtime-benchmarks")))] + pub type NontransferableTokens = Equals>; + + #[cfg(any(feature = "unlocked", feature = "runtime-benchmarks"))] + pub type ArbitrageBot = Nothing; + #[cfg(not(any(feature = "unlocked", feature = "runtime-benchmarks")))] + pub type ArbitrageBot = Equals; + parameter_types! { pub const RxTokenId: TokenId = RX_TOKEN_ID; pub const EthTokenId: TokenId = ETH_TOKEN_ID; + pub ArbitrageBotAddr: AccountId = sp_runtime::AccountId20::from( + hex_literal::hex!["fc741134c82b81b7ab7efbf334b0c90ff8dbf22c"] + ); } }