Skip to content

Commit 8310410

Browse files
committed
fix: remove create_tables_with_snapshot_and_commitment and CommitmentCreationCmd::FromSnapshot from pallet tables
1 parent 9492634 commit 8310410

File tree

2 files changed

+6
-104
lines changed

2 files changed

+6
-104
lines changed

pallets/tables/src/lib.rs

Lines changed: 6 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ pub mod pallet {
110110
/// What type of commitment to create
111111
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
112112
pub enum CommitmentCreationCmd {
113-
/// From a preexisting commitment
114-
FromSnapshot(SnapshotUrl, TableCommitmentBytesPerCommitmentScheme),
115113
/// An empty commitment
116114
Empty(CommitmentSchemeFlags),
117115
}
@@ -365,61 +363,8 @@ pub mod pallet {
365363
Self::create_tables_inner(origin, tables)
366364
}
367365

368-
/// Create tables with a known commit and snapshot url from which data can be loaded
369-
#[pallet::call_index(1)]
370-
#[pallet::weight(<T as Config>::WeightInfo::create_tables_with_snapshot_and_commitment())]
371-
pub fn create_tables_with_snapshot_and_commitment(
372-
origin: OriginFor<T>,
373-
source_and_mode: SourceAndMode,
374-
tables: CreateTableList,
375-
) -> DispatchResult {
376-
pallet_permissions::Pallet::<T>::ensure_root_or_permissioned(
377-
origin,
378-
&PermissionLevel::TablesPallet(TablesPalletPermission::EditSchema),
379-
)?;
380-
381-
let tables = tables
382-
.into_iter()
383-
.map(|table| {
384-
Self::insert_schema(
385-
table.table_name.clone(),
386-
table.ddl.clone(),
387-
table.table_type.clone(),
388-
source_and_mode.source.clone(),
389-
);
390-
391-
let statement_with_metadata = Self::insert_initial_commitment(
392-
table.table_name.clone(),
393-
table.ddl,
394-
table.commitment.clone(),
395-
table.snapshot_url.clone(),
396-
)?;
397-
let out = CreateTableRequest {
398-
table_uuid: table.table_uuid,
399-
table_version: table.table_version,
400-
column_uuids: table.column_uuids,
401-
table_name: table.table_name,
402-
ddl: statement_with_metadata,
403-
commitment: table.commitment,
404-
snapshot_url: table.snapshot_url,
405-
table_type: table.table_type,
406-
};
407-
Ok(out)
408-
})
409-
.collect::<Result<Vec<_>, DispatchError>>()?
410-
.try_into()
411-
.expect("iterator should still have < MAX_TABLES_PER_SCHEMA elements");
412-
413-
Self::deposit_event(Event::<T>::TablesCreatedWithCommitments {
414-
source_and_mode,
415-
table_list: tables,
416-
});
417-
418-
Ok(())
419-
}
420-
421366
/// Clear schemas and tables from chain state for all namespaces and identifiers
422-
#[pallet::call_index(3)]
367+
#[pallet::call_index(1)]
423368
#[pallet::weight(<T as Config>::WeightInfo::clear_tables())]
424369
pub fn clear_tables(origin: OriginFor<T>) -> DispatchResult {
425370
// Only sudo can call this
@@ -457,7 +402,7 @@ pub mod pallet {
457402

458403
/// Used to create a new namespace/schema on chain. Stores the associated UUID and emits
459404
/// an event containing the CREATE statement
460-
#[pallet::call_index(4)]
405+
#[pallet::call_index(2)]
461406
#[pallet::weight(<T as Config>::WeightInfo::create_namespace())]
462407
pub fn create_namespace(
463408
origin: OriginFor<T>,
@@ -499,7 +444,7 @@ pub mod pallet {
499444
}
500445

501446
/// Drop a single table
502-
#[pallet::call_index(5)]
447+
#[pallet::call_index(3)]
503448
#[pallet::weight(<T as Config>::WeightInfo::drop_table())]
504449
pub fn drop_table(
505450
origin: OriginFor<T>,
@@ -519,7 +464,7 @@ pub mod pallet {
519464
}
520465

521466
/// TODO remove this function
522-
#[pallet::call_index(6)]
467+
#[pallet::call_index(4)]
523468
#[pallet::weight(<T as Config>::WeightInfo::drop_table())]
524469
pub fn drop_invalid_commits(
525470
origin: OriginFor<T>,
@@ -533,7 +478,7 @@ pub mod pallet {
533478
}
534479

535480
/// Update the UUID for the specificed namespace and version to the provided UUID
536-
#[pallet::call_index(7)]
481+
#[pallet::call_index(5)]
537482
#[pallet::weight(<T as Config>::WeightInfo::update_namespace_uuid())]
538483
pub fn update_namespace_uuid(
539484
origin: OriginFor<T>,
@@ -560,7 +505,7 @@ pub mod pallet {
560505
}
561506

562507
/// Update the UUID for the specified table and version to the provided UUID
563-
#[pallet::call_index(8)]
508+
#[pallet::call_index(6)]
564509
#[pallet::weight(<T as Config>::WeightInfo::update_table_uuid())]
565510
pub fn update_table_uuid(
566511
origin: OriginFor<T>,
@@ -870,13 +815,6 @@ pub mod pallet {
870815
scheme,
871816
)?
872817
}
873-
CommitmentCreationCmd::FromSnapshot(ref snapshot_url, ref per_commitment_scheme) => {
874-
Snapshots::<T>::insert(table.ident.clone(), snapshot_url.clone());
875-
pallet_commitments::Pallet::<T>::process_create_table_from_snapshot_and_initiate_commitments(
876-
create_table,
877-
per_commitment_scheme.clone(),
878-
)?
879-
}
880818
};
881819

882820
// Reconstruct final DDL statement

pallets/tables/src/tests.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -141,42 +141,6 @@ fn update_tables_should_work_when_sudo() {
141141
})
142142
}
143143

144-
#[test]
145-
fn create_tables_should_work_when_sudo() {
146-
new_test_ext().execute_with(|| {
147-
System::set_block_number(1);
148-
149-
assert_ok!(
150-
Tables::create_tables_with_snapshot_and_commitment(
151-
RuntimeOrigin::root(),
152-
SourceAndMode::default(),
153-
CreateTableList::default(),
154-
),
155-
()
156-
);
157-
})
158-
}
159-
160-
#[test]
161-
fn create_tables_should_work_when_permissioned() {
162-
new_test_ext().execute_with(|| {
163-
System::set_block_number(1);
164-
165-
let (who, signer) = user(1);
166-
167-
set_permission!(who, TablesPalletPermission::EditSchema);
168-
169-
assert_ok!(
170-
Tables::create_tables_with_snapshot_and_commitment(
171-
signer,
172-
SourceAndMode::default(),
173-
CreateTableList::default(),
174-
),
175-
()
176-
);
177-
})
178-
}
179-
180144
#[test]
181145
fn create_namespace_should_work() {
182146
new_test_ext().execute_with(|| {

0 commit comments

Comments
 (0)