Skip to content

Commit

Permalink
Merge branch 'dan/compute-griefing-collateral' into 'master'
Browse files Browse the repository at this point in the history
Dan/compute griefing collateral

See merge request interlay/polkabtc-clients!169
  • Loading branch information
nud3l committed Jan 15, 2021
2 parents 4645e89 + 3b33c11 commit aabc878
Show file tree
Hide file tree
Showing 9 changed files with 314 additions and 224 deletions.
102 changes: 75 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ use pallets::*;
pub use rpc::{
historic_event_types, AccountId, BtcRelayPallet, BtcTxFeesPerByte, DotBalancesPallet,
ExchangeRateOraclePallet, FeePallet, IssuePallet, PolkaBtcHeader, PolkaBtcIssueRequest,
PolkaBtcProvider, PolkaBtcRedeemRequest, PolkaBtcReplaceRequest, PolkaBtcRequestIssueEvent,
PolkaBtcStatusUpdate, PolkaBtcVault, RedeemPallet, ReplacePallet, SecurityPallet,
StakedRelayerPallet, TimestampPallet, UtilFuncs, VaultRegistryPallet,
PolkaBtcProvider, PolkaBtcRedeemRequest, PolkaBtcReplaceRequest,
PolkaBtcRequestIssueEvent, PolkaBtcStatusUpdate, PolkaBtcVault, RedeemPallet,
ReplacePallet, SecurityPallet, StakedRelayerPallet, TimestampPallet, UtilFuncs,
VaultRegistryPallet,
};
pub use security::{ErrorCode, StatusCode};
pub use sp_arithmetic::{traits as FixedPointTraits, FixedI128, FixedPointNumber, FixedU128};
Expand Down
7 changes: 6 additions & 1 deletion runtime/src/pallets/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ use substrate_subxt_proc_macro::{module, Store};
#[module]
pub trait Fee: Core {}

/// Current BTC/DOT exchange rate
#[derive(Clone, Debug, Eq, PartialEq, Store, Encode)]
pub struct IssueGriefingCollateralStore<T: Fee> {
#[store(returns = T::UnsignedFixedPoint)]
pub _runtime: PhantomData<T>,
}

#[derive(Clone, Debug, Eq, PartialEq, Store, Encode)]
pub struct ReplaceGriefingCollateralStore<T: Fee> {
#[store(returns = T::UnsignedFixedPoint)]
pub _runtime: PhantomData<T>,
}
6 changes: 6 additions & 0 deletions runtime/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1406,11 +1406,17 @@ impl VaultRegistryPallet for PolkaBtcProvider {
#[async_trait]
pub trait FeePallet {
async fn get_issue_griefing_collateral(&self) -> Result<FixedU128, Error>;

async fn get_replace_griefing_collateral(&self) -> Result<FixedU128, Error>;
}

#[async_trait]
impl FeePallet for PolkaBtcProvider {
async fn get_issue_griefing_collateral(&self) -> Result<FixedU128, Error> {
Ok(self.ext_client.issue_griefing_collateral(None).await?)
}

async fn get_replace_griefing_collateral(&self) -> Result<FixedU128, Error> {
Ok(self.ext_client.replace_griefing_collateral(None).await?)
}
}
6 changes: 4 additions & 2 deletions staked-relayer/src/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ mod tests {
use super::*;
use async_trait::async_trait;
use runtime::PolkaBtcStatusUpdate;
use runtime::{AccountId, BtcTxFeesPerByte, Error, ErrorCode, H256Le, StatusCode};

use runtime::{
AccountId, BtcTxFeesPerByte, Error, ErrorCode, FixedPointNumber, FixedU128, H256Le,
StatusCode,
};
use std::collections::BTreeSet;
use std::iter::FromIterator;

Expand Down
3 changes: 2 additions & 1 deletion vault/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ thiserror = "1.0"
clap = "3.0.0-beta.2"
sp-keyring = "2.0.0"
sp-core = "2.0.0"
sp-arithmetic = "2.0.0"
runtime = { path = "../runtime" }
bitcoin = { path = "../bitcoin", features = ["cli"] }
backoff = { version = "0.2.1", features = ["tokio"] }
serde = "1.0.116"
serde_json = { version = "1.0.57", features = ["raw_value"] }
hex = "0.4.2"
parity-scale-codec = "1.3.1"
jsonrpc-http-server = "15.1.0"
jsonrpc-http-server = "16.0.0"
futures = "0.3.5"
async-trait = "0.1.40"

Expand Down
Loading

0 comments on commit aabc878

Please sign in to comment.