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

More efficient accounting oracle #589

Merged

Conversation

skozin
Copy link
Member

@skozin skozin commented Feb 9, 2023

Avoids non-trivial processing of exited/stuck validators report data in the accounting oracle by using bytes packing in the Staking Router's methods that receive the data from the oracle.

Gets rid of the hardly-explainable and non-semantical extraDataMaxNodeOpsCountByModule report field. ResizableArray is not needed anymore.

Should be significantly more gas-efficient than the current impl.

@skozin skozin changed the base branch from master to feature/shapella-upgrade February 9, 2023 20:15
Comment on lines +778 to +784
if (itemType == EXTRA_DATA_TYPE_EXITED_VALIDATORS ||
itemType == EXTRA_DATA_TYPE_STUCK_VALIDATORS
) {
_processExtraDataItem(data, iter);
} else {
revert UnsupportedExtraDataType(index, itemType);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

_processExtraDataItem handles specific two item types, this may not be flexible enough. Not sure if solidity allows it, but something like this might be more flexible and improve the semantics:

if (itemType == EXTRA_DATA_TYPE_EXITED_VALIDATORS) {
    (uint256 moduleId, bytes calldata nodeOpIds, bytes calldata valsCounts) = _extractKeysCounts(data, iter);
    IStakingRouter(iter.stakingRouter)
        .reportStakingModuleExitedKeysCountByNodeOperator(moduleId, nodeOpIds, valsCounts);
} else if (itemType == EXTRA_DATA_TYPE_STUCK_VALIDATORS) {
    (uint256 moduleId, bytes calldata nodeOpIds, bytes calldata valsCounts) = _extractKeysCounts(data, iter);
    IStakingRouter(iter.stakingRouter)
        .reportStakingModuleStuckKeysCountByNodeOperator(moduleId, nodeOpIds, valsCounts);
} else {
    revert UnsupportedExtraDataType(index, itemType);
}
  1. rename _processExtraDataItem into something more specific that performs the key extraction, like _extractKeysCounts
  2. move Staking Router methods calls from _extractKeysCounts here

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, this structuring would be better, and Solidity allows this. I'll try finding time to improve as you suggested

contracts/0.8.9/oracle/AccountingOracle.sol Outdated Show resolved Hide resolved
contracts/0.8.9/oracle/AccountingOracle.sol Outdated Show resolved Hide resolved
contracts/0.8.9/oracle/AccountingOracle.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@TheDZhon TheDZhon left a comment

Choose a reason for hiding this comment

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

Thank you 🚀
Gonna be the most efficient way of passing data 💯

@TheDZhon TheDZhon merged commit 82e423a into feature/shapella-upgrade Feb 10, 2023
@TheDZhon TheDZhon deleted the feature/more-efficient-accounting-oracle branch February 10, 2023 10:46
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