Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

use ValidateUnsigned to validate unsigned tx #133

Merged
merged 1 commit into from
Feb 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions modules/cdp_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,19 @@ impl<T: Trait> Module<T> {
if let Some((_, account_id)) = key {
// TODO: liquidate unsafe cdp before emergency shutdown, settle cdp with debit when emergency shutdown occurs.
if Self::is_unsafe_cdp(currency_id, &account_id) {
if let Err(e) = Self::submit_unsigned_liquidation_tx(currency_id, account_id) {
if let Err(e) = Self::submit_unsigned_liquidation_tx(currency_id, account_id.clone()) {
debug::debug!(
target: "cdp-engine offchain worker",
"faild to submit unsigned liquidation tx: {:?}",
e,
);
} else {
debug::info!(
target: "cdp-engine offchain worker",
"successfully submit unsigned liquidation tx for CDP: \n AccountId - {:?} \n CurrencyId: {:?}",
account_id,
currency_id,
);
}
}
}
Expand Down Expand Up @@ -700,7 +707,7 @@ impl<T: Trait> frame_support::unsigned::ValidateUnsigned for Module<T> {
Ok(ValidTransaction {
priority: TransactionPriority::max_value(),
requires: vec![],
provides: vec![],
provides: vec![(<system::Module<T>>::block_number(), currency_id, who).encode()],
longevity: 64_u64,
propagate: true,
})
Expand Down
4 changes: 1 addition & 3 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,6 @@ impl system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtim
system::CheckWeight::<Runtime>::new(),
orml_oracle::CheckOperator::<Runtime>::new(),
module_accounts::ChargeTransactionPayment::<Runtime>::from(tip),
module_cdp_engine::AutomaticLiquidationValidation::<Runtime>::new(),
);
let raw_payload = SignedPayload::new(call, extra)
.map_err(|e| {
Expand Down Expand Up @@ -686,7 +685,7 @@ construct_runtime!(
Auction: orml_auction::{Module, Storage, Call, Event<T>},
AuctionManager: module_auction_manager::{Module, Storage, Call, Event<T>},
Loans: module_loans::{Module, Storage, Call, Event<T>},
CdpEngine: module_cdp_engine::{Module, Storage, Call, Event<T>, Config<T>},
CdpEngine: module_cdp_engine::{Module, Storage, Call, Event<T>, Config<T>, ValidateUnsigned},
Honzon: module_honzon::{Module, Storage, Call, Event<T>},
Dex: module_dex::{Module, Storage, Call, Event<T>},
CdpTreasury: module_cdp_treasury::{Module, Storage, Call, Config<T>, Event<T>},
Expand Down Expand Up @@ -715,7 +714,6 @@ pub type SignedExtra = (
system::CheckWeight<Runtime>,
orml_oracle::CheckOperator<Runtime>,
module_accounts::ChargeTransactionPayment<Runtime>,
module_cdp_engine::AutomaticLiquidationValidation<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
Expand Down