-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dapp staking v3 - Oracle solution (#1197)
* Init commit * Progress on the implementation * More functionality * Price type updates, docs, functionality implementation * Tests, minor updates * More test & some fixes * Tests & minor fixes * Finished implementation * Docs * Year change to make license check happy * Full integration - init version * genesis * Move dummy combiner to primitives * Changes * orml oracle benchmarks dummy pallet * Temporary benchmarks * Comment * Resolve TODOs * Price aggregator weights * Post merge adjustments * Weights update * Integration tests * Remove comment * Fix UT * dApp staking v3 update * Comments
- Loading branch information
Showing
29 changed files
with
2,162 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
[package] | ||
name = "oracle-benchmarks" | ||
version = "0.1.0" | ||
license = "GPL-3.0-or-later" | ||
description = "Temporary pallet to benchmark orml-oracle. Should be handled by orml-oracle itself in the future." | ||
authors.workspace = true | ||
edition.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
log = { workspace = true } | ||
parity-scale-codec = { workspace = true } | ||
serde = { workspace = true } | ||
|
||
frame-support = { workspace = true } | ||
frame-system = { workspace = true } | ||
scale-info = { workspace = true } | ||
sp-arithmetic = { workspace = true } | ||
sp-runtime = { workspace = true } | ||
sp-std = { workspace = true } | ||
|
||
orml-oracle = { workspace = true } | ||
orml-traits = { workspace = true } | ||
|
||
astar-primitives = { workspace = true } | ||
|
||
frame-benchmarking = { workspace = true, optional = true } | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"parity-scale-codec/std", | ||
"log/std", | ||
"scale-info/std", | ||
"serde/std", | ||
"sp-std/std", | ||
"frame-support/std", | ||
"frame-system/std", | ||
"astar-primitives/std", | ||
"sp-arithmetic/std", | ||
"orml-traits/std", | ||
"orml-oracle/std", | ||
] | ||
runtime-benchmarks = [ | ||
"frame-benchmarking", | ||
"frame-support/runtime-benchmarks", | ||
"frame-system/runtime-benchmarks", | ||
"sp-runtime/runtime-benchmarks", | ||
"astar-primitives/runtime-benchmarks", | ||
] | ||
try-runtime = ["frame-support/try-runtime"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// This file is part of Astar. | ||
|
||
// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
// Astar is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Astar is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Astar. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
#![cfg(feature = "runtime-benchmarks")] | ||
|
||
use super::*; | ||
use frame_benchmarking::v2::*; | ||
use frame_support::{ | ||
assert_ok, | ||
traits::{Get, OnFinalize}, | ||
BoundedVec, | ||
}; | ||
use frame_system::RawOrigin; | ||
use sp_std::vec; | ||
|
||
#[benchmarks] | ||
mod benchmarks { | ||
use super::*; | ||
|
||
#[benchmark] | ||
fn feed_values(x: Linear<1, { <T as orml_oracle::Config>::MaxFeedValues::get() }>) { | ||
// Prepare account and add it as member | ||
let account: T::AccountId = whitelisted_caller(); | ||
T::AddMember::add_member(account.clone()); | ||
|
||
// Get base feed value | ||
let currency_id_price_pair = T::BenchmarkCurrencyIdValuePair::get(); | ||
|
||
// Prepare feed values vector | ||
let mut key_value_pairs = | ||
BoundedVec::<_, <T as orml_oracle::Config>::MaxFeedValues>::default(); | ||
for _ in 0..x { | ||
key_value_pairs | ||
.try_push(currency_id_price_pair.clone()) | ||
.unwrap(); | ||
} | ||
|
||
#[block] | ||
{ | ||
assert_ok!(orml_oracle::Pallet::<T>::feed_values( | ||
RawOrigin::Signed(account.clone()).into(), | ||
key_value_pairs | ||
)); | ||
} | ||
} | ||
|
||
#[benchmark] | ||
fn on_finalize() { | ||
#[block] | ||
{ | ||
orml_oracle::Pallet::<T>::on_finalize(1_u32.into()); | ||
} | ||
} | ||
} |
Oops, something went wrong.