-
Notifications
You must be signed in to change notification settings - Fork 242
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
Conversation
We need to pass some File-path options in some places, enable that.
Still every block...
Mainly differs in setup and simple_withdraw
fb7f8f3
to
afe660d
Compare
There was a problem hiding this 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.
For the contracts it is almost a complete rewrite, so I am not surprised diff's aren't super-helpful. |
There was a problem hiding this 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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) = |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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 inMainStaking
.This PR is supported by the Æternity Foundation