-
Notifications
You must be signed in to change notification settings - Fork 149
/
anchor.rs
692 lines (626 loc) · 19.5 KB
/
anchor.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
//! # Off-chain Rollup Anchor
//!
//! Off-chain rollup anchor is a pallet that handles the off-chain rollup logic. It maintains a
//! kv-store for Phat Contract to read and write, and allows the Phat Contract to send arbitrary
//! messages to the blockchain to trigger custom actions.
//!
//! Off-chain Rollup enables ACID operations on the blockchain for Phat Contracts. The kv-stroe
//! access and the customzed actions are wrapped as Rollup Transactions. It guarantees that the
//! transactions are isolated and atomic. No conflicting transactions will be accepted.
//!
//! The anchor pallet is designed to implement such ACID machanism. It accepts the Rollup
//! Transaction submitted by the rollup client running in Phat Contract, validates it, and aplly
//! the changes.
//!
//! On the other hand, the pallet provides two features to the other pallets:
//!
//! 1. Push messages to the Phat Contract via the `push_message(name, content)`
//! 2. Receive messages from Phat Contract by handling `Config::OnResponse` callback trait
//!
//! ## Register a contract
//!
//! The anchor pallet allows arbitrary Phat Contract to connect to it. Before using, the Phat
//! Contract must register itself in the pallet to claim a name (in `H256`) by calling extrinsic
//! `claim_name(name)` by the _submitter account_.
//!
//! The _submitter account_ should be an account solely controlled by the Phat Contract. After
//! the name is claimed, the submitter account will be saved on the blockchain for access control.
//! The future rollup transactions must be submitted by that account. The mechanism ensures that
//! the transaction submission are genuine.
//!
//! The name can be arbitrary. However, usually it's suggested to use the contract id as the name
//! since it's unique. The name will be used to identify the connected contract and the associated
//! resources (kv-store and the queue).
//!
//! ## Outbound message queue
//!
//! The anchor pallet provides a message queue to help pass messages to the Phat Contracts:
//!
//! - `push_message(name, message)`: Push a message (arbitrary bytes) to the contract and return
//! the id of the message. The id starts from 0.
//! - `queue_head(name)`: Return the id of the first unprocessed message
//! - `queue_tail(name)`: Return the id of the last unprocessed message
//!
//! ## Receive a message
//!
//! The anchor pallet allows Phat Contracts to send message back to the blockchain. To subscribe
//! the messages, the receiver pallet should implement the [`OnResponse`] trait.
//!
//! ```ignore
//! impl<T: Config> OnResponse for Pallet<T> {
//! fn on_response(name: H256, submitter: AccountId, data: Vec<u8>) -> DispatchResult {
//! // Check `name` and handle the message data
//! }
//! }
//! ```
//!
#![allow(clippy::tabs_in_doc_comments)]
pub use self::pallet::*;
#[frame_support::pallet]
pub mod pallet {
use crate::types::*;
use core::fmt::Debug;
use frame_support::{
dispatch::DispatchResult, pallet_prelude::*, traits::StorageVersion, transactional,
};
use frame_system::pallet_prelude::*;
use sp_core::H256;
use sp_std::vec::Vec;
#[pallet::config]
pub trait Config: frame_system::Config {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type OnResponse: OnResponse<Self::AccountId>;
type QueuePrefix: Get<&'static [u8]>;
type QueueCapacity: Get<u32>;
}
/// Anchor response handler trait
pub trait OnResponse<AccountId> {
fn on_response(name: H256, submitter: AccountId, data: Vec<u8>) -> DispatchResult;
}
// Default implementation
impl<AccountId> OnResponse<AccountId> for () {
fn on_response(_name: H256, _submitter: AccountId, _data: Vec<u8>) -> DispatchResult {
Ok(())
}
}
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
/// Many-to-one mapping between names and their submitters
#[pallet::storage]
#[pallet::getter(fn submitter_by_names)]
pub type SubmitterByNames<T: Config> = StorageMap<_, Blake2_128Concat, H256, T::AccountId>;
#[pallet::storage]
#[pallet::getter(fn states)]
pub type States<T> =
StorageDoubleMap<_, Blake2_128Concat, H256, Blake2_128Concat, KeyBytes, ValueBytes>;
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A name is claimed by a submitter
NameClaimed { submitter: T::AccountId, name: H256 },
/// A rollup transaction is executed
RollupExecuted {
submitter: T::AccountId,
name: H256,
nonce: u128,
},
}
#[pallet::error]
#[derive(Eq, PartialEq)]
pub enum Error<T> {
/// A name was already claimed. You must switch to another name.
NameAlreadyClaimed,
/// The name doesn't exist
NameNotExist,
/// The operation is forbidden because it's not done by the name owner
NotOwner,
/// Rollup condition doesn't meet
CondNotMet,
/// Cannot decode the action
FailedToDecodeAction,
/// The queue is full.
QueueIsFull,
/// Trying to set an invalid queue head
InvalidQueueHead,
}
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Claims a name and assign the caller as the owner of the name
///
/// Once the name is claimed, we don't allow to change the owner or deregister any more.
#[pallet::call_index(0)]
#[pallet::weight({0})]
#[transactional]
pub fn claim_name(origin: OriginFor<T>, name: H256) -> DispatchResult {
let who = ensure_signed(origin)?;
ensure!(
SubmitterByNames::<T>::get(name).is_none(),
Error::<T>::NameAlreadyClaimed
);
SubmitterByNames::<T>::insert(name, &who);
Self::deposit_event(Event::NameClaimed {
submitter: who,
name,
});
Ok(())
}
/// Triggers a rollup with an optional nonce
#[pallet::call_index(1)]
#[pallet::weight({0})]
#[transactional]
pub fn rollup(
origin: OriginFor<T>,
name: H256,
tx: RollupTx,
nonce: u128,
) -> DispatchResult {
// Check submitter
let who = ensure_signed(origin)?;
Self::ensure_name_owner(&name, &who)?;
// Check conditions
for cond in tx.conds {
let Cond::Eq(key, opt_value) = cond;
ensure!(
States::<T>::get(name, key) == opt_value,
Error::<T>::CondNotMet
);
}
// Apply updates
for (key, opt_value) in tx.updates {
if let Some(v) = opt_value {
States::<T>::insert(name, key, v);
} else {
States::<T>::remove(name, key);
}
}
// Exec actions
for raw_act in tx.actions {
let act: Action =
Decode::decode(&mut &raw_act[..]).or(Err(Error::<T>::FailedToDecodeAction))?;
match act {
Action::Reply(data) => {
T::OnResponse::on_response(name, who.clone(), data.into())?
}
Action::SetQueueHead(head) => {
Self::queue_head_set(&name, head)?;
}
}
}
Self::deposit_event(Event::RollupExecuted {
submitter: who,
name,
nonce,
});
Ok(())
}
}
impl<T: Config> Pallet<T> {
/// Cheks the name is owned by the caller
fn ensure_name_owner(name: &H256, caller: &T::AccountId) -> DispatchResult {
let owner = SubmitterByNames::<T>::get(name).ok_or(Error::<T>::NameNotExist)?;
ensure!(&owner == caller, Error::<T>::NotOwner);
Ok(())
}
/// Pushes a message to the target rollup instance by `name`
///
/// Returns the index of the message if succeeded
pub fn push_message(name: &H256, data: ValueBytes) -> Result<u32, Error<T>> {
ensure!(
SubmitterByNames::<T>::contains_key(name),
Error::<T>::NameNotExist
);
ensure!(
Self::queue_len(name) < T::QueueCapacity::get(),
Error::<T>::QueueIsFull
);
let end = Self::queue_tail(name);
Self::queue_set(name, &end, data);
Self::queue_tail_set(name, end + 1);
Ok(end)
}
/// Returns the position of the message queue head element
///
/// When `queue_head() == queue_tail()`, the queue is empty.
pub fn queue_head(name: &H256) -> u32 {
Self::queue_get_u32(name, b"_head").expect("BUG: Failed to decode queue head")
}
/// Returns the position of the message queue tail element
///
/// When `queue_head() == queue_tail()`, the queue is empty.
pub fn queue_tail(name: &H256) -> u32 {
Self::queue_get_u32(name, b"_tail").expect("BUG: Failed to decode queue tail")
}
/// Returns number of elements in the queue
pub fn queue_len(name: &H256) -> u32 {
Self::queue_tail(name).saturating_sub(Self::queue_head(name))
}
}
/// Private helper methods
impl<T: Config> Pallet<T> {
fn queue_get_u32(name: &H256, index: &[u8; 5]) -> Result<u32, impl Debug> {
let Some(bytes) = Self::queue_get(name, index) else {
return Ok(0);
};
u32::decode(&mut &bytes[..])
}
fn queue_set_u32(name: &H256, index: &[u8; 5], value: u32) {
let value = value
.encode()
.try_into()
.expect("BUG: Failed to encode u32");
Self::queue_set(name, index, value);
}
fn queue_head_set(name: &H256, index: u32) -> DispatchResult {
let head = Self::queue_head(name);
let tail = Self::queue_tail(name);
ensure!(head <= index && index <= tail, Error::<T>::InvalidQueueHead);
for i in head..index {
Self::queue_remove(name, &i);
}
Self::queue_set_u32(name, b"_head", index);
Ok(())
}
fn queue_tail_set(name: &H256, index: u32) {
Self::queue_set_u32(name, b"_tail", index)
}
fn queue_key(index: &impl Encode) -> KeyBytes {
let mut key = T::QueuePrefix::get().to_vec();
index.encode_to(&mut key);
key.try_into()
.expect("BUG: Failed to make the queue key, the prefix might be too long")
}
fn queue_set(name: &H256, index: &impl Encode, data: ValueBytes) {
States::<T>::insert(name, Self::queue_key(index), data);
}
fn queue_get(name: &H256, index: &impl Encode) -> Option<ValueBytes> {
States::<T>::get(name, Self::queue_key(index))
}
fn queue_remove(name: &H256, index: &impl Encode) {
States::<T>::remove(name, Self::queue_key(index))
}
}
#[cfg(test)]
mod test {
use super::*;
use crate::{
mock::{
bvec, new_test_ext, set_block_1, take_events, Anchor, RuntimeEvent,
RuntimeOrigin as Origin, Test,
},
types::RollupTx,
};
// Pallets
use frame_support::{assert_noop, assert_ok};
use kv_session::ReadTracker;
const NAME1: H256 = H256([1u8; 32]);
#[test]
fn rollup_works() {
new_test_ext().execute_with(|| {
set_block_1();
assert_ok!(Anchor::claim_name(Origin::signed(1), NAME1));
// Can apply updates
assert_ok!(Anchor::rollup(
Origin::signed(1),
NAME1,
RollupTx {
conds: vec![],
actions: vec![],
updates: vec![(bvec(b"key"), Some(bvec(b"value")))],
},
1u128
));
assert_eq!(Anchor::states(NAME1, bvec(b"key")), Some(bvec(b"value")));
// Condition check can work
assert_ok!(Anchor::rollup(
Origin::signed(1),
NAME1,
RollupTx {
conds: vec![Cond::Eq(bvec(b"key"), Some(bvec(b"value")))],
actions: vec![],
updates: vec![(bvec(b"key"), Some(bvec(b"new-value")))],
},
2u128
));
assert_eq!(
Anchor::states(NAME1, bvec(b"key")),
Some(bvec(b"new-value"))
);
// Reject conflicting tx
assert_noop!(
Anchor::rollup(
Origin::signed(1),
NAME1,
RollupTx {
conds: vec![Cond::Eq(bvec(b"key"), Some(bvec(b"value")))],
actions: vec![],
updates: vec![],
},
3u128
),
Error::<Test>::CondNotMet
);
// Delete update
assert_ok!(Anchor::rollup(
Origin::signed(1),
NAME1,
RollupTx {
conds: vec![],
actions: vec![],
updates: vec![(bvec(b"key"), None)],
},
4u128
));
assert_eq!(Anchor::states(NAME1, bvec(b"key")), None);
// Action received
let resposne = crate::oracle::ResponseRecord {
owner: sp_runtime::AccountId32::from([0u8; 32]),
contract_id: NAME1,
pair: bvec(b"polkadot_usd"),
price: 5_000000000000,
timestamp_ms: 1000,
};
let act = Action::Reply(bvec(&resposne.encode()));
let _ = take_events();
assert_ok!(Anchor::rollup(
Origin::signed(1),
NAME1,
RollupTx {
conds: vec![],
actions: vec![bvec(&act.encode())],
updates: vec![],
},
5u128
));
assert_eq!(
take_events(),
vec![
RuntimeEvent::Oracle(crate::oracle::Event::<Test>::QuoteReceived {
contract: NAME1,
submitter: 1,
owner: sp_runtime::AccountId32::from([0u8; 32]),
pair: bvec(b"polkadot_usd"),
price: 5000000000000,
}),
RuntimeEvent::Anchor(crate::anchor::Event::<Test>::RollupExecuted {
submitter: 1,
name: NAME1,
nonce: 5,
}),
]
);
});
}
#[test]
fn name_cannot_claim_twice() {
new_test_ext().execute_with(|| {
set_block_1();
assert_ok!(Anchor::claim_name(Origin::signed(1), NAME1));
assert_noop!(
Anchor::claim_name(Origin::signed(2), NAME1),
Error::<Test>::NameAlreadyClaimed
);
});
}
#[test]
fn queue_key_is_correct() {
assert_eq!(&Anchor::queue_key(&1)[..], b"_queue/\x01\x00\x00\x00");
assert_eq!(
&Anchor::queue_key(b"_head")[..],
[95, 113, 117, 101, 117, 101, 47, 95, 104, 101, 97, 100]
);
}
#[test]
fn queue_works() {
new_test_ext().execute_with(|| {
set_block_1();
assert_ok!(Anchor::claim_name(Origin::signed(1), NAME1));
assert_eq!(Anchor::queue_head(&NAME1), 0);
assert_eq!(Anchor::queue_tail(&NAME1), 0);
assert_eq!(Anchor::queue_len(&NAME1), 0);
assert_eq!(Anchor::push_message(&NAME1, bvec(b"foo")), Ok(0));
assert_eq!(Anchor::queue_head(&NAME1), 0);
assert_eq!(Anchor::queue_tail(&NAME1), 1);
assert_eq!(Anchor::queue_len(&NAME1), 1);
let cap = <<Test as Config>::QueueCapacity as Get<_>>::get();
for i in 1..cap {
assert_eq!(Anchor::push_message(&NAME1, bvec(b"foo")), Ok(i));
}
assert_eq!(Anchor::queue_head(&NAME1), 0);
assert_eq!(Anchor::queue_tail(&NAME1), cap);
assert_eq!(Anchor::queue_len(&NAME1), cap);
assert_eq!(
Anchor::push_message(&NAME1, bvec(b"foo")),
Err(Error::<Test>::QueueIsFull)
);
assert_eq!(Anchor::queue_head(&NAME1), 0);
assert_eq!(Anchor::queue_tail(&NAME1), cap);
assert_eq!(Anchor::queue_len(&NAME1), cap);
for i in 0..cap {
assert!(Anchor::queue_get(&NAME1, &i).is_some());
}
// Pop all elements except the last one
assert_ok!(Anchor::rollup(
Origin::signed(1),
NAME1,
RollupTx {
conds: vec![],
actions: vec![bvec(&Action::SetQueueHead(cap - 1).encode())],
updates: vec![],
},
1u128
));
assert_eq!(Anchor::queue_head(&NAME1), cap - 1);
assert_eq!(Anchor::queue_tail(&NAME1), cap);
assert_eq!(Anchor::queue_len(&NAME1), 1);
for i in 0..cap - 1 {
assert!(Anchor::queue_get(&NAME1, &i).is_none());
}
let last = cap - 1;
assert!(Anchor::queue_get(&NAME1, &last).is_some());
// Pop the last one
assert_ok!(Anchor::rollup(
Origin::signed(1),
NAME1,
RollupTx {
conds: vec![],
actions: vec![bvec(&Action::SetQueueHead(cap).encode())],
updates: vec![],
},
1u128
));
assert_eq!(Anchor::queue_len(&NAME1), 0);
// Pop more should fail
assert_noop!(
Anchor::rollup(
Origin::signed(1),
NAME1,
RollupTx {
conds: vec![],
actions: vec![bvec(&Action::SetQueueHead(cap + 1).encode())],
updates: vec![],
},
1u128
),
Error::<Test>::InvalidQueueHead
);
});
}
#[test]
fn queue_e2e() {
use kv_session::traits::KvSession;
use kv_session::traits::KvSnapshot;
use kv_session::traits::QueueSession;
use kv_session::{Error, Result};
struct ChainStorage {
name: H256,
}
impl KvSnapshot for ChainStorage {
/// Should be the block hash for a blockchain backend
fn snapshot_id(&self) -> Result<Vec<u8>> {
Ok(Vec::new())
}
/// Get a storage value from the snapshot
fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>> {
let key: KeyBytes = key.to_vec().try_into().unwrap();
Ok(States::<Test>::get(self.name, key).map(|x| x.to_vec()))
}
}
impl kv_session::traits::BumpVersion for ChainStorage {
fn bump_version(&self, version: Option<Vec<u8>>) -> Result<Vec<u8>> {
match version {
Some(v) => {
let ov = u32::decode(&mut &v[..]).or(Err(Error::FailedToDecode))?;
Ok((ov + 1).encode())
}
None => Ok(1_u32.encode()),
}
}
}
struct ScaleCodec;
impl kv_session::traits::QueueIndexCodec for ScaleCodec {
fn encode(number: u32) -> Vec<u8> {
number.encode()
}
fn decode(raw: impl AsRef<[u8]>) -> Result<u32> {
Decode::decode(&mut raw.as_ref()).or(Err(Error::FailedToDecode))
}
}
fn test_client() -> kv_session::Session<ChainStorage, ReadTracker, ScaleCodec> {
kv_session::Session::new(
ChainStorage { name: NAME1 },
ReadTracker::new(),
b"_queue/",
)
.unwrap()
}
fn rollup_tx(
tx: kv_session::traits::KvTransaction,
kvdb: ChainStorage,
) -> Option<RollupTx> {
let tx = kv_session::rollup::rollup(
&kvdb,
tx,
kv_session::rollup::VersionLayout::Standalone {
key_postfix: "_ver".into(),
},
)
.ok()?;
if !tx.has_updates() {
// We don't have to submit it if there are no updates
return None;
}
let conds = tx
.conditions
.into_iter()
.map(|(k, v)| Cond::Eq(k.try_into().unwrap(), v.map(|v| v.try_into().unwrap())))
.collect();
let updates = tx
.updates
.into_iter()
.map(|(k, v)| (k.try_into().unwrap(), v.map(|v| v.try_into().unwrap())))
.collect();
let mut actions = vec![];
if let Some(head) = tx.queue_head {
actions.push(bvec(&Action::SetQueueHead(head).encode()));
}
Some(RollupTx {
conds,
actions,
updates,
})
}
new_test_ext().execute_with(|| {
set_block_1();
assert_ok!(Anchor::claim_name(Origin::signed(1), NAME1));
assert_eq!(Anchor::queue_head(&NAME1), 0);
assert_eq!(Anchor::queue_tail(&NAME1), 0);
assert_eq!(Anchor::queue_len(&NAME1), 0);
// Put some data in the queue on-chain.
assert_eq!(Anchor::push_message(&NAME1, bvec(b"Tom")), Ok(0));
assert_eq!(Anchor::push_message(&NAME1, bvec(b"Kitty")), Ok(1));
assert_eq!(Anchor::queue_head(&NAME1), 0);
assert_eq!(Anchor::queue_tail(&NAME1), 2);
assert_eq!(Anchor::queue_len(&NAME1), 2);
let rollup = {
// Create an client to consume the elements.
let mut client = test_client();
assert_eq!(client.pop().unwrap(), Some(b"Tom".to_vec()));
assert_eq!(client.pop().unwrap(), Some(b"Kitty".to_vec()));
assert_eq!(client.pop().unwrap(), None);
// Set kv should also works.
assert_eq!(client.get(b"foo").unwrap(), None);
client.put(b"foo", b"bar".to_vec());
let (tx, db) = client.commit();
rollup_tx(tx, db).unwrap()
};
let dup_rollup = {
let mut client = test_client();
assert_eq!(client.get(b"foo").unwrap(), None);
client.put(b"foo", b"baz".to_vec());
let (tx, db) = client.commit();
rollup_tx(tx, db).unwrap()
};
// Apply the session updates
assert_ok!(Anchor::rollup(Origin::signed(1), NAME1, rollup, 1u128));
assert_eq!(Anchor::queue_head(&NAME1), 2);
assert_eq!(Anchor::queue_tail(&NAME1), 2);
assert_eq!(Anchor::queue_len(&NAME1), 0);
// The kv set should be applied
let mut client = test_client();
assert_eq!(client.pop().unwrap(), None);
assert_eq!(client.get(b"foo").unwrap(), Some(b"bar".to_vec()));
// Could not apply the duplicated updates
assert_noop!(
Anchor::rollup(Origin::signed(1), NAME1, dup_rollup, 1u128),
super::Error::<Test>::CondNotMet
);
});
}
// TODO: test cases
//
// fn rollup_bad_cond
// fn rollup_bad_action
}
}