Skip to content

Commit 96a2141

Browse files
committed
NODE-197, chore: remove oracle related code
1 parent 413c820 commit 96a2141

10 files changed

Lines changed: 35 additions & 506 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ members = [
3030
"precompiles/btc-socket-queue",
3131
"precompiles/blaze",
3232
"precompiles/bifrost-evm-tx-payment",
33-
"precompiles/cccp-relay-queue",
3433
"primitives/core",
3534
"primitives/bfc-staking",
3635
"primitives/btc-relay",
@@ -124,7 +123,6 @@ precompile-btc-registration-pool = { default-features = false, path = "precompil
124123
precompile-btc-socket-queue = { default-features = false, path = "precompiles/btc-socket-queue" }
125124
precompile-blaze = { default-features = false, path = "precompiles/blaze" }
126125
precompile-bifrost-evm-tx-payment = { default-features = false, path = "precompiles/bifrost-evm-tx-payment" }
127-
precompile-cccp-relay-queue = { default-features = false, path = "precompiles/cccp-relay-queue" }
128126

129127
# Substrate Client
130128
sc-cli = { git = "https://github.com/bifrost-platform/polkadot-sdk", branch = "bifrost-polkadot-stable2512" }

pallets/cccp-relay-queue/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ pub type ChainId = u32;
2222
/// Asset address type.
2323
pub type AssetId = H160;
2424

25-
/// Asset oracle address type.
26-
pub type AssetOracleId = H256;
27-
2825
/// Asset index hash type.
2926
pub type AssetIndexHash = H256;
3027

pallets/cccp-relay-queue/src/pallet/mod.rs

Lines changed: 6 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod impls;
22

33
use crate::{
4-
weights::WeightInfo, AssetCapInfo, AssetId, AssetIndexHash, AssetOracleId, BalanceOf, ChainId,
4+
weights::WeightInfo, AssetCapInfo, AssetId, AssetIndexHash, BalanceOf, ChainId,
55
FinalizePollSubmission, OnFlightPollSubmission, SocketMessageHash, SourceTransactionId,
66
TransferInfo, TransferInfoWithTxId, TransferOption,
77
};
@@ -96,10 +96,6 @@ pub mod pallet {
9696
InvalidMaxCap,
9797
/// Max on-flight cap exceeds maximum allowed value.
9898
CapTooLarge,
99-
/// Native currency chain already exists.
100-
NativeCurrencyChainAlreadyExists,
101-
/// Native currency chain does not exist.
102-
NativeCurrencyChainDNE,
10399
}
104100

105101
#[pallet::event]
@@ -130,7 +126,6 @@ pub mod pallet {
130126
/// An asset has been added.
131127
AssetAdded {
132128
asset_id: AssetId,
133-
asset_oracle_id: AssetOracleId,
134129
max_on_flight_cap: BalanceOf<T>,
135130
asset_indexes: Vec<AssetIndexHash>,
136131
},
@@ -139,7 +134,6 @@ pub mod pallet {
139134
/// An asset has been updated.
140135
AssetUpdated {
141136
asset_id: AssetId,
142-
new_asset_oracle_id: Option<AssetOracleId>,
143137
new_max_on_flight_cap: Option<BalanceOf<T>>,
144138
add_asset_indexes: Option<Vec<AssetIndexHash>>,
145139
remove_asset_indexes: Option<Vec<AssetIndexHash>>,
@@ -198,30 +192,6 @@ pub mod pallet {
198192
pub type AssetCaps<T: Config> =
199193
StorageMap<_, Twox64Concat, AssetId, AssetCapInfo<BalanceOf<T>>>;
200194

201-
#[pallet::storage]
202-
#[pallet::unbounded]
203-
/// Mapping from asset addresses to their oracle addresses.
204-
///
205-
/// This storage maps EVM-compatible asset contract addresses to their corresponding
206-
/// oracle IDs. Oracle IDs are used to fetch the price of the asset from the
207-
/// price oracle.
208-
///
209-
/// - **Key**: `AssetId` (H160) - The EVM-compatible asset contract address
210-
/// - **Value**: `AssetOracleId` (H256) - The oracle ID
211-
pub type AssetOracles<T: Config> = StorageMap<_, Twox64Concat, AssetId, AssetOracleId>;
212-
213-
#[pallet::storage]
214-
#[pallet::unbounded]
215-
/// Mapping from chain IDs to their native currency oracle IDs.
216-
///
217-
/// This storage maps chain IDs to their corresponding native currency oracle IDs.
218-
/// Native currency oracle IDs are used to fetch the price of the native currency from the
219-
/// price oracle.
220-
///
221-
/// - **Key**: `ChainId` (u32) - The chain ID
222-
/// - **Value**: `AssetOracleId` (H256) - The oracle ID
223-
pub type NativeCurrencyOracles<T: Config> = StorageMap<_, Twox64Concat, ChainId, AssetOracleId>;
224-
225195
#[pallet::storage]
226196
#[pallet::unbounded]
227197
/// Pending cross-chain transfers awaiting majority consensus approval.
@@ -860,7 +830,6 @@ pub mod pallet {
860830
/// * `asset_id` - The EVM-compatible asset contract address (H160)
861831
/// - For native BFC: `0xffffffffffffffffffffffffffffffffffffffff`
862832
/// - For ERC20 tokens: The unified token contract address
863-
/// * `asset_oracle_id` - The oracle ID (H256) for price feed of this asset
864833
/// * `max_on_flight_cap` - Maximum total amount allowed in Fast transfers simultaneously
865834
/// - Must be > 0 (cannot create non-functional assets)
866835
/// - Must be ≤ 100,000,000 * 10^18 (100M cap limit)
@@ -882,11 +851,10 @@ pub mod pallet {
882851
/// * `AssetIndexAlreadyExists` - If any asset index is already associated with another asset
883852
///
884853
/// # Events
885-
/// * `AssetAdded { asset_id, asset_oracle_id, max_on_flight_cap, asset_indexes }` - Emitted on successful registration
854+
/// * `AssetAdded { asset_id, max_on_flight_cap, asset_indexes }` - Emitted on successful registration
886855
///
887856
/// # Storage Modifications
888857
/// - `AssetCaps`: Inserts new entry with `max_on_flight_cap` and `on_flight_cap = 0`
889-
/// - `AssetOracles`: Inserts mapping from asset_id to asset_oracle_id
890858
/// - `AssetIndexes`: Inserts mapping from each asset index to the asset_id
891859
///
892860
/// # Important
@@ -899,7 +867,6 @@ pub mod pallet {
899867
pub fn add_asset(
900868
origin: OriginFor<T>,
901869
asset_id: AssetId,
902-
asset_oracle_id: AssetOracleId,
903870
max_on_flight_cap: BalanceOf<T>,
904871
asset_indexes: Vec<AssetIndexHash>,
905872
) -> DispatchResultWithPostInfo {
@@ -943,17 +910,11 @@ pub mod pallet {
943910
asset_id,
944911
AssetCapInfo { max_on_flight_cap, on_flight_cap: Default::default() },
945912
);
946-
AssetOracles::<T>::insert(asset_id, asset_oracle_id);
947913
for asset_index in &asset_indexes {
948914
AssetIndexes::<T>::insert(asset_index, asset_id);
949915
}
950916

951-
Self::deposit_event(Event::AssetAdded {
952-
asset_id,
953-
asset_oracle_id,
954-
max_on_flight_cap,
955-
asset_indexes,
956-
});
917+
Self::deposit_event(Event::AssetAdded { asset_id, max_on_flight_cap, asset_indexes });
957918

958919
Ok(().into())
959920
}
@@ -976,7 +937,6 @@ pub mod pallet {
976937
///
977938
/// # Storage Modifications
978939
/// - `AssetCaps`: Entry for `asset_id` is removed
979-
/// - `AssetOracles`: Entry for `asset_id` is removed
980940
/// - `AssetIndexes`: All mappings for the associated asset indexes are removed
981941
///
982942
/// # Important
@@ -1005,7 +965,6 @@ pub mod pallet {
1005965

1006966
// Safe to remove asset and its indexes
1007967
AssetCaps::<T>::remove(asset_id);
1008-
AssetOracles::<T>::remove(asset_id);
1009968
for asset_index in &asset_indexes {
1010969
AssetIndexes::<T>::remove(asset_index);
1011970
}
@@ -1017,14 +976,12 @@ pub mod pallet {
1017976

1018977
/// Update an existing asset's configuration and CCCP asset indexes.
1019978
///
1020-
/// This extrinsic allows modifying the oracle address, maximum on-flight capacity of a registered
979+
/// This extrinsic allows modifying the maximum on-flight capacity of a registered
1021980
/// asset and managing its associated CCCP asset indexes by adding or removing them.
1022981
///
1023982
/// # Parameters
1024983
/// * `origin` - Must be `Root` (sudo access required)
1025984
/// * `asset_id` - The EVM-compatible asset contract address (H160) to update
1026-
/// * `new_asset_oracle_id` - (Optional) New oracle ID for price feed of this asset
1027-
/// - Cannot be the same as the current oracle ID
1028985
/// * `new_max_on_flight_cap` - (Optional) New maximum total amount allowed in Fast transfers
1029986
/// - Must be > 0
1030987
/// - Must be ≤ 100M cap limit
@@ -1054,18 +1011,16 @@ pub mod pallet {
10541011
/// * `AssetHasActiveTransfers` - If an index to remove has active on-flight transfers
10551012
///
10561013
/// # Events
1057-
/// * `AssetUpdated { asset_id, new_asset_oracle_id, new_max_on_flight_cap, add_asset_indexes, remove_asset_indexes }`
1014+
/// * `AssetUpdated { asset_id, new_max_on_flight_cap, add_asset_indexes, remove_asset_indexes }`
10581015
///
10591016
/// # Storage Modifications
1060-
/// - `AssetOracles`: Updates oracle ID for the asset if provided
10611017
/// - `AssetCaps`: Updates `max_on_flight_cap` for the asset if provided
10621018
/// - `AssetIndexes`: Inserts new mappings and removes specified mappings
10631019
#[pallet::call_index(5)]
10641020
#[pallet::weight(<T as Config>::WeightInfo::default())]
10651021
pub fn update_asset(
10661022
origin: OriginFor<T>,
10671023
asset_id: AssetId,
1068-
new_asset_oracle_id: Option<AssetOracleId>,
10691024
new_max_on_flight_cap: Option<BalanceOf<T>>,
10701025
add_asset_indexes: Option<Vec<AssetIndexHash>>,
10711026
remove_asset_indexes: Option<Vec<AssetIndexHash>>,
@@ -1074,8 +1029,7 @@ pub mod pallet {
10741029

10751030
// Ensure at least one of the fields is provided
10761031
ensure!(
1077-
new_asset_oracle_id.is_some()
1078-
|| new_max_on_flight_cap.is_some()
1032+
new_max_on_flight_cap.is_some()
10791033
|| add_asset_indexes.is_some()
10801034
|| remove_asset_indexes.is_some(),
10811035
Error::<T>::EmptySubmission
@@ -1120,18 +1074,6 @@ pub mod pallet {
11201074

11211075
let mut asset_cap = AssetCaps::<T>::get(asset_id).ok_or(Error::<T>::AssetDNE)?;
11221076

1123-
// Update oracle address if provided
1124-
if let Some(new_asset_oracle_id) = new_asset_oracle_id {
1125-
let current_oracle_id = AssetOracles::<T>::get(asset_id);
1126-
if let Some(current_oracle_id) = current_oracle_id {
1127-
ensure!(
1128-
current_oracle_id != new_asset_oracle_id,
1129-
Error::<T>::NoWritingSameValue
1130-
);
1131-
}
1132-
AssetOracles::<T>::insert(asset_id, new_asset_oracle_id);
1133-
}
1134-
11351077
if let Some(new_max_on_flight_cap) = new_max_on_flight_cap {
11361078
if asset_cap.max_on_flight_cap == new_max_on_flight_cap {
11371079
return Err(Error::<T>::NoWritingSameValue.into());
@@ -1184,97 +1126,13 @@ pub mod pallet {
11841126

11851127
Self::deposit_event(Event::AssetUpdated {
11861128
asset_id,
1187-
new_asset_oracle_id,
11881129
new_max_on_flight_cap,
11891130
add_asset_indexes,
11901131
remove_asset_indexes,
11911132
});
11921133

11931134
Ok(().into())
11941135
}
1195-
1196-
#[pallet::call_index(6)]
1197-
#[pallet::weight(<T as Config>::WeightInfo::default())]
1198-
/// Set the native currency oracle ID for a chain.
1199-
///
1200-
/// This extrinsic sets the native currency oracle ID for a chain. The native currency oracle ID is used to fetch the price of the native currency from the price oracle.
1201-
///
1202-
/// # Parameters
1203-
/// * `origin` - Must be `Root` (sudo access required)
1204-
/// * `chain_id` - The chain ID (u32)
1205-
/// * `native_currency_oracle_id` - The native currency oracle ID (H256)
1206-
pub fn set_native_currency_oracle(
1207-
origin: OriginFor<T>,
1208-
chain_id: ChainId,
1209-
native_currency_oracle_id: AssetOracleId,
1210-
) -> DispatchResultWithPostInfo {
1211-
ensure_root(origin)?;
1212-
1213-
ensure!(
1214-
!NativeCurrencyOracles::<T>::contains_key(chain_id),
1215-
Error::<T>::NativeCurrencyChainAlreadyExists
1216-
);
1217-
NativeCurrencyOracles::<T>::insert(chain_id, native_currency_oracle_id);
1218-
1219-
Ok(().into())
1220-
}
1221-
1222-
#[pallet::call_index(7)]
1223-
#[pallet::weight(<T as Config>::WeightInfo::default())]
1224-
/// Update the native currency oracle ID for a chain.
1225-
///
1226-
/// This extrinsic updates the native currency oracle ID for a chain. The native currency oracle ID is used to fetch the price of the native currency from the price oracle.
1227-
///
1228-
/// # Parameters
1229-
/// * `origin` - Must be `Root` (sudo access required)
1230-
/// * `chain_id` - The chain ID (u32)
1231-
/// * `native_currency_oracle_id` - The native currency oracle ID (H256)
1232-
/// - Cannot be the same as the current native currency oracle ID
1233-
pub fn update_native_currency_oracle(
1234-
origin: OriginFor<T>,
1235-
chain_id: ChainId,
1236-
native_currency_oracle_id: AssetOracleId,
1237-
) -> DispatchResultWithPostInfo {
1238-
ensure_root(origin)?;
1239-
1240-
ensure!(
1241-
NativeCurrencyOracles::<T>::contains_key(chain_id),
1242-
Error::<T>::NativeCurrencyChainDNE
1243-
);
1244-
if let Some(current_oracle_id) = NativeCurrencyOracles::<T>::get(chain_id) {
1245-
ensure!(
1246-
current_oracle_id != native_currency_oracle_id,
1247-
Error::<T>::NoWritingSameValue
1248-
);
1249-
}
1250-
NativeCurrencyOracles::<T>::insert(chain_id, native_currency_oracle_id);
1251-
1252-
Ok(().into())
1253-
}
1254-
1255-
#[pallet::call_index(8)]
1256-
#[pallet::weight(<T as Config>::WeightInfo::default())]
1257-
/// Remove the native currency oracle ID for a chain.
1258-
///
1259-
/// This extrinsic removes the native currency oracle ID for a chain. The native currency oracle ID is used to fetch the price of the native currency from the price oracle.
1260-
///
1261-
/// # Parameters
1262-
/// * `origin` - Must be `Root` (sudo access required)
1263-
/// * `chain_id` - The chain ID (u32)
1264-
pub fn remove_native_currency_oracle(
1265-
origin: OriginFor<T>,
1266-
chain_id: ChainId,
1267-
) -> DispatchResultWithPostInfo {
1268-
ensure_root(origin)?;
1269-
1270-
ensure!(
1271-
NativeCurrencyOracles::<T>::contains_key(chain_id),
1272-
Error::<T>::NativeCurrencyChainDNE
1273-
);
1274-
NativeCurrencyOracles::<T>::remove(chain_id);
1275-
1276-
Ok(().into())
1277-
}
12781136
}
12791137

12801138
#[pallet::validate_unsigned]

precompiles/cccp-relay-queue/Cargo.toml

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)