Skip to content

Commit 43a77c2

Browse files
authored
add variable for exit-only consensus (#3207)
1 parent 1884868 commit 43a77c2

File tree

13 files changed

+32
-11
lines changed

13 files changed

+32
-11
lines changed

configs/app/features/beaconChain.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { getEnvValue } from '../utils';
44

55
const title = 'Beacon chain';
66

7-
const config: Feature<{ currency: { symbol: string }; validatorUrlTemplate: string | undefined }> = (() => {
7+
const config: Feature<{ currency: { symbol: string }; validatorUrlTemplate: string | undefined; withdrawalsOnly: boolean }> = (() => {
88
if (getEnvValue('NEXT_PUBLIC_HAS_BEACON_CHAIN') === 'true') {
99
const validatorUrlTemplate = getEnvValue('NEXT_PUBLIC_BEACON_CHAIN_VALIDATOR_URL_TEMPLATE');
10+
const withdrawalsOnly = getEnvValue('NEXT_PUBLIC_BEACON_CHAIN_WITHDRAWALS_ONLY') === 'true';
1011
return Object.freeze({
1112
title,
1213
isEnabled: true,
@@ -17,6 +18,7 @@ const config: Feature<{ currency: { symbol: string }; validatorUrlTemplate: stri
1718
'', // maybe we need some other default value here
1819
},
1920
validatorUrlTemplate,
21+
withdrawalsOnly,
2022
});
2123
}
2224

deploy/tools/envs-validator/schemas/features/beaconChain.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ export const beaconChainSchema = yup
44
.object()
55
.shape({
66
NEXT_PUBLIC_HAS_BEACON_CHAIN: yup.boolean(),
7+
NEXT_PUBLIC_BEACON_CHAIN_WITHDRAWALS_ONLY: yup
8+
.boolean()
9+
.when('NEXT_PUBLIC_HAS_BEACON_CHAIN', {
10+
is: (value: boolean) => value,
11+
then: (schema) => schema,
12+
otherwise: (schema) => schema.test(
13+
'not-exist',
14+
'NEXT_PUBLIC_BEACON_CHAIN_WITHDRAWALS_ONLY can only be used if NEXT_PUBLIC_HAS_BEACON_CHAIN is set to "true"',
15+
value => value === undefined,
16+
),
17+
}),
718
NEXT_PUBLIC_BEACON_CHAIN_CURRENCY_SYMBOL: yup
819
.string()
920
.when('NEXT_PUBLIC_HAS_BEACON_CHAIN', {

deploy/tools/sitemap-generator/next-sitemap.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module.exports = {
8282
break;
8383
case '/batches':
8484
case '/deposits':
85-
if (!process.env.NEXT_PUBLIC_ROLLUP_TYPE) {
85+
if (!process.env.NEXT_PUBLIC_ROLLUP_TYPE && (process.env.NEXT_PUBLIC_HAS_BEACON_CHAIN !== 'true' || process.env.NEXT_PUBLIC_BEACON_CHAIN_WITHDRAWALS_ONLY === 'true')) {
8686
return null;
8787
}
8888
break;

docs/ENVS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ Ads are enabled by default on all self-hosted instances. If you would like to di
506506
| Variable | Type| Description | Compulsoriness | Default value | Example value | Version |
507507
| --- | --- | --- | --- | --- | --- | --- |
508508
| NEXT_PUBLIC_HAS_BEACON_CHAIN | `boolean` | Set to true for networks with the beacon chain | Required | - | `true` | v1.0.x+ |
509+
| NEXT_PUBLIC_BEACON_CHAIN_WITHDRAWALS_ONLY | `boolean` | Set to true for networks that have only withdrawals (no deposits) | - | - | `true` | v2.6.0+ |
509510
| NEXT_PUBLIC_BEACON_CHAIN_CURRENCY_SYMBOL | `string` | Beacon network currency symbol | - | `NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL` | `ETH` | v1.0.x+ |
510511
| NEXT_PUBLIC_BEACON_CHAIN_VALIDATOR_URL_TEMPLATE | `string` | Url template to build a link to validator. Should contain `{pk}` string that will be replaced with the validator's public key | - | - | `https://example.com/beacon/{pk}/validator` | v2.3.0+ |
511512

lib/hooks/useNavItems.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import config from 'configs/app';
77
import { rightLineArrow } from 'toolkit/utils/htmlEntities';
88

99
const marketplaceFeature = config.features.marketplace;
10+
const beaconChainFeature = config.features.beaconChain;
1011

1112
interface ReturnType {
1213
mainNavItems: Array<NavItem | NavGroupItem>;
@@ -224,7 +225,7 @@ export default function useNavItems(): ReturnType {
224225
validators,
225226
verifiedContracts,
226227
nameLookup,
227-
config.features.beaconChain.isEnabled && {
228+
beaconChainFeature.isEnabled && !beaconChainFeature.withdrawalsOnly && {
228229
text: 'Deposits',
229230
nextRoute: { pathname: '/deposits' as const },
230231
icon: 'navigation/deposits',

nextjs/getServerSideProps/guards.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,9 @@ export const rollup: Guard = (chainConfig: typeof config) => async() => {
218218
const DEPOSITS_ROLLUP_TYPES: Array<RollupType> = [ 'optimistic', 'shibarium', 'zkEvm', 'arbitrum', 'scroll' ];
219219
export const deposits: Guard = (chainConfig: typeof config) => async() => {
220220
const rollupFeature = chainConfig.features.rollup;
221+
const beaconChainFeature = chainConfig.features.beaconChain;
221222
if (
222-
!chainConfig.features.beaconChain.isEnabled &&
223+
(!beaconChainFeature.isEnabled || beaconChainFeature.withdrawalsOnly) &&
223224
!(rollupFeature.isEnabled && DEPOSITS_ROLLUP_TYPES.includes(rollupFeature.type))) {
224225
return {
225226
notFound: true,

pages/deposits/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const Deposits = dynamic(() => {
2929
return import('ui/pages/ScrollL2Deposits');
3030
}
3131

32-
if (beaconChainFeature.isEnabled) {
32+
if (beaconChainFeature.isEnabled && !beaconChainFeature.withdrawalsOnly) {
3333
return import('ui/pages/BeaconChainDeposits');
3434
}
3535

ui/block/useBlockDepositsQuery.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ interface Params {
1616
tab: string;
1717
}
1818

19+
const beaconChainFeature = config.features.beaconChain;
20+
1921
// No deposits data in RPC, so we use API only
2022
export default function useBlockDepositsQuery({ heightOrHash, blockQuery, tab }: Params): BlockDepositsQuery {
2123
const apiQuery = useQueryWithPages({
@@ -24,7 +26,7 @@ export default function useBlockDepositsQuery({ heightOrHash, blockQuery, tab }:
2426
options: {
2527
enabled:
2628
tab === 'deposits' &&
27-
config.features.beaconChain.isEnabled &&
29+
beaconChainFeature.isEnabled && !beaconChainFeature.withdrawalsOnly &&
2830
!blockQuery.isPlaceholderData && !blockQuery.isDegradedData,
2931
placeholderData: generateListStub<'general:block_deposits'>(DEPOSIT, 50, { next_page_params: {
3032
index: 5,

ui/deposits/beaconChain/BeaconChainDepositsListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Props = {
2222
};
2323

2424
const BeaconChainDepositsListItem = ({ item, isLoading, view }: Props) => {
25-
if (!feature.isEnabled) {
25+
if (!feature.isEnabled || feature.withdrawalsOnly) {
2626
return null;
2727
}
2828

ui/deposits/beaconChain/BeaconChainDepositsTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Props = {
2121
const BeaconChainDepositsTable = ({ items, isLoading, top, view }: Props) => {
2222
const { cutRef, renderedItemsNum } = useLazyRenderedList(items, !isLoading);
2323

24-
if (!feature.isEnabled) {
24+
if (!feature.isEnabled || feature.withdrawalsOnly) {
2525
return null;
2626
}
2727

0 commit comments

Comments
 (0)