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

🐳 feat(protocol): alpha-4 with staking-based tokenomics #14006

Merged
merged 23 commits into from Jun 26, 2023

Conversation

adaki2004
Copy link
Contributor

@adaki2004 adaki2004 commented Jun 16, 2023

// New concept TLDR:
// 2 main data 'registry':
// - TopProver array: we keep track of the top32. We need an array because we need to iterate over
// - ExitingProver mapping: each and every prover who is either exiting or kicked out (by someone staking more) is
// here until they are not withdraw the funds (with exit())

// NOTE:
// - signalling an exit if you are a prover can be done via stake(totalAMount = 0)
// - modifying existing parameters also done via stake (see comments there)
// - there are mechanisms in the stake() code to handle scenarios like:
//     A: Bob is the least staker. Alice comes in and stakes more than Bob and Carol.
//     Now Bob forced to leave and not within the ExitingProvers. He realizes it and
//     tries to re-stake. Now he stakes more than Carol, so Carol is gone, but Bob can
//     re-use his funds currently in the 'staking queue'. So basically he is out of the
//     exiting queue.
//
//     B: Almost same situation as above, except that when Bob is leaving (force leaving)
//     Carol decided to leave as well, so she is not in the topProver array anymore. It means
//     Bob could come back with his stake (currenlty in the exit 'queue') or even less than that
//     amount since Carol left, there is 1 "free space". So he could decide to re-stake less than
//     his amount in the current exit 'queue', so technically he still have some left in the exit queue
//     while also being a topProver in the same time!

@cyberhorsey
Copy link
Contributor

i think we can remove systemProofCooldownPeriod from config now, right?

- Removed  blk.prover != address(0) check in LibProposing.sol because blk.prover can be address(0) if for example the prover pool is out of capacity
- Fix slashing check in LIbVerifying.sol in case blk.prover == address(0)
- Fix failing tests
- Removing tests which are not needed anymore (testOracleProverWithSignature, test_that_simple_oracle_prover_cannot_be_verified_only_if_normal_proof_comes_in)
dantaik and others added 4 commits June 26, 2023 15:55
Co-authored-by: Daniel Wang <dong77@gmail.com>
Co-authored-by: adaki2004 <keszeydani@gmail.com>
Co-authored-by: adaki2004 <adaki2004@users.noreply.github.com>
Co-authored-by: D <51912515+adaki2004@users.noreply.github.com>
@adaki2004
Copy link
Contributor Author

adaki2004 commented Jun 26, 2023

@dantaik @Brechtpd
Good news is that we have a working PoC initial implementation of the PoS system.
Covered with tests the following behaviors:

  • Prover assignment distribution indeed correlates with the staked amount
  • Code (protocol) can handle if staker list is: full, empty, 1 or just couple of provers are staking
  • Only provers (stakers) can prove their blocks within the proof time window, and everyone else otherwise
  • Slashing works
  • Provers could exit and will not get blocks assigned afterwards, and if another (highest) prover joins the assign prover distribution (weighting) works well

IMO this is a good PoC/ working solution so we might want to ask @davidtaikocha and @cyberhorsey to proceed with the client so we will have something in our hand by end of this week.

The less good news on the other hand is the gas consumption, comparison.

The current alpha3 gas consumption as a benchmark:
kép

This version (with full list (32) of stakers/provers):
kép

This version (with 5 stakers/provers):
kép

Currently it raises 3-4x the proposeBlock() consumption, and cca 2x the proveBlock().

@dantaik I guess there is room for some optimization, but would be great if you try it, to reserve the working mechanics/behavior of the code so we dont have to adjust the tests.

I'll try to reach the (as close as possible) same behavior with the Brecht's proposed solution (tho the client interactions will differ a bit) but will give it a shot!

@dantaik dantaik marked this pull request as ready for review June 26, 2023 14:59
@dantaik dantaik merged commit f45966f into alpha-4-base Jun 26, 2023
6 of 7 checks passed
@dantaik dantaik deleted the PoS_initial_impl branch June 26, 2023 14:59
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.

None yet

3 participants