Skip to content

Commit

Permalink
Feature/dapp shiden15 (#429)
Browse files Browse the repository at this point in the history
* Added DealWithFees handler for tx fees (#391)

* Temporary disable custom signatures pallet (#401)

* Temporary disable custom signatures pallet

* Bump version

* Fix custom signatures pallet (#402)

* Added stale transaction traction
* Added constant transaction fee

* EVM contracts integration (#397)

* Added EVM into runtime

* Added EVM support into collator

* Enabled Ethereum-compatible RPC
* Added Frontier consensus middleware

* Fix frontier consensus

* Fix frontier invalid transaction bug

* Added Shibuya testnet

* Fix EVM gas fee charge (#411)

* Fix pallet custom signatures issues (#412)

* Fix pallet custom signatures issues

* Update Cargo.lock

* Development chain with EVM and Ink contracts (#423)

* Development chain with EVM and Ink contracts

* Fix code formatting

* Added local chain properties

* Enable EVM withdraws & customsig fixes (#419)

* Enable EVM withdraws & customsig fixes

* Enable customsig pallet for shiden

* Fix EVM native tx conversion (#426)

* Fix EVM native tx conversion

* Increase Alice development endowment

* Update Cargo.lock

* Added staking EVM precompiles (#425)

* re fork

* remove recursive limit

* add bond() bond_extra() set_controller()

* formatting fix

* Feature/dapp step1 (#407)

* dapps-staking step1. (#405)

* added unbond() withraw_unbonded()

* dapp_staking_bond_test_wip

* add EraFinder mock and test bonding not_ok

Co-authored-by: Dinonard <dino.pacandi@gmail.com>

* Expanded UT for bond()
Added UT for bond_extra() and set_controller()
Left some TODOs to discuss in review

* add unbond() UT

* withdraw_unbonded() UT

* UT granularization, various improvements

Co-authored-by: Mar.io <34627453+Maar-io@users.noreply.github.com>

* Feature/dapp step2 (#409)

* dapps-staking step1. (#405)

* added unbond() withraw_unbonded()

* dapp_staking_bond_test_wip

* add EraFinder mock and test bonding not_ok

Co-authored-by: Dinonard <dino.pacandi@gmail.com>

* Expanded UT for bond()
Added UT for bond_extra() and set_controller()
Left some TODOs to discuss in review

* add unbond() UT

* withdraw_unbonded() UT

* UT granularization, various improvements

* resolving some merge issues

* Feature/dapps register (#408)

* register + test

* added SmartContract struct

* removed ContractFinder trait

* Feature/dapp step1 (#407)

* dapps-staking step1. (#405)

* added unbond() withraw_unbonded()

* dapp_staking_bond_test_wip

* add EraFinder mock and test bonding not_ok

Co-authored-by: Dinonard <dino.pacandi@gmail.com>

* Expanded UT for bond()
Added UT for bond_extra() and set_controller()
Left some TODOs to discuss in review

* add unbond() UT

* withdraw_unbonded() UT

* UT granularization, various improvements

Co-authored-by: Mar.io <34627453+Maar-io@users.noreply.github.com>

* register + test

* added SmartContract struct

* removed ContractFinder trait

* add to runtime

* resolvimg merge issues

* fmt fix

Co-authored-by: Dinonard <3002868+Dinonard@users.noreply.github.com>

* review fixes. Added support for AlreadyUsedDeveloperAccount

* fmt fix

* moved helper register() on top

* fmt test file

* fmt fix after merge

Co-authored-by: Dinonard <dino.pacandi@gmail.com>
Co-authored-by: Dinonard <3002868+Dinonard@users.noreply.github.com>

* dapps-staking Era handling (#410)

* era handling and ForceEra

* remove reward distribution from on_initialize

* added new storage maps (#413)

* added new storage maps

* added comment for PalletEraRewards

* Dapps-staking register() refactoring (#414)

* register() refactoring

* updateds after review
register() updated with initial:
  ContractLastClaimed
  ContractLastStaked

* not needed empty insert for ContractLastClaimed and Staked

* Update Cargo.toml (#420) with license

* Feature/bond and stake (#415)

* Initial stake and unbond

* Initial implementation of bond and stake

* Finished bond_and_stake, start with UT

* UT update & staked era bug fix

* Added era reward struct

* Pallet constants for staking, bug fixes, new UTs

* Finalized unit test, ready for review

* fix compilation error for runtime

* documentation fixes

* addressing review comments

Weight calculation will be implemented in a follow-up PR.

* License move to dapps (#421)

* Feature/unbond unstake and withdraw (#424)

* unbond,unstake&withdraw initial commit

* additional UTs for unbond_and_withdraw

* more UTs and bug fixes

* added test utils, minor modifications

* dapps staking claim (#422)

* initial claim() function

* fmt fix and license info

* added clearing of storage until claim era

* UT with several staking for a contract

* sceleton for payour_stakers()

* more checks on claim()

* fixes after running UT

* review fixes

* more review fixesž

* optimize storage use during payout

* minor comment fix

* added UT for 2 contracts

* minor merge fix

* claim() review updates

* use map instead of vec of vec, plus fmt

* renaming and adding comments to claim algorithm

* remove unnecessary cloning

* implemented accumulator for era rewards

* moved pallet-dapps-staking to local runtime

* megre conflict and fmt

Co-authored-by: Aleksandr Krupenkin <mail@akru.me>
Co-authored-by: satellitex <s.a.t.e.3.ths@gmail.com>
Co-authored-by: Dinonard <3002868+Dinonard@users.noreply.github.com>
Co-authored-by: Dinonard <dino.pacandi@gmail.com>
Co-authored-by: Sota Watanabe <w.souta.s.life@gmail.com>
  • Loading branch information
6 people committed Oct 4, 2021
1 parent 9839104 commit f1e2a55
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 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 Cargo.toml
Expand Up @@ -7,6 +7,7 @@ members = [
"frame/block-reward",
"frame/custom-signatures",
"precompiles/staking",
"frame/dapps-staking",
]

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion frame/dapps-staking/src/mock.rs
Expand Up @@ -34,7 +34,7 @@ pub(crate) const MINIMUM_STAKING_AMOUNT: Balance = 10;
pub(crate) const DEVELOPER_REWARD_PERCENTAGE: u32 = 80;

pub(crate) const MILLISDN: Balance = 1_000_000_000_000_000;
pub(crate) const BLOCK_REWARD: Balance = 2_664 * MILLISDN;
pub(crate) const BLOCK_REWARD: Balance = 2_664 * MILLIAST;

construct_runtime!(
pub enum TestRuntime where
Expand Down
2 changes: 2 additions & 0 deletions runtime/local/Cargo.toml
Expand Up @@ -48,6 +48,7 @@ pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/parityt

pallet-block-reward = { path = "../../frame/block-reward", default-features = false }
pallet-custom-signatures = { path = "../../frame/custom-signatures", default-features = false }
pallet-dapps-staking = { path = "../../frame/dapps-staking", default-features = false }

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false }
Expand All @@ -69,6 +70,7 @@ std = [
"pallet-contracts-primitives/std",
"pallet-contracts-rpc-runtime-api/std",
"pallet-custom-signatures/std",
"pallet-dapps-staking/std",
"pallet-ethereum/std",
"pallet-evm/std",
"pallet-evm-precompile-simple/std",
Expand Down
31 changes: 31 additions & 0 deletions runtime/local/src/lib.rs
Expand Up @@ -268,12 +268,42 @@ impl OnUnbalanced<NegativeImbalance> for OnBlockReward {

parameter_types! {
pub const RewardAmount: Balance = 2_664 * MILLIAST;
pub const DAppsRewardPercentage: u32 = 50;
}

impl pallet_block_reward::Config for Runtime {
type Currency = Balances;
type OnBlockReward = OnBlockReward;
type RewardAmount = RewardAmount;
type DAppsRewardPercentage = DAppsRewardPercentage;
}

parameter_types! {
pub const UnbondingDuration: pallet_dapps_staking::EraIndex = 2;
pub const BlockPerEra: BlockNumber = 60;
pub const MaxStakings: u32 = 5;
pub const RegisterDeposit: Balance = 100;
pub const DeveloperRewardPercentage: u32 = 80;
pub const MaxNumberOfStakersPerContract: u32 = 128;
pub const MinimumStakingAmount: Balance = 10;
}

impl pallet_dapps_staking::Config for Runtime {
type Currency = Balances;
type UnixTime = Timestamp;
type RewardRemainder = (); // Reward remainder is burned.
type RewardAmount = RewardAmount;
type DAppsRewardPercentage = DAppsRewardPercentage;
type BlockPerEra = BlockPerEra;
type UnbondingDuration = UnbondingDuration;
type RegisterDeposit = RegisterDeposit;
type DeveloperRewardPercentage = DeveloperRewardPercentage;
type EraPayout = ();
type MaxStakings = MaxStakings;
type Event = Event;
type WeightInfo = (); // TODO
type MaxNumberOfStakersPerContract = MaxNumberOfStakersPerContract;
type MinimumStakingAmount = MinimumStakingAmount;
}

/// Current approximation of the gas/s consumption considering
Expand Down Expand Up @@ -472,6 +502,7 @@ construct_runtime!(
Aura: pallet_aura::{Pallet, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
DappsStaking: pallet_dapps_staking::{Pallet, Call, Storage, Event<T>},
TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>},
Ethereum: pallet_ethereum::{Pallet, Call, Storage, Event, Config, ValidateUnsigned},
Expand Down
5 changes: 4 additions & 1 deletion runtime/shibuya/src/lib.rs
Expand Up @@ -371,7 +371,8 @@ impl OnUnbalanced<NegativeImbalance> for ToStakingPot {
pub struct OnBlockReward;
impl OnUnbalanced<NegativeImbalance> for OnBlockReward {
fn on_nonzero_unbalanced(amount: NegativeImbalance) {
let (dapps, maintain) = amount.ration(50, 50);
let dapps_percentage = DAppsRewardPercentage::get();
let (dapps, maintain) = amount.ration(dapps_percentage, 100 - dapps_percentage);
// dapp staking block reward
Balances::resolve_creating(&DappsStakingPalletId::get().into_account(), dapps);

Expand All @@ -385,11 +386,13 @@ impl OnUnbalanced<NegativeImbalance> for OnBlockReward {

parameter_types! {
pub const RewardAmount: Balance = 2_664 * MILLISDN;
pub const DAppsRewardPercentage: u32 = 50;
}

impl pallet_block_reward::Config for Runtime {
type Currency = Balances;
type OnBlockReward = OnBlockReward;
type DAppsRewardPercentage = DAppsRewardPercentage;
type RewardAmount = RewardAmount;
}

Expand Down
4 changes: 2 additions & 2 deletions runtime/shiden/src/lib.rs
Expand Up @@ -399,8 +399,8 @@ impl OnUnbalanced<NegativeImbalance> for ToStakingPot {
pub struct OnBlockReward;
impl OnUnbalanced<NegativeImbalance> for OnBlockReward {
fn on_nonzero_unbalanced(amount: NegativeImbalance) {
let dapps_ratio = DAppsRewardPercentage::get();
let (dapps, maintain) = amount.ration(dapps_ratio, 100 - dapps_ratio);
let dapps_percentage = DAppsRewardPercentage::get();
let (dapps, maintain) = amount.ration(dapps_percentage, 100 - dapps_percentage);
Balances::resolve_creating(&DappsStakingPalletId::get().into_account(), dapps);

let (treasury, collators) = maintain.ration(40, 10);
Expand Down

0 comments on commit f1e2a55

Please sign in to comment.