Skip to content

Commit

Permalink
Merge branch 'main' into code-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gpmayorga authored Mar 7, 2024
2 parents 95e520e + 2e45ffa commit 83c4ca0
Show file tree
Hide file tree
Showing 157 changed files with 5,896 additions and 4,271 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 #v3.0.0
uses: docker/setup-buildx-action@0d103c3126aa41d772a8362f6aa67afac040f80c #v3.1.0

- name: DockerHub Registry Login
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:

- name: Setup - gcloud / gsutil
if: ${{ steps.auth.outcome == 'success' }}
uses: google-github-actions/setup-gcloud@5a5f7b85fca43e76e53463acaa9d408a03c98d3a # v2.0.1
uses: google-github-actions/setup-gcloud@98ddc00a17442e89a24bbf282954a3b65ce6d200 # v2.1.0

- name: Publish artifacts to GCS
if: ${{ steps.auth.outcome == 'success' }}
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
<div align="center">

[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/centrifuge/centrifuge-chain/build-wasm.yml?label=Actions&logo=github)](https://github.com/centrifuge/centrifuge-chain/actions)
[![GitHub Release](https://img.shields.io/github/v/release/centrifuge/centrifuge-chain)](https://github.com/centrifuge/centrifuge-chain/releases)
[![Substrate version](https://img.shields.io/badge/Substrate-2.0.0-brightgreen?logo=Parity%20Substrate)](https://substrate.io/)
[![License](https://img.shields.io/github/license/centrifuge/centrifuge-chain?color=green)](https://github.com/centrifuge/centrifuge-chain/blob/main/LICENSE)
<br />
[![Twitter URL](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Ftwitter.com%2Fcentrifuge)](https://twitter.com/centrifuge/)
[![Telegram](https://img.shields.io/badge/Telegram-gray?logo=telegram)](https://t.me/centrifuge_chat)

</div>

<p align="center">
<a href="https://github.com/centrifuge/centrifuge-chain">
<a href="https://centrifuge.io">
<img alt="Centrifuge" src="/docs/images/banner.svg">
</a>
<h2 align="center">Centrifuge Chain</h2>
Expand Down
13 changes: 12 additions & 1 deletion libs/traits/src/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,30 @@ pub enum PoolFeeBucket {
}

/// Trait to add fees to a pool
pub trait PoolFees {
pub trait PoolFeesMutate {
type PoolId;
type FeeInfo;

/// Add a new fee to the pool and bucket.
///
/// NOTE: Assumes call permissions are separately checked beforehand.
fn add_fee(pool_id: Self::PoolId, bucket: PoolFeeBucket, fee: Self::FeeInfo) -> DispatchResult;
}

/// Trait to get pool fees counts
pub trait PoolFeesInspect {
type PoolId;

/// Returns the maximum number of pool fees required for accurate weights
fn get_max_fee_count() -> u32;

/// Returns the maximum number of pool fees per bucket required for accurate
/// weights
fn get_max_fees_per_bucket() -> u32;

/// Returns the current amount of active fees for the given pool
fn get_pool_fee_count(pool: Self::PoolId) -> u32;

/// Returns the current amount of active fees for the given pool and bucket
/// pair
fn get_pool_fee_bucket_count(pool: Self::PoolId, bucket: PoolFeeBucket) -> u32;
Expand Down
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ is-it-maintained-open-issues = { repository = "centrifuge/centrifuge-chain" }

[package]
name = "centrifuge-chain"
version = "0.10.35"
version = "0.10.36"
description = "Centrifuge chain implementation in Rust."
build = "build.rs"
default-run = "centrifuge-chain"
Expand Down
4 changes: 2 additions & 2 deletions pallets/block-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ pub mod pallet {

/// Admin method to set the reward amount for a collator used for the
/// next sessions. Current session is not affected by this call.
#[pallet::weight(T::WeightInfo::set_collator_reward())]
#[pallet::weight(T::WeightInfo::set_collator_reward_per_session())]
#[pallet::call_index(1)]
pub fn set_collator_reward_per_session(
origin: OriginFor<T>,
Expand All @@ -300,7 +300,7 @@ pub mod pallet {

/// Admin method to set the treasury inflation rate for the next
/// sessions. Current session is not affected by this call.
#[pallet::weight(T::WeightInfo::set_total_reward())]
#[pallet::weight(T::WeightInfo::set_annual_treasury_inflation_rate())]
#[pallet::call_index(2)]
pub fn set_annual_treasury_inflation_rate(
origin: OriginFor<T>,
Expand Down
42 changes: 25 additions & 17 deletions pallets/block-rewards/src/weights.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//! Autogenerated weights for pallet_block_rewards
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION
//! 4.0.0-dev DATE: 2023-02-28, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH
//! RANGE: `[]` EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN:
//! Some("development"), DB CACHE: 1024
//! 4.0.0-dev DATE: 2024-03-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH
//! RANGE: `[]` WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner`, CPU: `AMD EPYC 7763 64-Core Processor`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN:
//! Some("centrifuge-dev"), DB CACHE: 1024
// Executed Command:
// target/release/centrifuge-chain
Expand Down Expand Up @@ -32,50 +34,56 @@ use sp_std::marker::PhantomData;
/// Weight functions needed for pallet_block_rewards.
pub trait WeightInfo {
fn claim_reward() -> Weight;
fn set_collator_reward() -> Weight;
fn set_total_reward() -> Weight;
fn set_collator_reward_per_session() -> Weight;
fn set_annual_treasury_inflation_rate() -> Weight;
}

/// Weights for pallet_block_rewards using the Substrate node and recommended
/// hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
fn claim_reward() -> Weight {
Weight::from_parts(49_000_000, 0)
Weight::from_parts(90_960_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}

fn set_collator_reward() -> Weight {
Weight::from_parts(8_000_000, 0)
fn set_collator_reward_per_session() -> Weight {
Weight::from_parts(9_327_000, 0)
.saturating_add(Weight::from_parts(0, 3582))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}

fn set_total_reward() -> Weight {
Weight::from_parts(9_000_000, 0)
.saturating_add(T::DbWeight::get().reads(2))
fn set_annual_treasury_inflation_rate() -> Weight {
Weight::from_parts(9_418_000, 0)
.saturating_add(Weight::from_parts(0, 3582))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}

// For backwards compatibility and tests
impl WeightInfo for () {
fn claim_reward() -> Weight {
Weight::from_parts(49_000_000, 0)
Weight::from_parts(90_960_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(RocksDbWeight::get().reads(5))
.saturating_add(RocksDbWeight::get().writes(3))
}

fn set_collator_reward() -> Weight {
Weight::from_parts(8_000_000, 0)
fn set_collator_reward_per_session() -> Weight {
Weight::from_parts(9_327_000, 0)
.saturating_add(Weight::from_parts(0, 3582))
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}

fn set_total_reward() -> Weight {
Weight::from_parts(9_000_000, 0)
.saturating_add(RocksDbWeight::get().reads(2))
fn set_annual_treasury_inflation_rate() -> Weight {
Weight::from_parts(9_418_000, 0)
.saturating_add(Weight::from_parts(0, 3582))
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}
}
4 changes: 4 additions & 0 deletions pallets/foreign-investments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ pub mod pallet {

use super::*;

/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);

/// Configure the pallet by specifying the parameters and types on which it
Expand Down
5 changes: 0 additions & 5 deletions pallets/oracle-collection/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub trait WeightInfo {
fn propose_update_collection_info(feeders: u32) -> Weight;
fn apply_update_collection_info(feeders: u32) -> Weight;
fn update_collection(feeders: u32, keys: u32) -> Weight;
fn set_collection_info() -> Weight;
}

impl WeightInfo for () {
Expand All @@ -32,8 +31,4 @@ impl WeightInfo for () {
fn update_collection(_: u32, _: u32) -> Weight {
Weight::zero()
}

fn set_collection_info() -> Weight {
Weight::zero()
}
}
4 changes: 2 additions & 2 deletions pallets/order-book/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use sp_runtime::{traits::checked_pow, FixedPointNumber};

use super::*;

const CURRENCY_IN: u32 = 1;
const CURRENCY_OUT: u32 = 2;
const CURRENCY_IN: u32 = 1001;
const CURRENCY_OUT: u32 = 1002;
const RATIO: u32 = 2; // x2
const FEEDER: u32 = 23;

Expand Down
2 changes: 1 addition & 1 deletion pallets/order-book/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> {
/// Create an order with the default min fulfillment amount.
#[pallet::call_index(0)]
#[pallet::weight(T::Weights::create_order())]
#[pallet::weight(T::Weights::place_order())]
pub fn place_order(
origin: OriginFor<T>,
currency_in: T::CurrencyId,
Expand Down
5 changes: 2 additions & 3 deletions pallets/order-book/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ pub const FEEDER: u64 = 0x42;
pub const INITIAL_A: Balance = token_a(1000);
pub const INITIAL_B: Balance = token_b(1000);

pub const CURRENCY_A: CurrencyId = CurrencyId::ForeignAsset(1);
pub const CURRENCY_B: CurrencyId = CurrencyId::ForeignAsset(2);
pub const CURRENCY_X: CurrencyId = CurrencyId::ForeignAsset(3);
pub const CURRENCY_A: CurrencyId = CurrencyId::ForeignAsset(1001);
pub const CURRENCY_B: CurrencyId = CurrencyId::ForeignAsset(1002);
pub const CURRENCY_A_DECIMALS: u32 = 9;
pub const CURRENCY_B_DECIMALS: u32 = 12;

Expand Down
4 changes: 2 additions & 2 deletions pallets/order-book/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
pub use frame_support::weights::Weight;

pub trait WeightInfo {
fn create_order() -> Weight;
fn place_order() -> Weight;
fn update_order() -> Weight;
fn cancel_order() -> Weight;
fn fill_order() -> Weight;
fn set_market_feeder() -> Weight;
}

impl WeightInfo for () {
fn create_order() -> Weight {
fn place_order() -> Weight {
Weight::zero()
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/pool-fees/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use cfg_traits::{
benchmarking::{PoolBenchmarkHelper, PoolFeesBenchmarkHelper},
changes::ChangeGuard,
fee::{PoolFeeBucket, PoolFees as _},
fee::{PoolFeeBucket, PoolFeesMutate as _},
};
use cfg_types::pools::PoolFeeEditor;
use frame_benchmarking::v2::*;
Expand Down
Loading

0 comments on commit 83c4ca0

Please sign in to comment.