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

Latest cleanings pre audit #1974

Merged
merged 12 commits into from
Aug 18, 2024
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ members = [
"pallets/keystore",
"pallets/liquidity-pools",
"pallets/liquidity-pools-gateway",
"pallets/liquidity-pools-gateway/queue",
"pallets/liquidity-pools-gateway-queue",
"pallets/liquidity-pools-forwarder",
"pallets/liquidity-rewards",
"pallets/loans",
Expand Down Expand Up @@ -236,7 +236,7 @@ pallet-investments = { path = "pallets/investments", default-features = false }
pallet-keystore = { path = "pallets/keystore", default-features = false }
pallet-liquidity-pools = { path = "pallets/liquidity-pools", default-features = false }
pallet-liquidity-pools-gateway = { path = "pallets/liquidity-pools-gateway", default-features = false }
pallet-liquidity-pools-gateway-queue = { path = "pallets/liquidity-pools-gateway/queue", default-features = false }
pallet-liquidity-pools-gateway-queue = { path = "pallets/liquidity-pools-gateway-queue", default-features = false }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can leave this name as it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then it would look weird if the pallet is being used for another kind of queues...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a problem for future-us :D Plus, I think that eventually we'll drop it and use Tasks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced by the name, but I will leave it as it

pallet-liquidity-pools-forwarder = { path = "pallets/liquidity-pools-forwarder", default-features = false }
pallet-liquidity-rewards = { path = "pallets/liquidity-rewards", default-features = false }
pallet-loans = { path = "pallets/loans", default-features = false }
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ Centrifuge is the infrastructure that facilitates the decentralized financing of
On top of the [Substrate FRAME](https://docs.substrate.io/reference/frame-pallets/) framework, Centrifuge Chain is composed of custom pallets which can be found inside the `pallets` folder. The following list gives a brief overview, and links to the corresponding documentation:

- [**anchors**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/anchors) ([docs](https://reference.centrifuge.io/pallet_anchors/index.html)): Storing hashes of documents on-chain. The documents are stored in the Private Off-chain Data (POD) node network.
-

- [**anchors-v2**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/anchors-v2) ([docs](https://reference.centrifuge.io/pallet_anchors_v2/index.html)): Second version of the pallet used to store document hashes on-chain.

- [**axelar-routers**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools-gateway/pallet-axelar-router) ([docs](https://reference.centrifuge.io/pallet-axelar-router/index.html)): Pallet that communicates with other chains through axelar.

- [**block-rewards**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/block-rewards) ([docs](https://reference.centrifuge.io/pallet_block_rewards/index.html)): Provides means of configuring and distributing block rewards to collators as well as the annual treasury inflation.

- [**bridge**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/bridge) ([docs](https://reference.centrifuge.io/pallet_bridge/index.html)): Connecting [ChainBridge](https://github.com/centrifuge/chainbridge-substrate) to transfer tokens to and from Ethereum.
Expand All @@ -54,12 +56,8 @@ On top of the [Substrate FRAME](https://docs.substrate.io/reference/frame-pallet
- [**liquidity-pools**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools) ([docs](https://reference.centrifuge.io/pallet_liquidity_pools/index.html)): Provides the toolset to enable foreign investments on foreign domains.

- [**liquidity-pools-gateway**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools-gateway) ([docs](https://reference.centrifuge.io/pallet_liquidity_pools_gateway/index.html)): The main handler of incoming and outgoing Liquidity Pools messages.
-
- [**liquidity-pools-gateway-queue**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools-gateway/queue) ([docs](https://reference.centrifuge.io/pallet_liquidity_pools_gateway_queue/index.html)): The queue used by the Liquidity Pools Gateway for processing inbound/outbound messages.

- [**liquidity-pools-gateway-routers**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools-gateway/routers) ([docs](https://reference.centrifuge.io/liquidity_pools_gateway_routers/index.html)): This crate contains the `DomainRouters` used by the Liquidity Pools Gateway pallet.

- [**axelar-gateway-precompile**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools-gateway/axelar-gateway-precompile) ([docs](https://reference.centrifuge.io/axelar_gateway_precompile/index.html)): Pallet that serves as an EVM precompile for incoming Liquidity Pools messages from the Axelar network.
- [**liquidity-pools-gateway-queue**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools-gateway/queue) ([docs](https://reference.centrifuge.io/pallet_liquidity_pools_gateway_queue/index.html)): The queue used by the Liquidity Pools Gateway for processing inbound/outbound messages.

- [**liquidity-rewards**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-rewards) ([docs](https://reference.centrifuge.io/pallet_liquidity_rewards/index.html)): Epoch based reward system.

Expand Down
3 changes: 1 addition & 2 deletions libs/mocks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ pub mod foreign_investment_hooks;
pub mod investment;
pub mod liquidity_pools;
pub mod liquidity_pools_gateway;
pub mod liquidity_pools_gateway_queue;
pub mod pay_fee;
pub mod permissions;
pub mod pools;
pub mod pre_conditions;
pub mod queue;
pub mod rewards;
pub mod router_message;
pub mod status_notification;
Expand All @@ -30,7 +30,6 @@ pub use fees::pallet as pallet_mock_fees;
pub use investment::pallet as pallet_mock_investment;
pub use liquidity_pools::pallet as pallet_mock_liquidity_pools;
pub use liquidity_pools_gateway::pallet as pallet_mock_liquidity_pools_gateway;
pub use liquidity_pools_gateway_queue::pallet as pallet_mock_liquidity_pools_gateway_queue;
pub use pay_fee::pallet as pallet_mock_pay_fee;
pub use permissions::pallet as pallet_mock_permissions;
pub use pools::pallet as pallet_mock_pools;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ pub mod pallet {
type CallIds<T: Config> = StorageMap<_, _, String, mock_builder::CallId>;

impl<T: Config> Pallet<T> {
pub fn mock_submit(f: impl Fn(T::Message) -> DispatchResult + 'static) -> CallHandler {
pub fn mock_queue(f: impl Fn(T::Message) -> DispatchResult + 'static) -> CallHandler {
register_call!(f)
}
}

impl<T: Config> MessageQueue for Pallet<T> {
type Message = T::Message;

fn submit(msg: Self::Message) -> DispatchResult {
fn queue(msg: Self::Message) -> DispatchResult {
execute_call!(msg)
}
}
Expand Down
10 changes: 0 additions & 10 deletions libs/traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,15 @@ use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use sp_runtime::{traits::Member, DispatchError};
use sp_std::{fmt::Debug, marker::PhantomData, vec::Vec};

/// Traits related to checked changes.
pub mod changes;
/// Traits related to data registry and collection.
pub mod data;
/// Traits related to Ethereum/EVM.
pub mod ethereum;
/// Traits related to pool fees.
pub mod fee;
/// Traits related to fees payment.
pub mod fees;
/// Traits related to interest rates.
pub mod interest;
/// Traits related to investments.
pub mod investments;
/// Traits related to liquidity pools.
pub mod liquidity_pools;
/// Traits related to rewards.
pub mod rewards;
/// Traits related to swaps.
pub mod swaps;

#[cfg(feature = "runtime-benchmarks")]
Expand Down
10 changes: 5 additions & 5 deletions libs/traits/src/liquidity_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ pub trait LpMessage: Sized {
///
/// Hash - hash of the message that should be recovered.
/// Router - the address of the recovery router.
fn initiate_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self;
fn initiate_recovery_message(hash: MessageHash, router: [u8; 32]) -> Self;

/// Creates a message used for disputing message recovery.
///
/// Hash - hash of the message that should be disputed.
/// Router - the address of the recovery router.
fn dispute_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self;
fn dispute_recovery_message(hash: MessageHash, router: [u8; 32]) -> Self;

/// Checks whether a message is a forwarded one.
fn is_forwarded(&self) -> bool;
Expand Down Expand Up @@ -123,18 +123,18 @@ pub trait MessageQueue {
type Message;

/// Submit a message to the queue.
fn submit(msg: Self::Message) -> DispatchResult;
fn queue(msg: Self::Message) -> DispatchResult;
}

/// The trait required for processing queued messages.
/// The trait required for processing dequeued messages.
pub trait MessageProcessor {
/// The message type.
type Message;

/// Process a message.
fn process(msg: Self::Message) -> (DispatchResult, Weight);

/// Process a message.
/// Max weight that processing a message can take
fn max_processing_weight(msg: &Self::Message) -> Weight;
}

Expand Down
6 changes: 0 additions & 6 deletions libs/types/src/domain_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ impl TypeId for DomainAddress {
const TYPE_ID: [u8; 4] = crate::ids::DOMAIN_ADDRESS_ID;
}

impl Default for DomainAddress {
fn default() -> Self {
DomainAddress::Centrifuge(AccountId32::new([0; 32]))
}
}

impl From<DomainAddress> for Domain {
fn from(x: DomainAddress) -> Self {
match x {
Expand Down
6 changes: 0 additions & 6 deletions pallets/axelar-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ pub enum AxelarId {
Evm(EVMChainId),
}

impl Default for AxelarId {
fn default() -> Self {
Self::Evm(1)
}
}

/// Configuration for outbound messages though axelar
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)]
pub struct AxelarConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub mod pallet {
impl<T: Config> MessageQueueT for Pallet<T> {
type Message = T::Message;

fn submit(message: Self::Message) -> DispatchResult {
fn queue(message: Self::Message) -> DispatchResult {
let nonce = <MessageNonceStore<T>>::try_mutate(|n| {
n.ensure_add_assign(T::MessageNonce::one())?;
Ok::<T::MessageNonce, DispatchError>(*n)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
// GNU General Public License for more details.

use cfg_mocks::pallet_mock_liquidity_pools_gateway;
use cfg_primitives::LPGatewayQueueMessageNonce;
use cfg_types::domain_address::Domain;
use frame_support::derive_impl;

use crate::{self as pallet_liquidity_pools_gateway_queue, Config};

type Nonce = u64;

frame_support::construct_runtime!(
pub enum Runtime {
System: frame_system,
LPGatewayMock: pallet_mock_liquidity_pools_gateway,
LPGatewayQueue: pallet_liquidity_pools_gateway_queue,
Processor: pallet_mock_liquidity_pools_gateway,
Queue: pallet_liquidity_pools_gateway_queue,
}
);

Expand All @@ -33,14 +33,14 @@ impl frame_system::Config for Runtime {
}

impl pallet_mock_liquidity_pools_gateway::Config for Runtime {
type Destination = Domain;
type Destination = ();
type Message = u32;
}

impl Config for Runtime {
type Message = u32;
type MessageNonce = LPGatewayQueueMessageNonce;
type MessageProcessor = LPGatewayMock;
type MessageNonce = Nonce;
type MessageProcessor = Processor;
type RuntimeEvent = RuntimeEvent;
}

Expand Down
Loading
Loading