Skip to content

Commit

Permalink
Merge pull request #475 from lidofinance/feature/si-1600-whitelist-fo…
Browse files Browse the repository at this point in the history
…r-contract-addresses

Server Fixes
  • Loading branch information
itaven authored Sep 18, 2024
2 parents 9b38d02 + ffed485 commit 7605833
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 113 deletions.
236 changes: 151 additions & 85 deletions abi/lidoLocator.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,134 +2,200 @@
{
"inputs": [
{
"internalType": "address",
"name": "implementation_",
"type": "address"
},
{ "internalType": "address", "name": "admin_", "type": "address" },
{ "internalType": "bytes", "name": "data_", "type": "bytes" }
"components": [
{
"internalType": "address",
"name": "accountingOracle",
"type": "address"
},
{
"internalType": "address",
"name": "depositSecurityModule",
"type": "address"
},
{
"internalType": "address",
"name": "elRewardsVault",
"type": "address"
},
{
"internalType": "address",
"name": "legacyOracle",
"type": "address"
},
{ "internalType": "address", "name": "lido", "type": "address" },
{
"internalType": "address",
"name": "oracleReportSanityChecker",
"type": "address"
},
{
"internalType": "address",
"name": "postTokenRebaseReceiver",
"type": "address"
},
{ "internalType": "address", "name": "burner", "type": "address" },
{
"internalType": "address",
"name": "stakingRouter",
"type": "address"
},
{ "internalType": "address", "name": "treasury", "type": "address" },
{
"internalType": "address",
"name": "validatorsExitBusOracle",
"type": "address"
},
{
"internalType": "address",
"name": "withdrawalQueue",
"type": "address"
},
{
"internalType": "address",
"name": "withdrawalVault",
"type": "address"
},
{
"internalType": "address",
"name": "oracleDaemonConfig",
"type": "address"
}
],
"internalType": "struct LidoLocator.Config",
"name": "_config",
"type": "tuple"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{ "inputs": [], "name": "NotAdmin", "type": "error" },
{ "inputs": [], "name": "ProxyIsOssified", "type": "error" },
{ "inputs": [], "name": "ZeroAddress", "type": "error" },
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "previousAdmin",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "newAdmin",
"type": "address"
}
],
"name": "AdminChanged",
"type": "event"
"inputs": [],
"name": "accountingOracle",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "beacon",
"type": "address"
}
"inputs": [],
"name": "burner",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "coreComponents",
"outputs": [
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" }
],
"name": "BeaconUpgraded",
"type": "event"
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"inputs": [],
"name": "ProxyOssified",
"type": "event"
"name": "depositSecurityModule",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "implementation",
"type": "address"
}
],
"name": "Upgraded",
"type": "event"
"inputs": [],
"name": "elRewardsVault",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{ "stateMutability": "payable", "type": "fallback" },
{
"inputs": [
{ "internalType": "address", "name": "newAdmin_", "type": "address" }
"inputs": [],
"name": "legacyOracle",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lido",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "oracleDaemonConfig",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "oracleReportComponentsForLido",
"outputs": [
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" }
],
"name": "proxy__changeAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "proxy__getAdmin",
"name": "oracleReportSanityChecker",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "proxy__getImplementation",
"name": "postTokenRebaseReceiver",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "proxy__getIsOssified",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"name": "stakingRouter",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "proxy__ossify",
"outputs": [],
"stateMutability": "nonpayable",
"name": "treasury",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newImplementation_",
"type": "address"
}
],
"name": "proxy__upgradeTo",
"outputs": [],
"stateMutability": "nonpayable",
"inputs": [],
"name": "validatorsExitBusOracle",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newImplementation_",
"type": "address"
},
{ "internalType": "bytes", "name": "setupCalldata_", "type": "bytes" },
{ "internalType": "bool", "name": "forceCall_", "type": "bool" }
],
"name": "proxy__upgradeToAndCall",
"outputs": [],
"stateMutability": "nonpayable",
"inputs": [],
"name": "withdrawalQueue",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{ "stateMutability": "payable", "type": "receive" }
{
"inputs": [],
"name": "withdrawalVault",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
}
]
3 changes: 1 addition & 2 deletions config/groups/revalidation.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const DEFAULT_REVALIDATION = 60 * 15; // 15 minutes
export const ERROR_REVALIDATION_SECONDS = 60; // 1 minute
export const DEFAULT_REVALIDATION = 60; // 1 minute
13 changes: 12 additions & 1 deletion features/withdrawals/hooks/contract/useWithdrawalsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { standardFetcher } from 'utils/standardFetcher';
import { default as dynamics } from 'config/dynamics';

import { encodeURLQuery } from 'utils/encodeURLQuery';
import type { WithdrawalQueueAbi } from '@lido-sdk/contracts';

export type WithdrawalRequests = NonNullable<
ReturnType<typeof useWithdrawalRequests>['data']
Expand Down Expand Up @@ -99,7 +100,17 @@ export const useWithdrawalRequests = () => {
}),
contractRpc.getLastCheckpointIndex(),
]);
const requestStatuses = await contractRpc.getWithdrawalStatus(requestIds);

const STATUS_BATCH_SIZE = 500;
const requestStatuses: Awaited<
ReturnType<WithdrawalQueueAbi['getWithdrawalStatus']>
> = [];

for (let i = 0; i < requestIds.length; i += STATUS_BATCH_SIZE) {
const batch = requestIds.slice(i, i + STATUS_BATCH_SIZE);
const batchStatuses = await contractRpc.getWithdrawalStatus(batch);
requestStatuses.push(...batchStatuses);
}

const claimableRequests: RequestStatus[] = [];
const pendingRequests: RequestStatusPending[] = [];
Expand Down
6 changes: 4 additions & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import { startupCheckRPCs } from './scripts/startup-checks/rpc.mjs';
logEnvironmentVariables();
buildDynamics();

if (process.env.RUN_STARTUP_CHECKS === 'true' && typeof window === 'undefined') {
if (
process.env.RUN_STARTUP_CHECKS === 'true' &&
typeof window === 'undefined'
) {
void startupCheckRPCs();
}


// https://nextjs.org/docs/pages/api-reference/next-config-js/basePath
const basePath = process.env.BASE_PATH;

Expand Down
10 changes: 8 additions & 2 deletions server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const overrideSetHeader = (res) => {

// eslint-disable-next-line @typescript-eslint/no-floating-promises
app.prepare().then(() => {
createServer(async (req, res) => {
const server = createServer(async (req, res) => {
// Be sure to pass `true` as the second argument to `url.parse`.
// This tells it to parse the query portion of the URL.
const parsedUrl = parse(req.url, true);
Expand All @@ -46,5 +46,11 @@ app.prepare().then(() => {
})
.listen(port, () => {
console.debug(`> Ready on http://${hostname}:${port}`);
});
})
// hanging socket timeout
.setTimeout(10_000);
// prevents malicious client from slowly sending headers and rest of request
server.headersTimeout = 10_000;
server.requestTimeout = 30_000;
server.maxHeadersCount = 50;
});
6 changes: 1 addition & 5 deletions utilsApi/fetch-external-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import FallbackLocalManifest from 'IPFS.json' assert { type: 'json' };

export type ExternalConfigResult = {
___prefetch_manifest___: object | null;
revalidate: number;
};

const cache = new Cache<
Expand All @@ -25,7 +24,6 @@ export const fetchExternalManifest = async () => {
if (config.ipfsMode) {
return {
___prefetch_manifest___: FallbackLocalManifest,
revalidate: config.DEFAULT_REVALIDATION,
};
}

Expand All @@ -44,7 +42,6 @@ export const fetchExternalManifest = async () => {

const result = {
___prefetch_manifest___: data,
revalidate: config.DEFAULT_REVALIDATION,
};

cache.put(
Expand All @@ -68,10 +65,9 @@ export const fetchExternalManifest = async () => {
}
}
console.error(
`[fetchExternalManifest] failed to fetch external manifest after retries, revalidation is set to ${config.ERROR_REVALIDATION_SECONDS}`,
`[fetchExternalManifest] failed to fetch external manifest after retries`,
);
return {
revalidate: config.ERROR_REVALIDATION_SECONDS,
___prefetch_manifest___: FallbackLocalManifest,
};
};
Loading

0 comments on commit 7605833

Please sign in to comment.