8000 Staking contracts overhaul by hanssv · Pull Request #4504 · aeternity/aeternity · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Staking contracts overhaul #4504

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

Merged
merged 11 commits into from
Dec 2, 2024
Merged

Staking contracts overhaul #4504

merged 11 commits into from
Dec 2, 2024

Conversation

hanssv
Copy link
Member
@hanssv hanssv commented Nov 27, 2024

New staking contracts...

Hyperchains suite passes, and a new rather sparse staking contract suite also works.

Rewards are accumulated in the election contract and then distributed to stakers at the end of epoch (with one epoch delay). Each staker has a StakingValidator contract, created through a factory in MainStaking.

This PR is supported by the Æternity Foundation

@hanssv hanssv force-pushed the staking_contracts_overhaul branch from fb7f8f3 to afe660d Compare November 28, 2024 10:09
@hanssv hanssv marked this pull request as ready for review November 28, 2024 12:49
Copy link
Contributor
@happi happi left a comment

Choose a reason for hiding this comment

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

Hard to read the diffs, had to checkout out locally to read the contracts.

@hanssv
Copy link
Member Author
hanssv commented Nov 29, 2024

Hard to read the diffs, had to checkout out locally to read the contracts.

For the contracts it is almost a complete rewrite, so I am not surprised diff's aren't super-helpful.

@hanssv hanssv mentioned this pull request Nov 29, 2024
Copy link
Contributor
@ThomasArts ThomasArts left a comment

Choose a reason for hiding this comment

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

Good enough to merge.
Bookkeeping of rewards not totally clear to me

shares_to_ae(state.delegates[who = 0])
payable stateful entrypoint stake() =
require(Call.value > 0, "Stake must be positive")
assert_owner_caller()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add the callback contract to the permitted callers, so that funds provided by delegators could get routed through to the main contract in favour of this StakingValidator ? Unsure about how that plays together with the explicit need to deposit before staking though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Correcting myself after the last call, the delegation contract is the owner, right ? But this would also mean the delegation contract would have to be the one that deploys this contract, correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

It isn't deployed it is created through the factory in MainStaking. But you have pointed at a possible issue - the (delegation) contract will be the owner, but then we need a different/separate key-pair for signing blocks. Right @thepiwo?

stateful entrypoint set_description(description : string) =
assert_caller()
put(state{description = description})
stateful entrypoint withdraw(amount : int) =
Copy link
Contributor

Choose a reason for hiding this comment

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

same here as above

assert_main_staking_caller()
switch(state.reward_callback)
None => ()
Some(cb_ct) => cb_ct.reward_cb(epoch, amount, restaked)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we add protected = true here, if this is called by the mainstaking itself so it's not exposed to (un)intentional errors in the callback function?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is probably a good idea 👍 - I haven't had time to test in that detail yet.

@hanssv hanssv merged commit 0a6e9a9 into master Dec 2, 2024
40 checks passed
@hanssv hanssv deleted the staking_contracts_overhaul branch December 2, 2024 10:31
@dincho dincho added the kind/feature Issues or PRs related to a new feature label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hyperchains 57FB kind/feature Issues or PRs related to a new feature
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

5 participants
0