mirror of
https://github.com/ChainSafe/lodestar.git
synced 2026-01-10 08:08:16 -05:00
**Motivation** All networks are post-electra now and transition period is completed, which means due to [EIP-6110](https://eips.ethereum.org/EIPS/eip-6110) we no longer need to process deposits via eth1 bridge as those are now processed by the execution layer. This code is effectively tech debt, no longer exercised and just gets in the way when doing refactors. **Description** Removes all code related to eth1 bridge mechanism to include new deposits - removed all eth1 related code, we can no longer produce blocks with deposits pre-electra (syncing blocks still works) - building a genesis state from eth1 is no longer supported (only for testing) - removed various db repositories related to deposits/eth1 data - removed various `lodestar_eth1_*` metrics and dashboard panels - deprecated all `--eth1.*` flags (but kept for backward compatibility) - moved shared utility functions from eth1 to execution engine module Closes https://github.com/ChainSafe/lodestar/issues/7682 Closes https://github.com/ChainSafe/lodestar/issues/8654
60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
import {ChainForkConfig} from "@lodestar/config";
|
|
import {ForkName, GENESIS_SLOT} from "@lodestar/params";
|
|
import {
|
|
BeaconStateAllForks,
|
|
createEmptyEpochCacheImmutableData,
|
|
initializeBeaconStateFromEth1,
|
|
} from "@lodestar/state-transition";
|
|
import {Bytes32, TimeSeconds, phase0, ssz, sszTypesFor} from "@lodestar/types";
|
|
import {DepositTree} from "./deposits.js";
|
|
|
|
export const INTEROP_BLOCK_HASH = Buffer.alloc(32, "B");
|
|
export const INTEROP_TIMESTAMP = Math.pow(2, 40);
|
|
// Genesis testing settings (spec v1.0.1)
|
|
// Note: These configuration settings do not apply to the mainnet and are utilized only by pure Merge testing.
|
|
export const GENESIS_GAS_LIMIT = 30000000;
|
|
export const GENESIS_BASE_FEE_PER_GAS = BigInt(1000000000);
|
|
|
|
export type InteropStateOpts = {
|
|
genesisTime?: number;
|
|
eth1BlockHash?: Bytes32;
|
|
eth1Timestamp?: TimeSeconds;
|
|
withEth1Credentials?: boolean;
|
|
};
|
|
|
|
// TODO: (@matthewkeil) - Only used by initDevState. Consider combining into that function
|
|
export function getInteropState(
|
|
config: ChainForkConfig,
|
|
{
|
|
genesisTime = Math.floor(Date.now() / 1000),
|
|
eth1BlockHash = INTEROP_BLOCK_HASH,
|
|
eth1Timestamp = INTEROP_TIMESTAMP,
|
|
}: InteropStateOpts,
|
|
deposits: phase0.Deposit[],
|
|
fullDepositDataRootList?: DepositTree
|
|
): BeaconStateAllForks {
|
|
const fork = config.getForkName(GENESIS_SLOT);
|
|
const executionPayloadHeaderType =
|
|
fork !== ForkName.phase0 && fork !== ForkName.altair
|
|
? sszTypesFor(fork).ExecutionPayloadHeader
|
|
: ssz.bellatrix.ExecutionPayloadHeader;
|
|
const latestPayloadHeader = executionPayloadHeaderType.defaultViewDU();
|
|
// TODO: when having different test options, consider modifying these values
|
|
latestPayloadHeader.blockHash = eth1BlockHash;
|
|
latestPayloadHeader.timestamp = eth1Timestamp;
|
|
latestPayloadHeader.prevRandao = eth1BlockHash;
|
|
latestPayloadHeader.gasLimit = GENESIS_GAS_LIMIT;
|
|
latestPayloadHeader.baseFeePerGas = GENESIS_BASE_FEE_PER_GAS;
|
|
const state = initializeBeaconStateFromEth1(
|
|
config,
|
|
createEmptyEpochCacheImmutableData(config, {genesisValidatorsRoot: Buffer.alloc(32, 0)}),
|
|
eth1BlockHash,
|
|
eth1Timestamp,
|
|
deposits,
|
|
fullDepositDataRootList,
|
|
latestPayloadHeader
|
|
);
|
|
state.genesisTime = genesisTime;
|
|
return state;
|
|
}
|