Skip to content

Commit

Permalink
Revert "refactor!: remove theft reporting"
Browse files Browse the repository at this point in the history
This reverts commit ecb7c6f.

Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
  • Loading branch information
gregdhill committed Jul 25, 2022
1 parent f069ac9 commit 7e5ca3f
Show file tree
Hide file tree
Showing 42 changed files with 2,919 additions and 264 deletions.
72 changes: 72 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions README.md
Expand Up @@ -64,6 +64,7 @@ The Substrate runtime makes use of various custom pallets that are found in the
- [oracle](crates/oracle): Trusted providers use this to set exchange rates and Bitcoin fee estimates.
- [redeem](crates/redeem): Handles redeeming of interBTC for BTC on Bitcoin.
- [refund](crates/refund): Handles refunds for when a vault receives more BTC than it can cover.
- [relay](crates/relay): Handles block submission and theft reporting.
- [replace](crates/replace): Handles replacing vaults.
- [reward](crates/reward): Scalable reward distribution.
- [security](crates/security): Handles status and error changes.
Expand Down
48 changes: 1 addition & 47 deletions crates/btc-relay/src/benchmarking.rs
Expand Up @@ -24,7 +24,7 @@ fn mine_genesis<T: Config>(account_id: T::AccountId, address: &BtcAddress, heigh
let raw_block_header = RawBlockHeader::from_bytes(&block.header.try_format().unwrap()).unwrap();
let block_header = BtcRelay::<T>::parse_raw_block_header(&raw_block_header).unwrap();

BtcRelay::<T>::_initialize(account_id, block_header, height).unwrap();
BtcRelay::<T>::initialize(account_id, block_header, height).unwrap();

block
}
Expand Down Expand Up @@ -76,52 +76,6 @@ fn mine_block_with_one_tx<T: Config>(
}

benchmarks! {
initialize {
let height = 0u32;
let origin: T::AccountId = account("Origin", 0, 0);
let stake = 100u32;

let address = BtcAddress::P2PKH(H160::from([0; 20]));
let block = BlockBuilder::new()
.with_version(4)
.with_coinbase(&address, 50, 3)
.with_timestamp(1588813835)
.mine(U256::from(2).pow(254.into())).unwrap();
let block_header = RawBlockHeader::from_bytes(&block.header.try_format().unwrap()).unwrap();
}: _(RawOrigin::Signed(origin), block_header, height)

store_block_header {
let origin: T::AccountId = account("Origin", 0, 0);

let address = BtcAddress::P2PKH(H160::from([0; 20]));
let height = 0;
let stake = 100u32;

let init_block = BlockBuilder::new()
.with_version(4)
.with_coinbase(&address, 50, 3)
.with_timestamp(1588813835)
.mine(U256::from(2).pow(254.into())).unwrap();

let init_block_hash = init_block.header.hash;
let raw_block_header = RawBlockHeader::from_bytes(&init_block.header.try_format().unwrap())
.expect("could not serialize block header");
let block_header = BtcRelay::<T>::parse_raw_block_header(&raw_block_header).unwrap();

BtcRelay::<T>::_initialize(origin.clone(), block_header, height).unwrap();

let block = BlockBuilder::new()
.with_previous_hash(init_block_hash)
.with_version(4)
.with_coinbase(&address, 50, 3)
.with_timestamp(1588814835)
.mine(U256::from(2).pow(254.into())).unwrap();

let raw_block_header = RawBlockHeader::from_bytes(&block.header.try_format().unwrap())
.expect("could not serialize block header");

}: _(RawOrigin::Signed(origin), raw_block_header)

verify_and_validate_transaction {
let origin: T::AccountId = account("Origin", 0, 0);

Expand Down
58 changes: 0 additions & 58 deletions crates/btc-relay/src/default_weights.rs
Expand Up @@ -34,8 +34,6 @@ use sp_std::marker::PhantomData;

/// Weight functions needed for btc_relay.
pub trait WeightInfo {
fn initialize() -> Weight;
fn store_block_header() -> Weight;
fn verify_and_validate_transaction() -> Weight;
fn verify_transaction_inclusion() -> Weight;
fn validate_transaction() -> Weight;
Expand All @@ -44,34 +42,6 @@ pub trait WeightInfo {
/// Weights for btc_relay using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Security ParachainStatus (r:1 w:0)
// Storage: BTCRelay BestBlock (r:1 w:1)
// Storage: BTCRelay ChainCounter (r:1 w:1)
// Storage: BTCRelay Chains (r:1 w:1)
// Storage: Security ActiveBlockCount (r:1 w:0)
// Storage: BTCRelay ChainsHashes (r:0 w:1)
// Storage: BTCRelay StartBlockHeight (r:0 w:1)
// Storage: BTCRelay BestBlockHeight (r:0 w:1)
// Storage: BTCRelay ChainsIndex (r:0 w:1)
// Storage: BTCRelay BlockHeaders (r:0 w:1)
fn initialize() -> Weight {
(52_878_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(8 as Weight))
}
// Storage: Security ParachainStatus (r:1 w:0)
// Storage: BTCRelay BlockHeaders (r:2 w:1)
// Storage: BTCRelay ChainsIndex (r:1 w:1)
// Storage: BTCRelay DisableDifficultyCheck (r:1 w:0)
// Storage: BTCRelay ChainsHashes (r:1 w:1)
// Storage: Security ActiveBlockCount (r:1 w:0)
// Storage: BTCRelay BestBlock (r:0 w:1)
// Storage: BTCRelay BestBlockHeight (r:0 w:1)
fn store_block_header() -> Weight {
(68_306_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(5 as Weight))
}
// Storage: Security ParachainStatus (r:1 w:0)
// Storage: BTCRelay DisableInclusionCheck (r:1 w:0)
// Storage: BTCRelay BestBlockHeight (r:1 w:0)
Expand Down Expand Up @@ -103,34 +73,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {

// For backwards compatibility and tests
impl WeightInfo for () {
// Storage: Security ParachainStatus (r:1 w:0)
// Storage: BTCRelay BestBlock (r:1 w:1)
// Storage: BTCRelay ChainCounter (r:1 w:1)
// Storage: BTCRelay Chains (r:1 w:1)
// Storage: Security ActiveBlockCount (r:1 w:0)
// Storage: BTCRelay ChainsHashes (r:0 w:1)
// Storage: BTCRelay StartBlockHeight (r:0 w:1)
// Storage: BTCRelay BestBlockHeight (r:0 w:1)
// Storage: BTCRelay ChainsIndex (r:0 w:1)
// Storage: BTCRelay BlockHeaders (r:0 w:1)
fn initialize() -> Weight {
(52_878_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
.saturating_add(RocksDbWeight::get().writes(8 as Weight))
}
// Storage: Security ParachainStatus (r:1 w:0)
// Storage: BTCRelay BlockHeaders (r:2 w:1)
// Storage: BTCRelay ChainsIndex (r:1 w:1)
// Storage: BTCRelay DisableDifficultyCheck (r:1 w:0)
// Storage: BTCRelay ChainsHashes (r:1 w:1)
// Storage: Security ActiveBlockCount (r:1 w:0)
// Storage: BTCRelay BestBlock (r:0 w:1)
// Storage: BTCRelay BestBlockHeight (r:0 w:1)
fn store_block_header() -> Weight {
(68_306_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
.saturating_add(RocksDbWeight::get().writes(5 as Weight))
}
// Storage: Security ParachainStatus (r:1 w:0)
// Storage: BTCRelay DisableInclusionCheck (r:1 w:0)
// Storage: BTCRelay BestBlockHeight (r:1 w:0)
Expand Down

0 comments on commit 7e5ca3f

Please sign in to comment.