Skip to content

Commit

Permalink
Init commit (#1342)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard authored Aug 29, 2024
1 parent 724c763 commit d21a4ce
Show file tree
Hide file tree
Showing 54 changed files with 290 additions and 301 deletions.
36 changes: 18 additions & 18 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ orml-oracle = { git = "https://github.com/AstarNetwork/open-runtime-module-libra
# Astar pallets & modules
# (wasm)
pallet-collator-selection = { path = "./pallets/collator-selection", default-features = false }
pallet-dapp-staking-v3 = { path = "./pallets/dapp-staking-v3", default-features = false }
pallet-dapp-staking = { path = "./pallets/dapp-staking", default-features = false }
pallet-xc-asset-config = { path = "./pallets/xc-asset-config", default-features = false }
pallet-ethereum-checked = { path = "./pallets/ethereum-checked", default-features = false }
pallet-inflation = { path = "./pallets/inflation", default-features = false }
Expand All @@ -298,7 +298,7 @@ pallet-static-price-provider = { path = "./pallets/static-price-provider", defau
pallet-price-aggregator = { path = "./pallets/price-aggregator", default-features = false }
pallet-collective-proxy = { path = "./pallets/collective-proxy", default-features = false }

dapp-staking-v3-runtime-api = { path = "./pallets/dapp-staking-v3/rpc/runtime-api", default-features = false }
dapp-staking-runtime-api = { path = "./pallets/dapp-staking/rpc/runtime-api", default-features = false }

astar-primitives = { path = "./primitives", default-features = false }
astar-test-utils = { path = "./tests/utils", default-features = false }
Expand All @@ -307,7 +307,7 @@ pallet-evm-precompile-assets-erc20 = { path = "./precompiles/assets-erc20", defa
pallet-evm-precompile-sr25519 = { path = "./precompiles/sr25519", default-features = false }
pallet-evm-precompile-substrate-ecdsa = { path = "./precompiles/substrate-ecdsa", default-features = false }
pallet-evm-precompile-xcm = { path = "./precompiles/xcm", default-features = false }
pallet-evm-precompile-dapp-staking-v3 = { path = "./precompiles/dapp-staking-v3", default-features = false }
pallet-evm-precompile-dapp-staking = { path = "./precompiles/dapp-staking", default-features = false }
pallet-evm-precompile-unified-accounts = { path = "./precompiles/unified-accounts", default-features = false }
pallet-evm-precompile-dispatch-lockdrop = { path = "./precompiles/dispatch-lockdrop", default-features = false }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "pallet-dapp-staking-v3"
name = "pallet-dapp-staking"
version = "0.1.0"
description = "Pallet for dApp staking v3 protocol"
authors.workspace = true
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "dapp-staking-v3-runtime-api"
name = "dapp-staking-runtime-api"
version = "0.1.0"
description = "dApp Staking v3 runtime API"
authors.workspace = true
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,21 @@ mod v8 {

let old_config = v7::TierConfig::<T>::get().ok_or_else(|| {
TryRuntimeError::Other(
"dapp-staking-v3::migration::v8: No old configuration found for TierConfig",
"dapp-staking::migration::v8: No old configuration found for TierConfig",
)
})?;
Ok((old_config.number_of_slots, old_config.tier_thresholds).encode())
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(data: Vec<u8>) -> Result<(), TryRuntimeError> {
let (old_number_of_slots, old_tier_thresholds): (u16, BoundedVec<v7::TierThreshold, T::NumberOfTiers>) =
Decode::decode(&mut &data[..]).map_err(|_| {
TryRuntimeError::Other("dapp-staking-v3::migration::v8: Failed to decode old v7 version of tier config")
let (old_number_of_slots, old_tier_thresholds): (
u16,
BoundedVec<v7::TierThreshold, T::NumberOfTiers>,
) = Decode::decode(&mut &data[..]).map_err(|_| {
TryRuntimeError::Other(
"dapp-staking::migration::v8: Failed to decode old v7 version of tier config",
)
})?;

// 0. Prerequisites
Expand All @@ -180,7 +184,7 @@ mod v8 {

ensure!(
Pallet::<T>::on_chain_storage_version() >= 8,
"dapp-staking-v3::migration::v8: Wrong storage version."
"dapp-staking::migration::v8: Wrong storage version."
);

// 1. Ensure the number of slots is preserved
Expand All @@ -190,7 +194,7 @@ mod v8 {

assert!(
within_tolerance.contains(&actual_number_of_slots),
"dapp-staking-v3::migration::v8: New TiersConfiguration format not set correctly, number of slots has diverged. Old: {}. Actual: {}.",
"dapp-staking::migration::v8: New TiersConfiguration format not set correctly, number of slots has diverged. Old: {}. Actual: {}.",
old_number_of_slots,
actual_number_of_slots
);
Expand All @@ -203,7 +207,7 @@ mod v8 {
BoundedVec::try_from(TierThresholds::get().to_vec());
ensure!(
expected_tier_thresholds.is_ok(),
"dapp-staking-v3::migration::v8: Failed to convert expected tier thresholds."
"dapp-staking::migration::v8: Failed to convert expected tier thresholds."
);
let actual_tier_thresholds = actual_tier_params.clone().tier_thresholds;
assert_eq!(expected_tier_thresholds.unwrap(), actual_tier_thresholds);
Expand All @@ -222,7 +226,7 @@ mod v8 {

ensure!(
old_threshold_amounts.is_ok(),
"dapp-staking-v3::migration::v8: Failed to convert old v7 version tier thresholds to balance amounts."
"dapp-staking::migration::v8: Failed to convert old v7 version tier thresholds to balance amounts."
);
let old_threshold_amounts = old_threshold_amounts.unwrap();
let expected_new_threshold_amounts = actual_config
Expand All @@ -242,7 +246,7 @@ mod v8 {

assert!(
(lower_bound..=upper_bound).contains(&actual_amount),
"dapp-staking-v3::migration::v8: New tier threshold amounts diverged to much from old values, consider adjusting static tier parameters. Old: {}. Actual: {}.",
"dapp-staking::migration::v8: New tier threshold amounts diverged to much from old values, consider adjusting static tier parameters. Old: {}. Actual: {}.",
old_amount,
actual_amount
);
Expand Down Expand Up @@ -379,7 +383,7 @@ mod v7 {
fn post_upgrade(_data: Vec<u8>) -> Result<(), TryRuntimeError> {
ensure!(
Pallet::<T>::on_chain_storage_version() >= 7,
"dapp-staking-v3::migration::v7: wrong storage version"
"dapp-staking::migration::v7: wrong storage version"
);
Ok(())
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// You should have received a copy of the GNU General Public License
// along with Astar. If not, see <http://www.gnu.org/licenses/>.

//! Autogenerated weights for pallet_dapp_staking_v3
//! Autogenerated weights for pallet_dapp_staking
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2024-02-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
Expand All @@ -32,12 +32,12 @@
// --chain=shiden-dev
// --steps=50
// --repeat=20
// --pallet=pallet_dapp_staking_v3
// --pallet=pallet_dapp_staking
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --output=./benchmark-results/shiden-dev/dapp_staking_v3_weights.rs
// --output=./benchmark-results/shiden-dev/dapp_staking_weights.rs
// --template=./scripts/templates/weight-template.hbs

#![cfg_attr(rustfmt, rustfmt_skip)]
Expand All @@ -47,7 +47,7 @@
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;

/// Weight functions needed for pallet_dapp_staking_v3.
/// Weight functions needed for pallet_dapp_staking.
pub trait WeightInfo {
fn maintenance_mode() -> Weight;
fn register() -> Weight;
Expand Down Expand Up @@ -75,7 +75,7 @@ pub trait WeightInfo {
fn on_idle_cleanup() -> Weight;
}

/// Weights for pallet_dapp_staking_v3 using the Substrate node and recommended hardware.
/// Weights for pallet_dapp_staking using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
fn maintenance_mode() -> Weight {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "pallet-evm-precompile-dapp-staking-v3"
name = "pallet-evm-precompile-dapp-staking"
version = "0.1.0"
license = "GPL-3.0-or-later"
description = "dApp Staking EVM precompiles"
Expand All @@ -23,7 +23,7 @@ sp-std = { workspace = true }

# Astar
astar-primitives = { workspace = true }
pallet-dapp-staking-v3 = { workspace = true }
pallet-dapp-staking = { workspace = true }
precompile-utils = { workspace = true, default-features = false }

# Frontier
Expand Down Expand Up @@ -53,7 +53,7 @@ std = [
"fp-evm/std",
"frame-support/std",
"frame-system/std",
"pallet-dapp-staking-v3/std",
"pallet-dapp-staking/std",
"pallet-evm/std",
"precompile-utils/std",
"pallet-balances/std",
Expand All @@ -62,7 +62,7 @@ std = [
"num_enum/std",
]
runtime-benchmarks = [
"pallet-dapp-staking-v3/runtime-benchmarks",
"pallet-dapp-staking/runtime-benchmarks",
"astar-primitives/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity >=0.8.0;
/// Predeployed at the address 0x0000000000000000000000000000000000005001
/// For better understanding check the source code:
/// repo: https://github.com/AstarNetwork/Astar
/// code: pallets/dapp-staking-v3
/// code: pallets/dapp-staking
interface DAppStaking {

// Types
Expand Down
File renamed without changes.
Loading

0 comments on commit d21a4ce

Please sign in to comment.