Skip to content

Feature/dapp staking pallet#441

Merged
hoonsubin merged 29 commits intodevelopment/shidenfrom
feature/dapp-staking-pallet
Oct 4, 2021
Merged

Feature/dapp staking pallet#441
hoonsubin merged 29 commits intodevelopment/shidenfrom
feature/dapp-staking-pallet

Conversation

@hoonsubin
Copy link
Copy Markdown
Contributor

@hoonsubin hoonsubin commented Sep 28, 2021

Checklist

  • all tests passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • (option)

Affected core subsystem(s)

Description of change

dApps Staking pallet for Shibuya test network.


@hoonsubin hoonsubin mentioned this pull request Sep 28, 2021
4 tasks
Comment thread frame/block-reward/src/lib.rs
Comment thread frame/dapps-staking/src/lib.rs Outdated
Comment thread runtime/local/src/lib.rs
Comment thread frame/dapps-staking/src/pallet/mod.rs Outdated
Comment thread frame/dapps-staking/src/pallet/mod.rs
Comment thread frame/dapps-staking/src/pallet/mod.rs Outdated
Comment thread frame/dapps-staking/src/pallet/mod.rs Outdated
Comment thread frame/dapps-staking/src/pallet/mod.rs Outdated
Comment thread frame/dapps-staking/src/pallet/mod.rs Outdated
Comment on lines +813 to +856
/// Execute payout for stakers
fn payout_stakers(staker_map: &BTreeMap<T::AccountId, BalanceOf<T>>) {
for (s, b) in staker_map {
T::Currency::deposit_into_existing(&s, *b).ok();
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Maar-io
Perhaps this needs to be changed so that we transfer from dapps staking account to the staker?

Dapps rewards are deposited into dapps account so we need to payout those funds.

Copy link
Copy Markdown
Contributor

@satellitex satellitex left a comment

Choose a reason for hiding this comment

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

Some weight is constants. It needs to be calculated from weight.rs with a count of the store and write.

satellitex and others added 19 commits October 4, 2021 14:15
* 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>
* 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>
* era handling and ForceEra

* remove reward distribution from on_initialize
* added new storage maps

* added comment for PalletEraRewards
* register() refactoring

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

* not needed empty insert for ContractLastClaimed and Staked
* 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.
* unbond,unstake&withdraw initial commit

* additional UTs for unbond_and_withdraw

* more UTs and bug fixes

* added test utils, minor modifications
* 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
* 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>
Co-authored-by: Dinonard <3002868+Dinonard@users.noreply.github.com>
* Initial dapps staking cleanup

* Dapps staking cleanup 2nd part

* Dapps staking cleanup part3

* Improved empty current era handling

* Era reward bug fix

* Revert some fixes

* Addressed comments

* Fixed issue with era staking and reward. 3 more UTs need to be changed

* Claim UTs few fixes, more remains to be done
Dinonard and others added 9 commits October 4, 2021 14:16
* Refactored claim method to handle eras beyond history depth. Added unclaimed reward accumulation

* Rebase and some improvements

* Comment update
* registration with preapproved list of contracts

* format fix

* renaming and using append
* Inject rewards into dapps staking pallet

* local-runtime uses OnTimestamp

* Use of OnUnbalanced trait

* Aura and BLockReward tuple
* added counter for individual rewards

* update claim UT

* added counter for rewards paid out to contract

* review rework

* review rework2
* Added register deposit function

* Fix code formatting

* rebase updates

Co-authored-by: Dinonard <dino.pacandi@gmail.com>
* SmartContract as trait

* contract_id.is_contract() changes

* changed SmartContract to trait

* more rebase fixes

* runtime updates for shibuya and local

* changing Shibuya parameters, delete unused code

* default HistoryDepth set to 30

* fixing reserved amount for registration

* minor comment fix
* enable developer as the key for preapproval

* use StorageMap instead of Vec for preapproved devs
* use secure hasher

* Unregister implementation

* Unregister unit tests

* Addressed review comments

* Use safe hasher

* Rebase to latest
@Dinonard Dinonard force-pushed the feature/dapp-staking-pallet branch from 5e19e09 to 4effdb7 Compare October 4, 2021 12:16
* added README.md

* Some updates, added unregister documentation

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

@Dinonard Dinonard left a comment

Choose a reason for hiding this comment

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

LGTM...for the first version :D

@Dinonard Dinonard requested a review from akru October 4, 2021 14:24
Copy link
Copy Markdown
Contributor

@Maar-io Maar-io left a comment

Choose a reason for hiding this comment

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

let's go

@Maar-io
Copy link
Copy Markdown
Contributor

Maar-io commented Oct 4, 2021

@akru I think we addresses all comments. Please check and approve

@hoonsubin hoonsubin merged commit 35169c1 into development/shiden Oct 4, 2021
@hoonsubin hoonsubin deleted the feature/dapp-staking-pallet branch October 4, 2021 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants