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

Instant staking #1228

Merged
merged 10 commits into from
Dec 13, 2023
Merged

Instant staking #1228

merged 10 commits into from
Dec 13, 2023

Conversation

unknownunknown1
Copy link
Contributor

@unknownunknown1 unknownunknown1 commented Sep 12, 2023

This change relies heavliy on the new feature that wasn't present in the older version which is the removal of the old delayed stake.
When the juror changes his stake while there is already a delayed stake present for this juror, the old stake will simply be nullified and skipped upon delayed stake execution. Its index will still be there but it'll point to an empty struct. Also this applies to automatic staking (e.g. when inactive juror is penalized), thus it'll also remove the existing delayed stake for this juror. In order for this to work I had to restore the old stakeOf() function which returns the current stake that is stored in the sortition. This is needed because the sortition stake is unaffected by the partial staking, thus I can revert to this value if a partially delayed stake gets removed/replaced.
Overall, I tried to come up with a solution that doesn't complicate the existing code while also being reliable, and the option to remove the old delayed stake seems like an optimal one.
Also, the delayed stake can be manually removed by the juror if he staked by mistake (e.g. staked in the court where he didn't want to stake).


PR-Codex overview

This PR focuses on improving the arbitration functionality by making changes to the KlerosCore contract and related files.

Detailed summary

  • Added timeout configuration for Mocha tests in hardhat.config.ts.
  • Updated usage of core.getJurorBalance to core.sortitionModule().getJurorBalance in DisputeKitClassic.sol and DisputeKitSybilResistant.sol.
  • Updated event handler names in subgraph.yaml.
  • Renamed event StakeDelayed to StakeDelayedNotTransferred in KlerosCore.ts.
  • Updated usage of core.getJurorBalance to sortitionModule.getJurorBalance in integration tests.
  • Added new functions lockStake, unlockStake, penalizeStake, and updated setStake in ISortitionModule.sol.
  • Updated usage of core.getJurorBalance to sortitionModule.getJurorBalance in draw.ts.
  • Removed struct Juror and related mappings in KlerosCore.sol.

The following files were skipped due to too many changes: contracts/src/arbitration/KlerosCore.sol, contracts/test/arbitration/staking.ts, contracts/src/arbitration/SortitionModule.sol

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@netlify
Copy link

netlify bot commented Sep 12, 2023

Deploy Preview for kleros-v2 ready!

Name Link
🔨 Latest commit 6cbe8c4
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2/deploys/6579a2fe048f570008d4d3e3
😎 Deploy Preview https://deploy-preview-1228--kleros-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sonarcloud
Copy link

sonarcloud bot commented Sep 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@jaybuidl jaybuidl added Type: Feature🗿 Package: Contracts Court smart contracts Type: UX User Experience labels Sep 18, 2023
@jaybuidl jaybuidl removed the request for review from shotaronowhere December 8, 2023 00:16
@jaybuidl jaybuidl force-pushed the feat/instant-staking branch from de32966 to 1b365a4 Compare December 8, 2023 18:53
@jaybuidl jaybuidl force-pushed the feat/instant-staking branch from 83acd03 to 1a4a5f7 Compare December 9, 2023 01:43
jaybuidl
jaybuidl previously approved these changes Dec 12, 2023
@jaybuidl jaybuidl added the Compatibility: ABI change 🗯 Smart contract ABI is changing. label Dec 13, 2023
@jaybuidl jaybuidl added this to the testnet-3 milestone Dec 13, 2023
@jaybuidl jaybuidl changed the title feat(KC): add instant-staking Instant staking Dec 13, 2023
@jaybuidl jaybuidl force-pushed the feat/instant-staking branch from 861c85d to 6cbe8c4 Compare December 13, 2023 12:26
Copy link

sonarcloud bot commented Dec 13, 2023

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

codeclimate bot commented Dec 13, 2023

Code Climate has analyzed commit 6cbe8c4 and detected 26 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Duplication 24
Style 1

View more on Code Climate.

@jaybuidl jaybuidl enabled auto-merge December 13, 2023 12:29
@jaybuidl jaybuidl added this pull request to the merge queue Dec 13, 2023
Merged via the queue into kleros:dev with commit 17502d9 Dec 13, 2023
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compatibility: ABI change 🗯 Smart contract ABI is changing. Package: Contracts Court smart contracts Type: Feature🗿 Type: UX User Experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delayed stakes: transfer PNK immediately without waiting for the next Staking phase
2 participants