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

Service staking refactor #120

Merged
merged 7 commits into from
Oct 6, 2023
Merged

Service staking refactor #120

merged 7 commits into from
Oct 6, 2023

Conversation

kupermind
Copy link
Collaborator

  • Service staking implementation accounting for latest suggestions;
  • Adding more tests.

@kupermind kupermind requested review from 77ph and mariapiamo October 3, 2023 07:44
// Optional service multisig threshold requirement
uint256 public immutable threshold;
// Optional service number of agent instances requirement
uint256 public immutable numAgentInstances;
Copy link
Collaborator

Choose a reason for hiding this comment

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

According to the specifications, the agent instance is not an optional parameter.

revert WrongServiceConfiguration(serviceId);
}
// Check the threshold, if applicable
if (threshold > 0 && threshold != minNumAgents) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We might consider replacing minNumAgents with agentThreshold to improve the clarity of this check

@@ -191,7 +281,6 @@ abstract contract ServiceStakingBase is IErrorsRegistries {
/// @param eligibleServiceIds Service Ids eligible for rewards.
/// @param eligibleServiceRewards Corresponding rewards for eligible service Ids.
/// @param serviceIds All the staking service Ids.
/// @param serviceNonces Current service nonces.
Copy link
Collaborator

Choose a reason for hiding this comment

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

why this comment was removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was from the previous PR when this was considered obsolete, I've changed that now.

uint256 serviceCheckpoint = tsCheckpointLast;
uint256 tsStart = curInfo.tsStart;
// Adjust the service checkpoint time if the service was staking less than the current staking period
if (tsStart > serviceCheckpoint) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

With this approach, we are not forcing a service to be staked for the entire liveness period. As we did previously, service multisigs that pass the liveness check will be considered for incentives, even if they have been staked for less than the liveness period. Is that correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is correct, as the checkpoint is a centralization point and everybody eligible must account for their rewards.

}
// Calculate the liveness ratio in 1e18 value
uint256 ratio;
// If the checkpoint was called in the exactly same block, the ratio is zero
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the checkpoint was called in the exactly same block, we do not reach this part. No?

Copy link
Collaborator Author

@kupermind kupermind Oct 3, 2023

Choose a reason for hiding this comment

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

I think it is possible if someone calls staking and checkpoint in the same block. There will be a test for it.

Comment on lines +183 to +195
// Assign agent Ids, if applicable
uint256 size = _stakingParams.agentIds.length;
uint256 agentId;
if (size > 0) {
for (uint256 i = 0; i < size; ++i) {
// Agent Ids must be unique and in ascending order
if (_stakingParams.agentIds[i] <= agentId) {
revert WrongAgentId(_stakingParams.agentIds[i]);
}
agentId = _stakingParams.agentIds[i];
agentIds.push(agentId);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this guaranteed by the registry already?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Staking service agent Ids must match the staking contract configuration. We want to ensure at least the minimum order requirement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When staking, the service agents are extracted from the service and must match the provided agent Ids configuration.

Base automatically changed from service_staking_tests to main October 6, 2023 13:32
@kupermind kupermind merged commit d32ff3f into main Oct 6, 2023
2 checks passed
@kupermind kupermind deleted the service_staking2 branch October 6, 2023 13:32
77ph pushed a commit that referenced this pull request Oct 12, 2023
Update Docs: Autonolas_tokenomics_audit
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.

4 participants