Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into loans/moment-as-secs
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Oct 10, 2023
2 parents c4d2f9b + 74aeeb1 commit 7186c1d
Show file tree
Hide file tree
Showing 113 changed files with 5,397 additions and 3,672 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pallets/restricted-tokens/* @mustermeiszer
pallets/data-collector/* @lemunozm
pallets/fees/* @lemunozm
pallets/transfer-allowlist/* @mustermeiszer
pallets/foreign-investments/* @wischli

## Changes to specific libraries
libs/mock-builder/* @lemunozm
Expand All @@ -38,7 +39,7 @@ libs/traits/src/changes.rs @lemunozm
libs/traits/src/data.rs @lemunozm

## Changes to runtime
runtime/common/* @mustermeiszer @NunoAlexandre @hieronx @lemunozm
runtime/common/* @mustermeiszer @NunoAlexandre @hieronx @lemunozm @wischli
runtime/altair/* @mustermeiszer @NunoAlexandre @hieronx @wischli
runtime/centrifuge/* @mustermeiszer @NunoAlexandre @hieronx @wischli

Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ jobs:
name: Publish to GCS
run: |
gsutil cp ./runtime/altair/target/srtool/release/wbuild/altair-runtime/altair_runtime.compact.compressed.wasm gs://centrifuge-artifact-releases/test-parachain/altair_runtime-$(git rev-parse --short HEAD).compact.compressed.wasm
- if: ${{ matrix.target == 'build-runtime-testnet' && matrix.package == 'altair-runtime' }}
name: Publish to GCS
run: |
gsutil cp ./runtime/altair/target/srtool/release/wbuild/altair-runtime/altair_runtime.compact.compressed.wasm gs://centrifuge-artifact-releases/parachain/algol-$(git rev-parse --short HEAD).compact.compressed.wasm
- if: ${{ matrix.target == 'build-runtime' && matrix.package == 'centrifuge-runtime' }}
name: Publish to GCS
run: |
Expand Down
8 changes: 5 additions & 3 deletions Cargo.lock

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

8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "centrifuge-chain"
version = "0.10.28"
version = "0.10.34"
authors = ["Centrifuge <[email protected]>"]
description = "Centrifuge chain implementation in Rust."
build = "build.rs"
Expand Down Expand Up @@ -168,7 +168,9 @@ fc-rpc = { git = "https://github.com/PureStake/frontier", default-features = fal
fc-rpc-core = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.38" }
fp-consensus = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.38" }
fp-rpc = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.38" }
fp-evm = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.38" }
fp-storage = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.38" }
pallet-evm = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.38" }

[build-dependencies]
substrate-build-script-utils = { optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
Expand Down Expand Up @@ -278,10 +280,6 @@ fast-runtime = [
"runtime-integration-tests/fast-runtime",
]

testnet-runtime = [
"altair-runtime/testnet-runtime",
]

#
# Cargo patch rules for all the paritytech/ based crates.
#
Expand Down
5 changes: 0 additions & 5 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ case $TARGET in
docker run --rm -e PACKAGE=$PACKAGE -e BUILD_OPTS="--features=fast-runtime" -v $PWD:/build -v /tmp/cargo:/cargo-home paritytech/srtool:$SRTOOL_VERSION build
;;

build-runtime-testnet)
export RUSTC_VERSION=$RUST_TOOLCHAIN
docker run --rm -e PACKAGE=$PACKAGE -e BUILD_OPTS="--features=testnet-runtime" -v $PWD:/build -v /tmp/cargo:/cargo-home paritytech/srtool:$SRTOOL_VERSION build
;;

tests)
RUST_MIN_STACK=8388608 cargo test --workspace --release --features runtime-benchmarks,try-runtime --exclude runtime-integration-tests
;;
Expand Down
2 changes: 1 addition & 1 deletion libs/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub mod tokens;
pub mod xcm;

/// The EVM Chain ID
/// The type should accomodate all chain ids listed on <https://chainlist.org/>.
/// The type should accommodate all chain ids listed on <https://chainlist.org/>.
pub type EVMChainId = u64;

/// A raw para ID
Expand Down
112 changes: 70 additions & 42 deletions libs/types/src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,48 +324,6 @@ impl From<LiquidityPoolsWrappedToken> for DomainAddress {
}
}

pub const LP_ETH_USDC_CURRENCY_ID: CurrencyId = CurrencyId::ForeignAsset(100001);

pub const ETHEREUM_MAINNET_CHAIN_ID: EVMChainId = 1;
pub const GOERLI_CHAIN_ID: EVMChainId = 5;

pub const ETHEREUM_USDC: [u8; 20] = hex_literal::hex!("a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48");
pub const GOERLI_USDC: [u8; 20] = hex_literal::hex!("07865c6e87b9f70255377e024ace6630c1eaa37f");

/// The metadata for the LpEthUSDC token
// TODO(nuno): once used in the Centrifuge migration registering it,
// move it directly to the `chain_spec` > development genesis where it is also
// used.
pub fn lp_eth_usdc_metadata(
pallet_index: PalletIndex,
chain_id: EVMChainId,
usdc_contract: [u8; 20],
) -> AssetMetadata<Balance, CustomMetadata> {
AssetMetadata {
decimals: 6,
name: "LP Ethereum Wrapped USDC".as_bytes().to_vec(),
symbol: "LpEthUSDC".as_bytes().to_vec(),
existential_deposit: 1000,
location: Some(VersionedMultiLocation::V3(MultiLocation {
parents: 0,
interior: xcm::v3::Junctions::X3(
PalletInstance(pallet_index),
GlobalConsensus(NetworkId::Ethereum { chain_id }),
AccountKey20 {
network: None,
key: usdc_contract,
},
),
})),
additional: CustomMetadata {
transferability: CrossChainTransferability::LiquidityPools,
mintable: false,
permissioned: false,
pool_currency: true,
},
}
}

pub mod before {
use cfg_primitives::{PoolId, TrancheId};
use codec::{Decode, Encode, MaxEncodedLen};
Expand Down Expand Up @@ -407,6 +365,76 @@ pub mod before {
}
}

pub mod usdc {
use sp_std::vec::Vec;

use super::*;

pub const MIN_SWAP_ORDER_AMOUNT: Balance = 10_000_000;
pub const DECIMALS: u32 = 6;
pub const EXISTENTIAL_DEPOSIT: Balance = 1000;

pub const CURRENCY_ID_DOT_NATIVE: CurrencyId = CurrencyId::ForeignAsset(6);
pub const CURRENCY_ID_LP_ETH: CurrencyId = CurrencyId::ForeignAsset(100_001);
pub const CURRENCY_ID_LP_ETH_GOERLI: CurrencyId = CurrencyId::ForeignAsset(100_001);
pub const CURRENCY_ID_LP_BASE: CurrencyId = CurrencyId::ForeignAsset(100_002);
pub const CURRENCY_ID_LP_ARB: CurrencyId = CurrencyId::ForeignAsset(100_003);
pub const CURRENCY_ID_LP_CELO: CurrencyId = CurrencyId::ForeignAsset(100_004);

pub const CHAIN_ID_ETHEREUM_MAINNET: EVMChainId = 1;
pub const CHAIN_ID_ETH_GOERLI_TESTNET: EVMChainId = 5;
pub const CHAIN_ID_BASE_MAINNET: EVMChainId = 8453;
pub const CHAIN_ID_ARBITRUM_MAINNET: EVMChainId = 42_161;
pub const CHAIN_ID_CELO_MAINNET: EVMChainId = 42_220;

pub const CONTRACT_ETHEREUM: [u8; 20] =
hex_literal::hex!("a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48");
pub const CONTRACT_ETH_GOERLI: [u8; 20] =
hex_literal::hex!("07865c6e87b9f70255377e024ace6630c1eaa37f");
pub const CONTRACT_BASE: [u8; 20] =
hex_literal::hex!("833589fCD6eDb6E08f4c7C32D4f71b54bdA02913");
pub const CONTRACT_ARBITRUM: [u8; 20] =
hex_literal::hex!("af88d065e77c8cC2239327C5EDb3A432268e5831");
pub const CONTRACT_CELO: [u8; 20] =
hex_literal::hex!("37f750B7cC259A2f741AF45294f6a16572CF5cAd");

/// The metadata generator for the LP wrapped USDC currencies
// TODO(future): If no further LP wrapped USDC variants are expected, move this
// to `chain_spec.rs`.
pub fn lp_wrapped_usdc_metadata(
name: Vec<u8>,
symbol: Vec<u8>,
pallet_index: PalletIndex,
chain_id: EVMChainId,
contract_address_usdc: [u8; 20],
pool_currency: bool,
) -> AssetMetadata<Balance, CustomMetadata> {
AssetMetadata {
decimals: DECIMALS,
name,
symbol,
existential_deposit: EXISTENTIAL_DEPOSIT,
location: Some(VersionedMultiLocation::V3(MultiLocation {
parents: 0,
interior: xcm::v3::Junctions::X3(
PalletInstance(pallet_index),
GlobalConsensus(NetworkId::Ethereum { chain_id }),
AccountKey20 {
network: None,
key: contract_address_usdc,
},
),
})),
additional: CustomMetadata {
transferability: CrossChainTransferability::LiquidityPools,
mintable: false,
permissioned: false,
pool_currency,
},
}
}
}

#[cfg(test)]
mod tests {
use frame_support::parameter_types;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl WeightInfo for () {
// NOTE: Reasonable weight taken from `PoolSystem::set_max_reserve`
// This one has one read and one write for sure and possible one
// read for `AdminOrigin`
Weight::from_parts(17_000_000, 5991)
Weight::from_parts(30_117_000, 5991)
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(1))
}
Expand All @@ -35,7 +35,7 @@ impl WeightInfo for () {
// NOTE: Reasonable weight taken from `PoolSystem::set_max_reserve`
// This one has one read and one write for sure and possible one
// read for `AdminOrigin`
Weight::from_parts(17_000_000, 5991)
Weight::from_parts(30_117_000, 5991)
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(1))
}
Expand Down
17 changes: 9 additions & 8 deletions pallets/liquidity-pools-gateway/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl WeightInfo for () {
// NOTE: Reasonable weight taken from `PoolSystem::set_max_reserve`
// This one has one read and one write for sure and possible one
// read for `AdminOrigin`
Weight::from_parts(17_000_000, 5991)
Weight::from_parts(30_117_000, 5991)
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(1))
}
Expand All @@ -44,7 +44,7 @@ impl WeightInfo for () {
// NOTE: Reasonable weight taken from `PoolSystem::set_max_reserve`
// This one has one read and one write for sure and possible one
// read for `AdminOrigin`
Weight::from_parts(17_000_000, 5991)
Weight::from_parts(30_117_000, 5991)
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(1))
}
Expand All @@ -55,7 +55,7 @@ impl WeightInfo for () {
// NOTE: Reasonable weight taken from `PoolSystem::set_max_reserve`
// This one has one read and one write for sure and possible one
// read for `AdminOrigin`
Weight::from_parts(17_000_000, 5991)
Weight::from_parts(30_117_000, 5991)
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(1))
}
Expand All @@ -66,7 +66,7 @@ impl WeightInfo for () {
// NOTE: Reasonable weight taken from `PoolSystem::set_max_reserve`
// This one has one read and one write for sure and possible one
// read for `AdminOrigin`
Weight::from_parts(17_000_000, 5991)
Weight::from_parts(30_117_000, 5991)
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(1))
}
Expand All @@ -77,20 +77,21 @@ impl WeightInfo for () {
// NOTE: Reasonable weight taken from `PoolSystem::set_max_reserve`
// This one has one read and one write for sure and possible one
// read for `AdminOrigin`
Weight::from_parts(17_000_000, 5991)
Weight::from_parts(30_117_000, 5991)
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(1))
}

fn process_msg() -> Weight {
// TODO: BENCHMARK AND USE REAL WEIGHTS
// NOTE: Defensive hardcoded weight taken from pool_system::execute_epoch. Will
// be replaced with real benchmark soon.
//
// NOTE: For reference this weight compared to our maximum weight
// * This weight { ref_time: 4333558693, proof_size: 91070 }
// * Maximum weight { ref_time: 500000000000, proof_size: 5242880 }
//
Weight::from_parts(78_019_565, 19974)
.saturating_add(Weight::from_ref_time(38_884_782).saturating_mul(N))
Weight::from_parts(124_979_771, 19974)
.saturating_add(Weight::from_ref_time(58_136_652).saturating_mul(N))
.saturating_add(RocksDbWeight::get().reads(8))
.saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(N)))
.saturating_add(RocksDbWeight::get().writes(8))
Expand Down
Loading

0 comments on commit 7186c1d

Please sign in to comment.