-
Notifications
You must be signed in to change notification settings - Fork 50
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
Epoch phase performance improvements, access node open slot limits, and EpochStart
event
#379
Conversation
169242a
to
6fc75a3
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.
Can you explain in more detail why we can do this? I'm not sure I understand.
If the rewards are calculated earlier is there not a chance they would change?
I'm moving the rewards calculation to earlier so that it doesn't have to happen in the same transaction where the epoch transitions and tokens are moved. We currently don't have any logic to change rewards once they have been calculated anyway, so it doesn't really matter if they are calculated earlier. |
EpochStart
event
@jordanschalm No rush, but I could use another review on this when you get the chance. We could also schedule a call so I can walk you through the changes if you need help |
70bd277
to
4f5c45a
Compare
33795ec
to
c3dac9b
Compare
@jordanschalm Can you take a look at my last two commits? I've added in all the performance improvements we discussed this week |
ec49fc8
to
8bffe8b
Compare
I think it is very important that every set of service chunk events that transitions something contains the counter field. Atm NewEpoch and Payout event from FlowIDTableStaking does not contain this. This makes it very hard to identify what epoch this payout was for. In some cases these events happen before NewEpoch and in others it hapends after. If we have to "fix stuff" |
@bjartek That would be nice to have, but that might require the staking contract to import the |
Is it possible to have another event emitted when rewards are paid from FlowEpoch that has the counter? |
Assuming it's relatively straightforward, I think we should just do this and include the epoch counter in all events where it could be useful. Inferring auxiliary data about events based on the current state when they are emitted, or based on other events, is error-prone and more complex. |
Okay. I'll add those to the events in the staking contract then |
* add duration to EpochSetup This is needed to compute tau, the steady-state optimal time/view, in the cruise control system * update generated files * update tests * tidy * tidy
I did the upgrade on canary and everything seems to be working properly. We'll upgrade testnet on monday the 27th and stick with the dec 6th mainnet upgrade. I'm going to go ahead and merge this though unless anyone has any objections |
Makes three changes to improve the performance of the epoch transition:
Moves
FlowEpoch.calculateAndSetRewards
to the end of the epoch setup phase/beginning of epoch commit, which currently does not have much complexity. This removes calculating rewards from the end of the epoch, which when combined withmoveTokens
, was causing the execution to take a long time.Changes
FlowIDTableStaking.setNewMovesPending()
to be able to add a new node or delegator to the moves pending list without loading and storing to and from storage. If many nodes and delegators were unstaking tokens, this was very costly at the end of each epoch. The change uses a reference to allow the moves pending list to be modified in memory and not loaded or stored during node registration transactions.Updates the methods that are run at the end of the service auction to construct the proposed Node ID list as they go instead of the epoch contract having to query it fully at the end, which requires iterating through all nodes in the identity table to construct it.
Adds some new features to the epoch and staking contracts
Adds a
FlowEpoch.EpochStart
event that is emitted at the start of every epoch and includes important information related toFlowToken
and epoch information.Adds a feature to open up new access node slots each epoch instead of the service account committee having to do it manually
Also updates some comments and error messages for some transactions
No tests are needed for the first two improvements because they don't affect the behavior of the contracts, just the performance