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

Fix and multiple improvements to OracleReportSanityChecker #629

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 83 additions & 24 deletions contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/abi/OracleReportSanityChecker.json

Large diffs are not rendered by default.

170 changes: 40 additions & 130 deletions test/0.4.24/lido-handle-oracle-report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ const { setupNodeOperatorsRegistry } = require('../helpers/staking-modules')

const ONE_YEAR = 3600 * 24 * 365
const ONE_DAY = 3600 * 24
const ORACLE_REPORT_LIMITS_BOILERPLATE = {
churnValidatorsPerDayLimit: 255,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 10000,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
maxAccountingExtraDataListItemsCount: 10000,
maxNodeOperatorsPerExtraDataItemCount: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 1000000000,
}

contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, anotherStranger, depositor, operator]) => {
let deployed, snapshot, lido, treasury, voting, oracle
Expand Down Expand Up @@ -242,16 +253,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
it('does not revert on new total balance decrease under the limit', async () => {
// set oneOffCLBalanceDecreaseBPLimit = 1%
await oracleReportSanityChecker.setOracleReportLimits(
{
churnValidatorsPerDayLimit: 255,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 10000,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 1000000000,
maxAccountingExtraDataListItemsCount: 10000
},
ORACLE_REPORT_LIMITS_BOILERPLATE,
{ from: voting }
)

Expand Down Expand Up @@ -279,16 +281,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
it('reverts on new total balance decrease over the limit', async () => {
// set oneOffCLBalanceDecreaseBPLimit = 1%
await oracleReportSanityChecker.setOracleReportLimits(
{
churnValidatorsPerDayLimit: 255,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 10000,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 1000000000,
maxAccountingExtraDataListItemsCount: 10000
},
ORACLE_REPORT_LIMITS_BOILERPLATE,
{ from: voting }
)

Expand All @@ -309,16 +302,9 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another

it('does not revert on new total balance increase under the limit', async () => {
// set annualBalanceIncreaseBPLimit = 1%
await oracleReportSanityChecker.setOracleReportLimits(
{
churnValidatorsPerDayLimit: 255,
oneOffCLBalanceDecreaseBPLimit: 100,
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
annualBalanceIncreaseBPLimit: 100,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 1000000000,
maxAccountingExtraDataListItemsCount: 10000
},
{ from: voting }
)
Expand Down Expand Up @@ -346,16 +332,9 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another

it('reverts on new total balance increase over the limit', async () => {
// set annualBalanceIncreaseBPLimit = 1%
await oracleReportSanityChecker.setOracleReportLimits(
{
churnValidatorsPerDayLimit: 255,
oneOffCLBalanceDecreaseBPLimit: 100,
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
annualBalanceIncreaseBPLimit: 100,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 1000000000,
maxAccountingExtraDataListItemsCount: 10000
},
{ from: voting }
)
Expand All @@ -378,16 +357,10 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
it('does not revert on validators reported under limit', async () => {
await lido.submit(ZERO_ADDRESS, { from: stranger, value: ETH(3100), gasPrice: 1 })
await lido.deposit(100, 1, '0x', { from: depositor })
await oracleReportSanityChecker.setOracleReportLimits(
{
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
churnValidatorsPerDayLimit: 100,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 100,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 1000000000,
maxAccountingExtraDataListItemsCount: 10000
},
{ from: voting, gasPrice: 1 }
)
Expand All @@ -399,16 +372,10 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
it('reverts on validators reported when over limit', async () => {
await lido.submit(ZERO_ADDRESS, { from: stranger, value: ETH(3200), gasPrice: 1 })
await lido.deposit(101, 1, '0x', { from: depositor })
await oracleReportSanityChecker.setOracleReportLimits(
{
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
churnValidatorsPerDayLimit: 100,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 100,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 1000000000,
maxAccountingExtraDataListItemsCount: 10000
},
{ from: voting, gasPrice: 1 }
)
Expand All @@ -433,16 +400,9 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
})

it('does not smooth if report in limits', async () => {
await oracleReportSanityChecker.setOracleReportLimits(
{
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
churnValidatorsPerDayLimit: 100,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 10000,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 10000000,
maxAccountingExtraDataListItemsCount: 10000
},
{ from: voting, gasPrice: 1 }
)
Expand All @@ -451,16 +411,9 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
})

it('does not smooth if cl balance report over limit', async () => {
await oracleReportSanityChecker.setOracleReportLimits(
{
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
churnValidatorsPerDayLimit: 100,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 10000,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 1000000,
maxAccountingExtraDataListItemsCount: 10000
},
{ from: voting, gasPrice: 1 }
)
Expand All @@ -478,16 +431,10 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
it('does not smooth withdrawals if report in limits', async () => {
await setBalance(withdrawalVault, ETH(1))

await oracleReportSanityChecker.setOracleReportLimits(
{
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
churnValidatorsPerDayLimit: 100,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 10000,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 10000000,
maxAccountingExtraDataListItemsCount: 10000
annualBalanceIncreaseBPLimit: 100,
},
{ from: voting, gasPrice: 1 }
)
Expand All @@ -506,16 +453,10 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
it('smooths withdrawals if report out of limit', async () => {
await setBalance(withdrawalVault, ETH(1.1))

await oracleReportSanityChecker.setOracleReportLimits(
{
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
churnValidatorsPerDayLimit: 100,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 10000,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 10000000,
maxAccountingExtraDataListItemsCount: 10000
},
{ from: voting, gasPrice: 1 }
)
Expand All @@ -535,16 +476,10 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
it('does not smooth el rewards if report in limit without lido fee', async () => {
await setBalance(elRewardsVault, ETH(1))

await oracleReportSanityChecker.setOracleReportLimits(
{
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
churnValidatorsPerDayLimit: 100,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 10000,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 10000000,
maxAccountingExtraDataListItemsCount: 10000
},
{ from: voting, gasPrice: 1 }
)
Expand All @@ -565,16 +500,10 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
it('does not smooth el rewards if report in limit without lido fee', async () => {
await setBalance(elRewardsVault, ETH(1.5))

await oracleReportSanityChecker.setOracleReportLimits(
{
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
churnValidatorsPerDayLimit: 100,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 10000,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 10000000,
maxAccountingExtraDataListItemsCount: 10000
},
{ from: voting, gasPrice: 1 }
)
Expand All @@ -594,16 +523,10 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
it('smooths el rewards if report out of limit without lido fee', async () => {
await setBalance(elRewardsVault, ETH(1.1))

await oracleReportSanityChecker.setOracleReportLimits(
{
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
churnValidatorsPerDayLimit: 100,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 10000,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 10000000,
maxAccountingExtraDataListItemsCount: 10000
},
{ from: voting, gasPrice: 1 }
)
Expand All @@ -623,16 +546,9 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
it('does not smooth el rewards if report in limit', async () => {
await setBalance(elRewardsVault, ETH(1))

await oracleReportSanityChecker.setOracleReportLimits(
{
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
churnValidatorsPerDayLimit: 100,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 10000,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 10000000,
maxAccountingExtraDataListItemsCount: 10000
},
{ from: voting, gasPrice: 1 }
)
Expand All @@ -653,16 +569,10 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , , stranger, another
it('smooths el rewards if report out of limit', async () => {
await setBalance(elRewardsVault, ETH(1.1))

await oracleReportSanityChecker.setOracleReportLimits(
{
await oracleReportSanityChecker.setOracleReportLimits({
...ORACLE_REPORT_LIMITS_BOILERPLATE,
churnValidatorsPerDayLimit: 100,
oneOffCLBalanceDecreaseBPLimit: 100,
annualBalanceIncreaseBPLimit: 10000,
shareRateDeviationBPLimit: 10000,
maxValidatorExitRequestsPerReport: 10000,
requestTimestampMargin: 0,
maxPositiveTokenRebase: 10000000,
maxAccountingExtraDataListItemsCount: 10000
},
{ from: voting, gasPrice: 1 }
)
Expand Down
Loading